• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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     stringVal =
210         DistributedWantParams::GetStringByType(boolObj, DistributedWantParams::VALUE_TYPE_NULL);
211     EXPECT_EQ(stringVal, "");
212 }
213 
214 /**
215  * @tc.number: DistributedWantParams_GetStringByType_0300
216  * @tc.name: GetStringByType
217  * @tc.desc: Test get string with invalid type in the WantParam.
218  */
219 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetStringByType_0300, Function | MediumTest | Level3)
220 {
221     const std::string value = "string";
222     sptr<IInterface> stringObj =
223         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_STRING, value);
224     std::string stringVal =
225         DistributedWantParams::GetStringByType(stringObj, DistributedWantParams::VALUE_TYPE_STRING);
226     EXPECT_EQ(stringVal, "string");
227 }
228 
229 /**
230  * @tc.number: DistributedWantParams_GetStringByType_0400
231  * @tc.name: GetStringByType
232  * @tc.desc: Test get byte with invalid type in the WantParam.
233  */
234 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetStringByType_0400, Function | MediumTest | Level3)
235 {
236     const std::string value = "129";
237     sptr<IInterface> byteObj =
238         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_BYTE, value);
239     std::string byteVal = DistributedWantParams::GetStringByType(byteObj, DistributedWantParams::VALUE_TYPE_BYTE);
240     EXPECT_EQ(byteVal, "129");
241 }
242 
243 /**
244  * @tc.number: DistributedWantParams_GetStringByType_0500
245  * @tc.name: GetStringByType
246  * @tc.desc: Test get char with invalid type in the WantParam.
247  */
248 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetStringByType_0500, Function | MediumTest | Level3)
249 {
250     const std::string value = "I";
251     sptr<IInterface> charObj =
252         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_CHAR, value);
253     std::string charVal = DistributedWantParams::GetStringByType(charObj, DistributedWantParams::VALUE_TYPE_CHAR);
254     EXPECT_EQ(charVal, "I");
255 }
256 
257 /**
258  * @tc.number: DistributedWantParams_GetStringByType_0600
259  * @tc.name: GetStringByType
260  * @tc.desc: Test get short with invalid type in the WantParam.
261  */
262 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetStringByType_0600, Function | MediumTest | Level3)
263 {
264     const std::string value = "123";
265     sptr<IInterface> shortObj =
266         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_SHORT, value);
267     std::string shortVal = DistributedWantParams::GetStringByType(shortObj, DistributedWantParams::VALUE_TYPE_SHORT);
268     EXPECT_EQ(shortVal, "123");
269 }
270 
271 /**
272  * @tc.number: DistributedWantParams_GetStringByType_0700
273  * @tc.name: GetStringByType
274  * @tc.desc: Test get int with invalid type in the WantParam.
275  */
276 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetStringByType_0700, Function | MediumTest | Level3)
277 {
278     const std::string value = "-1";
279     sptr<IInterface> intObj = DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_INT, value);
280     std::string intVal = DistributedWantParams::GetStringByType(intObj, DistributedWantParams::VALUE_TYPE_INT);
281     EXPECT_EQ(intVal, "-1");
282 }
283 
284 /**
285  * @tc.number: DistributedWantParams_GetStringByType_0800
286  * @tc.name: GetStringByType
287  * @tc.desc: Test get long with invalid type in the WantParam.
288  */
289 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetStringByType_0800, Function | MediumTest | Level3)
290 {
291     const std::string value = "-1";
292     sptr<IInterface> longObj =
293         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_LONG, value);
294     std::string longVal = DistributedWantParams::GetStringByType(longObj, DistributedWantParams::VALUE_TYPE_LONG);
295     EXPECT_EQ(longVal, "-1");
296 }
297 
298 /**
299  * @tc.number: DistributedWantParams_GetStringByType_0900
300  * @tc.name: GetStringByType
301  * @tc.desc: Test get float with invalid type in the WantParam.
302  */
303 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetStringByType_0900, Function | MediumTest | Level3)
304 {
305     const std::string value = "-1.0004";
306     sptr<IInterface> floatObj =
307         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_FLOAT, value);
308     std::string floatVal = DistributedWantParams::GetStringByType(floatObj, DistributedWantParams::VALUE_TYPE_FLOAT);
309     EXPECT_EQ(floatVal, "-1.000400");
310 }
311 
312 /**
313  * @tc.number: DistributedWantParams_GetStringByType_1000
314  * @tc.name: GetStringByType
315  * @tc.desc: Test get float with invalid type in the WantParam.
316  */
317 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetStringByType_1000, Function | MediumTest | Level3)
318 {
319     const std::string value = "-1.00000004";
320     sptr<IInterface> doubleObj =
321         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_DOUBLE, value);
322     std::string doubleVal =
323         DistributedWantParams::GetStringByType(doubleObj, DistributedWantParams::VALUE_TYPE_DOUBLE);
324     EXPECT_EQ(doubleVal, "-1.000000");
325 }
326 
327 /**
328  * @tc.number: DistributedWantParams_GetStringByType_1100
329  * @tc.name: GetStringByType
330  * @tc.desc: Test get float with invalid type in the WantParam.
331  */
332 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetStringByType_1100, Function | MediumTest | Level3)
333 {
334     const std::string value = "I5{2,3,5,7,11}";
335     sptr<IInterface> arrayObj =
336         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_ARRAY, value);
337     std::string arrayVal = DistributedWantParams::GetStringByType(arrayObj, DistributedWantParams::VALUE_TYPE_ARRAY);
338     EXPECT_EQ(arrayVal, "I5{2,3,5,7,11}");
339 }
340 
341 /**
342  * @tc.number: DistributedWantParams_NewArrayData_0100
343  * @tc.name: NewArrayData
344  * @tc.desc: Test NewArrayData with invalid sptr<IArray> parameter.
345  */
346 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_NewArrayData_0100, Function | MediumTest | Level3)
347 {
348     sptr<AAFwk::IArray> array = new (std::nothrow) AAFwk::Array(0, g_IID_IDistributedWantParams);
349     DistributedWantParams wp;
350     wp.SetParam("param1", array);
351     IArray *iarray = IArray::Query(array);
352     sptr<IArray> destAO = nullptr;
353     bool result = wp.NewArrayData(iarray, destAO);
354     EXPECT_FALSE(result);
355 }
356 
357 /**
358  * @tc.number: DistributedWantParams_GetDataType_0100
359  * @tc.name: GetDataType
360  * @tc.desc: Test GetDataType with invalid parameter.
361  */
362 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetDataType_0100, Function | MediumTest | Level3)
363 {
364     int type = DistributedWantParams::GetDataType(nullptr);
365     EXPECT_EQ(type, DistributedWantParams::VALUE_TYPE_NULL);
366 }
367 
368 /**
369  * @tc.number: DistributedWantParams_GetDataType_0200
370  * @tc.name: GetDataType
371  * @tc.desc: Test GetDataType with bool parameter.
372  */
373 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetDataType_0200, Function | MediumTest | Level3)
374 {
375     const std::string value = "true";
376     sptr<IInterface> boolObj =
377         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_BOOLEAN, value);
378     int type = DistributedWantParams::GetDataType(boolObj);
379     EXPECT_EQ(type, DistributedWantParams::VALUE_TYPE_BOOLEAN);
380 }
381 
382 /**
383  * @tc.number: DistributedWantParams_GetDataType_0300
384  * @tc.name: GetDataType
385  * @tc.desc: Test GetDataType with byte parameter.
386  */
387 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetDataType_0300, Function | MediumTest | Level3)
388 {
389     const std::string value = "129";
390     sptr<IInterface> byteObj =
391         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_BYTE, value);
392     int type = DistributedWantParams::GetDataType(byteObj);
393     EXPECT_EQ(type, DistributedWantParams::VALUE_TYPE_BYTE);
394 }
395 
396 /**
397  * @tc.number: DistributedWantParams_GetDataType_0400
398  * @tc.name: GetDataType
399  * @tc.desc: Test GetDataType with char parameter.
400  */
401 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetDataType_0400, Function | MediumTest | Level3)
402 {
403     const std::string value = "I";
404     sptr<IInterface> charObj =
405         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_CHAR, value);
406     int type = DistributedWantParams::GetDataType(charObj);
407     EXPECT_EQ(type, DistributedWantParams::VALUE_TYPE_CHAR);
408 }
409 
410 /**
411  * @tc.number: DistributedWantParams_GetDataType_0500
412  * @tc.name: GetDataType
413  * @tc.desc: Test GetDataType with short parameter.
414  */
415 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetDataType_0500, Function | MediumTest | Level3)
416 {
417     const std::string value = "123";
418     sptr<IInterface> shortObj =
419         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_SHORT, value);
420     int type = DistributedWantParams::GetDataType(shortObj);
421     EXPECT_EQ(type, DistributedWantParams::VALUE_TYPE_SHORT);
422 }
423 
424 /**
425  * @tc.number: DistributedWantParams_GetDataType_0600
426  * @tc.name: GetDataType
427  * @tc.desc: Test GetDataType with int parameter.
428  */
429 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetDataType_0600, Function | MediumTest | Level3)
430 {
431     const std::string value = "-1";
432     sptr<IInterface> intObj = DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_INT, value);
433     int type = DistributedWantParams::GetDataType(intObj);
434     EXPECT_EQ(type, DistributedWantParams::VALUE_TYPE_INT);
435 }
436 
437 /**
438  * @tc.number: DistributedWantParams_GetDataType_0700
439  * @tc.name: GetDataType
440  * @tc.desc: Test GetDataType with long parameter.
441  */
442 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetDataType_0700, Function | MediumTest | Level3)
443 {
444     const std::string value = "-1";
445     sptr<IInterface> longObj = DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_LONG, value);
446     int type = DistributedWantParams::GetDataType(longObj);
447     EXPECT_EQ(type, DistributedWantParams::VALUE_TYPE_LONG);
448 }
449 
450 /**
451  * @tc.number: DistributedWantParams_GetDataType_0800
452  * @tc.name: GetDataType
453  * @tc.desc: Test GetDataType with float parameter.
454  */
455 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetDataType_0800, Function | MediumTest | Level3)
456 {
457     const std::string value = "-1.0004";
458     sptr<IInterface> floatObj =
459         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_FLOAT, value);
460     int type = DistributedWantParams::GetDataType(floatObj);
461     EXPECT_EQ(type, DistributedWantParams::VALUE_TYPE_FLOAT);
462 }
463 
464 /**
465  * @tc.number: DistributedWantParams_GetDataType_0900
466  * @tc.name: GetDataType
467  * @tc.desc: Test GetDataType with double parameter.
468  */
469 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetDataType_0900, Function | MediumTest | Level3)
470 {
471     const std::string value = "-1.00000004";
472     sptr<IInterface> doubleObj =
473         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_DOUBLE, value);
474     int type = DistributedWantParams::GetDataType(doubleObj);
475     EXPECT_EQ(type, DistributedWantParams::VALUE_TYPE_DOUBLE);
476 }
477 
478 /**
479  * @tc.number: DistributedWantParams_GetDataType_1000
480  * @tc.name: GetDataType
481  * @tc.desc: Test GetDataType with string parameter.
482  */
483 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetDataType_1000, Function | MediumTest | Level3)
484 {
485     const std::string value = "hello";
486     sptr<IInterface> stringObj =
487         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_STRING, value);
488     int type = DistributedWantParams::GetDataType(stringObj);
489     EXPECT_EQ(type, DistributedWantParams::VALUE_TYPE_STRING);
490 }
491 
492 /**
493  * @tc.number: DistributedWantParams_GetDataType_1100
494  * @tc.name: GetDataType
495  * @tc.desc: Test GetDataType with array parameter.
496  */
497 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetDataType_1100, Function | MediumTest | Level3)
498 {
499     const std::string value = "I5{2,3,5,7,11}";
500     sptr<IInterface> interfaceObj =
501         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_ARRAY, value);
502     int type = DistributedWantParams::GetDataType(interfaceObj);
503     EXPECT_EQ(type, DistributedWantParams::VALUE_TYPE_ARRAY);
504 }
505 
506 /**
507  * @tc.number: DistributedWantParams_GetInterfaceByType_0100
508  * @tc.name: GetInterfaceByType
509  * @tc.desc: Test GetInterfaceByType with boolean type.
510  */
511 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetInterfaceByType_0100, Function | MediumTest | Level3)
512 {
513     const std::string value = "true";
514     sptr<IInterface> boolObj =
515         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_BOOLEAN, value);
516     EXPECT_TRUE(Boolean::Unbox(IBoolean::Query(boolObj)));
517 }
518 
519 /**
520  * @tc.number: DistributedWantParams_GetInterfaceByType_0200
521  * @tc.name: GetInterfaceByType
522  * @tc.desc: Test GetInterfaceByType with byte type.
523  */
524 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetInterfaceByType_0200, Function | MediumTest | Level3)
525 {
526     const std::string value = "129";
527     sptr<IInterface> byteObj =
528         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_BYTE, value);
529     EXPECT_EQ(Byte::Unbox(IByte::Query(byteObj)), 129);
530 }
531 
532 /**
533  * @tc.number: DistributedWantParams_GetInterfaceByType_0300
534  * @tc.name: GetInterfaceByType
535  * @tc.desc: Test GetInterfaceByType with char type.
536  */
537 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetInterfaceByType_0300, Function | MediumTest | Level3)
538 {
539     const std::string value = "I";
540     sptr<IInterface> charObj =
541         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_CHAR, value);
542     EXPECT_EQ(Char::Unbox(IChar::Query(charObj)), 'I');
543 }
544 
545 /**
546  * @tc.number: DistributedWantParams_GetInterfaceByType_0400
547  * @tc.name: GetInterfaceByType
548  * @tc.desc: Test GetInterfaceByType with short type.
549  */
550 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetInterfaceByType_0400, Function | MediumTest | Level3)
551 {
552     const std::string value = "123";
553     sptr<IInterface> shortObj =
554         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_SHORT, value);
555     EXPECT_EQ(Short::Unbox(IShort::Query(shortObj)), 123);
556 }
557 
558 /**
559  * @tc.number: DistributedWantParams_GetInterfaceByType_0500
560  * @tc.name: GetInterfaceByType
561  * @tc.desc: Test GetInterfaceByType with integer type.
562  */
563 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetInterfaceByType_0500, Function | MediumTest | Level3)
564 {
565     const std::string value = "-1";
566     sptr<IInterface> intObj = DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_INT, value);
567     EXPECT_EQ(Integer::Unbox(IInteger::Query(intObj)), -1);
568 }
569 
570 /**
571  * @tc.number: DistributedWantParams_GetInterfaceByType_0600
572  * @tc.name: GetInterfaceByType
573  * @tc.desc: Test GetInterfaceByType with long type.
574  */
575 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetInterfaceByType_0600, Function | MediumTest | Level3)
576 {
577     const std::string value = "-1";
578     sptr<IInterface> longObj =
579         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_LONG, value);
580     EXPECT_EQ(Long::Unbox(ILong::Query(longObj)), -1);
581 }
582 
583 /**
584  * @tc.number: DistributedWantParams_GetInterfaceByType_0700
585  * @tc.name: GetInterfaceByType
586  * @tc.desc: Test GetInterfaceByType with float type.
587  */
588 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetInterfaceByType_0700, Function | MediumTest | Level3)
589 {
590     const std::string value = "-1.0004";
591     sptr<IInterface> floatObj =
592         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_FLOAT, value);
593     EXPECT_FLOAT_EQ(Float::Unbox(IFloat::Query(floatObj)), -1.0004);
594 }
595 
596 /**
597  * @tc.number: DistributedWantParams_GetInterfaceByType_0800
598  * @tc.name: GetInterfaceByType
599  * @tc.desc: Test GetInterfaceByType with double type.
600  */
601 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetInterfaceByType_0800, Function | MediumTest | Level3)
602 {
603     const std::string value = "-1.00000004";
604     sptr<IInterface> doubleObj =
605         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_DOUBLE, value);
606     EXPECT_DOUBLE_EQ(Double::Unbox(IDouble::Query(doubleObj)), -1.00000004);
607 }
608 
609 /**
610  * @tc.number: DistributedWantParams_GetInterfaceByType_0900
611  * @tc.name: GetInterfaceByType
612  * @tc.desc: Test GetInterfaceByType with string type.
613  */
614 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetInterfaceByType_0900, Function | MediumTest | Level3)
615 {
616     const std::string value = "hello";
617     sptr<IInterface> stringObj =
618         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_STRING, value);
619     EXPECT_EQ(String::Unbox(IString::Query(stringObj)), std::string("hello"));
620 }
621 
622 /**
623  * @tc.number: DistributedWantParams_GetInterfaceByType_1000
624  * @tc.name: GetInterfaceByType
625  * @tc.desc: Test GetInterfaceByType with array type.
626  */
627 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetInterfaceByType_1000, Function | MediumTest | Level3)
628 {
629     const std::string value = "I5{2,3,5,7,11}";
630     sptr<IInterface> interfaceObj =
631         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_ARRAY, value);
632     Array* arrayObj = static_cast<Array *>(IArray::Query(interfaceObj));
633     sptr<IInterface> valueObj;
634     arrayObj->Get(0, valueObj);
635     EXPECT_EQ(Integer::Unbox(IInteger::Query(valueObj)), 2);
636     arrayObj->Get(1, valueObj);
637     EXPECT_EQ(Integer::Unbox(IInteger::Query(valueObj)), 3);
638     arrayObj->Get(2, valueObj);
639     EXPECT_EQ(Integer::Unbox(IInteger::Query(valueObj)), 5);
640     arrayObj->Get(3, valueObj);
641     EXPECT_EQ(Integer::Unbox(IInteger::Query(valueObj)), 7);
642     arrayObj->Get(4, valueObj);
643     EXPECT_EQ(Integer::Unbox(IInteger::Query(valueObj)), 11);
644 }
645 
646 /**
647  * @tc.number: DistributedWantParams_GetInterfaceByType_1100
648  * @tc.name: GetInterfaceByType
649  * @tc.desc: Test GetInterfaceByType with invalid type.
650  */
651 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_GetInterfaceByType_1100, Function | MediumTest | Level3)
652 {
653     const std::string value = "123";
654     sptr<IInterface> arrayObj =
655         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_NULL, value);
656     EXPECT_EQ(arrayObj, nullptr);
657 }
658 
659 /**
660  * @tc.number: DistributedWantParams_CompareInterface_0100
661  * @tc.name: CompareInterface
662  * @tc.desc: Test CompareInterface with bool type.
663  */
664 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_CompareInterface_0100, Function | MediumTest | Level3)
665 {
666     const std::string value = "true";
667     sptr<IInterface> interfaceObj =
668         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_BOOLEAN, value);
669     bool result =
670         DistributedWantParams::CompareInterface(interfaceObj, interfaceObj, DistributedWantParams::VALUE_TYPE_BOOLEAN);
671     EXPECT_TRUE(result);
672 }
673 
674 /**
675  * @tc.number: DistributedWantParams_CompareInterface_0200
676  * @tc.name: CompareInterface
677  * @tc.desc: Test CompareInterface with byte type.
678  */
679 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_CompareInterface_0200, Function | MediumTest | Level3)
680 {
681     const std::string value = "129";
682     sptr<IInterface> interfaceObj =
683         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_BYTE, value);
684     bool result =
685         DistributedWantParams::CompareInterface(interfaceObj, interfaceObj, DistributedWantParams::VALUE_TYPE_BYTE);
686     EXPECT_TRUE(result);
687 }
688 
689 /**
690  * @tc.number: DistributedWantParams_CompareInterface_0300
691  * @tc.name: CompareInterface
692  * @tc.desc: Test CompareInterface with char type.
693  */
694 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_CompareInterface_0300, Function | MediumTest | Level3)
695 {
696     const std::string value = "I";
697     sptr<IInterface> interfaceObj =
698         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_CHAR, value);
699     bool result =
700         DistributedWantParams::CompareInterface(interfaceObj, interfaceObj, DistributedWantParams::VALUE_TYPE_CHAR);
701     EXPECT_TRUE(result);
702 }
703 
704 /**
705  * @tc.number: DistributedWantParams_CompareInterface_0400
706  * @tc.name: CompareInterface
707  * @tc.desc: Test CompareInterface with short type.
708  */
709 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_CompareInterface_0400, Function | MediumTest | Level3)
710 {
711     const std::string value = "123";
712     sptr<IInterface> interfaceObj =
713         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_SHORT, value);
714     bool result =
715         DistributedWantParams::CompareInterface(interfaceObj, interfaceObj, DistributedWantParams::VALUE_TYPE_SHORT);
716     EXPECT_TRUE(result);
717 }
718 
719 /**
720  * @tc.number: DistributedWantParams_CompareInterface_0500
721  * @tc.name: CompareInterface
722  * @tc.desc: Test CompareInterface with integer type.
723  */
724 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_CompareInterface_0500, Function | MediumTest | Level3)
725 {
726     const std::string value = "-1";
727     sptr<IInterface> interfaceObj =
728         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_INT, value);
729     bool result =
730         DistributedWantParams::CompareInterface(interfaceObj, interfaceObj, DistributedWantParams::VALUE_TYPE_INT);
731     EXPECT_TRUE(result);
732 }
733 
734 /**
735  * @tc.number: DistributedWantParams_CompareInterface_0600
736  * @tc.name: CompareInterface
737  * @tc.desc: Test CompareInterface with long type.
738  */
739 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_CompareInterface_0600, Function | MediumTest | Level3)
740 {
741     const std::string value = "-1";
742     sptr<IInterface> interfaceObj =
743         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_LONG, value);
744     bool result =
745         DistributedWantParams::CompareInterface(interfaceObj, interfaceObj, DistributedWantParams::VALUE_TYPE_LONG);
746     EXPECT_TRUE(result);
747 }
748 
749 /**
750  * @tc.number: DistributedWantParams_CompareInterface_0700
751  * @tc.name: CompareInterface
752  * @tc.desc: Test CompareInterface with float type.
753  */
754 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_CompareInterface_0700, Function | MediumTest | Level3)
755 {
756     const std::string value = "-1.0004";
757     sptr<IInterface> interfaceObj =
758         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_FLOAT, value);
759     bool result =
760         DistributedWantParams::CompareInterface(interfaceObj, interfaceObj, DistributedWantParams::VALUE_TYPE_FLOAT);
761     EXPECT_TRUE(result);
762 }
763 
764 /**
765  * @tc.number: DistributedWantParams_CompareInterface_0800
766  * @tc.name: CompareInterface
767  * @tc.desc: Test CompareInterface with double type.
768  */
769 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_CompareInterface_0800, Function | MediumTest | Level3)
770 {
771     const std::string value = "-1.00000004";
772     sptr<IInterface> interfaceObj =
773         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_DOUBLE, value);
774     bool result =
775         DistributedWantParams::CompareInterface(interfaceObj, interfaceObj, DistributedWantParams::VALUE_TYPE_DOUBLE);
776     EXPECT_TRUE(result);
777 }
778 
779 /**
780  * @tc.number: DistributedWantParams_CompareInterface_0900
781  * @tc.name: CompareInterface
782  * @tc.desc: Test CompareInterface with string type.
783  */
784 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_CompareInterface_0900, Function | MediumTest | Level3)
785 {
786     const std::string value = "hello";
787     sptr<IInterface> interfaceObj =
788         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_STRING, value);
789     bool result =
790         DistributedWantParams::CompareInterface(interfaceObj, interfaceObj, DistributedWantParams::VALUE_TYPE_STRING);
791     EXPECT_TRUE(result);
792 }
793 
794 /**
795  * @tc.number: DistributedWantParams_CompareInterface_1000
796  * @tc.name: CompareInterface
797  * @tc.desc: Test CompareInterface with array type.
798  */
799 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_CompareInterface_1000, Function | MediumTest | Level3)
800 {
801     const std::string value = "I5{2,3,5,7,11}";
802     sptr<IInterface> interfaceObj =
803         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_ARRAY, value);
804     bool result =
805         DistributedWantParams::CompareInterface(interfaceObj, interfaceObj, DistributedWantParams::VALUE_TYPE_ARRAY);
806     EXPECT_TRUE(result);
807 }
808 
809 /**
810  * @tc.number: DistributedWantParams_WriteArrayToParStr_0100
811  * @tc.name: WriteArrayToParcelString
812  * @tc.desc: Test WriteArrayToParcelString string content.
813  */
814 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_WriteArrayToParStr_0100, Function | MediumTest | Level3)
815 {
816     Parcel parcel;
817     DistributedWantParams wp;
818     bool result = wp.WriteArrayToParcelString(parcel, nullptr);
819     EXPECT_FALSE(result);
820 }
821 
822 /**
823  * @tc.number: DistributedWantParams_WriteArrayToParBo_0100
824  * @tc.name: WriteArrayToParcelBool
825  * @tc.desc: Test WriteArrayToParcelBool bool content.
826  */
827 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_WriteArrayToParBo_0100, Function | MediumTest | Level3)
828 {
829     Parcel parcel;
830     DistributedWantParams wp;
831     bool result = wp.WriteArrayToParcelBool(parcel, nullptr);
832     EXPECT_FALSE(result);
833 }
834 
835 /**
836  * @tc.number: DistributedWantParams_WriteArrayToParBy_0100
837  * @tc.name: WriteArrayToParcelByte
838  * @tc.desc: Test WriteArrayToParcelByte byte content.
839  */
840 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_WriteArrayToParBy_0100, Function | MediumTest | Level3)
841 {
842     Parcel parcel;
843     DistributedWantParams wp;
844     bool result = wp.WriteArrayToParcelByte(parcel, nullptr);
845     EXPECT_FALSE(result);
846 }
847 
848 /**
849  * @tc.number: DistributedWantParams_WriteArrayToParCh_0100
850  * @tc.name: WriteArrayToParcelChar
851  * @tc.desc: Test WriteArrayToParcelChar char content.
852  */
853 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_WriteArrayToParCh_0100, Function | MediumTest | Level3)
854 {
855     Parcel parcel;
856     DistributedWantParams wp;
857     bool result = wp.WriteArrayToParcelChar(parcel, nullptr);
858     EXPECT_FALSE(result);
859 }
860 
861 /**
862  * @tc.number: DistributedWantParams_WriteArrayToParSho_0100
863  * @tc.name: WriteArrayToParcelShort
864  * @tc.desc: Test WriteArrayToParcelShort short content.
865  */
866 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_WriteArrayToParSho_0100, Function | MediumTest | Level3)
867 {
868     Parcel parcel;
869     DistributedWantParams wp;
870     bool result = wp.WriteArrayToParcelShort(parcel, nullptr);
871     EXPECT_FALSE(result);
872 }
873 
874 /**
875  * @tc.number: DistributedWantParams_WriteArrayToParInt_0100
876  * @tc.name: WriteArrayToParcelInt
877  * @tc.desc: Test WriteArrayToParcelInt int content.
878  */
879 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_WriteArrayToParInt_0100, Function | MediumTest | Level3)
880 {
881     Parcel parcel;
882     DistributedWantParams wp;
883     bool result = wp.WriteArrayToParcelInt(parcel, nullptr);
884     EXPECT_FALSE(result);
885 }
886 
887 /**
888  * @tc.number: DistributedWantParams_WriteArrayToParLo_0100
889  * @tc.name: WriteArrayToParcelLong
890  * @tc.desc: Test WriteArrayToParcelLong long content.
891  */
892 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_WriteArrayToParLo_0100, Function | MediumTest | Level3)
893 {
894     Parcel parcel;
895     DistributedWantParams wp;
896     bool result = wp.WriteArrayToParcelLong(parcel, nullptr);
897     EXPECT_FALSE(result);
898 }
899 
900 /**
901  * @tc.number: DistributedWantParams_WriteArrayToParFl_0100
902  * @tc.name: WriteArrayToParcelFloat
903  * @tc.desc: Test WriteArrayToParcelFloat float content.
904  */
905 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_WriteArrayToParFl_0100, Function | MediumTest | Level3)
906 {
907     Parcel parcel;
908     DistributedWantParams wp;
909     bool result = wp.WriteArrayToParcelFloat(parcel, nullptr);
910     EXPECT_FALSE(result);
911 }
912 
913 /**
914  * @tc.number: DistributedWantParams_WriteArrayToParDou_0100
915  * @tc.name: WriteArrayToParcelDouble
916  * @tc.desc: Test WriteArrayToParcelDouble double content.
917  */
918 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_WriteArrayToParDou_0100, Function | MediumTest | Level3)
919 {
920     Parcel parcel;
921     DistributedWantParams wp;
922     bool result = wp.WriteArrayToParcelDouble(parcel, nullptr);
923     EXPECT_FALSE(result);
924 }
925 
926 class DistributedUnsupportedDataTest : public testing::Test {
927 public:
DistributedUnsupportedDataTest()928     DistributedUnsupportedDataTest()
929     {}
~DistributedUnsupportedDataTest()930     ~DistributedUnsupportedDataTest()
931     {
932     }
933     static void SetUpTestCase(void);
934     static void TearDownTestCase(void);
935     void SetUp();
936     void TearDown();
937 
938     std::shared_ptr<DistributedUnsupportedData> unsupportedData_ = nullptr;
939 };
940 
SetUpTestCase(void)941 void DistributedUnsupportedDataTest::SetUpTestCase(void)
942 {}
943 
TearDownTestCase(void)944 void DistributedUnsupportedDataTest::TearDownTestCase(void)
945 {}
946 
SetUp(void)947 void DistributedUnsupportedDataTest::SetUp(void)
948 {
949     unsupportedData_ = std::make_shared<DistributedUnsupportedData>();
950 }
951 
TearDown(void)952 void DistributedUnsupportedDataTest::TearDown(void)
953 {
954 }
955 
956 /**
957  * @tc.number: DistributedUnsupportedData_Test
958  * @tc.name: DistributedUnsupportedData
959  * @tc.desc: Test DistributedUnsupportedData.
960  * @tc.require: issueI648W6
961  */
962 HWTEST_F(DistributedUnsupportedDataTest, DistributedUnsupportedData_Test, Function | MediumTest | Level3)
963 {
964     DistributedUnsupportedData data1;
965     data1.size = 5;
966     data1.buffer = new uint8_t[data1.size];
967     DistributedUnsupportedData data2(data1);
968     EXPECT_EQ(data2.size, data1.size);
969     EXPECT_NE(data2.buffer, nullptr);
970     EXPECT_NE(data1.buffer, nullptr);
971 
972     DistributedUnsupportedData data3 = data1;
973     EXPECT_EQ(data3.size, data1.size);
974     EXPECT_NE(data3.buffer, nullptr);
975     EXPECT_NE(data3.buffer, nullptr);
976 
977     DistributedUnsupportedData data4(std::move(data1));
978     EXPECT_EQ(data4.size, data3.size);
979     EXPECT_NE(data4.buffer, nullptr);
980     EXPECT_EQ(data1.buffer, nullptr);
981     EXPECT_EQ(data1.size, 0);
982 
983     DistributedUnsupportedData data5 = std::move(data1);
984     EXPECT_EQ(data5.buffer, nullptr);
985     EXPECT_EQ(data1.buffer, nullptr);
986 
987     DistributedUnsupportedData data6 = std::move(data2);
988     EXPECT_NE(data6.buffer, nullptr);
989     EXPECT_EQ(data2.buffer, nullptr);
990 }
991 
992 /**
993  * @tc.number: DistributedWantParams_ReadArrayToParcel_1000
994  * @tc.name: ReadArrayToParcel
995  * @tc.desc: Test ReadArrayToParcel.
996  * @tc.require: issueI648W6
997  */
998 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_ReadArrayToParcel_1000, Function | MediumTest | Level3)
999 {
1000     DistributedWantParams wantParams;
1001     Parcel parcel;
1002     int type = 1;
1003     sptr<IArray> destAO = nullptr;
1004     bool result = wantParams.ReadArrayToParcel(parcel, type, destAO);
1005     EXPECT_EQ(result, true);
1006 }
1007 
1008 /**
1009  * @tc.number: DistributedWantParams_ReadUnsupportedData_1000
1010  * @tc.name: ReadUnsupportedData
1011  * @tc.desc: Test ReadUnsupportedData.
1012  * @tc.require: issueI648W6
1013  */
1014 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_ReadUnsupportedData_1000, Function | MediumTest | Level3)
1015 {
1016     DistributedWantParams wantParams;
1017     Parcel parcel;
1018     std::string key = "this is key";
1019     int type = 1;
1020     bool result = wantParams.ReadUnsupportedData(parcel, key, type);
1021     EXPECT_EQ(result, false);
1022 
1023     parcel.WriteInt32(-1);
1024     bool result1 = wantParams.ReadUnsupportedData(parcel, key, type);
1025     EXPECT_EQ(result1, false);
1026 
1027     int type1 = 50;
1028     bool result2 = wantParams.ReadFromParcelParam(parcel, key, type1);
1029     EXPECT_EQ(result2, false);
1030 }
1031 
1032 /**
1033  * @tc.number: DistributedWantParams_CompareInterface_1200
1034  * @tc.name: CompareInterface
1035  * @tc.desc: Test CompareInterface.
1036  * @tc.require: I77HFZ
1037  */
1038 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_CompareInterface_1200, Function | MediumTest | Level3)
1039 {
1040     DTEST_LOG << "DistributedWantParamsBaseTest DistributedWantParams_CompareInterface_1200 begin" << std::endl;
1041     const std::string value = "wantParam";
1042     sptr<IInterface> interfaceObj =
1043         DistributedWantParams::GetInterfaceByType(DistributedWantParams::VALUE_TYPE_NULL, value);
1044     bool result =
1045         DistributedWantParams::CompareInterface(interfaceObj, interfaceObj, DistributedWantParams::VALUE_TYPE_NULL);
1046     EXPECT_FALSE(result);
1047     DTEST_LOG << "DistributedWantParamsBaseTest DistributedWantParams_CompareInterface_1200 end" << std::endl;
1048 }
1049 
1050 /**
1051  * @tc.number: DistributedWantParams_remove_0100
1052  * @tc.name: remove
1053  * @tc.desc: Test remove.
1054  * @tc.require: I77HFZ
1055  */
1056 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_remove_0100, Function | MediumTest | Level3)
1057 {
1058     DTEST_LOG << "DistributedWantParamsBaseTest DistributedWantParams_remove_0100 begin" << std::endl;
1059     ASSERT_NE(distributedWantParams_, nullptr);
1060     distributedWantParams_->params_["hello"] = String::Box("World");
1061     distributedWantParams_->Remove("hello");
1062     distributedWantParams_->params_.clear();
1063     EXPECT_TRUE(distributedWantParams_->params_.empty());
1064     DTEST_LOG << "DistributedWantParamsBaseTest DistributedWantParams_remove_0100 end" << std::endl;
1065 }
1066 
1067 /**
1068  * @tc.number: DistributedWantParams_IsEmpty_0100
1069  * @tc.name: IsEmpty
1070  * @tc.desc: Test IsEmpty.
1071  * @tc.require: I77HFZ
1072  */
1073 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_IsEmpty_0100, Function | MediumTest | Level3)
1074 {
1075     DTEST_LOG << "DistributedWantParamsBaseTest DistributedWantParams_IsEmpty_0100 begin" << std::endl;
1076     ASSERT_NE(distributedWantParams_, nullptr);
1077     distributedWantParams_->params_.clear();
1078     EXPECT_TRUE(distributedWantParams_->IsEmpty());
1079     DTEST_LOG << "DistributedWantParamsBaseTest DistributedWantParams_IsEmpty_0100 end" << std::endl;
1080 }
1081 
1082 /**
1083  * @tc.number: DistributedWantParams_DoMarshalling_0100
1084  * @tc.name: DoMarshalling
1085  * @tc.desc: Test DoMarshalling.
1086  * @tc.require: I77HFZ
1087  */
1088 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_DoMarshalling_0100, Function | MediumTest | Level3)
1089 {
1090     DTEST_LOG << "DistributedWantParamsBaseTest DistributedWantParams_DoMarshalling_0100 begin" << std::endl;
1091     ASSERT_NE(distributedWantParams_, nullptr);
1092     DistributedUnsupportedData data;
1093     distributedWantParams_->cachedUnsupportedData_.emplace_back(std::move(data));
1094     Parcel tempParcel;
1095     bool result = wantParamsIn_->DoMarshalling(tempParcel);
1096     distributedWantParams_->cachedUnsupportedData_.clear();
1097     EXPECT_TRUE(result);
1098     DTEST_LOG << "DistributedWantParamsBaseTest DistributedWantParams_DoMarshalling_0100 end" << std::endl;
1099 }
1100 
1101 
1102 /**
1103  * @tc.number: DistributedWantParams_ReadUnsupportedData_1100
1104  * @tc.name: ReadUnsupportedData
1105  * @tc.desc: Test ReadUnsupportedData.
1106  * @tc.require: I77HFZ
1107  */
1108 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_ReadUnsupportedData_1100, Function | MediumTest | Level3)
1109 {
1110     DTEST_LOG << "DistributedWantParamsBaseTest DistributedWantParams_ReadUnsupportedData_1100 begin" << std::endl;
1111     DistributedWantParams wantParams;
1112     Parcel parcel;
1113     std::string key = "this is key";
1114     int type = 1;
1115     parcel.WriteInt32(0);
1116     bool result = wantParams.ReadUnsupportedData(parcel, key, type);
1117     EXPECT_FALSE(result);
1118 
1119     int bufferSize = 1;
1120     parcel.WriteInt32(bufferSize);
1121     parcel.WriteInt32(0);
1122     bool result2 = wantParams.ReadUnsupportedData(parcel, key, type);
1123     EXPECT_FALSE(result2);
1124     DTEST_LOG << "DistributedWantParamsBaseTest DistributedWantParams_ReadUnsupportedData_1100 end" << std::endl;
1125 }
1126 
1127 /**
1128  * @tc.number: DistributedWantParams_ReadFromParcelParam_1000
1129  * @tc.name: ReadFromParcelParam
1130  * @tc.desc: Test ReadFromParcelParam.
1131  * @tc.require: I77HFZ
1132  */
1133 HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_ReadFromParcelParam_1000, Function | MediumTest | Level3)
1134 {
1135     DTEST_LOG << "DistributedWantParamsBaseTest DistributedWantParams_ReadFromParcelParam_1000 begin" << std::endl;
1136     DistributedWantParams wantParams;
1137     Parcel parcel;
1138     std::string key = "this is key";
1139     int type = 51;
1140     int bufferSize = 1;
1141     parcel.WriteInt32(bufferSize);
1142     parcel.WriteInt32(0);
1143     bool result = wantParams.ReadFromParcelParam(parcel, key, type);
1144     EXPECT_TRUE(result);
1145     DTEST_LOG << "DistributedWantParamsBaseTest DistributedWantParams_ReadFromParcelParam_1000 end" << std::endl;
1146 }
1147 
1148 /**
1149  * @tc.number: ReadFromParcelWantParamWrapper_1000
1150  * @tc.name: ReadFromParcelWantParamWrapper
1151  * @tc.desc: Test ReadFromParcelWantParamWrapper.
1152  * @tc.require: I77HFZ
1153  */
1154 HWTEST_F(DistributedWantParamsBaseTest, ReadFromParcelWantParamWrapper_1000, Function | MediumTest | Level3)
1155 {
1156     DTEST_LOG << "DistributedWantParamsBaseTest ReadFromParcelWantParamWrapper_1000 begin" << std::endl;
1157     DistributedWantParams wantParams;
1158     Parcel parcel;
1159     std::string key = "this is key";
1160     int type = DistributedWantParams::VALUE_TYPE_FD;
1161     int bufferSize = 1;
1162     parcel.WriteInt32(bufferSize);
1163     parcel.WriteInt32(0);
1164     bool result = wantParams.ReadFromParcelWantParamWrapper(parcel, key, type);
1165     EXPECT_TRUE(result);
1166 
1167     type = DistributedWantParams::VALUE_TYPE_REMOTE_OBJECT;
1168     result = wantParams.ReadFromParcelWantParamWrapper(parcel, key, type);
1169     EXPECT_TRUE(result);
1170     DTEST_LOG << "DistributedWantParamsBaseTest ReadFromParcelWantParamWrapper_1000 end" << std::endl;
1171 }
1172 
1173 /**
1174  * @tc.number: WriteToParcelFD_1000
1175  * @tc.name: WriteToParcelFD
1176  * @tc.desc: Test WriteToParcelFD.
1177  * @tc.require: I77HFZ
1178  */
1179 HWTEST_F(DistributedWantParamsBaseTest, WriteToParcelFD_1000, Function | MediumTest | Level3)
1180 {
1181     DTEST_LOG << "DistributedWantParamsBaseTest WriteToParcelFD_1000 begin" << std::endl;
1182     DistributedWantParams wantParams;
1183     Parcel parcel;
1184     bool result = wantParams.WriteToParcelFD(parcel, wantParams);
1185     EXPECT_FALSE(result);
1186 
1187     int valueInteger = -1;
1188     std::string key = "value";
1189     wantParams.SetParam(key, Integer::Box(valueInteger));
1190     result = wantParams.WriteToParcelFD(parcel, wantParams);
1191     EXPECT_FALSE(result);
1192     DTEST_LOG << "DistributedWantParamsBaseTest WriteToParcelFD_1000 end" << std::endl;
1193 }
1194 
1195 /**
1196  * @tc.number: ReadFromParce_failed_1000
1197  * @tc.name: ReadFromParce
1198  * @tc.desc: Test ReadFromParce.
1199  * @tc.require: I77HFZ
1200  */
1201 HWTEST_F(DistributedWantParamsBaseTest, ReadFromParce_1000, Function | MediumTest | Level3)
1202 {
1203     DTEST_LOG << "DistributedWantParamsBaseTest ReadFromParce_1000 begin" << std::endl;
1204     DistributedWantParams wantParams;
1205     Parcel parcel;
1206     std::string key = "test";
1207     bool result = wantParams.ReadFromParcelBool(parcel, key);
1208     EXPECT_FALSE(result);
1209 
1210     result = wantParams.ReadFromParcelInt8(parcel, key);
1211     EXPECT_FALSE(result);
1212 
1213     result = wantParams.ReadFromParcelChar(parcel, key);
1214     EXPECT_FALSE(result);
1215 
1216     result = wantParams.ReadFromParcelShort(parcel, key);
1217     EXPECT_FALSE(result);
1218 
1219     result = wantParams.ReadFromParcelLong(parcel, key);
1220     EXPECT_FALSE(result);
1221 
1222     result = wantParams.ReadFromParcelFloat(parcel, key);
1223     EXPECT_FALSE(result);
1224 
1225     result = wantParams.ReadFromParcelDouble(parcel, key);
1226     EXPECT_FALSE(result);
1227     DTEST_LOG << "DistributedWantParamsBaseTest ReadFromParce_1000 end" << std::endl;
1228 }
1229 
1230 /**
1231  * @tc.number: ReadUnsupportedData_0001
1232  * @tc.name: ReadUnsupportedData
1233  * @tc.desc: Test ReadUnsupportedData.
1234  * @tc.require: I77HFZ
1235  */
1236 HWTEST_F(DistributedWantParamsBaseTest, ReadUnsupportedData_0001, Function | MediumTest | Level3)
1237 {
1238     DTEST_LOG << "DistributedWantParamsBaseTest ReadUnsupportedData_0001 begin" << std::endl;
1239     DistributedWantParams wantParams;
1240     Parcel parcel;
1241     std::string key = "test";
1242     int type = 5;
1243     bool result = wantParams.ReadUnsupportedData(parcel, key, type);
1244     EXPECT_FALSE(result);
1245 
1246     int bufferSize = -1;
1247     parcel.WriteInt32(bufferSize);
1248     result = wantParams.ReadUnsupportedData(parcel, key, type);
1249     EXPECT_FALSE(result);
1250 
1251     bufferSize = 100 * 1024 * 1024 + 1;
1252     parcel.WriteInt32(bufferSize);
1253     result = wantParams.ReadUnsupportedData(parcel, key, type);
1254     EXPECT_FALSE(result);
1255 
1256     bufferSize = 5;
1257     parcel.WriteInt32(bufferSize);
1258     result = wantParams.ReadUnsupportedData(parcel, key, type);
1259     EXPECT_FALSE(result);
1260 
1261     int32_t length = 10;
1262     parcel.WriteInt32(bufferSize);
1263     parcel.WriteInt32(length);
1264     result = wantParams.ReadUnsupportedData(parcel, key, type);
1265     EXPECT_FALSE(result);
1266     DTEST_LOG << "DistributedWantParamsBaseTest ReadUnsupportedData_0001 end" << std::endl;
1267 }
1268 
1269 /**
1270  * @tc.number: ReadUnsupportedData_0002
1271  * @tc.name: ReadUnsupportedData
1272  * @tc.desc: Test ReadUnsupportedData.
1273  * @tc.require: I77HFZ
1274  */
1275 HWTEST_F(DistributedWantParamsBaseTest, ReadUnsupportedData_0002, Function | MediumTest | Level3)
1276 {
1277     DTEST_LOG << "DistributedWantParamsBaseTest ReadUnsupportedData_0002 begin" << std::endl;
1278     DistributedWantParams wantParams;
1279     Parcel parcel;
1280     std::string key = "test";
1281     int bufferSize = 5;
1282     int32_t length = 10;
1283     int type = 5;
1284     uint8_t* bufferP = new (std::nothrow) uint8_t[bufferSize];
1285     parcel.WriteInt32(bufferSize);
1286     parcel.WriteInt32(length);
1287     parcel.WriteUnpadBuffer(bufferP, bufferSize);
1288     auto result = wantParams.ReadUnsupportedData(parcel, key, type);
1289     EXPECT_TRUE(result);
1290     delete[] bufferP;
1291     DTEST_LOG << "DistributedWantParamsBaseTest ReadUnsupportedData_0002 end" << std::endl;
1292 }
1293