1/*
2 * Copyright (c) 2021-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#include "string_wrapper.h"
19#include "base_obj.h"
20#include "bool_wrapper.h"
21#include "int_wrapper.h"
22#include "float_wrapper.h"
23#include "long_wrapper.h"
24#include "array_wrapper.h"
25
26#define private public
27#define protected public
28#include "operation.h"
29#include "want.h"
30#undef private
31#undef protected
32
33using namespace testing::ext;
34using namespace OHOS::AAFwk;
35using namespace OHOS;
36using OHOS::Parcel;
37using OHOS::AppExecFwk::ElementName;
38
39namespace OHOS {
40namespace AAFwk {
41class WantBaseTest : public testing::Test {
42public:
43    WantBaseTest()
44    {}
45    ~WantBaseTest()
46    {}
47    static void SetUpTestCase(void);
48    static void TearDownTestCase(void);
49    void SetUp();
50    void TearDown();
51
52    std::shared_ptr<Want> want_ = nullptr;
53
54    void CompareWant(const std::shared_ptr<Want> &want1, const std::shared_ptr<Want> &want2) const;
55    bool CompareWant(const std::shared_ptr<Want> &want1, const std::shared_ptr<Want> &want2,
56        std::map<std::string, std::string> &keys) const;
57    void SendParcelTest(const std::shared_ptr<Want> &want, std::map<std::string, std::string> &keys) const;
58    void AddBoolParams(Want &want, std::map<std::string, std::string> &keys, int loop, unsigned int flag) const;
59    void AddByteParams(Want &want, std::map<std::string, std::string> &keys, int loop, unsigned int flag) const;
60    void AddCharParams(Want &want, std::map<std::string, std::string> &keys, int loop, unsigned int flag) const;
61    void AddShortParams(Want &want, std::map<std::string, std::string> &keys, int loop, unsigned int flag) const;
62    void AddIntParams(Want &want, std::map<std::string, std::string> &keys, int loop, unsigned int flag) const;
63    void AddLongParams(Want &want, std::map<std::string, std::string> &keys, int loop, unsigned int flag) const;
64    void AddFloatParams(Want &want, std::map<std::string, std::string> &keys, int loop, unsigned int flag) const;
65    void AddDoubleParams(Want &want, std::map<std::string, std::string> &keys, int loop, unsigned int flag) const;
66    void AddStringParams(Want &want, std::map<std::string, std::string> &keys, int loop, unsigned int flag) const;
67
68    std::string boolType = "bool";
69    std::string boolArrayType = "boolArray";
70    std::string byteType = "byte";
71    std::string byteArrayType = "byteArray";
72    std::string charType = "char";
73    std::string charArrayType = "charArray";
74    std::string shortType = "short";
75    std::string shortArrayType = "shortArray";
76    std::string intType = "int";
77    std::string intArrayType = "intArray";
78    std::string longType = "long";
79    std::string longArrayType = "longArray";
80    std::string floatType = "float";
81    std::string floatArrayType = "floatArray";
82    std::string doubleType = "double";
83    std::string doubleArrayType = "doubleArray";
84    std::string stringType = "string";
85    std::string stringArrayType = "stringArray";
86
87    static const std::string URI_STRING_HEAD;
88    static const std::string URI_STRING_END;
89};
90
91template<typename T>
92bool CompareArrayData(const std::vector<T> &arr1, const std::vector<T> &arr2)
93{
94    if (arr1.size() != arr2.size()) {
95        return false;
96    }
97
98    for (std::uint32_t i = 0; i < arr1.size(); i++) {
99        if (arr1[i] != arr2[i]) {
100            return false;
101        }
102    }
103
104    return true;
105};
106
107enum type { FLAG_TEST_SINGLE = 0x01, FLAG_TEST_ARRAY, FLAG_TEST_BOTH };
108
109void WantBaseTest::SetUpTestCase(void)
110{}
111
112void WantBaseTest::TearDownTestCase(void)
113{}
114
115void WantBaseTest::SetUp(void)
116{
117    want_ = std::make_shared<Want>();
118}
119
120void WantBaseTest::TearDown(void)
121{}
122
123const std::string WantBaseTest::URI_STRING_HEAD("#Intent;");
124const std::string WantBaseTest::URI_STRING_END(";end");
125
126/**
127 * @tc.number: AaExecFwk_Want_Type_0100
128 * @tc.name: SetType/GetType
129 * @tc.desc: Validate when normally entering a string
130 */
131HWTEST_F(WantBaseTest, AaExecFwk_Want_Type_0100, Function | MediumTest | Level1)
132{
133    if (want_ != nullptr) {
134        std::string description = "liuuy";
135        want_->SetType(description);
136        EXPECT_STREQ(description.c_str(), want_->GetType().c_str());
137    }
138}
139
140/**
141 * @tc.number: AaFwk_Want_Action_0100
142 * @tc.name: SetAction/GetAction
143 * @tc.desc: Validate when normally entering a string
144 */
145HWTEST_F(WantBaseTest, AaFwk_Want_Action_0100, Function | MediumTest | Level1)
146{
147    if (want_ != nullptr) {
148        std::string actiondescription = "liuuy";
149        want_->SetAction(actiondescription);
150        EXPECT_STREQ(actiondescription.c_str(), want_->GetAction().c_str());
151    }
152}
153
154/**
155 * @tc.number: AaFwk_Want_Bundle_0100
156 * @tc.name: SetBundle/GetBundle
157 * @tc.desc: Validate when normally entering a string
158 */
159HWTEST_F(WantBaseTest, AaFwk_Want_Bundle_0100, Function | MediumTest | Level1)
160{
161    if (want_ != nullptr) {
162        std::string bundleName = "liuuy";
163        want_->SetBundle(bundleName);
164        EXPECT_STREQ(bundleName.c_str(), want_->GetBundle().c_str());
165    }
166}
167
168/**
169 * @tc.number: AaFwk_Want_DeviceId_0100
170 * @tc.name: SetDeviceId/GetDeviceId
171 * @tc.desc: Validate when normally entering a string
172 */
173HWTEST_F(WantBaseTest, AaFwk_Want_DeviceId_0100, Function | MediumTest | Level1)
174{
175    if (want_ != nullptr) {
176        std::string DeviceId = "liuuy";
177        want_->SetDeviceId(DeviceId);
178        EXPECT_STREQ(DeviceId.c_str(), want_->GetDeviceId().c_str());
179    }
180}
181
182/**
183 * @tc.number: AaFwk_Want_ModuleName_0100
184 * @tc.name: SetModuleName/GetModuleName
185 * @tc.desc: Validate when normally entering a string
186 */
187HWTEST_F(WantBaseTest, AaFwk_Want_ModuleName_0100, Function | MediumTest | Level1)
188{
189    if (want_ != nullptr) {
190        std::string ModuleName = "liuuy";
191        want_->SetModuleName(ModuleName);
192        EXPECT_STREQ(ModuleName.c_str(), want_->GetModuleName().c_str());
193    }
194}
195/**
196 * @tc.number: AaFwk_Want_Parcelable_0100
197 * @tc.name: Marshalling/Unmarshalling
198 * @tc.desc: marshalling Want, and then check result.
199 */
200HWTEST_F(WantBaseTest, AaFwk_Want_Parcelable_0100, Function | MediumTest | Level1)
201{
202    std::shared_ptr<Want> WantIn_ = std::make_shared<Want>();
203    if (WantIn_ == nullptr) {
204        return;
205    }
206
207    WantIn_->SetAction("12345");
208    WantIn_->SetFlags(123);
209
210    WantIn_->SetAction("12345");
211    WantIn_->SetFlags(123);
212    WantIn_->AddEntity("12345");
213    WantParams wantParams;
214    std::string keyStr = "12345667";
215    bool valueBool = true;
216    wantParams.SetParam(keyStr, Boolean::Box(valueBool));
217    WantIn_->SetParams(wantParams);
218    OHOS::AppExecFwk::ElementName element;
219    element.SetAbilityName("12345");
220    element.SetBundleName("12345");
221    element.SetDeviceID("12345");
222    WantIn_->SetElement(element);
223    WantIn_->SetType("12345");
224    size_t pos1;
225    size_t pos2;
226    bool result = false;
227
228    Parcel in;
229    pos1 = in.GetWritePosition();
230    result = WantIn_->Marshalling(in);
231    pos2 = in.GetWritePosition();
232    EXPECT_EQ(result, true);
233    GTEST_LOG_(INFO) << " Marshalling: pos1: " << pos1 << ", pos2: " << pos2 << ", result: " << result;
234
235    pos1 = in.GetWritePosition();
236    result = WantIn_->Marshalling(in);
237    pos2 = in.GetWritePosition();
238    EXPECT_EQ(result, true);
239    GTEST_LOG_(INFO) << " Marshalling: pos1: " << pos1 << ", pos2: " << pos2 << ", result: " << result;
240
241    pos1 = in.GetReadPosition();
242    std::shared_ptr<Want> WantOut_(Want::Unmarshalling(in));
243    if (WantOut_ != nullptr) {
244        pos2 = in.GetReadPosition();
245        CompareWant(WantIn_, WantOut_);
246        EXPECT_EQ(valueBool, Boolean::Unbox(IBoolean::Query(WantOut_->GetParams().GetParam(keyStr))));
247        GTEST_LOG_(INFO) << " Unmarshalling: pos1: " << pos1 << ", pos2: " << pos2 << ", result: " << result;
248    }
249
250    pos1 = in.GetReadPosition();
251    std::shared_ptr<Want> WantOut2_(Want::Unmarshalling(in));
252    if (WantOut2_ != nullptr) {
253        pos2 = in.GetReadPosition();
254        CompareWant(WantIn_, WantOut2_);
255        EXPECT_EQ(valueBool, Boolean::Unbox(IBoolean::Query(WantOut2_->GetParams().GetParam(keyStr))));
256        GTEST_LOG_(INFO) << " Unmarshalling: pos1: " << pos1 << ", pos2: " << pos2 << ", result: " << result;
257    }
258}
259/**
260 * @tc.number: AaFwk_Want_Parcelable_0200
261 * @tc.name: Marshalling/Unmarshalling
262 * @tc.desc: marshalling Want, and then check result.
263 */
264HWTEST_F(WantBaseTest, AaFwk_Want_Parcelable_0200, Function | MediumTest | Level1)
265{
266    std::shared_ptr<Want> WantIn_ = std::make_shared<Want>();
267    if (WantIn_ == nullptr) {
268        return;
269    }
270    WantIn_->SetAction("@#¥#3243adsafdf_中文");
271    WantIn_->SetFlags(123);
272    WantIn_->AddEntity("@#¥#3243adsafdf_中文");
273    WantParams wantParams;
274    std::string keyStr = "@#¥#3243adsafdf_中文";
275    long valueLong = 123;
276    wantParams.SetParam(keyStr, Long::Box(valueLong));
277    WantIn_->SetParams(wantParams);
278    OHOS::AppExecFwk::ElementName element;
279    element.SetAbilityName("@#¥#3243adsafdf_中文");
280    element.SetBundleName("@#¥#3243adsafdf_中文");
281    element.SetDeviceID("@#¥#3243adsafdf_中文");
282    WantIn_->SetElement(element);
283    WantIn_->SetType("@#¥#3243adsafdf_中文");
284    size_t pos1;
285    size_t pos2;
286    bool result = false;
287    Parcel in;
288    pos1 = in.GetWritePosition();
289    result = WantIn_->Marshalling(in);
290    pos2 = in.GetWritePosition();
291    EXPECT_EQ(result, true);
292    GTEST_LOG_(INFO) << "Marshalling: pos1: " << pos1 << ", pos2: " << pos2 << ", result: " << result;
293    pos1 = in.GetWritePosition();
294    result = WantIn_->Marshalling(in);
295    pos2 = in.GetWritePosition();
296    EXPECT_EQ(result, true);
297    pos1 = in.GetReadPosition();
298    std::shared_ptr<Want> WantOut_(Want::Unmarshalling(in));
299    if (WantOut_ != nullptr) {
300        pos2 = in.GetReadPosition();
301        CompareWant(WantIn_, WantOut_);
302        long retLong = Long::Unbox(ILong::Query(WantOut_->GetParams().GetParam(keyStr)));
303        EXPECT_EQ(valueLong, retLong);
304        GTEST_LOG_(INFO) << "Unmarshalling: pos1: " << pos1 << ", pos2: " << pos2 << ", result: " << result;
305    }
306    pos1 = in.GetReadPosition();
307    std::shared_ptr<Want> WantOut2_(Want::Unmarshalling(in));
308    if (WantOut2_ != nullptr) {
309        pos2 = in.GetReadPosition();
310        CompareWant(WantIn_, WantOut2_);
311        long retLong = Long::Unbox(ILong::Query(WantOut2_->GetParams().GetParam(keyStr)));
312        EXPECT_EQ(valueLong, retLong);
313    }
314}
315
316/**
317 * @tc.number: AaFwk_Want_Parcelable_0300
318 * @tc.name: Marshalling/Unmarshalling
319 * @tc.desc: marshalling Want, and then check result.
320 */
321HWTEST_F(WantBaseTest, AaFwk_Want_Parcelable_0300, Function | MediumTest | Level1)
322{
323    std::shared_ptr<Want> WantIn_ = std::make_shared<Want>();
324    if (WantIn_ == nullptr) {
325        return;
326    }
327
328    WantIn_->SetAction("");
329    WantIn_->SetFlags(123);
330    WantIn_->AddEntity("");
331    WantParams wantParams;
332    std::string keyStr = "";
333    int valueInt = 123;
334    wantParams.SetParam(keyStr, Integer::Box(valueInt));
335    WantIn_->SetParams(wantParams);
336    OHOS::AppExecFwk::ElementName element;
337    element.SetAbilityName("");
338    element.SetBundleName("");
339    element.SetDeviceID("");
340    WantIn_->SetElement(element);
341    WantIn_->SetType("");
342
343    size_t pos1;
344    size_t pos2;
345    bool result = false;
346
347    Parcel in;
348    pos1 = in.GetWritePosition();
349    result = WantIn_->Marshalling(in);
350    pos2 = in.GetWritePosition();
351    EXPECT_EQ(result, true);
352    GTEST_LOG_(INFO) << "Marshalling: pos1: " << pos1 << ", pos2: " << pos2 << ", result: " << result;
353
354    pos1 = in.GetWritePosition();
355    result = WantIn_->Marshalling(in);
356    pos2 = in.GetWritePosition();
357    EXPECT_EQ(result, true);
358    GTEST_LOG_(INFO) << "Marshalling: pos1: " << pos1 << ", pos2: " << pos2 << ", result: " << result;
359
360    pos1 = in.GetReadPosition();
361    std::shared_ptr<Want> WantOut_(Want::Unmarshalling(in));
362    if (WantOut_ != nullptr) {
363        pos2 = in.GetReadPosition();
364        CompareWant(WantIn_, WantOut_);
365        EXPECT_EQ(valueInt, Integer::Unbox(IInteger::Query(WantOut_->GetParams().GetParam(keyStr))));
366        GTEST_LOG_(INFO) << "Unmarshalling: pos1: " << pos1 << ", pos2: " << pos2 << ", result: " << result;
367    }
368
369    pos1 = in.GetReadPosition();
370    std::shared_ptr<Want> WantOut2_(Want::Unmarshalling(in));
371    if (WantOut2_ != nullptr) {
372        pos2 = in.GetReadPosition();
373        CompareWant(WantIn_, WantOut2_);
374        EXPECT_EQ(valueInt, Integer::Unbox(IInteger::Query(WantOut2_->GetParams().GetParam(keyStr))));
375        GTEST_LOG_(INFO) << "Unmarshalling: pos1: " << pos1 << ", pos2: " << pos2 << ", result: " << result;
376    }
377}
378
379/**
380 * @tc.number: AaFwk_Want_Parcelable_0400
381 * @tc.name: Marshalling/Unmarshalling
382 * @tc.desc: marshalling Want, and then check result.
383 */
384HWTEST_F(WantBaseTest, AaFwk_Want_Parcelable_0400, Function | MediumTest | Level1)
385{
386    std::shared_ptr<Want> WantIn_ = std::make_shared<Want>();
387    if (WantIn_ == nullptr) {
388        return;
389    }
390
391    WantIn_->SetAction("12345");
392    WantIn_->SetFlags(123);
393    WantIn_->AddEntity("12345");
394    WantIn_->AddEntity("@#¥#3243adsafdf_中文");
395    WantIn_->AddEntity("");
396    WantParams wantParams;
397    std::string keyStr = "12345667";
398    std::string valueString = "123";
399    wantParams.SetParam(keyStr, String::Box(valueString));
400    WantIn_->SetParams(wantParams);
401    OHOS::AppExecFwk::ElementName element;
402    element.SetAbilityName("12345");
403    element.SetBundleName("12345");
404    element.SetDeviceID("12345");
405    WantIn_->SetElement(element);
406    WantIn_->SetType("12345");
407
408    size_t pos1;
409    size_t pos2;
410    bool result = false;
411
412    Parcel in;
413    pos1 = in.GetWritePosition();
414    result = WantIn_->Marshalling(in);
415    pos2 = in.GetWritePosition();
416    EXPECT_EQ(result, true);
417    GTEST_LOG_(INFO) << "Marshalling: pos1: " << pos1 << ", pos2: " << pos2 << ", result: " << result;
418
419    pos1 = in.GetWritePosition();
420    result = WantIn_->Marshalling(in);
421    pos2 = in.GetWritePosition();
422    EXPECT_EQ(result, true);
423    GTEST_LOG_(INFO) << "Marshalling: pos1: " << pos1 << ", pos2: " << pos2 << ", result: " << result;
424
425    pos1 = in.GetReadPosition();
426    std::shared_ptr<Want> WantOut_(Want::Unmarshalling(in));
427    if (WantOut_ != nullptr) {
428        pos2 = in.GetReadPosition();
429        CompareWant(WantIn_, WantOut_);
430        EXPECT_EQ(valueString, String::Unbox(IString::Query(WantOut_->GetParams().GetParam(keyStr))));
431        GTEST_LOG_(INFO) << "Unmarshalling: pos1: " << pos1 << ", pos2: " << pos2 << ", result: " << result;
432    }
433
434    pos1 = in.GetReadPosition();
435    std::shared_ptr<Want> WantOut2_(Want::Unmarshalling(in));
436    if (WantOut2_ != nullptr) {
437        pos2 = in.GetReadPosition();
438        CompareWant(WantIn_, WantOut2_);
439        EXPECT_EQ(valueString, String::Unbox(IString::Query(WantOut2_->GetParams().GetParam(keyStr))));
440        GTEST_LOG_(INFO) << "Unmarshalling: pos1: " << pos1 << ", pos2: " << pos2 << ", result: " << result;
441    }
442}
443
444/**
445 * @tc.number: AaFwk_Want_Parcelable_0500
446 * @tc.name: Marshalling/Unmarshalling
447 * @tc.desc: marshalling Want, and then check result.
448 */
449HWTEST_F(WantBaseTest, AaFwk_Want_Parcelable_0500, Function | MediumTest | Level1)
450{
451    GTEST_LOG_(INFO) << "AaFwk_Want_Parcelable_005 start";
452    std::shared_ptr<Want> WantIn_ = std::make_shared<Want>();
453    if (WantIn_ == nullptr) {
454        return;
455    }
456
457    WantIn_->SetAction("system.test.action");
458    WantIn_->SetFlags(64);
459    WantIn_->AddEntity("system.test.entity");
460
461    OHOS::AppExecFwk::ElementName element;
462    element.SetAbilityName("system.test.abilityname");
463    element.SetBundleName("system.test.bundlename");
464    element.SetDeviceID("system.test.deviceid");
465    WantIn_->SetElement(element);
466
467    WantParams wantParams;
468    std::string keyStr = "system.test.wantparams.key";
469    std::string MIMEKEY = "mime-type";
470    wantParams.SetParam(MIMEKEY, String::Box("system.test.uritype"));
471
472    std::string valueString = "system.wantparams.value.content.test";
473    wantParams.SetParam(keyStr, String::Box(valueString));
474    WantIn_->SetParams(wantParams);
475
476    // want SetParam  arraydata  test
477    std::vector<bool> boolArrayValue = {true, false, true};
478    WantIn_->SetParam(std::string("bool_arraykey"), boolArrayValue);
479
480    std::vector<byte> byteArrayValue = {'?', 'a', '\\'};
481    WantIn_->SetParam(std::string("byte_arraykey"), byteArrayValue);
482
483    std::vector<zchar> charArrayValue = {U'e', U'l', U'l', U'o'};
484    WantIn_->SetParam(std::string("char_arraykey"), charArrayValue);
485
486    std::vector<short> shortArrayValue = {-1, 0, 1};
487    WantIn_->SetParam(std::string("short_arraykey"), shortArrayValue);
488
489    std::vector<int> intArrayValue = {-10, 0, 10};
490    WantIn_->SetParam(std::string("int_arraykey"), intArrayValue);
491
492    std::vector<long> longArrayValue = {-100, 0, 100};
493    WantIn_->SetParam(std::string("long_arraykey"), longArrayValue);
494
495    std::vector<float> floatArrayValue = {-100.1, 0.1, 100.1};
496    WantIn_->SetParam(std::string("float_arraykey"), floatArrayValue);
497
498    std::vector<double> doubleArrayValue = {-1000.1, 0.1, 1000.1};
499    WantIn_->SetParam(std::string("double_arraykey"), doubleArrayValue);
500
501    std::vector<std::string> stringArrayValue = {"stringtest1", "string@test2", "string@!#test2"};
502    WantIn_->SetParam(std::string("string_arraykey"), stringArrayValue);
503
504    Want wantCopy(*WantIn_);
505    std::vector<std::string> teststringArrayValue1 = WantIn_->GetStringArrayParam(std::string("string_arraykey"));
506    std::vector<std::string> teststringArrayValue2 = wantCopy.GetStringArrayParam(std::string("string_arraykey"));
507    bool copyarraycompare = CompareArrayData<std::string>(teststringArrayValue1, teststringArrayValue1);
508    EXPECT_EQ(copyarraycompare, true);
509    std::string str = (copyarraycompare == true) ? "true" : "false";
510    GTEST_LOG_(INFO) << "copyarraycompare=" << str.c_str();
511
512    Parcel in;
513    bool result = false;
514    result = WantIn_->Marshalling(in);
515    EXPECT_EQ(result, true);
516    std::shared_ptr<Want> WantOut_(Want::Unmarshalling(in));
517    if (WantOut_ != nullptr) {
518        GTEST_LOG_(INFO) << "WantOut_->GetAction().c_str(): " << WantOut_->GetAction().c_str();
519        EXPECT_STREQ(WantOut_->GetAction().c_str(), std::string("system.test.action").c_str());
520
521        int flags = WantOut_->GetFlags();
522        GTEST_LOG_(INFO) << "WantOut_->GetFlags(): " << flags;
523        EXPECT_EQ(static_cast<int>(flags), 64);
524
525        bool hasentity = WantOut_->HasEntity("system.test.entity");
526        GTEST_LOG_(INFO) << "WantOut_->HasEntity(system.test.entity)" << hasentity;
527        EXPECT_EQ(hasentity, true);
528
529        WantOut_->RemoveEntity(std::string("system.test.entity"));
530        hasentity = WantOut_->HasEntity(std::string("system.test.entity"));
531        GTEST_LOG_(INFO) << "WantOut_->RemoveEntity(system.test.entity)" << hasentity;
532        EXPECT_EQ(hasentity, false);
533
534        std::string outtype = WantOut_->GetType();
535        GTEST_LOG_(INFO) << "WantOut_->GetType()" << outtype.c_str();
536        EXPECT_STREQ(outtype.c_str(), std::string("system.test.uritype").c_str());
537
538        element = WantOut_->GetElement();
539        GTEST_LOG_(INFO) << "element.GetAbilityName().c_str(): " << element.GetAbilityName().c_str();
540        EXPECT_STREQ(element.GetAbilityName().c_str(), std::string("system.test.abilityname").c_str());
541
542        GTEST_LOG_(INFO) << "element->GetBundleName().c_str(): " << element.GetBundleName().c_str();
543        EXPECT_STREQ(element.GetBundleName().c_str(), std::string("system.test.bundlename").c_str());
544
545        EXPECT_STREQ(element.GetDeviceID().c_str(), std::string("system.test.deviceid").c_str());
546
547        std::string param_content = WantOut_->GetStringParam(keyStr);
548        GTEST_LOG_(INFO) << "WantOut_->GetStringParam(keyStr): " << param_content.c_str();
549
550        // want SetParam  arraydata test
551        std::vector<bool> retboolArray;
552        retboolArray = WantOut_->GetBoolArrayParam(std::string("bool_arraykey"));
553
554        bool arraycompare = CompareArrayData<bool>(retboolArray, boolArrayValue);
555        EXPECT_EQ(arraycompare, true);
556
557        std::vector<byte> retbyteArrayValue;
558        retbyteArrayValue = WantOut_->GetByteArrayParam(std::string("byte_arraykey"));
559        arraycompare = CompareArrayData<byte>(retbyteArrayValue, byteArrayValue);
560        EXPECT_EQ(arraycompare, true);
561
562        std::vector<zchar> retcharArrayValue;
563        retcharArrayValue = WantOut_->GetCharArrayParam(std::string("char_arraykey"));
564        arraycompare = CompareArrayData<zchar>(retcharArrayValue, charArrayValue);
565        EXPECT_EQ(arraycompare, true);
566
567        std::vector<short> retshortArrayValue;
568        retshortArrayValue = WantOut_->GetShortArrayParam(std::string("short_arraykey"));
569        arraycompare = CompareArrayData<short>(retshortArrayValue, shortArrayValue);
570        EXPECT_EQ(arraycompare, true);
571
572        std::vector<int> retintArrayValue;
573        retintArrayValue = WantOut_->GetIntArrayParam(std::string("int_arraykey"));
574        arraycompare = CompareArrayData<int>(retintArrayValue, intArrayValue);
575        EXPECT_EQ(arraycompare, true);
576
577        std::vector<long> retlonArrayValue;
578        retlonArrayValue = WantOut_->GetLongArrayParam(std::string("long_arraykey"));
579        arraycompare = CompareArrayData<long>(retlonArrayValue, longArrayValue);
580        EXPECT_EQ(arraycompare, true);
581
582        std::vector<float> retfloatArrayValue;
583        retfloatArrayValue = WantOut_->GetFloatArrayParam(std::string("float_arraykey"));
584        arraycompare = CompareArrayData<float>(retfloatArrayValue, floatArrayValue);
585        EXPECT_EQ(arraycompare, true);
586
587        std::vector<double> retdoubleArrayValue;
588        retdoubleArrayValue = WantOut_->GetDoubleArrayParam(std::string("double_arraykey"));
589        arraycompare = CompareArrayData<double>(retdoubleArrayValue, doubleArrayValue);
590        EXPECT_EQ(arraycompare, true);
591
592        std::vector<std::string> retstringArrayValue;
593        retstringArrayValue = WantOut_->GetStringArrayParam(std::string("string_arraykey"));
594        arraycompare = CompareArrayData<std::string>(retstringArrayValue, stringArrayValue);
595        EXPECT_EQ(arraycompare, true);
596
597        GTEST_LOG_(INFO) << "AaFwk_Want_Parcelable_005 end";
598    }
599}
600
601void WantBaseTest::CompareWant(const std::shared_ptr<Want> &want1, const std::shared_ptr<Want> &want2) const
602{
603    Operation opt1 = want1->GetOperation();
604    Operation opt2 = want2->GetOperation();
605    EXPECT_EQ(opt1.GetDeviceId(), opt2.GetDeviceId());
606    EXPECT_EQ(opt1.GetBundleName(), opt2.GetBundleName());
607    EXPECT_EQ(opt1.GetAbilityName(), opt2.GetAbilityName());
608
609    EXPECT_EQ(want1->GetAction(), want2->GetAction());
610    EXPECT_EQ(want1->GetFlags(), want2->GetFlags());
611    EXPECT_EQ(want1->GetType(), want2->GetType());
612    EXPECT_EQ(want1->CountEntities(), want2->CountEntities());
613
614    int count = want1->CountEntities();
615    std::vector<std::string> entities1 = want1->GetEntities();
616    std::vector<std::string> entities2 = want2->GetEntities();
617    for (int i = 0; i < count; i++) {
618        EXPECT_EQ(entities1.at(i), entities2.at(i));
619    }
620
621    OHOS::AppExecFwk::ElementName element1 = want1->GetElement();
622    OHOS::AppExecFwk::ElementName element2 = want2->GetElement();
623    EXPECT_EQ(element1.GetURI(), element1.GetURI());
624
625    std::set<std::string> key1;
626    std::set<std::string> key2;
627    key1 = want1->GetParams().KeySet();
628    key2 = want2->GetParams().KeySet();
629    EXPECT_EQ(key1.size(), key2.size());
630
631    std::set<std::string>::iterator iter1 = key1.begin();
632    std::set<std::string>::iterator iter2 = key2.begin();
633    for (; (iter1 != key1.end() && iter2 != key2.end()); iter1++, iter2++) {
634        EXPECT_EQ(*iter1, *iter2);
635    }
636}
637
638bool WantBaseTest::CompareWant(const std::shared_ptr<Want> &want1, const std::shared_ptr<Want> &want2,
639    std::map<std::string, std::string> &keys) const
640{
641    if (want1 == nullptr || want2 == nullptr) {
642        return false;
643    }
644    EXPECT_STREQ(want1->GetAction().c_str(), want2->GetAction().c_str());
645    EXPECT_EQ(want1->CountEntities(), want2->CountEntities());
646
647    if (want1->CountEntities() != want2->CountEntities()) {
648        return false;
649    }
650
651    int count = want1->CountEntities();
652
653    std::vector<std::string> entities1 = want1->GetEntities();
654    std::vector<std::string> entities2 = want2->GetEntities();
655    for (int i = 0; i < count; i++) {
656        EXPECT_EQ(entities1.at(i), entities2.at(i));
657    }
658    EXPECT_EQ(want1->GetFlags(), want2->GetFlags());
659    EXPECT_EQ(want1->GetElement(), want2->GetElement());
660
661    for (auto it = keys.begin(); it != keys.end(); it++) {
662        if (it->second == boolType) {
663            bool v1 = want1->GetBoolParam(it->first, false);
664            bool v2 = want2->GetBoolParam(it->first, false);
665            EXPECT_EQ(v1, v2);
666            EXPECT_EQ(v1, true);
667        } else if (it->second == boolArrayType) {
668            std::vector<bool> v1 = want1->GetBoolArrayParam(it->first);
669            std::vector<bool> v2 = want2->GetBoolArrayParam(it->first);
670            EXPECT_EQ(v1, v2);
671        } else if (it->second == byteType) {
672            byte v1 = want1->GetByteParam(it->first, 'j');
673            byte v2 = want2->GetByteParam(it->first, 'k');
674            EXPECT_EQ(v1, v2);
675        } else if (it->second == byteArrayType) {
676            std::vector<byte> v1 = want1->GetByteArrayParam(it->first);
677            std::vector<byte> v2 = want2->GetByteArrayParam(it->first);
678            EXPECT_EQ(v1, v2);
679        } else if (it->second == charType) {
680            zchar v1 = want1->GetCharParam(it->first, 0x01AB);
681            zchar v2 = want2->GetCharParam(it->first, 0x02CD);
682            EXPECT_EQ(v1, v2);
683        } else if (it->second == charArrayType) {
684            std::vector<zchar> v1 = want1->GetCharArrayParam(it->first);
685            std::vector<zchar> v2 = want2->GetCharArrayParam(it->first);
686            EXPECT_EQ(v1, v2);
687        } else if (it->second == shortType) {
688            short default1 = 123;
689            short default2 = 456;
690            short v1 = want1->GetShortParam(it->first, default1);
691            short v2 = want2->GetShortParam(it->first, default2);
692            EXPECT_EQ(v1, v2);
693        } else if (it->second == shortArrayType) {
694            std::vector<short> v1 = want1->GetShortArrayParam(it->first);
695            std::vector<short> v2 = want2->GetShortArrayParam(it->first);
696            EXPECT_EQ(v1, v2);
697        } else if (it->second == intType) {
698            int default1 = 1230000;
699            int default2 = 4560000;
700            int v1 = want1->GetIntParam(it->first, default1);
701            int v2 = want2->GetIntParam(it->first, default2);
702            EXPECT_EQ(v1, v2);
703        } else if (it->second == intArrayType) {
704            std::vector<int> v1 = want1->GetIntArrayParam(it->first);
705            std::vector<int> v2 = want2->GetIntArrayParam(it->first);
706            EXPECT_EQ(v1, v2);
707        } else if (it->second == longType) {
708            long default1 = 1e8;
709            long default2 = 2e8;
710            long v1 = want1->GetLongParam(it->first, default1);
711            long v2 = want2->GetLongParam(it->first, default2);
712            EXPECT_EQ(v1, v2);
713        } else if (it->second == longArrayType) {
714            std::vector<long> v1 = want1->GetLongArrayParam(it->first);
715            std::vector<long> v2 = want2->GetLongArrayParam(it->first);
716            EXPECT_EQ(v1, v2);
717        } else if (it->second == floatType) {
718            float default1 = 12.3;
719            float default2 = 45.6;
720            float v1 = want1->GetFloatParam(it->first, default1);
721            float v2 = want2->GetFloatParam(it->first, default2);
722            EXPECT_EQ(v1, v2);
723        } else if (it->second == floatArrayType) {
724            std::vector<float> v1 = want1->GetFloatArrayParam(it->first);
725            std::vector<float> v2 = want2->GetFloatArrayParam(it->first);
726            EXPECT_EQ(v1, v2);
727        } else if (it->second == doubleType) {
728            double default1 = 12.3;
729            double default2 = 45.6;
730            double v1 = want1->GetDoubleParam(it->first, default1);
731            double v2 = want2->GetDoubleParam(it->first, default2);
732            EXPECT_EQ(v1, v2);
733        } else if (it->second == doubleArrayType) {
734            std::vector<double> v1 = want1->GetDoubleArrayParam(it->first);
735            std::vector<double> v2 = want2->GetDoubleArrayParam(it->first);
736            EXPECT_EQ(v1, v2);
737        } else if (it->second == stringType) {
738            std::string v1 = want1->GetStringParam(it->first);
739            std::string v2 = want2->GetStringParam(it->first);
740            EXPECT_EQ(v1, v2);
741        } else if (it->second == stringArrayType) {
742            std::vector<std::string> v1 = want1->GetStringArrayParam(it->first);
743            std::vector<std::string> v2 = want2->GetStringArrayParam(it->first);
744            EXPECT_EQ(v1, v2);
745        }
746    }
747
748    return true;
749}
750
751void WantBaseTest::SendParcelTest(const std::shared_ptr<Want> &want, std::map<std::string, std::string> &keys) const
752{
753    size_t pos1;
754    size_t pos2;
755    Parcel data;
756    bool result = false;
757
758    pos1 = data.GetWritePosition();
759    result = data.WriteParcelable(want.get());
760    pos2 = data.GetWritePosition();
761    EXPECT_EQ(result, true);
762    GTEST_LOG_(INFO) << "SendParcelTest: pos1: " << pos1 << ", pos2: " << pos2 << ", result: " << result;
763
764    std::shared_ptr<Want> wantNew(data.ReadParcelable<Want>());
765    EXPECT_NE(wantNew, nullptr);
766
767    if (wantNew != nullptr) {
768        result = CompareWant(want, wantNew, keys);
769        EXPECT_EQ(result, true);
770    }
771}
772
773void WantBaseTest::AddBoolParams(
774    Want &want, std::map<std::string, std::string> &keys, int loop, unsigned int flag) const
775{
776    std::string key;
777    std::string boolKey = "boolKey";
778    std::string boolArrayKey = "boolArrayKey";
779    for (int i = 0; i < loop; i++) {
780        if (flag & FLAG_TEST_SINGLE) {
781            bool boolValue = true;
782            keys[boolKey + std::to_string(i)] = boolType;
783            want.SetParam(boolKey + std::to_string(i), boolValue);
784        }
785
786        if (flag & FLAG_TEST_ARRAY) {
787            std::vector<bool> boolArrayValue = {true, false, true};
788            keys[key] = boolArrayType;
789            want.SetParam(key, boolArrayValue);
790        }
791    }
792}
793
794void WantBaseTest::AddByteParams(
795    Want &want, std::map<std::string, std::string> &keys, int loop, unsigned int flag) const
796{
797    std::string key;
798    std::string byteKey = "byteKey";
799    std::string byteArrayKey = "byteArrayKey";
800    for (int i = 0; i < loop; i++) {
801        if (flag & FLAG_TEST_SINGLE) {
802            byte byteValue = 'z';
803            key = byteKey + std::to_string(i);
804            keys[key] = byteType;
805            want.SetParam(key, byteValue);
806        }
807
808        if (flag & FLAG_TEST_ARRAY) {
809            std::vector<byte> byteArrayValue = {'?', 'a', '\\'};
810            key = byteArrayKey + std::to_string(i);
811            keys[key] = byteArrayType;
812            want.SetParam(key, byteArrayValue);
813        }
814    }
815}
816
817void WantBaseTest::AddCharParams(
818    Want &want, std::map<std::string, std::string> &keys, int loop, unsigned int flag) const
819{
820    std::string key;
821    std::string charKey = "charKey";
822    std::string charArrayKey = "charArrayKey";
823    for (int i = 0; i < loop; i++) {
824        if (flag & FLAG_TEST_SINGLE) {
825            zchar charValue = U'h';
826            key = charKey + std::to_string(i);
827            keys[key] = charType;
828            want.SetParam(key, charValue);
829        }
830
831        if (flag & FLAG_TEST_ARRAY) {
832            std::vector<zchar> charArrayValue = {U'e', U'l', U'l', U'o'};
833            key = charArrayKey + std::to_string(i);
834            keys[key] = charArrayType;
835            want.SetParam(key, charArrayValue);
836        }
837    }
838}
839
840void WantBaseTest::AddShortParams(
841    Want &want, std::map<std::string, std::string> &keys, int loop, unsigned int flag) const
842{
843    std::string key;
844    std::string shortKey = "shortKey";
845    std::string shortArrayKey = "shortArrayKey";
846    for (int i = 0; i < loop; i++) {
847        if (flag & FLAG_TEST_SINGLE) {
848            short shortValue = 1;
849            key = shortKey + std::to_string(i);
850            keys[key] = shortType;
851            want.SetParam(key, shortValue);
852        }
853
854        if (flag & FLAG_TEST_ARRAY) {
855            std::vector<short> shortArrayValue = {-1, 0, 1};
856            key = shortArrayKey + std::to_string(i);
857            keys[key] = shortArrayType;
858            want.SetParam(key, shortArrayValue);
859        }
860    }
861}
862
863void WantBaseTest::AddIntParams(Want &want, std::map<std::string, std::string> &keys, int loop, unsigned int flag) const
864{
865    std::string key;
866    std::string intKey = "intKey";
867    std::string intArrayKey = "intArrayKey";
868    for (int i = 0; i < loop; i++) {
869        if (flag & FLAG_TEST_SINGLE) {
870            int intValue = 10;
871            key = intKey + std::to_string(i);
872            keys[key] = intType;
873            want.SetParam(key, intValue);
874        }
875
876        if (flag & FLAG_TEST_ARRAY) {
877            std::vector<int> intArrayValue = {-10, 0, 10};
878            key = intArrayKey + std::to_string(i);
879            keys[key] = intArrayType;
880            want.SetParam(key, intArrayValue);
881        }
882    }
883}
884
885void WantBaseTest::AddLongParams(
886    Want &want, std::map<std::string, std::string> &keys, int loop, unsigned int flag) const
887{
888    std::string key;
889    std::string longKey = "longKey";
890    std::string longArrayKey = "longArrayKey";
891    for (int i = 0; i < loop; i++) {
892        if (flag & FLAG_TEST_SINGLE) {
893            long longValue = 100L;
894            key = longKey + std::to_string(i);
895            keys[key] = longType;
896            want.SetParam(key, longValue);
897        }
898
899        if (flag & FLAG_TEST_ARRAY) {
900            std::vector<long> longArrayValue = {-100, 0, 100};
901            key = longArrayKey + std::to_string(i);
902            keys[key] = longArrayType;
903            want.SetParam(key, longArrayValue);
904        }
905    }
906}
907
908void WantBaseTest::AddFloatParams(
909    Want &want, std::map<std::string, std::string> &keys, int loop, unsigned int flag) const
910{
911    std::string key;
912    std::string floatKey = "floatKey";
913    std::string floatArrayKey = "floatArrayKey";
914    for (int i = 0; i < loop; i++) {
915        if (flag & FLAG_TEST_SINGLE) {
916            float floatValue = 100.1f;
917            key = floatKey + std::to_string(i);
918            keys[key] = floatType;
919            want.SetParam(key, floatValue);
920        }
921
922        if (flag & FLAG_TEST_ARRAY) {
923            std::vector<float> floatArrayValue = {-100.1, 0.1, 100.1};
924            key = floatArrayKey + std::to_string(i);
925            keys[key] = floatArrayType;
926            want.SetParam(key, floatArrayValue);
927        }
928    }
929}
930
931void WantBaseTest::AddDoubleParams(
932    Want &want, std::map<std::string, std::string> &keys, int loop, unsigned int flag) const
933{
934    std::string key;
935    std::string doubleKey = "doubleKey";
936    std::string doubleArrayKey = "doubleArrayKey";
937    for (int i = 0; i < loop; i++) {
938        if (flag & FLAG_TEST_SINGLE) {
939            double doubleValue = 1000.1;
940            key = doubleKey + std::to_string(i);
941            keys[key] = doubleType;
942            want.SetParam(key, doubleValue);
943        }
944
945        if (flag & FLAG_TEST_ARRAY) {
946            std::vector<double> doubleArrayValue = {-1000.1, 0.1, 1000.1};
947            key = doubleArrayKey + std::to_string(i);
948            keys[key] = doubleArrayType;
949            want.SetParam(key, doubleArrayValue);
950        }
951    }
952}
953
954void WantBaseTest::AddStringParams(
955    Want &want, std::map<std::string, std::string> &keys, int loop, unsigned int flag) const
956{
957    std::string key;
958    std::string stringKey = "stringKey";
959    std::string stringArrayKey = "stringArrayKey";
960    for (int i = 0; i < loop; i++) {
961        if (flag & FLAG_TEST_SINGLE) {
962            string stringValue = "zzzz";
963            key = stringKey + std::to_string(i);
964            keys[key] = stringType;
965            want.SetParam(key, stringValue);
966        }
967
968        if (flag & FLAG_TEST_ARRAY) {
969            std::vector<std::string> stringArrayValue = {"??", "aa", "\\\\"};
970            key = stringArrayKey + std::to_string(i);
971            keys[key] = stringArrayType;
972            want.SetParam(key, stringArrayValue);
973        }
974    }
975}
976
977/**
978 * @tc.number: AaFwk_Want_Parcelable_0600
979 * @tc.name: parcelable
980 * @tc.desc: Verify parcelable.
981 */
982HWTEST_F(WantBaseTest, AaFwk_Want_Parcelable_0600, Function | MediumTest | Level1)
983{
984    std::string action = "want.action.test";
985    unsigned int flag = 0x789;
986    std::string entity = "want.entity.test";
987    OHOS::AppExecFwk::ElementName element("bundlename", "appname", "abilityname");
988
989    std::shared_ptr<Want> want = std::make_shared<Want>();
990    if (want != nullptr) {
991        want->SetAction(action);
992        want->AddEntity(entity);
993        want->AddFlags(flag);
994        want->SetElement(element);
995
996        std::map<std::string, std::string> keys;
997
998        SendParcelTest(want, keys);
999    }
1000}
1001
1002/**
1003 * @tc.number: AaFwk_Want_Parcelable_0700
1004 * @tc.name: parcelable
1005 * @tc.desc: Verify parcelable.
1006 */
1007HWTEST_F(WantBaseTest, AaFwk_Want_Parcelable_0700, Function | MediumTest | Level1)
1008{
1009    std::string action = "want.action.test";
1010    unsigned int flag = 0x789;
1011    std::string entity = "want.entity.test";
1012    OHOS::AppExecFwk::ElementName element("bundlename", "appname", "abilityname");
1013
1014    std::shared_ptr<Want> want = std::make_shared<Want>();
1015    if (want != nullptr) {
1016        want->SetAction(action);
1017        want->AddEntity(entity);
1018        want->AddFlags(flag);
1019        want->SetElement(element);
1020
1021        int loop = 1;
1022        std::map<std::string, std::string> keys;
1023
1024        AddByteParams(*(want.get()), keys, loop, FLAG_TEST_BOTH);
1025        AddCharParams(*(want.get()), keys, loop, FLAG_TEST_BOTH);
1026        AddShortParams(*(want.get()), keys, loop, FLAG_TEST_BOTH);
1027        AddIntParams(*(want.get()), keys, loop, FLAG_TEST_BOTH);
1028        AddLongParams(*(want.get()), keys, loop, FLAG_TEST_BOTH);
1029        AddFloatParams(*(want.get()), keys, loop, FLAG_TEST_BOTH);
1030        AddDoubleParams(*(want.get()), keys, loop, FLAG_TEST_BOTH);
1031        AddStringParams(*(want.get()), keys, loop, FLAG_TEST_BOTH);
1032
1033        SendParcelTest(want, keys);
1034    }
1035}
1036
1037/**
1038 * @tc.number: AaFwk_Want_Parcelable_0800
1039 * @tc.name: parcelable
1040 * @tc.desc: Verify parcelable.
1041 */
1042HWTEST_F(WantBaseTest, AaFwk_Want_Parcelable_0800, Function | MediumTest | Level1)
1043{
1044    std::string action = "want.action.test";
1045    unsigned int flag = 0x789;
1046    std::string entity = "want.entity.test";
1047    OHOS::AppExecFwk::ElementName element("bundlename", "appname", "abilityname");
1048
1049    std::shared_ptr<Want> want = std::make_shared<Want>();
1050    if (want != nullptr) {
1051        want->SetAction(action);
1052        want->AddEntity(entity);
1053        want->AddFlags(flag);
1054        want->SetElement(element);
1055        std::map<std::string, std::string> keys;
1056
1057        SendParcelTest(want, keys);
1058    }
1059}
1060
1061/**
1062 * @tc.number: AaFwk_Want_FormatMimeType_0100
1063 * @tc.name: formatMimeType
1064 * @tc.desc: formats data of a specified MIME type.
1065 */
1066HWTEST_F(WantBaseTest, AaFwk_Want_FormatMimeType_0100, Function | MediumTest | Level1)
1067{
1068    std::string mimeType = "Application/Envoy";
1069    std::string mimeTypeResult = "application/envoy";
1070
1071    EXPECT_EQ(mimeTypeResult, Want::FormatMimeType(mimeType));
1072}
1073
1074/**
1075 * @tc.number: AaFwk_Want_FormatMimeType_0200
1076 * @tc.name: formatMimeType
1077 * @tc.desc: formats data of a specified MIME type.
1078 */
1079HWTEST_F(WantBaseTest, AaFwk_Want_FormatMimeType_0200, Function | MediumTest | Level1)
1080{
1081    std::string mimeType = "APPLICATION/ENVOY";
1082    std::string mimeTypeResult = "application/envoy";
1083
1084    EXPECT_EQ(mimeTypeResult, Want::FormatMimeType(mimeType));
1085}
1086
1087/**
1088 * @tc.number: AaFwk_Want_FormatMimeType_0300
1089 * @tc.name: formatMimeType
1090 * @tc.desc: formats data of a specified MIME type.
1091 */
1092HWTEST_F(WantBaseTest, AaFwk_Want_FormatMimeType_0300, Function | MediumTest | Level1)
1093{
1094    std::string mimeType = " Appl icati on/ Envoy ";
1095    std::string mimeTypeResult = "application/envoy";
1096
1097    EXPECT_EQ(mimeTypeResult, Want::FormatMimeType(mimeType));
1098}
1099
1100/**
1101 * @tc.number: AaFwk_Want_FormatMimeType_0400
1102 * @tc.name: formatMimeType
1103 * @tc.desc: formats data of a specified MIME type.
1104 */
1105HWTEST_F(WantBaseTest, AaFwk_Want_FormatMimeType_0400, Function | MediumTest | Level1)
1106{
1107    std::string mimeType = " Appl icati on/ Envoy ; yovnE ;no itaci lppA ";
1108    std::string mimeTypeResult = "application/envoy";
1109
1110    EXPECT_EQ(mimeTypeResult, Want::FormatMimeType(mimeType));
1111}
1112
1113/**
1114 * @tc.number:  AaFwk_Want_ParseUri_ToUri_0100
1115 * @tc.name: ParseUri and ToUri
1116 * @tc.desc: Verify the function when Want is empty.
1117 */
1118HWTEST_F(WantBaseTest, AaFwk_Want_ParseUri_ToUri_0100, Function | MediumTest | Level1)
1119{
1120    std::size_t pos = 0;
1121    std::size_t content = 0;
1122    std::size_t head = 0;
1123    Want wantOrigin;
1124
1125    std::string uri = wantOrigin.ToUri();
1126
1127    head = uri.find(WantBaseTest::URI_STRING_HEAD, pos);
1128    EXPECT_EQ(head, pos);
1129    if (head != std::string::npos) {
1130        pos += head + WantBaseTest::URI_STRING_HEAD.length() - 1;
1131    }
1132
1133    content = uri.find(WantBaseTest::URI_STRING_END, pos);
1134    EXPECT_EQ(content, pos);
1135    if (content != std::string::npos) {
1136        pos += WantBaseTest::URI_STRING_END.length();
1137    }
1138
1139    EXPECT_EQ(uri.length(), pos);
1140
1141    Want *wantNew = Want::ParseUri(uri);
1142    EXPECT_NE(wantNew, nullptr);
1143
1144    if (wantNew != nullptr) {
1145        EXPECT_EQ(wantNew->GetAction(), std::string(""));
1146        for (auto entity : wantNew->GetEntities()) {
1147            EXPECT_EQ(entity, std::string(""));
1148        }
1149        OHOS::AppExecFwk::ElementName element;
1150        EXPECT_EQ(wantNew->GetElement(), element);
1151        EXPECT_EQ(static_cast<int>(wantNew->GetFlags()), 0);
1152
1153        delete wantNew;
1154    }
1155}
1156
1157/**
1158 * @tc.number:  AaFwk_Want_ParseUri_ToUri_0200
1159 * @tc.name: ParseUri and ToUri
1160 * @tc.desc: Verify the function when Want only has action/entity/flag/element.
1161 */
1162HWTEST_F(WantBaseTest, AaFwk_Want_ParseUri_ToUri_0200, Function | MediumTest | Level1)
1163{
1164    std::string search;
1165
1166    std::string action = Want::ACTION_PLAY;
1167    std::string entity = Want::ENTITY_VIDEO;
1168    unsigned int flag = 0x0f0f0f0f;
1169    std::string flagStr = "0x0f0f0f0f";
1170    std::string device = "device1";
1171    std::string bundle = "bundle1";
1172    std::string ability = "ability1";
1173    OHOS::AppExecFwk::ElementName element(device, bundle, ability);
1174
1175    Want wantOrigin;
1176    wantOrigin.SetAction(action);
1177    wantOrigin.AddEntity(entity);
1178    wantOrigin.AddFlags(flag);
1179    wantOrigin.SetElement(element);
1180
1181    std::string uri = wantOrigin.ToUri();
1182    Want *wantNew = Want::ParseUri(uri);
1183    EXPECT_NE(wantNew, nullptr);
1184
1185    if (wantNew != nullptr) {
1186        EXPECT_EQ(wantNew->GetAction(), action);
1187        for (auto entityItem : wantNew->GetEntities()) {
1188            EXPECT_EQ(entityItem, entity);
1189        }
1190        EXPECT_EQ(wantNew->GetElement().GetDeviceID(), device);
1191        EXPECT_EQ(wantNew->GetElement().GetBundleName(), bundle);
1192        EXPECT_EQ(wantNew->GetElement().GetAbilityName(), ability);
1193        EXPECT_EQ(wantNew->GetFlags(), flag);
1194
1195        delete wantNew;
1196        wantNew = nullptr;
1197    }
1198}
1199
1200/**
1201 * @tc.number:  AaFwk_Want_ParseUri_ToUri_0300
1202 * @tc.name: ParseUri and ToUri
1203 * @tc.desc:  Verify the function when Want only has parameter and the parameter
1204 *            has only 1 float type element.
1205 */
1206HWTEST_F(WantBaseTest, AaFwk_Want_ParseUri_ToUri_0300, Function | MediumTest | Level1)
1207{
1208    std::string search;
1209    std::string substring;
1210    std::size_t pos = 0;
1211    std::size_t length = 0;
1212    std::size_t result = 0;
1213    std::size_t delims = 0;
1214    std::size_t head = 0;
1215    Want wantOrigin;
1216    std::string keyFloat = "keyFloat";
1217    float valueFloatOrigin = 123.4;
1218    wantOrigin.SetParam(keyFloat, valueFloatOrigin);
1219
1220    std::string uri = wantOrigin.ToUri();
1221
1222    search = WantBaseTest::URI_STRING_HEAD;
1223    result = uri.find(search, pos);
1224    EXPECT_EQ(result, pos);
1225    if (result != std::string::npos) {
1226        head = result + search.length();
1227    }
1228    length += head;
1229
1230    search = Float::SIGNATURE + std::string(".") + keyFloat + std::string("=");
1231    result = uri.find(search);
1232    EXPECT_NE(result, std::string::npos);
1233    EXPECT_GE(result, head);
1234    length += search.length();
1235    if (result != std::string::npos) {
1236        pos = result + search.length();
1237        delims = uri.find(";", pos);
1238        if (delims != std::string::npos) {
1239            substring = uri.substr(pos, delims - pos);
1240            float valueFloatNew = Float::Unbox(Float::Parse(substring));
1241            EXPECT_EQ(valueFloatNew, valueFloatOrigin);
1242            length += substring.length() + 1;
1243        }
1244    }
1245
1246    search = WantBaseTest::URI_STRING_END;
1247    result = uri.find(search);
1248    EXPECT_NE(result, std::string::npos);
1249    EXPECT_GE(result, head);
1250    if (result != std::string::npos) {
1251        length += search.length() - 1;
1252    }
1253
1254    EXPECT_EQ(uri.length(), length);
1255
1256    Want *wantNew = Want::ParseUri(uri);
1257    EXPECT_NE(wantNew, nullptr);
1258
1259    if (wantNew != nullptr) {
1260        float floatNew = wantNew->GetFloatParam(keyFloat, 0.1);
1261        float floatOld = wantOrigin.GetFloatParam(keyFloat, 1.1);
1262        EXPECT_EQ(floatNew, floatOld);
1263        delete wantNew;
1264    }
1265}
1266
1267/**
1268 * @tc.number:  AaFwk_Want_ParseUri_ToUri_0400
1269 * @tc.name: ParseUri and ToUri
1270 * @tc.desc: Verify the function when Want only has parameter and the parameter
1271 *           has only one float and one string type element.
1272 */
1273HWTEST_F(WantBaseTest, AaFwk_Want_ParseUri_ToUri_0400, Function | MediumTest | Level1)
1274{
1275    std::string search;
1276    std::string substring;
1277    std::size_t pos = 0;
1278    std::size_t length = 0;
1279    std::size_t result = 0;
1280    std::size_t delims = 0;
1281    std::size_t head = 0;
1282    Want wantOrigin;
1283    std::string keyFloat = "keyFloat";
1284    std::string keyString = "keyString";
1285    float valueFloatOrigin = 123.4;
1286    std::string valueStringOrigin = "abcd";
1287    wantOrigin.SetParam(keyFloat, valueFloatOrigin);
1288    wantOrigin.SetParam(keyString, valueStringOrigin);
1289
1290    std::string uri = wantOrigin.ToUri();
1291
1292    search = WantBaseTest::URI_STRING_HEAD;
1293    result = uri.find(search, pos);
1294    EXPECT_NE(result, std::string::npos);
1295    EXPECT_EQ(result, pos);
1296    if (result != std::string::npos) {
1297        head = result + search.length();
1298    }
1299    length += head;
1300
1301    search = Float::SIGNATURE + std::string(".") + keyFloat + std::string("=");
1302    result = uri.find(search);
1303    EXPECT_NE(result, std::string::npos);
1304    EXPECT_GE(result, head);
1305    length += search.length();
1306    if (result != std::string::npos) {
1307        pos = result + search.length();
1308        delims = uri.find(";", pos);
1309        if (delims != std::string::npos) {
1310            substring = uri.substr(pos, delims - pos);
1311            float valueFloatNew = Float::Unbox(Float::Parse(substring));
1312            EXPECT_EQ(valueFloatNew, valueFloatOrigin);
1313            length += substring.length() + 1;
1314        }
1315    }
1316
1317    search = String::SIGNATURE + std::string(".") + keyString + std::string("=");
1318    result = uri.find(search);
1319    EXPECT_NE(result, std::string::npos);
1320    EXPECT_GE(result, head);
1321    length += search.length();
1322    if (result != std::string::npos) {
1323        pos = result + search.length();
1324        delims = uri.find(";", result);
1325        if (delims != std::string::npos) {
1326            std::string substring = uri.substr(pos, delims - pos);
1327            std::string valueStringNew = String::Unbox(String::Parse(substring));
1328            EXPECT_EQ(valueStringNew, valueStringOrigin);
1329            length += substring.length() + 1;
1330        }
1331    }
1332
1333    search = WantBaseTest::URI_STRING_END;
1334    result = uri.find(search);
1335    EXPECT_NE(result, std::string::npos);
1336    EXPECT_GE(result, head);
1337    if (result != std::string::npos) {
1338        length += search.length() - 1;
1339    }
1340
1341    EXPECT_EQ(uri.length(), length);
1342
1343    Want *wantNew = Want::ParseUri(uri);
1344    EXPECT_NE(wantNew, nullptr);
1345
1346    if (wantNew != nullptr) {
1347        float floatNew = wantNew->GetFloatParam(keyFloat, 0);
1348        float floatOld = wantOrigin.GetFloatParam(keyFloat, 1);
1349        EXPECT_EQ(floatNew, floatOld);
1350
1351        std::string stringNew = wantNew->GetStringParam(keyString);
1352        std::string stringOld = wantOrigin.GetStringParam(keyString);
1353        EXPECT_EQ(stringNew, stringOld);
1354
1355        delete wantNew;
1356    }
1357}
1358
1359/**
1360 * @tc.number:  AaFwk_Want_ParseUri_ToUri_0500
1361 * @tc.name: ParseUri and ToUri
1362 * @tc.desc: Verify the function when Want only has parameter and the parameter
1363 *           has only one float array type element.
1364 */
1365HWTEST_F(WantBaseTest, AaFwk_Want_ParseUri_ToUri_0500, Function | MediumTest | Level1)
1366{
1367    std::string search;
1368    std::string substring;
1369    std::size_t pos = 0;
1370    std::size_t length = 0;
1371    std::size_t result = 0;
1372    std::size_t delims = 0;
1373    std::size_t head = 0;
1374    Want wantOrigin;
1375    std::string keyFloatArray = "keyFloatArray";
1376    std::vector<float> valueFloatArrayOrigin = {1.1, 2.1, 3.1};
1377    wantOrigin.SetParam(keyFloatArray, valueFloatArrayOrigin);
1378
1379    std::string uri = wantOrigin.ToUri();
1380
1381    search = WantBaseTest::URI_STRING_HEAD;
1382    result = uri.find(search, pos);
1383    EXPECT_NE(result, std::string::npos);
1384    EXPECT_EQ(result, pos);
1385    if (result != std::string::npos) {
1386        head = result + search.length();
1387    }
1388    length += head;
1389
1390    search = Array::SIGNATURE + std::string(".") + keyFloatArray + std::string("=");
1391    result = uri.find(search);
1392    EXPECT_NE(result, std::string::npos);
1393    EXPECT_GE(result, head);
1394    length += search.length();
1395    if (result != std::string::npos) {
1396        pos = result + search.length();
1397        delims = uri.find(";", result);
1398        if (delims != std::string::npos) {
1399            std::string substring = uri.substr(pos, delims - pos);
1400            sptr<IArray> array = Array::Parse(substring);
1401            std::vector<float> valueFloatArrayNew;
1402            auto func = [&valueFloatArrayNew](
1403                            IInterface *object) { valueFloatArrayNew.push_back(Float::Unbox(IFloat::Query(object))); };
1404            Array::ForEach(array, func);
1405            EXPECT_EQ(valueFloatArrayNew, valueFloatArrayOrigin);
1406            length += substring.length() + 1;
1407        }
1408    }
1409
1410    search = WantBaseTest::URI_STRING_END;
1411    result = uri.find(search);
1412    EXPECT_NE(result, std::string::npos);
1413    EXPECT_GE(result, head);
1414    if (result != std::string::npos) {
1415        length += search.length() - 1;
1416    }
1417
1418    EXPECT_EQ(uri.length(), length);
1419
1420    Want *wantNew = Want::ParseUri(uri);
1421    EXPECT_NE(wantNew, nullptr);
1422
1423    if (wantNew != nullptr) {
1424        std::vector<float> arrayNew = wantNew->GetFloatArrayParam(keyFloatArray);
1425        std::vector<float> arrayOld = wantOrigin.GetFloatArrayParam(keyFloatArray);
1426        EXPECT_EQ(arrayNew, arrayOld);
1427        delete wantNew;
1428    }
1429}
1430
1431/**
1432 * @tc.number:  AaFwk_Want_ParseUri_ToUri_0600
1433 * @tc.name: ParseUri and ToUri
1434 * @tc.desc: Verify the function when Want only has parameter and the parameter
1435 *           has only one int array and one string array type element
1436 */
1437HWTEST_F(WantBaseTest, AaFwk_Want_ParseUri_ToUri_0600, Function | MediumTest | Level1)
1438{
1439    std::string search;
1440    std::string substring;
1441    std::size_t pos = 0;
1442    std::size_t length = 0;
1443    std::size_t result = 0;
1444    std::size_t delims = 0;
1445    std::size_t head = 0;
1446    Want wantOrigin;
1447    std::string keyFloatArray = "keyFloatArray";
1448    std::string keyStringArray = "keyStringArray";
1449    std::vector<float> valueFloatArrayOrigin = {1.1, 2.1, 3.1};
1450    std::vector<std::string> valueStringArrayOrigin = {"aa", "bb", "cc"};
1451    wantOrigin.SetParam(keyFloatArray, valueFloatArrayOrigin);
1452    wantOrigin.SetParam(keyStringArray, valueStringArrayOrigin);
1453
1454    std::string uri = wantOrigin.ToUri();
1455
1456    search = WantBaseTest::URI_STRING_HEAD;
1457    result = uri.find(search, pos);
1458    EXPECT_NE(result, std::string::npos);
1459    EXPECT_EQ(result, pos);
1460    if (result != std::string::npos) {
1461        head = result + search.length();
1462    }
1463    length += head;
1464
1465    search = Array::SIGNATURE + std::string(".") + keyFloatArray + std::string("=");
1466    result = uri.find(search);
1467    EXPECT_NE(result, std::string::npos);
1468    EXPECT_GE(result, head);
1469    length += search.length();
1470    if (result != std::string::npos) {
1471        pos = result + search.length();
1472        delims = uri.find(";", result);
1473        if (delims != std::string::npos) {
1474            std::string substring = uri.substr(pos, delims - pos);
1475            sptr<IArray> array = Array::Parse(substring);
1476            std::vector<float> valueFloatArrayNew;
1477            auto func = [&valueFloatArrayNew](
1478                            IInterface *object) { valueFloatArrayNew.push_back(Float::Unbox(IFloat::Query(object))); };
1479            Array::ForEach(array, func);
1480            EXPECT_EQ(valueFloatArrayNew, valueFloatArrayOrigin);
1481            length += substring.length() + 1;
1482        }
1483    }
1484
1485    search = Array::SIGNATURE + std::string(".") + keyStringArray + std::string("=");
1486    result = uri.find(search);
1487    EXPECT_NE(result, std::string::npos);
1488    EXPECT_GE(result, head);
1489    length += search.length();
1490    if (result != std::string::npos) {
1491        pos = result + search.length();
1492        delims = uri.find(";", result);
1493        if (delims != std::string::npos) {
1494            std::string substring = uri.substr(pos, delims - pos);
1495            sptr<IArray> array = Array::Parse(substring);
1496            std::vector<std::string> valueStringArrayNew;
1497            auto func = [&valueStringArrayNew](IInterface *object) {
1498                valueStringArrayNew.push_back(String::Unbox(IString::Query(object)));
1499            };
1500            Array::ForEach(array, func);
1501            EXPECT_EQ(valueStringArrayNew, valueStringArrayOrigin);
1502            length += substring.length() + 1;
1503        }
1504    }
1505
1506    search = WantBaseTest::URI_STRING_END;
1507    result = uri.find(search);
1508    EXPECT_NE(result, std::string::npos);
1509    EXPECT_GE(result, head);
1510    if (result != std::string::npos) {
1511        length += search.length() - 1;
1512    }
1513
1514    EXPECT_EQ(uri.length(), length);
1515
1516    Want *wantNew = Want::ParseUri(uri);
1517    EXPECT_NE(wantNew, nullptr);
1518
1519    if (wantNew != nullptr) {
1520        std::vector<float> arrayFloatNew = wantNew->GetFloatArrayParam(keyFloatArray);
1521        std::vector<float> arrayFloatOld = wantOrigin.GetFloatArrayParam(keyFloatArray);
1522        EXPECT_EQ(arrayFloatNew, arrayFloatOld);
1523
1524        std::vector<std::string> arrayStringNew = wantNew->GetStringArrayParam(keyStringArray);
1525        std::vector<std::string> arrayStringOld = wantOrigin.GetStringArrayParam(keyStringArray);
1526        EXPECT_EQ(arrayStringNew, arrayStringOld);
1527
1528        delete wantNew;
1529    }
1530}
1531
1532/**
1533 * @tc.number:  AaFwk_Want_ParseUri_ToUri_0700
1534 * @tc.name: ParseUri and ToUri
1535 * @tc.desc: Verify the function when the length of input string is 0.
1536 */
1537HWTEST_F(WantBaseTest, AaFwk_Want_ParseUri_ToUri_0700, Function | MediumTest | Level1)
1538{
1539    std::string uri;
1540    EXPECT_EQ(static_cast<int>(uri.length()), 0);
1541
1542    Want *want = Want::ParseUri(uri);
1543    EXPECT_EQ(want, nullptr);
1544
1545    if (want != nullptr) {
1546        delete want;
1547    }
1548}
1549
1550/**
1551 * @tc.number:  AaFwk_Want_ParseUri_ToUri_0800
1552 * @tc.name: ParseUri and ToUri
1553 * @tc.desc: Verify the function when the action etc. are empty.
1554 */
1555HWTEST_F(WantBaseTest, AaFwk_Want_ParseUri_ToUri_0800, Function | MediumTest | Level1)
1556{
1557    std::string empty;
1558    std::string uri = "#Intent;action=;entity=;device=;bundle=;ability=;flag=;end";
1559    EXPECT_NE(static_cast<int>(uri.length()), 0);
1560
1561    Want *want = Want::ParseUri(uri);
1562    EXPECT_NE(want, nullptr);
1563
1564    if (want != nullptr) {
1565        EXPECT_EQ(want->GetAction(), empty);
1566        for (auto entityItem : want->GetEntities()) {
1567            EXPECT_EQ(entityItem, empty);
1568        }
1569        EXPECT_EQ(want->GetFlags(), (unsigned int)0);
1570        OHOS::AppExecFwk::ElementName element;
1571        EXPECT_EQ(want->GetElement(), element);
1572        EXPECT_EQ(want->HasParameter(empty), false);
1573        delete want;
1574    }
1575}
1576
1577/**
1578 * @tc.number:  AaFwk_Want_ParseUri_ToUri_0900
1579 * @tc.name: ParseUri and ToUri
1580 * @tc.desc: Verify the function when flag is not number.
1581 */
1582HWTEST_F(WantBaseTest, AaFwk_Want_ParseUri_ToUri_0900, Function | MediumTest | Level1)
1583{
1584    std::string empty;
1585    std::string uri = "#Intent;action=want.action.VIEW;flag=\"123\";end";
1586    EXPECT_NE(static_cast<int>(uri.length()), 0);
1587
1588    Want *want = Want::ParseUri(uri);
1589    EXPECT_EQ(want, nullptr);
1590    if (want != nullptr) {
1591        delete want;
1592        want = nullptr;
1593    }
1594}
1595
1596/**
1597 * @tc.number:  AaFwk_Want_ParseUri_ToUri_1000
1598 * @tc.name: ParseUri and ToUri
1599 * @tc.desc: Verify the function when head is not "#Intent".
1600 */
1601HWTEST_F(WantBaseTest, AaFwk_Want_ParseUri_ToUri_1000, Function | MediumTest | Level1)
1602{
1603    std::string empty;
1604    std::string uri = "action=want.action.VIEW;end";
1605    EXPECT_NE(static_cast<int>(uri.length()), 0);
1606
1607    Want *want = Want::ParseUri(uri);
1608    EXPECT_EQ(want, nullptr);
1609    if (want != nullptr) {
1610        delete want;
1611        want = nullptr;
1612    }
1613}
1614
1615/**
1616 * @tc.number:  AaFwk_Want_ParseUri_ToUri_1100
1617 * @tc.name: ParseUri and ToUri
1618 * @tc.desc: Verify the function when flag is empty.
1619 */
1620HWTEST_F(WantBaseTest, AaFwk_Want_ParseUri_ToUri_1100, Function | MediumTest | Level1)
1621{
1622    std::string empty;
1623    std::string uri = "#Intent;flag=;end";
1624    EXPECT_NE(static_cast<int>(uri.length()), 0);
1625
1626    Want *want = Want::ParseUri(uri);
1627    EXPECT_NE(want, nullptr);
1628
1629    if (want != nullptr) {
1630        EXPECT_EQ(want->GetFlags(), static_cast<unsigned int>(0));
1631        delete want;
1632    }
1633}
1634
1635/**
1636 * @tc.number:  AaFwk_Want_ParseUri_ToUri_1200
1637 * @tc.name: ParseUri and ToUri
1638 * @tc.desc: Verify the function when x is capital.
1639 */
1640HWTEST_F(WantBaseTest, AaFwk_Want_ParseUri_ToUri_1200, Function | MediumTest | Level1)
1641{
1642    std::string empty;
1643    unsigned int flag = 0X12345678;
1644    std::string uri = "#Intent;flag=0X12345678;end";
1645    EXPECT_NE(static_cast<int>(uri.length()), 0);
1646
1647    Want *want = Want::ParseUri(uri);
1648    EXPECT_NE(want, nullptr);
1649
1650    if (want != nullptr) {
1651        EXPECT_EQ(want->GetFlags(), flag);
1652        delete want;
1653    }
1654}
1655
1656/**
1657 * @tc.number:  AaFwk_Want_ParseUri_ToUri_1300
1658 * @tc.name: ParseUri and ToUri
1659 * @tc.desc: Verify the function when special character.
1660 */
1661HWTEST_F(WantBaseTest, AaFwk_Want_ParseUri_ToUri_1300, Function | MediumTest | Level1)
1662{
1663    std::string action = "\\";
1664    std::string entity = "../../../jj/j=075/./.;;/07507399/\\\\;;--==.com.\a\b\tfoobar.vide\073\\075";
1665    unsigned int flag = 0x0f0f0f0f;
1666    std::string flagStr = "0x0f0f0f0f";
1667    std::string key = "\\kkk=.=;";
1668    std::string value = "==\\\\\\.;\\;\\;\\=\\\073075\\\\075073";
1669
1670    Want wantOrigin;
1671    wantOrigin.SetAction(action);
1672    wantOrigin.AddEntity(entity);
1673    wantOrigin.AddFlags(flag);
1674    wantOrigin.SetParam(key, value);
1675
1676    std::string uri = wantOrigin.ToUri();
1677
1678    Want *wantNew = Want::ParseUri(uri);
1679    EXPECT_NE(wantNew, nullptr);
1680
1681    if (wantNew != nullptr) {
1682        EXPECT_STREQ(wantNew->GetAction().c_str(), action.c_str());
1683        for (auto entityItem : wantNew->GetEntities()) {
1684            EXPECT_EQ(entityItem, entity);
1685        }
1686        EXPECT_EQ(wantNew->GetFlags(), flag);
1687        EXPECT_EQ(wantNew->GetStringParam(key), value);
1688
1689        delete wantNew;
1690        wantNew = nullptr;
1691    }
1692}
1693
1694/**
1695 * @tc.number:  AaFwk_Want_ParseUri_ToUri_1400
1696 * @tc.name: ParseUri and ToUri
1697 * @tc.desc: Verify the function when no '=' or only has a '='.
1698 */
1699HWTEST_F(WantBaseTest, AaFwk_Want_ParseUri_ToUri_1400, Function | MediumTest | Level1)
1700{
1701    std::string uri = "#Intent;action;end";
1702    Want *want = Want::ParseUri(uri);
1703    EXPECT_EQ(want, nullptr);
1704    if (want != nullptr) {
1705        delete want;
1706        want = nullptr;
1707    }
1708
1709    uri = "#Intent;entity;end";
1710    want = Want::ParseUri(uri);
1711    EXPECT_EQ(want, nullptr);
1712    if (want != nullptr) {
1713        delete want;
1714        want = nullptr;
1715    }
1716
1717    uri = "#Intent;device;end";
1718    want = Want::ParseUri(uri);
1719    EXPECT_EQ(want, nullptr);
1720    if (want != nullptr) {
1721        delete want;
1722        want = nullptr;
1723    }
1724
1725    uri = "#Intent;bundle;end";
1726    want = Want::ParseUri(uri);
1727    EXPECT_EQ(want, nullptr);
1728    if (want != nullptr) {
1729        delete want;
1730        want = nullptr;
1731    }
1732
1733    uri = "#Intent;ability;end";
1734    want = Want::ParseUri(uri);
1735    EXPECT_EQ(want, nullptr);
1736    if (want != nullptr) {
1737        delete want;
1738        want = nullptr;
1739    }
1740
1741    uri = "#Intent;flag;end";
1742    want = Want::ParseUri(uri);
1743    EXPECT_EQ(want, nullptr);
1744    if (want != nullptr) {
1745        delete want;
1746        want = nullptr;
1747    }
1748
1749    uri = "#Intent;param;end";
1750    want = Want::ParseUri(uri);
1751    EXPECT_EQ(want, nullptr);
1752    if (want != nullptr) {
1753        delete want;
1754        want = nullptr;
1755    }
1756
1757    uri = "#Intent;=;end";
1758    want = Want::ParseUri(uri);
1759    EXPECT_NE(want, nullptr);
1760    if (want != nullptr) {
1761        delete want;
1762        want = nullptr;
1763    }
1764
1765    uri = "#Intent;abc=;end";
1766    want = Want::ParseUri(uri);
1767    EXPECT_NE(want, nullptr);
1768    if (want != nullptr) {
1769        delete want;
1770        want = nullptr;
1771    }
1772
1773    uri = "#Intent;=abc;end";
1774    want = Want::ParseUri(uri);
1775    EXPECT_NE(want, nullptr);
1776    if (want != nullptr) {
1777        delete want;
1778        want = nullptr;
1779    }
1780
1781    uri = "#Intent;xxxx=yyy;end";
1782    want = Want::ParseUri(uri);
1783    EXPECT_NE(want, nullptr);
1784    if (want != nullptr) {
1785        delete want;
1786        want = nullptr;
1787    }
1788
1789    uri = "#Intent;;;;;;end";
1790    want = Want::ParseUri(uri);
1791    EXPECT_NE(want, nullptr);
1792    if (want != nullptr) {
1793        delete want;
1794        want = nullptr;
1795    }
1796}
1797
1798/**
1799 * @tc.number:  AaFwk_Want_Flags_0100
1800 * @tc.name: SetFlags/AddFlags/GetFlags/RemoveFlags
1801 * @tc.desc: Verify SetFlags/AddFlags/GetFlags/RemoveFlags.
1802 */
1803HWTEST_F(WantBaseTest, AaFwk_Want_Flags_0100, Function | MediumTest | Level1)
1804{
1805    int flags = 3;
1806    int returnsflags;
1807    int description = 8;
1808
1809    want_->SetFlags(description);
1810    want_->AddFlags(flags);
1811    returnsflags = want_->GetFlags();
1812    EXPECT_EQ(11, returnsflags);
1813
1814    want_->RemoveFlags(flags);
1815    returnsflags = want_->GetFlags();
1816    EXPECT_EQ(description, returnsflags);
1817}
1818
1819/**
1820 * @tc.number:  AaFwk_Want_MakeMainAbility_0100
1821 * @tc.name: MakeMainAbility
1822 * @tc.desc: Verify MakeMainAbility.
1823 */
1824HWTEST_F(WantBaseTest, AaFwk_Want_MakeMainAbility_0100, Function | MediumTest | Level1)
1825{
1826    ElementName elementName;
1827
1828    std::string action("action.system.home");
1829    std::string entity("entity.system.home");
1830
1831    Want *wantNew = want_->MakeMainAbility(elementName);
1832    if (wantNew != nullptr) {
1833        std::vector<std::string> entities = wantNew->GetEntities();
1834
1835        EXPECT_EQ((size_t)1, entities.size());
1836        if (entities.size() > 0) {
1837            EXPECT_EQ(entity, entities.at(0));
1838        }
1839        EXPECT_EQ(action, wantNew->GetAction());
1840        EXPECT_EQ(elementName, wantNew->GetElement());
1841
1842        delete wantNew;
1843        wantNew = nullptr;
1844    }
1845}
1846
1847/**
1848 * @tc.number:  AaFwk_Want_ClearWant_0100
1849 * @tc.name: ClearWant
1850 * @tc.desc: Verify ClearWant.
1851 */
1852HWTEST_F(WantBaseTest, AaFwk_Want_ClearWant_0100, Function | MediumTest | Level1)
1853{
1854    Want want;
1855    ElementName elementName;
1856    std::string empty = "";
1857    want_->ClearWant(&want);
1858
1859    EXPECT_EQ((uint)0, want_->GetFlags());
1860    EXPECT_EQ(empty, want_->GetType());
1861    EXPECT_EQ(empty, want_->GetAction());
1862    EXPECT_EQ(elementName, want_->GetElement());
1863    EXPECT_EQ((size_t)0, want_->GetEntities().size());
1864    EXPECT_EQ(0, want_->CountEntities());
1865}
1866
1867/**
1868 * @tc.number:  AaFwk_Want_replaceParams_0100
1869 * @tc.name: replaceParams(wantParams)
1870 * @tc.desc: Verify the function when the input string is empty.
1871 */
1872HWTEST_F(WantBaseTest, AaFwk_Want_replaceParams_0100, Function | MediumTest | Level1)
1873{
1874    WantParams wantParams;
1875    std::string keyStr = "123";
1876    std::string valueStr = "123";
1877    wantParams.SetParam(keyStr, String::Box(valueStr));
1878    want_->ReplaceParams(wantParams);
1879
1880    EXPECT_EQ(valueStr, String::Unbox(IString::Query(want_->GetParams().GetParam(keyStr))));
1881}
1882
1883/**
1884 * @tc.number:  AaFwk_Want_setElement_0100
1885 * @tc.name:setElement / setElementName
1886 * @tc.desc: Verify the function when the input string is empty.
1887 */
1888HWTEST_F(WantBaseTest, AaFwk_Want_setElement_0100, Function | MediumTest | Level1)
1889{
1890    std::string valueStr1 = "xxxxx";
1891    std::string valueStr2 = "uaid";
1892    std::string valueStr3 = "uaygfi";
1893
1894    OHOS::AppExecFwk::ElementName elementname1;
1895    OHOS::AppExecFwk::ElementName elementname2;
1896    OHOS::AppExecFwk::ElementName elementname3;
1897    ElementName elementname4;
1898    elementname1.SetAbilityName(valueStr1);
1899    elementname2.SetDeviceID(valueStr2);
1900    elementname3.SetBundleName(valueStr3);
1901    want_->SetElement(elementname1);
1902    EXPECT_EQ(valueStr1, want_->GetElement().GetAbilityName());
1903
1904    want_->SetElement(elementname2);
1905    EXPECT_EQ(valueStr2, want_->GetElement().GetDeviceID());
1906
1907    want_->SetElement(elementname3);
1908    EXPECT_EQ(valueStr3, want_->GetElement().GetBundleName());
1909
1910    want_->SetElementName(valueStr3, valueStr1);
1911    EXPECT_EQ(valueStr1, want_->GetElement().GetAbilityName());
1912    EXPECT_EQ(valueStr3, want_->GetElement().GetBundleName());
1913
1914    want_->SetElementName(valueStr2, valueStr3, valueStr1);
1915    EXPECT_EQ(valueStr1, want_->GetElement().GetAbilityName());
1916    EXPECT_EQ(valueStr2, want_->GetElement().GetDeviceID());
1917    EXPECT_EQ(valueStr3, want_->GetElement().GetBundleName());
1918}
1919
1920/**
1921 * @tc.number:  AaFwk_Want_Action_0200
1922 * @tc.name:SetAction / GetAction
1923 * @tc.desc: Verify the function when the input string is empty.
1924 */
1925HWTEST_F(WantBaseTest, AaFwk_Want_Action_0200, Function | MediumTest | Level1)
1926{
1927    std::string setValue;
1928    want_->SetAction(setValue);
1929    EXPECT_EQ(setValue, want_->GetAction());
1930}
1931
1932/**
1933 * @tc.number:  AaFwk_Want_Action_0300
1934 * @tc.name:SetAction / GetAction
1935 * @tc.desc: Verify the function when the input string contains special characters.
1936 */
1937HWTEST_F(WantBaseTest, AaFwk_Want_Action_0300, Function | MediumTest | Level1)
1938{
1939    std::string setValue("action.system.com");
1940    want_->SetAction(setValue);
1941    EXPECT_STREQ(setValue.c_str(), want_->GetAction().c_str());
1942}
1943
1944using testByteType = std::tuple<std::string, std::string, byte, byte, byte>;
1945class WantParametersBoolArrayTest : public testing::TestWithParam<testByteType> {
1946public:
1947    WantParametersBoolArrayTest()
1948    {
1949        want_ = nullptr;
1950    }
1951    ~WantParametersBoolArrayTest()
1952    {
1953        want_ = nullptr;
1954    }
1955    static void SetUpTestCase(void);
1956    static void TearDownTestCase(void);
1957    void SetUp();
1958    void TearDown();
1959    std::shared_ptr<Want> want_;
1960};
1961
1962void WantParametersBoolArrayTest::SetUpTestCase(void)
1963{}
1964
1965void WantParametersBoolArrayTest::TearDownTestCase(void)
1966{}
1967
1968void WantParametersBoolArrayTest::SetUp(void)
1969{
1970    want_ = std::make_shared<Want>();
1971}
1972
1973void WantParametersBoolArrayTest::TearDown(void)
1974{}
1975
1976/**
1977 * @tc.number:  AaFwk_Want_BoolArray_0100
1978 * @tc.name:SetBoolArrayParam/GetBoolArrayParam
1979 * @tc.desc: Verify when parameter change.
1980 */
1981HWTEST_P(WantParametersBoolArrayTest, AaFwk_Want_BoolArray_0100, Function | MediumTest | Level1)
1982{
1983    std::string setKey = std::get<0>(GetParam());
1984    std::string getKey = std::get<1>(GetParam());
1985    byte setValue = std::get<2>(GetParam());
1986    byte defaultValue = std::get<3>(GetParam());
1987    byte result = std::get<4>(GetParam());
1988    want_->SetParam(setKey, setValue);
1989    EXPECT_EQ(result, want_->GetByteParam(getKey, defaultValue));
1990}
1991
1992INSTANTIATE_TEST_SUITE_P(WantParametersBoolArrayTestCaseP, WantParametersBoolArrayTest,
1993    testing::Values(testByteType("", "aa", '#', 'U', 'U'), testByteType("", "", 'N', 'K', 'N'),
1994        testByteType("1*中_aR", "aa", 'a', '%', '%'), testByteType("1*中_aR", "1*中_aR", 'a', 'z', 'a')));
1995
1996using testBoolArrayType = std::tuple<std::string, std::string, std::vector<bool>, std::vector<bool>, std::vector<bool>>;
1997class WantBoolArrayParamTest : public testing::TestWithParam<testBoolArrayType> {
1998public:
1999    WantBoolArrayParamTest()
2000    {
2001        want_ = nullptr;
2002    }
2003    ~WantBoolArrayParamTest()
2004    {
2005        want_ = nullptr;
2006    }
2007    static void SetUpTestCase(void);
2008    static void TearDownTestCase(void);
2009    void SetUp();
2010    void TearDown();
2011    std::shared_ptr<Want> want_;
2012};
2013
2014void WantBoolArrayParamTest::SetUpTestCase(void)
2015{}
2016
2017void WantBoolArrayParamTest::TearDownTestCase(void)
2018{}
2019
2020void WantBoolArrayParamTest::SetUp(void)
2021{
2022    want_ = std::make_shared<Want>();
2023}
2024
2025void WantBoolArrayParamTest::TearDown(void)
2026{}
2027
2028/**
2029 * @tc.number:  AaFwk_Want_BoolArray_0200
2030 * @tc.name:SetBoolArrayParam/GetBoolArrayParam
2031 * @tc.desc: Verify when parameter change.
2032 */
2033HWTEST_P(WantBoolArrayParamTest, AaFwk_Want_BoolArray_0200, Function | MediumTest | Level1)
2034{
2035    std::string setKey = std::get<0>(GetParam());
2036    std::string getKey = std::get<1>(GetParam());
2037    std::vector<bool> setValue = std::get<2>(GetParam());
2038    std::vector<bool> defaultValue = std::get<3>(GetParam());
2039    std::vector<bool> result = std::get<4>(GetParam());
2040    want_->SetParam(setKey, setValue);
2041    EXPECT_EQ(result, want_->GetBoolArrayParam(getKey));
2042}
2043
2044INSTANTIATE_TEST_SUITE_P(WantBoolArrayParamTestCaseP, WantBoolArrayParamTest,
2045    testing::Values(testBoolArrayType("", "aa", {true, false}, {}, {}),
2046        testBoolArrayType("", "", {true, false}, {}, {true, false}),
2047        testBoolArrayType("1*中_aR", "aa", {true, false}, {}, {}),
2048        testBoolArrayType("1*中_aR", "1*中_aR", {false, true}, {}, {false, true})));
2049
2050using testCharArrayType =
2051    std::tuple<std::string, std::string, std::vector<zchar>, std::vector<zchar>, std::vector<zchar>>;
2052class WantCharArrayParamTest : public testing::TestWithParam<testCharArrayType> {
2053public:
2054    WantCharArrayParamTest()
2055    {
2056        want_ = nullptr;
2057    }
2058    ~WantCharArrayParamTest()
2059    {
2060        want_ = nullptr;
2061    }
2062    static void SetUpTestCase(void);
2063    static void TearDownTestCase(void);
2064    void SetUp();
2065    void TearDown();
2066    std::shared_ptr<Want> want_;
2067};
2068
2069void WantCharArrayParamTest::SetUpTestCase(void)
2070{}
2071
2072void WantCharArrayParamTest::TearDownTestCase(void)
2073{}
2074
2075void WantCharArrayParamTest::SetUp(void)
2076{
2077    want_ = std::make_shared<Want>();
2078}
2079
2080void WantCharArrayParamTest::TearDown(void)
2081{}
2082
2083/**
2084 * @tc.number:  AaFwk_Want_Parameters_CharArray_0100
2085 * @tc.name: SetParam/GetCharArrayParam
2086 * @tc.desc: Verify when parameter change.
2087 */
2088HWTEST_P(WantCharArrayParamTest, AaFwk_Want_Parameters_CharArray_0100, Function | MediumTest | Level1)
2089{
2090    std::string setKey = std::get<0>(GetParam());
2091    std::string getKey = std::get<1>(GetParam());
2092    std::vector<zchar> setValue = std::get<2>(GetParam());
2093    std::vector<zchar> defaultValue = std::get<3>(GetParam());
2094    std::vector<zchar> result = std::get<4>(GetParam());
2095    want_->SetParam(setKey, setValue);
2096    EXPECT_EQ(result, want_->GetCharArrayParam(getKey));
2097}
2098
2099INSTANTIATE_TEST_SUITE_P(WantCharArrayParamTestCaseP, WantCharArrayParamTest,
2100    testing::Values(testCharArrayType("", "aa", {U'中', U'文'}, {}, {}),
2101        testCharArrayType("", "", {U'中', U'文'}, {}, {U'中', U'文'}),
2102        testCharArrayType("1*中_aR", "aa", {U'中', U'文'}, {}, {}),
2103        testCharArrayType("1*中_aR", "1*中_aR", {U'中', U'文'}, {}, {U'中', U'文'})));
2104
2105/**
2106 * @tc.number:  AaFwk_Want_Parameters_CharArray_0200
2107 * @tc.name:  GetCharArrayParam
2108 * @tc.desc: Verify when the value is char array.
2109 */
2110HWTEST_F(WantCharArrayParamTest, AaFwk_Want_Parameters_CharArray_0200, Function | MediumTest | Level1)
2111{
2112    std::vector<zchar> defaultValue;
2113    std::string getKey("aa");
2114    EXPECT_EQ(defaultValue, want_->GetCharArrayParam(getKey));
2115}
2116
2117/**
2118 * @tc.number:  AaFwk_Want_Parameters_CharArray_0300
2119 * @tc.name:  SetParam/GetCharArrayParam
2120 * @tc.desc: Verify when the value is char array.
2121 */
2122HWTEST_F(WantCharArrayParamTest, AaFwk_Want_Parameters_CharArray_0300, Function | MediumTest | Level1)
2123{
2124    std::string emptyStr("ff");
2125    std::vector<zchar> firstValue({U'中', U'文'});
2126    std::vector<zchar> secondValue({U'字', U'符'});
2127    std::vector<zchar> thirdValue({U'集', U'英'});
2128    std::string keyStr("aa");
2129    want_->SetParam(emptyStr, firstValue);
2130    want_->SetParam(emptyStr, firstValue);
2131    want_->SetParam(emptyStr, secondValue);
2132    std::vector<zchar> defaultValue;
2133    EXPECT_EQ(defaultValue, want_->GetCharArrayParam(keyStr));
2134    want_->SetParam(emptyStr, thirdValue);
2135    EXPECT_EQ(thirdValue, want_->GetCharArrayParam(emptyStr));
2136}
2137
2138/**
2139 * @tc.number: AaFwk_Want_Parameters_CharArray_0400
2140 * @tc.name:  SetParam/GetCharArrayParam
2141 * @tc.desc: Verify when the value is char array.
2142 */
2143HWTEST_F(WantCharArrayParamTest, AaFwk_Want_Parameters_CharArray_0400, Function | MediumTest | Level1)
2144{
2145    std::string firstKey("%1uH3");
2146    std::vector<zchar> firstValue({U'中', U'文'});
2147    std::vector<zchar> secondValue({U'字', U'符'});
2148    std::vector<zchar> defaultValue;
2149    std::string secondKey("aa");
2150    want_->SetParam(firstKey, firstValue);
2151    want_->SetParam(firstKey, firstValue);
2152    want_->SetParam(firstKey, secondValue);
2153    EXPECT_EQ(secondValue, want_->GetCharArrayParam(firstKey));
2154    want_->SetParam(firstKey, firstValue);
2155    EXPECT_EQ(defaultValue, want_->GetCharArrayParam(secondKey));
2156}
2157
2158using testCharType = std::tuple<std::string, std::string, zchar, zchar, zchar>;
2159class WantCharParamTest : public testing::TestWithParam<testCharType> {
2160public:
2161    WantCharParamTest()
2162    {
2163        want_ = nullptr;
2164    }
2165    ~WantCharParamTest()
2166    {
2167        want_ = nullptr;
2168    }
2169    static void SetUpTestCase(void);
2170    static void TearDownTestCase(void);
2171    void SetUp();
2172    void TearDown();
2173    std::shared_ptr<Want> want_;
2174};
2175
2176void WantCharParamTest::SetUpTestCase(void)
2177{}
2178
2179void WantCharParamTest::TearDownTestCase(void)
2180{}
2181
2182void WantCharParamTest::SetUp(void)
2183{
2184    want_ = std::make_shared<Want>();
2185}
2186
2187void WantCharParamTest::TearDown(void)
2188{}
2189
2190/**
2191 * @tc.number: AaFwk_Want_Parameters_Char_0100
2192 * @tc.name:  SetParam/GetCharParam
2193 * @tc.desc: Verify when the value is char array.
2194 */
2195HWTEST_P(WantCharParamTest, AaFwk_Want_Parameters_Char_0100, Function | MediumTest | Level1)
2196{
2197    std::string setKey = std::get<0>(GetParam());
2198    std::string getKey = std::get<1>(GetParam());
2199    zchar setValue = std::get<2>(GetParam());
2200    zchar defaultValue = std::get<3>(GetParam());
2201    zchar result = std::get<4>(GetParam());
2202    want_->SetParam(setKey, setValue);
2203    EXPECT_EQ(result, want_->GetCharParam(getKey, defaultValue));
2204}
2205
2206INSTANTIATE_TEST_SUITE_P(WantParametersCharTestCaseP, WantCharParamTest,
2207    testing::Values(testCharType("", "aa", U'#', U'中', U'中'), testCharType("", "", U'中', U'K', U'中'),
2208        testCharType("1*中_aR", "aa", U'a', U'中', U'中'), testCharType("1*中_aR", "1*中_aR", U'中', U'z', U'中')));
2209
2210/**
2211 * @tc.number: AaFwk_Want_Parameters_Char_0200
2212 * @tc.name:  SetParam/GetCharParam
2213 * @tc.desc: Verify when the value is char
2214 */
2215HWTEST_F(WantCharParamTest, AaFwk_Want_Parameters_Char_0200, Function | MediumTest | Level1)
2216{
2217    zchar defaultValue = U'文';
2218    std::string getKey("aa");
2219    EXPECT_EQ(defaultValue, want_->GetCharParam(getKey, defaultValue));
2220}
2221
2222/**
2223 * @tc.number: AaFwk_Want_Parameters_Char_0300
2224 * @tc.name:  SetParam/GetCharParam
2225 * @tc.desc: Verify when the value is char.
2226 */
2227HWTEST_F(WantCharParamTest, AaFwk_Want_Parameters_Char_0300, Function | MediumTest | Level1)
2228{
2229    std::string emptyStr("jj");
2230    zchar firstValue = U'中';
2231    zchar secondValue = U'文';
2232    zchar thirdValue = U'字';
2233    zchar firstDefaultValue = U'符';
2234    zchar secondDefaultValue = U'集';
2235    std::string keyStr("aa");
2236    want_->SetParam(emptyStr, firstValue);
2237    want_->SetParam(emptyStr, firstValue);
2238    want_->SetParam(emptyStr, secondValue);
2239    EXPECT_EQ(firstDefaultValue, want_->GetCharParam(keyStr, firstDefaultValue));
2240    want_->SetParam(emptyStr, thirdValue);
2241    EXPECT_EQ(thirdValue, want_->GetCharParam(emptyStr, secondDefaultValue));
2242}
2243
2244/**
2245 * @tc.number: AaFwk_Want_Parameters_Char_0400
2246 * @tc.name:  SetParam/GetCharParam
2247 * @tc.desc: Verify when the value is char.
2248 */
2249HWTEST_F(WantCharParamTest, AaFwk_Want_Parameters_Char_0400, Function | MediumTest | Level1)
2250{
2251    std::string firstKey("%1uH3");
2252    zchar firstValue = U'中';
2253    zchar secondValue = U'文';
2254    zchar firstDefaultValue = U'字';
2255    zchar secondDefaultValue = U'符';
2256    std::string secondKey("aa");
2257    want_->SetParam(firstKey, firstValue);
2258    want_->SetParam(firstKey, firstValue);
2259    want_->SetParam(firstKey, secondValue);
2260    EXPECT_EQ(secondValue, want_->GetCharParam(firstKey, firstDefaultValue));
2261    want_->SetParam(firstKey, firstValue);
2262    EXPECT_EQ(secondDefaultValue, want_->GetCharParam(secondKey, secondDefaultValue));
2263}
2264
2265using testDoubleArrayType =
2266    std::tuple<std::string, std::string, std::vector<double>, std::vector<double>, std::vector<double>>;
2267class WantDoubleArrayParamTest : public testing::TestWithParam<testDoubleArrayType> {
2268public:
2269    WantDoubleArrayParamTest()
2270    {
2271        want_ = nullptr;
2272    }
2273    ~WantDoubleArrayParamTest()
2274    {
2275        want_ = nullptr;
2276    }
2277    static void SetUpTestCase(void);
2278    static void TearDownTestCase(void);
2279    void SetUp();
2280    void TearDown();
2281    std::shared_ptr<Want> want_;
2282};
2283
2284void WantDoubleArrayParamTest::SetUpTestCase(void)
2285{}
2286
2287void WantDoubleArrayParamTest::TearDownTestCase(void)
2288{}
2289
2290void WantDoubleArrayParamTest::SetUp(void)
2291{
2292    want_ = std::make_shared<Want>();
2293}
2294
2295void WantDoubleArrayParamTest::TearDown(void)
2296{}
2297
2298/**
2299 * @tc.number: AaFwk_Want_DoubleArray_0100
2300 * @tc.name:  SetParam/GetDoubleArrayParam
2301 * @tc.desc: Verify when parameter change.
2302 */
2303HWTEST_P(WantDoubleArrayParamTest, AaFwk_Want_DoubleArray_0100, Function | MediumTest | Level1)
2304{
2305    std::string setKey = std::get<0>(GetParam());
2306    std::string getKey = std::get<1>(GetParam());
2307    std::vector<double> setValue = std::get<2>(GetParam());
2308    std::vector<double> defaultValue = std::get<3>(GetParam());
2309    std::vector<double> result = std::get<4>(GetParam());
2310    want_->SetParam(setKey, setValue);
2311    EXPECT_EQ(result, want_->GetDoubleArrayParam(getKey));
2312}
2313
2314INSTANTIATE_TEST_SUITE_P(WantDoubleArrayParamTestCaseP, WantDoubleArrayParamTest,
2315    testing::Values(testDoubleArrayType("", "aa", {-1.1, -2.1}, {}, {}),
2316        testDoubleArrayType("", "", {-41.1, -42.1}, {}, {-41.1, -42.1}),
2317        testDoubleArrayType("1*中_aR", "aa", {50.1, 51.1}, {}, {}),
2318        testDoubleArrayType("1*中_aR", "1*中_aR", {5000.1, 5001.1}, {}, {5000.1, 5001.1})));
2319
2320/**
2321 * @tc.number: AaFwk_Want_DoubleArray_0200
2322 * @tc.name:  SetParam/GetDoubleArrayParam
2323 * @tc.desc: Verify when parameter change.
2324 */
2325HWTEST_F(WantDoubleArrayParamTest, AaFwk_Want_DoubleArray_0200, Function | MediumTest | Level1)
2326{
2327    std::vector<double> defaultValue;
2328    std::string key = "aa";
2329    EXPECT_EQ(defaultValue, want_->GetDoubleArrayParam(key));
2330}
2331
2332/**
2333 * @tc.number: AaFwk_Want_DoubleArray_0300
2334 * @tc.name:  SetParam/GetDoubleArrayParam
2335 * @tc.desc: set empty-string key repeatedly, but get param of another nonexistent key
2336 */
2337HWTEST_F(WantDoubleArrayParamTest, AaFwk_Want_DoubleArray_0300, Function | MediumTest | Level1)
2338{
2339    std::vector<double> defaultValue;
2340    std::string setKey1 = "cc";
2341    std::string setKey2 = "aa";
2342    std::vector<double> setValue1 = {1.1, 2.1};
2343    std::vector<double> setValue2 = {5.1, 6.1};
2344    want_->SetParam(setKey1, setValue1);
2345    want_->SetParam(setKey1, setValue1);
2346    setValue1 = {2.1, 3.1};
2347    want_->SetParam(setKey1, setValue1);
2348    EXPECT_EQ(defaultValue, want_->GetDoubleArrayParam(setKey2));
2349    setValue1 = {4.1, 5.1};
2350    want_->SetParam(setKey1, setValue1);
2351    EXPECT_EQ(setValue1, want_->GetDoubleArrayParam(setKey1));
2352}
2353
2354/**
2355 * @tc.number: AaFwk_Want_DoubleArray_0400
2356 * @tc.name:  SetParam/GetDoubleArrayParam
2357 * @tc.desc: set empty-string key repeatedly, then get param of the key
2358 */
2359HWTEST_F(WantDoubleArrayParamTest, AaFwk_Want_DoubleArray_0400, Function | MediumTest | Level1)
2360{
2361    std::vector<double> defaultValue;
2362    std::string setKey1 = "%1uH3";
2363    std::string setKey2 = "aa";
2364    std::vector<double> setValue1 = {-1.1, -2.1};
2365    std::vector<double> setValue2 = {9.1, 10.1};
2366    want_->SetParam(setKey1, setValue1);
2367    want_->SetParam(setKey1, setValue1);
2368    setValue1 = {0.1, 1.1};
2369    want_->SetParam(setKey1, setValue1);
2370    EXPECT_EQ(setValue1, want_->GetDoubleArrayParam(setKey1));
2371    setValue1 = {4.1, 5.1};
2372    want_->SetParam(setKey1, setValue1);
2373    setValue1 = {-10.1, -11.1};
2374    EXPECT_EQ(defaultValue, want_->GetDoubleArrayParam(setKey2));
2375}
2376
2377using testFloatArrayType =
2378    std::tuple<std::string, std::string, std::vector<float>, std::vector<float>, std::vector<float>>;
2379class WantFloatArrayParamTest : public testing::TestWithParam<testFloatArrayType> {
2380public:
2381    WantFloatArrayParamTest()
2382    {
2383        want_ = nullptr;
2384    }
2385    ~WantFloatArrayParamTest()
2386    {
2387        want_ = nullptr;
2388    }
2389    static void SetUpTestCase(void);
2390    static void TearDownTestCase(void);
2391    void SetUp();
2392    void TearDown();
2393    std::shared_ptr<Want> want_;
2394};
2395
2396void WantFloatArrayParamTest::SetUpTestCase(void)
2397{}
2398
2399void WantFloatArrayParamTest::TearDownTestCase(void)
2400{}
2401
2402void WantFloatArrayParamTest::SetUp(void)
2403{
2404    want_ = std::make_shared<Want>();
2405}
2406
2407void WantFloatArrayParamTest::TearDown(void)
2408{}
2409
2410/**
2411 * @tc.number: AaFwk_Want_FloatArray_0100
2412 * @tc.name:  SetParam/GetFloatArrayParam
2413 * @tc.desc: Verify when parameter change.
2414 */
2415HWTEST_P(WantFloatArrayParamTest, AaFwk_Want_FloatArray_0100, Function | MediumTest | Level1)
2416{
2417    std::string setKey = std::get<0>(GetParam());
2418    std::string getKey = std::get<1>(GetParam());
2419    std::vector<float> setValue = std::get<2>(GetParam());
2420    std::vector<float> defaultValue = std::get<3>(GetParam());
2421    std::vector<float> result = std::get<4>(GetParam());
2422    want_->SetParam(setKey, setValue);
2423    EXPECT_EQ(result, want_->GetFloatArrayParam(getKey));
2424}
2425
2426INSTANTIATE_TEST_SUITE_P(WantFloatArrayParamTestCaseP, WantFloatArrayParamTest,
2427    testing::Values(testFloatArrayType("", "aa", {-1.1, -2.1}, {}, {}),
2428        testFloatArrayType("", "", {-41.1, -42.1}, {}, {-41.1, -42.1}),
2429        testFloatArrayType("1*中_aR", "aa", {50.1, 51.1}, {}, {}),
2430        testFloatArrayType("1*中_aR", "1*中_aR", {5000.1, 5001.1}, {}, {5000.1, 5001.1})));
2431
2432/**
2433 * @tc.number: AaFwk_Want_FloatArray_0200
2434 * @tc.name:  SetParam/GetFloatArrayParam
2435 * @tc.desc: get param when WantParam is empty
2436 */
2437HWTEST_F(WantFloatArrayParamTest, AaFwk_Want_FloatArray_0200, Function | MediumTest | Level1)
2438{
2439    std::vector<float> defaultValue;
2440    std::string key = "aa";
2441    EXPECT_EQ(defaultValue, want_->GetFloatArrayParam(key));
2442}
2443
2444/**
2445 * @tc.number: AaFwk_Want_FloatArray_0300
2446 * @tc.name:  SetParam & GetFloatArrayParam
2447 * @tc.desc: set empty-string key repeatedly, but get param of another nonexistent key
2448 */
2449HWTEST_F(WantFloatArrayParamTest, AaFwk_Want_FloatArray_0300, Function | MediumTest | Level1)
2450{
2451    std::vector<float> defaultValue;
2452    std::string setKey1 = "hh";
2453    std::string setKey2 = "aa";
2454    std::vector<float> setValue1 = {1.1, 2.1};
2455    want_->SetParam(setKey1, setValue1);
2456    want_->SetParam(setKey1, setValue1);
2457    setValue1 = {2.1, 3.1};
2458    want_->SetParam(setKey1, setValue1);
2459    EXPECT_EQ(defaultValue, want_->GetFloatArrayParam(setKey2));
2460    setValue1 = {4.1, 5.1};
2461    want_->SetParam(setKey1, setValue1);
2462    EXPECT_EQ(setValue1, want_->GetFloatArrayParam(setKey1));
2463}
2464
2465/**
2466 * @tc.number: AaFwk_Want_FloatArray_0400
2467 * @tc.name:  SetParam & GetFloatArrayParam
2468 * @tc.desc: set empty-string key repeatedly, then get param of the key
2469 */
2470HWTEST_F(WantFloatArrayParamTest, AaFwk_Want_FloatArray_0400, Function | MediumTest | Level1)
2471{
2472    std::vector<float> defaultValue;
2473    std::string setKey1 = "%1uH3";
2474    std::string setKey2 = "aa";
2475    std::vector<float> setValue1 = {-1.1, -2.1};
2476    std::vector<float> setValue2 = {9.1, 10.1};
2477    want_->SetParam(setKey1, setValue1);
2478    want_->SetParam(setKey1, setValue1);
2479    setValue1 = {0.1, 1.1};
2480    want_->SetParam(setKey1, setValue1);
2481    EXPECT_EQ(setValue1, want_->GetFloatArrayParam(setKey1));
2482    setValue1 = {4.1, 5.1};
2483    want_->SetParam(setKey1, setValue1);
2484    EXPECT_EQ(defaultValue, want_->GetFloatArrayParam(setKey2));
2485}
2486
2487using testLongArrayType = std::tuple<std::string, std::string, std::vector<long>, std::vector<long>, std::vector<long>>;
2488class WantLongArrayParamTest : public testing::TestWithParam<testLongArrayType> {
2489public:
2490    WantLongArrayParamTest()
2491    {
2492        want_ = nullptr;
2493    }
2494    ~WantLongArrayParamTest()
2495    {
2496        want_ = nullptr;
2497    }
2498    static void SetUpTestCase(void);
2499    static void TearDownTestCase(void);
2500    void SetUp();
2501    void TearDown();
2502    std::shared_ptr<Want> want_;
2503};
2504
2505void WantLongArrayParamTest::SetUpTestCase(void)
2506{}
2507
2508void WantLongArrayParamTest::TearDownTestCase(void)
2509{}
2510
2511void WantLongArrayParamTest::SetUp(void)
2512{
2513    want_ = std::make_shared<Want>();
2514}
2515
2516void WantLongArrayParamTest::TearDown(void)
2517{}
2518
2519/**
2520 * @tc.number: AaFwk_Want_LongArray_0100
2521 * @tc.name:  SetParam & GetLongArrayParam
2522 * @tc.desc: Verify when parameter change.
2523 */
2524HWTEST_P(WantLongArrayParamTest, AaFwk_Want_LongArray_0100, Function | MediumTest | Level1)
2525{
2526    std::string setKey = std::get<0>(GetParam());
2527    std::string getKey = std::get<1>(GetParam());
2528    std::vector<long> setValue = std::get<2>(GetParam());
2529    std::vector<long> defaultValue = std::get<3>(GetParam());
2530    std::vector<long> result = std::get<4>(GetParam());
2531    want_->SetParam(setKey, setValue);
2532    EXPECT_EQ(result, want_->GetLongArrayParam(getKey));
2533}
2534
2535INSTANTIATE_TEST_SUITE_P(WantLongArrayParamTestCaseP, WantLongArrayParamTest,
2536    testing::Values(testLongArrayType("", "aa", {-1, 3, 25, -9}, {}, {}),
2537        testLongArrayType("", "", {-41, 0, 0, 9}, {}, {-41, 0, 0, 9}),
2538        testLongArrayType("1*中_aR", "aa", {50, 2, -9}, {}, {}),
2539        testLongArrayType("1*中_aR", "1*中_aR", {-5000}, {}, {-5000})));
2540
2541/**
2542 * @tc.number: AaFwk_Want_LongArray_0200
2543 * @tc.name:  SetParam & GetLongArrayParam
2544 * @tc.desc: get param when WantParam is empty
2545 */
2546HWTEST_F(WantLongArrayParamTest, AaFwk_Want_LongArray_0200, Function | MediumTest | Level1)
2547{
2548    std::vector<long> defaultValue;
2549    std::string key = "aa";
2550    EXPECT_EQ(defaultValue, want_->GetLongArrayParam(key));
2551}
2552
2553/**
2554 * @tc.number: AaFwk_Want_LongArray_0300
2555 * @tc.name:  SetParam & GetLongArrayParam
2556 * @tc.desc: set empty-string key repeatedly, but get param of another nonexistent key
2557 */
2558HWTEST_F(WantLongArrayParamTest, AaFwk_Want_LongArray_0300, Function | MediumTest | Level1)
2559{
2560    std::vector<long> defaultValue;
2561    std::string setKey1 = "bb";
2562    std::string setKey2 = "aa";
2563    std::vector<long> setValue1 = {1, 2};
2564    want_->SetParam(setKey1, setValue1);
2565    want_->SetParam(setKey1, setValue1);
2566    setValue1 = {2, 3};
2567    want_->SetParam(setKey1, setValue1);
2568    EXPECT_EQ(defaultValue, want_->GetLongArrayParam(setKey2));
2569    setValue1 = {4, 5};
2570    want_->SetParam(setKey1, setValue1);
2571    EXPECT_EQ(setValue1, want_->GetLongArrayParam(setKey1));
2572}
2573
2574/**
2575 * @tc.number: AaFwk_Want_LongArray_0400
2576 * @tc.name:  SetParam & GetLongArrayParam
2577 * @tc.desc: set empty-string key repeatedly, then get param of the key
2578 */
2579HWTEST_F(WantLongArrayParamTest, AaFwk_Want_LongArray_0400, Function | MediumTest | Level1)
2580{
2581    std::vector<long> defaultValue;
2582    std::string setKey1 = "%1uH3";
2583    std::string setKey2 = "aa";
2584    std::vector<long> setValue1 = {-1, -2};
2585    want_->SetParam(setKey1, setValue1);
2586    want_->SetParam(setKey1, setValue1);
2587    setValue1 = {0, 1};
2588    want_->SetParam(setKey1, setValue1);
2589    EXPECT_EQ(setValue1, want_->GetLongArrayParam(setKey1));
2590    setValue1 = {4, 5};
2591    want_->SetParam(setKey1, setValue1);
2592    EXPECT_EQ(defaultValue, want_->GetLongArrayParam(setKey2));
2593}
2594
2595using testShortArrayType =
2596    std::tuple<std::string, std::string, std::vector<short>, std::vector<short>, std::vector<short>>;
2597class WantShortArrayParamTest : public testing::TestWithParam<testShortArrayType> {
2598public:
2599    WantShortArrayParamTest()
2600    {
2601        want_ = nullptr;
2602    }
2603    ~WantShortArrayParamTest()
2604    {
2605        want_ = nullptr;
2606    }
2607    static void SetUpTestCase(void);
2608    static void TearDownTestCase(void);
2609    void SetUp();
2610    void TearDown();
2611    std::shared_ptr<Want> want_;
2612};
2613
2614void WantShortArrayParamTest::SetUpTestCase(void)
2615{}
2616
2617void WantShortArrayParamTest::TearDownTestCase(void)
2618{}
2619
2620void WantShortArrayParamTest::SetUp(void)
2621{
2622    want_ = std::make_shared<Want>();
2623}
2624
2625void WantShortArrayParamTest::TearDown(void)
2626{}
2627
2628/**
2629 * @tc.number: AaFwk_Want_ShortArray_0100
2630 * @tc.name:  SetParam/GetShortArrayParam
2631 * @tc.desc: Verify when parameter change.
2632 */
2633HWTEST_P(WantShortArrayParamTest, AaFwk_Want_ShortArray_0100, Function | MediumTest | Level1)
2634{
2635    std::string setKey = std::get<0>(GetParam());
2636    std::string getKey = std::get<1>(GetParam());
2637    std::vector<short> setValue = std::get<2>(GetParam());
2638    std::vector<short> defaultValue = std::get<3>(GetParam());
2639    std::vector<short> result = std::get<4>(GetParam());
2640    want_->SetParam(setKey, setValue);
2641    EXPECT_EQ(result, want_->GetShortArrayParam(getKey));
2642}
2643
2644INSTANTIATE_TEST_SUITE_P(WantShortArrayParamTestCaseP, WantShortArrayParamTest,
2645    testing::Values(testShortArrayType("", "aa", {-1, 3, 25, -9}, {}, {}),
2646        testShortArrayType("", "", {-41, 0, 0, 9}, {}, {-41, 0, 0, 9}),
2647        testShortArrayType("1*中_aR", "aa", {50, 2, -9}, {}, {}),
2648        testShortArrayType("1*中_aR", "1*中_aR", {-5000}, {}, {-5000})));
2649
2650/**
2651 * @tc.number: AaFwk_Want_ShortArray_0200
2652 * @tc.name:  SetParam/GetShortArrayParam
2653 * @tc.desc: Verify when the value is short array
2654 */
2655HWTEST_F(WantShortArrayParamTest, AaFwk_Want_ShortArray_0200, Function | MediumTest | Level1)
2656{
2657    std::vector<short> defaultValue;
2658    std::string getKey("aa");
2659    EXPECT_EQ(defaultValue, want_->GetShortArrayParam(getKey));
2660}
2661
2662/**
2663 * @tc.number: AaFwk_Want_ShortArray_0300
2664 * @tc.name:  SetParam/GetShortArrayParam
2665 * @tc.desc: Verify when the value is short array
2666 */
2667HWTEST_F(WantShortArrayParamTest, AaFwk_Want_ShortArray_0300, Function | MediumTest | Level1)
2668{
2669    std::string emptyStr("hh");
2670    std::vector<short> firstValue({1, 4, -9});
2671    std::vector<short> secondValue({1, 8, -9});
2672    std::vector<short> thirdValue({1, 4, 9});
2673    std::string keyStr("aa");
2674    want_->SetParam(emptyStr, firstValue);
2675    want_->SetParam(emptyStr, firstValue);
2676    want_->SetParam(emptyStr, secondValue);
2677    std::vector<short> defaultValue;
2678    EXPECT_EQ(defaultValue, want_->GetShortArrayParam(keyStr));
2679    want_->SetParam(emptyStr, thirdValue);
2680    EXPECT_EQ(thirdValue, want_->GetShortArrayParam(emptyStr));
2681}
2682
2683/**
2684 * @tc.number: AaFwk_Want_ShortArray_0400
2685 * @tc.name:  SetParam/GetShortArrayParam
2686 * @tc.desc: Verify when the value is short array
2687 */
2688HWTEST_F(WantShortArrayParamTest, AaFwk_Want_ShortArray_0400, Function | MediumTest | Level1)
2689{
2690    std::string firstKey("%1uH3");
2691    std::vector<short> firstValue({-1, -2});
2692    std::vector<short> secondValue({-1, -2, -1, -2, 0});
2693    std::vector<short> thirdValue({-1, -2, 100});
2694    std::string secondKey("aa");
2695    want_->SetParam(firstKey, firstValue);
2696    want_->SetParam(firstKey, firstValue);
2697    want_->SetParam(firstKey, secondValue);
2698    EXPECT_EQ(secondValue, want_->GetShortArrayParam(firstKey));
2699    want_->SetParam(firstKey, thirdValue);
2700    std::vector<short> defaultValue;
2701    EXPECT_EQ(defaultValue, want_->GetShortArrayParam(secondKey));
2702}
2703
2704using testShortType = std::tuple<std::string, std::string, short, short, short>;
2705class WantShortParamTest : public testing::TestWithParam<testShortType> {
2706public:
2707    WantShortParamTest()
2708    {
2709        want_ = nullptr;
2710    }
2711    ~WantShortParamTest()
2712    {}
2713    static void SetUpTestCase(void);
2714    static void TearDownTestCase(void);
2715    void SetUp();
2716    void TearDown();
2717    std::shared_ptr<Want> want_;
2718};
2719
2720void WantShortParamTest::SetUpTestCase(void)
2721{}
2722
2723void WantShortParamTest::TearDownTestCase(void)
2724{}
2725
2726void WantShortParamTest::SetUp(void)
2727{
2728    want_ = std::make_shared<Want>();
2729}
2730
2731void WantShortParamTest::TearDown(void)
2732{}
2733
2734/**
2735 * @tc.number: AaFwk_Want_Short_0100
2736 * @tc.name:  SetParam/GetShortParam
2737 * @tc.desc: Verify when parameter change.
2738 */
2739HWTEST_P(WantShortParamTest, AaFwk_Want_Short_0100, Function | MediumTest | Level1)
2740{
2741    std::string setKey = std::get<0>(GetParam());
2742    std::string getKey = std::get<1>(GetParam());
2743    short setValue = std::get<2>(GetParam());
2744    short defaultValue = std::get<3>(GetParam());
2745    short result = std::get<4>(GetParam());
2746    want_->SetParam(setKey, setValue);
2747    EXPECT_EQ(result, want_->GetShortParam(getKey, defaultValue));
2748}
2749
2750INSTANTIATE_TEST_SUITE_P(WantShortParamTestCaseP, WantShortParamTest,
2751    testing::Values(testShortType("", "aa", -1, 100, 100), testShortType("", "", -9, -41, -9),
2752        testShortType("1*中_aR", "aa", 50, 5, 5), testShortType("1*中_aR", "1*中_aR", -5000, 5000, -5000)));
2753
2754/**
2755 * @tc.number: AaFwk_Want_Short_0200
2756 * @tc.name:  SetParam/GetShortParam
2757 * @tc.desc: Verify when the value is short
2758 */
2759HWTEST_F(WantShortParamTest, AaFwk_Want_Short_0200, Function | MediumTest | Level1)
2760{
2761    short defaultValue = 200;
2762    std::string getKey("aa");
2763    EXPECT_EQ(defaultValue, want_->GetShortParam(getKey, defaultValue));
2764}
2765/**
2766 * @tc.number: AaFwk_Want_Short_0300
2767 * @tc.name:  SetParam/GetShortParam
2768 * @tc.desc: Verify when the value is short
2769 */
2770HWTEST_F(WantShortParamTest, AaFwk_Want_Short_0300, Function | MediumTest | Level1)
2771{
2772    std::string emptyStr("bb");
2773    short firstValue = 1;
2774    short secondValue = 2;
2775    short thirdValue = 4;
2776    short firstDefaultValue = 3;
2777    short secondDefaultValue = 5;
2778    std::string keyStr("aa");
2779    want_->SetParam(emptyStr, firstValue);
2780    want_->SetParam(emptyStr, firstValue);
2781    want_->SetParam(emptyStr, secondValue);
2782    EXPECT_EQ(firstDefaultValue, want_->GetShortParam(keyStr, firstDefaultValue));
2783    want_->SetParam(emptyStr, thirdValue);
2784    EXPECT_EQ(thirdValue, want_->GetShortParam(emptyStr, secondDefaultValue));
2785}
2786
2787/**
2788 * @tc.number: AaFwk_Want_Short_0400
2789 * @tc.name:  SetParam/GetShortParam
2790 * @tc.desc: Verify when the value is short
2791 */
2792HWTEST_F(WantShortParamTest, AaFwk_Want_Short_0400, Function | MediumTest | Level1)
2793{
2794    std::string firstKey("%1uH3");
2795    short firstValue = -1;
2796    short secondValue = 0;
2797    short thirdValue = 4;
2798    short firstDefaultValue = 9;
2799    short secondDefaultValue = -10;
2800    std::string secondKey("aa");
2801    want_->SetParam(firstKey, firstValue);
2802    want_->SetParam(firstKey, firstValue);
2803    want_->SetParam(firstKey, secondValue);
2804    EXPECT_EQ(secondValue, want_->GetShortParam(firstKey, firstDefaultValue));
2805    want_->SetParam(firstKey, thirdValue);
2806    EXPECT_EQ(secondDefaultValue, want_->GetShortParam(secondKey, secondDefaultValue));
2807}
2808
2809using testStrArrayType =
2810    std::tuple<std::string, std::string, std::vector<std::string>, std::vector<std::string>, std::vector<std::string>>;
2811class WantStringArrayParamTest : public testing::TestWithParam<testStrArrayType> {
2812public:
2813    WantStringArrayParamTest()
2814    {
2815        want_ = nullptr;
2816    }
2817    ~WantStringArrayParamTest()
2818    {}
2819    static void SetUpTestCase(void);
2820    static void TearDownTestCase(void);
2821    void SetUp();
2822    void TearDown();
2823    std::shared_ptr<Want> want_ = nullptr;
2824};
2825
2826void WantStringArrayParamTest::SetUpTestCase(void)
2827{}
2828
2829void WantStringArrayParamTest::TearDownTestCase(void)
2830{}
2831
2832void WantStringArrayParamTest::SetUp(void)
2833{
2834    want_ = std::make_shared<Want>();
2835}
2836
2837void WantStringArrayParamTest::TearDown(void)
2838{}
2839
2840/**
2841 * @tc.number: AaFwk_Want_StringArray_0100
2842 * @tc.name:  SetParam/GetStringArrayParam
2843 * @tc.desc: Verify when parameter change.
2844 */
2845HWTEST_P(WantStringArrayParamTest, AaFwk_Want_StringArray_0100, Function | MediumTest | Level1)
2846{
2847    std::string setKey = std::get<0>(GetParam());
2848    std::string getKey = std::get<1>(GetParam());
2849    std::vector<std::string> setValue = std::get<2>(GetParam());
2850    std::vector<std::string> defaultValue = std::get<3>(GetParam());
2851    std::vector<std::string> result = std::get<4>(GetParam());
2852    want_->SetParam(setKey, setValue);
2853    EXPECT_EQ(result, want_->GetStringArrayParam(getKey));
2854}
2855
2856INSTANTIATE_TEST_SUITE_P(WantStringArrayParamTestCaseP, WantStringArrayParamTest,
2857    testing::Values(testStrArrayType("", "aa", {"1*中_aR", "dbdb"}, {}, {}),
2858        testStrArrayType("", "", {"1*中_aR", "dbdb"}, {}, {"1*中_aR", "dbdb"}),
2859        testStrArrayType("1*中_aR", "aa", {"1*中_aR", "dbdb"}, {}, {}),
2860        testStrArrayType("1*中_aR", "1*中_aR", {"1*中_aR", "dbdb"}, {}, {"1*中_aR", "dbdb"})));
2861
2862/**
2863 * @tc.number: AaFwk_Want_StringArray_0200
2864 * @tc.name:  SetParam/GetStringArrayParam
2865 * @tc.desc: get param when WantParam is empty
2866 */
2867HWTEST_F(WantStringArrayParamTest, AaFwk_Want_StringArray_0200, Function | MediumTest | Level1)
2868{
2869    std::vector<std::string> defaultValue;
2870    std::string key = "aa";
2871    std::vector<std::string> resultValue = want_->GetStringArrayParam(key);
2872    EXPECT_EQ(defaultValue, resultValue);
2873}
2874
2875/**
2876 * @tc.number: AaFwk_Want_StringArray_0300
2877 * @tc.name:  SetParam/GetStringArrayParam
2878 * @tc.desc: set empty-string key repeatedly, but get param of another nonexistent key
2879 */
2880HWTEST_F(WantStringArrayParamTest, AaFwk_Want_StringArray_0300, Function | MediumTest | Level1)
2881{
2882    std::vector<std::string> defaultValue;
2883    std::vector<std::string> setValue1 = {"aaa", "2132"};
2884    std::vector<std::string> setValue2 = {"1*中_aR", "dbdb"};
2885    std::string key1 = "cc";
2886    std::string key2 = "aa";
2887    want_->SetParam(key1, setValue1);
2888    want_->SetParam(key1, setValue1);
2889    want_->SetParam(key1, setValue2);
2890    std::vector<std::string> resultValue = want_->GetStringArrayParam(key2);
2891    EXPECT_EQ(defaultValue, resultValue);
2892
2893    want_->SetParam(key1, setValue1);
2894    resultValue = want_->GetStringArrayParam(key1);
2895    EXPECT_EQ(setValue1, resultValue);
2896}
2897
2898/**
2899 * @tc.number: AaFwk_Want_StringArray_0400
2900 * @tc.name:  SetParam/GetStringArrayParam
2901 * @tc.desc: set empty-string key repeatedly, then get param of the key
2902 */
2903HWTEST_F(WantStringArrayParamTest, AaFwk_Want_StringArray_0400, Function | MediumTest | Level1)
2904{
2905    std::vector<std::string> defaultValue;
2906    std::vector<std::string> setValue = {"aaa", "2132"};
2907    std::string key1 = "%1uH3";
2908    std::string key2 = "aa";
2909    want_->SetParam(key1, setValue);
2910    want_->SetParam(key1, setValue);
2911    setValue = {"1*中_aR", "3#$%"};
2912    want_->SetParam(key1, setValue);
2913    std::vector<std::string> resultValue = want_->GetStringArrayParam(key1);
2914    EXPECT_EQ(setValue, resultValue);
2915
2916    setValue = {"aaa", "2132"};
2917    want_->SetParam(key1, setValue);
2918    resultValue = want_->GetStringArrayParam(key2);
2919    EXPECT_EQ(defaultValue, resultValue);
2920}
2921
2922using testStrType = std::tuple<std::string, std::string, std::string, std::string, std::string>;
2923class WantStringParamTest : public testing::TestWithParam<testStrType> {
2924public:
2925    WantStringParamTest()
2926    {
2927        want_ = nullptr;
2928    }
2929    ~WantStringParamTest()
2930    {}
2931    static void SetUpTestCase(void);
2932    static void TearDownTestCase(void);
2933    void SetUp();
2934    void TearDown();
2935    std::shared_ptr<Want> want_;
2936};
2937
2938void WantStringParamTest::SetUpTestCase(void)
2939{}
2940
2941void WantStringParamTest::TearDownTestCase(void)
2942{}
2943
2944void WantStringParamTest::SetUp(void)
2945{
2946    want_ = std::make_shared<Want>();
2947}
2948
2949void WantStringParamTest::TearDown(void)
2950{}
2951
2952/**
2953 * @tc.number: AaFwk_Want_String_0100
2954 * @tc.name:  SetParam/GetStringParam
2955 * @tc.desc: Verify when parameter change.
2956 */
2957HWTEST_P(WantStringParamTest, AaFwk_Want_String_0100, Function | MediumTest | Level1)
2958{
2959    std::string setKey = std::get<0>(GetParam());
2960    std::string getKey = std::get<1>(GetParam());
2961    std::string setValue = std::get<2>(GetParam());
2962    std::string defaultValue = std::get<3>(GetParam());
2963    std::string result = std::get<4>(GetParam());
2964    want_->SetParam(setKey, setValue);
2965    EXPECT_EQ(result, want_->GetStringParam(getKey));
2966}
2967
2968INSTANTIATE_TEST_SUITE_P(WantStringParamTestCaseP, WantStringParamTest,
2969    testing::Values(testStrType("", "aa", "1*中_aR", "", ""), testStrType("", "", "1*中_aR", "", "1*中_aR"),
2970        testStrType("1*中_aR", "aa", "aaa", "", ""), testStrType("1*中_aR", "1*中_aR", "aaa", "", "aaa")));
2971
2972/**
2973 * @tc.number: AaFwk_Want_String_0200
2974 * @tc.name:  SetParam/GetStringParam
2975 * @tc.desc: get param when WantParam is empty.
2976 */
2977HWTEST_F(WantStringParamTest, AaFwk_Want_String_0200, Function | MediumTest | Level1)
2978{
2979    std::string defaultStrValue;
2980    std::string key = "aa";
2981    EXPECT_EQ(defaultStrValue, want_->GetStringParam(key));
2982}
2983
2984/**
2985 * @tc.number: AaFwk_Want_String_0300
2986 * @tc.name:  SetParam/GetStringParam
2987 * @tc.desc: set empty-string key repeatedly, but get param of another nonexistent key.
2988 */
2989HWTEST_F(WantStringParamTest, AaFwk_Want_String_0300, Function | MediumTest | Level1)
2990{
2991    std::string defaultStrValue;
2992    std::string setValue1 = "aaa";
2993    std::string setValue2 = "1*中_aR";
2994    std::string key1 = "dd";
2995    std::string key2 = "aa";
2996    want_->SetParam(key1, setValue1);
2997    want_->SetParam(key1, setValue1);
2998    want_->SetParam(key1, setValue2);
2999    EXPECT_EQ(defaultStrValue, want_->GetStringParam(key2));
3000    want_->SetParam(key1, setValue1);
3001    EXPECT_EQ(setValue1, want_->GetStringParam(key1));
3002}
3003
3004/**
3005 * @tc.number: AaFwk_Want_String_0400
3006 * @tc.name:  SetParam/GetStringParam
3007 * @tc.desc: set empty-string key repeatedly, then get param of the key.
3008 */
3009HWTEST_F(WantStringParamTest, AaFwk_Want_String_0400, Function | MediumTest | Level1)
3010{
3011    std::string key1 = "%1uH3";
3012    std::string defaultStrValue;
3013    std::string setValue1 = "aaa";
3014    std::string setValue2 = "1*中_aR";
3015    std::string key2 = "aa";
3016    want_->SetParam(key1, setValue1);
3017    want_->SetParam(key1, setValue1);
3018    want_->SetParam(key1, setValue2);
3019    EXPECT_EQ("1*中_aR", want_->GetStringParam(key1));
3020    want_->SetParam(key1, setValue1);
3021    EXPECT_EQ(defaultStrValue, want_->GetStringParam(key2));
3022}
3023
3024using testLongType = std::tuple<std::string, std::string, long, long, long>;
3025class WantLongParamTest : public testing::TestWithParam<testLongType> {
3026public:
3027    WantLongParamTest()
3028    {
3029        want_ = nullptr;
3030    }
3031    ~WantLongParamTest()
3032    {}
3033    static void SetUpTestCase(void);
3034    static void TearDownTestCase(void);
3035    void SetUp();
3036    void TearDown();
3037    std::shared_ptr<Want> want_ = nullptr;
3038};
3039
3040void WantLongParamTest::SetUpTestCase(void)
3041{}
3042
3043void WantLongParamTest::TearDownTestCase(void)
3044{}
3045
3046void WantLongParamTest::SetUp(void)
3047{
3048    want_ = std::make_shared<Want>();
3049}
3050
3051void WantLongParamTest::TearDown(void)
3052{}
3053
3054/**
3055 * @tc.number: AaFwk_Want_LongParam_0100
3056 * @tc.name:  SetParam/GetLongParam
3057 * @tc.desc: Verify when parameter change.
3058 */
3059HWTEST_P(WantLongParamTest, AaFwk_Want_LongParam_0100, Function | MediumTest | Level1)
3060{
3061    std::string setKey = std::get<0>(GetParam());
3062    std::string getKey = std::get<1>(GetParam());
3063    long setValue = std::get<2>(GetParam());
3064    long defaultValue = std::get<3>(GetParam());
3065    long result = std::get<4>(GetParam());
3066    want_->SetParam(setKey, setValue);
3067    EXPECT_EQ(result, want_->GetLongParam(getKey, defaultValue));
3068}
3069
3070INSTANTIATE_TEST_SUITE_P(WantLongParamTestCaseP, WantLongParamTest,
3071    testing::Values(testLongType("b1", "b1", -1, 100, -1), testLongType("b3", "b4", 600, 200, 200),
3072        testLongType("b5", "b5", 50, 6, 50), testLongType("b6", "b7", 1000, 2200, 2200)));
3073
3074/**
3075 * @tc.number: AaFwk_Want_LongParam_0200
3076 * @tc.name:  SetParam/GetLongParam
3077 * @tc.desc:  get param when WantParam is empty.
3078 */
3079HWTEST_F(WantLongParamTest, AaFwk_Want_LongParam_0200, Function | MediumTest | Level1)
3080{
3081    long defaultValue = 100;
3082    std::string key = "aa";
3083    EXPECT_EQ(defaultValue, want_->GetLongParam(key, defaultValue));
3084}
3085
3086/**
3087 * @tc.number: AaFwk_Want_LongParam_0300
3088 * @tc.name:  SetParam/GetLongParam
3089 * @tc.desc:  set empty-string key repeatedly, but get param of another nonexistent key.
3090 */
3091HWTEST_F(WantLongParamTest, AaFwk_Want_LongParam_0300, Function | MediumTest | Level1)
3092{
3093    std::string setKey1 = "dd";
3094    std::string setKey2 = "aa";
3095    long setValue1 = 1;
3096    long setValue2 = 5;
3097    want_->SetParam(setKey1, setValue1);
3098    want_->SetParam(setKey1, setValue1);
3099    setValue1 = 2;
3100    want_->SetParam(setKey1, setValue1);
3101    setValue1 = 3;
3102    EXPECT_EQ(setValue1, want_->GetLongParam(setKey2, setValue1));
3103    setValue1 = 4;
3104    want_->SetParam(setKey1, setValue1);
3105    EXPECT_EQ(setValue1, want_->GetLongParam(setKey1, setValue2));
3106}
3107
3108/**
3109 * @tc.number: AaFwk_Want_LongParam_0400
3110 * @tc.name:  SetParam/GetLongParam
3111 * @tc.desc:  set empty-string key repeatedly, then get param of the key.
3112 */
3113HWTEST_F(WantLongParamTest, AaFwk_Want_LongParam_0400, Function | MediumTest | Level1)
3114{
3115    std::string setKey1 = "%1uH3";
3116    std::string setKey2 = "aa";
3117    long setValue1 = -1;
3118    long setValue2 = 9;
3119    want_->SetParam(setKey1, setValue1);
3120    want_->SetParam(setKey1, setValue1);
3121    setValue1 = 0;
3122    want_->SetParam(setKey1, setValue1);
3123    EXPECT_EQ(setValue1, want_->GetLongParam(setKey1, setValue2));
3124    setValue1 = 4;
3125    want_->SetParam(setKey1, setValue1);
3126    setValue1 = -10;
3127    EXPECT_EQ(setValue1, want_->GetLongParam(setKey2, setValue1));
3128}
3129
3130using testIntType = std::tuple<std::string, std::string, int, int, int>;
3131class WantIntParamTest : public testing::TestWithParam<testIntType> {
3132public:
3133    WantIntParamTest()
3134    {
3135        want_ = nullptr;
3136    }
3137    ~WantIntParamTest()
3138    {
3139        want_ = nullptr;
3140    }
3141    static void SetUpTestCase(void);
3142    static void TearDownTestCase(void);
3143    void SetUp();
3144    void TearDown();
3145    std::shared_ptr<Want> want_;
3146};
3147
3148void WantIntParamTest::SetUpTestCase(void)
3149{}
3150
3151void WantIntParamTest::TearDownTestCase(void)
3152{}
3153
3154void WantIntParamTest::SetUp(void)
3155{
3156    want_ = std::make_shared<Want>();
3157}
3158
3159void WantIntParamTest::TearDown(void)
3160{}
3161
3162/**
3163 * @tc.number: AaFwk_Want_IntParam_0100
3164 * @tc.name:  SetParam/GetIntParam
3165 * @tc.desc:  Verify when parameter change.
3166 */
3167HWTEST_P(WantIntParamTest, AaFwk_Want_IntParam_0100, Function | MediumTest | Level1)
3168{
3169    std::string setKey = std::get<0>(GetParam());
3170    std::string getKey = std::get<1>(GetParam());
3171    int setValue = std::get<2>(GetParam());
3172    int defaultValue = std::get<3>(GetParam());
3173    int result = std::get<4>(GetParam());
3174    want_->SetParam(setKey, setValue);
3175    EXPECT_EQ(result, want_->GetIntParam(getKey, defaultValue));
3176}
3177
3178INSTANTIATE_TEST_SUITE_P(WantParametersIntTestCaseP, WantIntParamTest,
3179    testing::Values(testIntType("", "aa", -1, 100, 100), testIntType("", "", -9, -41, -9),
3180        testIntType("1*中_aR", "aa", 50, 5, 5), testIntType("1*中_aR", "1*中_aR", -5000, 5000, -5000)));
3181
3182/**
3183 * @tc.number: AaFwk_Want_IntParam_0200
3184 * @tc.name:  SetParam/GetIntParam
3185 * @tc.desc:  Verify when the value is integer.
3186 */
3187HWTEST_F(WantIntParamTest, AaFwk_Want_IntParam_0200, Function | MediumTest | Level1)
3188{
3189    int defaultValue = 200;
3190    std::string getKey("aa");
3191    EXPECT_EQ(defaultValue, want_->GetIntParam(getKey, defaultValue));
3192}
3193
3194/**
3195 * @tc.number: AaFwk_Want_IntParam_0300
3196 * @tc.name:  SetParam/GetIntParam
3197 * @tc.desc:  Verify when the value is integer.
3198 */
3199HWTEST_F(WantIntParamTest, AaFwk_Want_IntParam_0300, Function | MediumTest | Level1)
3200{
3201    std::string emptyStr("bb");
3202    int firstValue = 1;
3203    int secondValue = 2;
3204    int thirdValue = 4;
3205    int firstDefaultValue = 3;
3206    int secondDefaultValue = 5;
3207    std::string keyStr("aa");
3208    want_->SetParam(emptyStr, firstValue);
3209    want_->SetParam(emptyStr, firstValue);
3210    want_->SetParam(emptyStr, secondValue);
3211    EXPECT_EQ(firstDefaultValue, want_->GetIntParam(keyStr, firstDefaultValue));
3212    want_->SetParam(emptyStr, thirdValue);
3213    EXPECT_EQ(thirdValue, want_->GetIntParam(emptyStr, secondDefaultValue));
3214}
3215
3216/**
3217 * @tc.number: AaFwk_Want_IntParam_0400
3218 * @tc.name:  SetParam/GetIntParam
3219 * @tc.desc:  Verify when the value is integer.
3220 */
3221HWTEST_F(WantIntParamTest, AaFwk_Want_IntParam_0400, Function | MediumTest | Level1)
3222{
3223    std::string firstKey("%1uH3");
3224    int firstValue = -1;
3225    int secondValue = 0;
3226    int thirdValue = 4;
3227    int firstDefaultValue = 9;
3228    int secondDefaultValue = -10;
3229    std::string secondKey("aa");
3230    want_->SetParam(firstKey, firstValue);
3231    want_->SetParam(firstKey, firstValue);
3232    want_->SetParam(firstKey, secondValue);
3233    EXPECT_EQ(secondValue, want_->GetIntParam(firstKey, firstDefaultValue));
3234    want_->SetParam(firstKey, thirdValue);
3235    EXPECT_EQ(secondDefaultValue, want_->GetIntParam(secondKey, secondDefaultValue));
3236}
3237
3238using testIntArrayType = std::tuple<std::string, std::string, std::vector<int>, std::vector<int>, std::vector<int>>;
3239class WantIntArrayParamTest : public testing::TestWithParam<testIntArrayType> {
3240public:
3241    WantIntArrayParamTest()
3242    {
3243        want_ = nullptr;
3244    }
3245    ~WantIntArrayParamTest()
3246    {
3247        want_ = nullptr;
3248    }
3249    static void SetUpTestCase(void);
3250    static void TearDownTestCase(void);
3251    void SetUp();
3252    void TearDown();
3253    std::shared_ptr<Want> want_;
3254};
3255
3256void WantIntArrayParamTest::SetUpTestCase(void)
3257{}
3258
3259void WantIntArrayParamTest::TearDownTestCase(void)
3260{}
3261
3262void WantIntArrayParamTest::SetUp(void)
3263{
3264    want_ = std::make_shared<Want>();
3265}
3266
3267void WantIntArrayParamTest::TearDown(void)
3268{}
3269
3270/**
3271 * @tc.number: AaFwk_Want_IntArrayParam_0100
3272 * @tc.name:  SetParam/GetIntArrayParam
3273 * @tc.desc:  Verify when parameter change.
3274 */
3275HWTEST_P(WantIntArrayParamTest, AaFwk_Want_IntArrayParam_0100, Function | MediumTest | Level1)
3276{
3277    std::string setKey = std::get<0>(GetParam());
3278    std::string getKey = std::get<1>(GetParam());
3279    std::vector<int> setValue = std::get<2>(GetParam());
3280    std::vector<int> defaultValue = std::get<3>(GetParam());
3281    std::vector<int> result = std::get<4>(GetParam());
3282    want_->SetParam(setKey, setValue);
3283    EXPECT_EQ(result, want_->GetIntArrayParam(getKey));
3284}
3285
3286INSTANTIATE_TEST_SUITE_P(WantIntArrayParamTestCaseP, WantIntArrayParamTest,
3287    testing::Values(testIntArrayType("", "aa", {-1, 3, 25, -9}, {}, {}),
3288        testIntArrayType("", "", {-41, 0, 0, 9}, {}, {-41, 0, 0, 9}),
3289        testIntArrayType("1*中_aR", "aa", {50, 2, -9}, {}, {}),
3290        testIntArrayType("1*中_aR", "1*中_aR", {-5000}, {}, {-5000})));
3291
3292/**
3293 * @tc.number: AaFwk_Want_IntArrayParam_0200
3294 * @tc.name:  SetParam/GetIntArrayParam
3295 * @tc.desc:  Verify when the value is integer array.
3296 */
3297HWTEST_F(WantIntArrayParamTest, AaFwk_Want_IntArrayParam_0200, Function | MediumTest | Level1)
3298{
3299    std::vector<int> defaultValue;
3300    std::string getKey("aa");
3301    EXPECT_EQ(defaultValue, want_->GetIntArrayParam(getKey));
3302}
3303
3304/**
3305 * @tc.number: AaFwk_Want_IntArrayParam_0300
3306 * @tc.name:  SetParam/GetIntArrayParam
3307 * @tc.desc:  Verify when the value is integer array.
3308 */
3309HWTEST_F(WantIntArrayParamTest, AaFwk_Want_IntArrayParam_0300, Function | MediumTest | Level1)
3310{
3311    std::string emptyStr("cc");
3312    std::vector<int> firstValue({1, 4, -9});
3313    std::vector<int> secondValue({1, 8, -9});
3314    std::vector<int> thirdValue({1, 4, 9});
3315    std::string keyStr("aa");
3316    want_->SetParam(emptyStr, firstValue);
3317    want_->SetParam(emptyStr, firstValue);
3318    want_->SetParam(emptyStr, secondValue);
3319    std::vector<int> defaultValue;
3320    EXPECT_EQ(defaultValue, want_->GetIntArrayParam(keyStr));
3321    want_->SetParam(emptyStr, thirdValue);
3322    EXPECT_EQ(thirdValue, want_->GetIntArrayParam(emptyStr));
3323}
3324
3325/**
3326 * @tc.number: AaFwk_Want_IntArrayParam_0400
3327 * @tc.name:  SetParam/GetIntArrayParam
3328 * @tc.desc:  Verify when the value is integer array.
3329 */
3330HWTEST_F(WantIntArrayParamTest, AaFwk_Want_IntArrayParam_0400, Function | MediumTest | Level1)
3331{
3332    std::string firstKey("%1uH3");
3333    std::vector<int> firstValue({-1, -2});
3334    std::vector<int> secondValue({-1, -2, -1, -2, 0});
3335    std::vector<int> thirdValue({-1, -2, 100});
3336    std::string secondKey("aa");
3337    want_->SetParam(firstKey, firstValue);
3338    want_->SetParam(firstKey, firstValue);
3339    want_->SetParam(firstKey, secondValue);
3340    EXPECT_EQ(secondValue, want_->GetIntArrayParam(firstKey));
3341    want_->SetParam(firstKey, thirdValue);
3342    std::vector<int> defaultValue;
3343    EXPECT_EQ(defaultValue, want_->GetIntArrayParam(secondKey));
3344}
3345
3346using testFloatType = std::tuple<std::string, std::string, float, float, float>;
3347class WantFloatParamTest : public testing::TestWithParam<testFloatType> {
3348public:
3349    WantFloatParamTest()
3350    {
3351        want_ = nullptr;
3352    }
3353    ~WantFloatParamTest()
3354    {
3355        want_ = nullptr;
3356    }
3357
3358    static void SetUpTestCase(void);
3359    static void TearDownTestCase(void);
3360    void SetUp();
3361    void TearDown();
3362    std::shared_ptr<Want> want_;
3363};
3364
3365void WantFloatParamTest::SetUpTestCase(void)
3366{}
3367
3368void WantFloatParamTest::TearDownTestCase(void)
3369{}
3370
3371void WantFloatParamTest::SetUp(void)
3372{
3373    want_ = std::make_shared<Want>();
3374}
3375
3376void WantFloatParamTest::TearDown(void)
3377{}
3378
3379/**
3380 * @tc.number: AaFwk_Want_FloatParam_0100
3381 * @tc.name:  SetParam/GetFloatParam
3382 * @tc.desc:  Verify when parameter change.
3383 */
3384HWTEST_P(WantFloatParamTest, AaFwk_Want_FloatParam_0100, Function | MediumTest | Level1)
3385{
3386    std::string setKey = std::get<0>(GetParam());
3387    std::string getKey = std::get<1>(GetParam());
3388    float setValue = std::get<2>(GetParam());
3389    float defaultValue = std::get<3>(GetParam());
3390    float result = std::get<4>(GetParam());
3391    want_->SetParam(setKey, setValue);
3392    EXPECT_EQ(result, want_->GetFloatParam(getKey, defaultValue));
3393}
3394
3395INSTANTIATE_TEST_SUITE_P(WantFloatParamTestCaseP, WantFloatParamTest,
3396    testing::Values(testFloatType("", "aa", -1.1, 100.1, 100.1), testFloatType("", "", -9.1, -41.1, -9.1),
3397        testFloatType("1*中_aR", "aa", 50.1, 5.1, 5.1), testFloatType("1*中_aR", "1*中_aR", -5000.1, 5000.1, -5000.1)));
3398
3399/**
3400 * @tc.number: AaFwk_Want_FloatParam_0200
3401 * @tc.name:  SetParam/GetFloatParam
3402 * @tc.desc:  get param when WantParam is empty.
3403 */
3404HWTEST_F(WantFloatParamTest, AaFwk_Want_FloatParam_0200, Function | MediumTest | Level1)
3405{
3406    float defaultValue = 100.1;
3407    std::string key = "aa";
3408    EXPECT_EQ(defaultValue, want_->GetFloatParam(key, defaultValue));
3409}
3410
3411/**
3412 * @tc.number: AaFwk_Want_FloatParam_0300
3413 * @tc.name:  SetParam/GetFloatParam
3414 * @tc.desc:  set empty-string key repeatedly, but get param of another nonexistent key.
3415 */
3416HWTEST_F(WantFloatParamTest, AaFwk_Want_FloatParam_0300, Function | MediumTest | Level1)
3417{
3418    std::string setKey1 = "ee";
3419    std::string setKey2 = "aa";
3420    float setValue1 = 1.1;
3421    float setValue2 = 5.1;
3422    want_->SetParam(setKey1, setValue1);
3423    want_->SetParam(setKey1, setValue1);
3424    setValue1 = 2.1;
3425    want_->SetParam(setKey1, setValue1);
3426    setValue1 = 3.1;
3427    EXPECT_EQ(setValue1, want_->GetFloatParam(setKey2, setValue1));
3428    setValue1 = 4.1;
3429    want_->SetParam(setKey1, setValue1);
3430    EXPECT_EQ(setValue1, want_->GetFloatParam(setKey1, setValue2));
3431}
3432
3433/**
3434 * @tc.number: AaFwk_Want_FloatParam_0400
3435 * @tc.name:  SetParam/GetFloatParam
3436 * @tc.desc:  set empty-string key repeatedly, but get param of another nonexistent key.
3437 */
3438HWTEST_F(WantFloatParamTest, AaFwk_Want_FloatParam_0400, Function | MediumTest | Level1)
3439{
3440    std::string setKey1 = "%1uH3";
3441    std::string setKey2 = "aa";
3442    float setValue1 = -1.1;
3443    float setValue2 = 9.1;
3444    want_->SetParam(setKey1, setValue1);
3445    want_->SetParam(setKey1, setValue1);
3446    setValue1 = 0.1;
3447    want_->SetParam(setKey1, setValue1);
3448    EXPECT_EQ(setValue1, want_->GetFloatParam(setKey1, setValue2));
3449    setValue1 = 4.1;
3450    want_->SetParam(setKey1, setValue1);
3451    setValue1 = -10.1;
3452    EXPECT_EQ(setValue1, want_->GetFloatParam(setKey2, setValue1));
3453}
3454
3455using testDoubleType = std::tuple<std::string, std::string, double, double, double>;
3456class WantDoubleParamTest : public testing::TestWithParam<testDoubleType> {
3457public:
3458    WantDoubleParamTest()
3459    {
3460        want_ = nullptr;
3461    }
3462    ~WantDoubleParamTest()
3463    {
3464        want_ = nullptr;
3465    }
3466    static void SetUpTestCase(void);
3467    static void TearDownTestCase(void);
3468    void SetUp();
3469    void TearDown();
3470    std::shared_ptr<Want> want_;
3471};
3472
3473void WantDoubleParamTest::SetUpTestCase(void)
3474{}
3475
3476void WantDoubleParamTest::TearDownTestCase(void)
3477{}
3478
3479void WantDoubleParamTest::SetUp(void)
3480{
3481    want_ = std::make_shared<Want>();
3482}
3483
3484void WantDoubleParamTest::TearDown(void)
3485{}
3486
3487/**
3488 * @tc.number: AaFwk_Want_DoubleParam_0100
3489 * @tc.name:  SetParam/GetDoubleParam
3490 * @tc.desc:  Verify when parameter change.
3491 */
3492HWTEST_P(WantDoubleParamTest, AaFwk_Want_DoubleParam_0100, Function | MediumTest | Level1)
3493{
3494    std::string setKey = std::get<0>(GetParam());
3495    std::string getKey = std::get<1>(GetParam());
3496    double setValue = std::get<2>(GetParam());
3497    double defaultValue = std::get<3>(GetParam());
3498    double result = std::get<4>(GetParam());
3499    want_->SetParam(setKey, setValue);
3500    EXPECT_EQ(result, want_->GetDoubleParam(getKey, defaultValue));
3501}
3502
3503INSTANTIATE_TEST_SUITE_P(WantDoubleParamTestCaseP, WantDoubleParamTest,
3504    testing::Values(testDoubleType("", "aa", -1.1, 100.1, 100.1), testDoubleType("", "", -9.1, -41.1, -9.1),
3505        testDoubleType("1*中_aR", "aa", 50.1, 5.1, 5.1),
3506        testDoubleType("1*中_aR", "1*中_aR", -5000.1, 5000.1, -5000.1)));
3507
3508/**
3509 * @tc.number: AaFwk_Want_DoubleParam_0300
3510 * @tc.name:  SetParam & GetDoubleParam
3511 * @tc.desc:  set empty-string key repeatedly, but get param of another nonexistent key.
3512 */
3513HWTEST_F(WantDoubleParamTest, AaFwk_Want_DoubleParam_0300, Function | MediumTest | Level1)
3514{
3515    double defaultValue = 100.1;
3516    std::string key = "aa";
3517    EXPECT_EQ(defaultValue, want_->GetDoubleParam(key, defaultValue));
3518}
3519
3520/**
3521 * @tc.number: AaFwk_Want_DoubleParam_0400
3522 * @tc.name:  SetParam & GetDoubleParam
3523 * @tc.desc:  set empty-string key repeatedly, then get param of the key.
3524 */
3525HWTEST_F(WantDoubleParamTest, AaFwk_Want_DoubleParam_0400, Function | MediumTest | Level1)
3526{
3527    std::string setKey1 = "ff";
3528    std::string setKey2 = "aa";
3529    double setValue1 = 1.1;
3530    double setValue2 = 5.1;
3531    want_->SetParam(setKey1, setValue1);
3532    want_->SetParam(setKey1, setValue1);
3533    setValue1 = 2.1;
3534    want_->SetParam(setKey1, setValue1);
3535    setValue1 = 3.1;
3536    EXPECT_EQ(setValue1, want_->GetDoubleParam(setKey2, setValue1));
3537    setValue1 = 4.1;
3538    want_->SetParam(setKey1, setValue1);
3539    EXPECT_EQ(setValue1, want_->GetDoubleParam(setKey1, setValue2));
3540}
3541
3542/**
3543 * @tc.number: AaFwk_Want_ByteArray_0100
3544 * @tc.name:  SetParam/GetByteArrayParam
3545 * @tc.desc:  Verify when parameter change.
3546 */
3547HWTEST_F(WantDoubleParamTest, AaFwk_Want_ByteArray_0100, Function | MediumTest | Level1)
3548{
3549    std::string setKey1 = "%1uH3";
3550    std::string setKey2 = "aa";
3551    double setValue1 = -1.1;
3552    double setValue2 = 9.1;
3553    want_->SetParam(setKey1, setValue1);
3554    want_->SetParam(setKey1, setValue1);
3555    setValue1 = 0.1;
3556    want_->SetParam(setKey1, setValue1);
3557    EXPECT_EQ(setValue1, want_->GetDoubleParam(setKey1, setValue2));
3558    setValue1 = 4.1;
3559    want_->SetParam(setKey1, setValue1);
3560    setValue1 = -10.1;
3561    EXPECT_EQ(setValue1, want_->GetDoubleParam(setKey2, setValue1));
3562}
3563
3564using testByteArrayType = std::tuple<std::string, std::string, std::vector<byte>, std::vector<byte>, std::vector<byte>>;
3565class WantByteArrayParamTest : public testing::TestWithParam<testByteArrayType> {
3566public:
3567    WantByteArrayParamTest()
3568    {
3569        want_ = nullptr;
3570    }
3571    ~WantByteArrayParamTest()
3572    {
3573        want_ = nullptr;
3574    }
3575    static void SetUpTestCase(void);
3576    static void TearDownTestCase(void);
3577    void SetUp();
3578    void TearDown();
3579    std::shared_ptr<Want> want_;
3580};
3581
3582void WantByteArrayParamTest::SetUpTestCase(void)
3583{}
3584
3585void WantByteArrayParamTest::TearDownTestCase(void)
3586{}
3587
3588void WantByteArrayParamTest::SetUp(void)
3589{
3590    want_ = std::make_shared<Want>();
3591}
3592
3593void WantByteArrayParamTest::TearDown(void)
3594{}
3595
3596/**
3597 * @tc.number: AaFwk_Want_ByteArray_0100
3598 * @tc.name:  SetParam/GetByteArrayParam
3599 * @tc.desc:  Verify when parameter change.
3600 */
3601HWTEST_P(WantByteArrayParamTest, AaFwk_Want_ByteArray_0100, Function | MediumTest | Level1)
3602{
3603    std::string setKey = std::get<0>(GetParam());
3604    std::string getKey = std::get<1>(GetParam());
3605    std::vector<byte> setValue = std::get<2>(GetParam());
3606    std::vector<byte> defaultValue = std::get<3>(GetParam());
3607    std::vector<byte> result = std::get<4>(GetParam());
3608    want_->SetParam(setKey, setValue);
3609    EXPECT_EQ(result, want_->GetByteArrayParam(getKey));
3610}
3611
3612INSTANTIATE_TEST_SUITE_P(WantByteArrayParamTestCaseP, WantByteArrayParamTest,
3613    testing::Values(testByteArrayType("", "aa", {'*', 'D'}, {}, {}),
3614        testByteArrayType("", "", {'%', ')'}, {}, {'%', ')'}), testByteArrayType("1*中_aR", "aa", {'R', '.'}, {}, {}),
3615        testByteArrayType("1*中_aR", "1*中_aR", {'R', 'b'}, {}, {'R', 'b'})));
3616
3617/**
3618 * @tc.number: AaFwk_Want_ByteArray_0200
3619 * @tc.name:  SetParam/GetByteArrayParam
3620 * @tc.desc:  Verify when the value is byte array.
3621 */
3622HWTEST_F(WantByteArrayParamTest, AaFwk_Want_ByteArray_0200, Function | MediumTest | Level1)
3623{
3624    std::vector<byte> defaultValue;
3625    std::string getKey("aa");
3626    EXPECT_EQ(defaultValue, want_->GetByteArrayParam(getKey));
3627}
3628
3629/**
3630 * @tc.number: AaFwk_Want_ByteArray_0300
3631 * @tc.name:  SetParam/GetByteArrayParam
3632 * @tc.desc:  Verify when the value is byte array.
3633 */
3634HWTEST_F(WantByteArrayParamTest, AaFwk_Want_ByteArray_0300, Function | MediumTest | Level1)
3635{
3636    std::string emptyStr("gg");
3637    std::vector<byte> firstValue({'a', '2'});
3638    std::vector<byte> secondValue({'1', 'd'});
3639    std::vector<byte> thirdValue({'t', '3'});
3640    std::string keyStr("aa");
3641    want_->SetParam(emptyStr, firstValue);
3642    want_->SetParam(emptyStr, firstValue);
3643    want_->SetParam(emptyStr, secondValue);
3644    std::vector<byte> defaultValue;
3645    EXPECT_EQ(defaultValue, want_->GetByteArrayParam(keyStr));
3646    want_->SetParam(emptyStr, thirdValue);
3647    EXPECT_EQ(thirdValue, want_->GetByteArrayParam(emptyStr));
3648}
3649
3650/**
3651 * @tc.number: AaFwk_Want_ByteArray_0400
3652 * @tc.name:  SetParam/GetByteArrayParam
3653 * @tc.desc:  Verify when the value is byte array.
3654 */
3655HWTEST_F(WantByteArrayParamTest, AaFwk_Want_ByteArray_0400, Function | MediumTest | Level1)
3656{
3657    std::string firstKey("%1uH3");
3658    std::vector<byte> firstValue({'a', '2'});
3659    std::vector<byte> secondValue({'w', '$'});
3660    std::vector<byte> defaultValue;
3661    std::string secondKey("aa");
3662    want_->SetParam(firstKey, firstValue);
3663    want_->SetParam(firstKey, firstValue);
3664    want_->SetParam(firstKey, secondValue);
3665    EXPECT_EQ(secondValue, want_->GetByteArrayParam(firstKey));
3666    want_->SetParam(firstKey, firstValue);
3667    EXPECT_EQ(defaultValue, want_->GetByteArrayParam(secondKey));
3668}
3669
3670using testBoolType = std::tuple<std::string, std::string, bool, bool, bool>;
3671class WantBoolParamTest : public testing::TestWithParam<testBoolType> {
3672public:
3673    WantBoolParamTest()
3674    {
3675        want_ = nullptr;
3676    }
3677    ~WantBoolParamTest()
3678    {
3679        want_ = nullptr;
3680    }
3681    static void SetUpTestCase(void);
3682    static void TearDownTestCase(void);
3683    void SetUp();
3684    void TearDown();
3685    std::shared_ptr<Want> want_;
3686};
3687
3688void WantBoolParamTest::SetUpTestCase(void)
3689{}
3690
3691void WantBoolParamTest::TearDownTestCase(void)
3692{}
3693
3694void WantBoolParamTest::SetUp(void)
3695{
3696    want_ = std::make_shared<Want>();
3697}
3698
3699void WantBoolParamTest::TearDown(void)
3700{}
3701
3702/**
3703 * @tc.number: AaFwk_Want_BoolParam_0100
3704 * @tc.name: SetParam/GetBoolParam
3705 * @tc.desc: Verify when parameter change.
3706 */
3707HWTEST_P(WantBoolParamTest, AaFwk_Want_BoolParam_0100, Function | MediumTest | Level1)
3708{
3709    std::string setKey = std::get<0>(GetParam());
3710    std::string getKey = std::get<1>(GetParam());
3711    bool setValue = std::get<2>(GetParam());
3712    bool defaultValue = std::get<3>(GetParam());
3713    bool result = std::get<4>(GetParam());
3714    want_->SetParam(setKey, setValue);
3715    EXPECT_EQ(result, want_->GetBoolParam(getKey, defaultValue));
3716}
3717
3718INSTANTIATE_TEST_SUITE_P(WantBoolParamTestCaseP, WantBoolParamTest,
3719    testing::Values(testBoolType("b1", "aa", true, true, true), testBoolType("b1", "aa", true, false, false),
3720        testBoolType("b2", "b2", true, true, true), testBoolType("b3", "b3", true, false, true),
3721        testBoolType("123", "123", true, false, true), testBoolType("123", "aa", true, false, false),
3722        testBoolType("-~*&%¥", "-~*&%¥", true, false, true), testBoolType("-~*&%¥", "aa", true, false, false),
3723        testBoolType("中文", "中文", true, false, true), testBoolType("中文", "aa", true, false, false),
3724        testBoolType("_中文ddPEJKJ#(&*~#^%", "_中文ddPEJKJ#(&*~#^%", true, false, true),
3725        testBoolType("_中文ddPEJKJ#(&*~#^%", "123", true, false, false)));
3726
3727/**
3728 * @tc.number: AaFwk_Want_BoolParam_0200
3729 * @tc.name:   SetParam/GetBoolParam
3730 * @tc.desc: Verify when set twice and get twice.
3731 */
3732HWTEST_F(WantBoolParamTest, AaFwk_Want_BoolParam_0200, Function | MediumTest | Level1)
3733{
3734    std::string firstKey("_中文ddPEJKJ#(&*~#^%");
3735    std::string secondKey("key33");
3736    want_->SetParam(firstKey, true);
3737    want_->SetParam(secondKey, true);
3738    EXPECT_EQ(true, want_->GetBoolParam(firstKey, false));
3739    EXPECT_EQ(true, want_->GetBoolParam(secondKey, false));
3740}
3741
3742/**
3743 * @tc.number: AaFwk_Want_BoolParam_0300
3744 * @tc.name:   SetParam/GetBoolParam
3745 * @tc.desc: Verify when set 20 times, and get once.
3746 */
3747HWTEST_F(WantBoolParamTest, AaFwk_Want_BoolParam_0300, Function | MediumTest | Level1)
3748{
3749    std::string keyStr("_中文ddPEJKJ#(&*~#^%");
3750    for (int i = 0; i < 20; i++) {
3751        want_->SetParam(keyStr, true);
3752    }
3753    EXPECT_EQ(true, want_->GetBoolParam(keyStr, false));
3754}
3755
3756/**
3757 * @tc.number: AaFwk_Want_Want_0100
3758 * @tc.name:   Want() and Want(want)
3759 * @tc.desc: Verify Want()
3760 */
3761HWTEST_F(WantBaseTest, AaFwk_Want_Want_0100, Function | MediumTest | Level1)
3762{
3763    Want want;
3764
3765    EXPECT_EQ((uint)0, want.GetFlags());
3766    EXPECT_EQ(std::string(""), want.GetAction());
3767
3768    std::vector<std::string> vect = want.GetEntities();
3769    EXPECT_EQ((size_t)0, vect.size());
3770    EXPECT_EQ(std::string(""), want.GetType());
3771
3772    want.SetFlags(10);
3773    want.SetAction("system.Action.test");
3774    want.AddEntity("system.Entity.test");
3775    want.SetType("system.Type.test");
3776
3777    Want want2(want);
3778    EXPECT_EQ("system.Action.test", want2.GetAction());
3779    EXPECT_EQ(true, want2.HasEntity("system.Entity.test"));
3780    EXPECT_EQ("system.Type.test", want2.GetType());
3781}
3782
3783/**
3784 * @tc.number: AaFwk_Want_Entity_0100
3785 * @tc.name:    [AddEntity or RemoveEntity] & HasEntity &CountEntities
3786 * @tc.desc: Verify [AddEntity or RemoveEntity] & HasEntity &CountEntities
3787 */
3788HWTEST_F(WantBaseTest, AaFwk_Want_Entity_0100, Function | MediumTest | Level1)
3789{
3790    std::string entity1 = "entity.system.entity1";
3791
3792    want_->AddEntity(entity1);
3793
3794    EXPECT_EQ(true, want_->HasEntity(entity1));
3795    EXPECT_EQ(1, want_->CountEntities());
3796    want_->RemoveEntity(entity1);
3797    EXPECT_EQ(false, want_->HasEntity(entity1));
3798    EXPECT_EQ(0, want_->CountEntities());
3799    int length = want_->GetEntities().size();
3800    EXPECT_EQ(0, length);
3801
3802    std::string entity2 = "entity.system.entity2";
3803
3804    want_->AddEntity(entity1);
3805    want_->AddEntity(entity2);
3806
3807    EXPECT_EQ(true, want_->HasEntity(entity1));
3808    EXPECT_EQ(2, want_->CountEntities());
3809    EXPECT_EQ(true, want_->HasEntity(entity2));
3810    EXPECT_EQ(2, want_->CountEntities());
3811
3812    want_->RemoveEntity(entity1);
3813    want_->RemoveEntity(entity2);
3814    EXPECT_EQ(0, want_->CountEntities());
3815    int length2 = want_->GetEntities().size();
3816
3817    EXPECT_EQ(0, length2);
3818}
3819
3820/**
3821 * @tc.number: AaFwk_Want_HasParameter_0100
3822 * @tc.name:    SetParam and HasParameter
3823 * @tc.desc: Verify HasParameter()
3824 */
3825HWTEST_F(WantBaseTest, AaFwk_Want_HasParameter_0100, Function | MediumTest | Level1)
3826{
3827    std::vector<std::string> vector;
3828    std::string key = "system.want.test.key";
3829    std::string key2 = "system.want.test.key2";
3830
3831    vector.push_back("system.want.test.content");
3832    want_->SetParam(key, vector);
3833    EXPECT_EQ(true, want_->HasParameter(key));
3834
3835    want_->SetParam(key2, vector);
3836    EXPECT_EQ(true, want_->HasParameter(key2));
3837}
3838/**
3839 * @tc.number: AaFwk_Want_HasParameter_0200
3840 * @tc.name:    SetParam and HasParameter
3841 * @tc.desc: Verify HasParameter()
3842 */
3843HWTEST_F(WantBaseTest, AaFwk_Want_HasParameter_0200, Function | MediumTest | Level1)
3844{
3845    std::string key = std::to_string(Array::SIGNATURE) + ".#Intent;key=3{\"\\b\\\";end";
3846    std::vector<zchar> arrayValue = {'.', '=', ';'};
3847    std::shared_ptr<Want> p1 = std::make_shared<Want>();
3848    if (p1 == nullptr) {
3849        return;
3850    }
3851    p1->SetParam(key, arrayValue);
3852    Want *newWant = nullptr;
3853    newWant = Want::ParseUri(p1->ToUri());
3854    if (newWant == nullptr) {
3855        return;
3856    }
3857    std::shared_ptr<Want> p2(newWant);
3858    // want has default param which key is "moduleName"
3859    std::string moduleKey = "moduleName";
3860    std::string moduleValue = "wantTest";
3861    p1->SetParam(moduleKey, moduleValue);
3862    CompareWant(p1, p2);
3863}
3864/**
3865 * @tc.number: AaFwk_Want_ToString_0100
3866 * @tc.name:    ToString and FromString
3867 * @tc.desc: Verify FromString()
3868 */
3869HWTEST_F(WantBaseTest, AaFwk_Want_ToString_0100, Function | MediumTest | Level1)
3870{
3871    std::string deviceId = "deviceId";
3872    std::string bundleName = "bundleName";
3873    std::string abilityName ="abilityName";
3874    std::string uri = "url";
3875    std::string type = "type";
3876    unsigned int flags = 1;
3877    std::string action = "action";
3878    WantParams parameters;
3879    std::vector<std::string> entities = {"entity.system.entity1", "entity.system.entity2"};
3880
3881    std::string keyBool = "key_bool";
3882    bool valueBool = true;
3883    parameters.SetParam(keyBool, Boolean::Box(valueBool));
3884
3885    std::string keyStr = "key_string";
3886    std::string valueString = "123";
3887    parameters.SetParam(keyStr, String::Box(valueString));
3888
3889    std::string keyInt = "key_int";
3890    int valueInt = 111;
3891    parameters.SetParam(keyStr, Integer::Box(valueInt));
3892
3893    std::shared_ptr<Want> want1 = std::make_shared<Want>();
3894    if (want1 == nullptr) {
3895        return;
3896    }
3897    want1->SetElementName(deviceId, bundleName, abilityName);
3898    want1->SetUri(uri);
3899    want1->SetType(type);
3900    want1->SetFlags(flags);
3901    want1->SetAction(action);
3902    Uri urivalue("");
3903    want1->SetUriAndType(urivalue, keyInt);
3904    want1->FormatUri(urivalue);
3905    want1->FormatUri(keyInt);
3906    want1->FormatType(keyInt);
3907    want1->FormatUriAndType(urivalue, keyInt);
3908    want1->CloneOperation();
3909    for (auto entity : entities) {
3910        want1->AddEntity(entity);
3911    }
3912
3913    std::string jsonString = want1->ToString();
3914    Want *newWant = Want::FromString(jsonString);
3915    if (newWant == nullptr) {
3916        return;
3917    }
3918    std::shared_ptr<Want> want2(newWant);
3919
3920    CompareWant(want1, want2);
3921}
3922
3923/*
3924 * Feature: Array
3925 * Function: GetLength and GetType
3926 * SubFunction: NA
3927 * FunctionPoints: GetLength and GetType
3928 * EnvConditions: NA
3929 * CaseDescription: Verify GetLength and GetType method of Array.
3930 */
3931HWTEST_F(WantBaseTest, array_test_001, TestSize.Level1)
3932{
3933    sptr<Array> arrayObj = new Array(9, g_IID_IInteger);
3934    long size = 0;
3935    arrayObj->GetLength(size);
3936    EXPECT_EQ(size, 9);
3937    InterfaceID type;
3938    arrayObj->GetType(type);
3939    EXPECT_EQ(type, g_IID_IInteger);
3940}
3941
3942/*
3943 * Feature: Array
3944 * Function: Get and Set
3945 * SubFunction: NA
3946 * FunctionPoints: Get and Set
3947 * EnvConditions: NA
3948 * CaseDescription: Verify Get and Set method of Array.
3949 */
3950HWTEST_F(WantBaseTest, array_test_002, TestSize.Level1)
3951{
3952    sptr<Array> arrayObj = new Array(19, g_IID_IInteger);
3953    arrayObj->Set(0, Integer::Box(23));
3954    sptr<IInterface> valueObj;
3955    arrayObj->Get(0, valueObj);
3956    EXPECT_TRUE(valueObj != nullptr);
3957    EXPECT_EQ(Integer::Unbox(IInteger::Query(valueObj)), 23);
3958    arrayObj->Get(1, valueObj);
3959    EXPECT_TRUE(valueObj == nullptr);
3960}
3961
3962/*
3963 * Feature: Array
3964 * Function: ToString
3965 * SubFunction: NA
3966 * FunctionPoints: ToString
3967 * EnvConditions: NA
3968 * CaseDescription: Verify ToString method of Array.
3969 */
3970HWTEST_F(WantBaseTest, array_test_003, TestSize.Level1)
3971{
3972    sptr<Array> arrayObj = new Array(5, g_IID_IInteger);
3973    arrayObj->Set(0, Integer::Box(2));
3974    arrayObj->Set(1, Integer::Box(3));
3975    arrayObj->Set(2, Integer::Box(5));
3976    arrayObj->Set(3, Integer::Box(7));
3977    arrayObj->Set(4, Integer::Box(11));
3978    EXPECT_EQ(arrayObj->ToString(), std::string("I5{2,3,5,7,11}"));
3979}
3980
3981/*
3982 * Feature: Array
3983 * Function: Parse
3984 * SubFunction: NA
3985 * FunctionPoints: Parse
3986 * EnvConditions: NA
3987 * CaseDescription: Verify Parse method of Array.
3988 */
3989HWTEST_F(WantBaseTest, array_test_004, TestSize.Level1)
3990{
3991    sptr<IArray> arrayObj = Array::Parse("I5{2,3,5,7,11}");
3992    sptr<IInterface> valueObj;
3993    arrayObj->Get(0, valueObj);
3994    EXPECT_EQ(Integer::Unbox(IInteger::Query(valueObj)), 2);
3995    arrayObj->Get(1, valueObj);
3996    EXPECT_EQ(Integer::Unbox(IInteger::Query(valueObj)), 3);
3997    arrayObj->Get(2, valueObj);
3998    EXPECT_EQ(Integer::Unbox(IInteger::Query(valueObj)), 5);
3999    arrayObj->Get(3, valueObj);
4000    EXPECT_EQ(Integer::Unbox(IInteger::Query(valueObj)), 7);
4001    arrayObj->Get(4, valueObj);
4002    EXPECT_EQ(Integer::Unbox(IInteger::Query(valueObj)), 11);
4003}
4004
4005/*
4006 * Feature: Array
4007 * Function: Equals
4008 * SubFunction: NA
4009 * FunctionPoints: Equals
4010 * EnvConditions: NA
4011 * CaseDescription: Verify Equals method of Array.
4012 */
4013HWTEST_F(WantBaseTest, array_test_005, TestSize.Level1)
4014{
4015    sptr<IArray> arrayObj1 = Array::Parse("I5{2,3,5,7,11}");
4016    sptr<IArray> arrayObj2 = Array::Parse("I5{2,3,7,7,11}");
4017    sptr<IArray> arrayObj3 = Array::Parse("I5{2,3,5,7,11}");
4018    EXPECT_FALSE(Object::Equals(*(arrayObj1.GetRefPtr()), *(arrayObj2.GetRefPtr())));
4019    EXPECT_TRUE(Object::Equals(*(arrayObj1.GetRefPtr()), *(arrayObj3.GetRefPtr())));
4020}
4021
4022/**
4023 * @tc.number: DumpInfo_test_001
4024 * @tc.name: DumpInfo
4025 * @tc.desc: Test the want function DumpInfo.
4026 */
4027HWTEST_F(WantBaseTest, DumpInfo_test_001, TestSize.Level1)
4028{
4029    GTEST_LOG_(INFO) << "AaFwk_Want_DumpInfo_0100 start";
4030
4031    Want want;
4032    int level = 1;
4033    want.operation_.entities_.push_back("a");
4034    want.operation_.entities_.push_back("b");
4035    want.DumpInfo(level);
4036    EXPECT_EQ(true, want.operation_.GetEntities().size() == 2);
4037
4038    GTEST_LOG_(INFO) << "AaFwk_Want_DumpInfo_0100 end";
4039}
4040
4041/**
4042 * @tc.number: DupAllFd_test_001
4043 * @tc.name: DupAllFd
4044 * @tc.desc: Test the want function DupAllFd.
4045 */
4046HWTEST_F(WantBaseTest, DupAllFd_test_001, TestSize.Level1)
4047{
4048    GTEST_LOG_(INFO) << "DupAllFd_test_001 start";
4049
4050    Want want;
4051    want.operation_.entities_.push_back("a");
4052    want.operation_.entities_.push_back("b");
4053    want.DupAllFd();
4054    EXPECT_EQ(true, want.operation_.GetEntities().size() == 2);
4055    GTEST_LOG_(INFO) << "DupAllFd_test_001 end";
4056}
4057
4058/**
4059 * @tc.number: SetEntities_test_001
4060 * @tc.name: SetEntities
4061 * @tc.desc: Test the want function SetEntities.
4062 */
4063HWTEST_F(WantBaseTest, SetEntities_test_001, TestSize.Level1)
4064{
4065    GTEST_LOG_(INFO) << "SetEntities_test_001 start";
4066
4067    Want want;
4068    want.operation_.entities_.push_back("a");
4069    want.operation_.entities_.push_back("b");
4070    std::vector<std::string> entities;
4071    want.SetEntities(entities);
4072    auto ret = want.operation_.GetEntities().size();
4073    EXPECT_EQ(ret, 0);
4074    GTEST_LOG_(INFO) << "SetEntities_test_001 end";
4075}
4076
4077/**
4078 * @tc.number: SetElementModuleName_test_001
4079 * @tc.name: SetElementModuleName
4080 * @tc.desc: Test the want function SetElementModuleName.
4081 * @tc.require: issueI648W6
4082 */
4083HWTEST_F(WantBaseTest, SetElementModuleName_test_001, TestSize.Level1)
4084{
4085    GTEST_LOG_(INFO) << "SetElementModuleName_test_001 start";
4086
4087    std::shared_ptr<OHOS::AppExecFwk::ElementName> element = std::make_shared<OHOS::AppExecFwk::ElementName>();
4088    ASSERT_NE(nullptr, element);
4089    const char *moduleName = "12345";
4090    element->SetModuleName(moduleName);
4091
4092    GTEST_LOG_(INFO) << "SetElementModuleName_test_001 end";
4093}
4094
4095/**
4096 * @tc.number: ParseURI_test_001
4097 * @tc.name: ParseURI
4098 * @tc.desc: Test the want function ParseURI.
4099 * @tc.require: issueI648W6
4100 */
4101HWTEST_F(WantBaseTest, ParseURI_test_001, TestSize.Level1)
4102{
4103    GTEST_LOG_(INFO) << "ParseURI_test_001 start";
4104
4105    OHOS::AppExecFwk::ElementName element;
4106    std::string uri = "#Intent;action;end";
4107    bool result = element.ParseURI(uri);
4108    EXPECT_EQ(result, false);
4109    const char *deviceId = "12345";
4110    const char *bundleName = "NAME";
4111    const char *abilityName = "abilityName";
4112    const char *moduleName = "moduleName";
4113    ElementName *elementName = new (std::nothrow) ElementName();
4114    element.SetElementDeviceID(elementName, deviceId);
4115    element.SetElementBundleName(elementName, bundleName);
4116    element.SetElementAbilityName(elementName, abilityName);
4117    element.SetElementModuleName(elementName, moduleName);
4118    element.ClearElement(elementName);
4119    element.SetElementDeviceID(nullptr, deviceId);
4120    element.SetElementBundleName(nullptr, bundleName);
4121    element.SetElementAbilityName(nullptr, abilityName);
4122    element.SetElementModuleName(nullptr, moduleName);
4123    element.ClearElement(nullptr);
4124    GTEST_LOG_(INFO) << "ParseURI_test_001 end";
4125}
4126}  // namespace AAFwk
4127}  // namespace OHOS