• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023-2025 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 "resource_manager_test_hap.h"
17 
18 #include "resource_manager_test_common.h"
19 
20 using namespace OHOS::Global::Resource;
21 using namespace testing::ext;
22 namespace {
23 static constexpr uint32_t DATA_ALL_HAP_LIMIT_KEYS = 1503;
24 static constexpr uint32_t SYSTEM_RES_LIMIT_KEYS = 1503;
25 class ResourceManagerTestHap : public testing::Test {
26 public:
27     static void SetUpTestCase(void);
28 
29     static void TearDownTestCase(void);
30 
31     void SetUp();
32 
33     void TearDown();
34 
ResourceManagerTestHap()35     ResourceManagerTestHap() : rm(nullptr)
36     {}
37 
~ResourceManagerTestHap()38     ~ResourceManagerTestHap()
39     {}
40 public:
41     ResourceManager *rm;
42     ResourceManagerTestCommon *rmc;
43 };
44 
SetUpTestCase(void)45 void ResourceManagerTestHap::SetUpTestCase(void)
46 {
47     // step 1: input testsuit setup step
48     g_logLevel = LOG_DEBUG;
49 }
50 
TearDownTestCase(void)51 void ResourceManagerTestHap::TearDownTestCase(void)
52 {
53     // step 2: input testsuit teardown step
54 }
55 
SetUp(void)56 void ResourceManagerTestHap::SetUp(void)
57 {
58     this->rm = CreateResourceManager();
59     this->rmc = new ResourceManagerTestCommon(rm);
60 }
61 
TearDown(void)62 void ResourceManagerTestHap::TearDown(void)
63 {
64     delete this->rm;
65     delete this->rmc;
66 }
67 
68 /*
69  * @tc.name: ResourceManagerAddResourceFromHapTest001
70  * @tc.desc: Test AddResource function
71  * @tc.type: FUNC
72  * @tc.require: issueI5LHLP
73  */
74 HWTEST_F(ResourceManagerTestHap, ResourceManagerAddResourceFromHapTest001, TestSize.Level1)
75 {
76     // error cases
77     // file not exist
78     bool ret = rm->AddResource("/data/test/do_not_exist.hap");
79     ASSERT_TRUE(!ret);
80 }
81 
82 /*
83  * @tc.name: ResourceManagerGetStringByIdFromHapTest002
84  * @tc.desc: Test GetStringById function
85  * @tc.type: FUNC
86  * @tc.require: issueI5LHLP
87  */
88 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetStringByIdFromHapTest002, TestSize.Level1)
89 {
90     rmc->AddHapResource("en", nullptr, "US");
91 
92     rmc->TestStringById("app_name", "App Name");
93     rmc->TestStringById("copyright_text", "XXXXXX All rights reserved. ©2011-2019");
94 }
95 
96 /*
97  * @tc.name: ResourceManagerGetStringByIdFromHapTest003
98  * @tc.desc: Test GetStringById function
99  * @tc.type: FUNC
100  * @tc.require: issueI5LHLP
101  */
102 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetStringByIdFromHapTest003, TestSize.Level1)
103 {
104     rmc->AddHapResource("zh", nullptr, nullptr);
105 
106     rmc->TestStringById("app_name", "应用名称");
107     rmc->TestStringById("copyright_text", "版权所有 ©2011-2019 XXXX有限公司保留一切权利");
108 }
109 
110 /*
111  * @tc.name: ResourceManagerGetStringByNameFromHapTest004
112  * @tc.desc: Test GetStringByName function
113  * @tc.type: FUNC
114  * @tc.require: issueI5LHLP
115  */
116 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetStringByNameFromHapTest004, TestSize.Level1)
117 {
118     rmc->AddHapResource("en", nullptr, nullptr);
119 
120     rmc->TestStringByName("app_name", "App Name");
121     rmc->TestStringByName("copyright_text", "XXXXXX All rights reserved. ©2011-2019");
122 }
123 
124 /*
125  * @tc.name: ResourceManagerGetStringByNameFromHapTest005
126  * @tc.desc: Test GetStringByName function
127  * @tc.type: FUNC
128  * @tc.require: issueI5LHLP
129  */
130 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetStringByNameFromHapTest005, TestSize.Level1)
131 {
132     rmc->AddHapResource("zh", nullptr, nullptr);
133 
134     rmc->TestStringByName("app_name", "应用名称");
135     rmc->TestStringByName("copyright_text", "版权所有 ©2011-2019 XXXX有限公司保留一切权利");
136 }
137 
138 /*
139  * @tc.name: ResourceManagerGetStringFormatByIdFromHapTest006
140  * @tc.desc: Test GetStringFormatById function
141  * @tc.type: FUNC
142  * @tc.require: issueI5LHLP
143  */
144 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetStringFormatByIdFromHapTest006, TestSize.Level1)
145 {
146     rmc->AddHapResource("zh", nullptr, nullptr);
147 
148     rmc->TestGetStringFormatById("app_name", "应用名称");
149 }
150 
151 
152 /*
153  * @tc.name: ResourceManagerGetStringFormatByNameFromHapTest007
154  * @tc.desc: Test GetStringFormatByName function
155  * @tc.type: FUNC
156  * @tc.require: issueI5LHLP
157  */
158 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetStringFormatByNameFromHapTest007, TestSize.Level1)
159 {
160     rmc->AddHapResource("zh", nullptr, nullptr);
161 
162     rmc->TestGetStringFormatByName("app_name", "应用名称");
163 }
164 
165 /*
166  * @tc.name: ResourceManagerGetStringArrayByIdFromHapTest008
167  * @tc.desc: Test GetStringArrayById function
168  * @tc.type: FUNC
169  * @tc.require: issueI5LHLP
170  */
171 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetStringArrayByIdFromHapTest008, TestSize.Level1)
172 {
173     rmc->AddHapResource("zh", nullptr, nullptr);
174 
175     rmc->TestGetStringArrayById("size");
176 }
177 
178 /*
179  * @tc.name: ResourceManagerGetStringArrayByNameFromHapTest009
180  * @tc.desc: Test GetStringArrayByName function
181  * @tc.type: FUNC
182  * @tc.require: issueI5LHLP
183  */
184 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetStringArrayByNameFromHapTest009, TestSize.Level1)
185 {
186     rmc->AddHapResource("zh", nullptr, nullptr);
187 
188     rmc->TestGetStringArrayByName("size");
189 }
190 
191 /*
192  * @tc.name: ResourceManagerGetPatternByIdFromHapTest0010
193  * @tc.desc: Test GetPatternById function
194  * @tc.type: FUNC
195  * @tc.require: issueI5LHLP
196  */
197 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetPatternByIdFromHapTest0010, TestSize.Level1)
198 {
199     rmc->AddHapResource("zh", nullptr, nullptr);
200     rmc->TestGetPatternById("base");
201 }
202 
203 /*
204  * @tc.name: ResourceManagerGetPatternByNameFromHapTest0011
205  * @tc.desc: Test GetPatternByName function
206  * @tc.type: FUNC
207  * @tc.require: issueI5LHLP
208  */
209 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetPatternByNameFromHapTest0011, TestSize.Level1)
210 {
211     rmc->AddHapResource("zh", nullptr, nullptr);
212     rmc->TestGetPatternByName("base");
213 }
214 
215 /*
216  * @tc.name: ResourceManagerGetPluralStringByIdFromHapTest0012
217  * @tc.desc: Test GetPluralStringById function
218  * @tc.type: FUNC
219  * @tc.require: issueI5LHLP
220  */
221 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetPluralStringByIdFromHapTest0012, TestSize.Level1)
222 {
223     rmc->AddHapResource("en", nullptr, "US");
224 
225     int quantity = 1;
226     rmc->TestPluralStringById(quantity, "%d apple", false);
227     quantity = 101;
228     rmc->TestPluralStringById(quantity, "%d apples", false);
229 }
230 
231 /*
232  * @tc.name: ResourceManagerGetPluralStringByIdFromHapTest0013
233  * @tc.desc: Test GetPluralStringById function
234  * @tc.type: FUNC
235  * @tc.require: issueI5LHLP
236  */
237 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetPluralStringByIdFromHapTest0013, TestSize.Level1)
238 {
239     rmc->AddHapResource("zh", nullptr, "CN");
240 
241     int quantity = 1;
242     rmc->TestPluralStringById(quantity, "%d apples", false);
243     quantity = 101;
244     rmc->TestPluralStringById(quantity, "%d apples", false);
245 }
246 
247 /*
248  * @tc.name: ResourceManagerGetPluralStringByIdFromHapTest0014
249  * @tc.desc: Test GetPluralStringById function
250  * @tc.type: FUNC
251  * @tc.require: issueI5LHLP
252  */
253 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetPluralStringByIdFromHapTest0014, TestSize.Level1)
254 {
255     rmc->AddHapResource("ar", nullptr, "SA");
256 
257     int quantity = 0;
258     rmc->TestPluralStringById(quantity, "zero-0");
259     quantity = 1;
260     rmc->TestPluralStringById(quantity, "one-1");
261     quantity = 5;
262     rmc->TestPluralStringById(quantity, "few-%d");
263     quantity = 500;
264     rmc->TestPluralStringById(quantity, "other-%d");
265 }
266 
267 /*
268  * @tc.name: ResourceManagerGetPluralStringByIdFromHapTest0015
269  * @tc.desc: Test GetPluralStringById function
270  * @tc.type: FUNC
271  * @tc.require: issueI5LHLP
272  */
273 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetPluralStringByIdFromHapTest0015, TestSize.Level1)
274 {
275     rmc->AddHapResource("pl", nullptr, "PL");
276 
277     int quantity = 1;
278     rmc->TestPluralStringById(quantity, "1 jabłko");
279     quantity = 2;
280     rmc->TestPluralStringById(quantity, "%d jabłka");
281 }
282 
283 /*
284  * @tc.name: ResourceManagerGetPluralStringByNameFromHapTest0016
285  * @tc.desc: Test GetPluralStringByName function
286  * @tc.type: FUNC
287  * @tc.require: issueI5LHLP
288  */
289 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetPluralStringByNameFromHapTest0016, TestSize.Level1)
290 {
291     rmc->AddHapResource("en", nullptr, "US");
292 
293     int quantity = 1;
294     rmc->TestPluralStringByName(quantity, "%d apple", false);
295     quantity = 101;
296     rmc->TestPluralStringByName(quantity, "%d apples", false);
297 }
298 
299 /*
300  * @tc.name: ResourceManagerGetPluralStringByIdFormatFromHapTest0017
301  * @tc.desc: Test GetPluralStringById function
302  * @tc.type: FUNC
303  * @tc.require: issueI5LHLP
304  */
305 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetPluralStringByIdFormatFromHapTest0017, TestSize.Level1)
306 {
307     rmc->AddHapResource("zh", nullptr, "CN");
308 
309     int quantity = 1;
310     rmc->TestPluralStringById(quantity, "1 apples", true);
311     quantity = 101;
312     rmc->TestPluralStringById(quantity, "101 apples", true);
313 }
314 
315 /*
316  * @tc.name: ResourceManagerGetPluralStringByNameFormatFromHapTest0018
317  * @tc.desc: Test GetPluralStringByName function
318  * @tc.type: FUNC
319  * @tc.require: issueI5LHLP
320  */
321 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetPluralStringByNameFormatFromHapTest0018, TestSize.Level1)
322 {
323     rmc->AddHapResource("zh", nullptr, "CN");
324 
325     int quantity = 1;
326     rmc->TestPluralStringByName(quantity, "1 apples", true);
327     quantity = 101;
328     rmc->TestPluralStringByName(quantity, "101 apples", true);
329 }
330 
331 /*
332  * @tc.name: ResourceManagerGetThemeByIdFromHapTest0019
333  * @tc.desc: Test GetThemeById
334  * @tc.type: FUNC
335  * @tc.require: issueI5LHLP
336  */
337 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetThemeByIdFromHapTest0019, TestSize.Level1)
338 {
339     rmc->AddHapResource("zh", nullptr, "CN");
340 
341     rmc->TestGetThemeById("app_theme");
342 }
343 
344 /*
345  * @tc.name: ResourceManagerGetThemeByNameFromHapTest0020
346  * @tc.desc: Test GetThemeByName
347  * @tc.type: FUNC
348  * @tc.require: issueI5LHLP
349  */
350 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetThemeByNameFromHapTest0020, TestSize.Level1)
351 {
352     rmc->AddHapResource("zh", nullptr, "CN");
353 
354     rmc->TestGetThemeByName("app_theme", "test_theme");
355 }
356 
357 /*
358  * @tc.name: ResourceManagerGetBooleanByIdFromHapTest0021
359  * @tc.desc: Test GetBooleanById
360  * @tc.type: FUNC
361  * @tc.require: issueI5LHLP
362  */
363 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetBooleanByIdFromHapTest0021, TestSize.Level1)
364 {
365     rmc->AddHapResource("zh", nullptr, "CN");
366 
367     rmc->TestGetBooleanById("boolean_1", "boolean_ref");
368 }
369 
370 /*
371  * @tc.name: ResourceManagerGetBooleanByNameFromHapTest0022
372  * @tc.desc: Test GetBooleanByName
373  * @tc.type: FUNC
374  * @tc.require: issueI5LHLP
375  */
376 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetBooleanByNameFromHapTest0022, TestSize.Level1)
377 {
378     rmc->AddHapResource("zh", nullptr, "CN");
379 
380     rmc->TestGetBooleanByName("boolean_1", "boolean_ref");
381 }
382 
383 /*
384  * @tc.name: ResourceManagerGetIntegerByIdFromHapTest0023
385  * @tc.desc: Test GetIntegerById
386  * @tc.type: FUNC
387  * @tc.require: issueI5LHLP
388  */
389 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetIntegerByIdFromHapTest0023, TestSize.Level1)
390 {
391     rmc->AddHapResource("zh", nullptr, "CN");
392 
393     rmc->TestGetIntegerById("integer_1", "integer_ref");
394 }
395 
396 /*
397  * @tc.name: ResourceManagerGetIntegerByNameFromHapTest0024
398  * @tc.desc: Test GetIntegerByName
399  * @tc.type: FUNC
400  * @tc.require: issueI5LHLP
401  */
402 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetIntegerByNameFromHapTest0024, TestSize.Level1)
403 {
404     rmc->AddHapResource("zh", nullptr, "CN");
405 
406     rmc->TestGetIntegerByName("integer_1", "integer_ref");
407 }
408 
409 /*
410  * @tc.name: ResourceManagerGetFloatByIdFromHapTest0025
411  * @tc.desc: Test GetFloatById
412  * @tc.type: FUNC
413  * @tc.require: issueI5LHLP
414  */
415 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetFloatByIdFromHapTest0025, TestSize.Level1)
416 {
417     rmc->AddHapResource("zh", nullptr, "CN");
418 
419     rmc->TestGetFloatById("width_appBar_backButton_touchTarget", "float_ref");
420 }
421 
422 /*
423  * @tc.name: ResourceManagerGetFloatByNameFromHapTest0026
424  * @tc.desc: Test GetFloatByName
425  * @tc.type: FUNC
426  * @tc.require: issueI5LHLP
427  */
428 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetFloatByNameFromHapTest0026, TestSize.Level1)
429 {
430     rmc->AddHapResource("zh", nullptr, "CN");
431 
432     rmc->TestGetFloatByName("width_appBar_backButton_touchTarget", "float_ref");
433 }
434 
435 /*
436  * @tc.name: ResourceManagerGetIntArrayByIdFromHapTest0027
437  * @tc.desc: Test GetIntArrayById
438  * @tc.type: FUNC
439  * @tc.require: issueI5LHLP
440  */
441 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetIntArrayByIdFromHapTest0027, TestSize.Level1)
442 {
443     rmc->AddHapResource("zh", nullptr, "CN");
444 
445     rmc->TestGetIntArrayById("intarray_1");
446 }
447 
448 /*
449  * @tc.name: ResourceManagerGetIntArrayByNameFromHapTest0028
450  * @tc.desc: Test GetIntArrayByName
451  * @tc.type: FUNC
452  * @tc.require: issueI5LHLP
453  */
454 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetIntArrayByNameFromHapTest0028, TestSize.Level1)
455 {
456     rmc->AddHapResource("zh", nullptr, "CN");
457 
458     rmc->TestGetIntArrayByName("intarray_1");
459 }
460 
461 /*
462  * @tc.name: ResourceManagerGetProfileByIdFromHapTest0029
463  * @tc.desc: Test GetProfileById
464  * @tc.type: FUNC
465  * @tc.require: issueI5LHLP
466  */
467 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetProfileByIdFromHapTest0029, TestSize.Level1)
468 {
469     rmc->AddHapResource("zh", nullptr, "CN");
470 
471     HapResourceV1 *tmp = new HapResourceV1(FormatFullPath(g_hapPath).c_str(), 0, nullptr);
472     rmc->TestGetProfileById(tmp);
473     delete tmp;
474 }
475 
476 /*
477  * @tc.name: ResourceManagerGetProfileByNameFromHapTest0030
478  * @tc.desc: Test GetProfileByName
479  * @tc.type: FUNC
480  * @tc.require: issueI5LHLP
481  */
482 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetProfileByNameFromHapTest0030, TestSize.Level1)
483 {
484     rmc->AddHapResource("zh", nullptr, "CN");
485 
486     HapResourceV1 *tmp = new HapResourceV1(FormatFullPath(g_hapPath).c_str(), 0, nullptr);
487     rmc->TestGetProfileByName(tmp);
488     delete tmp;
489 }
490 
491 /*
492  * @tc.name: ResourceManagerGetMediaByIdFromHapTest0031
493  * @tc.desc: Test GetMediaById
494  * @tc.type: FUNC
495  * @tc.require: issueI5LHLP
496  */
497 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetMediaByIdFromHapTest0031, TestSize.Level1)
498 {
499     rmc->AddHapResource("zh", nullptr, "CN");
500 
501     HapResourceV1 *tmp = new HapResourceV1(FormatFullPath(g_hapPath).c_str(), 0, nullptr);
502     rmc->TestGetMediaById(tmp);
503     delete tmp;
504 }
505 
506 /*
507  * @tc.name: ResourceManagerGetMediaByIdFromHapTest0032
508  * @tc.desc: Test GetMediaById, to match sdpi determinder
509  * @tc.type: FUNC
510  * @tc.require: issueI5LHLP
511  */
512 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetMediaByIdFromHapTest0032, TestSize.Level1)
513 {
514     rmc->AddHapResource("en", nullptr, "US");
515 
516     HapResourceV1 *tmp = new HapResourceV1(FormatFullPath(g_hapPath).c_str(), 0, nullptr);
517     rmc->TestGetMediaWithDensityById(tmp);
518     delete tmp;
519 }
520 
521 /*
522  * @tc.name: ResourceManagerGetMediaByNameFromHapTest0033
523  * @tc.desc: Test GetMediaByName
524  * @tc.type: FUNC
525  * @tc.require: issueI5LHLP
526  */
527 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetMediaByNameFromHapTest0033, TestSize.Level1)
528 {
529     rmc->AddHapResource("zh", nullptr, "CN");
530 
531     HapResourceV1 *tmp = new HapResourceV1(FormatFullPath(g_hapPath).c_str(), 0, nullptr);
532     rmc->TestGetMediaByName(tmp);
533     delete tmp;
534 }
535 
536 /*
537  * @tc.name: ResourceManagerGetMediaByNameFromHapTest0034
538  * @tc.desc: Test GetMediaByName, to match sdpi determinder
539  * @tc.type: FUNC
540  * @tc.require: issueI5LHLP
541  */
542 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetMediaByNameFromHapTest0034, TestSize.Level1)
543 {
544     rmc->AddHapResource("en", nullptr, "US");
545 
546     HapResourceV1 *tmp = new HapResourceV1(FormatFullPath(g_hapPath).c_str(), 0, nullptr);
547     rmc->TestGetMediaWithDensityByName(tmp);
548     delete tmp;
549 }
550 
551 /*
552  * @tc.name: ResourceManagerGetProfileDataByIdFromHapTest0035
553  * @tc.desc: Test GetProfileDataByName
554  * @tc.type: FUNC
555  * @tc.require: issueI5LHLP
556  */
557 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetProfileDataByIdFromHapTest0035, TestSize.Level1)
558 {
559     rmc->AddHapResource("zh", nullptr, "CN");
560 
561     std::unique_ptr<uint8_t[]> outValue;
562     int id = rmc->GetResId("test_profile", ResType::PROF);
563     EXPECT_TRUE(id > 0);
564     size_t len;
565     RState state = rm->GetProfileDataById(id, len, outValue);
566     EXPECT_TRUE(state == SUCCESS);
567 }
568 
569 /*
570  * @tc.name: ResourceManagerGetProfileDataByNameFromHapTest0036
571  * @tc.desc: Test GetProfileDataByName
572  * @tc.type: FUNC
573  * @tc.require: issueI5LHLP
574  */
575 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetProfileDataByNameFromHapTest0036, TestSize.Level1)
576 {
577     rmc->AddHapResource("zh", nullptr, "CN");
578 
579     std::unique_ptr<uint8_t[]> outValue;
580     size_t len;
581     RState state = rm->GetProfileDataByName("test_profile", len, outValue);
582     EXPECT_TRUE(state == SUCCESS);
583 }
584 
585 /*
586  * @tc.name: ResourceManagerGetMediaDataByNameFromHapTest0037
587  * @tc.desc: Test GetMediaDataByName
588  * @tc.type: FUNC
589  * @tc.require: issueI5LHLP
590  */
591 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetMediaDataByNameFromHapTest0037, TestSize.Level1)
592 {
593     rmc->AddHapResource("zh", nullptr, "CN");
594 
595     std::unique_ptr<uint8_t[]> outValue;
596     RState state;
597     size_t len;
598     state = rm->GetMediaDataByName("icon1", len, outValue);
599     EXPECT_EQ(len, static_cast<size_t>(5997)); // the length of icon1
600     EXPECT_TRUE(state == SUCCESS);
601 }
602 
603 /*
604  * @tc.name: ResourceManagerGetMediaDataByIdFromHapTest0038
605  * @tc.desc: Test GetMediaDataById
606  * @tc.type: FUNC
607  * @tc.require: issueI5LHLP
608  */
609 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetMediaDataByIdFromHapTest0038, TestSize.Level1)
610 {
611     rmc->AddHapResource("zh", nullptr, "CN");
612 
613     std::unique_ptr<uint8_t[]> outValue;
614     RState state;
615     int id = rmc->GetResId("icon1", ResType::MEDIA);
616     EXPECT_TRUE(id > 0);
617     size_t len;
618     state = rm->GetMediaDataById(id, len, outValue);
619     EXPECT_EQ(len, static_cast<size_t>(5997)); // the length of icon1
620     EXPECT_TRUE(state == SUCCESS);
621 }
622 
623 /*
624  * @tc.name: ResourceManagerGetMediaDataBase64ByNameFromHapTest0039
625  * @tc.desc: Test GetMediaBase64DataByName
626  * @tc.type: FUNC
627  * @tc.require: issueI5LHLP
628  */
629 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetMediaDataBase64ByNameFromHapTest0039, TestSize.Level1)
630 {
631     rmc->AddHapResource("zh", nullptr, "CN");
632 
633     std::string outValue;
634     RState state;
635     state = rm->GetMediaBase64DataByName("icon1", outValue);
636     EXPECT_TRUE(state == SUCCESS);
637 }
638 
639 /*
640  * @tc.name: ResourceManagerGetMediaDataBase64ByIdFromHapTest0040
641  * @tc.desc: Test GetMediaDataBase64ById
642  * @tc.type: FUNC
643  * @tc.require: issueI5LHLP
644  */
645 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetMediaDataBase64ByIdFromHapTest0040, TestSize.Level1)
646 {
647     rmc->AddHapResource("zh", nullptr, "CN");
648 
649     std::string outValue;
650     int id = rmc->GetResId("icon1", ResType::MEDIA);
651     EXPECT_TRUE(id > 0);
652     RState state;
653     state = rm->GetMediaBase64DataById(id, outValue);
654     EXPECT_TRUE(state == SUCCESS);
655 }
656 
657 /*
658  * @tc.name: ResourceManagerGetMediaDataByIdFromHapTest0041
659  * @tc.desc: Test GetMediaDataById, to match sdpi determinder
660  * @tc.type: FUNC
661  * @tc.require: issueI5LHLP
662  */
663 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetMediaDataByIdFromHapTest0041, TestSize.Level1)
664 {
665     rmc->AddHapResource("zh", nullptr, "CN");
666 
667     auto rc = CreateResConfig();
668     if (rc == nullptr) {
669         ASSERT_TRUE(false);
670     }
671     rc->SetDeviceType(DEVICE_TV);
672     rc->SetColorMode(COLOR_MODE_NOT_SET);
673     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
674     rm->UpdateResConfig(*rc);
675     delete rc;
676 
677     int density = 120;
678     std::unique_ptr<uint8_t[]> outValue;
679     RState state;
680     int id = rmc->GetResId("icon", ResType::MEDIA);
681     EXPECT_TRUE(id > 0);
682     size_t len;
683     state = rm->GetMediaDataById(id, len, outValue, density);
684     EXPECT_EQ(static_cast<int>(len), 6790); // the length of icon
685     EXPECT_TRUE(state == SUCCESS);
686 
687     density = 1; // invalid density
688     size_t len2;
689     state = rm->GetMediaDataById(id, len2, outValue, density);
690     EXPECT_EQ(static_cast<int>(len2), 0);
691     EXPECT_TRUE(state == ERROR_CODE_INVALID_INPUT_PARAMETER);
692 }
693 
694 /*
695  * @tc.name: ResourceManagerGetMediaDataByNameFromHapTest0042
696  * @tc.desc: Test GetMediaBase64DataByName, to match sdpi determinder
697  * @tc.type: FUNC
698  * @tc.require: issueI5LHLP
699  */
700 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetMediaDataByNameFromHapTest0042, TestSize.Level1)
701 {
702     rmc->AddHapResource("zh", nullptr, "CN");
703 
704     auto rc = CreateResConfig();
705     if (rc == nullptr) {
706         ASSERT_TRUE(false);
707     }
708     rc->SetDeviceType(DEVICE_TV);
709     rc->SetColorMode(COLOR_MODE_NOT_SET);
710     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
711     rm->UpdateResConfig(*rc);
712     delete rc;
713 
714     int density = 120;
715     std::unique_ptr<uint8_t[]> outValue;
716     RState state;
717     size_t len;
718     state = rm->GetMediaDataByName("icon", len, outValue, density);
719     EXPECT_EQ(static_cast<int>(len), 6790); // the length of icon
720     EXPECT_TRUE(state == SUCCESS);
721 
722     density = 1; // invalid density
723     size_t len2;
724     state = rm->GetMediaDataByName("icon", len2, outValue, density);
725     EXPECT_EQ(static_cast<int>(len2), 0);
726     EXPECT_TRUE(state == ERROR_CODE_INVALID_INPUT_PARAMETER);
727 }
728 
729 /*
730  * @tc.name: ResourceManagerGetMediaBase64DataByIdFromHapTest0043
731  * @tc.desc: Test GetMediaBase64DataById, to match sdpi determinder
732  * @tc.type: FUNC
733  * @tc.require: issueI5LHLP
734  */
735 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetMediaBase64DataByIdFromHapTest0043, TestSize.Level1)
736 {
737     rmc->AddHapResource("zh", nullptr, "CN");
738 
739     auto rc = CreateResConfig();
740     if (rc == nullptr) {
741         ASSERT_TRUE(false);
742     }
743     rc->SetDeviceType(DEVICE_TV);
744     rc->SetColorMode(COLOR_MODE_NOT_SET);
745     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
746     rm->UpdateResConfig(*rc);
747     delete rc;
748 
749     int density = 120;
750     std::string outValue;
751     RState state;
752     int id = rmc->GetResId("icon", ResType::MEDIA);
753     EXPECT_TRUE(id > 0);
754     state = rm->GetMediaBase64DataById(id, outValue, density);
755     EXPECT_TRUE(state == SUCCESS);
756 
757     density = 1; // invalid density
758     state = rm->GetMediaBase64DataById(id, outValue, density);
759     EXPECT_TRUE(state == ERROR_CODE_INVALID_INPUT_PARAMETER);
760 }
761 
762 /*
763  * @tc.name: ResourceManagerGetMediaBase64DataByNameFromHapTest0044
764  * @tc.desc: Test GetMediaDataById, to match sdpi determinder
765  * @tc.type: FUNC
766  * @tc.require: issueI5LHLP
767  */
768 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetMediaBase64DataByNameFromHapTest0044, TestSize.Level1)
769 {
770     rmc->AddHapResource("zh", nullptr, "CN");
771 
772     auto rc = CreateResConfig();
773     if (rc == nullptr) {
774         ASSERT_TRUE(false);
775     }
776     rc->SetDeviceType(DEVICE_TV);
777     rc->SetColorMode(COLOR_MODE_NOT_SET);
778     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
779     rm->UpdateResConfig(*rc);
780     delete rc;
781 
782     int density = 120;
783     std::string outValue;
784     RState state;
785     state = rm->GetMediaBase64DataByName("icon", outValue, density);
786     EXPECT_TRUE(state == SUCCESS);
787 
788     density = 1; // invalid density
789     state = rm->GetMediaBase64DataByName("icon", outValue, density);
790     EXPECT_TRUE(state == ERROR_CODE_INVALID_INPUT_PARAMETER);
791 }
792 
793 /*
794  * test get raw file path interface
795  * @tc.name: RawFileTestFromHap0045
796  * @tc.desc: Test GetRawFileFromHap & AddResource function, file case.
797  * @tc.type: FUNC
798  * @tc.require: issueI5LHLP
799  */
800 HWTEST_F(ResourceManagerTestHap, RawFileTestFromHap0045, TestSize.Level1)
801 {
802     bool ret = rm->AddResource(FormatFullPath(g_hapPath).c_str());
803     EXPECT_TRUE(ret);
804     RState state;
805     size_t len;
806     std::unique_ptr<uint8_t[]> outValue;
807     state = rm->GetRawFileFromHap("test_rawfile.txt", len, outValue);
808     ASSERT_EQ(static_cast<int>(len), 17); // 17 means the length of "for raw file test" in "test_rawfile.txt"
809     EXPECT_TRUE(state == SUCCESS);
810 
811     size_t len2;
812     std::unique_ptr<uint8_t[]> outValue2;
813     state = rm->GetRawFileFromHap("rawfile/test_rawfile.txt", len2, outValue2);
814     ASSERT_EQ(static_cast<int>(len2), 17); // 17 means the length of "for raw file test" in "test_rawfile.txt"
815     EXPECT_TRUE(state == SUCCESS);
816 }
817 
818 /*
819  * test get raw file path interface
820  * @tc.name: RawFileTestFromHap0046
821  * @tc.desc: Test GetRawFileFromHap & AddResource function, file case.
822  * @tc.type: FUNC
823  * @tc.require: issueI5LHLP
824  */
825 HWTEST_F(ResourceManagerTestHap, RawFileTestFromHap0046, TestSize.Level1)
826 {
827     bool ret = rm->AddResource(FormatFullPath(g_hapPath).c_str());
828     EXPECT_TRUE(ret);
829     ResourceManager::RawFileDescriptor descriptor;
830     RState state;
831     state = rm->GetRawFileDescriptorFromHap("test_rawfile.txt", descriptor);
832     EXPECT_TRUE(state == SUCCESS);
833     ASSERT_EQ(descriptor.length, 17); // 17 means the length of test_rawfile.txt after compressed
834     state = rm->CloseRawFileDescriptor("test_rawfile.txt");
835     EXPECT_TRUE(state == SUCCESS);
836 
837     state = rm->GetRawFileDescriptorFromHap("rawfile/test_rawfile.txt", descriptor);
838     EXPECT_TRUE(state == SUCCESS);
839     ASSERT_EQ(descriptor.length, 17); // 17 means the length of test_rawfile.txt after compressed
840     state = rm->CloseRawFileDescriptor("rawfile/test_rawfile.txt");
841     EXPECT_TRUE(state == SUCCESS);
842 
843     state = rm->CloseRawFileDescriptor("noexist.txt");
844     EXPECT_EQ(state, ERROR_CODE_RES_PATH_INVALID);
845 }
846 
847 /*
848  * test get raw file path interface
849  * @tc.name: RawFileTestFromHap0047
850  * @tc.desc: Test GetRawFileFromHap & AddResource function, file case.
851  * @tc.type: FUNC
852  * @tc.require: issueI5LHLP
853  */
854 HWTEST_F(ResourceManagerTestHap, RawFileTestFromHap0047, TestSize.Level1)
855 {
856     rm->AddResource(FormatFullPath(g_resFilePath).c_str());
857     size_t len;
858     std::unique_ptr<uint8_t[]> outValue;
859     RState state = rm->GetRawFileFromHap("test_rawfile.txt", len, outValue);
860     ASSERT_EQ(static_cast<int>(len), 17); // 17 means the length of "for raw file test" in "test_rawfile.txt"
861     EXPECT_TRUE(state == SUCCESS);
862 }
863 
864 /*
865  * test get raw file path interface
866  * @tc.name: RawFileTestFromHap0048
867  * @tc.desc: Test GetRawFileDescriptorFromHap & AddResource function, file case.
868  * @tc.type: FUNC
869  * @tc.require: issueI5LHLP
870  */
871 HWTEST_F(ResourceManagerTestHap, RawFileTestFromHap0048, TestSize.Level1)
872 {
873     rm->AddResource(FormatFullPath(g_resFilePath).c_str());
874     std::unique_ptr<uint8_t[]> outValue;
875     ResourceManager::RawFileDescriptor descriptor;
876     RState state;
877     state = rm->GetRawFileDescriptorFromHap("test_rawfile.txt", descriptor);
878     ASSERT_EQ(descriptor.length, 17);
879     EXPECT_TRUE(state == SUCCESS);
880 }
881 
882 /*
883  * @tc.name: ResourceManagerGetProfileByIdFromHapTest0049
884  * @tc.desc: Test GetProfileById
885  * @tc.type: FUNC
886  * @tc.require: issueI5LHLP
887  */
888 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetProfileByIdFromHapTest0049, TestSize.Level1)
889 {
890     rmc->AddHapResource("zh", nullptr, "CN");
891 
892     HapResourceV2 *tmp = new HapResourceV2(FormatFullPath(g_newModuleHapPath).c_str(), 0);
893     rmc->TestGetProfileById(tmp);
894     delete tmp;
895 }
896 
897 /*
898  * @tc.name: ResourceManagerGetProfileByNameFromHapTest0050
899  * @tc.desc: Test GetProfileByName
900  * @tc.type: FUNC
901  * @tc.require: issueI5LHLP
902  */
903 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetProfileByNameFromHapTest0050, TestSize.Level1)
904 {
905     rmc->AddHapResource("zh", nullptr, "CN");
906 
907     HapResourceV2 *tmp = new HapResourceV2(FormatFullPath(g_newModuleHapPath).c_str(), 0);
908     rmc->TestGetProfileByName(tmp);
909     delete tmp;
910 }
911 
912 /*
913  * @tc.name: ResourceManagerGetMediaByIdFromHapTest0051
914  * @tc.desc: Test GetMediaById
915  * @tc.type: FUNC
916  * @tc.require: issueI5LHLP
917  */
918 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetMediaByIdFromHapTest0051, TestSize.Level1)
919 {
920     rmc->AddHapResource("zh", nullptr, "CN");
921 
922     HapResourceV2 *tmp = new HapResourceV2(FormatFullPath(g_newModuleHapPath).c_str(), 0);
923     rmc->TestGetMediaById(tmp);
924     delete tmp;
925 }
926 
927 /*
928  * @tc.name: ResourceManagerGetMediaByIdFromHapTest0052
929  * @tc.desc: Test GetMediaById, to match sdpi determinder
930  * @tc.type: FUNC
931  * @tc.require: issueI5LHLP
932  */
933 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetMediaByIdFromHapTest0052, TestSize.Level1)
934 {
935     rmc->AddHapResource("en", nullptr, "US");
936 
937     HapResourceV2 *tmp = new HapResourceV2(FormatFullPath(g_newModuleHapPath).c_str(), 0);
938     rmc->TestGetMediaWithDensityById(tmp);
939     delete tmp;
940 }
941 
942 /*
943  * @tc.name: ResourceManagerGetMediaByNameFromHapTest0053
944  * @tc.desc: Test GetMediaByName
945  * @tc.type: FUNC
946  * @tc.require: issueI5LHLP
947  */
948 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetMediaByNameFromHapTest0053, TestSize.Level1)
949 {
950     rmc->AddHapResource("zh", nullptr, "CN");
951 
952     HapResourceV2 *tmp = new HapResourceV2(FormatFullPath(g_newModuleHapPath).c_str(), 0);
953     rmc->TestGetMediaByName(tmp);
954     delete tmp;
955 }
956 
957 /*
958  * @tc.name: ResourceManagerGetMediaByNameFromHapTest0054
959  * @tc.desc: Test GetMediaByName, to match sdpi determinder
960  * @tc.type: FUNC
961  * @tc.require: issueI5LHLP
962  */
963 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetMediaByNameFromHapTest0054, TestSize.Level1)
964 {
965     rmc->AddHapResource("en", nullptr, "US");
966 
967     HapResourceV2 *tmp = new HapResourceV2(FormatFullPath(g_newModuleHapPath).c_str(), 0);
968     rmc->TestGetMediaWithDensityByName(tmp);
969     delete tmp;
970 }
971 
972 /*
973  * @tc.name: ResourceManagerOverlayTest001
974  * @tc.desc: Test overlay AddResource & UpdateResConfig function, file case.
975  * @tc.type: FUNC
976  * @tc.require: issueI5LHLP
977  */
978 HWTEST_F(ResourceManagerTestHap, ResourceManagerOverlayTest001, TestSize.Level1)
979 {
980     std::vector<std::string> overlayPaths;
981     overlayPaths.push_back(FormatFullPath(g_overlayResFilePath).c_str());
982     bool ret = ((ResourceManagerImpl *)rm)->AddResource(FormatFullPath(g_resFilePath).c_str(), overlayPaths);
983     ASSERT_TRUE(ret);
984 
985     auto rc = CreateResConfig();
986     if (rc == nullptr) {
987         ASSERT_TRUE(false);
988     }
989     rc->SetLocaleInfo("en", nullptr, "US");
990     rm->UpdateResConfig(*rc);
991     delete rc;
992 }
993 
994 /*
995  * @tc.name: ResourceManagerOverlayTest002
996  * @tc.desc: Test overlay function
997  * @tc.type: FUNC
998  */
999 HWTEST_F(ResourceManagerTestHap, ResourceManagerOverlayTest002, TestSize.Level1)
1000 {
1001     rmc->AddResource("en", nullptr, nullptr);
1002 
1003     std::vector<std::string> overlayPaths;
1004     overlayPaths.push_back(FormatFullPath(g_overlayResFilePath).c_str());
1005     bool ret = ((ResourceManagerImpl*)rm)->AddResource(FormatFullPath(g_resFilePath).c_str(), overlayPaths);
1006     ASSERT_TRUE(ret);
1007     ret = ((ResourceManagerImpl*)rm)->AddResource(FormatFullPath(g_resFilePath).c_str(), overlayPaths);
1008     // repeat add the same overlayPaths
1009     ASSERT_TRUE(ret);
1010     rmc->TestStringById("ohos_app_name", "SystemOverlay");
1011 
1012     std::vector<std::string> removePaths;
1013     removePaths.push_back(FormatFullPath(g_overlayResFilePath).c_str());
1014     ret = ((ResourceManagerImpl*)rm)->RemoveResource(FormatFullPath(g_resFilePath).c_str(), removePaths);
1015     ASSERT_TRUE(ret);
1016     rmc->TestStringById("ohos_app_name", "System");
1017 
1018     ret = ((ResourceManagerImpl*)rm)->AddResource(FormatFullPath(g_resFilePath).c_str(), overlayPaths);
1019     ASSERT_TRUE(ret);
1020     rmc->TestStringById("ohos_app_name", "SystemOverlay");
1021 }
1022 
1023 /*
1024  * @tc.name: ResourceManagerOverlayTest003
1025  * @tc.desc: Test overlay function
1026  * @tc.type: FUNC
1027  */
1028 HWTEST_F(ResourceManagerTestHap, ResourceManagerOverlayTest003, TestSize.Level1)
1029 {
1030     rmc->AddResource("en", nullptr, nullptr);
1031 
1032     std::vector<std::string> overlayPaths;
1033     overlayPaths.push_back(FormatFullPath(g_overlayResFilePath).c_str());
1034     bool ret = ((ResourceManagerImpl*)rm)->AddResource(FormatFullPath(g_resFilePath).c_str(), overlayPaths);
1035     ASSERT_TRUE(ret);
1036     rmc->TestStringById("ohos_app_name", "SystemOverlay");
1037 
1038     std::vector<std::string> removePaths;
1039     removePaths.push_back("notexist.index");
1040     removePaths.push_back("notexist2.index");
1041     removePaths.push_back(FormatFullPath(g_overlayResFilePath).c_str());
1042     ret = ((ResourceManagerImpl*)rm)->RemoveResource(FormatFullPath(g_resFilePath).c_str(), removePaths);
1043     ASSERT_TRUE(ret);
1044     rmc->TestStringById("ohos_app_name", "System");
1045 }
1046 
1047 /*
1048  * @tc.name: ResourceManagerOverlayTest004
1049  * @tc.desc: Test overlay function
1050  * @tc.type: FUNC
1051  */
1052 HWTEST_F(ResourceManagerTestHap, ResourceManagerOverlayTest004, TestSize.Level1)
1053 {
1054     rmc->AddResource("zh", nullptr, nullptr);
1055 
1056     std::vector<std::string> overlayPaths;
1057     overlayPaths.push_back(FormatFullPath(g_overlayResFilePath).c_str());
1058     bool ret = ((ResourceManagerImpl*)rm)->AddResource(FormatFullPath(g_resFilePath).c_str(), overlayPaths);
1059     ASSERT_TRUE(ret);
1060     rmc->TestStringById("ohos_lab_answer_call", "overlay接听电话");
1061 
1062     std::vector<std::string> removePaths;
1063     removePaths.push_back("notexist.index");
1064     removePaths.push_back(FormatFullPath(g_overlayResFilePath).c_str());
1065     ret = ((ResourceManagerImpl*)rm)->RemoveResource(FormatFullPath(g_resFilePath).c_str(), removePaths);
1066     ASSERT_TRUE(ret);
1067     rmc->TestStringById("ohos_lab_answer_call", "接听电话");
1068 
1069     ret = ((ResourceManagerImpl*)rm)->AddResource(FormatFullPath(g_resFilePath).c_str(), overlayPaths);
1070     ASSERT_TRUE(ret);
1071     rmc->TestStringById("ohos_lab_answer_call", "overlay接听电话");
1072 }
1073 
1074 /*
1075  * @tc.name: ResourceManagerUtilsTest001
1076  * @tc.desc: Test endWithTail;
1077  * @tc.type: FUNC
1078  * @tc.require: issueI5LHLP
1079  */
1080 HWTEST_F(ResourceManagerTestHap, ResourceManagerUtilsTest001, TestSize.Level1)
1081 {
1082     std::string path = "";
1083     std::string tail = ".hap";
1084     bool ret = Utils::endWithTail(path, tail);
1085     ASSERT_FALSE(ret);
1086 }
1087 
1088 /*
1089  * @tc.name: ResourceManagerGetResourceLimitKeysTest001
1090  * @tc.desc: Test GetResourceLimitKeys function
1091  * @tc.type: FUNC
1092  * @tc.require: issueI73ZQ8
1093  */
1094 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetResourceLimitKeysTest001, TestSize.Level1)
1095 {
1096     bool ret = rm->AddResource(FormatFullPath(g_resFilePath).c_str());
1097     ASSERT_TRUE(ret);
1098     // all/assets/entry/resources.index contains limit keys for LANGUAGE/REGION/
1099     // SCREEN_DENSITY/DEVICETYPE/COLORMODE/MCC/MNC/INPUTDEVICE
1100     rmc->TestGetResourceLimitKeys(DATA_ALL_HAP_LIMIT_KEYS);
1101 }
1102 
1103 /*
1104  * @tc.name: ResourceManagerGetResourceLimitKeysTest002
1105  * @tc.desc: Test GetResourceLimitKeys function
1106  * @tc.type: FUNC
1107  * @tc.require: issueI73ZQ8
1108  */
1109 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetResourceLimitKeysTest002, TestSize.Level1)
1110 {
1111     bool ret = rm->AddResource(FormatFullPath(g_hapPath).c_str());
1112     ASSERT_TRUE(ret);
1113     // all.hap contains limit keys for LANGUAGE/REGION/
1114     // SCREEN_DENSITY/DEVICETYPE/COLORMODE/MCC/MNC/INPUTDEVICE
1115     rmc->TestGetResourceLimitKeys(DATA_ALL_HAP_LIMIT_KEYS);
1116 }
1117 
1118 /*
1119  * @tc.name: ResourceManagerGetResourceLimitKeysTest003
1120  * @tc.desc: Test GetResourceLimitKeys function
1121  * @tc.type: FUNC
1122  * @tc.require: issueI73ZQ8
1123  */
1124 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetResourceLimitKeysTest003, TestSize.Level1)
1125 {
1126     std::vector<std::string> overlayPaths;
1127     overlayPaths.push_back(FormatFullPath(g_overlayResFilePath).c_str());
1128     bool ret = ((ResourceManagerImpl *)rm)->AddResource(FormatFullPath(g_resFilePath).c_str(), overlayPaths);
1129     ASSERT_TRUE(ret);
1130     // all/assets/entry/resources.index and overlay/assets/entry/resources.index contains
1131     // LANGUAGE/REGION/DIRECTION/COLORMODE
1132     rmc->TestGetResourceLimitKeys(SYSTEM_RES_LIMIT_KEYS);
1133 }
1134 
1135 /*
1136  * @tc.name: ResourceManagerOverlayTest005
1137  * @tc.desc: Test overlay function
1138  * @tc.type: FUNC
1139  */
1140 HWTEST_F(ResourceManagerTestHap, ResourceManagerOverlayTest005, TestSize.Level1)
1141 {
1142     rmc->AddResource("zh", nullptr, nullptr);
1143     // test add invalid overlay path
1144     bool ret = ((ResourceManagerImpl*)rm)->AddAppOverlay("noexist.hap");
1145     ASSERT_FALSE(ret);
1146 
1147     ret = ((ResourceManagerImpl*)rm)->AddAppOverlay(FormatFullPath(g_overlayResFilePath).c_str());
1148     ASSERT_TRUE(ret);
1149     rmc->TestStringById("ohos_lab_answer_call", "overlay接听电话");
1150 }
1151 
1152 /*
1153  * @tc.name: ResourceManagerOverlayTest006
1154  * @tc.desc: Test overlay function
1155  * @tc.type: FUNC
1156  */
1157 HWTEST_F(ResourceManagerTestHap, ResourceManagerOverlayTest006, TestSize.Level1)
1158 {
1159     rmc->AddResource("zh", nullptr, nullptr);
1160     // test remove invalid overlay path
1161     bool ret = ((ResourceManagerImpl*)rm)->RemoveAppOverlay("noexist.hap");
1162     ASSERT_FALSE(ret);
1163 
1164     ret = ((ResourceManagerImpl*)rm)->AddAppOverlay(FormatFullPath(g_overlayResFilePath).c_str());
1165     ASSERT_TRUE(ret);
1166     ret = ((ResourceManagerImpl*)rm)->RemoveAppOverlay(FormatFullPath(g_overlayResFilePath).c_str());
1167     ASSERT_TRUE(ret);
1168     rmc->TestStringById("ohos_lab_answer_call", "接听电话");
1169 }
1170 
1171 /*
1172  * @tc.name: ResourceManagerGetResIdTest001
1173  * @tc.desc: Test GetResId function
1174  * @tc.type: FUNC
1175  */
1176 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetResIdTest001, TestSize.Level1)
1177 {
1178     bool ret = rm->AddResource(FormatFullPath(g_hapPath).c_str());
1179     EXPECT_TRUE(ret);
1180     const std::string resTypeName = "app.string.entry_MainAbility";
1181     uint32_t id = 0;
1182     RState state = rm->GetResId(resTypeName, id);
1183     EXPECT_TRUE(state == SUCCESS);
1184     EXPECT_EQ(id, 16777226);
1185 }
1186 
1187 /*
1188  * @tc.name: ResourceManagerGetResIdTest002
1189  * @tc.desc: Test GetResId function
1190  * @tc.type: FUNC
1191  */
1192 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetResIdTest002, TestSize.Level1)
1193 {
1194     bool ret = rm->AddResource(FormatFullPath(g_hapPath).c_str());
1195     EXPECT_TRUE(ret);
1196     const std::string resTypeName = "app.media.icon";
1197     uint32_t id = 0;
1198     RState state = rm->GetResId(resTypeName, id);
1199     EXPECT_TRUE(state == SUCCESS);
1200     EXPECT_EQ(id, 16777321);
1201 }
1202 
1203 /*
1204  * @tc.name: ResourceManagerGetResIdTest003
1205  * @tc.desc: Test GetResId function
1206  * @tc.type: FUNC
1207  */
1208 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetResIdTest003, TestSize.Level1)
1209 {
1210     bool ret = rm->AddResource(FormatFullPath(g_hapPath).c_str());
1211     EXPECT_TRUE(ret);
1212     const std::string resTypeName = "app.color.color_aboutPage_title_primary";
1213     uint32_t id = 0;
1214     RState state = rm->GetResId(resTypeName, id);
1215     EXPECT_TRUE(state == SUCCESS);
1216     EXPECT_EQ(id, 16777273);
1217 }
1218 
1219 /*
1220  * @tc.name: ResourceManagerGetResIdTest004
1221  * @tc.desc: Test GetResId function
1222  * @tc.type: FUNC
1223  */
1224 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetResIdTest004, TestSize.Level1)
1225 {
1226     bool ret = rm->AddResource(FormatFullPath(g_hapPath).c_str());
1227     EXPECT_TRUE(ret);
1228     const std::string resTypeName = "app.string.xxx";
1229     uint32_t id = 0;
1230     RState state = rm->GetResId(resTypeName, id);
1231     EXPECT_TRUE(state == NOT_FOUND);
1232     EXPECT_EQ(id, 0);
1233 }
1234 
1235 /*
1236  * @tc.name: ResourceManagerGetResIdTest005
1237  * @tc.desc: Test GetResId function
1238  * @tc.type: FUNC
1239  */
1240 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetResIdTest005, TestSize.Level1)
1241 {
1242     bool ret = rm->AddResource(FormatFullPath(g_hapPath).c_str());
1243     EXPECT_TRUE(ret);
1244     const std::string resTypeName = "xxx.string.entry_MainAbility";
1245     uint32_t id = 0;
1246     RState state = rm->GetResId(resTypeName, id);
1247     EXPECT_TRUE(state == NOT_FOUND);
1248     EXPECT_EQ(id, 0);
1249 }
1250 
1251 /*
1252  * @tc.name: ResourceManagerGetResIdTest006
1253  * @tc.desc: Test GetResId function
1254  * @tc.type: FUNC
1255  */
1256 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetResIdTest006, TestSize.Level1)
1257 {
1258     bool ret = rm->AddResource(FormatFullPath(g_hapPath).c_str());
1259     EXPECT_TRUE(ret);
1260     const std::string resTypeName = "app.xxx.entry_MainAbility";
1261     uint32_t id = 0;
1262     RState state = rm->GetResId(resTypeName, id);
1263     EXPECT_TRUE(state == NOT_FOUND);
1264     EXPECT_EQ(id, 0);
1265 }
1266 
1267 /*
1268  * @tc.name: ResourceManagerGetLocalesTest001
1269  * @tc.desc: Test GetLocales function
1270  * @tc.type: FUNC
1271  */
1272 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetLocalesTest001, TestSize.Level1)
1273 {
1274     bool ret = rm->AddResource(FormatFullPath(g_hapPath).c_str());
1275     EXPECT_TRUE(ret);
1276     std::vector<std::string> outValue;
1277     rm->GetLocales(outValue);
1278     EXPECT_EQ(static_cast<size_t>(4), outValue.size());
1279 }
1280 
1281 /*
1282  * @tc.name: ResourceManagerGetLocalesTest002
1283  * @tc.desc: Test GetLocales function
1284  * @tc.type: FUNC
1285  */
1286 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetLocalesTest002, TestSize.Level1)
1287 {
1288     bool ret = rm->AddResource(FormatFullPath(g_hapPath).c_str());
1289     EXPECT_TRUE(ret);
1290     std::vector<std::string> outValue;
1291     rm->GetLocales(outValue, false);
1292     EXPECT_EQ(static_cast<size_t>(4), outValue.size());
1293 }
1294 
1295 /*
1296  * @tc.name: ResourceManagerGetLocalesTest003
1297  * @tc.desc: Test GetLocales function
1298  * @tc.type: FUNC
1299  */
1300 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetLocalesTest003, TestSize.Level1)
1301 {
1302     bool ret = rm->AddResource(FormatFullPath(g_hapPath).c_str());
1303     EXPECT_TRUE(ret);
1304     std::vector<std::string> outValue;
1305     rm->GetLocales(outValue, false);
1306     EXPECT_EQ(static_cast<size_t>(4), outValue.size());
1307 }
1308 
1309 /*
1310  * @tc.name: ResourceManagerGetDrawableInfoByIdFromHapTest001
1311  * @tc.desc: Test GetDrawableInfo
1312  * @tc.type: FUNC
1313  * @tc.require: issueI5LHLP
1314  */
1315 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetDrawableInfoByIdFromHapTest001, TestSize.Level1)
1316 {
1317     rmc->AddHapResource("zh", nullptr, "CN");
1318 
1319     HapResourceV1 *tmp = new HapResourceV1(FormatFullPath(g_hapPath).c_str(), 0, nullptr);
1320     rmc->TestGetDrawableInfoById(tmp);
1321     delete tmp;
1322 }
1323 
1324 /*
1325  * @tc.name: ResourceManagerGetDrawableInfoByIdFromHapTest002
1326  * @tc.desc: Test GetDrawableInfo, to match sdpi determinder
1327  * @tc.type: FUNC
1328  * @tc.require: issueI5LHLP
1329  */
1330 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetDrawableInfoByIdFromHapTest002, TestSize.Level1)
1331 {
1332     rmc->AddHapResource("en", nullptr, "US");
1333 
1334     HapResourceV1 *tmp = new HapResourceV1(FormatFullPath(g_hapPath).c_str(), 0, nullptr);
1335     rmc->TestGetDrawableInfoWithDensityById(tmp);
1336     delete tmp;
1337 }
1338 
1339 /*
1340  * @tc.name: ResourceManagerGetDrawableInfoByIdFromHapTest003
1341  * @tc.desc: Test GetDrawableInfo
1342  * @tc.type: FUNC
1343  * @tc.require: issueI5LHLP
1344  */
1345 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetDrawableInfoByIdFromHapTest003, TestSize.Level1)
1346 {
1347     rmc->AddHapResource("zh", nullptr, "CN");
1348 
1349     HapResourceV2 *tmp = new HapResourceV2(FormatFullPath(g_newModuleHapPath).c_str(), 0);
1350     rmc->TestGetDrawableInfoById(tmp);
1351     delete tmp;
1352 }
1353 
1354 /*
1355  * @tc.name: ResourceManagerGetDrawableInfoByIdFromHapTest004
1356  * @tc.desc: Test GetDrawableInfo, to match sdpi determinder
1357  * @tc.type: FUNC
1358  * @tc.require: issueI5LHLP
1359  */
1360 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetDrawableInfoByIdFromHapTest004, TestSize.Level1)
1361 {
1362     rmc->AddHapResource("en", nullptr, "US");
1363 
1364     HapResourceV2 *tmp = new HapResourceV2(FormatFullPath(g_newModuleHapPath).c_str(), 0);
1365     rmc->TestGetDrawableInfoWithDensityById(tmp);
1366     delete tmp;
1367 }
1368 
1369 /*
1370  * @tc.name: ResourceManagerGetDrawableInfoByNameFromHapTest001
1371  * @tc.desc: Test GetDrawableInfo
1372  * @tc.type: FUNC
1373  * @tc.require: issueI5LHLP
1374  */
1375 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetDrawableInfoByNameFromHapTest001, TestSize.Level1)
1376 {
1377     rmc->AddHapResource("zh", nullptr, "CN");
1378 
1379     HapResourceV1 *tmp = new HapResourceV1(FormatFullPath(g_hapPath).c_str(), 0, nullptr);
1380     rmc->TestGetDrawableInfoByName(tmp);
1381     delete tmp;
1382 }
1383 
1384 /*
1385  * @tc.name: ResourceManagerGetDrawableInfoByNameFromHapTest002
1386  * @tc.desc: Test GetDrawableInfo, to match sdpi determinder
1387  * @tc.type: FUNC
1388  * @tc.require: issueI5LHLP
1389  */
1390 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetDrawableInfoByNameFromHapTest002, TestSize.Level1)
1391 {
1392     rmc->AddHapResource("en", nullptr, "US");
1393 
1394     HapResourceV1 *tmp = new HapResourceV1(FormatFullPath(g_hapPath).c_str(), 0, nullptr);
1395     rmc->TestGetDrawableInfoWithDensityByName(tmp);
1396     delete tmp;
1397 }
1398 
1399 /*
1400  * @tc.name: ResourceManagerGetDrawableInfoByNameFromHapTest003
1401  * @tc.desc: Test GetDrawableInfo
1402  * @tc.type: FUNC
1403  * @tc.require: issueI5LHLP
1404  */
1405 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetDrawableInfoByNameFromHapTest003, TestSize.Level1)
1406 {
1407     rmc->AddHapResource("zh", nullptr, "CN");
1408 
1409     HapResourceV2 *tmp = new HapResourceV2(FormatFullPath(g_newModuleHapPath).c_str(), 0);
1410     rmc->TestGetDrawableInfoByName(tmp);
1411     delete tmp;
1412 }
1413 
1414 /*
1415  * @tc.name: ResourceManagerGetDrawableInfoByNameFromHapTest004
1416  * @tc.desc: Test GetDrawableInfo, to match sdpi determinder
1417  * @tc.type: FUNC
1418  * @tc.require: issueI5LHLP
1419  */
1420 HWTEST_F(ResourceManagerTestHap, ResourceManagerGetDrawableInfoByNameFromHapTest004, TestSize.Level1)
1421 {
1422     rmc->AddHapResource("en", nullptr, "US");
1423 
1424     HapResourceV2 *tmp = new HapResourceV2(FormatFullPath(g_newModuleHapPath).c_str(), 0);
1425     rmc->TestGetDrawableInfoWithDensityByName(tmp);
1426     delete tmp;
1427 }
1428 }
1429