• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "resource_manager_test_media.h"
17 
18 #include "resource_manager_test_common.h"
19 
20 using namespace OHOS::Global::Resource;
21 using namespace testing::ext;
22 namespace {
23 class ResourceManagerTestMedia : public testing::Test {
24 public:
25     static void SetUpTestCase(void);
26 
27     static void TearDownTestCase(void);
28 
29     void SetUp();
30 
31     void TearDown();
32 
ResourceManagerTestMedia()33     ResourceManagerTestMedia() : rm(nullptr)
34     {}
35 
~ResourceManagerTestMedia()36     ~ResourceManagerTestMedia()
37     {}
38 public:
39     ResourceManager *rm;
40     ResourceManagerTestCommon *rmc;
41 };
42 
SetUpTestCase(void)43 void ResourceManagerTestMedia::SetUpTestCase(void)
44 {
45     // step 1: input testsuit setup step
46     g_logLevel = LOG_DEBUG;
47 }
48 
TearDownTestCase(void)49 void ResourceManagerTestMedia::TearDownTestCase(void)
50 {
51     // step 2: input testsuit teardown step
52 }
53 
SetUp(void)54 void ResourceManagerTestMedia::SetUp(void)
55 {
56     this->rm = CreateResourceManager();
57     this->rmc = new ResourceManagerTestCommon(rm);
58 }
59 
TearDown(void)60 void ResourceManagerTestMedia::TearDown(void)
61 {
62     delete this->rm;
63     delete this->rmc;
64 }
65 
66 /*
67  * @tc.name: ResourceManagerGetMediaByIdTest001
68  * @tc.desc: Test GetMediaById
69  * @tc.type: FUNC
70  */
71 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest001, TestSize.Level1)
72 {
73     rmc->AddResource("zh", nullptr, "CN");
74 
75     HapResource *tmp = new HapResource(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
76     rmc->TestGetMediaById(tmp);
77     delete tmp;
78 }
79 
80 /*
81  * @tc.name: ResourceManagerGetMediaByIdTest002
82  * @tc.desc: Test GetMediaById
83  * @tc.type: FUNC
84  */
85 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest002, TestSize.Level1)
86 {
87     rmc->AddResource("zh", nullptr, "CN");
88 
89     std::string outValue;
90     RState state;
91     state = rm->GetMediaById(NON_EXIST_ID, outValue);
92     ASSERT_EQ(ERROR_CODE_RES_ID_NOT_FOUND, state);
93 }
94 
95 /*
96  * @tc.name: ResourceManagerGetMediaByIdTest003
97  * @tc.desc: Test GetMediaById, to match sdpi determinder
98  * @tc.type: FUNC
99  */
100 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest003, TestSize.Level1)
101 {
102     rmc->AddResource("en", nullptr, "US");
103 
104     HapResource *tmp = new HapResource(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
105     rmc->TestGetMediaWithDensityById(tmp);
106     delete tmp;
107 }
108 
109 /*
110  * @tc.name: ResourceManagerGetMediaByIdTest004
111  * @tc.desc: Test GetMediaById, to match mdpi determinder
112  * @tc.type: FUNC
113  */
114 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest004, TestSize.Level1)
115 {
116     rmc->AddResource("en", nullptr, "US");
117 
118     HapResource *tmp = new HapResource(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
119     tmp->Init(rmc->defaultResConfig);
120     std::string res = tmp->GetResourcePath();
121     res.append("entry/resources/mdpi/media/icon.png");
122 
123     auto rc = CreateResConfig();
124     if (rc == nullptr) {
125         EXPECT_TRUE(false);
126         return;
127     }
128     rc->SetDeviceType(DEVICE_TV);
129     rc->SetColorMode(COLOR_MODE_NOT_SET);
130     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
131     rm->UpdateResConfig(*rc);
132     delete rc;
133 
134     int density = 160;
135     std::string outValue;
136     RState state;
137     int id = rmc->GetResId("icon", ResType::MEDIA);
138     EXPECT_TRUE(id > 0);
139     state = rm->GetMediaById(id, outValue, density);
140     EXPECT_TRUE(state == SUCCESS);
141     EXPECT_EQ(res, outValue);
142     delete tmp;
143 }
144 
145 /*
146  * @tc.name: ResourceManagerGetMediaByIdTest005
147  * @tc.desc: Test GetMediaById, to match ldpi determinder
148  * @tc.type: FUNC
149  */
150 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest005, TestSize.Level1)
151 {
152     rmc->AddResource("en", nullptr, "US");
153 
154     HapResource *tmp = new HapResource(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
155     tmp->Init(rmc->defaultResConfig);
156     std::string res = tmp->GetResourcePath();
157     res.append("entry/resources/ldpi/media/icon.png");
158 
159     auto rc = CreateResConfig();
160     if (rc == nullptr) {
161         EXPECT_TRUE(false);
162         return;
163     }
164     rc->SetDeviceType(DEVICE_PHONE);
165     rc->SetColorMode(COLOR_MODE_NOT_SET);
166     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
167     rm->UpdateResConfig(*rc);
168     delete rc;
169 
170     int density = 240;
171     std::string outValue;
172     RState state;
173     int id = rmc->GetResId("icon", ResType::MEDIA);
174     EXPECT_TRUE(id > 0);
175     state = rm->GetMediaById(id, outValue, density);
176     EXPECT_TRUE(state == SUCCESS);
177     EXPECT_EQ(res, outValue);
178     delete tmp;
179 }
180 
181 /*
182  * @tc.name: ResourceManagerGetMediaByIdTest006
183  * @tc.desc: Test GetMediaById, to match xldpi determinder
184  * @tc.type: FUNC
185  */
186 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest006, TestSize.Level1)
187 {
188     rmc->AddResource("en", nullptr, "US");
189 
190     HapResource *tmp = new HapResource(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
191     tmp->Init(rmc->defaultResConfig);
192     std::string res = tmp->GetResourcePath();
193     res.append("entry/resources/xldpi/media/icon.png");
194 
195     auto rc = CreateResConfig();
196     if (rc == nullptr) {
197         EXPECT_TRUE(false);
198         return;
199     }
200     rc->SetDeviceType(DEVICE_PHONE);
201     rc->SetColorMode(COLOR_MODE_NOT_SET);
202     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
203     rm->UpdateResConfig(*rc);
204     delete rc;
205 
206     int density = 320;
207     std::string outValue;
208     RState state;
209     int id = rmc->GetResId("icon", ResType::MEDIA);
210     EXPECT_TRUE(id > 0);
211     state = rm->GetMediaById(id, outValue, density);
212     EXPECT_TRUE(state == SUCCESS);
213     EXPECT_EQ(res, outValue);
214     delete tmp;
215 }
216 
217 /*
218  * @tc.name: ResourceManagerGetMediaByIdTest007
219  * @tc.desc: Test GetMediaById, to match xxldpi determinder
220  * @tc.type: FUNC
221  */
222 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest007, TestSize.Level1)
223 {
224     rmc->AddResource("en", nullptr, "US");
225 
226     HapResource *tmp = new HapResource(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
227     tmp->Init(rmc->defaultResConfig);
228     std::string res = tmp->GetResourcePath();
229     res.append("entry/resources/xxldpi/media/icon.png");
230 
231     auto rc = CreateResConfig();
232     if (rc == nullptr) {
233         EXPECT_TRUE(false);
234         return;
235     }
236     rc->SetDeviceType(DEVICE_PHONE);
237     rc->SetColorMode(COLOR_MODE_NOT_SET);
238     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
239     rm->UpdateResConfig(*rc);
240     delete rc;
241 
242     int density = 480;
243     std::string outValue;
244     RState state;
245     int id = rmc->GetResId("icon", ResType::MEDIA);
246     EXPECT_TRUE(id > 0);
247     state = rm->GetMediaById(id, outValue, density);
248     EXPECT_TRUE(state == SUCCESS);
249     EXPECT_EQ(res, outValue);
250     delete tmp;
251 }
252 
253 /*
254  * @tc.name: ResourceManagerGetMediaByIdTest008
255  * @tc.desc: Test GetMediaById, to match xxxldpi determinder
256  * @tc.type: FUNC
257  */
258 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest008, TestSize.Level1)
259 {
260     rmc->AddResource("en", nullptr, "US");
261 
262     HapResource *tmp = new HapResource(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
263     tmp->Init(rmc->defaultResConfig);
264     std::string res = tmp->GetResourcePath();
265     res.append("entry/resources/xxxldpi/media/icon.png");
266 
267     auto rc = CreateResConfig();
268     if (rc == nullptr) {
269         EXPECT_TRUE(false);
270         return;
271     }
272     rc->SetDeviceType(DEVICE_PHONE);
273     rc->SetColorMode(COLOR_MODE_NOT_SET);
274     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
275     rm->UpdateResConfig(*rc);
276     delete rc;
277 
278     int density = 640;
279     std::string outValue;
280     RState state;
281     int id = rmc->GetResId("icon", ResType::MEDIA);
282     EXPECT_TRUE(id > 0);
283     state = rm->GetMediaById(id, outValue, density);
284     EXPECT_TRUE(state == SUCCESS);
285     EXPECT_EQ(res, outValue);
286     delete tmp;
287 }
288 
289 /*
290  * @tc.name: ResourceManagerGetMediaByIdTest009
291  * @tc.desc: Test GetMediaById, to match unsupport density
292  * @tc.type: FUNC
293  */
294 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest009, TestSize.Level1)
295 {
296     rmc->AddResource("en", nullptr, "US");
297 
298     uint32_t density1 = 420;
299     uint32_t density2 = 800;
300     uint32_t density3 = 10;
301     std::string outValue;
302     RState state1;
303     RState state2;
304     RState state3;
305     int id = rmc->GetResId("icon", ResType::MEDIA);
306     EXPECT_TRUE(id > 0);
307     state1 = rm->GetMediaById(id, outValue, density1);
308     state2 = rm->GetMediaById(id, outValue, density2);
309     state3 = rm->GetMediaById(id, outValue, density3);
310     EXPECT_TRUE(state1 == ERROR_CODE_INVALID_INPUT_PARAMETER);
311     EXPECT_TRUE(state2 == ERROR_CODE_INVALID_INPUT_PARAMETER);
312     EXPECT_TRUE(state3 == ERROR_CODE_INVALID_INPUT_PARAMETER);
313 }
314 
315 /*
316  * @tc.name: ResourceManagerGetMediaByIdTest010
317  * @tc.desc: Test GetMediaById, to match with no density param
318  * @tc.type: FUNC
319  */
320 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest010, TestSize.Level1)
321 {
322     rmc->AddResource("en", nullptr, "US");
323 
324     uint32_t density = 0;
325     std::string outValue1;
326     std::string outValue2;
327     RState state1;
328     RState state2;
329     int id = rmc->GetResId("icon", ResType::MEDIA);
330     state1 = rm->GetMediaById(id, outValue1, density);
331     state2 = rm->GetMediaById(id, outValue2);
332     EXPECT_TRUE(state1 == SUCCESS);
333     EXPECT_TRUE(state2 == SUCCESS);
334     EXPECT_EQ(outValue1, outValue2);
335 }
336 
337 /*
338  * @tc.name: ResourceManagerGetMediaByIdTest011
339  * @tc.desc: Test GetMediaById, to match zh_CN-sdpi determinder
340  * @tc.type: FUNC
341  */
342 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest011, TestSize.Level1)
343 {
344     rmc->AddResource("zh", nullptr, "CN");
345 
346     HapResource *tmp = new HapResource(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
347     tmp->Init(rmc->defaultResConfig);
348     std::string res = tmp->GetResourcePath();
349     res.append("entry/resources/zh_CN-sdpi/media/icon.png");
350 
351     auto rc = CreateResConfig();
352     if (rc == nullptr) {
353         EXPECT_TRUE(false);
354         return;
355     }
356     rc->SetDeviceType(DEVICE_TABLET);
357     rc->SetColorMode(COLOR_MODE_NOT_SET);
358     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
359     rm->UpdateResConfig(*rc);
360     delete rc;
361 
362     int density = 120;
363     std::string outValue;
364     RState state;
365     int id = rmc->GetResId("icon", ResType::MEDIA);
366     EXPECT_TRUE(id > 0);
367     state = rm->GetMediaById(id, outValue, density);
368     EXPECT_TRUE(state == SUCCESS);
369     EXPECT_EQ(res, outValue);
370     delete tmp;
371 }
372 
373 /*
374  * @tc.name: ResourceManagerGetMediaByIdTest012
375  * @tc.desc: Test GetMediaById, to match zh_CN-mdpi determinder
376  * @tc.type: FUNC
377  */
378 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest012, TestSize.Level1)
379 {
380     rmc->AddResource("zh", nullptr, "CN");
381 
382     HapResource *tmp = new HapResource(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
383     tmp->Init(rmc->defaultResConfig);
384     std::string res = tmp->GetResourcePath();
385     res.append("entry/resources/zh_CN-mdpi/media/icon.png");
386 
387     auto rc = CreateResConfig();
388     if (rc == nullptr) {
389         EXPECT_TRUE(false);
390         return;
391     }
392     rc->SetDeviceType(DEVICE_TABLET);
393     rc->SetColorMode(COLOR_MODE_NOT_SET);
394     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
395     rm->UpdateResConfig(*rc);
396     delete rc;
397 
398     int density = 160;
399     std::string outValue;
400     RState state;
401     int id = rmc->GetResId("icon", ResType::MEDIA);
402     EXPECT_TRUE(id > 0);
403     state = rm->GetMediaById(id, outValue, density);
404     EXPECT_TRUE(state == SUCCESS);
405     EXPECT_EQ(res, outValue);
406     delete tmp;
407 }
408 
409 /*
410  * @tc.name: ResourceManagerGetMediaByIdTest013
411  * @tc.desc: Test GetMediaById, to match zh_CN-ldpi determinder
412  * @tc.type: FUNC
413  */
414 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest013, TestSize.Level1)
415 {
416     rmc->AddResource("zh", nullptr, "CN");
417 
418     HapResource *tmp = new HapResource(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
419     tmp->Init(rmc->defaultResConfig);
420     std::string res = tmp->GetResourcePath();
421     res.append("entry/resources/zh_CN-ldpi/media/icon.png");
422 
423     auto rc = CreateResConfig();
424     if (rc == nullptr) {
425         EXPECT_TRUE(false);
426         return;
427     }
428     rc->SetDeviceType(DEVICE_TABLET);
429     rc->SetColorMode(COLOR_MODE_NOT_SET);
430     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
431     rm->UpdateResConfig(*rc);
432     delete rc;
433 
434     int density = 240;
435     std::string outValue;
436     RState state;
437     int id = rmc->GetResId("icon", ResType::MEDIA);
438     EXPECT_TRUE(id > 0);
439     state = rm->GetMediaById(id, outValue, density);
440     EXPECT_TRUE(state == SUCCESS);
441     EXPECT_EQ(res, outValue);
442     delete tmp;
443 }
444 
445 /*
446  * @tc.name: ResourceManagerGetMediaByIdTest014
447  * @tc.desc: Test GetMediaById, to match zh_CN-xldpi determinder
448  * @tc.type: FUNC
449  */
450 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest014, TestSize.Level1)
451 {
452     rmc->AddResource("zh", nullptr, "CN");
453 
454     HapResource *tmp = new HapResource(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
455     tmp->Init(rmc->defaultResConfig);
456     std::string res = tmp->GetResourcePath();
457     res.append("entry/resources/zh_CN-xldpi/media/icon.png");
458 
459     auto rc = CreateResConfig();
460     if (rc == nullptr) {
461         EXPECT_TRUE(false);
462         return;
463     }
464     rc->SetDeviceType(DEVICE_TABLET);
465     rc->SetColorMode(COLOR_MODE_NOT_SET);
466     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
467     rm->UpdateResConfig(*rc);
468     delete rc;
469 
470     int density = 320;
471     std::string outValue;
472     RState state;
473     int id = rmc->GetResId("icon", ResType::MEDIA);
474     EXPECT_TRUE(id > 0);
475     state = rm->GetMediaById(id, outValue, density);
476     EXPECT_TRUE(state == SUCCESS);
477     EXPECT_EQ(res, outValue);
478     delete tmp;
479 }
480 
481 /*
482  * @tc.name: ResourceManagerGetMediaByIdTest015
483  * @tc.desc: Test GetMediaById, to match zh_CN-xxldpi determinder
484  * @tc.type: FUNC
485  */
486 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest015, TestSize.Level1)
487 {
488     rmc->AddResource("zh", nullptr, "CN");
489 
490     HapResource *tmp = new HapResource(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
491     tmp->Init(rmc->defaultResConfig);
492     std::string res = tmp->GetResourcePath();
493     res.append("entry/resources/zh_CN-xxldpi/media/icon.png");
494 
495     auto rc = CreateResConfig();
496     if (rc == nullptr) {
497         EXPECT_TRUE(false);
498         return;
499     }
500     rc->SetDeviceType(DEVICE_TABLET);
501     rc->SetColorMode(COLOR_MODE_NOT_SET);
502     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
503     rm->UpdateResConfig(*rc);
504     delete rc;
505 
506     int density = 480;
507     std::string outValue;
508     RState state;
509     int id = rmc->GetResId("icon", ResType::MEDIA);
510     EXPECT_TRUE(id > 0);
511     state = rm->GetMediaById(id, outValue, density);
512     EXPECT_TRUE(state == SUCCESS);
513     EXPECT_EQ(res, outValue);
514     delete tmp;
515 }
516 
517 /*
518  * @tc.name: ResourceManagerGetMediaByIdTest016
519  * @tc.desc: Test GetMediaById, to match zh_CN-xxxldpi determinder
520  * @tc.type: FUNC
521  */
522 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest016, TestSize.Level1)
523 {
524     rmc->AddResource("zh", nullptr, "CN");
525 
526     HapResource *tmp = new HapResource(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
527     tmp->Init(rmc->defaultResConfig);
528     std::string res = tmp->GetResourcePath();
529     res.append("entry/resources/zh_CN-xxxldpi/media/icon.png");
530 
531     auto rc = CreateResConfig();
532     if (rc == nullptr) {
533         EXPECT_TRUE(false);
534         return;
535     }
536     rc->SetDeviceType(DEVICE_TABLET);
537     rc->SetColorMode(COLOR_MODE_NOT_SET);
538     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
539     rm->UpdateResConfig(*rc);
540     delete rc;
541 
542     int density = 640;
543     std::string outValue;
544     RState state;
545     int id = rmc->GetResId("icon", ResType::MEDIA);
546     EXPECT_TRUE(id > 0);
547     state = rm->GetMediaById(id, outValue, density);
548     EXPECT_TRUE(state == SUCCESS);
549     EXPECT_EQ(res, outValue);
550     delete tmp;
551 }
552 
553 /*
554  * @tc.name: ResourceManagerGetMediaByIdTest017
555  * @tc.desc: Test GetMediaById, to match mcc460_mnc101-zh_CN-phone-dark-sdpi determinder
556  * @tc.type: FUNC
557  */
558 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest017, TestSize.Level1)
559 {
560     rmc->AddResource("zh", nullptr, "CN");
561 
562     HapResource *tmp = new HapResource(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
563     tmp->Init(rmc->defaultResConfig);
564     std::string res = tmp->GetResourcePath();
565     res.append("entry/resources/mcc460_mnc101-zh_CN-phone-dark-sdpi/media/icon.png");
566 
567     auto rc = CreateResConfig();
568     if (rc == nullptr) {
569         EXPECT_TRUE(false);
570         return;
571     }
572     rc->SetLocaleInfo("zh", nullptr, "CN");
573     rc->SetMcc(460);
574     rc->SetMnc(101);
575     rc->SetDeviceType(DEVICE_PHONE);
576     rc->SetColorMode(DARK);
577     rc->SetScreenDensity(SCREEN_DENSITY_XXXLDPI / BASE_DPI);
578     rm->UpdateResConfig(*rc);
579     delete rc;
580 
581     int density = 120;
582     std::string outValue;
583     RState state;
584     int id = rmc->GetResId("icon", ResType::MEDIA);
585     EXPECT_TRUE(id > 0);
586     state = rm->GetMediaById(id, outValue, density);
587     EXPECT_TRUE(state == SUCCESS);
588     EXPECT_EQ(res, outValue);
589     delete tmp;
590 }
591 
592 /*
593  * @tc.name: ResourceManagerGetMediaByIdTest018
594  * @tc.desc: Test GetMediaById, to match mcc460_mnc101-zh_CN-phone-dark-mdpi determinder
595  * @tc.type: FUNC
596  */
597 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest018, TestSize.Level1)
598 {
599     rmc->AddResource("zh", nullptr, "CN");
600 
601     HapResource *tmp = new HapResource(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
602     tmp->Init(rmc->defaultResConfig);
603     std::string res = tmp->GetResourcePath();
604     res.append("entry/resources/mcc460_mnc101-zh_CN-phone-dark-mdpi/media/icon.png");
605 
606     auto rc = CreateResConfig();
607     if (rc == nullptr) {
608         EXPECT_TRUE(false);
609         return;
610     }
611     rc->SetLocaleInfo("zh", nullptr, "CN");
612     rc->SetMcc(460);
613     rc->SetMnc(101);
614     rc->SetDeviceType(DEVICE_PHONE);
615     rc->SetColorMode(DARK);
616     rc->SetScreenDensity(SCREEN_DENSITY_XXXLDPI / BASE_DPI);
617     rm->UpdateResConfig(*rc);
618     delete rc;
619 
620     int density = 160;
621     std::string outValue;
622     RState state;
623     int id = rmc->GetResId("icon", ResType::MEDIA);
624     EXPECT_TRUE(id > 0);
625     state = rm->GetMediaById(id, outValue, density);
626     EXPECT_TRUE(state == SUCCESS);
627     EXPECT_EQ(res, outValue);
628     delete tmp;
629 }
630 
631 /*
632  * @tc.name: ResourceManagerGetMediaByIdTest019
633  * @tc.desc: Test GetMediaById, to match mcc460_mnc101-zh_CN-phone-dark-ldpi determinder
634  * @tc.type: FUNC
635  */
636 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest019, TestSize.Level1)
637 {
638     rmc->AddResource("zh", nullptr, "CN");
639 
640     HapResource *tmp = new HapResource(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
641     tmp->Init(rmc->defaultResConfig);
642     std::string res = tmp->GetResourcePath();
643     res.append("entry/resources/mcc460_mnc101-zh_CN-phone-dark-ldpi/media/icon.png");
644 
645     auto rc = CreateResConfig();
646     if (rc == nullptr) {
647         EXPECT_TRUE(false);
648         return;
649     }
650     rc->SetLocaleInfo("zh", nullptr, "CN");
651     rc->SetMcc(460);
652     rc->SetMnc(101);
653     rc->SetDeviceType(DEVICE_PHONE);
654     rc->SetColorMode(DARK);
655     rc->SetScreenDensity(SCREEN_DENSITY_XXXLDPI / BASE_DPI);
656     rm->UpdateResConfig(*rc);
657     delete rc;
658 
659     int density = 240;
660     std::string outValue;
661     RState state;
662     int id = rmc->GetResId("icon", ResType::MEDIA);
663     EXPECT_TRUE(id > 0);
664     state = rm->GetMediaById(id, outValue, density);
665     EXPECT_TRUE(state == SUCCESS);
666     EXPECT_EQ(res, outValue);
667     delete tmp;
668 }
669 
670 /*
671  * @tc.name: ResourceManagerGetMediaByIdTest020
672  * @tc.desc: Test GetMediaById, to match mcc460_mnc101-zh_CN-phone-dark-xldpi determinder
673  * @tc.type: FUNC
674  */
675 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest020, TestSize.Level1)
676 {
677     rmc->AddResource("zh", nullptr, "CN");
678 
679     HapResource *tmp = new HapResource(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
680     tmp->Init(rmc->defaultResConfig);
681     std::string res = tmp->GetResourcePath();
682     res.append("entry/resources/mcc460_mnc101-zh_CN-phone-dark-xldpi/media/icon.png");
683 
684     auto rc = CreateResConfig();
685     if (rc == nullptr) {
686         EXPECT_TRUE(false);
687         return;
688     }
689     rc->SetLocaleInfo("zh", nullptr, "CN");
690     rc->SetMcc(460);
691     rc->SetMnc(101);
692     rc->SetDeviceType(DEVICE_PHONE);
693     rc->SetColorMode(DARK);
694     rc->SetScreenDensity(SCREEN_DENSITY_XXXLDPI / BASE_DPI);
695     rm->UpdateResConfig(*rc);
696     delete rc;
697 
698     int density = 320;
699     std::string outValue;
700     RState state;
701     int id = rmc->GetResId("icon", ResType::MEDIA);
702     EXPECT_TRUE(id > 0);
703     state = rm->GetMediaById(id, outValue, density);
704     EXPECT_TRUE(state == SUCCESS);
705     EXPECT_EQ(res, outValue);
706     delete tmp;
707 }
708 
709 /*
710  * @tc.name: ResourceManagerGetMediaByIdTest021
711  * @tc.desc: Test GetMediaById, to match mcc460_mnc101-zh_CN-phone-dark-xxldpi determinder
712  * @tc.type: FUNC
713  */
714 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest021, TestSize.Level1)
715 {
716     rmc->AddResource("zh", nullptr, "CN");
717 
718     HapResource *tmp = new HapResource(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
719     tmp->Init(rmc->defaultResConfig);
720     std::string res = tmp->GetResourcePath();
721     res.append("entry/resources/mcc460_mnc101-zh_CN-phone-dark-xxldpi/media/icon.png");
722 
723     auto rc = CreateResConfig();
724     if (rc == nullptr) {
725         EXPECT_TRUE(false);
726         return;
727     }
728     rc->SetLocaleInfo("zh", nullptr, "CN");
729     rc->SetMcc(460);
730     rc->SetMnc(101);
731     rc->SetDeviceType(DEVICE_PHONE);
732     rc->SetColorMode(DARK);
733     rc->SetScreenDensity(SCREEN_DENSITY_XXXLDPI / BASE_DPI);
734     rm->UpdateResConfig(*rc);
735     delete rc;
736 
737     int density = 480;
738     std::string outValue;
739     RState state;
740     int id = rmc->GetResId("icon", ResType::MEDIA);
741     EXPECT_TRUE(id > 0);
742     state = rm->GetMediaById(id, outValue, density);
743     EXPECT_TRUE(state == SUCCESS);
744     EXPECT_EQ(res, outValue);
745     delete tmp;
746 }
747 
748 /*
749  * @tc.name: ResourceManagerGetMediaByIdTest022
750  * @tc.desc: Test GetMediaById, to match mcc460_mnc101-zh_CN-phone-dark-xxxldpi determinder
751  * @tc.type: FUNC
752  */
753 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest022, TestSize.Level1)
754 {
755     rmc->AddResource("zh", nullptr, "CN");
756 
757     HapResource *tmp = new HapResource(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
758     tmp->Init(rmc->defaultResConfig);
759     std::string res = tmp->GetResourcePath();
760     res.append("entry/resources/mcc460_mnc101-zh_CN-phone-dark-xxxldpi/media/icon.png");
761 
762     auto rc = CreateResConfig();
763     if (rc == nullptr) {
764         EXPECT_TRUE(false);
765         return;
766     }
767     rc->SetLocaleInfo("zh", nullptr, "CN");
768     rc->SetMcc(460);
769     rc->SetMnc(101);
770     rc->SetDeviceType(DEVICE_PHONE);
771     rc->SetColorMode(DARK);
772     rc->SetScreenDensity(SCREEN_DENSITY_XXLDPI / BASE_DPI);
773     rm->UpdateResConfig(*rc);
774     delete rc;
775 
776     int density = 640;
777     std::string outValue;
778     RState state;
779     int id = rmc->GetResId("icon", ResType::MEDIA);
780     EXPECT_TRUE(id > 0);
781     state = rm->GetMediaById(id, outValue, density);
782     EXPECT_TRUE(state == SUCCESS);
783     EXPECT_EQ(res, outValue);
784     delete tmp;
785 }
786 
787 /*
788  * @tc.name: ResourceManagerGetMediaByIdTest023
789  * @tc.desc: Test GetMediaById
790  * @tc.type: FUNC
791  */
792 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest023, TestSize.Level1)
793 {
794     rmc->AddResource("en", nullptr, nullptr);
795 
796     int id = rmc->GetResId("app_name", ResType::STRING);
797     EXPECT_TRUE(id > 0);
798     std::string outValue;
799     RState state = rm->GetMediaById(id, outValue);
800     EXPECT_EQ(state, ERROR_CODE_RES_NOT_FOUND_BY_ID);
801 }
802 
803 /*
804  * @tc.name: ResourceManagerGetDrawableInfoByIdTest001
805  * @tc.desc: Test GetDrawableInfoById
806  * @tc.type: FUNC
807  */
808 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetDrawableInfoByIdTest001, TestSize.Level1)
809 {
810     rmc->AddResource("zh", nullptr, "CN");
811 
812     auto rc = CreateResConfig();
813     if (rc == nullptr) {
814         EXPECT_TRUE(false);
815         return;
816     }
817     rc->SetDeviceType(DEVICE_TABLET);
818     rc->SetColorMode(COLOR_MODE_NOT_SET);
819     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
820     rm->UpdateResConfig(*rc);
821     delete rc;
822 
823     int density = 480;
824     std::unique_ptr<uint8_t[]> outValue;
825     RState state;
826     int id = rmc->GetResId("icon", ResType::MEDIA);
827     EXPECT_TRUE(id > 0);
828     std::tuple<std::string, size_t, std::string> info;
829     state = rm->GetDrawableInfoById(id, info, outValue, 1, density);
830     EXPECT_TRUE(state == SUCCESS);
831 }
832 
833 /*
834  * @tc.name: ResourceManagerGetMediaByNameTest001
835  * @tc.desc: Test GetMediaByName
836  * @tc.type: FUNC
837  */
838 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest001, TestSize.Level1)
839 {
840     rmc->AddResource("zh", nullptr, "CN");
841 
842     HapResource *tmp = new HapResource(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
843     rmc->TestGetMediaByName(tmp);
844     delete tmp;
845 }
846 
847 /*
848  * @tc.name: ResourceManagerGetMediaByNameTest002
849  * @tc.desc: Test GetMediaByName
850  * @tc.type: FUNC
851  */
852 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest002, TestSize.Level1)
853 {
854     rmc->AddResource("zh", nullptr, "CN");
855 
856     std::string outValue;
857     RState state;
858     state = rm->GetMediaByName(g_nonExistName, outValue);
859     ASSERT_EQ(ERROR_CODE_RES_NAME_NOT_FOUND, state);
860 }
861 
862 /*
863  * @tc.name: ResourceManagerGetMediaByNameTest003
864  * @tc.desc: Test GetMediaByName, to match sdpi determinder
865  * @tc.type: FUNC
866  */
867 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest003, TestSize.Level1)
868 {
869     rmc->AddResource("en", nullptr, "US");
870 
871     HapResource *tmp = new HapResource(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
872     rmc->TestGetMediaWithDensityByName(tmp);
873     delete tmp;
874 }
875 
876 /*
877  * @tc.name: ResourceManagerGetMediaByNameTest004
878  * @tc.desc: Test GetMediaByName, to match mdpi determinder
879  * @tc.type: FUNC
880  */
881 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest004, TestSize.Level1)
882 {
883     rmc->AddResource("en", nullptr, "US");
884 
885     HapResource *tmp = new HapResource(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
886     tmp->Init(rmc->defaultResConfig);
887     std::string res = tmp->GetResourcePath();
888     res.append("entry/resources/mdpi/media/icon.png");
889 
890     auto rc = CreateResConfig();
891     if (rc == nullptr) {
892         EXPECT_TRUE(false);
893         return;
894     }
895     rc->SetDeviceType(DEVICE_PHONE);
896     rc->SetColorMode(COLOR_MODE_NOT_SET);
897     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
898     rm->UpdateResConfig(*rc);
899     delete rc;
900 
901     uint32_t density = 160;
902     std::string outValue;
903     RState state;
904     state = rm->GetMediaByName("icon", outValue, density);
905     EXPECT_TRUE(state == SUCCESS);
906     EXPECT_EQ(res, outValue);
907     delete tmp;
908 }
909 
910 /*
911  * @tc.name: ResourceManagerGetMediaByNameTest005
912  * @tc.desc: Test GetMediaByName, to match ldpi determinder
913  * @tc.type: FUNC
914  */
915 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest005, TestSize.Level1)
916 {
917     rmc->AddResource("en", nullptr, "US");
918 
919     HapResource *tmp = new HapResource(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
920     tmp->Init(rmc->defaultResConfig);
921     std::string res = tmp->GetResourcePath();
922     res.append("entry/resources/ldpi/media/icon.png");
923 
924     auto rc = CreateResConfig();
925     if (rc == nullptr) {
926         EXPECT_TRUE(false);
927         return;
928     }
929     rc->SetDeviceType(DEVICE_PHONE);
930     rc->SetColorMode(COLOR_MODE_NOT_SET);
931     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
932     rm->UpdateResConfig(*rc);
933     delete rc;
934 
935     uint32_t density = 240;
936     std::string outValue;
937     RState state;
938     state = rm->GetMediaByName("icon", outValue, density);
939     EXPECT_TRUE(state == SUCCESS);
940     EXPECT_EQ(res, outValue);
941     delete tmp;
942 }
943 
944 /*
945  * @tc.name: ResourceManagerGetMediaByNameTest006
946  * @tc.desc: Test GetMediaByName, to match xldpi determinder
947  * @tc.type: FUNC
948  */
949 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest006, TestSize.Level1)
950 {
951     rmc->AddResource("en", nullptr, "US");
952 
953     HapResource *tmp = new HapResource(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
954     tmp->Init(rmc->defaultResConfig);
955     std::string res = tmp->GetResourcePath();
956     res.append("entry/resources/xldpi/media/icon.png");
957 
958     auto rc = CreateResConfig();
959     if (rc == nullptr) {
960         EXPECT_TRUE(false);
961         return;
962     }
963     rc->SetDeviceType(DEVICE_PHONE);
964     rc->SetColorMode(COLOR_MODE_NOT_SET);
965     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
966     rm->UpdateResConfig(*rc);
967     delete rc;
968 
969     uint32_t density = 320;
970     std::string outValue;
971     RState state;
972     state = rm->GetMediaByName("icon", outValue, density);
973     EXPECT_TRUE(state == SUCCESS);
974     EXPECT_EQ(res, outValue);
975     delete tmp;
976 }
977 
978 /*
979  * @tc.name: ResourceManagerGetMediaByNameTest007
980  * @tc.desc: Test GetMediaByName, to match xxldpi determinder
981  * @tc.type: FUNC
982  */
983 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest007, TestSize.Level1)
984 {
985     rmc->AddResource("en", nullptr, "US");
986 
987     HapResource *tmp = new HapResource(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
988     tmp->Init(rmc->defaultResConfig);
989     std::string res = tmp->GetResourcePath();
990     res.append("entry/resources/xxldpi/media/icon.png");
991 
992     auto rc = CreateResConfig();
993     if (rc == nullptr) {
994         EXPECT_TRUE(false);
995         return;
996     }
997     rc->SetDeviceType(DEVICE_PHONE);
998     rc->SetColorMode(COLOR_MODE_NOT_SET);
999     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
1000     rm->UpdateResConfig(*rc);
1001     delete rc;
1002 
1003     uint32_t density = 480;
1004     std::string outValue;
1005     RState state;
1006     state = rm->GetMediaByName("icon", outValue, density);
1007     EXPECT_TRUE(state == SUCCESS);
1008     EXPECT_EQ(res, outValue);
1009     delete tmp;
1010 }
1011 
1012 /*
1013  * @tc.name: ResourceManagerGetMediaByNameTest008
1014  * @tc.desc: Test GetMediaByName, to match xxxldpi determinder
1015  * @tc.type: FUNC
1016  */
1017 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest008, TestSize.Level1)
1018 {
1019     rmc->AddResource("en", nullptr, "US");
1020 
1021     HapResource *tmp = new HapResource(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
1022     tmp->Init(rmc->defaultResConfig);
1023     std::string res = tmp->GetResourcePath();
1024     res.append("entry/resources/xxxldpi/media/icon.png");
1025 
1026     auto rc = CreateResConfig();
1027     if (rc == nullptr) {
1028         EXPECT_TRUE(false);
1029         return;
1030     }
1031     rc->SetDeviceType(DEVICE_PHONE);
1032     rc->SetColorMode(COLOR_MODE_NOT_SET);
1033     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
1034     rm->UpdateResConfig(*rc);
1035     delete rc;
1036 
1037     uint32_t density = 640;
1038     std::string outValue;
1039     RState state;
1040     state = rm->GetMediaByName("icon", outValue, density);
1041     EXPECT_TRUE(state == SUCCESS);
1042     EXPECT_EQ(res, outValue);
1043     delete tmp;
1044 }
1045 
1046 /*
1047  * @tc.name: ResourceManagerGetMediaByNameTest009
1048  * @tc.desc: Test GetMediaByName, to match unsupport density
1049  * @tc.type: FUNC
1050  */
1051 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest009, TestSize.Level1)
1052 {
1053     rmc->AddResource("en", nullptr, "US");
1054 
1055     uint32_t density1 = 420;
1056     uint32_t density2 = 800;
1057     uint32_t density3 = 10;
1058     std::string outValue;
1059     RState state1;
1060     RState state2;
1061     RState state3;
1062     state1 = rm->GetMediaByName("icon", outValue, density1);
1063     state2 = rm->GetMediaByName("icon", outValue, density2);
1064     state3 = rm->GetMediaByName("icon", outValue, density3);
1065     EXPECT_TRUE(state1 == ERROR_CODE_INVALID_INPUT_PARAMETER);
1066     EXPECT_TRUE(state2 == ERROR_CODE_INVALID_INPUT_PARAMETER);
1067     EXPECT_TRUE(state3 == ERROR_CODE_INVALID_INPUT_PARAMETER);
1068 }
1069 
1070 /*
1071  * @tc.name: ResourceManagerGetMediaByNameTest010
1072  * @tc.desc: Test GetMediaByName, to match with no density param
1073  * @tc.type: FUNC
1074  */
1075 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest010, TestSize.Level1)
1076 {
1077     rmc->AddResource("en", nullptr, "US");
1078 
1079     uint32_t density = 0;
1080     std::string outValue1;
1081     std::string outValue2;
1082     RState state1;
1083     RState state2;
1084     state1 = rm->GetMediaByName("icon", outValue1, density);
1085     state2 = rm->GetMediaByName("icon", outValue2);
1086     EXPECT_TRUE(state1 == SUCCESS);
1087     EXPECT_TRUE(state2 == SUCCESS);
1088     EXPECT_EQ(outValue1, outValue2);
1089 }
1090 
1091 /*
1092  * @tc.name: ResourceManagerGetMediaByNameTest011
1093  * @tc.desc: Test GetMediaByName, to match zh_CN-sdpi determinder
1094  * @tc.type: FUNC
1095  */
1096 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest011, TestSize.Level1)
1097 {
1098     rmc->AddResource("zh", nullptr, "CN");
1099 
1100     HapResource *tmp = new HapResource(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
1101     tmp->Init(rmc->defaultResConfig);
1102     std::string res = tmp->GetResourcePath();
1103     res.append("entry/resources/zh_CN-sdpi/media/icon.png");
1104 
1105     auto rc = CreateResConfig();
1106     if (rc == nullptr) {
1107         EXPECT_TRUE(false);
1108         return;
1109     }
1110     rc->SetDeviceType(DEVICE_TABLET);
1111     rc->SetColorMode(COLOR_MODE_NOT_SET);
1112     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
1113     rm->UpdateResConfig(*rc);
1114     delete rc;
1115 
1116     int density = 120;
1117     std::string outValue;
1118     RState state;
1119     state = rm->GetMediaByName("icon", outValue, density);
1120     EXPECT_TRUE(state == SUCCESS);
1121     EXPECT_EQ(res, outValue);
1122     delete tmp;
1123 }
1124 
1125 /*
1126  * @tc.name: ResourceManagerGetMediaByNameTest012
1127  * @tc.desc: Test GetMediaByName, to match zh_CN-mdpi determinder
1128  * @tc.type: FUNC
1129  */
1130 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest012, TestSize.Level1)
1131 {
1132     rmc->AddResource("zh", nullptr, "CN");
1133 
1134     HapResource *tmp = new HapResource(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
1135     tmp->Init(rmc->defaultResConfig);
1136     std::string res = tmp->GetResourcePath();
1137     res.append("entry/resources/zh_CN-mdpi/media/icon.png");
1138 
1139     auto rc = CreateResConfig();
1140     if (rc == nullptr) {
1141         EXPECT_TRUE(false);
1142         return;
1143     }
1144     rc->SetDeviceType(DEVICE_TABLET);
1145     rc->SetColorMode(COLOR_MODE_NOT_SET);
1146     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
1147     rm->UpdateResConfig(*rc);
1148     delete rc;
1149 
1150     int density = 160;
1151     std::string outValue;
1152     RState state;
1153     state = rm->GetMediaByName("icon", outValue, density);
1154     EXPECT_TRUE(state == SUCCESS);
1155     EXPECT_EQ(res, outValue);
1156     delete tmp;
1157 }
1158 
1159 /*
1160  * @tc.name: ResourceManagerGetMediaByNameTest013
1161  * @tc.desc: Test GetMediaByName, to match zh_CN-ldpi determinder
1162  * @tc.type: FUNC
1163  */
1164 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest013, TestSize.Level1)
1165 {
1166     rmc->AddResource("zh", nullptr, "CN");
1167 
1168     HapResource *tmp = new HapResource(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
1169     tmp->Init(rmc->defaultResConfig);
1170     std::string res = tmp->GetResourcePath();
1171     res.append("entry/resources/zh_CN-ldpi/media/icon.png");
1172 
1173     auto rc = CreateResConfig();
1174     if (rc == nullptr) {
1175         EXPECT_TRUE(false);
1176         return;
1177     }
1178     rc->SetDeviceType(DEVICE_TABLET);
1179     rc->SetColorMode(COLOR_MODE_NOT_SET);
1180     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
1181     rm->UpdateResConfig(*rc);
1182     delete rc;
1183 
1184     int density = 240;
1185     std::string outValue;
1186     RState state;
1187     state = rm->GetMediaByName("icon", outValue, density);
1188     EXPECT_TRUE(state == SUCCESS);
1189     EXPECT_EQ(res, outValue);
1190     delete tmp;
1191 }
1192 
1193 /*
1194  * @tc.name: ResourceManagerGetMediaByNameTest014
1195  * @tc.desc: Test GetMediaByName, to match zh_CN-xldpi determinder
1196  * @tc.type: FUNC
1197  */
1198 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest014, TestSize.Level1)
1199 {
1200     rmc->AddResource("zh", nullptr, "CN");
1201 
1202     HapResource *tmp = new HapResource(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
1203     tmp->Init(rmc->defaultResConfig);
1204     std::string res = tmp->GetResourcePath();
1205     res.append("entry/resources/zh_CN-xldpi/media/icon.png");
1206 
1207     auto rc = CreateResConfig();
1208     if (rc == nullptr) {
1209         EXPECT_TRUE(false);
1210         return;
1211     }
1212     rc->SetDeviceType(DEVICE_TABLET);
1213     rc->SetColorMode(COLOR_MODE_NOT_SET);
1214     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
1215     rm->UpdateResConfig(*rc);
1216     delete rc;
1217 
1218     int density = 320;
1219     std::string outValue;
1220     RState state;
1221     state = rm->GetMediaByName("icon", outValue, density);
1222     EXPECT_TRUE(state == SUCCESS);
1223     EXPECT_EQ(res, outValue);
1224     delete tmp;
1225 }
1226 
1227 /*
1228  * @tc.name: ResourceManagerGetMediaByNameTest015
1229  * @tc.desc: Test GetMediaByName, to match zh_CN-xxldpi determinder
1230  * @tc.type: FUNC
1231  */
1232 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest015, TestSize.Level1)
1233 {
1234     rmc->AddResource("zh", nullptr, "CN");
1235 
1236     HapResource *tmp = new HapResource(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
1237     tmp->Init(rmc->defaultResConfig);
1238     std::string res = tmp->GetResourcePath();
1239     res.append("entry/resources/zh_CN-xxldpi/media/icon.png");
1240 
1241     auto rc = CreateResConfig();
1242     if (rc == nullptr) {
1243         EXPECT_TRUE(false);
1244         return;
1245     }
1246     rc->SetDeviceType(DEVICE_TABLET);
1247     rc->SetColorMode(COLOR_MODE_NOT_SET);
1248     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
1249     rm->UpdateResConfig(*rc);
1250     delete rc;
1251 
1252     int density = 480;
1253     std::string outValue;
1254     RState state;
1255     state = rm->GetMediaByName("icon", outValue, density);
1256     EXPECT_TRUE(state == SUCCESS);
1257     EXPECT_EQ(res, outValue);
1258     delete tmp;
1259 }
1260 
1261 /*
1262  * @tc.name: ResourceManagerGetMediaByNameTest016
1263  * @tc.desc: Test GetMediaByName, to match zh_CN-xxxldpi determinder
1264  * @tc.type: FUNC
1265  */
1266 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest016, TestSize.Level1)
1267 {
1268     rmc->AddResource("zh", nullptr, "CN");
1269 
1270     HapResource *tmp = new HapResource(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
1271     tmp->Init(rmc->defaultResConfig);
1272     std::string res = tmp->GetResourcePath();
1273     res.append("entry/resources/zh_CN-xxxldpi/media/icon.png");
1274 
1275     auto rc = CreateResConfig();
1276     if (rc == nullptr) {
1277         EXPECT_TRUE(false);
1278         return;
1279     }
1280     rc->SetDeviceType(DEVICE_TABLET);
1281     rc->SetColorMode(COLOR_MODE_NOT_SET);
1282     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
1283     rm->UpdateResConfig(*rc);
1284     delete rc;
1285 
1286     int density = 640;
1287     std::string outValue;
1288     RState state;
1289     state = rm->GetMediaByName("icon", outValue, density);
1290     EXPECT_TRUE(state == SUCCESS);
1291     EXPECT_EQ(res, outValue);
1292     delete tmp;
1293 }
1294 
1295 /*
1296  * @tc.name: ResourceManagerGetMediaByNameTest017
1297  * @tc.desc: Test GetMediaByName, to match mcc460_mnc101-zh_CN-phone-dark-sdpi determinder
1298  * @tc.type: FUNC
1299  */
1300 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest017, TestSize.Level1)
1301 {
1302     rmc->AddResource("zh", nullptr, "CN");
1303 
1304     HapResource *tmp = new HapResource(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
1305     tmp->Init(rmc->defaultResConfig);
1306     std::string res = tmp->GetResourcePath();
1307     res.append("entry/resources/mcc460_mnc101-zh_CN-phone-dark-sdpi/media/icon.png");
1308 
1309     auto rc = CreateResConfig();
1310     if (rc == nullptr) {
1311         EXPECT_TRUE(false);
1312         return;
1313     }
1314     rc->SetMcc(460);
1315     rc->SetMnc(101);
1316     rc->SetLocaleInfo("zh", nullptr, "CN");
1317     rc->SetDeviceType(DEVICE_PHONE);
1318     rc->SetColorMode(DARK);
1319     rc->SetScreenDensity(SCREEN_DENSITY_XXXLDPI / BASE_DPI);
1320     rm->UpdateResConfig(*rc);
1321     delete rc;
1322 
1323     int density = 120;
1324     std::string outValue;
1325     RState state;
1326     state = rm->GetMediaByName("icon", outValue, density);
1327     EXPECT_TRUE(state == SUCCESS);
1328     EXPECT_EQ(res, outValue);
1329     delete tmp;
1330 }
1331 
1332 /*
1333  * @tc.name: ResourceManagerGetMediaByNameTest018
1334  * @tc.desc: Test GetMediaByName, to match mcc460_mnc101-zh_CN-phone-dark-mdpi determinder
1335  * @tc.type: FUNC
1336  */
1337 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest018, TestSize.Level1)
1338 {
1339     rmc->AddResource("zh", nullptr, "CN");
1340 
1341     HapResource *tmp = new HapResource(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
1342     tmp->Init(rmc->defaultResConfig);
1343     std::string res = tmp->GetResourcePath();
1344     res.append("entry/resources/mcc460_mnc101-zh_CN-phone-dark-mdpi/media/icon.png");
1345 
1346     auto rc = CreateResConfig();
1347     if (rc == nullptr) {
1348         EXPECT_TRUE(false);
1349         return;
1350     }
1351     rc->SetMcc(460);
1352     rc->SetMnc(101);
1353     rc->SetLocaleInfo("zh", nullptr, "CN");
1354     rc->SetDeviceType(DEVICE_PHONE);
1355     rc->SetColorMode(DARK);
1356     rc->SetScreenDensity(SCREEN_DENSITY_XXXLDPI / BASE_DPI);
1357     rm->UpdateResConfig(*rc);
1358     delete rc;
1359 
1360     int density = 160;
1361     std::string outValue;
1362     RState state;
1363     state = rm->GetMediaByName("icon", outValue, density);
1364     EXPECT_TRUE(state == SUCCESS);
1365     EXPECT_EQ(res, outValue);
1366     delete tmp;
1367 }
1368 
1369 /*
1370  * @tc.name: ResourceManagerGetMediaByNameTest019
1371  * @tc.desc: Test GetMediaByName, to match mcc460_mnc101-zh_CN-phone-dark-ldpi determinder
1372  * @tc.type: FUNC
1373  */
1374 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest019, TestSize.Level1)
1375 {
1376     rmc->AddResource("zh", nullptr, "CN");
1377 
1378     HapResource *tmp = new HapResource(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
1379     tmp->Init(rmc->defaultResConfig);
1380     std::string res = tmp->GetResourcePath();
1381     res.append("entry/resources/mcc460_mnc101-zh_CN-phone-dark-ldpi/media/icon.png");
1382 
1383     auto rc = CreateResConfig();
1384     if (rc == nullptr) {
1385         EXPECT_TRUE(false);
1386         return;
1387     }
1388     rc->SetMcc(460);
1389     rc->SetMnc(101);
1390     rc->SetLocaleInfo("zh", nullptr, "CN");
1391     rc->SetDeviceType(DEVICE_PHONE);
1392     rc->SetColorMode(DARK);
1393     rc->SetScreenDensity(SCREEN_DENSITY_XXXLDPI / BASE_DPI);
1394     rm->UpdateResConfig(*rc);
1395     delete rc;
1396 
1397     int density = 240;
1398     std::string outValue;
1399     RState state;
1400     state = rm->GetMediaByName("icon", outValue, density);
1401     EXPECT_TRUE(state == SUCCESS);
1402     EXPECT_EQ(res, outValue);
1403     delete tmp;
1404 }
1405 
1406 /*
1407  * @tc.name: ResourceManagerGetMediaByNameTest020
1408  * @tc.desc: Test GetMediaByName, to match mcc460_mnc101-zh_CN-phone-dark-xldpi determinder
1409  * @tc.type: FUNC
1410  */
1411 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest020, TestSize.Level1)
1412 {
1413     rmc->AddResource("zh", nullptr, "CN");
1414 
1415     HapResource *tmp = new HapResource(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
1416     tmp->Init(rmc->defaultResConfig);
1417     std::string res = tmp->GetResourcePath();
1418     res.append("entry/resources/mcc460_mnc101-zh_CN-phone-dark-xldpi/media/icon.png");
1419 
1420     auto rc = CreateResConfig();
1421     if (rc == nullptr) {
1422         EXPECT_TRUE(false);
1423         return;
1424     }
1425     rc->SetMcc(460);
1426     rc->SetMnc(101);
1427     rc->SetLocaleInfo("zh", nullptr, "CN");
1428     rc->SetDeviceType(DEVICE_PHONE);
1429     rc->SetColorMode(DARK);
1430     rc->SetScreenDensity(SCREEN_DENSITY_XXXLDPI / BASE_DPI);
1431     rm->UpdateResConfig(*rc);
1432     delete rc;
1433 
1434     int density = 320;
1435     std::string outValue;
1436     RState state;
1437     state = rm->GetMediaByName("icon", outValue, density);
1438     EXPECT_TRUE(state == SUCCESS);
1439     EXPECT_EQ(res, outValue);
1440     delete tmp;
1441 }
1442 
1443 /*
1444  * @tc.name: ResourceManagerGetMediaByNameTest021
1445  * @tc.desc: Test GetMediaByName, to match mcc460_mnc101-zh_CN-phone-dark-xxldpi determinder
1446  * @tc.type: FUNC
1447  */
1448 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest021, TestSize.Level1)
1449 {
1450     rmc->AddResource("zh", nullptr, "CN");
1451 
1452     HapResource *tmp = new HapResource(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
1453     tmp->Init(rmc->defaultResConfig);
1454     std::string res = tmp->GetResourcePath();
1455     res.append("entry/resources/mcc460_mnc101-zh_CN-phone-dark-xxldpi/media/icon.png");
1456 
1457     auto rc = CreateResConfig();
1458     if (rc == nullptr) {
1459         EXPECT_TRUE(false);
1460         return;
1461     }
1462     rc->SetMcc(460);
1463     rc->SetMnc(101);
1464     rc->SetLocaleInfo("zh", nullptr, "CN");
1465     rc->SetDeviceType(DEVICE_PHONE);
1466     rc->SetColorMode(DARK);
1467     rc->SetScreenDensity(SCREEN_DENSITY_XXXLDPI / BASE_DPI);
1468     rm->UpdateResConfig(*rc);
1469     delete rc;
1470 
1471     int density = 480;
1472     std::string outValue;
1473     RState state;
1474     state = rm->GetMediaByName("icon", outValue, density);
1475     EXPECT_TRUE(state == SUCCESS);
1476     EXPECT_EQ(res, outValue);
1477     delete tmp;
1478 }
1479 
1480 /*
1481  * @tc.name: ResourceManagerGetMediaByNameTest022
1482  * @tc.desc: Test GetMediaByName, to match mcc460_mnc101-zh_CN-phone-dark-xxxldpi determinder
1483  * @tc.type: FUNC
1484  */
1485 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest022, TestSize.Level1)
1486 {
1487     rmc->AddResource("zh", nullptr, "CN");
1488 
1489     HapResource *tmp = new HapResource(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
1490     tmp->Init(rmc->defaultResConfig);
1491     std::string res = tmp->GetResourcePath();
1492     res.append("entry/resources/mcc460_mnc101-zh_CN-phone-dark-xxxldpi/media/icon.png");
1493 
1494     auto rc = CreateResConfig();
1495     if (rc == nullptr) {
1496         EXPECT_TRUE(false);
1497         return;
1498     }
1499     rc->SetMcc(460);
1500     rc->SetMnc(101);
1501     rc->SetLocaleInfo("zh", nullptr, "CN");
1502     rc->SetDeviceType(DEVICE_PHONE);
1503     rc->SetColorMode(DARK);
1504     rc->SetScreenDensity(SCREEN_DENSITY_XXXLDPI / BASE_DPI);
1505     rm->UpdateResConfig(*rc);
1506     delete rc;
1507 
1508     int density = 640;
1509     std::string outValue;
1510     RState state;
1511     state = rm->GetMediaByName("icon", outValue, density);
1512     EXPECT_TRUE(state == SUCCESS);
1513     EXPECT_EQ(res, outValue);
1514     delete tmp;
1515 }
1516 
1517 /*
1518  * @tc.name: ResourceManagerGetDrawableInfoByNameTest001
1519  * @tc.desc: Test GetDrawableInfoByName
1520  * @tc.type: FUNC
1521  */
1522 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetDrawableInfoByNameTest001, TestSize.Level1)
1523 {
1524     rmc->AddResource("zh", nullptr, "CN");
1525 
1526     auto rc = CreateResConfig();
1527     if (rc == nullptr) {
1528         EXPECT_TRUE(false);
1529         return;
1530     }
1531     rc->SetDeviceType(DEVICE_TABLET);
1532     rc->SetColorMode(COLOR_MODE_NOT_SET);
1533     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
1534     rm->UpdateResConfig(*rc);
1535     delete rc;
1536 
1537     int density = 480;
1538     std::unique_ptr<uint8_t[]> outValue;
1539     RState state;
1540     std::tuple<std::string, size_t, std::string> info;
1541     state = rm->GetDrawableInfoByName("icon", info, outValue, 1, density);
1542     EXPECT_TRUE(state == SUCCESS);
1543 }
1544 }