1 /*
2 * Copyright (c) 2021 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 #include <cstring>
18
19 #include "ohos/aafwk/content/intent.h"
20
21 using namespace testing::ext;
22 using namespace OHOS::AAFwk;
23
24 using testBoolType = std::tuple<std::string, std::string, bool, bool, bool>;
25 class IntentParametersBoolTest : public testing::TestWithParam<testBoolType> {
26 public:
IntentParametersBoolTest()27 IntentParametersBoolTest() : intent_(nullptr)
28 {}
~IntentParametersBoolTest()29 ~IntentParametersBoolTest()
30 {
31 intent_ = nullptr;
32 }
33 static void SetUpTestCase(void);
34 static void TearDownTestCase(void);
35 void SetUp();
36 void TearDown();
37 Intent *intent_;
38 };
39
SetUpTestCase(void)40 void IntentParametersBoolTest::SetUpTestCase(void)
41 {}
42
TearDownTestCase(void)43 void IntentParametersBoolTest::TearDownTestCase(void)
44 {}
45
SetUp(void)46 void IntentParametersBoolTest::SetUp(void)
47 {
48 intent_ = new (std::nothrow) Intent();
49 }
50
TearDown(void)51 void IntentParametersBoolTest::TearDown(void)
52 {
53 delete intent_;
54 intent_ = nullptr;
55 }
56
57 /*
58 * Feature: Intent
59 * Function: SetBoolParam/GetBoolParam
60 * SubFunction: NA
61 * FunctionPoints: SetBoolParam/GetBoolParam
62 * EnvConditions: NA
63 * CaseDescription: Verify when parameter change.
64 */
65 HWTEST_P(IntentParametersBoolTest, AaFwk_Intent_Parameters_Bool, TestSize.Level1)
66 {
67 std::string setKey = std::get<0>(GetParam());
68 std::string getKey = std::get<1>(GetParam());
69 bool setValue = std::get<2>(GetParam());
70 bool defaultValue = std::get<3>(GetParam());
71 bool result = std::get<4>(GetParam());
72 intent_->SetBoolParam(setKey, setValue);
73 EXPECT_EQ(result, intent_->GetBoolParam(getKey, defaultValue));
74 }
75
76 INSTANTIATE_TEST_CASE_P(IntentParametersBoolTestCaseP, IntentParametersBoolTest,
77 testing::Values(testBoolType("", "aa", true, true, true), testBoolType("", "aa", true, false, false),
78 testBoolType("", "", true, true, true), testBoolType("", "", true, false, true),
79 testBoolType("123", "123", true, false, true), testBoolType("123", "aa", true, false, false),
80 testBoolType("-~*&%¥", "-~*&%¥", true, false, true), testBoolType("-~*&%¥", "aa", true, false, false),
81 testBoolType("中文", "中文", true, false, true), testBoolType("中文", "aa", true, false, false),
82 testBoolType("_中文ddPEJKJ#(&*~#^%", "_中文ddPEJKJ#(&*~#^%", true, false, true),
83 testBoolType("_中文ddPEJKJ#(&*~#^%", "123", true, false, false)));
84
85 /*
86 * Feature: Intent
87 * Function: SetBoolParam/GetBoolParam
88 * SubFunction: NA
89 * FunctionPoints: SetBoolParam/GetBoolParam
90 * EnvConditions: NA
91 * CaseDescription: Verify when set twice and get twice
92 */
93 HWTEST_F(IntentParametersBoolTest, AaFwk_Intent_Parameters_Bool_001, TestSize.Level1)
94 {
95 std::string firstKey("_中文ddPEJKJ#(&*~#^%");
96 std::string secondKey("key33");
97 intent_->SetBoolParam(firstKey, true);
98 intent_->SetBoolParam(secondKey, true);
99 EXPECT_EQ(true, intent_->GetBoolParam(firstKey, false));
100 EXPECT_EQ(true, intent_->GetBoolParam(secondKey, false));
101 }
102
103 /*
104 * Feature: Intent
105 * Function: SetBoolParam/GetBoolParam
106 * SubFunction: NA
107 * FunctionPoints: SetBoolParam/GetBoolParam
108 * EnvConditions: NA
109 * CaseDescription: Verify when set 20 times, and get once
110 */
111 HWTEST_F(IntentParametersBoolTest, AaFwk_Intent_Parameters_Bool_002, TestSize.Level1)
112 {
113 std::string keyStr("_中文ddPEJKJ#(&*~#^%");
114 for (int i = 0; i < 20; i++) {
115 intent_->SetBoolParam(keyStr, true);
116 }
117 EXPECT_EQ(true, intent_->GetBoolParam(keyStr, false));
118 }
119
120 using testBoolArrayType = std::tuple<std::string, std::string, std::vector<bool>, std::vector<bool>, std::vector<bool>>;
121 class IntentParametersBoolArrayTest : public testing::TestWithParam<testBoolArrayType> {
122 public:
IntentParametersBoolArrayTest()123 IntentParametersBoolArrayTest() : intent_(nullptr)
124 {}
~IntentParametersBoolArrayTest()125 ~IntentParametersBoolArrayTest()
126 {
127 intent_ = nullptr;
128 }
129 static void SetUpTestCase(void);
130 static void TearDownTestCase(void);
131 void SetUp();
132 void TearDown();
133 Intent *intent_;
134 };
135
SetUpTestCase(void)136 void IntentParametersBoolArrayTest::SetUpTestCase(void)
137 {}
138
TearDownTestCase(void)139 void IntentParametersBoolArrayTest::TearDownTestCase(void)
140 {}
141
SetUp(void)142 void IntentParametersBoolArrayTest::SetUp(void)
143 {
144 intent_ = new (std::nothrow) Intent();
145 }
146
TearDown(void)147 void IntentParametersBoolArrayTest::TearDown(void)
148 {
149 delete intent_;
150 intent_ = nullptr;
151 }
152
153 /*
154 * Feature: Intent
155 * Function: SetBoolArrayParam/GetBoolArrayParam
156 * SubFunction: NA
157 * FunctionPoints: SetBoolArrayParam/GetBoolArrayParam
158 * EnvConditions: NA
159 * CaseDescription: Verify when parameter change.
160 */
161 HWTEST_P(IntentParametersBoolArrayTest, AaFwk_Intent_Parameters_BoolArray, TestSize.Level1)
162 {
163 std::string setKey = std::get<0>(GetParam());
164 std::string getKey = std::get<1>(GetParam());
165 std::vector<bool> setValue = std::get<2>(GetParam());
166 std::vector<bool> result = std::get<4>(GetParam());
167 intent_->SetBoolArrayParam(setKey, setValue);
168 EXPECT_EQ(result, intent_->GetBoolArrayParam(getKey));
169 }
170
171 INSTANTIATE_TEST_CASE_P(IntentParametersBoolArrayTestCaseP, IntentParametersBoolArrayTest,
172 testing::Values(testBoolArrayType("", "aa", {true, false}, {}, {}),
173 testBoolArrayType("", "", {true, false}, {}, {true, false}),
174 testBoolArrayType("1*中_aR", "aa", {true, false}, {}, {}),
175 testBoolArrayType("1*中_aR", "1*中_aR", {false, true}, {}, {false, true})));
176
177 /*
178 * Feature: Intent
179 * Function: SetBoolArrayParam/GetBoolArrayParam
180 * SubFunction: NA
181 * FunctionPoints: SetBoolArrayParam/GetBoolArrayParam
182 * EnvConditions: NA
183 * CaseDescription: Verify when the value is bool array
184 */
185 HWTEST_F(IntentParametersBoolArrayTest, AaFwk_Intent_Parameters_Bool_Array_001, TestSize.Level1)
186 {
187 std::vector<bool> defaultValue;
188 std::string getKey("aa");
189 EXPECT_EQ(defaultValue, intent_->GetBoolArrayParam(getKey));
190 }
191
192 /*
193 * Feature: Intent
194 * Function: SetBoolArrayParam/GetBoolArrayParam
195 * SubFunction: NA
196 * FunctionPoints: SetBoolArrayParam/GetBoolArrayParam
197 * EnvConditions: NA
198 * CaseDescription: Verify when the value is bool array
199 */
200 HWTEST_F(IntentParametersBoolArrayTest, AaFwk_Intent_Parameters_Bool_Array_002, TestSize.Level1)
201 {
202 std::string emptyStr("");
203 std::vector<bool> firstValue({true, false});
204 std::vector<bool> secondValue({true, true});
205 std::vector<bool> firstDefaultValue({false, true});
206 std::string keyStr("aa");
207 intent_->SetBoolArrayParam(emptyStr, firstValue);
208 intent_->SetBoolArrayParam(emptyStr, firstValue);
209 intent_->SetBoolArrayParam(emptyStr, secondValue);
210 std::vector<bool> defaultValue;
211 EXPECT_EQ(defaultValue, intent_->GetBoolArrayParam(keyStr));
212 intent_->SetBoolArrayParam(emptyStr, firstDefaultValue);
213 EXPECT_EQ(firstDefaultValue, intent_->GetBoolArrayParam(emptyStr));
214 }
215
216 /*
217 * Feature: Intent
218 * Function: SetBoolArrayParam/GetBoolArrayParam
219 * SubFunction: NA
220 * FunctionPoints: SetBoolArrayParam/GetBoolArrayParam
221 * EnvConditions: NA
222 * CaseDescription: Verify when the value is bool array
223 */
224 HWTEST_F(IntentParametersBoolArrayTest, AaFwk_Intent_Parameters_Bool_Array_003, TestSize.Level1)
225 {
226 std::string firstKey("%1uH3");
227 std::vector<bool> firstValue({true, false});
228 std::vector<bool> secondValue({true, true});
229 std::string secondKey("aa");
230 intent_->SetBoolArrayParam(firstKey, firstValue);
231 intent_->SetBoolArrayParam(firstKey, firstValue);
232 intent_->SetBoolArrayParam(firstKey, secondValue);
233 EXPECT_EQ(secondValue, intent_->GetBoolArrayParam(firstKey));
234 intent_->SetBoolArrayParam(firstKey, firstValue);
235 std::vector<bool> defaultValue;
236 EXPECT_EQ(defaultValue, intent_->GetBoolArrayParam(secondKey));
237 }
238
239 using testByteType = std::tuple<std::string, std::string, byte, byte, byte>;
240 class IntentParametersByteTest : public testing::TestWithParam<testByteType> {
241 public:
IntentParametersByteTest()242 IntentParametersByteTest() : intent_(nullptr)
243 {}
~IntentParametersByteTest()244 ~IntentParametersByteTest()
245 {
246 intent_ = nullptr;
247 }
248 static void SetUpTestCase(void);
249 static void TearDownTestCase(void);
250 void SetUp();
251 void TearDown();
252 Intent *intent_;
253 };
254
SetUpTestCase(void)255 void IntentParametersByteTest::SetUpTestCase(void)
256 {}
257
TearDownTestCase(void)258 void IntentParametersByteTest::TearDownTestCase(void)
259 {}
260
SetUp(void)261 void IntentParametersByteTest::SetUp(void)
262 {
263 intent_ = new (std::nothrow) Intent();
264 }
265
TearDown(void)266 void IntentParametersByteTest::TearDown(void)
267 {
268 delete intent_;
269 intent_ = nullptr;
270 }
271
272 /*
273 * Feature: Intent
274 * Function: SetByteParam/GetByteParam
275 * SubFunction: NA
276 * FunctionPoints: SetByteParam/GetByteParam
277 * EnvConditions: NA
278 * CaseDescription: Verify when parameter change.
279 */
280 HWTEST_P(IntentParametersByteTest, AaFwk_Intent_Parameters_Byte, TestSize.Level1)
281 {
282 std::string setKey = std::get<0>(GetParam());
283 std::string getKey = std::get<1>(GetParam());
284 byte setValue = std::get<2>(GetParam());
285 byte defaultValue = std::get<3>(GetParam());
286 byte result = std::get<4>(GetParam());
287 intent_->SetByteParam(setKey, setValue);
288 EXPECT_EQ(result, intent_->GetByteParam(getKey, defaultValue));
289 }
290
291 INSTANTIATE_TEST_CASE_P(IntentParametersByteTestCaseP, IntentParametersByteTest,
292 testing::Values(testByteType("", "aa", '#', 'U', 'U'), testByteType("", "", 'N', 'K', 'N'),
293 testByteType("1*中_aR", "aa", 'a', '%', '%'), testByteType("1*中_aR", "1*中_aR", 'a', 'z', 'a')));
294
295 /*
296 * Feature: Intent
297 * Function: SetByteParam/GetByteParam
298 * SubFunction: NA
299 * FunctionPoints: SetByteParam/GetByteParam
300 * EnvConditions: NA
301 * CaseDescription: Verify when the value is byte
302 */
303 HWTEST_F(IntentParametersByteTest, AaFwk_Intent_Parameters_Byte_001, TestSize.Level1)
304 {
305 byte defaultValue = '%';
306 std::string getKey("aa");
307 EXPECT_EQ(defaultValue, intent_->GetByteParam(getKey, defaultValue));
308 }
309
310 /*
311 * Feature: Intent
312 * Function: SetByteParam/GetByteParam
313 * SubFunction: NA
314 * FunctionPoints: SetByteParam/GetByteParam
315 * EnvConditions: NA
316 * CaseDescription: Verify when the value is byte
317 */
318 HWTEST_F(IntentParametersByteTest, AaFwk_Intent_Parameters_Byte_002, TestSize.Level1)
319 {
320 std::string emptyStr("");
321 byte firstValue = 'a';
322 byte secondValue = '1';
323 byte thirdValue = '*';
324 byte firstDefaultValue = '2';
325 byte secondDefaultValue = '!';
326 std::string keyStr("aa");
327 intent_->SetByteParam(emptyStr, firstValue);
328 intent_->SetByteParam(emptyStr, firstValue);
329 intent_->SetByteParam(emptyStr, secondValue);
330 EXPECT_EQ(firstDefaultValue, intent_->GetByteParam(keyStr, firstDefaultValue));
331 intent_->SetByteParam(emptyStr, thirdValue);
332 EXPECT_EQ(thirdValue, intent_->GetByteParam(emptyStr, secondDefaultValue));
333 }
334
335 /*
336 * Feature: Intent
337 * Function: SetByteParam/GetByteParam
338 * SubFunction: NA
339 * FunctionPoints: SetByteParam/GetByteParam
340 * EnvConditions: NA
341 * CaseDescription: Verify when the value is byte
342 */
343 HWTEST_F(IntentParametersByteTest, AaFwk_Intent_Parameters_Byte_003, TestSize.Level1)
344 {
345 std::string firstKey("%1uH3");
346 byte firstValue = 'a';
347 byte secondValue = '_';
348 byte firstDefaultValue = 'W';
349 byte secondDefaultValue = '%';
350 std::string secondKey("aa");
351 intent_->SetByteParam(firstKey, firstValue);
352 intent_->SetByteParam(firstKey, firstValue);
353 intent_->SetByteParam(firstKey, secondValue);
354 EXPECT_EQ(secondValue, intent_->GetByteParam(firstKey, firstDefaultValue));
355 intent_->SetByteParam(firstKey, firstValue);
356 EXPECT_EQ(secondDefaultValue, intent_->GetByteParam(secondKey, secondDefaultValue));
357 }
358
359 using testByteArrayType = std::tuple<std::string, std::string, std::vector<byte>, std::vector<byte>, std::vector<byte>>;
360 class IntentParametersByteArrayTest : public testing::TestWithParam<testByteArrayType> {
361 public:
IntentParametersByteArrayTest()362 IntentParametersByteArrayTest() : intent_(nullptr)
363 {}
~IntentParametersByteArrayTest()364 ~IntentParametersByteArrayTest()
365 {
366 intent_ = nullptr;
367 }
368 static void SetUpTestCase(void);
369 static void TearDownTestCase(void);
370 void SetUp();
371 void TearDown();
372 Intent *intent_;
373 };
374
SetUpTestCase(void)375 void IntentParametersByteArrayTest::SetUpTestCase(void)
376 {}
377
TearDownTestCase(void)378 void IntentParametersByteArrayTest::TearDownTestCase(void)
379 {}
380
SetUp(void)381 void IntentParametersByteArrayTest::SetUp(void)
382 {
383 intent_ = new (std::nothrow) Intent();
384 }
385
TearDown(void)386 void IntentParametersByteArrayTest::TearDown(void)
387 {
388 delete intent_;
389 intent_ = nullptr;
390 }
391
392 /*
393 * Feature: Intent
394 * Function: SetByteArrayParam/GetByteArrayParam
395 * SubFunction: NA
396 * FunctionPoints: SetByteArrayParam/GetByteArrayParam
397 * EnvConditions: NA
398 * CaseDescription: Verify when parameter change.
399 */
400 HWTEST_P(IntentParametersByteArrayTest, AaFwk_Intent_Parameters_ByteArray, TestSize.Level1)
401 {
402 std::string setKey = std::get<0>(GetParam());
403 std::string getKey = std::get<1>(GetParam());
404 std::vector<byte> setValue = std::get<2>(GetParam());
405 std::vector<byte> result = std::get<4>(GetParam());
406 intent_->SetByteArrayParam(setKey, setValue);
407 EXPECT_EQ(result, intent_->GetByteArrayParam(getKey));
408 }
409
410 INSTANTIATE_TEST_CASE_P(IntentParametersByteArrayTestCaseP, IntentParametersByteArrayTest,
411 testing::Values(testByteArrayType("", "aa", {'*', 'D'}, {}, {}),
412 testByteArrayType("", "", {'%', ')'}, {}, {'%', ')'}), testByteArrayType("1*中_aR", "aa", {'R', '.'}, {}, {}),
413 testByteArrayType("1*中_aR", "1*中_aR", {'R', 'b'}, {}, {'R', 'b'})));
414
415 /*
416 * Feature: Intent
417 * Function: GetByteArrayParam
418 * SubFunction: NA
419 * FunctionPoints: GetByteArrayParam
420 * EnvConditions: NA
421 * CaseDescription: Verify when the value is byte array
422 */
423 HWTEST_F(IntentParametersByteArrayTest, AaFwk_Intent_Parameters_Byte_Array_001, TestSize.Level1)
424 {
425 std::vector<byte> defaultValue;
426 std::string getKey("aa");
427 EXPECT_EQ(defaultValue, intent_->GetByteArrayParam(getKey));
428 }
429
430 /*
431 * Feature: Intent
432 * Function: SetByteArrayParam/GetByteArrayParam
433 * SubFunction: NA
434 * FunctionPoints: SetByteArrayParam/GetByteArrayParam
435 * EnvConditions: NA
436 * CaseDescription: Verify when the value is byte array
437 */
438 HWTEST_F(IntentParametersByteArrayTest, AaFwk_Intent_Parameters_Byte_Array_002, TestSize.Level1)
439 {
440 std::string emptyStr("");
441 std::vector<byte> firstValue({'a', '2'});
442 std::vector<byte> secondValue({'1', 'd'});
443 std::vector<byte> thirdValue({'t', '3'});
444 std::string keyStr("aa");
445 intent_->SetByteArrayParam(emptyStr, firstValue);
446 intent_->SetByteArrayParam(emptyStr, firstValue);
447 intent_->SetByteArrayParam(emptyStr, secondValue);
448 std::vector<byte> defaultValue;
449 EXPECT_EQ(defaultValue, intent_->GetByteArrayParam(keyStr));
450 intent_->SetByteArrayParam(emptyStr, thirdValue);
451 EXPECT_EQ(thirdValue, intent_->GetByteArrayParam(emptyStr));
452 }
453
454 /*
455 * Feature: Intent
456 * Function: SetByteArrayParam/GetByteArrayParam
457 * SubFunction: NA
458 * FunctionPoints: SetByteArrayParam/GetByteArrayParam
459 * EnvConditions: NA
460 * CaseDescription: Verify when the value is byte array
461 */
462 HWTEST_F(IntentParametersByteArrayTest, AaFwk_Intent_Parameters_Byte_Array_003, TestSize.Level1)
463 {
464 std::string firstKey("%1uH3");
465 std::vector<byte> firstValue({'a', '2'});
466 std::vector<byte> secondValue({'w', '$'});
467 std::vector<byte> defaultValue;
468 std::string secondKey("aa");
469 intent_->SetByteArrayParam(firstKey, firstValue);
470 intent_->SetByteArrayParam(firstKey, firstValue);
471 intent_->SetByteArrayParam(firstKey, secondValue);
472 EXPECT_EQ(secondValue, intent_->GetByteArrayParam(firstKey));
473 intent_->SetByteArrayParam(firstKey, firstValue);
474 EXPECT_EQ(defaultValue, intent_->GetByteArrayParam(secondKey));
475 }
476
477 using testCharType = std::tuple<std::string, std::string, zchar, zchar, zchar>;
478 class IntentParametersCharTest : public testing::TestWithParam<testCharType> {
479 public:
IntentParametersCharTest()480 IntentParametersCharTest() : intent_(nullptr)
481 {}
~IntentParametersCharTest()482 ~IntentParametersCharTest()
483 {
484 intent_ = nullptr;
485 }
486 static void SetUpTestCase(void);
487 static void TearDownTestCase(void);
488 void SetUp();
489 void TearDown();
490 Intent *intent_;
491 };
492
SetUpTestCase(void)493 void IntentParametersCharTest::SetUpTestCase(void)
494 {}
495
TearDownTestCase(void)496 void IntentParametersCharTest::TearDownTestCase(void)
497 {}
498
SetUp(void)499 void IntentParametersCharTest::SetUp(void)
500 {
501 intent_ = new (std::nothrow) Intent();
502 }
503
TearDown(void)504 void IntentParametersCharTest::TearDown(void)
505 {
506 delete intent_;
507 intent_ = nullptr;
508 }
509
510 /*
511 * Feature: Intent
512 * Function: SetCharParam/GetCharParam
513 * SubFunction: NA
514 * FunctionPoints: SetCharParam/GetCharParam
515 * EnvConditions: NA
516 * CaseDescription: Verify when parameter change.
517 */
518 HWTEST_P(IntentParametersCharTest, AaFwk_Intent_Parameters_Char, TestSize.Level1)
519 {
520 std::string setKey = std::get<0>(GetParam());
521 std::string getKey = std::get<1>(GetParam());
522 zchar setValue = std::get<2>(GetParam());
523 zchar defaultValue = std::get<3>(GetParam());
524 zchar result = std::get<4>(GetParam());
525 intent_->SetCharParam(setKey, setValue);
526 EXPECT_EQ(result, intent_->GetCharParam(getKey, defaultValue));
527 }
528
529 INSTANTIATE_TEST_CASE_P(IntentParametersCharTestCaseP, IntentParametersCharTest,
530 testing::Values(testCharType("", "aa", U'#', U'中', U'中'), testCharType("", "", U'中', U'K', U'中'),
531 testCharType("1*中_aR", "aa", U'a', U'中', U'中'), testCharType("1*中_aR", "1*中_aR", U'中', U'z', U'中')));
532
533 /*
534 * Feature: Intent
535 * Function: SetCharParam/GetCharParam
536 * SubFunction: NA
537 * FunctionPoints: SetCharParam/GetCharParam
538 * EnvConditions: NA
539 * CaseDescription: Verify when the value is char
540 */
541 HWTEST_F(IntentParametersCharTest, AaFwk_Intent_Parameters_Char_001, TestSize.Level1)
542 {
543 zchar defaultValue = U'文';
544 std::string getKey("aa");
545 EXPECT_EQ(defaultValue, intent_->GetCharParam(getKey, defaultValue));
546 }
547
548 /*
549 * Feature: Intent
550 * Function: SetCharParam/GetCharParam
551 * SubFunction: NA
552 * FunctionPoints: SetCharParam/GetCharParam
553 * EnvConditions: NA
554 * CaseDescription: Verify when the value is char
555 */
556 HWTEST_F(IntentParametersCharTest, AaFwk_Intent_Parameters_Char_002, TestSize.Level1)
557 {
558 std::string emptyStr("");
559 zchar firstValue = U'中';
560 zchar secondValue = U'文';
561 zchar thirdValue = U'字';
562 zchar firstDefaultValue = U'符';
563 zchar secondDefaultValue = U'集';
564 std::string keyStr("aa");
565 intent_->SetCharParam(emptyStr, firstValue);
566 intent_->SetCharParam(emptyStr, firstValue);
567 intent_->SetCharParam(emptyStr, secondValue);
568 EXPECT_EQ(firstDefaultValue, intent_->GetCharParam(keyStr, firstDefaultValue));
569 intent_->SetCharParam(emptyStr, thirdValue);
570 EXPECT_EQ(thirdValue, intent_->GetCharParam(emptyStr, secondDefaultValue));
571 }
572
573 /*
574 * Feature: Intent
575 * Function: SetCharParam/GetCharParam
576 * SubFunction: NA
577 * FunctionPoints: SetCharParam/GetCharParam
578 * EnvConditions: NA
579 * CaseDescription: Verify when the value is char
580 */
581 HWTEST_F(IntentParametersCharTest, AaFwk_Intent_Parameters_Char_003, TestSize.Level1)
582 {
583 std::string firstKey("%1uH3");
584 zchar firstValue = U'中';
585 zchar secondValue = U'文';
586 zchar firstDefaultValue = U'字';
587 zchar secondDefaultValue = U'符';
588 std::string secondKey("aa");
589 intent_->SetCharParam(firstKey, firstValue);
590 intent_->SetCharParam(firstKey, firstValue);
591 intent_->SetCharParam(firstKey, secondValue);
592 EXPECT_EQ(secondValue, intent_->GetCharParam(firstKey, firstDefaultValue));
593 intent_->SetCharParam(firstKey, firstValue);
594 EXPECT_EQ(secondDefaultValue, intent_->GetCharParam(secondKey, secondDefaultValue));
595 }
596
597 using testCharArrayType =
598 std::tuple<std::string, std::string, std::vector<zchar>, std::vector<zchar>, std::vector<zchar>>;
599 class IntentParametersCharArrayTest : public testing::TestWithParam<testCharArrayType> {
600 public:
IntentParametersCharArrayTest()601 IntentParametersCharArrayTest() : intent_(nullptr)
602 {}
~IntentParametersCharArrayTest()603 ~IntentParametersCharArrayTest()
604 {
605 intent_ = nullptr;
606 }
607 static void SetUpTestCase(void);
608 static void TearDownTestCase(void);
609 void SetUp();
610 void TearDown();
611 Intent *intent_;
612 };
613
SetUpTestCase(void)614 void IntentParametersCharArrayTest::SetUpTestCase(void)
615 {}
616
TearDownTestCase(void)617 void IntentParametersCharArrayTest::TearDownTestCase(void)
618 {}
619
SetUp(void)620 void IntentParametersCharArrayTest::SetUp(void)
621 {
622 intent_ = new (std::nothrow) Intent();
623 }
624
TearDown(void)625 void IntentParametersCharArrayTest::TearDown(void)
626 {
627 delete intent_;
628 intent_ = nullptr;
629 }
630
631 /*
632 * Feature: Intent
633 * Function: SetCharArrayParam/GetCharArrayParam
634 * SubFunction: NA
635 * FunctionPoints: SetCharArrayParam/GetCharArrayParam
636 * EnvConditions: NA
637 * CaseDescription: Verify when parameter change.
638 */
639 HWTEST_P(IntentParametersCharArrayTest, AaFwk_Intent_Parameters_CharArray, TestSize.Level1)
640 {
641 std::string setKey = std::get<0>(GetParam());
642 std::string getKey = std::get<1>(GetParam());
643 std::vector<zchar> setValue = std::get<2>(GetParam());
644 std::vector<zchar> result = std::get<4>(GetParam());
645 intent_->SetCharArrayParam(setKey, setValue);
646 EXPECT_EQ(result, intent_->GetCharArrayParam(getKey));
647 }
648
649 INSTANTIATE_TEST_CASE_P(IntentParametersCharArrayTestCaseP, IntentParametersCharArrayTest,
650 testing::Values(testCharArrayType("", "aa", {U'中', U'文'}, {}, {}),
651 testCharArrayType("", "", {U'中', U'文'}, {}, {U'中', U'文'}),
652 testCharArrayType("1*中_aR", "aa", {U'中', U'文'}, {}, {}),
653 testCharArrayType("1*中_aR", "1*中_aR", {U'中', U'文'}, {}, {U'中', U'文'})));
654
655 /*
656 * Feature: Intent
657 * Function: GetCharArrayParam
658 * SubFunction: NA
659 * FunctionPoints: GetCharArrayParam
660 * EnvConditions: NA
661 * CaseDescription: Verify when the value is char array
662 */
663 HWTEST_F(IntentParametersCharArrayTest, AaFwk_Intent_Parameters_Char_Array_001, TestSize.Level1)
664 {
665 std::vector<zchar> defaultValue;
666 std::string getKey("aa");
667 EXPECT_EQ(defaultValue, intent_->GetCharArrayParam(getKey));
668 }
669
670 /*
671 * Feature: Intent
672 * Function: SetCharArrayParam/GetCharArrayParam
673 * SubFunction: NA
674 * FunctionPoints: SetCharArrayParam/GetCharArrayParam
675 * EnvConditions: NA
676 * CaseDescription: Verify when the value is char array
677 */
678 HWTEST_F(IntentParametersCharArrayTest, AaFwk_Intent_Parameters_Char_Array_002, TestSize.Level1)
679 {
680 std::string emptyStr("");
681 std::vector<zchar> firstValue({U'中', U'文'});
682 std::vector<zchar> secondValue({U'字', U'符'});
683 std::vector<zchar> thirdValue({U'集', U'英'});
684 std::string keyStr("aa");
685 intent_->SetCharArrayParam(emptyStr, firstValue);
686 intent_->SetCharArrayParam(emptyStr, firstValue);
687 intent_->SetCharArrayParam(emptyStr, secondValue);
688 std::vector<zchar> defaultValue;
689 EXPECT_EQ(defaultValue, intent_->GetCharArrayParam(keyStr));
690 intent_->SetCharArrayParam(emptyStr, thirdValue);
691 EXPECT_EQ(thirdValue, intent_->GetCharArrayParam(emptyStr));
692 }
693
694 /*
695 * Feature: Intent
696 * Function: SetCharArrayParam/GetCharArrayParam
697 * SubFunction: NA
698 * FunctionPoints: SetCharArrayParam/GetCharArrayParam
699 * EnvConditions: NA
700 * CaseDescription: Verify when the value is char array
701 */
702 HWTEST_F(IntentParametersCharArrayTest, AaFwk_Intent_Parameters_Char_Array_003, TestSize.Level1)
703 {
704 std::string firstKey("%1uH3");
705 std::vector<zchar> firstValue({U'中', U'文'});
706 std::vector<zchar> secondValue({U'字', U'符'});
707 std::vector<zchar> defaultValue;
708 std::string secondKey("aa");
709 intent_->SetCharArrayParam(firstKey, firstValue);
710 intent_->SetCharArrayParam(firstKey, firstValue);
711 intent_->SetCharArrayParam(firstKey, secondValue);
712 EXPECT_EQ(secondValue, intent_->GetCharArrayParam(firstKey));
713 intent_->SetCharArrayParam(firstKey, firstValue);
714 EXPECT_EQ(defaultValue, intent_->GetCharArrayParam(secondKey));
715 }
716
717 using testShortType = std::tuple<std::string, std::string, short, short, short>;
718 class IntentParametersShortTest : public testing::TestWithParam<testShortType> {
719 public:
IntentParametersShortTest()720 IntentParametersShortTest() : intent_(nullptr)
721 {}
~IntentParametersShortTest()722 ~IntentParametersShortTest()
723 {
724 intent_ = nullptr;
725 }
726 static void SetUpTestCase(void);
727 static void TearDownTestCase(void);
728 void SetUp();
729 void TearDown();
730 Intent *intent_;
731 };
732
SetUpTestCase(void)733 void IntentParametersShortTest::SetUpTestCase(void)
734 {}
735
TearDownTestCase(void)736 void IntentParametersShortTest::TearDownTestCase(void)
737 {}
738
SetUp(void)739 void IntentParametersShortTest::SetUp(void)
740 {
741 intent_ = new (std::nothrow) Intent();
742 }
743
TearDown(void)744 void IntentParametersShortTest::TearDown(void)
745 {
746 delete intent_;
747 intent_ = nullptr;
748 }
749
750 /*
751 * Feature: Intent
752 * Function: SetShortParam/GetShortParam
753 * SubFunction: NA
754 * FunctionPoints: SetShortParam/GetShortParam
755 * EnvConditions: NA
756 * CaseDescription: Verify when parameter change.
757 */
758 HWTEST_P(IntentParametersShortTest, AaFwk_Intent_Parameters_Short, TestSize.Level1)
759 {
760 std::string setKey = std::get<0>(GetParam());
761 std::string getKey = std::get<1>(GetParam());
762 short setValue = std::get<2>(GetParam());
763 short defaultValue = std::get<3>(GetParam());
764 short result = std::get<4>(GetParam());
765 intent_->SetShortParam(setKey, setValue);
766 EXPECT_EQ(result, intent_->GetShortParam(getKey, defaultValue));
767 }
768
769 INSTANTIATE_TEST_CASE_P(IntentParametersShortTestCaseP, IntentParametersShortTest,
770 testing::Values(testShortType("", "aa", -1, 100, 100), testShortType("", "", -9, -41, -9),
771 testShortType("1*中_aR", "aa", 50, 5, 5), testShortType("1*中_aR", "1*中_aR", -5000, 5000, -5000)));
772
773 /*
774 * Feature: Intent
775 * Function: GetShortParam
776 * SubFunction: NA
777 * FunctionPoints: GetShortParam
778 * EnvConditions: NA
779 * CaseDescription: Verify when the value is short
780 */
781 HWTEST_F(IntentParametersShortTest, AaFwk_Intent_Parameters_Short_001, TestSize.Level1)
782 {
783 short defaultValue = 200;
784 std::string getKey("aa");
785 EXPECT_EQ(defaultValue, intent_->GetShortParam(getKey, defaultValue));
786 }
787
788 /*
789 * Feature: Intent
790 * Function: SetShortParam/GetShortParam
791 * SubFunction: NA
792 * FunctionPoints: SetShortParam/GetShortParam
793 * EnvConditions: NA
794 * CaseDescription: Verify when the value is short
795 */
796 HWTEST_F(IntentParametersShortTest, AaFwk_Intent_Parameters_Short_002, TestSize.Level1)
797 {
798 std::string emptyStr("");
799 short firstValue = 1;
800 short secondValue = 2;
801 short thirdValue = 4;
802 short firstDefaultValue = 3;
803 short secondDefaultValue = 5;
804 std::string keyStr("aa");
805 intent_->SetShortParam(emptyStr, firstValue);
806 intent_->SetShortParam(emptyStr, firstValue);
807 intent_->SetShortParam(emptyStr, secondValue);
808 EXPECT_EQ(firstDefaultValue, intent_->GetShortParam(keyStr, firstDefaultValue));
809 intent_->SetShortParam(emptyStr, thirdValue);
810 EXPECT_EQ(thirdValue, intent_->GetShortParam(emptyStr, secondDefaultValue));
811 }
812
813 /*
814 * Feature: Intent
815 * Function: SetShortParam/GetShortParam
816 * SubFunction: NA
817 * FunctionPoints: SetShortParam/GetShortParam
818 * EnvConditions: NA
819 * CaseDescription: Verify when the value is short
820 */
821 HWTEST_F(IntentParametersShortTest, AaFwk_Intent_Parameters_Short_003, TestSize.Level1)
822 {
823 std::string firstKey("%1uH3");
824 short firstValue = -1;
825 short secondValue = 0;
826 short thirdValue = 4;
827 short firstDefaultValue = 9;
828 short secondDefaultValue = -10;
829 std::string secondKey("aa");
830 intent_->SetShortParam(firstKey, firstValue);
831 intent_->SetShortParam(firstKey, firstValue);
832 intent_->SetShortParam(firstKey, secondValue);
833 EXPECT_EQ(secondValue, intent_->GetShortParam(firstKey, firstDefaultValue));
834 intent_->SetShortParam(firstKey, thirdValue);
835 EXPECT_EQ(secondDefaultValue, intent_->GetShortParam(secondKey, secondDefaultValue));
836 }
837
838 using testShortArrayType =
839 std::tuple<std::string, std::string, std::vector<short>, std::vector<short>, std::vector<short>>;
840 class IntentParametersShortArrayTest : public testing::TestWithParam<testShortArrayType> {
841 public:
IntentParametersShortArrayTest()842 IntentParametersShortArrayTest() : intent_(nullptr)
843 {}
~IntentParametersShortArrayTest()844 ~IntentParametersShortArrayTest()
845 {
846 intent_ = nullptr;
847 }
848 static void SetUpTestCase(void);
849 static void TearDownTestCase(void);
850 void SetUp();
851 void TearDown();
852 Intent *intent_;
853 };
854
SetUpTestCase(void)855 void IntentParametersShortArrayTest::SetUpTestCase(void)
856 {}
857
TearDownTestCase(void)858 void IntentParametersShortArrayTest::TearDownTestCase(void)
859 {}
860
SetUp(void)861 void IntentParametersShortArrayTest::SetUp(void)
862 {
863 intent_ = new (std::nothrow) Intent();
864 }
865
TearDown(void)866 void IntentParametersShortArrayTest::TearDown(void)
867 {
868 delete intent_;
869 intent_ = nullptr;
870 }
871
872 /*
873 * Feature: Intent
874 * Function: SetShortArrayParam/GetShortArrayParam
875 * SubFunction: NA
876 * FunctionPoints: SetShortArrayParam/GetShortArrayParam
877 * EnvConditions: NA
878 * CaseDescription: Verify when parameter change.
879 */
880 HWTEST_P(IntentParametersShortArrayTest, AaFwk_Intent_Parameters_ShortArray, TestSize.Level1)
881 {
882 std::string setKey = std::get<0>(GetParam());
883 std::string getKey = std::get<1>(GetParam());
884 std::vector<short> setValue = std::get<2>(GetParam());
885 std::vector<short> defaultValue = std::get<3>(GetParam());
886 std::vector<short> result = std::get<4>(GetParam());
887 intent_->SetShortArrayParam(setKey, setValue);
888 EXPECT_EQ(result, intent_->GetShortArrayParam(getKey));
889 }
890
891 INSTANTIATE_TEST_CASE_P(IntentParametersShortArrayTestCaseP, IntentParametersShortArrayTest,
892 testing::Values(testShortArrayType("", "aa", {-1, 3, 25, -9}, {}, {}),
893 testShortArrayType("", "", {-41, 0, 0, 9}, {}, {-41, 0, 0, 9}),
894 testShortArrayType("1*中_aR", "aa", {50, 2, -9}, {}, {}),
895 testShortArrayType("1*中_aR", "1*中_aR", {-5000}, {}, {-5000})));
896
897 /*
898 * Feature: Intent
899 * Function: GetShortArrayParam
900 * SubFunction: NA
901 * FunctionPoints: GetShortArrayParam
902 * EnvConditions: NA
903 * CaseDescription: Verify when the value is short array
904 */
905 HWTEST_F(IntentParametersShortArrayTest, AaFwk_Intent_Parameters_Short_Array_001, TestSize.Level1)
906 {
907 std::vector<short> defaultValue;
908 std::string getKey("aa");
909 EXPECT_EQ(defaultValue, intent_->GetShortArrayParam(getKey));
910 }
911
912 /*
913 * Feature: Intent
914 * Function: SetShortArrayParam/GetShortArrayParam
915 * SubFunction: NA
916 * FunctionPoints: SetShortArrayParam/GetShortArrayParam
917 * EnvConditions: NA
918 * CaseDescription: Verify when the value is short array
919 */
920 HWTEST_F(IntentParametersShortArrayTest, AaFwk_Intent_Parameters_Short_Array_002, TestSize.Level1)
921 {
922 std::string emptyStr("");
923 std::vector<short> firstValue({1, 4, -9});
924 std::vector<short> secondValue({1, 8, -9});
925 std::vector<short> thirdValue({1, 4, 9});
926 std::string keyStr("aa");
927 intent_->SetShortArrayParam(emptyStr, firstValue);
928 intent_->SetShortArrayParam(emptyStr, firstValue);
929 intent_->SetShortArrayParam(emptyStr, secondValue);
930 std::vector<short> defaultValue;
931 EXPECT_EQ(defaultValue, intent_->GetShortArrayParam(keyStr));
932 intent_->SetShortArrayParam(emptyStr, thirdValue);
933 EXPECT_EQ(thirdValue, intent_->GetShortArrayParam(emptyStr));
934 }
935
936 /*
937 * Feature: Intent
938 * Function: SetShortArrayParam/GetShortArrayParam
939 * SubFunction: NA
940 * FunctionPoints: SetShortArrayParam/GetShortArrayParam
941 * EnvConditions: NA
942 * CaseDescription: Verify when the value is short array
943 */
944 HWTEST_F(IntentParametersShortArrayTest, AaFwk_Intent_Parameters_Short_Array_003, TestSize.Level1)
945 {
946 std::string firstKey("%1uH3");
947 std::vector<short> firstValue({-1, -2});
948 std::vector<short> secondValue({-1, -2, -1, -2, 0});
949 std::vector<short> thirdValue({-1, -2, 100});
950 std::string secondKey("aa");
951 intent_->SetShortArrayParam(firstKey, firstValue);
952 intent_->SetShortArrayParam(firstKey, firstValue);
953 intent_->SetShortArrayParam(firstKey, secondValue);
954 EXPECT_EQ(secondValue, intent_->GetShortArrayParam(firstKey));
955 intent_->SetShortArrayParam(firstKey, thirdValue);
956 std::vector<short> defaultValue;
957 EXPECT_EQ(defaultValue, intent_->GetShortArrayParam(secondKey));
958 }
959
960 using testIntType = std::tuple<std::string, std::string, int, int, int>;
961 class IntentParametersIntTest : public testing::TestWithParam<testIntType> {
962 public:
IntentParametersIntTest()963 IntentParametersIntTest() : intent_(nullptr)
964 {}
~IntentParametersIntTest()965 ~IntentParametersIntTest()
966 {
967 intent_ = nullptr;
968 }
969 static void SetUpTestCase(void);
970 static void TearDownTestCase(void);
971 void SetUp();
972 void TearDown();
973 Intent *intent_;
974 };
975
SetUpTestCase(void)976 void IntentParametersIntTest::SetUpTestCase(void)
977 {}
978
TearDownTestCase(void)979 void IntentParametersIntTest::TearDownTestCase(void)
980 {}
981
SetUp(void)982 void IntentParametersIntTest::SetUp(void)
983 {
984 intent_ = new (std::nothrow) Intent();
985 }
986
TearDown(void)987 void IntentParametersIntTest::TearDown(void)
988 {
989 delete intent_;
990 intent_ = nullptr;
991 }
992
993 /*
994 * Feature: Intent
995 * Function: SetIntParam/GetIntParam
996 * SubFunction: NA
997 * FunctionPoints: SetIntParam/GetIntParam
998 * EnvConditions: NA
999 * CaseDescription: Verify when parameter change.
1000 */
1001 HWTEST_P(IntentParametersIntTest, AaFwk_Intent_Parameters_Int, TestSize.Level1)
1002 {
1003 std::string setKey = std::get<0>(GetParam());
1004 std::string getKey = std::get<1>(GetParam());
1005 int setValue = std::get<2>(GetParam());
1006 int defaultValue = std::get<3>(GetParam());
1007 int result = std::get<4>(GetParam());
1008 intent_->SetIntParam(setKey, setValue);
1009 EXPECT_EQ(result, intent_->GetIntParam(getKey, defaultValue));
1010 }
1011
1012 INSTANTIATE_TEST_CASE_P(IntentParametersIntTestCaseP, IntentParametersIntTest,
1013 testing::Values(testIntType("", "aa", -1, 100, 100), testIntType("", "", -9, -41, -9),
1014 testIntType("1*中_aR", "aa", 50, 5, 5), testIntType("1*中_aR", "1*中_aR", -5000, 5000, -5000)));
1015
1016 /*
1017 * Feature: Intent
1018 * Function: GetIntParam
1019 * SubFunction: NA
1020 * FunctionPoints: GetIntParam
1021 * EnvConditions: NA
1022 * CaseDescription: Verify when the value is integer
1023 */
1024 HWTEST_F(IntentParametersIntTest, AaFwk_Intent_Parameters_Int_001, TestSize.Level1)
1025 {
1026 int defaultValue = 200;
1027 std::string getKey("aa");
1028 EXPECT_EQ(defaultValue, intent_->GetIntParam(getKey, defaultValue));
1029 }
1030
1031 /*
1032 * Feature: Intent
1033 * Function: SetIntParam/GetIntParam
1034 * SubFunction: NA
1035 * FunctionPoints: SetIntParam/GetIntParam
1036 * EnvConditions: NA
1037 * CaseDescription: Verify when the value is integer
1038 */
1039 HWTEST_F(IntentParametersIntTest, AaFwk_Intent_Parameters_Int_002, TestSize.Level1)
1040 {
1041 std::string emptyStr("");
1042 int firstValue = 1;
1043 int secondValue = 2;
1044 int thirdValue = 4;
1045 int firstDefaultValue = 3;
1046 int secondDefaultValue = 5;
1047 std::string keyStr("aa");
1048 intent_->SetIntParam(emptyStr, firstValue);
1049 intent_->SetIntParam(emptyStr, firstValue);
1050 intent_->SetIntParam(emptyStr, secondValue);
1051 EXPECT_EQ(firstDefaultValue, intent_->GetIntParam(keyStr, firstDefaultValue));
1052 intent_->SetIntParam(emptyStr, thirdValue);
1053 EXPECT_EQ(thirdValue, intent_->GetIntParam(emptyStr, secondDefaultValue));
1054 }
1055
1056 /*
1057 * Feature: Intent
1058 * Function: SetIntParam/GetIntParam
1059 * SubFunction: NA
1060 * FunctionPoints: SetIntParam/GetIntParam
1061 * EnvConditions: NA
1062 * CaseDescription: Verify when the value is integer
1063 */
1064 HWTEST_F(IntentParametersIntTest, AaFwk_Intent_Parameters_Int_003, TestSize.Level1)
1065 {
1066 std::string firstKey("%1uH3");
1067 int firstValue = -1;
1068 int secondValue = 0;
1069 int thirdValue = 4;
1070 int firstDefaultValue = 9;
1071 int secondDefaultValue = -10;
1072 std::string secondKey("aa");
1073 intent_->SetIntParam(firstKey, firstValue);
1074 intent_->SetIntParam(firstKey, firstValue);
1075 intent_->SetIntParam(firstKey, secondValue);
1076 EXPECT_EQ(secondValue, intent_->GetIntParam(firstKey, firstDefaultValue));
1077 intent_->SetIntParam(firstKey, thirdValue);
1078 EXPECT_EQ(secondDefaultValue, intent_->GetIntParam(secondKey, secondDefaultValue));
1079 }
1080
1081 using testIntArrayType = std::tuple<std::string, std::string, std::vector<int>, std::vector<int>, std::vector<int>>;
1082 class IntentParametersIntArrayTest : public testing::TestWithParam<testIntArrayType> {
1083 public:
IntentParametersIntArrayTest()1084 IntentParametersIntArrayTest() : intent_(nullptr)
1085 {}
~IntentParametersIntArrayTest()1086 ~IntentParametersIntArrayTest()
1087 {
1088 intent_ = nullptr;
1089 }
1090 static void SetUpTestCase(void);
1091 static void TearDownTestCase(void);
1092 void SetUp();
1093 void TearDown();
1094 Intent *intent_;
1095 };
1096
SetUpTestCase(void)1097 void IntentParametersIntArrayTest::SetUpTestCase(void)
1098 {}
1099
TearDownTestCase(void)1100 void IntentParametersIntArrayTest::TearDownTestCase(void)
1101 {}
1102
SetUp(void)1103 void IntentParametersIntArrayTest::SetUp(void)
1104 {
1105 intent_ = new (std::nothrow) Intent();
1106 }
1107
TearDown(void)1108 void IntentParametersIntArrayTest::TearDown(void)
1109 {
1110 delete intent_;
1111 intent_ = nullptr;
1112 }
1113
1114 /*
1115 * Feature: Intent
1116 * Function: SetIntArrayParam/GetIntArrayParam
1117 * SubFunction: NA
1118 * FunctionPoints: SetIntArrayParam/GetIntArrayParam
1119 * EnvConditions: NA
1120 * CaseDescription: Verify when parameter change.
1121 */
1122 HWTEST_P(IntentParametersIntArrayTest, AaFwk_Intent_Parameters_IntArray, TestSize.Level1)
1123 {
1124 std::string setKey = std::get<0>(GetParam());
1125 std::string getKey = std::get<1>(GetParam());
1126 std::vector<int> setValue = std::get<2>(GetParam());
1127 std::vector<int> defaultValue = std::get<3>(GetParam());
1128 std::vector<int> result = std::get<4>(GetParam());
1129 intent_->SetIntArrayParam(setKey, setValue);
1130 EXPECT_EQ(result, intent_->GetIntArrayParam(getKey));
1131 }
1132
1133 INSTANTIATE_TEST_CASE_P(IntentParametersIntArrayTestCaseP, IntentParametersIntArrayTest,
1134 testing::Values(testIntArrayType("", "aa", {-1, 3, 25, -9}, {}, {}),
1135 testIntArrayType("", "", {-41, 0, 0, 9}, {}, {-41, 0, 0, 9}),
1136 testIntArrayType("1*中_aR", "aa", {50, 2, -9}, {}, {}),
1137 testIntArrayType("1*中_aR", "1*中_aR", {-5000}, {}, {-5000})));
1138
1139 /*
1140 * Feature: Intent
1141 * Function: GetIntArrayParam
1142 * SubFunction: NA
1143 * FunctionPoints: GetIntArrayParam
1144 * EnvConditions: NA
1145 * CaseDescription: Verify when the value is integer array
1146 */
1147 HWTEST_F(IntentParametersIntArrayTest, AaFwk_Intent_Parameters_Int_Array_001, TestSize.Level1)
1148 {
1149 std::vector<int> defaultValue;
1150 std::string getKey("aa");
1151 EXPECT_EQ(defaultValue, intent_->GetIntArrayParam(getKey));
1152 }
1153
1154 /*
1155 * Feature: Intent
1156 * Function: SetIntArrayParam/GetIntArrayParam
1157 * SubFunction: NA
1158 * FunctionPoints: SetIntArrayParam/GetIntArrayParam
1159 * EnvConditions: NA
1160 * CaseDescription: Verify when the value is integer array
1161 */
1162 HWTEST_F(IntentParametersIntArrayTest, AaFwk_Intent_Parameters_Int_Array_002, TestSize.Level1)
1163 {
1164 std::string emptyStr("");
1165 std::vector<int> firstValue({1, 4, -9});
1166 std::vector<int> secondValue({1, 8, -9});
1167 std::vector<int> thirdValue({1, 4, 9});
1168 std::string keyStr("aa");
1169 intent_->SetIntArrayParam(emptyStr, firstValue);
1170 intent_->SetIntArrayParam(emptyStr, firstValue);
1171 intent_->SetIntArrayParam(emptyStr, secondValue);
1172 std::vector<int> defaultValue;
1173 EXPECT_EQ(defaultValue, intent_->GetIntArrayParam(keyStr));
1174 intent_->SetIntArrayParam(emptyStr, thirdValue);
1175 EXPECT_EQ(thirdValue, intent_->GetIntArrayParam(emptyStr));
1176 }
1177
1178 /*
1179 * Feature: Intent
1180 * Function: SetIntArrayParam/GetIntArrayParam
1181 * SubFunction: NA
1182 * FunctionPoints: SetIntArrayParam/GetIntArrayParam
1183 * EnvConditions: NA
1184 * CaseDescription: Verify when the value is integer array
1185 */
1186 HWTEST_F(IntentParametersIntArrayTest, AaFwk_Intent_Parameters_Int_Array_003, TestSize.Level1)
1187 {
1188 std::string firstKey("%1uH3");
1189 std::vector<int> firstValue({-1, -2});
1190 std::vector<int> secondValue({-1, -2, -1, -2, 0});
1191 std::vector<int> thirdValue({-1, -2, 100});
1192 std::string secondKey("aa");
1193 intent_->SetIntArrayParam(firstKey, firstValue);
1194 intent_->SetIntArrayParam(firstKey, firstValue);
1195 intent_->SetIntArrayParam(firstKey, secondValue);
1196 EXPECT_EQ(secondValue, intent_->GetIntArrayParam(firstKey));
1197 intent_->SetIntArrayParam(firstKey, thirdValue);
1198 std::vector<int> defaultValue;
1199 EXPECT_EQ(defaultValue, intent_->GetIntArrayParam(secondKey));
1200 }
1201
1202 using testLongType = std::tuple<std::string, std::string, long, long, long>;
1203 class IntentParametersLongTest : public testing::TestWithParam<testLongType> {
1204 public:
IntentParametersLongTest()1205 IntentParametersLongTest() : intent_(nullptr)
1206 {}
~IntentParametersLongTest()1207 ~IntentParametersLongTest()
1208 {
1209 intent_ = nullptr;
1210 }
1211 static void SetUpTestCase(void);
1212 static void TearDownTestCase(void);
1213 void SetUp();
1214 void TearDown();
1215 Intent *intent_;
1216 };
1217
SetUpTestCase(void)1218 void IntentParametersLongTest::SetUpTestCase(void)
1219 {}
1220
TearDownTestCase(void)1221 void IntentParametersLongTest::TearDownTestCase(void)
1222 {}
1223
SetUp(void)1224 void IntentParametersLongTest::SetUp(void)
1225 {
1226 intent_ = new (std::nothrow) Intent();
1227 }
1228
TearDown(void)1229 void IntentParametersLongTest::TearDown(void)
1230 {
1231 delete intent_;
1232 intent_ = nullptr;
1233 }
1234
1235 /*
1236 * Feature: Intent
1237 * Function: SetLongParam/GetLongParam
1238 * SubFunction: NA
1239 * FunctionPoints: SetLongParam/GetLongParam
1240 * EnvConditions: NA
1241 * CaseDescription: Verify when parameter change.
1242 */
1243 HWTEST_P(IntentParametersLongTest, AaFwk_Intent_Parameters_Long, TestSize.Level1)
1244 {
1245 std::string setKey = std::get<0>(GetParam());
1246 std::string getKey = std::get<1>(GetParam());
1247 long setValue = std::get<2>(GetParam());
1248 long defaultValue = std::get<3>(GetParam());
1249 long result = std::get<4>(GetParam());
1250 intent_->SetLongParam(setKey, setValue);
1251 EXPECT_EQ(result, intent_->GetLongParam(getKey, defaultValue));
1252 }
1253
1254 INSTANTIATE_TEST_CASE_P(IntentParametersLongTestCaseP, IntentParametersLongTest,
1255 testing::Values(testLongType("", "aa", -1, 100, 100), testLongType("", "", -9, -41, -9),
1256 testLongType("1*中_aR", "aa", 50, 5, 5), testLongType("1*中_aR", "1*中_aR", -5000, 5000, -5000)));
1257
1258 /*
1259 * Feature: Intent
1260 * Function: SetLongParam & GetLongParam
1261 * SubFunction: NA
1262 * FunctionPoints: SetLongParam & GetLongParam
1263 * EnvConditions: NA
1264 * CaseDescription: get param when IntentParam is empty
1265 */
1266 HWTEST_F(IntentParametersLongTest, AaFwk_Intent_Parameters_Long_001, TestSize.Level1)
1267 {
1268 long defaultValue = 100;
1269 std::string key = "aa";
1270 EXPECT_EQ(defaultValue, intent_->GetLongParam(key, defaultValue));
1271 }
1272
1273 /*
1274 * Feature: Intent
1275 * Function: SetLongParam & GetLongParam
1276 * SubFunction: NA
1277 * FunctionPoints: SetLongParam & GetLongParam
1278 * EnvConditions: NA
1279 * CaseDescription: set empty-string key repeatedly, but get param of another nonexistent key
1280 */
1281 HWTEST_F(IntentParametersLongTest, AaFwk_Intent_Parameters_Long_002, TestSize.Level1)
1282 {
1283 std::string setKey1 = "";
1284 std::string setKey2 = "aa";
1285 long setValue1 = 1;
1286 long setValue2 = 5;
1287 intent_->SetLongParam(setKey1, setValue1);
1288 intent_->SetLongParam(setKey1, setValue1);
1289 setValue1 = 2;
1290 intent_->SetLongParam(setKey1, setValue1);
1291 setValue1 = 3;
1292 EXPECT_EQ(setValue1, intent_->GetLongParam(setKey2, setValue1));
1293 setValue1 = 4;
1294 intent_->SetLongParam(setKey1, setValue1);
1295 EXPECT_EQ(setValue1, intent_->GetLongParam(setKey1, setValue2));
1296 }
1297
1298 /*
1299 * Feature: Intent
1300 * Function: SetLongParam & GetLongParam
1301 * SubFunction: NA
1302 * FunctionPoints: SetLongParam & GetLongParam
1303 * EnvConditions: NA
1304 * CaseDescription: set empty-string key repeatedly, then get param of the key
1305 */
1306 HWTEST_F(IntentParametersLongTest, AaFwk_Intent_Parameters_Long_003, TestSize.Level1)
1307 {
1308 std::string setKey1 = "%1uH3";
1309 std::string setKey2 = "aa";
1310 long setValue1 = -1;
1311 long setValue2 = 9;
1312 intent_->SetLongParam(setKey1, setValue1);
1313 intent_->SetLongParam(setKey1, setValue1);
1314 setValue1 = 0;
1315 intent_->SetLongParam(setKey1, setValue1);
1316 EXPECT_EQ(setValue1, intent_->GetLongParam(setKey1, setValue2));
1317 setValue1 = 4;
1318 intent_->SetLongParam(setKey1, setValue1);
1319 setValue1 = -10;
1320 EXPECT_EQ(setValue1, intent_->GetLongParam(setKey2, setValue1));
1321 }
1322
1323 using testLongArrayType = std::tuple<std::string, std::string, std::vector<long>, std::vector<long>, std::vector<long>>;
1324 class IntentParametersLongArrayTest : public testing::TestWithParam<testLongArrayType> {
1325 public:
IntentParametersLongArrayTest()1326 IntentParametersLongArrayTest() : intent_(nullptr)
1327 {}
~IntentParametersLongArrayTest()1328 ~IntentParametersLongArrayTest()
1329 {
1330 intent_ = nullptr;
1331 }
1332 static void SetUpTestCase(void);
1333 static void TearDownTestCase(void);
1334 void SetUp();
1335 void TearDown();
1336 Intent *intent_;
1337 };
1338
SetUpTestCase(void)1339 void IntentParametersLongArrayTest::SetUpTestCase(void)
1340 {}
1341
TearDownTestCase(void)1342 void IntentParametersLongArrayTest::TearDownTestCase(void)
1343 {}
1344
SetUp(void)1345 void IntentParametersLongArrayTest::SetUp(void)
1346 {
1347 intent_ = new (std::nothrow) Intent();
1348 }
1349
TearDown(void)1350 void IntentParametersLongArrayTest::TearDown(void)
1351 {
1352 delete intent_;
1353 intent_ = nullptr;
1354 }
1355
1356 /*
1357 * Feature: Intent
1358 * Function: SetLongArrayParam/GetLongArrayParam
1359 * SubFunction: NA
1360 * FunctionPoints: SetLongArrayParam/GetLongArrayParam
1361 * EnvConditions: NA
1362 * CaseDescription: Verify when parameter change.
1363 */
1364 HWTEST_P(IntentParametersLongArrayTest, AaFwk_Intent_Parameters_LongArray, TestSize.Level1)
1365 {
1366 std::string setKey = std::get<0>(GetParam());
1367 std::string getKey = std::get<1>(GetParam());
1368 std::vector<long> setValue = std::get<2>(GetParam());
1369 std::vector<long> defaultValue = std::get<3>(GetParam());
1370 std::vector<long> result = std::get<4>(GetParam());
1371 intent_->SetLongArrayParam(setKey, setValue);
1372 EXPECT_EQ(result, intent_->GetLongArrayParam(getKey));
1373 }
1374
1375 INSTANTIATE_TEST_CASE_P(IntentParametersLongArrayTestCaseP, IntentParametersLongArrayTest,
1376 testing::Values(testLongArrayType("", "aa", {-1, 3, 25, -9}, {}, {}),
1377 testLongArrayType("", "", {-41, 0, 0, 9}, {}, {-41, 0, 0, 9}),
1378 testLongArrayType("1*中_aR", "aa", {50, 2, -9}, {}, {}),
1379 testLongArrayType("1*中_aR", "1*中_aR", {-5000}, {}, {-5000})));
1380
1381 /*
1382 * Feature: Intent
1383 * Function: SetLongArrayParam & GetLongArrayParam
1384 * SubFunction: NA
1385 * FunctionPoints: SetLongArrayParam & GetLongArrayParam
1386 * EnvConditions: NA
1387 * CaseDescription: get param when IntentParam is empty
1388 */
1389 HWTEST_F(IntentParametersLongArrayTest, AaFwk_Intent_Parameters_Long_Array_001, TestSize.Level1)
1390 {
1391 std::vector<long> defaultValue;
1392 std::string key = "aa";
1393 EXPECT_EQ(defaultValue, intent_->GetLongArrayParam(key));
1394 }
1395
1396 /*
1397 * Feature: Intent
1398 * Function: SetLongArrayParam & GetLongArrayParam
1399 * SubFunction: NA
1400 * FunctionPoints: SetLongArrayParam & GetLongArrayParam
1401 * EnvConditions: NA
1402 * CaseDescription: set empty-string key repeatedly, but get param of another nonexistent key
1403 */
1404 HWTEST_F(IntentParametersLongArrayTest, AaFwk_Intent_Parameters_Long_Array_002, TestSize.Level1)
1405 {
1406 std::vector<long> defaultValue;
1407 std::string setKey1 = "";
1408 std::string setKey2 = "aa";
1409 std::vector<long> setValue1 = {1, 2};
1410 intent_->SetLongArrayParam(setKey1, setValue1);
1411 intent_->SetLongArrayParam(setKey1, setValue1);
1412 setValue1 = {2, 3};
1413 intent_->SetLongArrayParam(setKey1, setValue1);
1414 EXPECT_EQ(defaultValue, intent_->GetLongArrayParam(setKey2));
1415 setValue1 = {4, 5};
1416 intent_->SetLongArrayParam(setKey1, setValue1);
1417 EXPECT_EQ(setValue1, intent_->GetLongArrayParam(setKey1));
1418 }
1419
1420 /*
1421 * Feature: Intent
1422 * Function: SetLongArrayParam & GetLongArrayParam
1423 * SubFunction: NA
1424 * FunctionPoints: SetLongArrayParam & GetLongArrayParam
1425 * EnvConditions: NA
1426 * CaseDescription: set empty-string key repeatedly, then get param of the key
1427 */
1428 HWTEST_F(IntentParametersLongArrayTest, AaFwk_Intent_Parameters_Long_Array_003, TestSize.Level1)
1429 {
1430 std::vector<long> defaultValue;
1431 std::string setKey1 = "%1uH3";
1432 std::string setKey2 = "aa";
1433 std::vector<long> setValue1 = {-1, -2};
1434 intent_->SetLongArrayParam(setKey1, setValue1);
1435 intent_->SetLongArrayParam(setKey1, setValue1);
1436 setValue1 = {0, 1};
1437 intent_->SetLongArrayParam(setKey1, setValue1);
1438 EXPECT_EQ(setValue1, intent_->GetLongArrayParam(setKey1));
1439 setValue1 = {4, 5};
1440 intent_->SetLongArrayParam(setKey1, setValue1);
1441 EXPECT_EQ(defaultValue, intent_->GetLongArrayParam(setKey2));
1442 }
1443
1444 using testFloatType = std::tuple<std::string, std::string, float, float, float>;
1445 class IntentParametersFloatTest : public testing::TestWithParam<testFloatType> {
1446 public:
IntentParametersFloatTest()1447 IntentParametersFloatTest() : intent_(nullptr)
1448 {}
~IntentParametersFloatTest()1449 ~IntentParametersFloatTest()
1450 {
1451 intent_ = nullptr;
1452 }
1453 static void SetUpTestCase(void);
1454 static void TearDownTestCase(void);
1455 void SetUp();
1456 void TearDown();
1457 Intent *intent_;
1458 };
1459
SetUpTestCase(void)1460 void IntentParametersFloatTest::SetUpTestCase(void)
1461 {}
1462
TearDownTestCase(void)1463 void IntentParametersFloatTest::TearDownTestCase(void)
1464 {}
1465
SetUp(void)1466 void IntentParametersFloatTest::SetUp(void)
1467 {
1468 intent_ = new (std::nothrow) Intent();
1469 }
1470
TearDown(void)1471 void IntentParametersFloatTest::TearDown(void)
1472 {
1473 delete intent_;
1474 intent_ = nullptr;
1475 }
1476
1477 /*
1478 * Feature: Intent
1479 * Function: SetFloatParam/GetFloatParam
1480 * SubFunction: NA
1481 * FunctionPoints: SetFloatParam/GetFloatParam
1482 * EnvConditions: NA
1483 * CaseDescription: Verify when parameter change.
1484 */
1485 HWTEST_P(IntentParametersFloatTest, AaFwk_Intent_Parameters_Float, TestSize.Level1)
1486 {
1487 std::string setKey = std::get<0>(GetParam());
1488 std::string getKey = std::get<1>(GetParam());
1489 float setValue = std::get<2>(GetParam());
1490 float defaultValue = std::get<3>(GetParam());
1491 float result = std::get<4>(GetParam());
1492 intent_->SetFloatParam(setKey, setValue);
1493 EXPECT_EQ(result, intent_->GetFloatParam(getKey, defaultValue));
1494 }
1495
1496 INSTANTIATE_TEST_CASE_P(IntentParametersFloatTestCaseP, IntentParametersFloatTest,
1497 testing::Values(testFloatType("", "aa", -1.1, 100.1, 100.1), testFloatType("", "", -9.1, -41.1, -9.1),
1498 testFloatType("1*中_aR", "aa", 50.1, 5.1, 5.1), testFloatType("1*中_aR", "1*中_aR", -5000.1, 5000.1, -5000.1)));
1499
1500 /*
1501 * Feature: Intent
1502 * Function: SetFloatParam & GetFloatParam
1503 * SubFunction: NA
1504 * FunctionPoints: SetFloatParam & GetFloatParam
1505 * EnvConditions: NA
1506 * CaseDescription: get param when IntentParam is empty
1507 */
1508 HWTEST_F(IntentParametersFloatTest, AaFwk_Intent_Parameters_Float_001, TestSize.Level1)
1509 {
1510 float defaultValue = 100.1;
1511 std::string key = "aa";
1512 EXPECT_EQ(defaultValue, intent_->GetFloatParam(key, defaultValue));
1513 }
1514
1515 /*
1516 * Feature: Intent
1517 * Function: SetFloatParam & GetFloatParam
1518 * SubFunction: NA
1519 * FunctionPoints: SetFloatParam & GetFloatParam
1520 * EnvConditions: NA
1521 * CaseDescription: set empty-string key repeatedly, but get param of another nonexistent key
1522 */
1523 HWTEST_F(IntentParametersFloatTest, AaFwk_Intent_Parameters_Float_002, TestSize.Level1)
1524 {
1525 std::string setKey1 = "";
1526 std::string setKey2 = "aa";
1527 float setValue1 = 1.1;
1528 float setValue2 = 5.1;
1529 intent_->SetFloatParam(setKey1, setValue1);
1530 intent_->SetFloatParam(setKey1, setValue1);
1531 setValue1 = 2.1;
1532 intent_->SetFloatParam(setKey1, setValue1);
1533 setValue1 = 3.1;
1534 EXPECT_EQ(setValue1, intent_->GetFloatParam(setKey2, setValue1));
1535 setValue1 = 4.1;
1536 intent_->SetFloatParam(setKey1, setValue1);
1537 EXPECT_EQ(setValue1, intent_->GetFloatParam(setKey1, setValue2));
1538 }
1539
1540 /*
1541 * Feature: Intent
1542 * Function: SetFloatParam & GetFloatParam
1543 * SubFunction: NA
1544 * FunctionPoints: SetFloatParam & GetFloatParam
1545 * EnvConditions: NA
1546 * CaseDescription: set empty-string key repeatedly, then get param of the key
1547 */
1548 HWTEST_F(IntentParametersFloatTest, AaFwk_Intent_Parameters_Float_003, TestSize.Level1)
1549 {
1550 std::string setKey1 = "%1uH3";
1551 std::string setKey2 = "aa";
1552 float setValue1 = -1.1;
1553 float setValue2 = 9.1;
1554 intent_->SetFloatParam(setKey1, setValue1);
1555 intent_->SetFloatParam(setKey1, setValue1);
1556 setValue1 = 0.1;
1557 intent_->SetFloatParam(setKey1, setValue1);
1558 EXPECT_EQ(setValue1, intent_->GetFloatParam(setKey1, setValue2));
1559 setValue1 = 4.1;
1560 intent_->SetFloatParam(setKey1, setValue1);
1561 setValue1 = -10.1;
1562 EXPECT_EQ(setValue1, intent_->GetFloatParam(setKey2, setValue1));
1563 }
1564
1565 using testFloatArrayType =
1566 std::tuple<std::string, std::string, std::vector<float>, std::vector<float>, std::vector<float>>;
1567 class IntentParametersFloatArrayTest : public testing::TestWithParam<testFloatArrayType> {
1568 public:
IntentParametersFloatArrayTest()1569 IntentParametersFloatArrayTest() : intent_(nullptr)
1570 {}
~IntentParametersFloatArrayTest()1571 ~IntentParametersFloatArrayTest()
1572 {
1573 intent_ = nullptr;
1574 }
1575 static void SetUpTestCase(void);
1576 static void TearDownTestCase(void);
1577 void SetUp();
1578 void TearDown();
1579 Intent *intent_;
1580 };
1581
SetUpTestCase(void)1582 void IntentParametersFloatArrayTest::SetUpTestCase(void)
1583 {}
1584
TearDownTestCase(void)1585 void IntentParametersFloatArrayTest::TearDownTestCase(void)
1586 {}
1587
SetUp(void)1588 void IntentParametersFloatArrayTest::SetUp(void)
1589 {
1590 intent_ = new (std::nothrow) Intent();
1591 }
1592
TearDown(void)1593 void IntentParametersFloatArrayTest::TearDown(void)
1594 {
1595 delete intent_;
1596 intent_ = nullptr;
1597 }
1598
1599 /*
1600 * Feature: Intent
1601 * Function: SetFloatArrayParam/GetFloatArrayParam
1602 * SubFunction: NA
1603 * FunctionPoints: SetFloatArrayParam/GetFloatArrayParam
1604 * EnvConditions: NA
1605 * CaseDescription: Verify when parameter change.
1606 */
1607 HWTEST_P(IntentParametersFloatArrayTest, AaFwk_Intent_Parameters_FloatArray, TestSize.Level1)
1608 {
1609 std::string setKey = std::get<0>(GetParam());
1610 std::string getKey = std::get<1>(GetParam());
1611 std::vector<float> setValue = std::get<2>(GetParam());
1612 std::vector<float> defaultValue = std::get<3>(GetParam());
1613 std::vector<float> result = std::get<4>(GetParam());
1614 intent_->SetFloatArrayParam(setKey, setValue);
1615 EXPECT_EQ(result, intent_->GetFloatArrayParam(getKey));
1616 }
1617
1618 INSTANTIATE_TEST_CASE_P(IntentParametersFloatArrayTestCaseP, IntentParametersFloatArrayTest,
1619 testing::Values(testFloatArrayType("", "aa", {-1.1, -2.1}, {}, {}),
1620 testFloatArrayType("", "", {-41.1, -42.1}, {}, {-41.1, -42.1}),
1621 testFloatArrayType("1*中_aR", "aa", {50.1, 51.1}, {}, {}),
1622 testFloatArrayType("1*中_aR", "1*中_aR", {5000.1, 5001.1}, {}, {5000.1, 5001.1})));
1623
1624 /*
1625 * Feature: Intent
1626 * Function: SetFloatArrayParam & GetFloatArrayParam
1627 * SubFunction: NA
1628 * FunctionPoints: SetFloatArrayParam & GetFloatArrayParam
1629 * EnvConditions: NA
1630 * CaseDescription: get param when IntentParam is empty
1631 */
1632 HWTEST_F(IntentParametersFloatArrayTest, AaFwk_Intent_Parameters_Float_Array_001, TestSize.Level1)
1633 {
1634 std::vector<float> defaultValue;
1635 std::string key = "aa";
1636 EXPECT_EQ(defaultValue, intent_->GetFloatArrayParam(key));
1637 }
1638
1639 /*
1640 * Feature: Intent
1641 * Function: SetFloatArrayParam & GetFloatArrayParam
1642 * SubFunction: NA
1643 * FunctionPoints: SetFloatArrayParam & GetFloatArrayParam
1644 * EnvConditions: NA
1645 * CaseDescription: set empty-string key repeatedly, but get param of another nonexistent key
1646 */
1647 HWTEST_F(IntentParametersFloatArrayTest, AaFwk_Intent_Parameters_Float_Array_002, TestSize.Level1)
1648 {
1649 std::vector<float> defaultValue;
1650 std::string setKey1 = "";
1651 std::string setKey2 = "aa";
1652 std::vector<float> setValue1 = {1.1, 2.1};
1653 intent_->SetFloatArrayParam(setKey1, setValue1);
1654 intent_->SetFloatArrayParam(setKey1, setValue1);
1655 setValue1 = {2.1, 3.1};
1656 intent_->SetFloatArrayParam(setKey1, setValue1);
1657 EXPECT_EQ(defaultValue, intent_->GetFloatArrayParam(setKey2));
1658 setValue1 = {4.1, 5.1};
1659 intent_->SetFloatArrayParam(setKey1, setValue1);
1660 EXPECT_EQ(setValue1, intent_->GetFloatArrayParam(setKey1));
1661 }
1662
1663 /*
1664 * Feature: Intent
1665 * Function: SetFloatArrayParam & GetFloatArrayParam
1666 * SubFunction: NA
1667 * FunctionPoints: SetFloatArrayParam & GetFloatArrayParam
1668 * EnvConditions: NA
1669 * CaseDescription: set empty-string key repeatedly, then get param of the key
1670 */
1671 HWTEST_F(IntentParametersFloatArrayTest, AaFwk_Intent_Parameters_Float_Array_003, TestSize.Level1)
1672 {
1673 std::vector<float> defaultValue;
1674 std::string setKey1 = "%1uH3";
1675 std::string setKey2 = "aa";
1676 std::vector<float> setValue1 = {-1.1, -2.1};
1677 intent_->SetFloatArrayParam(setKey1, setValue1);
1678 intent_->SetFloatArrayParam(setKey1, setValue1);
1679 setValue1 = {0.1, 1.1};
1680 intent_->SetFloatArrayParam(setKey1, setValue1);
1681 EXPECT_EQ(setValue1, intent_->GetFloatArrayParam(setKey1));
1682 setValue1 = {4.1, 5.1};
1683 intent_->SetFloatArrayParam(setKey1, setValue1);
1684 EXPECT_EQ(defaultValue, intent_->GetFloatArrayParam(setKey2));
1685 }
1686
1687 using testDoubleType = std::tuple<std::string, std::string, double, double, double>;
1688 class IntentParametersDoubleTest : public testing::TestWithParam<testDoubleType> {
1689 public:
IntentParametersDoubleTest()1690 IntentParametersDoubleTest() : intent_(nullptr)
1691 {}
~IntentParametersDoubleTest()1692 ~IntentParametersDoubleTest()
1693 {
1694 intent_ = nullptr;
1695 }
1696 static void SetUpTestCase(void);
1697 static void TearDownTestCase(void);
1698 void SetUp();
1699 void TearDown();
1700 Intent *intent_;
1701 };
1702
SetUpTestCase(void)1703 void IntentParametersDoubleTest::SetUpTestCase(void)
1704 {}
1705
TearDownTestCase(void)1706 void IntentParametersDoubleTest::TearDownTestCase(void)
1707 {}
1708
SetUp(void)1709 void IntentParametersDoubleTest::SetUp(void)
1710 {
1711 intent_ = new (std::nothrow) Intent();
1712 }
1713
TearDown(void)1714 void IntentParametersDoubleTest::TearDown(void)
1715 {
1716 delete intent_;
1717 intent_ = nullptr;
1718 }
1719
1720 /*
1721 * Feature: Intent
1722 * Function: SetDoubleParam/GetDoubleParam
1723 * SubFunction: NA
1724 * FunctionPoints: SetDoubleParam/GetDoubleParam
1725 * EnvConditions: NA
1726 * CaseDescription: Verify when parameter change.
1727 */
1728 HWTEST_P(IntentParametersDoubleTest, AaFwk_Intent_Parameters_Double, TestSize.Level1)
1729 {
1730 std::string setKey = std::get<0>(GetParam());
1731 std::string getKey = std::get<1>(GetParam());
1732 double setValue = std::get<2>(GetParam());
1733 double defaultValue = std::get<3>(GetParam());
1734 double result = std::get<4>(GetParam());
1735 intent_->SetDoubleParam(setKey, setValue);
1736 EXPECT_EQ(result, intent_->GetDoubleParam(getKey, defaultValue));
1737 }
1738
1739 INSTANTIATE_TEST_CASE_P(IntentParametersDoubleTestCaseP, IntentParametersDoubleTest,
1740 testing::Values(testDoubleType("", "aa", -1.1, 100.1, 100.1), testDoubleType("", "", -9.1, -41.1, -9.1),
1741 testDoubleType("1*中_aR", "aa", 50.1, 5.1, 5.1),
1742 testDoubleType("1*中_aR", "1*中_aR", -5000.1, 5000.1, -5000.1)));
1743
1744 /*
1745 * Feature: Intent
1746 * Function: SetDoubleParam & GetDoubleParam
1747 * SubFunction: NA
1748 * FunctionPoints: SetDoubleParam & GetDoubleParam
1749 * EnvConditions: NA
1750 * CaseDescription: get param when IntentParam is empty
1751 */
1752 HWTEST_F(IntentParametersDoubleTest, AaFwk_Intent_Parameters_Double_001, TestSize.Level1)
1753 {
1754 double defaultValue = 100.1;
1755 std::string key = "aa";
1756 EXPECT_EQ(defaultValue, intent_->GetDoubleParam(key, defaultValue));
1757 }
1758
1759 /*
1760 * Feature: Intent
1761 * Function: SetDoubleParam & GetDoubleParam
1762 * SubFunction: NA
1763 * FunctionPoints: SetDoubleParam & GetDoubleParam
1764 * EnvConditions: NA
1765 * CaseDescription: set empty-string key repeatedly, but get param of another nonexistent key
1766 */
1767 HWTEST_F(IntentParametersDoubleTest, AaFwk_Intent_Parameters_Double_002, TestSize.Level1)
1768 {
1769 std::string setKey1 = "";
1770 std::string setKey2 = "aa";
1771 double setValue1 = 1.1;
1772 double setValue2 = 5.1;
1773 intent_->SetDoubleParam(setKey1, setValue1);
1774 intent_->SetDoubleParam(setKey1, setValue1);
1775 setValue1 = 2.1;
1776 intent_->SetDoubleParam(setKey1, setValue1);
1777 setValue1 = 3.1;
1778 EXPECT_EQ(setValue1, intent_->GetDoubleParam(setKey2, setValue1));
1779 setValue1 = 4.1;
1780 intent_->SetDoubleParam(setKey1, setValue1);
1781 EXPECT_EQ(setValue1, intent_->GetDoubleParam(setKey1, setValue2));
1782 }
1783
1784 /*
1785 * Feature: Intent
1786 * Function: SetDoubleParam & GetDoubleParam
1787 * SubFunction: NA
1788 * FunctionPoints: SetDoubleParam & GetDoubleParam
1789 * EnvConditions: NA
1790 * CaseDescription: set empty-string key repeatedly, then get param of the key
1791 */
1792 HWTEST_F(IntentParametersDoubleTest, AaFwk_Intent_Parameters_Double_003, TestSize.Level1)
1793 {
1794 std::string setKey1 = "%1uH3";
1795 std::string setKey2 = "aa";
1796 double setValue1 = -1.1;
1797 double setValue2 = 9.1;
1798 intent_->SetDoubleParam(setKey1, setValue1);
1799 intent_->SetDoubleParam(setKey1, setValue1);
1800 setValue1 = 0.1;
1801 intent_->SetDoubleParam(setKey1, setValue1);
1802 EXPECT_EQ(setValue1, intent_->GetDoubleParam(setKey1, setValue2));
1803 setValue1 = 4.1;
1804 intent_->SetDoubleParam(setKey1, setValue1);
1805 setValue1 = -10.1;
1806 EXPECT_EQ(setValue1, intent_->GetDoubleParam(setKey2, setValue1));
1807 }
1808
1809 using testDoubleArrayType =
1810 std::tuple<std::string, std::string, std::vector<double>, std::vector<double>, std::vector<double>>;
1811 class IntentParametersDoubleArrayTest : public testing::TestWithParam<testDoubleArrayType> {
1812 public:
IntentParametersDoubleArrayTest()1813 IntentParametersDoubleArrayTest() : intent_(nullptr)
1814 {}
~IntentParametersDoubleArrayTest()1815 ~IntentParametersDoubleArrayTest()
1816 {
1817 intent_ = nullptr;
1818 }
1819 static void SetUpTestCase(void);
1820 static void TearDownTestCase(void);
1821 void SetUp();
1822 void TearDown();
1823 Intent *intent_;
1824 };
1825
SetUpTestCase(void)1826 void IntentParametersDoubleArrayTest::SetUpTestCase(void)
1827 {}
1828
TearDownTestCase(void)1829 void IntentParametersDoubleArrayTest::TearDownTestCase(void)
1830 {}
1831
SetUp(void)1832 void IntentParametersDoubleArrayTest::SetUp(void)
1833 {
1834 intent_ = new (std::nothrow) Intent();
1835 }
1836
TearDown(void)1837 void IntentParametersDoubleArrayTest::TearDown(void)
1838 {
1839 delete intent_;
1840 intent_ = nullptr;
1841 }
1842
1843 /*
1844 * Feature: Intent
1845 * Function: SetDoubleArrayParam/GetDoubleArrayParam
1846 * SubFunction: NA
1847 * FunctionPoints: SetDoubleArrayParam/GetDoubleArrayParam
1848 * EnvConditions: NA
1849 * CaseDescription: Verify when parameter change.
1850 */
1851 HWTEST_P(IntentParametersDoubleArrayTest, AaFwk_Intent_Parameters_DoubleArray, TestSize.Level1)
1852 {
1853 std::string setKey = std::get<0>(GetParam());
1854 std::string getKey = std::get<1>(GetParam());
1855 std::vector<double> setValue = std::get<2>(GetParam());
1856 std::vector<double> defaultValue = std::get<3>(GetParam());
1857 std::vector<double> result = std::get<4>(GetParam());
1858 intent_->SetDoubleArrayParam(setKey, setValue);
1859 EXPECT_EQ(result, intent_->GetDoubleArrayParam(getKey));
1860 }
1861
1862 INSTANTIATE_TEST_CASE_P(IntentParametersDoubleArrayTestCaseP, IntentParametersDoubleArrayTest,
1863 testing::Values(testDoubleArrayType("", "aa", {-1.1, -2.1}, {}, {}),
1864 testDoubleArrayType("", "", {-41.1, -42.1}, {}, {-41.1, -42.1}),
1865 testDoubleArrayType("1*中_aR", "aa", {50.1, 51.1}, {}, {}),
1866 testDoubleArrayType("1*中_aR", "1*中_aR", {5000.1, 5001.1}, {}, {5000.1, 5001.1})));
1867
1868 /*
1869 * Feature: Intent
1870 * Function: SetDoubleArrayParam & GetDoubleArrayParam
1871 * SubFunction: NA
1872 * FunctionPoints: SetDoubleArrayParam & GetDoubleArrayParam
1873 * EnvConditions: NA
1874 * CaseDescription: get param when IntentParam is empty
1875 */
1876 HWTEST_F(IntentParametersDoubleArrayTest, AaFwk_Intent_Parameters_Double_Array_001, TestSize.Level1)
1877 {
1878 std::vector<double> defaultValue;
1879 std::string key = "aa";
1880 EXPECT_EQ(defaultValue, intent_->GetDoubleArrayParam(key));
1881 }
1882
1883 /*
1884 * Feature: Intent
1885 * Function: SetDoubleArrayParam & GetDoubleArrayParam
1886 * SubFunction: NA
1887 * FunctionPoints: SetDoubleArrayParam & GetDoubleArrayParam
1888 * EnvConditions: NA
1889 * CaseDescription: set empty-string key repeatedly, but get param of another nonexistent key
1890 */
1891 HWTEST_F(IntentParametersDoubleArrayTest, AaFwk_Intent_Parameters_Double_Array_002, TestSize.Level1)
1892 {
1893 std::vector<double> defaultValue;
1894 std::string setKey1 = "";
1895 std::string setKey2 = "aa";
1896 std::vector<double> setValue1 = {1.1, 2.1};
1897 std::vector<double> setValue2 = {5.1, 6.1};
1898 intent_->SetDoubleArrayParam(setKey1, setValue1);
1899 intent_->SetDoubleArrayParam(setKey1, setValue1);
1900 setValue1 = {2.1, 3.1};
1901 intent_->SetDoubleArrayParam(setKey1, setValue1);
1902 EXPECT_EQ(defaultValue, intent_->GetDoubleArrayParam(setKey2));
1903 setValue1 = {4.1, 5.1};
1904 intent_->SetDoubleArrayParam(setKey1, setValue1);
1905 EXPECT_EQ(setValue1, intent_->GetDoubleArrayParam(setKey1));
1906 }
1907
1908 /*
1909 * Feature: Intent
1910 * Function: SetDoubleArrayParam & GetDoubleArrayParam
1911 * SubFunction: NA
1912 * FunctionPoints: SetDoubleArrayParam & GetDoubleArrayParam
1913 * EnvConditions: NA
1914 * CaseDescription: set empty-string key repeatedly, then get param of the key
1915 */
1916 HWTEST_F(IntentParametersDoubleArrayTest, AaFwk_Intent_Parameters_Double_Array_003, TestSize.Level1)
1917 {
1918 std::vector<double> defaultValue;
1919 std::string setKey1 = "%1uH3";
1920 std::string setKey2 = "aa";
1921 std::vector<double> setValue1 = {-1.1, -2.1};
1922 intent_->SetDoubleArrayParam(setKey1, setValue1);
1923 intent_->SetDoubleArrayParam(setKey1, setValue1);
1924 setValue1 = {0.1, 1.1};
1925 intent_->SetDoubleArrayParam(setKey1, setValue1);
1926 EXPECT_EQ(setValue1, intent_->GetDoubleArrayParam(setKey1));
1927 setValue1 = {4.1, 5.1};
1928 intent_->SetDoubleArrayParam(setKey1, setValue1);
1929 setValue1 = {-10.1, -11.1};
1930 EXPECT_EQ(defaultValue, intent_->GetDoubleArrayParam(setKey2));
1931 }
1932
1933 using testStrType = std::tuple<std::string, std::string, std::string, std::string, std::string>;
1934 class IntentParametersStringTest : public testing::TestWithParam<testStrType> {
1935 public:
IntentParametersStringTest()1936 IntentParametersStringTest() : intent_(nullptr)
1937 {}
~IntentParametersStringTest()1938 ~IntentParametersStringTest()
1939 {
1940 intent_ = nullptr;
1941 }
1942 static void SetUpTestCase(void);
1943 static void TearDownTestCase(void);
1944 void SetUp();
1945 void TearDown();
1946 Intent *intent_;
1947 };
1948
SetUpTestCase(void)1949 void IntentParametersStringTest::SetUpTestCase(void)
1950 {}
1951
TearDownTestCase(void)1952 void IntentParametersStringTest::TearDownTestCase(void)
1953 {}
1954
SetUp(void)1955 void IntentParametersStringTest::SetUp(void)
1956 {
1957 intent_ = new (std::nothrow) Intent();
1958 }
1959
TearDown(void)1960 void IntentParametersStringTest::TearDown(void)
1961 {
1962 delete intent_;
1963 intent_ = nullptr;
1964 }
1965
1966 /*
1967 * Feature: Intent
1968 * Function: SetStringParam/GetStringParam
1969 * SubFunction: NA
1970 * FunctionPoints: SetStringParam/GetStringParam
1971 * EnvConditions: NA
1972 * CaseDescription: Verify when parameter change.
1973 */
1974 HWTEST_P(IntentParametersStringTest, AaFwk_Intent_Parameters_String, TestSize.Level1)
1975 {
1976 std::string setKey = std::get<0>(GetParam());
1977 std::string getKey = std::get<1>(GetParam());
1978 std::string setValue = std::get<2>(GetParam());
1979 std::string defaultValue = std::get<3>(GetParam());
1980 std::string result = std::get<4>(GetParam());
1981 intent_->SetStringParam(setKey, setValue);
1982 EXPECT_EQ(result, intent_->GetStringParam(getKey));
1983 }
1984
1985 INSTANTIATE_TEST_CASE_P(IntentParametersStringTestCaseP, IntentParametersStringTest,
1986 testing::Values(testStrType("", "aa", "1*中_aR", "", ""), testStrType("", "", "1*中_aR", "", "1*中_aR"),
1987 testStrType("1*中_aR", "aa", "aaa", "", ""), testStrType("1*中_aR", "1*中_aR", "aaa", "", "aaa")));
1988
1989 /*
1990 * Feature: Intent
1991 * Function: SetStringParam & GetStringParam
1992 * SubFunction: NA
1993 * FunctionPoints: SetStringParam & GetStringParam
1994 * EnvConditions: NA
1995 * CaseDescription: get param when IntentParam is empty
1996 */
1997 HWTEST_F(IntentParametersStringTest, AaFwk_Intent_Parameters_String_001, TestSize.Level1)
1998 {
1999 std::string defaultStrValue;
2000 std::string key = "aa";
2001 EXPECT_EQ(defaultStrValue, intent_->GetStringParam(key));
2002 }
2003
2004 /*
2005 * Feature: Intent
2006 * Function: SetStringParam & GetStringParam
2007 * SubFunction: NA
2008 * FunctionPoints: SetStringParam & GetStringParam
2009 * EnvConditions: NA
2010 * CaseDescription: set empty-string key repeatedly, but get param of another nonexistent key
2011 */
2012 HWTEST_F(IntentParametersStringTest, AaFwk_Intent_Parameters_String_002, TestSize.Level1)
2013 {
2014 std::string defaultStrValue;
2015 std::string setValue1 = "aaa";
2016 std::string setValue2 = "1*中_aR";
2017 std::string key1 = "";
2018 std::string key2 = "aa";
2019 intent_->SetStringParam(key1, setValue1);
2020 intent_->SetStringParam(key1, setValue1);
2021 intent_->SetStringParam(key1, setValue2);
2022 EXPECT_EQ(defaultStrValue, intent_->GetStringParam(key2));
2023 intent_->SetStringParam(key1, setValue1);
2024 EXPECT_EQ(setValue1, intent_->GetStringParam(key1));
2025 }
2026
2027 /*
2028 * Feature: Intent
2029 * Function: SetStringParam & GetStringParam
2030 * SubFunction: NA
2031 * FunctionPoints: SetStringParam & GetStringParam
2032 * EnvConditions: NA
2033 * CaseDescription: set empty-string key repeatedly, then get param of the key
2034 */
2035 HWTEST_F(IntentParametersStringTest, AaFwk_Intent_Parameters_String_003, TestSize.Level1)
2036 {
2037 std::string key1 = "%1uH3";
2038 std::string defaultStrValue;
2039 std::string setValue1 = "aaa";
2040 std::string setValue2 = "1*中_aR";
2041 std::string key2 = "aa";
2042 intent_->SetStringParam(key1, setValue1);
2043 intent_->SetStringParam(key1, setValue1);
2044 intent_->SetStringParam(key1, setValue2);
2045 EXPECT_EQ("1*中_aR", intent_->GetStringParam(key1));
2046 intent_->SetStringParam(key1, setValue1);
2047 EXPECT_EQ(defaultStrValue, intent_->GetStringParam(key2));
2048 }
2049
2050 using testStrArrayType =
2051 std::tuple<std::string, std::string, std::vector<std::string>, std::vector<std::string>, std::vector<std::string>>;
2052 class IntentParametersStringArrayTest : public testing::TestWithParam<testStrArrayType> {
2053 public:
IntentParametersStringArrayTest()2054 IntentParametersStringArrayTest() : intent_(nullptr)
2055 {}
~IntentParametersStringArrayTest()2056 ~IntentParametersStringArrayTest()
2057 {
2058 intent_ = nullptr;
2059 }
2060 static void SetUpTestCase(void);
2061 static void TearDownTestCase(void);
2062 void SetUp();
2063 void TearDown();
2064 Intent *intent_;
2065 };
2066
SetUpTestCase(void)2067 void IntentParametersStringArrayTest::SetUpTestCase(void)
2068 {}
2069
TearDownTestCase(void)2070 void IntentParametersStringArrayTest::TearDownTestCase(void)
2071 {}
2072
SetUp(void)2073 void IntentParametersStringArrayTest::SetUp(void)
2074 {
2075 intent_ = new (std::nothrow) Intent();
2076 }
2077
TearDown(void)2078 void IntentParametersStringArrayTest::TearDown(void)
2079 {
2080 delete intent_;
2081 intent_ = nullptr;
2082 }
2083
2084 /*
2085 * Feature: Intent
2086 * Function: SetStringArrayParam/GetStringArrayParam
2087 * SubFunction: NA
2088 * FunctionPoints: SetStringArrayParam/GetStringArrayParam
2089 * EnvConditions: NA
2090 * CaseDescription: Verify when parameter change.
2091 */
2092 HWTEST_P(IntentParametersStringArrayTest, AaFwk_Intent_Parameters_StringArray, TestSize.Level1)
2093 {
2094 std::string setKey = std::get<0>(GetParam());
2095 std::string getKey = std::get<1>(GetParam());
2096 std::vector<std::string> setValue = std::get<2>(GetParam());
2097 std::vector<std::string> defaultValue = std::get<3>(GetParam());
2098 std::vector<std::string> result = std::get<4>(GetParam());
2099 intent_->SetStringArrayParam(setKey, setValue);
2100 EXPECT_EQ(result, intent_->GetStringArrayParam(getKey));
2101 }
2102
2103 INSTANTIATE_TEST_CASE_P(IntentParametersStringArrayTestCaseP, IntentParametersStringArrayTest,
2104 testing::Values(testStrArrayType("", "aa", {"1*中_aR", "dadb"}, {}, {}),
2105 testStrArrayType("", "", {"1*中_aR", "dadb"}, {}, {"1*中_aR", "dadb"}),
2106 testStrArrayType("1*中_aR", "aa", {"1*中_aR", "dadb"}, {}, {}),
2107 testStrArrayType("1*中_aR", "1*中_aR", {"1*中_aR", "dadb"}, {}, {"1*中_aR", "dadb"})));
2108
2109 /*
2110 * Feature: Intent
2111 * Function: SetStringArrayParam & GetStringArrayParam
2112 * SubFunction: NA
2113 * FunctionPoints: SetStringArrayParam & GetStringArrayParam
2114 * EnvConditions: NA
2115 * CaseDescription: get param when IntentParam is empty
2116 */
2117 HWTEST_F(IntentParametersStringArrayTest, AaFwk_Intent_Parameters_String_Array_001, TestSize.Level1)
2118 {
2119 std::vector<std::string> defaultValue;
2120 std::string key = "aa";
2121 std::vector<std::string> resultValue = intent_->GetStringArrayParam(key);
2122 EXPECT_EQ(defaultValue, resultValue);
2123 }
2124
2125 /*
2126 * Feature: Intent
2127 * Function: SetStringArrayParam & GetStringArrayParam
2128 * SubFunction: NA
2129 * FunctionPoints: SetStringArrayParam & GetStringArrayParam
2130 * EnvConditions: NA
2131 * CaseDescription: set empty-string key repeatedly, but get param of another nonexistent key
2132 */
2133 HWTEST_F(IntentParametersStringArrayTest, AaFwk_Intent_Parameters_String_Array_002, TestSize.Level1)
2134 {
2135 std::vector<std::string> defaultValue;
2136 std::vector<std::string> setValue1 = {"aaa", "2132"};
2137 std::vector<std::string> setValue2 = {"1*中_aR", "dadb"};
2138 std::string key1 = "";
2139 std::string key2 = "aa";
2140 intent_->SetStringArrayParam(key1, setValue1);
2141 intent_->SetStringArrayParam(key1, setValue1);
2142 intent_->SetStringArrayParam(key1, setValue2);
2143 std::vector<std::string> resultValue = intent_->GetStringArrayParam(key2);
2144 EXPECT_EQ(defaultValue, resultValue);
2145
2146 intent_->SetStringArrayParam(key1, setValue1);
2147 resultValue = intent_->GetStringArrayParam(key1);
2148 EXPECT_EQ(setValue1, resultValue);
2149 }
2150
2151 /*
2152 * Feature: Intent
2153 * Function: SetStringArrayParam & GetStringArrayParam
2154 * SubFunction: NA
2155 * FunctionPoints: SetStringArrayParam & GetStringArrayParam
2156 * EnvConditions: NA
2157 * CaseDescription: set empty-string key repeatedly, then get param of the key
2158 */
2159 HWTEST_F(IntentParametersStringArrayTest, AaFwk_Intent_Parameters_String_Array_003, TestSize.Level1)
2160 {
2161 std::vector<std::string> defaultValue;
2162 std::vector<std::string> setValue = {"aaa", "2132"};
2163 std::string key1 = "%1uH3";
2164 std::string key2 = "aa";
2165 intent_->SetStringArrayParam(key1, setValue);
2166 intent_->SetStringArrayParam(key1, setValue);
2167 setValue = {"1*中_aR", "3#$%"};
2168 intent_->SetStringArrayParam(key1, setValue);
2169 std::vector<std::string> resultValue = intent_->GetStringArrayParam(key1);
2170 EXPECT_EQ(setValue, resultValue);
2171
2172 setValue = {"aaa", "2132"};
2173 intent_->SetStringArrayParam(key1, setValue);
2174 resultValue = intent_->GetStringArrayParam(key2);
2175 EXPECT_EQ(defaultValue, resultValue);
2176 }
2177
2178 class IntentParametersHasParamTest : public testing::Test {
2179 public:
IntentParametersHasParamTest()2180 IntentParametersHasParamTest() : intent_(nullptr)
2181 {}
~IntentParametersHasParamTest()2182 ~IntentParametersHasParamTest()
2183 {
2184 intent_ = nullptr;
2185 }
2186 static void SetUpTestCase(void);
2187 static void TearDownTestCase(void);
2188 void SetUp();
2189 void TearDown();
2190 Intent *intent_;
2191 };
2192
SetUpTestCase(void)2193 void IntentParametersHasParamTest::SetUpTestCase(void)
2194 {}
2195
TearDownTestCase(void)2196 void IntentParametersHasParamTest::TearDownTestCase(void)
2197 {}
2198
SetUp(void)2199 void IntentParametersHasParamTest::SetUp(void)
2200 {
2201 intent_ = new (std::nothrow) Intent();
2202 }
2203
TearDown(void)2204 void IntentParametersHasParamTest::TearDown(void)
2205 {
2206 delete intent_;
2207 intent_ = nullptr;
2208 }
2209
2210 /*
2211 * Feature: Intent
2212 * Function: HasParameter
2213 * SubFunction: NA
2214 * FunctionPoints: HasParameter
2215 * EnvConditions: NA
2216 * CaseDescription: verify if parameter exists
2217 */
2218 HWTEST_F(IntentParametersHasParamTest, AaFwk_Intent_Parameters_Has_Parameter_001, TestSize.Level1)
2219 {
2220 std::string keyBool = "keyBool";
2221 std::string keyChar = "keyChar";
2222 std::string keyShort = "keyShort";
2223 std::string keyInt = "keyInt";
2224 std::string keyLong = "keyLong";
2225 std::string keyFloat = "keyFloat";
2226 std::string keyDouble = "keyDouble";
2227 std::string keyString = "keyString";
2228 std::string keyBoolArray = "keyBoolArray";
2229 std::string keyCharArray = "keyCharArray";
2230 std::string keyShortArray = "keyShortArray";
2231 std::string keyIntArray = "keyIntArray";
2232 std::string keyLongArray = "keyLongArray";
2233 std::string keyFloatArray = "keyFloatArray";
2234 std::string keyDoubleArray = "keyDoubleArray";
2235 std::string keyStringArray = "keyStringArray";
2236
2237 std::string keyBoolNotExist = "keyBoolNotExist";
2238 std::string keyCharNotExist = "keyCharNotExist";
2239 std::string keyShortNotExist = "keyShortNotExist";
2240 std::string keyIntNotExist = "keyIntNotExist";
2241 std::string keyLongNotExist = "keyLongNotExist";
2242 std::string keyFloatNotExist = "keyFloatNotExist";
2243 std::string keyDoubleNotExist = "keyDoubleNotExist";
2244 std::string keyStringNotExist = "keyStringNotExist";
2245 std::string keyBoolArrayNotExist = "keyBoolArrayNotExist";
2246 std::string keyCharArrayNotExist = "keyCharArrayNotExist";
2247 std::string keyShortArrayNotExist = "keyShortArrayNotExist";
2248 std::string keyIntArrayNotExist = "keyIntArrayNotExist";
2249 std::string keyLongArrayNotExist = "keyLongArrayNotExist";
2250 std::string keyFloatArrayNotExist = "keyFloatArrayNotExist";
2251 std::string keyDoubleArrayNotExist = "keyDoubleArrayNotExist";
2252 std::string keyStringArrayNotExist = "keyStringArrayNotExist";
2253
2254 bool valueBool = false;
2255 zchar valueChar = 1;
2256 short valueShort = 2;
2257 int valueInt = 3;
2258 long valueLong = 4;
2259 float valueFloat = 5.1;
2260 double valueDouble = 6.2;
2261 std::string valueString = "1*中_aRabc";
2262 std::vector<bool> valueBoolArray = {true, false};
2263 std::vector<zchar> valueCharArray = {1, 2};
2264 std::vector<short> valueShortArray = {3, 4};
2265 std::vector<int> valueIntArray = {5, 6};
2266 std::vector<long> valueLongArray = {7, 8};
2267 std::vector<float> valueFloatArray = {9.1, 10.2};
2268 std::vector<double> valueDoubleArray = {11.3, 12.4};
2269 std::vector<std::string> valueStringArray = {"1*中_aRabc", "1*中_aRpinyin"};
2270
2271 intent_->SetBoolParam(keyBool, valueBool);
2272 intent_->SetCharParam(keyChar, valueChar);
2273 intent_->SetShortParam(keyShort, valueShort);
2274 intent_->SetIntParam(keyInt, valueInt);
2275 intent_->SetLongParam(keyLong, valueLong);
2276 intent_->SetFloatParam(keyFloat, valueFloat);
2277 intent_->SetDoubleParam(keyDouble, valueDouble);
2278 intent_->SetStringParam(keyString, valueString);
2279
2280 intent_->SetBoolArrayParam(keyBoolArray, valueBoolArray);
2281 intent_->SetCharArrayParam(keyCharArray, valueCharArray);
2282 intent_->SetShortArrayParam(keyShortArray, valueShortArray);
2283 intent_->SetIntArrayParam(keyIntArray, valueIntArray);
2284 intent_->SetLongArrayParam(keyLongArray, valueLongArray);
2285 intent_->SetFloatArrayParam(keyFloatArray, valueFloatArray);
2286 intent_->SetDoubleArrayParam(keyDoubleArray, valueDoubleArray);
2287 intent_->SetStringArrayParam(keyStringArray, valueStringArray);
2288
2289 EXPECT_EQ(true, intent_->HasParameter(keyBool));
2290 EXPECT_EQ(true, intent_->HasParameter(keyChar));
2291 EXPECT_EQ(true, intent_->HasParameter(keyShort));
2292 EXPECT_EQ(true, intent_->HasParameter(keyInt));
2293 EXPECT_EQ(true, intent_->HasParameter(keyLong));
2294 EXPECT_EQ(true, intent_->HasParameter(keyFloat));
2295 EXPECT_EQ(true, intent_->HasParameter(keyDouble));
2296 EXPECT_EQ(true, intent_->HasParameter(keyString));
2297 EXPECT_EQ(true, intent_->HasParameter(keyBoolArray));
2298 EXPECT_EQ(true, intent_->HasParameter(keyCharArray));
2299 EXPECT_EQ(true, intent_->HasParameter(keyShortArray));
2300 EXPECT_EQ(true, intent_->HasParameter(keyIntArray));
2301 EXPECT_EQ(true, intent_->HasParameter(keyLongArray));
2302 EXPECT_EQ(true, intent_->HasParameter(keyFloatArray));
2303 EXPECT_EQ(true, intent_->HasParameter(keyDoubleArray));
2304 EXPECT_EQ(true, intent_->HasParameter(keyStringArray));
2305
2306 EXPECT_EQ(false, intent_->HasParameter(keyBoolNotExist));
2307 EXPECT_EQ(false, intent_->HasParameter(keyCharNotExist));
2308 EXPECT_EQ(false, intent_->HasParameter(keyShortNotExist));
2309 EXPECT_EQ(false, intent_->HasParameter(keyIntNotExist));
2310 EXPECT_EQ(false, intent_->HasParameter(keyLongNotExist));
2311 EXPECT_EQ(false, intent_->HasParameter(keyFloatNotExist));
2312 EXPECT_EQ(false, intent_->HasParameter(keyDoubleNotExist));
2313 EXPECT_EQ(false, intent_->HasParameter(keyStringNotExist));
2314 EXPECT_EQ(false, intent_->HasParameter(keyBoolArrayNotExist));
2315 EXPECT_EQ(false, intent_->HasParameter(keyCharArrayNotExist));
2316 EXPECT_EQ(false, intent_->HasParameter(keyShortArrayNotExist));
2317 EXPECT_EQ(false, intent_->HasParameter(keyIntArrayNotExist));
2318 EXPECT_EQ(false, intent_->HasParameter(keyLongArrayNotExist));
2319 EXPECT_EQ(false, intent_->HasParameter(keyFloatArrayNotExist));
2320 EXPECT_EQ(false, intent_->HasParameter(keyDoubleArrayNotExist));
2321 EXPECT_EQ(false, intent_->HasParameter(keyStringArrayNotExist));
2322 }
2323