1 /*
2  * Copyright (c) 2023 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 <gtest/gtest.h>
17 
18 #define private public
19 #define protected public
20 #include "array_wrapper.h"
21 #include "base_obj.h"
22 #include "bool_wrapper.h"
23 #include "byte_wrapper.h"
24 #include "distributed_want_params.h"
25 #include "distributed_want_params_wrapper.h"
26 #include "double_wrapper.h"
27 #include "float_wrapper.h"
28 #include "int_wrapper.h"
29 #include "long_wrapper.h"
30 #include "short_wrapper.h"
31 #include "string_wrapper.h"
32 #include "test_log.h"
33 #include "zchar_wrapper.h"
34 #undef private
35 #undef protected
36 
37 using namespace testing::ext;
38 using namespace OHOS;
39 using namespace AAFwk;
40 using namespace DistributedSchedule;
41 using OHOS::Parcel;
42 class DistributedWantParamsBaseTest : public testing::Test {
43 public:
DistributedWantParamsBaseTest()44     DistributedWantParamsBaseTest()
45     {}
~DistributedWantParamsBaseTest()46     ~DistributedWantParamsBaseTest()
47     {}
48     static void SetUpTestCase(void);
49     static void TearDownTestCase(void);
50     void SetUp();
51     void TearDown();
52     std::shared_ptr<DistributedWantParams> wantParamsIn_ = nullptr;
53     std::shared_ptr<DistributedWantParams> wantParamsOut_ = nullptr;
54     static sptr<DistributedWantParams> distributedWantParams_;
55 };
56 
57 sptr<DistributedWantParams> DistributedWantParamsBaseTest::distributedWantParams_;
58 
SetUpTestCase(void)59 void DistributedWantParamsBaseTest::SetUpTestCase(void)
60 {
61     distributedWantParams_ = new DistributedWantParams();
62 }
63 
TearDownTestCase(void)64 void DistributedWantParamsBaseTest::TearDownTestCase(void)
65 {}
66 
SetUp(void)67 void DistributedWantParamsBaseTest::SetUp(void)
68 {
69     wantParamsIn_ = std::make_shared<DistributedWantParams>();
70     wantParamsOut_ = std::make_shared<DistributedWantParams>();
71 }
72 
TearDown(void)73 void DistributedWantParamsBaseTest::TearDown(void)
74 {
75 }
76 
77 /**
78  * @tc.number: DistributedWantParams_Parcelable_0100
79  * @tc.name: Marshalling/Unmarshalling
80  * @tc.desc: marshalling WantParams, and then check result.
81  */
82 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_Parcelable_0100, Function | MediumTest | Level3)
83 {
84     ASSERT_NE(wantParamsIn_, nullptr);
85     std::string keyStr = "12345667";
86     std::string valueStr = "sdasdfdsffdgfdg";
87     wantParamsIn_->SetParam(keyStr, String::Box(valueStr));
88     Parcel in;
89     if (wantParamsOut_ != nullptr) {
90         wantParamsIn_->Marshalling(in);
91         std::shared_ptr<DistributedWantParams> wantParamsOut_(DistributedWantParams::Unmarshalling(in));
92         EXPECT_EQ(valueStr, String::Unbox(IString::Query(wantParamsOut_->GetParam(keyStr))));
93     }
94 }
95 
96 /**
97  * @tc.number: DistributedWantParams_Parcelable_0200
98  * @tc.name: Marshalling/Unmarshalling
99  * @tc.desc: marshalling WantParams, and then check result.
100  */
101 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_Parcelable_0200, Function | MediumTest | Level3)
102 {
103     ASSERT_NE(wantParamsIn_, nullptr);
104     std::string keyStr = "12345667";
105     bool valueBool = true;
106     wantParamsIn_->SetParam(keyStr, Boolean::Box(valueBool));
107 
108     Parcel in;
109     if (wantParamsOut_ != nullptr) {
110         wantParamsIn_->Marshalling(in);
111         std::shared_ptr<DistributedWantParams> wantParamsOut_(DistributedWantParams::Unmarshalling(in));
112         EXPECT_EQ(valueBool, Boolean::Unbox(IBoolean::Query(wantParamsOut_->GetParam(keyStr))));
113     }
114 }
115 
116 /**
117  * @tc.number: DistributedWantParams_Parcelable_0300
118  * @tc.name: Marshalling/Unmarshalling
119  * @tc.desc: marshalling WantParams, and then check result.
120  */
121 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_Parcelable_0300, Function | MediumTest | Level3)
122 {
123     ASSERT_NE(wantParamsIn_, nullptr);
124     std::string keyStr = "12345667";
125     int valueInteger = 12345;
126     wantParamsIn_->SetParam(keyStr, Integer::Box(valueInteger));
127     Integer::Unbox(IInteger::Query(wantParamsIn_->GetParam(keyStr)));
128 
129     Parcel in;
130     wantParamsIn_->Marshalling(in);
131     std::shared_ptr<DistributedWantParams> wantParamsOut_(DistributedWantParams::Unmarshalling(in));
132     if (wantParamsOut_ != nullptr) {
133         int right = Integer::Unbox(IInteger::Query(wantParamsOut_->GetParam(keyStr)));
134         EXPECT_EQ(valueInteger, right);
135         wantParamsOut_ = nullptr;
136     }
137 }
138 
139 /**
140  * @tc.number: DistributedWantParams_Parcelable_0400
141  * @tc.name: Marshalling/Unmarshalling
142  * @tc.desc: marshalling WantParams, and then check result.
143  */
144 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_Parcelable_0400, Function | MediumTest | Level3)
145 {
146     ASSERT_NE(wantParamsIn_, nullptr);
147     std::string keyStr = "12345667";
148     long valueLong = 1234567;
149     wantParamsIn_->SetParam(keyStr, Long::Box(valueLong));
150 
151     Parcel in;
152     wantParamsIn_->Marshalling(in);
153     std::shared_ptr<DistributedWantParams> wantParamsOut_(DistributedWantParams::Unmarshalling(in));
154     std::string outString(String::Unbox(IString::Query(wantParamsOut_->GetParam(keyStr))));
155     EXPECT_STREQ(std::to_string(valueLong).c_str(), outString.c_str());
156 }
157 
158 /**
159  * @tc.number: DistributedWantParams_Parcelable_0700
160  * @tc.name: Marshalling/Unmarshalling
161  * @tc.desc: marshalling array, and then check result.
162  */
163 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_Parcelable_0700, Function | MediumTest | Level3)
164 {
165     ASSERT_NE(wantParamsIn_, nullptr);
166     sptr<AAFwk::IArray> ao = new (std::nothrow) AAFwk::Array(2, AAFwk::g_IID_IString);
167     std::string valueStr0 = "TestValue0";
168     ao->Set(0, String::Box(valueStr0));
169     std::string valueStr1 = "TestValue1";
170     ao->Set(1, String::Box(valueStr1));
171 
172     DistributedWantParams l1;
173     l1.SetParam("l1", ao);
174     wantParamsIn_->SetParam("l2",  DistributedWantParamWrapper::Box(l1));
175 
176     Parcel in;
177     wantParamsIn_->Marshalling(in);
178     std::shared_ptr<DistributedWantParams> wantParamsOut_(DistributedWantParams::Unmarshalling(in));
179     DistributedWantParams l1Out =
180         DistributedWantParamWrapper::Unbox(IDistributedWantParams::Query(wantParamsOut_->GetParam("l2")));
181     IArray *aoOut = IArray::Query(l1Out.GetParam("l1"));
182 
183     long size;
184     aoOut->GetLength(size);
185     EXPECT_EQ(size, 2);
186     sptr<IInterface> str0;
187     sptr<IInterface> str1;
188     aoOut->Get(0, str0);
189     aoOut->Get(1, str1);
190 
191     EXPECT_EQ(valueStr0, String::Unbox(IString::Query(str0)));
192     EXPECT_EQ(valueStr1, String::Unbox(IString::Query(str1)));
193 }
194 
195 /**
196  * @tc.number: DistributedWantParams_GetStringByType_0200
197  * @tc.name: GetStringByType
198  * @tc.desc: Test get bool with invalid type in the WantParam.
199  */
200 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetStringByType_0200, Function | MediumTest | Level3)
201 {
202     const std::string value = "true";
203     sptr<IInterface> boolObj =
204         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_BOOLEAN, value);
205     std::string stringVal =
206         DistributedWantParams::GetStringByType(boolObj, DistributedWantParams::VALUE_TYPE_BOOLEAN);
207     EXPECT_EQ(stringVal, "true");
208 }
209 
210 /**
211  * @tc.number: DistributedWantParams_GetStringByType_0300
212  * @tc.name: GetStringByType
213  * @tc.desc: Test get string with invalid type in the WantParam.
214  */
215 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetStringByType_0300, Function | MediumTest | Level3)
216 {
217     const std::string value = "string";
218     sptr<IInterface> stringObj =
219         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_STRING, value);
220     std::string stringVal =
221         DistributedWantParams::GetStringByType(stringObj, DistributedWantParams::VALUE_TYPE_STRING);
222     EXPECT_EQ(stringVal, "string");
223 }
224 
225 /**
226  * @tc.number: DistributedWantParams_GetStringByType_0400
227  * @tc.name: GetStringByType
228  * @tc.desc: Test get byte with invalid type in the WantParam.
229  */
230 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetStringByType_0400, Function | MediumTest | Level3)
231 {
232     const std::string value = "129";
233     sptr<IInterface> byteObj =
234         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_BYTE, value);
235     std::string byteVal = DistributedWantParams::GetStringByType(byteObj, DistributedWantParams::VALUE_TYPE_BYTE);
236     EXPECT_EQ(byteVal, "129");
237 }
238 
239 /**
240  * @tc.number: DistributedWantParams_GetStringByType_0500
241  * @tc.name: GetStringByType
242  * @tc.desc: Test get char with invalid type in the WantParam.
243  */
244 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetStringByType_0500, Function | MediumTest | Level3)
245 {
246     const std::string value = "I";
247     sptr<IInterface> charObj =
248         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_CHAR, value);
249     std::string charVal = DistributedWantParams::GetStringByType(charObj, DistributedWantParams::VALUE_TYPE_CHAR);
250     EXPECT_EQ(charVal, "I");
251 }
252 
253 /**
254  * @tc.number: DistributedWantParams_GetStringByType_0600
255  * @tc.name: GetStringByType
256  * @tc.desc: Test get short with invalid type in the WantParam.
257  */
258 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetStringByType_0600, Function | MediumTest | Level3)
259 {
260     const std::string value = "123";
261     sptr<IInterface> shortObj =
262         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_SHORT, value);
263     std::string shortVal = DistributedWantParams::GetStringByType(shortObj, DistributedWantParams::VALUE_TYPE_SHORT);
264     EXPECT_EQ(shortVal, "123");
265 }
266 
267 /**
268  * @tc.number: DistributedWantParams_GetStringByType_0700
269  * @tc.name: GetStringByType
270  * @tc.desc: Test get int with invalid type in the WantParam.
271  */
272 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetStringByType_0700, Function | MediumTest | Level3)
273 {
274     const std::string value = "-1";
275     sptr<IInterface> intObj = DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_INT, value);
276     std::string intVal = DistributedWantParams::GetStringByType(intObj, DistributedWantParams::VALUE_TYPE_INT);
277     EXPECT_EQ(intVal, "-1");
278 }
279 
280 /**
281  * @tc.number: DistributedWantParams_GetStringByType_0800
282  * @tc.name: GetStringByType
283  * @tc.desc: Test get long with invalid type in the WantParam.
284  */
285 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetStringByType_0800, Function | MediumTest | Level3)
286 {
287     const std::string value = "-1";
288     sptr<IInterface> longObj =
289         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_LONG, value);
290     std::string longVal = DistributedWantParams::GetStringByType(longObj, DistributedWantParams::VALUE_TYPE_LONG);
291     EXPECT_EQ(longVal, "-1");
292 }
293 
294 /**
295  * @tc.number: DistributedWantParams_GetStringByType_0900
296  * @tc.name: GetStringByType
297  * @tc.desc: Test get float with invalid type in the WantParam.
298  */
299 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetStringByType_0900, Function | MediumTest | Level3)
300 {
301     const std::string value = "-1.0004";
302     sptr<IInterface> floatObj =
303         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_FLOAT, value);
304     std::string floatVal = DistributedWantParams::GetStringByType(floatObj, DistributedWantParams::VALUE_TYPE_FLOAT);
305     EXPECT_EQ(floatVal, "-1.000400");
306 }
307 
308 /**
309  * @tc.number: DistributedWantParams_GetStringByType_1000
310  * @tc.name: GetStringByType
311  * @tc.desc: Test get float with invalid type in the WantParam.
312  */
313 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetStringByType_1000, Function | MediumTest | Level3)
314 {
315     const std::string value = "-1.00000004";
316     sptr<IInterface> doubleObj =
317         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_DOUBLE, value);
318     std::string doubleVal =
319         DistributedWantParams::GetStringByType(doubleObj, DistributedWantParams::VALUE_TYPE_DOUBLE);
320     EXPECT_EQ(doubleVal, "-1.000000");
321 }
322 
323 /**
324  * @tc.number: DistributedWantParams_GetStringByType_1100
325  * @tc.name: GetStringByType
326  * @tc.desc: Test get float with invalid type in the WantParam.
327  */
328 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetStringByType_1100, Function | MediumTest | Level3)
329 {
330     const std::string value = "I5{2,3,5,7,11}";
331     sptr<IInterface> arrayObj =
332         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_ARRAY, value);
333     std::string arrayVal = DistributedWantParams::GetStringByType(arrayObj, DistributedWantParams::VALUE_TYPE_ARRAY);
334     EXPECT_EQ(arrayVal, "I5{2,3,5,7,11}");
335 }
336 
337 /**
338  * @tc.number: DistributedWantParams_NewArrayData_0100
339  * @tc.name: NewArrayData
340  * @tc.desc: Test NewArrayData with invalid sptr<IArray> parameter.
341  */
342 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_NewArrayData_0100, Function | MediumTest | Level3)
343 {
344     sptr<AAFwk::IArray> array = new (std::nothrow) AAFwk::Array(0, g_IID_IDistributedWantParams);
345     DistributedWantParams wp;
346     wp.SetParam("param1", array);
347     IArray *iarray = IArray::Query(array);
348     sptr<IArray> destAO = nullptr;
349     bool result = wp.NewArrayData(iarray, destAO);
350     EXPECT_FALSE(result);
351 }
352 
353 /**
354  * @tc.number: DistributedWantParams_GetDataType_0100
355  * @tc.name: GetDataType
356  * @tc.desc: Test GetDataType with invalid parameter.
357  */
358 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetDataType_0100, Function | MediumTest | Level3)
359 {
360     int type = DistributedWantParams::GetDataType(nullptr);
361     EXPECT_EQ(type, DistributedWantParams::VALUE_TYPE_NULL);
362 }
363 
364 /**
365  * @tc.number: DistributedWantParams_GetDataType_0200
366  * @tc.name: GetDataType
367  * @tc.desc: Test GetDataType with bool parameter.
368  */
369 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetDataType_0200, Function | MediumTest | Level3)
370 {
371     const std::string value = "true";
372     sptr<IInterface> boolObj =
373         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_BOOLEAN, value);
374     int type = DistributedWantParams::GetDataType(boolObj);
375     EXPECT_EQ(type, DistributedWantParams::VALUE_TYPE_BOOLEAN);
376 }
377 
378 /**
379  * @tc.number: DistributedWantParams_GetDataType_0300
380  * @tc.name: GetDataType
381  * @tc.desc: Test GetDataType with byte parameter.
382  */
383 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetDataType_0300, Function | MediumTest | Level3)
384 {
385     const std::string value = "129";
386     sptr<IInterface> byteObj =
387         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_BYTE, value);
388     int type = DistributedWantParams::GetDataType(byteObj);
389     EXPECT_EQ(type, DistributedWantParams::VALUE_TYPE_BYTE);
390 }
391 
392 /**
393  * @tc.number: DistributedWantParams_GetDataType_0400
394  * @tc.name: GetDataType
395  * @tc.desc: Test GetDataType with char parameter.
396  */
397 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetDataType_0400, Function | MediumTest | Level3)
398 {
399     const std::string value = "I";
400     sptr<IInterface> charObj =
401         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_CHAR, value);
402     int type = DistributedWantParams::GetDataType(charObj);
403     EXPECT_EQ(type, DistributedWantParams::VALUE_TYPE_CHAR);
404 }
405 
406 /**
407  * @tc.number: DistributedWantParams_GetDataType_0500
408  * @tc.name: GetDataType
409  * @tc.desc: Test GetDataType with short parameter.
410  */
411 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetDataType_0500, Function | MediumTest | Level3)
412 {
413     const std::string value = "123";
414     sptr<IInterface> shortObj =
415         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_SHORT, value);
416     int type = DistributedWantParams::GetDataType(shortObj);
417     EXPECT_EQ(type, DistributedWantParams::VALUE_TYPE_SHORT);
418 }
419 
420 /**
421  * @tc.number: DistributedWantParams_GetDataType_0600
422  * @tc.name: GetDataType
423  * @tc.desc: Test GetDataType with int parameter.
424  */
425 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetDataType_0600, Function | MediumTest | Level3)
426 {
427     const std::string value = "-1";
428     sptr<IInterface> intObj = DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_INT, value);
429     int type = DistributedWantParams::GetDataType(intObj);
430     EXPECT_EQ(type, DistributedWantParams::VALUE_TYPE_INT);
431 }
432 
433 /**
434  * @tc.number: DistributedWantParams_GetDataType_0700
435  * @tc.name: GetDataType
436  * @tc.desc: Test GetDataType with long parameter.
437  */
438 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetDataType_0700, Function | MediumTest | Level3)
439 {
440     const std::string value = "-1";
441     sptr<IInterface> longObj = DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_LONG, value);
442     int type = DistributedWantParams::GetDataType(longObj);
443     EXPECT_EQ(type, DistributedWantParams::VALUE_TYPE_LONG);
444 }
445 
446 /**
447  * @tc.number: DistributedWantParams_GetDataType_0800
448  * @tc.name: GetDataType
449  * @tc.desc: Test GetDataType with float parameter.
450  */
451 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetDataType_0800, Function | MediumTest | Level3)
452 {
453     const std::string value = "-1.0004";
454     sptr<IInterface> floatObj =
455         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_FLOAT, value);
456     int type = DistributedWantParams::GetDataType(floatObj);
457     EXPECT_EQ(type, DistributedWantParams::VALUE_TYPE_FLOAT);
458 }
459 
460 /**
461  * @tc.number: DistributedWantParams_GetDataType_0900
462  * @tc.name: GetDataType
463  * @tc.desc: Test GetDataType with double parameter.
464  */
465 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetDataType_0900, Function | MediumTest | Level3)
466 {
467     const std::string value = "-1.00000004";
468     sptr<IInterface> doubleObj =
469         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_DOUBLE, value);
470     int type = DistributedWantParams::GetDataType(doubleObj);
471     EXPECT_EQ(type, DistributedWantParams::VALUE_TYPE_DOUBLE);
472 }
473 
474 /**
475  * @tc.number: DistributedWantParams_GetDataType_1000
476  * @tc.name: GetDataType
477  * @tc.desc: Test GetDataType with string parameter.
478  */
479 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetDataType_1000, Function | MediumTest | Level3)
480 {
481     const std::string value = "hello";
482     sptr<IInterface> stringObj =
483         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_STRING, value);
484     int type = DistributedWantParams::GetDataType(stringObj);
485     EXPECT_EQ(type, DistributedWantParams::VALUE_TYPE_STRING);
486 }
487 
488 /**
489  * @tc.number: DistributedWantParams_GetDataType_1100
490  * @tc.name: GetDataType
491  * @tc.desc: Test GetDataType with array parameter.
492  */
493 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetDataType_1100, Function | MediumTest | Level3)
494 {
495     const std::string value = "I5{2,3,5,7,11}";
496     sptr<IInterface> interfaceObj =
497         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_ARRAY, value);
498     int type = DistributedWantParams::GetDataType(interfaceObj);
499     EXPECT_EQ(type, DistributedWantParams::VALUE_TYPE_ARRAY);
500 }
501 
502 /**
503  * @tc.number: DistributedWantParams_GetInterfaceByType_0100
504  * @tc.name: GetInterfaceByType
505  * @tc.desc: Test GetInterfaceByType with boolean type.
506  */
507 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetInterfaceByType_0100, Function | MediumTest | Level3)
508 {
509     const std::string value = "true";
510     sptr<IInterface> boolObj =
511         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_BOOLEAN, value);
512     EXPECT_TRUE(Boolean::Unbox(IBoolean::Query(boolObj)));
513 }
514 
515 /**
516  * @tc.number: DistributedWantParams_GetInterfaceByType_0200
517  * @tc.name: GetInterfaceByType
518  * @tc.desc: Test GetInterfaceByType with byte type.
519  */
520 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetInterfaceByType_0200, Function | MediumTest | Level3)
521 {
522     const std::string value = "129";
523     sptr<IInterface> byteObj =
524         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_BYTE, value);
525     EXPECT_EQ(Byte::Unbox(IByte::Query(byteObj)), 129);
526 }
527 
528 /**
529  * @tc.number: DistributedWantParams_GetInterfaceByType_0300
530  * @tc.name: GetInterfaceByType
531  * @tc.desc: Test GetInterfaceByType with char type.
532  */
533 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetInterfaceByType_0300, Function | MediumTest | Level3)
534 {
535     const std::string value = "I";
536     sptr<IInterface> charObj =
537         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_CHAR, value);
538     EXPECT_EQ(Char::Unbox(IChar::Query(charObj)), 'I');
539 }
540 
541 /**
542  * @tc.number: DistributedWantParams_GetInterfaceByType_0400
543  * @tc.name: GetInterfaceByType
544  * @tc.desc: Test GetInterfaceByType with short type.
545  */
546 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetInterfaceByType_0400, Function | MediumTest | Level3)
547 {
548     const std::string value = "123";
549     sptr<IInterface> shortObj =
550         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_SHORT, value);
551     EXPECT_EQ(Short::Unbox(IShort::Query(shortObj)), 123);
552 }
553 
554 /**
555  * @tc.number: DistributedWantParams_GetInterfaceByType_0500
556  * @tc.name: GetInterfaceByType
557  * @tc.desc: Test GetInterfaceByType with integer type.
558  */
559 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetInterfaceByType_0500, Function | MediumTest | Level3)
560 {
561     const std::string value = "-1";
562     sptr<IInterface> intObj = DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_INT, value);
563     EXPECT_EQ(Integer::Unbox(IInteger::Query(intObj)), -1);
564 }
565 
566 /**
567  * @tc.number: DistributedWantParams_GetInterfaceByType_0600
568  * @tc.name: GetInterfaceByType
569  * @tc.desc: Test GetInterfaceByType with long type.
570  */
571 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetInterfaceByType_0600, Function | MediumTest | Level3)
572 {
573     const std::string value = "-1";
574     sptr<IInterface> longObj =
575         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_LONG, value);
576     EXPECT_EQ(Long::Unbox(ILong::Query(longObj)), -1);
577 }
578 
579 /**
580  * @tc.number: DistributedWantParams_GetInterfaceByType_0700
581  * @tc.name: GetInterfaceByType
582  * @tc.desc: Test GetInterfaceByType with float type.
583  */
584 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetInterfaceByType_0700, Function | MediumTest | Level3)
585 {
586     const std::string value = "-1.0004";
587     sptr<IInterface> floatObj =
588         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_FLOAT, value);
589     EXPECT_FLOAT_EQ(Float::Unbox(IFloat::Query(floatObj)), -1.0004);
590 }
591 
592 /**
593  * @tc.number: DistributedWantParams_GetInterfaceByType_0800
594  * @tc.name: GetInterfaceByType
595  * @tc.desc: Test GetInterfaceByType with double type.
596  */
597 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetInterfaceByType_0800, Function | MediumTest | Level3)
598 {
599     const std::string value = "-1.00000004";
600     sptr<IInterface> doubleObj =
601         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_DOUBLE, value);
602     EXPECT_DOUBLE_EQ(Double::Unbox(IDouble::Query(doubleObj)), -1.00000004);
603 }
604 
605 /**
606  * @tc.number: DistributedWantParams_GetInterfaceByType_0900
607  * @tc.name: GetInterfaceByType
608  * @tc.desc: Test GetInterfaceByType with string type.
609  */
610 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetInterfaceByType_0900, Function | MediumTest | Level3)
611 {
612     const std::string value = "hello";
613     sptr<IInterface> stringObj =
614         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_STRING, value);
615     EXPECT_EQ(String::Unbox(IString::Query(stringObj)), std::string("hello"));
616 }
617 
618 /**
619  * @tc.number: DistributedWantParams_GetInterfaceByType_1000
620  * @tc.name: GetInterfaceByType
621  * @tc.desc: Test GetInterfaceByType with array type.
622  */
623 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetInterfaceByType_1000, Function | MediumTest | Level3)
624 {
625     const std::string value = "I5{2,3,5,7,11}";
626     sptr<IInterface> interfaceObj =
627         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_ARRAY, value);
628     Array* arrayObj = static_cast<Array *>(IArray::Query(interfaceObj));
629     sptr<IInterface> valueObj;
630     arrayObj->Get(0, valueObj);
631     EXPECT_EQ(Integer::Unbox(IInteger::Query(valueObj)), 2);
632     arrayObj->Get(1, valueObj);
633     EXPECT_EQ(Integer::Unbox(IInteger::Query(valueObj)), 3);
634     arrayObj->Get(2, valueObj);
635     EXPECT_EQ(Integer::Unbox(IInteger::Query(valueObj)), 5);
636     arrayObj->Get(3, valueObj);
637     EXPECT_EQ(Integer::Unbox(IInteger::Query(valueObj)), 7);
638     arrayObj->Get(4, valueObj);
639     EXPECT_EQ(Integer::Unbox(IInteger::Query(valueObj)), 11);
640 }
641 
642 /**
643  * @tc.number: DistributedWantParams_GetInterfaceByType_1100
644  * @tc.name: GetInterfaceByType
645  * @tc.desc: Test GetInterfaceByType with invalid type.
646  */
647 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetInterfaceByType_1100, Function | MediumTest | Level3)
648 {
649     const std::string value = "123";
650     sptr<IInterface> arrayObj =
651         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_NULL, value);
652     EXPECT_EQ(arrayObj, nullptr);
653 }
654 
655 /**
656  * @tc.number: DistributedWantParams_CompareInterface_0100
657  * @tc.name: CompareInterface
658  * @tc.desc: Test CompareInterface with bool type.
659  */
660 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_CompareInterface_0100, Function | MediumTest | Level3)
661 {
662     const std::string value = "true";
663     sptr<IInterface> interfaceObj =
664         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_BOOLEAN, value);
665     bool result =
666         DistributedWantParams::CompareInterface(interfaceObj, interfaceObj, DistributedWantParams::VALUE_TYPE_BOOLEAN);
667     EXPECT_TRUE(result);
668 }
669 
670 /**
671  * @tc.number: DistributedWantParams_CompareInterface_0200
672  * @tc.name: CompareInterface
673  * @tc.desc: Test CompareInterface with byte type.
674  */
675 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_CompareInterface_0200, Function | MediumTest | Level3)
676 {
677     const std::string value = "129";
678     sptr<IInterface> interfaceObj =
679         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_BYTE, value);
680     bool result =
681         DistributedWantParams::CompareInterface(interfaceObj, interfaceObj, DistributedWantParams::VALUE_TYPE_BYTE);
682     EXPECT_TRUE(result);
683 }
684 
685 /**
686  * @tc.number: DistributedWantParams_CompareInterface_0300
687  * @tc.name: CompareInterface
688  * @tc.desc: Test CompareInterface with char type.
689  */
690 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_CompareInterface_0300, Function | MediumTest | Level3)
691 {
692     const std::string value = "I";
693     sptr<IInterface> interfaceObj =
694         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_CHAR, value);
695     bool result =
696         DistributedWantParams::CompareInterface(interfaceObj, interfaceObj, DistributedWantParams::VALUE_TYPE_CHAR);
697     EXPECT_TRUE(result);
698 }
699 
700 /**
701  * @tc.number: DistributedWantParams_CompareInterface_0400
702  * @tc.name: CompareInterface
703  * @tc.desc: Test CompareInterface with short type.
704  */
705 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_CompareInterface_0400, Function | MediumTest | Level3)
706 {
707     const std::string value = "123";
708     sptr<IInterface> interfaceObj =
709         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_SHORT, value);
710     bool result =
711         DistributedWantParams::CompareInterface(interfaceObj, interfaceObj, DistributedWantParams::VALUE_TYPE_SHORT);
712     EXPECT_TRUE(result);
713 }
714 
715 /**
716  * @tc.number: DistributedWantParams_CompareInterface_0500
717  * @tc.name: CompareInterface
718  * @tc.desc: Test CompareInterface with integer type.
719  */
720 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_CompareInterface_0500, Function | MediumTest | Level3)
721 {
722     const std::string value = "-1";
723     sptr<IInterface> interfaceObj =
724         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_INT, value);
725     bool result =
726         DistributedWantParams::CompareInterface(interfaceObj, interfaceObj, DistributedWantParams::VALUE_TYPE_INT);
727     EXPECT_TRUE(result);
728 }
729 
730 /**
731  * @tc.number: DistributedWantParams_CompareInterface_0600
732  * @tc.name: CompareInterface
733  * @tc.desc: Test CompareInterface with long type.
734  */
735 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_CompareInterface_0600, Function | MediumTest | Level3)
736 {
737     const std::string value = "-1";
738     sptr<IInterface> interfaceObj =
739         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_LONG, value);
740     bool result =
741         DistributedWantParams::CompareInterface(interfaceObj, interfaceObj, DistributedWantParams::VALUE_TYPE_LONG);
742     EXPECT_TRUE(result);
743 }
744 
745 /**
746  * @tc.number: DistributedWantParams_CompareInterface_0700
747  * @tc.name: CompareInterface
748  * @tc.desc: Test CompareInterface with float type.
749  */
750 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_CompareInterface_0700, Function | MediumTest | Level3)
751 {
752     const std::string value = "-1.0004";
753     sptr<IInterface> interfaceObj =
754         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_FLOAT, value);
755     bool result =
756         DistributedWantParams::CompareInterface(interfaceObj, interfaceObj, DistributedWantParams::VALUE_TYPE_FLOAT);
757     EXPECT_TRUE(result);
758 }
759 
760 /**
761  * @tc.number: DistributedWantParams_CompareInterface_0800
762  * @tc.name: CompareInterface
763  * @tc.desc: Test CompareInterface with double type.
764  */
765 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_CompareInterface_0800, Function | MediumTest | Level3)
766 {
767     const std::string value = "-1.00000004";
768     sptr<IInterface> interfaceObj =
769         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_DOUBLE, value);
770     bool result =
771         DistributedWantParams::CompareInterface(interfaceObj, interfaceObj, DistributedWantParams::VALUE_TYPE_DOUBLE);
772     EXPECT_TRUE(result);
773 }
774 
775 /**
776  * @tc.number: DistributedWantParams_CompareInterface_0900
777  * @tc.name: CompareInterface
778  * @tc.desc: Test CompareInterface with string type.
779  */
780 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_CompareInterface_0900, Function | MediumTest | Level3)
781 {
782     const std::string value = "hello";
783     sptr<IInterface> interfaceObj =
784         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_STRING, value);
785     bool result =
786         DistributedWantParams::CompareInterface(interfaceObj, interfaceObj, DistributedWantParams::VALUE_TYPE_STRING);
787     EXPECT_TRUE(result);
788 }
789 
790 /**
791  * @tc.number: DistributedWantParams_CompareInterface_1000
792  * @tc.name: CompareInterface
793  * @tc.desc: Test CompareInterface with array type.
794  */
795 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_CompareInterface_1000, Function | MediumTest | Level3)
796 {
797     const std::string value = "I5{2,3,5,7,11}";
798     sptr<IInterface> interfaceObj =
799         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_ARRAY, value);
800     bool result =
801         DistributedWantParams::CompareInterface(interfaceObj, interfaceObj, DistributedWantParams::VALUE_TYPE_ARRAY);
802     EXPECT_TRUE(result);
803 }
804 
805 /**
806  * @tc.number: DistributedWantParams_WriteArrayToParStr_0100
807  * @tc.name: WriteArrayToParcelString
808  * @tc.desc: Test WriteArrayToParcelString string content.
809  */
810 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_WriteArrayToParStr_0100, Function | MediumTest | Level3)
811 {
812     Parcel parcel;
813     DistributedWantParams wp;
814     bool result = wp.WriteArrayToParcelString(parcel, nullptr);
815     EXPECT_FALSE(result);
816 }
817 
818 /**
819  * @tc.number: DistributedWantParams_WriteArrayToParBo_0100
820  * @tc.name: WriteArrayToParcelBool
821  * @tc.desc: Test WriteArrayToParcelBool bool content.
822  */
823 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_WriteArrayToParBo_0100, Function | MediumTest | Level3)
824 {
825     Parcel parcel;
826     DistributedWantParams wp;
827     bool result = wp.WriteArrayToParcelBool(parcel, nullptr);
828     EXPECT_FALSE(result);
829 }
830 
831 /**
832  * @tc.number: DistributedWantParams_WriteArrayToParBy_0100
833  * @tc.name: WriteArrayToParcelByte
834  * @tc.desc: Test WriteArrayToParcelByte byte content.
835  */
836 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_WriteArrayToParBy_0100, Function | MediumTest | Level3)
837 {
838     Parcel parcel;
839     DistributedWantParams wp;
840     bool result = wp.WriteArrayToParcelByte(parcel, nullptr);
841     EXPECT_FALSE(result);
842 }
843 
844 /**
845  * @tc.number: DistributedWantParams_WriteArrayToParCh_0100
846  * @tc.name: WriteArrayToParcelChar
847  * @tc.desc: Test WriteArrayToParcelChar char content.
848  */
849 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_WriteArrayToParCh_0100, Function | MediumTest | Level3)
850 {
851     Parcel parcel;
852     DistributedWantParams wp;
853     bool result = wp.WriteArrayToParcelChar(parcel, nullptr);
854     EXPECT_FALSE(result);
855 }
856 
857 /**
858  * @tc.number: DistributedWantParams_WriteArrayToParSho_0100
859  * @tc.name: WriteArrayToParcelShort
860  * @tc.desc: Test WriteArrayToParcelShort short content.
861  */
862 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_WriteArrayToParSho_0100, Function | MediumTest | Level3)
863 {
864     Parcel parcel;
865     DistributedWantParams wp;
866     bool result = wp.WriteArrayToParcelShort(parcel, nullptr);
867     EXPECT_FALSE(result);
868 }
869 
870 /**
871  * @tc.number: DistributedWantParams_WriteArrayToParInt_0100
872  * @tc.name: WriteArrayToParcelInt
873  * @tc.desc: Test WriteArrayToParcelInt int content.
874  */
875 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_WriteArrayToParInt_0100, Function | MediumTest | Level3)
876 {
877     Parcel parcel;
878     DistributedWantParams wp;
879     bool result = wp.WriteArrayToParcelInt(parcel, nullptr);
880     EXPECT_FALSE(result);
881 }
882 
883 /**
884  * @tc.number: DistributedWantParams_WriteArrayToParLo_0100
885  * @tc.name: WriteArrayToParcelLong
886  * @tc.desc: Test WriteArrayToParcelLong long content.
887  */
888 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_WriteArrayToParLo_0100, Function | MediumTest | Level3)
889 {
890     Parcel parcel;
891     DistributedWantParams wp;
892     bool result = wp.WriteArrayToParcelLong(parcel, nullptr);
893     EXPECT_FALSE(result);
894 }
895 
896 /**
897  * @tc.number: DistributedWantParams_WriteArrayToParFl_0100
898  * @tc.name: WriteArrayToParcelFloat
899  * @tc.desc: Test WriteArrayToParcelFloat float content.
900  */
901 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_WriteArrayToParFl_0100, Function | MediumTest | Level3)
902 {
903     Parcel parcel;
904     DistributedWantParams wp;
905     bool result = wp.WriteArrayToParcelFloat(parcel, nullptr);
906     EXPECT_FALSE(result);
907 }
908 
909 /**
910  * @tc.number: DistributedWantParams_WriteArrayToParDou_0100
911  * @tc.name: WriteArrayToParcelDouble
912  * @tc.desc: Test WriteArrayToParcelDouble double content.
913  */
914 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_WriteArrayToParDou_0100, Function | MediumTest | Level3)
915 {
916     Parcel parcel;
917     DistributedWantParams wp;
918     bool result = wp.WriteArrayToParcelDouble(parcel, nullptr);
919     EXPECT_FALSE(result);
920 }
921 
922 class DistributedUnsupportedDataTest : public testing::Test {
923 public:
DistributedUnsupportedDataTest()924     DistributedUnsupportedDataTest()
925     {}
~DistributedUnsupportedDataTest()926     ~DistributedUnsupportedDataTest()
927     {
928     }
929     static void SetUpTestCase(void);
930     static void TearDownTestCase(void);
931     void SetUp();
932     void TearDown();
933 
934     std::shared_ptr<DistributedUnsupportedData> unsupportedData_ = nullptr;
935 };
936 
SetUpTestCase(void)937 void DistributedUnsupportedDataTest::SetUpTestCase(void)
938 {}
939 
TearDownTestCase(void)940 void DistributedUnsupportedDataTest::TearDownTestCase(void)
941 {}
942 
SetUp(void)943 void DistributedUnsupportedDataTest::SetUp(void)
944 {
945     unsupportedData_ = std::make_shared<DistributedUnsupportedData>();
946 }
947 
TearDown(void)948 void DistributedUnsupportedDataTest::TearDown(void)
949 {
950 }
951 
952 /**
953  * @tc.number: DistributedWantParams_ReadArrayToParcel_1000
954  * @tc.name: ReadArrayToParcel
955  * @tc.desc: Test ReadArrayToParcel.
956  * @tc.require: issueI648W6
957  */
958 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_ReadArrayToParcel_1000, Function | MediumTest | Level3)
959 {
960     DistributedWantParams wantParams;
961     Parcel parcel;
962     int type = 1;
963     sptr<IArray> destAO = nullptr;
964     bool result = wantParams.ReadArrayToParcel(parcel, type, destAO);
965     EXPECT_EQ(result, true);
966 }
967 
968 /**
969  * @tc.number: DistributedWantParams_ReadUnsupportedData_1000
970  * @tc.name: ReadUnsupportedData
971  * @tc.desc: Test ReadUnsupportedData.
972  * @tc.require: issueI648W6
973  */
974 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_ReadUnsupportedData_1000, Function | MediumTest | Level3)
975 {
976     DistributedWantParams wantParams;
977     Parcel parcel;
978     std::string key = "this is key";
979     int type = 1;
980     bool result = wantParams.ReadUnsupportedData(parcel, key, type);
981     EXPECT_EQ(result, false);
982 
983     parcel.WriteInt32(-1);
984     bool result1 = wantParams.ReadUnsupportedData(parcel, key, type);
985     EXPECT_EQ(result1, false);
986 
987     int type1 = 50;
988     bool result2 = wantParams.ReadFromParcelParam(parcel, key, type1);
989     EXPECT_EQ(result2, false);
990 }
991 
992 /**
993  * @tc.number: DistributedWantParams_Operator_1000
994  * @tc.name: Operator
995  * @tc.desc: Test Operator.
996  * @tc.require: I77HFZ
997  */
998 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_Operator_1000, Function | MediumTest | Level3)
999 {
1000     DTEST_LOG << "DistributedWantParamsBaseTest DistributedWantParams_Operator_1000 begin" << std::endl;
1001     DistributedWantParams wantParams1;
1002     DistributedWantParams wantParams2;
1003     int32_t typeId = DistributedWantParams::VALUE_TYPE_WANTPARAMS;
1004     DistributedWantParams ret = (wantParams1 = wantParams2);
1005     EXPECT_EQ(typeId, DistributedWantParams::VALUE_TYPE_WANTPARAMS);
1006     DTEST_LOG << "DistributedWantParamsBaseTest DistributedWantParams_Operator_1000 end" << std::endl;
1007 }
1008 
1009 /**
1010  * @tc.number: DistributedWantParams_Operator_2000
1011  * @tc.name: Operator
1012  * @tc.desc: Test Operator.
1013  * @tc.require: I77HFZ
1014  */
1015 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_Operator_2000, Function | MediumTest | Level3)
1016 {
1017     DTEST_LOG << "DistributedWantParamsBaseTest DistributedWantParams_Operator_2000 begin" << std::endl;
1018     DistributedWantParams wantParams1;
1019     const DistributedWantParams wantParams2;
1020     int32_t typeId = DistributedWantParams::VALUE_TYPE_WANTPARAMS;
1021     DistributedWantParams ret = (wantParams1 = wantParams2);
1022     EXPECT_EQ(typeId, DistributedWantParams::VALUE_TYPE_WANTPARAMS);
1023     DTEST_LOG << "DistributedWantParamsBaseTest DistributedWantParams_Operator_2000 end" << std::endl;
1024 }
1025 
1026 /**
1027  * @tc.number: DistributedWantParams_Operator_3000
1028  * @tc.name: Operator
1029  * @tc.desc: Test Operator.
1030  * @tc.require: I77HFZ
1031  */
1032 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_Operator_3000, Function | MediumTest | Level3)
1033 {
1034     DTEST_LOG << "DistributedWantParamsBaseTest DistributedWantParams_Operator_3000 begin" << std::endl;
1035     DistributedUnsupportedData data1;
1036     const DistributedUnsupportedData data2;
1037     int32_t typeId = DistributedWantParams::VALUE_TYPE_WANTPARAMS;
1038     DistributedUnsupportedData ret = (data1 = data2);
1039     EXPECT_EQ(typeId, DistributedWantParams::VALUE_TYPE_WANTPARAMS);
1040     DTEST_LOG << "DistributedWantParamsBaseTest DistributedWantParams_Operator_3000 end" << std::endl;
1041 }
1042 
1043 /**
1044  * @tc.number: DistributedWantParams_CompareInterface_1200
1045  * @tc.name: CompareInterface
1046  * @tc.desc: Test CompareInterface.
1047  * @tc.require: I77HFZ
1048  */
1049 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_CompareInterface_1200, Function | MediumTest | Level3)
1050 {
1051     DTEST_LOG << "DistributedWantParamsBaseTest DistributedWantParams_CompareInterface_1200 begin" << std::endl;
1052     const std::string value = "wantParam";
1053     sptr<IInterface> interfaceObj =
1054         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_NULL, value);
1055     bool result =
1056         DistributedWantParams::CompareInterface(interfaceObj, interfaceObj, DistributedWantParams::VALUE_TYPE_NULL);
1057     EXPECT_FALSE(result);
1058     DTEST_LOG << "DistributedWantParamsBaseTest DistributedWantParams_CompareInterface_1200 end" << std::endl;
1059 }
1060 
1061 /**
1062  * @tc.number: DistributedWantParams_remove_0100
1063  * @tc.name: remove
1064  * @tc.desc: Test remove.
1065  * @tc.require: I77HFZ
1066  */
1067 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_remove_0100, Function | MediumTest | Level3)
1068 {
1069     DTEST_LOG << "DistributedWantParamsBaseTest DistributedWantParams_remove_0100 begin" << std::endl;
1070     ASSERT_NE(distributedWantParams_, nullptr);
1071     distributedWantParams_->params_["hello"] = String::Box("World");
1072     distributedWantParams_->Remove("hello");
1073     distributedWantParams_->params_.clear();
1074     EXPECT_TRUE(distributedWantParams_->params_.empty());
1075     DTEST_LOG << "DistributedWantParamsBaseTest DistributedWantParams_remove_0100 end" << std::endl;
1076 }
1077 
1078 /**
1079  * @tc.number: DistributedWantParams_IsEmpty_0100
1080  * @tc.name: IsEmpty
1081  * @tc.desc: Test IsEmpty.
1082  * @tc.require: I77HFZ
1083  */
1084 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_IsEmpty_0100, Function | MediumTest | Level3)
1085 {
1086     DTEST_LOG << "DistributedWantParamsBaseTest DistributedWantParams_IsEmpty_0100 begin" << std::endl;
1087     ASSERT_NE(distributedWantParams_, nullptr);
1088     distributedWantParams_->params_.clear();
1089     EXPECT_TRUE(distributedWantParams_->IsEmpty());
1090     DTEST_LOG << "DistributedWantParamsBaseTest DistributedWantParams_IsEmpty_0100 end" << std::endl;
1091 }
1092 
1093 /**
1094  * @tc.number: DistributedWantParams_DoMarshalling_0100
1095  * @tc.name: DoMarshalling
1096  * @tc.desc: Test DoMarshalling.
1097  * @tc.require: I77HFZ
1098  */
1099 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_DoMarshalling_0100, Function | MediumTest | Level3)
1100 {
1101     DTEST_LOG << "DistributedWantParamsBaseTest DistributedWantParams_DoMarshalling_0100 begin" << std::endl;
1102     ASSERT_NE(distributedWantParams_, nullptr);
1103     DistributedUnsupportedData data;
1104     distributedWantParams_->cachedUnsupportedData_.emplace_back(std::move(data));
1105     Parcel tempParcel;
1106     bool result = wantParamsIn_->DoMarshalling(tempParcel);
1107     distributedWantParams_->cachedUnsupportedData_.clear();
1108     EXPECT_TRUE(result);
1109     DTEST_LOG << "DistributedWantParamsBaseTest DistributedWantParams_DoMarshalling_0100 end" << std::endl;
1110 }
1111 
1112 
1113 /**
1114  * @tc.number: DistributedWantParams_ReadUnsupportedData_1100
1115  * @tc.name: ReadUnsupportedData
1116  * @tc.desc: Test ReadUnsupportedData.
1117  * @tc.require: I77HFZ
1118  */
1119 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_ReadUnsupportedData_1100, Function | MediumTest | Level3)
1120 {
1121     DTEST_LOG << "DistributedWantParamsBaseTest DistributedWantParams_ReadUnsupportedData_1100 begin" << std::endl;
1122     DistributedWantParams wantParams;
1123     Parcel parcel;
1124     std::string key = "this is key";
1125     int type = 1;
1126     parcel.WriteInt32(0);
1127     bool result = wantParams.ReadUnsupportedData(parcel, key, type);
1128     EXPECT_FALSE(result);
1129 
1130     int bufferSize = 1;
1131     parcel.WriteInt32(bufferSize);
1132     parcel.WriteInt32(0);
1133     bool result2 = wantParams.ReadUnsupportedData(parcel, key, type);
1134     EXPECT_FALSE(result2);
1135     DTEST_LOG << "DistributedWantParamsBaseTest DistributedWantParams_ReadUnsupportedData_1100 end" << std::endl;
1136 }
1137 
1138 /**
1139  * @tc.number: DistributedWantParams_ReadFromParcelParam_1000
1140  * @tc.name: ReadFromParcelParam
1141  * @tc.desc: Test ReadFromParcelParam.
1142  * @tc.require: I77HFZ
1143  */
1144 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_ReadFromParcelParam_1000, Function | MediumTest | Level3)
1145 {
1146     DTEST_LOG << "DistributedWantParamsBaseTest DistributedWantParams_ReadFromParcelParam_1000 begin" << std::endl;
1147     DistributedWantParams wantParams;
1148     Parcel parcel;
1149     std::string key = "this is key";
1150     int type = 51;
1151     int bufferSize = 1;
1152     parcel.WriteInt32(bufferSize);
1153     parcel.WriteInt32(0);
1154     bool result = wantParams.ReadFromParcelParam(parcel, key, type);
1155     EXPECT_TRUE(result);
1156     DTEST_LOG << "DistributedWantParamsBaseTest DistributedWantParams_ReadFromParcelParam_1000 end" << std::endl;
1157 }