• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "dscreen_source_stub_test.h"
17 #include "dscreen_constants.h"
18 
19 #include <memory>
20 
21 using namespace testing;
22 using namespace testing::ext;
23 
24 namespace OHOS {
25 namespace DistributedHardware {
SetUpTestCase(void)26 void DScreenSourceStubTest::SetUpTestCase(void)
27 {
28 }
29 
TearDownTestCase(void)30 void DScreenSourceStubTest::TearDownTestCase(void)
31 {
32 }
33 
SetUp(void)34 void DScreenSourceStubTest::SetUp(void)
35 {
36 }
37 
TearDown(void)38 void DScreenSourceStubTest::TearDown(void)
39 {
40 }
41 
InitSource(const std::string & params,const sptr<IDScreenSourceCallback> & callback)42 int32_t DScreenSourceStubTest::TestDScreenSourceStub::InitSource(const std::string &params,
43     const sptr<IDScreenSourceCallback> &callback)
44 {
45     (void)params;
46     (void)callback;
47     return DH_SUCCESS;
48 }
49 
ReleaseSource()50 int32_t DScreenSourceStubTest::TestDScreenSourceStub::ReleaseSource()
51 {
52     return DH_SUCCESS;
53 }
54 
RegisterDistributedHardware(const std::string & devId,const std::string & dhId,const EnableParam & param,const std::string & reqId)55 int32_t DScreenSourceStubTest::TestDScreenSourceStub::RegisterDistributedHardware(const std::string &devId,
56     const std::string &dhId, const EnableParam &param, const std::string &reqId)
57 {
58     (void)devId;
59     (void)dhId;
60     (void)param;
61     (void)reqId;
62     return DH_SUCCESS;
63 }
64 
UnregisterDistributedHardware(const std::string & devId,const std::string & dhId,const std::string & reqId)65 int32_t DScreenSourceStubTest::TestDScreenSourceStub::UnregisterDistributedHardware(const std::string &devId,
66     const std::string &dhId, const std::string &reqId)
67 {
68     (void)devId;
69     (void)dhId;
70     (void)reqId;
71     return DH_SUCCESS;
72 }
73 
ConfigDistributedHardware(const std::string & devId,const std::string & dhId,const std::string & key,const std::string & value)74 int32_t DScreenSourceStubTest::TestDScreenSourceStub::ConfigDistributedHardware(const std::string &devId,
75     const std::string &dhId, const std::string &key, const std::string &value)
76 {
77     (void)devId;
78     (void)dhId;
79     (void)key;
80     (void)value;
81     return DH_SUCCESS;
82 }
83 
DScreenNotify(const std::string & devId,int32_t eventCode,const std::string & eventContent)84 void DScreenSourceStubTest::TestDScreenSourceStub::DScreenNotify(const std::string &devId, int32_t eventCode,
85     const std::string &eventContent)
86 {
87     devId_ = devId;
88     eventCode_ = eventCode;
89     eventContent_ = eventContent;
90 }
91 
92 /**
93  * @tc.name: InitSource_001
94  * @tc.desc: Invoke the InitSource ipc interface.
95  * @tc.type: FUNC
96  * @tc.require: Issue Number
97  */
98 HWTEST_F(DScreenSourceStubTest, InitSource_001, TestSize.Level1)
99 {
100     sptr<IRemoteObject> sourceStubPtr(new TestDScreenSourceStub());
101     DScreenSourceProxy sourceProxy(sourceStubPtr);
102 
103     sptr<DScreenSourceCallback> callback;
104     int32_t ret = sourceProxy.InitSource("", callback);
105     EXPECT_EQ(ERR_DH_SCREEN_INPUT_PARAM_INVALID, ret);
106 
107     ret = sourceProxy.InitSource("params000", callback);
108     EXPECT_EQ(ERR_DH_SCREEN_INPUT_PARAM_INVALID, ret);
109 
110     callback = new DScreenSourceCallback();
111     ret = sourceProxy.InitSource("params000", callback);
112     EXPECT_EQ(DH_SUCCESS, ret);
113 }
114 
115 /**
116  * @tc.name: ReleaseSource_001
117  * @tc.desc: Invoke the ReleaseSource ipc interface.
118  * @tc.type: FUNC
119  * @tc.require: Issue Number
120  */
121 HWTEST_F(DScreenSourceStubTest, ReleaseSource_001, TestSize.Level1)
122 {
123     sptr<IRemoteObject> sourceStubPtr(new TestDScreenSourceStub());
124     DScreenSourceProxy sourceProxy(sourceStubPtr);
125     int32_t ret = sourceProxy.ReleaseSource();
126     EXPECT_EQ(DH_SUCCESS, ret);
127 }
128 
129 /**
130  * @tc.name: RegisterDistributedHardware_001
131  * @tc.desc: Invoke the RegisterDistributedHardware ipc interface.
132  * @tc.type: FUNC
133  * @tc.require: Issue Number
134  */
135 HWTEST_F(DScreenSourceStubTest, RegisterDistributedHardware_001, TestSize.Level1)
136 {
137     sptr<IRemoteObject> sourceStubPtr(new TestDScreenSourceStub());
138     DScreenSourceProxy sourceProxy(sourceStubPtr);
139 
140     EnableParam param;
141     param.sinkVersion = "";
142     param.sinkAttrs = "";
143     int32_t ret = sourceProxy.RegisterDistributedHardware("", "dhId000", param, "reqId000");
144     EXPECT_EQ(ERR_DH_SCREEN_INPUT_PARAM_INVALID, ret);
145 
146     std::string devId = R"(dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000d
147         Id000dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000d
148         hId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000)";
149     ret = sourceProxy.RegisterDistributedHardware(devId, "dhId000", param, "reqId000");
150     EXPECT_EQ(ERR_DH_SCREEN_INPUT_PARAM_INVALID, ret);
151 
152     ret = sourceProxy.RegisterDistributedHardware("devId000", "", param, "reqId000");
153     EXPECT_EQ(ERR_DH_SCREEN_INPUT_PARAM_INVALID, ret);
154 
155     ret = sourceProxy.RegisterDistributedHardware("devId000", devId, param, "reqId000");
156     EXPECT_EQ(ERR_DH_SCREEN_INPUT_PARAM_INVALID, ret);
157 
158     ret = sourceProxy.RegisterDistributedHardware("devId000", "dhId000", param, "");
159     EXPECT_EQ(ERR_DH_SCREEN_INPUT_PARAM_INVALID, ret);
160 
161     ret = sourceProxy.RegisterDistributedHardware("devId000", "dhId000", param, devId);
162     EXPECT_EQ(ERR_DH_SCREEN_INPUT_PARAM_INVALID, ret);
163 
164     ret = sourceProxy.RegisterDistributedHardware("devId000", "dhId000", param, "reqId000");
165     EXPECT_EQ(ERR_DH_SCREEN_INPUT_PARAM_INVALID, ret);
166 
167     param.sinkVersion = "1";
168     ret = sourceProxy.RegisterDistributedHardware("devId000", "dhId000", param, "reqId000");
169     EXPECT_EQ(ERR_DH_SCREEN_INPUT_PARAM_INVALID, ret);
170 
171     param.sinkAttrs = "attrs";
172     ret = sourceProxy.RegisterDistributedHardware("devId000", "dhId000", param, "reqId000");
173     EXPECT_EQ(DH_SUCCESS, ret);
174 }
175 
176 /**
177  * @tc.name: UnregisterDistributedHardware_001
178  * @tc.desc: Invoke the UnregisterDistributedHardware ipc interface.
179  * @tc.type: FUNC
180  * @tc.require: Issue Number
181  */
182 HWTEST_F(DScreenSourceStubTest, UnregisterDistributedHardware_001, TestSize.Level1)
183 {
184     sptr<IRemoteObject> sourceStubPtr(new TestDScreenSourceStub());
185     DScreenSourceProxy sourceProxy(sourceStubPtr);
186 
187     int32_t ret = sourceProxy.UnregisterDistributedHardware("", "dhId000", "reqId000");
188     EXPECT_EQ(ERR_DH_SCREEN_INPUT_PARAM_INVALID, ret);
189 
190     std::string devId = R"(dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000d
191         Id000dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000d
192         hId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000)";
193     ret = sourceProxy.UnregisterDistributedHardware(devId, "dhId000", "reqId000");
194     EXPECT_EQ(ERR_DH_SCREEN_INPUT_PARAM_INVALID, ret);
195 
196     ret = sourceProxy.UnregisterDistributedHardware("devId000", "", "reqId000");
197     EXPECT_EQ(ERR_DH_SCREEN_INPUT_PARAM_INVALID, ret);
198 
199     ret = sourceProxy.UnregisterDistributedHardware("devId000", devId, "reqId000");
200     EXPECT_EQ(ERR_DH_SCREEN_INPUT_PARAM_INVALID, ret);
201 
202     ret = sourceProxy.UnregisterDistributedHardware("devId000", "dhId000", "");
203     EXPECT_EQ(ERR_DH_SCREEN_INPUT_PARAM_INVALID, ret);
204 
205     ret = sourceProxy.UnregisterDistributedHardware("devId000", "dhId000", devId);
206     EXPECT_EQ(ERR_DH_SCREEN_INPUT_PARAM_INVALID, ret);
207 
208     ret = sourceProxy.UnregisterDistributedHardware("devId000", "dhId000", "reqId000");
209     EXPECT_EQ(DH_SUCCESS, ret);
210 }
211 
212 /**
213  * @tc.name: ConfigDistributedHardware_001
214  * @tc.desc: Invoke the ConfigDistributedHardware ipc interface.
215  * @tc.type: FUNC
216  * @tc.require: Issue Number
217  */
218 HWTEST_F(DScreenSourceStubTest, ConfigDistributedHardware_001, TestSize.Level1)
219 {
220     sptr<IRemoteObject> sourceStubPtr(new TestDScreenSourceStub());
221     DScreenSourceProxy sourceProxy(sourceStubPtr);
222 
223     int32_t ret = sourceProxy.ConfigDistributedHardware("", "dhId000", "key000", "value000");
224     EXPECT_EQ(ERR_DH_SCREEN_INPUT_PARAM_INVALID, ret);
225 
226     std::string devId = R"(dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000d
227         Id000dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000d
228         hId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000)";
229     ret = sourceProxy.ConfigDistributedHardware(devId, "dhId000", "key000", "value000");
230     EXPECT_EQ(ERR_DH_SCREEN_INPUT_PARAM_INVALID, ret);
231 
232     ret = sourceProxy.ConfigDistributedHardware("devId000", "", "key000", "value000");
233     EXPECT_EQ(ERR_DH_SCREEN_INPUT_PARAM_INVALID, ret);
234 
235     ret = sourceProxy.ConfigDistributedHardware("devId000", devId, "key000", "value000");
236     EXPECT_EQ(ERR_DH_SCREEN_INPUT_PARAM_INVALID, ret);
237 
238     ret = sourceProxy.ConfigDistributedHardware("devId000", "dhId000", "", "value000");
239     EXPECT_EQ(ERR_DH_SCREEN_INPUT_PARAM_INVALID, ret);
240 
241     ret = sourceProxy.ConfigDistributedHardware("devId000", "dhId000", "key000", "");
242     EXPECT_EQ(ERR_DH_SCREEN_INPUT_PARAM_INVALID, ret);
243 
244     ret = sourceProxy.ConfigDistributedHardware("devId000", "dhId000", "key000", "value000");
245     EXPECT_EQ(DH_SUCCESS, ret);
246 }
247 
248 /**
249  * @tc.name: DScreenNotify_001
250  * @tc.desc: Invoke the DScreenNotify ipc interface.
251  * @tc.type: FUNC
252  * @tc.require: Issue Number
253  */
254 HWTEST_F(DScreenSourceStubTest, DScreenNotify_001, TestSize.Level1)
255 {
256     sptr<IRemoteObject> sourceStubPtr(new TestDScreenSourceStub());
257     DScreenSourceProxy sourceProxy(sourceStubPtr);
258 
259     sourceProxy.DScreenNotify("", 0, "eventContent000");
260 
261     std::string longString = R"(dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000d
262         Id000dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000d
263         hId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000dhId000)";
264     sourceProxy.DScreenNotify(longString, 0, "eventContent000");
265 
266     sourceProxy.DScreenNotify("devId000", 0, "");
267 
268     std::string devId = "devId000";
269     int32_t eventCode = 0;
270     std::string eventContent = "eventContent000";
271     sourceProxy.DScreenNotify(devId, eventCode, eventContent);
272     EXPECT_STREQ(devId.c_str(), ((sptr<TestDScreenSourceStub> &)sourceStubPtr)->devId_.c_str());
273     EXPECT_EQ(eventCode, ((sptr<TestDScreenSourceStub> &)sourceStubPtr)->eventCode_);
274     EXPECT_STREQ(eventContent.c_str(), ((sptr<TestDScreenSourceStub> &)sourceStubPtr)->eventContent_.c_str());
275 }
276 
277 /**
278  * @tc.name: OnRemoteRequest_001
279  * @tc.desc: Test with valid interface descriptor and request code.
280  * @tc.type: FUNC
281  * @tc.require: Issue Number
282  */
283 HWTEST_F(DScreenSourceStubTest, OnRemoteRequest_001, TestSize.Level1)
284 {
285     std::shared_ptr<TestDScreenSourceStub> stubPtr = std::make_shared<TestDScreenSourceStub>();
286     uint32_t requestCode = 1;
287     MessageParcel data;
288     data.WriteInterfaceToken(stubPtr->GetDescriptor());
289     data.WriteUint32(requestCode);
290     MessageParcel reply;
291     MessageOption option;
292     int32_t result = stubPtr->OnRemoteRequest(requestCode, data, reply, option);
293     EXPECT_EQ(SESSION_UNOPEN_ERR, result);
294 }
295 
296 /**
297  * @tc.name: OnRemoteRequest_002
298  * @tc.desc: Test with invalid interface descriptor.
299  * @tc.type: FUNC
300  * @tc.require: Issue Number
301  */
302 HWTEST_F(DScreenSourceStubTest, OnRemoteRequest_002, TestSize.Level1)
303 {
304     std::shared_ptr<TestDScreenSourceStub> stubPtr = std::make_shared<TestDScreenSourceStub>();
305     std::u16string requestDescriptor = u"invalid_descriptor";
306     uint32_t requestCode = 1;
307     MessageParcel data;
308     data.WriteInterfaceToken(requestDescriptor);
309     data.WriteUint32(requestCode);
310     MessageParcel reply;
311     MessageOption option;
312     int32_t result = stubPtr->OnRemoteRequest(requestCode, data, reply, option);
313     EXPECT_EQ(ERR_INVALID_DATA, result);
314 }
315 
316 /**
317  * @tc.name: OnRemoteRequest_003
318  * @tc.desc: Test with invalid request code.
319  * @tc.type: FUNC
320  * @tc.require: Issue Number
321  */
322 HWTEST_F(DScreenSourceStubTest, OnRemoteRequest_003, TestSize.Level1)
323 {
324     std::shared_ptr<TestDScreenSourceStub> stubPtr = std::make_shared<TestDScreenSourceStub>();
325     std::u16string descriptor = DScreenSourceStub::GetDescriptor();
326     std::u16string requestDescriptor = descriptor;
327     uint32_t requestCode = 999;
328     MessageParcel data;
329     data.WriteInterfaceToken(requestDescriptor);
330     data.WriteUint32(requestCode);
331     MessageParcel reply;
332     MessageOption option;
333     int32_t result = stubPtr->OnRemoteRequest(requestCode, data, reply, option);
334     EXPECT_EQ(IPC_STUB_UNKNOW_TRANS_ERR, result);
335 }
336 
337 /**
338  * @tc.name: InitSourceInner_001
339  * @tc.desc: When there is no permission
340  * @tc.type: FUNC
341  * @tc.require: Issue Number
342  */
343 HWTEST_F(DScreenSourceStubTest, InitSourceInner_001, TestSize.Level1)
344 {
345     std::shared_ptr<TestDScreenSourceStub> stubPtr = std::make_shared<TestDScreenSourceStub>();
346     std::u16string descriptor = stubPtr->GetDescriptor();
347     MessageParcel data;
348     MessageParcel reply;
349     MessageOption option;
350     int32_t result = stubPtr->InitSourceInner(data, reply, option);
351     EXPECT_EQ(DSCREEN_INIT_ERR, result);
352 }
353 
354 /**
355  * @tc.name: ReleaseSourceInner_001
356  * @tc.desc: When there is no permission
357  * @tc.type: FUNC
358  * @tc.require: Issue Number
359  */
360 HWTEST_F(DScreenSourceStubTest, ReleaseSourceInner_001, TestSize.Level1)
361 {
362     std::shared_ptr<TestDScreenSourceStub> stubPtr = std::make_shared<TestDScreenSourceStub>();
363     std::u16string descriptor = stubPtr->GetDescriptor();
364     MessageParcel data;
365     MessageParcel reply;
366     MessageOption option;
367     int32_t result = stubPtr->ReleaseSourceInner(data, reply, option);
368     EXPECT_EQ(DSCREEN_INIT_ERR, result);
369 }
370 
371 /**
372  * @tc.name: RegisterDistributedHardwareInner_001
373  * @tc.desc: When there is no permission
374  * @tc.type: FUNC
375  * @tc.require: Issue Number
376  */
377 HWTEST_F(DScreenSourceStubTest, RegisterDistributedHardwareInner_001, TestSize.Level1)
378 {
379     std::shared_ptr<TestDScreenSourceStub> stubPtr = std::make_shared<TestDScreenSourceStub>();
380     std::u16string descriptor = stubPtr->GetDescriptor();
381     MessageParcel data;
382     MessageParcel reply;
383     MessageOption option;
384     int32_t result = stubPtr->RegisterDistributedHardwareInner(data, reply, option);
385     EXPECT_EQ(DSCREEN_INIT_ERR, result);
386 }
387 
388 /**
389  * @tc.name: CheckRegParams_001
390  * @tc.desc: ValidParams
391  * @tc.type: FUNC
392  * @tc.require: Issue Number
393  */
394 HWTEST_F(DScreenSourceStubTest, CheckRegParams_001, TestSize.Level1)
395 {
396     std::shared_ptr<TestDScreenSourceStub> stubPtr = std::make_shared<TestDScreenSourceStub>();
397     bool result = stubPtr->CheckRegParams("devId", "dhId", "version", "attrs", "reqId");
398     EXPECT_TRUE(result);
399 }
400 
401 /**
402  * @tc.name: CheckRegParams_002
403  * @tc.desc: Parameter is empty
404  * @tc.type: FUNC
405  * @tc.require: Issue Number
406  */
407 
408 HWTEST_F(DScreenSourceStubTest, CheckRegParams_002, TestSize.Level1)
409 {
410     std::shared_ptr<TestDScreenSourceStub> stubPtr = std::make_shared<TestDScreenSourceStub>();
411     bool result;
412     result = stubPtr->CheckRegParams("", "dhId", "version", "attrs", "reqId");
413     EXPECT_FALSE(result);
414     result = stubPtr->CheckRegParams("devId", "", "version", "attrs", "reqId");
415     EXPECT_FALSE(result);
416     result = stubPtr->CheckRegParams("devId", "dhId", "", "attrs", "reqId");
417     EXPECT_FALSE(result);
418     result = stubPtr->CheckRegParams("devId", "dhId", "version", "", "reqId");
419     EXPECT_FALSE(result);
420     result = stubPtr->CheckRegParams("devId", "dhId", "version", "attrs", "");
421     EXPECT_FALSE(result);
422 }
423 
424 /**
425  * @tc.name: CheckRegParams_003
426  * @tc.desc: parameter exceeds maximum length
427  * @tc.type: FUNC
428  * @tc.require: Issue Number
429  */
430 
431 HWTEST_F(DScreenSourceStubTest, CheckRegParams_003, TestSize.Level1)
432 {
433     std::shared_ptr<TestDScreenSourceStub> stubPtr = std::make_shared<TestDScreenSourceStub>();
434     std::string exceedDidMaxSizeStr(DID_MAX_SIZE + 1, 'a');
435     std::string exceedParamMaxSizeStr(PARAM_MAX_SIZE + 1, 'a');
436     bool result;
437     result = stubPtr->CheckRegParams(exceedDidMaxSizeStr, "dhId", "version", "attrs", "reqId");
438     EXPECT_FALSE(result);
439     result = stubPtr->CheckRegParams("devId", exceedDidMaxSizeStr, "version", "attrs", "reqId");
440     EXPECT_FALSE(result);
441     result = stubPtr->CheckRegParams("devId", "dhId", exceedParamMaxSizeStr, "attrs", "reqId");
442     EXPECT_FALSE(result);
443     result = stubPtr->CheckRegParams("devId", "dhId", "version", exceedParamMaxSizeStr, "reqId");
444     EXPECT_FALSE(result);
445     result = stubPtr->CheckRegParams("devId", "dhId", "version", "attrs", exceedDidMaxSizeStr);
446     EXPECT_FALSE(result);
447 }
448 
449 /**
450  * @tc.name: CheckUnregParams_001
451  * @tc.desc: ValidParams
452  * @tc.type: FUNC
453  * @tc.require: Issue Number
454  */
455 HWTEST_F(DScreenSourceStubTest, CheckUnregParams_001, TestSize.Level1)
456 {
457     std::shared_ptr<TestDScreenSourceStub> stubPtr = std::make_shared<TestDScreenSourceStub>();
458     bool result = stubPtr->CheckUnregParams("devId", "dhId", "reqId");
459     EXPECT_TRUE(result);
460 }
461 
462 /**
463  * @tc.name: CheckUnregParams_002
464  * @tc.desc: Parameter is empty
465  * @tc.type: FUNC
466  * @tc.require: Issue Number
467  */
468 
469 HWTEST_F(DScreenSourceStubTest, CheckUnregParams_002, TestSize.Level1)
470 {
471     std::shared_ptr<TestDScreenSourceStub> stubPtr = std::make_shared<TestDScreenSourceStub>();
472     bool result;
473     result = stubPtr->CheckUnregParams("", "dhId", "reqId");
474     EXPECT_FALSE(result);
475     result = stubPtr->CheckUnregParams("devId", "", "reqId");
476     EXPECT_FALSE(result);
477     result = stubPtr->CheckUnregParams("devId", "dhId", "");
478     EXPECT_FALSE(result);
479 }
480 
481 /**
482  * @tc.name: CheckUnregParams_003
483  * @tc.desc: parameter exceeds maximum length
484  * @tc.type: FUNC
485  * @tc.require: Issue Number
486  */
487 
488 HWTEST_F(DScreenSourceStubTest, CheckUnregParams_003, TestSize.Level1)
489 {
490     std::shared_ptr<TestDScreenSourceStub> stubPtr = std::make_shared<TestDScreenSourceStub>();
491     std::string exceedDidMaxSizeStr(DID_MAX_SIZE + 1, 'a');
492     bool result;
493     result = stubPtr->CheckUnregParams(exceedDidMaxSizeStr, "dhId", "reqId");
494     EXPECT_FALSE(result);
495     result = stubPtr->CheckUnregParams("devId", exceedDidMaxSizeStr, "reqId");
496     EXPECT_FALSE(result);
497     result = stubPtr->CheckUnregParams("devId", "dhId", exceedDidMaxSizeStr);
498     EXPECT_FALSE(result);
499 }
500 
501 /**
502  * @tc.name: CheckConfigParams_001
503  * @tc.desc: ValidParams
504  * @tc.type: FUNC
505  * @tc.require: Issue Number
506  */
507 HWTEST_F(DScreenSourceStubTest, CheckConfigParams_001, TestSize.Level1)
508 {
509     std::shared_ptr<TestDScreenSourceStub> stubPtr = std::make_shared<TestDScreenSourceStub>();
510     bool result = stubPtr->CheckConfigParams("devId", "dhId", "key", "value");
511     EXPECT_TRUE(result);
512 }
513 
514 /**
515  * @tc.name: CheckConfigParams_002
516  * @tc.desc: Parameter is empty
517  * @tc.type: FUNC
518  * @tc.require: Issue Number
519  */
520 
521 HWTEST_F(DScreenSourceStubTest, CheckConfigParams_002, TestSize.Level1)
522 {
523     std::shared_ptr<TestDScreenSourceStub> stubPtr = std::make_shared<TestDScreenSourceStub>();
524     bool result;
525     result = stubPtr->CheckConfigParams("", "dhId", "key", "value");
526     EXPECT_FALSE(result);
527     result = stubPtr->CheckConfigParams("devId", "", "key", "value");
528     EXPECT_FALSE(result);
529     result = stubPtr->CheckConfigParams("devId", "dhId", "", "value");
530     EXPECT_FALSE(result);
531     result = stubPtr->CheckConfigParams("devId", "dhId", "key", "");
532     EXPECT_FALSE(result);
533 }
534 
535 /**
536  * @tc.name: CheckConfigParams_003
537  * @tc.desc: parameter exceeds maximum length
538  * @tc.type: FUNC
539  * @tc.require: Issue Number
540  */
541 
542 HWTEST_F(DScreenSourceStubTest, CheckConfigParams_003, TestSize.Level1)
543 {
544     std::shared_ptr<TestDScreenSourceStub> stubPtr = std::make_shared<TestDScreenSourceStub>();
545     std::string exceedDidMaxSizeStr(DID_MAX_SIZE + 1, 'a');
546     std::string exceedParamMaxSizeStr(PARAM_MAX_SIZE + 1, 'a');
547     bool result;
548     result = stubPtr->CheckConfigParams(exceedDidMaxSizeStr, "dhId", "key", "value");
549     EXPECT_FALSE(result);
550     result = stubPtr->CheckConfigParams("devId", exceedDidMaxSizeStr, "key", "value");
551     EXPECT_FALSE(result);
552     result = stubPtr->CheckConfigParams("devId", "dhId", exceedParamMaxSizeStr, "value");
553     EXPECT_FALSE(result);
554     result = stubPtr->CheckConfigParams("devId", "dhId", "key", exceedParamMaxSizeStr);
555     EXPECT_FALSE(result);
556 }
557 }  // namespace DistributedHardware
558 }  // namespace OHOS
559