• 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_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     HapResourceV1 *tmp = new HapResourceV1(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     HapResourceV1 *tmp = new HapResourceV1(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     HapResourceV1 *tmp = new HapResourceV1(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         ASSERT_TRUE(false);
126     }
127     rc->SetDeviceType(DEVICE_TV);
128     rc->SetColorMode(COLOR_MODE_NOT_SET);
129     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
130     rm->UpdateResConfig(*rc);
131     delete rc;
132 
133     int density = 160;
134     std::string outValue;
135     RState state;
136     int id = rmc->GetResId("icon", ResType::MEDIA);
137     EXPECT_TRUE(id > 0);
138     state = rm->GetMediaById(id, outValue, density);
139     EXPECT_TRUE(state == SUCCESS);
140     EXPECT_EQ(res, outValue);
141     delete tmp;
142 }
143 
144 /*
145  * @tc.name: ResourceManagerGetMediaByIdTest005
146  * @tc.desc: Test GetMediaById, to match ldpi determinder
147  * @tc.type: FUNC
148  */
149 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest005, TestSize.Level1)
150 {
151     rmc->AddResource("en", nullptr, "US");
152 
153     HapResourceV1 *tmp = new HapResourceV1(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
154     tmp->Init(rmc->defaultResConfig);
155     std::string res = tmp->GetResourcePath();
156     res.append("entry/resources/ldpi/media/icon.png");
157 
158     auto rc = CreateResConfig();
159     if (rc == nullptr) {
160         ASSERT_TRUE(false);
161     }
162     rc->SetDeviceType(DEVICE_PHONE);
163     rc->SetColorMode(COLOR_MODE_NOT_SET);
164     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
165     rm->UpdateResConfig(*rc);
166     delete rc;
167 
168     int density = 240;
169     std::string outValue;
170     RState state;
171     int id = rmc->GetResId("icon", ResType::MEDIA);
172     EXPECT_TRUE(id > 0);
173     state = rm->GetMediaById(id, outValue, density);
174     EXPECT_TRUE(state == SUCCESS);
175     EXPECT_EQ(res, outValue);
176     delete tmp;
177 }
178 
179 /*
180  * @tc.name: ResourceManagerGetMediaByIdTest006
181  * @tc.desc: Test GetMediaById, to match xldpi determinder
182  * @tc.type: FUNC
183  */
184 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest006, TestSize.Level1)
185 {
186     rmc->AddResource("en", nullptr, "US");
187 
188     HapResourceV1 *tmp = new HapResourceV1(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
189     tmp->Init(rmc->defaultResConfig);
190     std::string res = tmp->GetResourcePath();
191     res.append("entry/resources/xldpi/media/icon.png");
192 
193     auto rc = CreateResConfig();
194     if (rc == nullptr) {
195         ASSERT_TRUE(false);
196     }
197     rc->SetDeviceType(DEVICE_PHONE);
198     rc->SetColorMode(COLOR_MODE_NOT_SET);
199     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
200     rm->UpdateResConfig(*rc);
201     delete rc;
202 
203     int density = 320;
204     std::string outValue;
205     RState state;
206     int id = rmc->GetResId("icon", ResType::MEDIA);
207     EXPECT_TRUE(id > 0);
208     state = rm->GetMediaById(id, outValue, density);
209     EXPECT_TRUE(state == SUCCESS);
210     EXPECT_EQ(res, outValue);
211     delete tmp;
212 }
213 
214 /*
215  * @tc.name: ResourceManagerGetMediaByIdTest007
216  * @tc.desc: Test GetMediaById, to match xxldpi determinder
217  * @tc.type: FUNC
218  */
219 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest007, TestSize.Level1)
220 {
221     rmc->AddResource("en", nullptr, "US");
222 
223     HapResourceV1 *tmp = new HapResourceV1(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
224     tmp->Init(rmc->defaultResConfig);
225     std::string res = tmp->GetResourcePath();
226     res.append("entry/resources/xxldpi/media/icon.png");
227 
228     auto rc = CreateResConfig();
229     if (rc == nullptr) {
230         ASSERT_TRUE(false);
231     }
232     rc->SetDeviceType(DEVICE_PHONE);
233     rc->SetColorMode(COLOR_MODE_NOT_SET);
234     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
235     rm->UpdateResConfig(*rc);
236     delete rc;
237 
238     int density = 480;
239     std::string outValue;
240     RState state;
241     int id = rmc->GetResId("icon", ResType::MEDIA);
242     EXPECT_TRUE(id > 0);
243     state = rm->GetMediaById(id, outValue, density);
244     EXPECT_TRUE(state == SUCCESS);
245     EXPECT_EQ(res, outValue);
246     delete tmp;
247 }
248 
249 /*
250  * @tc.name: ResourceManagerGetMediaByIdTest008
251  * @tc.desc: Test GetMediaById, to match xxxldpi determinder
252  * @tc.type: FUNC
253  */
254 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest008, TestSize.Level1)
255 {
256     rmc->AddResource("en", nullptr, "US");
257 
258     HapResourceV1 *tmp = new HapResourceV1(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
259     tmp->Init(rmc->defaultResConfig);
260     std::string res = tmp->GetResourcePath();
261     res.append("entry/resources/xxxldpi/media/icon.png");
262 
263     auto rc = CreateResConfig();
264     if (rc == nullptr) {
265         ASSERT_TRUE(false);
266     }
267     rc->SetDeviceType(DEVICE_PHONE);
268     rc->SetColorMode(COLOR_MODE_NOT_SET);
269     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
270     rm->UpdateResConfig(*rc);
271     delete rc;
272 
273     int density = 640;
274     std::string outValue;
275     RState state;
276     int id = rmc->GetResId("icon", ResType::MEDIA);
277     EXPECT_TRUE(id > 0);
278     state = rm->GetMediaById(id, outValue, density);
279     EXPECT_TRUE(state == SUCCESS);
280     EXPECT_EQ(res, outValue);
281     delete tmp;
282 }
283 
284 /*
285  * @tc.name: ResourceManagerGetMediaByIdTest009
286  * @tc.desc: Test GetMediaById, to match unsupport density
287  * @tc.type: FUNC
288  */
289 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest009, TestSize.Level1)
290 {
291     rmc->AddResource("en", nullptr, "US");
292 
293     uint32_t density1 = 420;
294     uint32_t density2 = 800;
295     uint32_t density3 = 10;
296     std::string outValue;
297     RState state1;
298     RState state2;
299     RState state3;
300     int id = rmc->GetResId("icon", ResType::MEDIA);
301     EXPECT_TRUE(id > 0);
302     state1 = rm->GetMediaById(id, outValue, density1);
303     state2 = rm->GetMediaById(id, outValue, density2);
304     state3 = rm->GetMediaById(id, outValue, density3);
305     EXPECT_TRUE(state1 == ERROR_CODE_INVALID_INPUT_PARAMETER);
306     EXPECT_TRUE(state2 == ERROR_CODE_INVALID_INPUT_PARAMETER);
307     EXPECT_TRUE(state3 == ERROR_CODE_INVALID_INPUT_PARAMETER);
308 }
309 
310 /*
311  * @tc.name: ResourceManagerGetMediaByIdTest010
312  * @tc.desc: Test GetMediaById, to match with no density param
313  * @tc.type: FUNC
314  */
315 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest010, TestSize.Level1)
316 {
317     rmc->AddResource("en", nullptr, "US");
318 
319     uint32_t density = 0;
320     std::string outValue1;
321     std::string outValue2;
322     RState state1;
323     RState state2;
324     int id = rmc->GetResId("icon", ResType::MEDIA);
325     state1 = rm->GetMediaById(id, outValue1, density);
326     state2 = rm->GetMediaById(id, outValue2);
327     EXPECT_TRUE(state1 == SUCCESS);
328     EXPECT_TRUE(state2 == SUCCESS);
329     EXPECT_EQ(outValue1, outValue2);
330 }
331 
332 /*
333  * @tc.name: ResourceManagerGetMediaByIdTest011
334  * @tc.desc: Test GetMediaById, to match zh_CN-sdpi determinder
335  * @tc.type: FUNC
336  */
337 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest011, TestSize.Level1)
338 {
339     rmc->AddResource("zh", nullptr, "CN");
340 
341     HapResourceV1 *tmp = new HapResourceV1(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
342     tmp->Init(rmc->defaultResConfig);
343     std::string res = tmp->GetResourcePath();
344     res.append("entry/resources/zh_CN-sdpi/media/icon.png");
345 
346     auto rc = CreateResConfig();
347     if (rc == nullptr) {
348         ASSERT_TRUE(false);
349     }
350     rc->SetDeviceType(DEVICE_TABLET);
351     rc->SetColorMode(COLOR_MODE_NOT_SET);
352     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
353     rm->UpdateResConfig(*rc);
354     delete rc;
355 
356     int density = 120;
357     std::string outValue;
358     RState state;
359     int id = rmc->GetResId("icon", ResType::MEDIA);
360     EXPECT_TRUE(id > 0);
361     state = rm->GetMediaById(id, outValue, density);
362     EXPECT_TRUE(state == SUCCESS);
363     EXPECT_EQ(res, outValue);
364     delete tmp;
365 }
366 
367 /*
368  * @tc.name: ResourceManagerGetMediaByIdTest012
369  * @tc.desc: Test GetMediaById, to match zh_CN-mdpi determinder
370  * @tc.type: FUNC
371  */
372 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest012, TestSize.Level1)
373 {
374     rmc->AddResource("zh", nullptr, "CN");
375 
376     HapResourceV1 *tmp = new HapResourceV1(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
377     tmp->Init(rmc->defaultResConfig);
378     std::string res = tmp->GetResourcePath();
379     res.append("entry/resources/zh_CN-mdpi/media/icon.png");
380 
381     auto rc = CreateResConfig();
382     if (rc == nullptr) {
383         ASSERT_TRUE(false);
384     }
385     rc->SetDeviceType(DEVICE_TABLET);
386     rc->SetColorMode(COLOR_MODE_NOT_SET);
387     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
388     rm->UpdateResConfig(*rc);
389     delete rc;
390 
391     int density = 160;
392     std::string outValue;
393     RState state;
394     int id = rmc->GetResId("icon", ResType::MEDIA);
395     EXPECT_TRUE(id > 0);
396     state = rm->GetMediaById(id, outValue, density);
397     EXPECT_TRUE(state == SUCCESS);
398     EXPECT_EQ(res, outValue);
399     delete tmp;
400 }
401 
402 /*
403  * @tc.name: ResourceManagerGetMediaByIdTest013
404  * @tc.desc: Test GetMediaById, to match zh_CN-ldpi determinder
405  * @tc.type: FUNC
406  */
407 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest013, TestSize.Level1)
408 {
409     rmc->AddResource("zh", nullptr, "CN");
410 
411     HapResourceV1 *tmp = new HapResourceV1(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
412     tmp->Init(rmc->defaultResConfig);
413     std::string res = tmp->GetResourcePath();
414     res.append("entry/resources/zh_CN-ldpi/media/icon.png");
415 
416     auto rc = CreateResConfig();
417     if (rc == nullptr) {
418         ASSERT_TRUE(false);
419     }
420     rc->SetDeviceType(DEVICE_TABLET);
421     rc->SetColorMode(COLOR_MODE_NOT_SET);
422     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
423     rm->UpdateResConfig(*rc);
424     delete rc;
425 
426     int density = 240;
427     std::string outValue;
428     RState state;
429     int id = rmc->GetResId("icon", ResType::MEDIA);
430     EXPECT_TRUE(id > 0);
431     state = rm->GetMediaById(id, outValue, density);
432     EXPECT_TRUE(state == SUCCESS);
433     EXPECT_EQ(res, outValue);
434     delete tmp;
435 }
436 
437 /*
438  * @tc.name: ResourceManagerGetMediaByIdTest014
439  * @tc.desc: Test GetMediaById, to match zh_CN-xldpi determinder
440  * @tc.type: FUNC
441  */
442 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest014, TestSize.Level1)
443 {
444     rmc->AddResource("zh", nullptr, "CN");
445 
446     HapResourceV1 *tmp = new HapResourceV1(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
447     tmp->Init(rmc->defaultResConfig);
448     std::string res = tmp->GetResourcePath();
449     res.append("entry/resources/zh_CN-xldpi/media/icon.png");
450 
451     auto rc = CreateResConfig();
452     if (rc == nullptr) {
453         ASSERT_TRUE(false);
454     }
455     rc->SetDeviceType(DEVICE_TABLET);
456     rc->SetColorMode(COLOR_MODE_NOT_SET);
457     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
458     rm->UpdateResConfig(*rc);
459     delete rc;
460 
461     int density = 320;
462     std::string outValue;
463     RState state;
464     int id = rmc->GetResId("icon", ResType::MEDIA);
465     EXPECT_TRUE(id > 0);
466     state = rm->GetMediaById(id, outValue, density);
467     EXPECT_TRUE(state == SUCCESS);
468     EXPECT_EQ(res, outValue);
469     delete tmp;
470 }
471 
472 /*
473  * @tc.name: ResourceManagerGetMediaByIdTest015
474  * @tc.desc: Test GetMediaById, to match zh_CN-xxldpi determinder
475  * @tc.type: FUNC
476  */
477 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest015, TestSize.Level1)
478 {
479     rmc->AddResource("zh", nullptr, "CN");
480 
481     HapResourceV1 *tmp = new HapResourceV1(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
482     tmp->Init(rmc->defaultResConfig);
483     std::string res = tmp->GetResourcePath();
484     res.append("entry/resources/zh_CN-xxldpi/media/icon.png");
485 
486     auto rc = CreateResConfig();
487     if (rc == nullptr) {
488         ASSERT_TRUE(false);
489     }
490     rc->SetDeviceType(DEVICE_TABLET);
491     rc->SetColorMode(COLOR_MODE_NOT_SET);
492     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
493     rm->UpdateResConfig(*rc);
494     delete rc;
495 
496     int density = 480;
497     std::string outValue;
498     RState state;
499     int id = rmc->GetResId("icon", ResType::MEDIA);
500     EXPECT_TRUE(id > 0);
501     state = rm->GetMediaById(id, outValue, density);
502     EXPECT_TRUE(state == SUCCESS);
503     EXPECT_EQ(res, outValue);
504     delete tmp;
505 }
506 
507 /*
508  * @tc.name: ResourceManagerGetMediaByIdTest016
509  * @tc.desc: Test GetMediaById, to match zh_CN-xxxldpi determinder
510  * @tc.type: FUNC
511  */
512 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest016, TestSize.Level1)
513 {
514     rmc->AddResource("zh", nullptr, "CN");
515 
516     HapResourceV1 *tmp = new HapResourceV1(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
517     tmp->Init(rmc->defaultResConfig);
518     std::string res = tmp->GetResourcePath();
519     res.append("entry/resources/zh_CN-xxxldpi/media/icon.png");
520 
521     auto rc = CreateResConfig();
522     if (rc == nullptr) {
523         ASSERT_TRUE(false);
524     }
525     rc->SetDeviceType(DEVICE_TABLET);
526     rc->SetColorMode(COLOR_MODE_NOT_SET);
527     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
528     rm->UpdateResConfig(*rc);
529     delete rc;
530 
531     int density = 640;
532     std::string outValue;
533     RState state;
534     int id = rmc->GetResId("icon", ResType::MEDIA);
535     EXPECT_TRUE(id > 0);
536     state = rm->GetMediaById(id, outValue, density);
537     EXPECT_TRUE(state == SUCCESS);
538     EXPECT_EQ(res, outValue);
539     delete tmp;
540 }
541 
542 /*
543  * @tc.name: ResourceManagerGetMediaByIdTest017
544  * @tc.desc: Test GetMediaById, to match mcc460_mnc101-zh_CN-phone-dark-sdpi determinder
545  * @tc.type: FUNC
546  */
547 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest017, TestSize.Level1)
548 {
549     rmc->AddResource("zh", nullptr, "CN");
550 
551     HapResourceV1 *tmp = new HapResourceV1(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
552     tmp->Init(rmc->defaultResConfig);
553     std::string res = tmp->GetResourcePath();
554     res.append("entry/resources/mcc460_mnc101-zh_CN-phone-dark-sdpi/media/icon.png");
555 
556     auto rc = CreateResConfig();
557     if (rc == nullptr) {
558         ASSERT_TRUE(false);
559     }
560     rc->SetLocaleInfo("zh", nullptr, "CN");
561     rc->SetMcc(460);
562     rc->SetMnc(101);
563     rc->SetDeviceType(DEVICE_PHONE);
564     rc->SetColorMode(DARK);
565     rc->SetScreenDensity(SCREEN_DENSITY_XXXLDPI / BASE_DPI);
566     rm->UpdateResConfig(*rc);
567     delete rc;
568 
569     int density = 120;
570     std::string outValue;
571     RState state;
572     int id = rmc->GetResId("icon", ResType::MEDIA);
573     EXPECT_TRUE(id > 0);
574     state = rm->GetMediaById(id, outValue, density);
575     EXPECT_TRUE(state == SUCCESS);
576     EXPECT_EQ(res, outValue);
577     delete tmp;
578 }
579 
580 /*
581  * @tc.name: ResourceManagerGetMediaByIdTest018
582  * @tc.desc: Test GetMediaById, to match mcc460_mnc101-zh_CN-phone-dark-mdpi determinder
583  * @tc.type: FUNC
584  */
585 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest018, TestSize.Level1)
586 {
587     rmc->AddResource("zh", nullptr, "CN");
588 
589     HapResourceV1 *tmp = new HapResourceV1(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
590     tmp->Init(rmc->defaultResConfig);
591     std::string res = tmp->GetResourcePath();
592     res.append("entry/resources/mcc460_mnc101-zh_CN-phone-dark-mdpi/media/icon.png");
593 
594     auto rc = CreateResConfig();
595     if (rc == nullptr) {
596         ASSERT_TRUE(false);
597     }
598     rc->SetLocaleInfo("zh", nullptr, "CN");
599     rc->SetMcc(460);
600     rc->SetMnc(101);
601     rc->SetDeviceType(DEVICE_PHONE);
602     rc->SetColorMode(DARK);
603     rc->SetScreenDensity(SCREEN_DENSITY_XXXLDPI / BASE_DPI);
604     rm->UpdateResConfig(*rc);
605     delete rc;
606 
607     int density = 160;
608     std::string outValue;
609     RState state;
610     int id = rmc->GetResId("icon", ResType::MEDIA);
611     EXPECT_TRUE(id > 0);
612     state = rm->GetMediaById(id, outValue, density);
613     EXPECT_TRUE(state == SUCCESS);
614     EXPECT_EQ(res, outValue);
615     delete tmp;
616 }
617 
618 /*
619  * @tc.name: ResourceManagerGetMediaByIdTest019
620  * @tc.desc: Test GetMediaById, to match mcc460_mnc101-zh_CN-phone-dark-ldpi determinder
621  * @tc.type: FUNC
622  */
623 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest019, TestSize.Level1)
624 {
625     rmc->AddResource("zh", nullptr, "CN");
626 
627     HapResourceV1 *tmp = new HapResourceV1(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
628     tmp->Init(rmc->defaultResConfig);
629     std::string res = tmp->GetResourcePath();
630     res.append("entry/resources/mcc460_mnc101-zh_CN-phone-dark-ldpi/media/icon.png");
631 
632     auto rc = CreateResConfig();
633     if (rc == nullptr) {
634         ASSERT_TRUE(false);
635     }
636     rc->SetLocaleInfo("zh", nullptr, "CN");
637     rc->SetMcc(460);
638     rc->SetMnc(101);
639     rc->SetDeviceType(DEVICE_PHONE);
640     rc->SetColorMode(DARK);
641     rc->SetScreenDensity(SCREEN_DENSITY_XXXLDPI / BASE_DPI);
642     rm->UpdateResConfig(*rc);
643     delete rc;
644 
645     int density = 240;
646     std::string outValue;
647     RState state;
648     int id = rmc->GetResId("icon", ResType::MEDIA);
649     EXPECT_TRUE(id > 0);
650     state = rm->GetMediaById(id, outValue, density);
651     EXPECT_TRUE(state == SUCCESS);
652     EXPECT_EQ(res, outValue);
653     delete tmp;
654 }
655 
656 /*
657  * @tc.name: ResourceManagerGetMediaByIdTest020
658  * @tc.desc: Test GetMediaById, to match mcc460_mnc101-zh_CN-phone-dark-xldpi determinder
659  * @tc.type: FUNC
660  */
661 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest020, TestSize.Level1)
662 {
663     rmc->AddResource("zh", nullptr, "CN");
664 
665     HapResourceV1 *tmp = new HapResourceV1(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
666     tmp->Init(rmc->defaultResConfig);
667     std::string res = tmp->GetResourcePath();
668     res.append("entry/resources/mcc460_mnc101-zh_CN-phone-dark-xldpi/media/icon.png");
669 
670     auto rc = CreateResConfig();
671     if (rc == nullptr) {
672         ASSERT_TRUE(false);
673     }
674     rc->SetLocaleInfo("zh", nullptr, "CN");
675     rc->SetMcc(460);
676     rc->SetMnc(101);
677     rc->SetDeviceType(DEVICE_PHONE);
678     rc->SetColorMode(DARK);
679     rc->SetScreenDensity(SCREEN_DENSITY_XXXLDPI / BASE_DPI);
680     rm->UpdateResConfig(*rc);
681     delete rc;
682 
683     int density = 320;
684     std::string outValue;
685     RState state;
686     int id = rmc->GetResId("icon", ResType::MEDIA);
687     EXPECT_TRUE(id > 0);
688     state = rm->GetMediaById(id, outValue, density);
689     EXPECT_TRUE(state == SUCCESS);
690     EXPECT_EQ(res, outValue);
691     delete tmp;
692 }
693 
694 /*
695  * @tc.name: ResourceManagerGetMediaByIdTest021
696  * @tc.desc: Test GetMediaById, to match mcc460_mnc101-zh_CN-phone-dark-xxldpi determinder
697  * @tc.type: FUNC
698  */
699 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest021, TestSize.Level1)
700 {
701     rmc->AddResource("zh", nullptr, "CN");
702 
703     HapResourceV1 *tmp = new HapResourceV1(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
704     tmp->Init(rmc->defaultResConfig);
705     std::string res = tmp->GetResourcePath();
706     res.append("entry/resources/mcc460_mnc101-zh_CN-phone-dark-xxldpi/media/icon.png");
707 
708     auto rc = CreateResConfig();
709     if (rc == nullptr) {
710         ASSERT_TRUE(false);
711     }
712     rc->SetLocaleInfo("zh", nullptr, "CN");
713     rc->SetMcc(460);
714     rc->SetMnc(101);
715     rc->SetDeviceType(DEVICE_PHONE);
716     rc->SetColorMode(DARK);
717     rc->SetScreenDensity(SCREEN_DENSITY_XXXLDPI / BASE_DPI);
718     rm->UpdateResConfig(*rc);
719     delete rc;
720 
721     int density = 480;
722     std::string outValue;
723     RState state;
724     int id = rmc->GetResId("icon", ResType::MEDIA);
725     EXPECT_TRUE(id > 0);
726     state = rm->GetMediaById(id, outValue, density);
727     EXPECT_TRUE(state == SUCCESS);
728     EXPECT_EQ(res, outValue);
729     delete tmp;
730 }
731 
732 /*
733  * @tc.name: ResourceManagerGetMediaByIdTest022
734  * @tc.desc: Test GetMediaById, to match mcc460_mnc101-zh_CN-phone-dark-xxxldpi determinder
735  * @tc.type: FUNC
736  */
737 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest022, TestSize.Level1)
738 {
739     rmc->AddResource("zh", nullptr, "CN");
740 
741     HapResourceV1 *tmp = new HapResourceV1(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
742     tmp->Init(rmc->defaultResConfig);
743     std::string res = tmp->GetResourcePath();
744     res.append("entry/resources/mcc460_mnc101-zh_CN-phone-dark-xxxldpi/media/icon.png");
745 
746     auto rc = CreateResConfig();
747     if (rc == nullptr) {
748         ASSERT_TRUE(false);
749     }
750     rc->SetLocaleInfo("zh", nullptr, "CN");
751     rc->SetMcc(460);
752     rc->SetMnc(101);
753     rc->SetDeviceType(DEVICE_PHONE);
754     rc->SetColorMode(DARK);
755     rc->SetScreenDensity(SCREEN_DENSITY_XXLDPI / BASE_DPI);
756     rm->UpdateResConfig(*rc);
757     delete rc;
758 
759     int density = 640;
760     std::string outValue;
761     RState state;
762     int id = rmc->GetResId("icon", ResType::MEDIA);
763     EXPECT_TRUE(id > 0);
764     state = rm->GetMediaById(id, outValue, density);
765     EXPECT_TRUE(state == SUCCESS);
766     EXPECT_EQ(res, outValue);
767     delete tmp;
768 }
769 
770 /*
771  * @tc.name: ResourceManagerGetMediaByIdTest023
772  * @tc.desc: Test GetMediaById
773  * @tc.type: FUNC
774  */
775 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest023, TestSize.Level1)
776 {
777     rmc->AddResource("en", nullptr, nullptr);
778 
779     int id = rmc->GetResId("app_name", ResType::STRING);
780     EXPECT_TRUE(id > 0);
781     std::string outValue;
782     RState state = rm->GetMediaById(id, outValue);
783     EXPECT_EQ(state, ERROR_CODE_RES_NOT_FOUND_BY_ID);
784 }
785 
786 /*
787  * @tc.name: ResourceManagerGetMediaByIdTest024
788  * @tc.desc: Test GetMediaById
789  * @tc.type: FUNC
790  */
791 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest024, TestSize.Level1)
792 {
793     rmc->AddResource("zh", nullptr, "CN");
794 
795     HapResourceV2 *tmp = new HapResourceV2(FormatFullPath(g_newResFilePath).c_str(), 0);
796     rmc->TestGetMediaById(tmp);
797     delete tmp;
798 }
799 
800 /*
801  * @tc.name: ResourceManagerGetMediaByIdTest025
802  * @tc.desc: Test GetMediaById, to match sdpi determinder
803  * @tc.type: FUNC
804  */
805 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest025, TestSize.Level1)
806 {
807     rmc->AddResource("en", nullptr, "US");
808 
809     HapResourceV2 *tmp = new HapResourceV2(FormatFullPath(g_newResFilePath).c_str(), 0);
810     rmc->TestGetMediaWithDensityById(tmp);
811     delete tmp;
812 }
813 
814 /*
815  * @tc.name: ResourceManagerGetMediaByIdTest026
816  * @tc.desc: Test GetMediaById, to match mdpi determinder
817  * @tc.type: FUNC
818  */
819 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest026, TestSize.Level1)
820 {
821     rmc->AddResource("en", nullptr, "US");
822 
823     HapResourceV2 *tmp = new HapResourceV2(FormatFullPath(g_newResFilePath).c_str(), 0);
824     std::unordered_map<uint32_t, std::shared_ptr<ResConfigImpl>> keys;
825     std::unordered_map<uint32_t, std::shared_ptr<IdValuesV2>> idMap;
826     std::unordered_map<uint32_t, std::unordered_map<std::string, std::shared_ptr<IdValuesV2>>> typeNameMap;
827     std::shared_ptr<MmapFile> mMap;
828     tmp->Init(keys, idMap, typeNameMap, mMap);
829     std::string res = tmp->GetResourcePath();
830     res.append("entry/resources/mdpi/media/icon.png");
831 
832     auto rc = CreateResConfig();
833     if (rc == nullptr) {
834         ASSERT_TRUE(false);
835     }
836     rc->SetDeviceType(DEVICE_TV);
837     rc->SetColorMode(COLOR_MODE_NOT_SET);
838     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
839     rm->UpdateResConfig(*rc);
840     delete rc;
841 
842     int density = 160;
843     std::string outValue;
844     RState state;
845     int id = rmc->GetResId("icon", ResType::MEDIA);
846     EXPECT_TRUE(id > 0);
847     state = rm->GetMediaById(id, outValue, density);
848     EXPECT_TRUE(state == SUCCESS);
849     EXPECT_EQ(res, outValue);
850     delete tmp;
851 }
852 
853 /*
854  * @tc.name: ResourceManagerGetMediaByIdTest027
855  * @tc.desc: Test GetMediaById, to match ldpi determinder
856  * @tc.type: FUNC
857  */
858 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest027, TestSize.Level1)
859 {
860     rmc->AddResource("en", nullptr, "US");
861 
862     HapResourceV2 *tmp = new HapResourceV2(FormatFullPath(g_newResFilePath).c_str(), 0);
863     std::unordered_map<uint32_t, std::shared_ptr<ResConfigImpl>> keys;
864     std::unordered_map<uint32_t, std::shared_ptr<IdValuesV2>> idMap;
865     std::unordered_map<uint32_t, std::unordered_map<std::string, std::shared_ptr<IdValuesV2>>> typeNameMap;
866     std::shared_ptr<MmapFile> mMap;
867     tmp->Init(keys, idMap, typeNameMap, mMap);
868     std::string res = tmp->GetResourcePath();
869     res.append("entry/resources/ldpi/media/icon.png");
870 
871     auto rc = CreateResConfig();
872     if (rc == nullptr) {
873         ASSERT_TRUE(false);
874     }
875     rc->SetDeviceType(DEVICE_PHONE);
876     rc->SetColorMode(COLOR_MODE_NOT_SET);
877     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
878     rm->UpdateResConfig(*rc);
879     delete rc;
880 
881     int density = 240;
882     std::string outValue;
883     RState state;
884     int id = rmc->GetResId("icon", ResType::MEDIA);
885     EXPECT_TRUE(id > 0);
886     state = rm->GetMediaById(id, outValue, density);
887     EXPECT_TRUE(state == SUCCESS);
888     EXPECT_EQ(res, outValue);
889     delete tmp;
890 }
891 
892 /*
893  * @tc.name: ResourceManagerGetMediaByIdTest028
894  * @tc.desc: Test GetMediaById, to match xldpi determinder
895  * @tc.type: FUNC
896  */
897 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest028, TestSize.Level1)
898 {
899     rmc->AddResource("en", nullptr, "US");
900 
901     HapResourceV2 *tmp = new HapResourceV2(FormatFullPath(g_newResFilePath).c_str(), 0);
902     std::unordered_map<uint32_t, std::shared_ptr<ResConfigImpl>> keys;
903     std::unordered_map<uint32_t, std::shared_ptr<IdValuesV2>> idMap;
904     std::unordered_map<uint32_t, std::unordered_map<std::string, std::shared_ptr<IdValuesV2>>> typeNameMap;
905     std::shared_ptr<MmapFile> mMap;
906     tmp->Init(keys, idMap, typeNameMap, mMap);
907     std::string res = tmp->GetResourcePath();
908     res.append("entry/resources/xldpi/media/icon.png");
909 
910     auto rc = CreateResConfig();
911     if (rc == nullptr) {
912         ASSERT_TRUE(false);
913     }
914     rc->SetDeviceType(DEVICE_PHONE);
915     rc->SetColorMode(COLOR_MODE_NOT_SET);
916     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
917     rm->UpdateResConfig(*rc);
918     delete rc;
919 
920     int density = 320;
921     std::string outValue;
922     RState state;
923     int id = rmc->GetResId("icon", ResType::MEDIA);
924     EXPECT_TRUE(id > 0);
925     state = rm->GetMediaById(id, outValue, density);
926     EXPECT_TRUE(state == SUCCESS);
927     EXPECT_EQ(res, outValue);
928     delete tmp;
929 }
930 
931 /*
932  * @tc.name: ResourceManagerGetMediaByIdTest029
933  * @tc.desc: Test GetMediaById, to match xxldpi determinder
934  * @tc.type: FUNC
935  */
936 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest029, TestSize.Level1)
937 {
938     rmc->AddResource("en", nullptr, "US");
939 
940     HapResourceV2 *tmp = new HapResourceV2(FormatFullPath(g_newResFilePath).c_str(), 0);
941     std::unordered_map<uint32_t, std::shared_ptr<ResConfigImpl>> keys;
942     std::unordered_map<uint32_t, std::shared_ptr<IdValuesV2>> idMap;
943     std::unordered_map<uint32_t, std::unordered_map<std::string, std::shared_ptr<IdValuesV2>>> typeNameMap;
944     std::shared_ptr<MmapFile> mMap;
945     tmp->Init(keys, idMap, typeNameMap, mMap);
946     std::string res = tmp->GetResourcePath();
947     res.append("entry/resources/xxldpi/media/icon.png");
948 
949     auto rc = CreateResConfig();
950     if (rc == nullptr) {
951         ASSERT_TRUE(false);
952     }
953     rc->SetDeviceType(DEVICE_PHONE);
954     rc->SetColorMode(COLOR_MODE_NOT_SET);
955     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
956     rm->UpdateResConfig(*rc);
957     delete rc;
958 
959     int density = 480;
960     std::string outValue;
961     RState state;
962     int id = rmc->GetResId("icon", ResType::MEDIA);
963     EXPECT_TRUE(id > 0);
964     state = rm->GetMediaById(id, outValue, density);
965     EXPECT_TRUE(state == SUCCESS);
966     EXPECT_EQ(res, outValue);
967     delete tmp;
968 }
969 
970 /*
971  * @tc.name: ResourceManagerGetMediaByIdTest030
972  * @tc.desc: Test GetMediaById, to match xxxldpi determinder
973  * @tc.type: FUNC
974  */
975 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest030, TestSize.Level1)
976 {
977     rmc->AddResource("en", nullptr, "US");
978 
979     HapResourceV2 *tmp = new HapResourceV2(FormatFullPath(g_newResFilePath).c_str(), 0);
980     std::unordered_map<uint32_t, std::shared_ptr<ResConfigImpl>> keys;
981     std::unordered_map<uint32_t, std::shared_ptr<IdValuesV2>> idMap;
982     std::unordered_map<uint32_t, std::unordered_map<std::string, std::shared_ptr<IdValuesV2>>> typeNameMap;
983     std::shared_ptr<MmapFile> mMap;
984     tmp->Init(keys, idMap, typeNameMap, mMap);
985     std::string res = tmp->GetResourcePath();
986     res.append("entry/resources/xxxldpi/media/icon.png");
987 
988     auto rc = CreateResConfig();
989     if (rc == nullptr) {
990         ASSERT_TRUE(false);
991     }
992     rc->SetDeviceType(DEVICE_PHONE);
993     rc->SetColorMode(COLOR_MODE_NOT_SET);
994     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
995     rm->UpdateResConfig(*rc);
996     delete rc;
997 
998     int density = 640;
999     std::string outValue;
1000     RState state;
1001     int id = rmc->GetResId("icon", ResType::MEDIA);
1002     EXPECT_TRUE(id > 0);
1003     state = rm->GetMediaById(id, outValue, density);
1004     EXPECT_TRUE(state == SUCCESS);
1005     EXPECT_EQ(res, outValue);
1006     delete tmp;
1007 }
1008 
1009 /*
1010  * @tc.name: ResourceManagerGetMediaByIdTest031
1011  * @tc.desc: Test GetMediaById, to match zh_CN-sdpi determinder
1012  * @tc.type: FUNC
1013  */
1014 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest031, TestSize.Level1)
1015 {
1016     rmc->AddResource("zh", nullptr, "CN");
1017 
1018     HapResourceV2 *tmp = new HapResourceV2(FormatFullPath(g_newResFilePath).c_str(), 0);
1019     std::unordered_map<uint32_t, std::shared_ptr<ResConfigImpl>> keys;
1020     std::unordered_map<uint32_t, std::shared_ptr<IdValuesV2>> idMap;
1021     std::unordered_map<uint32_t, std::unordered_map<std::string, std::shared_ptr<IdValuesV2>>> typeNameMap;
1022     std::shared_ptr<MmapFile> mMap;
1023     tmp->Init(keys, idMap, typeNameMap, mMap);
1024     std::string res = tmp->GetResourcePath();
1025     res.append("entry/resources/zh_CN-sdpi/media/icon.png");
1026 
1027     auto rc = CreateResConfig();
1028     if (rc == nullptr) {
1029         ASSERT_TRUE(false);
1030     }
1031     rc->SetDeviceType(DEVICE_TABLET);
1032     rc->SetColorMode(COLOR_MODE_NOT_SET);
1033     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
1034     rm->UpdateResConfig(*rc);
1035     delete rc;
1036 
1037     int density = 120;
1038     std::string outValue;
1039     RState state;
1040     int id = rmc->GetResId("icon", ResType::MEDIA);
1041     EXPECT_TRUE(id > 0);
1042     state = rm->GetMediaById(id, outValue, density);
1043     EXPECT_TRUE(state == SUCCESS);
1044     EXPECT_EQ(res, outValue);
1045     delete tmp;
1046 }
1047 
1048 /*
1049  * @tc.name: ResourceManagerGetMediaByIdTest032
1050  * @tc.desc: Test GetMediaById, to match zh_CN-mdpi determinder
1051  * @tc.type: FUNC
1052  */
1053 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest032, TestSize.Level1)
1054 {
1055     rmc->AddResource("zh", nullptr, "CN");
1056 
1057     HapResourceV2 *tmp = new HapResourceV2(FormatFullPath(g_newResFilePath).c_str(), 0);
1058     std::unordered_map<uint32_t, std::shared_ptr<ResConfigImpl>> keys;
1059     std::unordered_map<uint32_t, std::shared_ptr<IdValuesV2>> idMap;
1060     std::unordered_map<uint32_t, std::unordered_map<std::string, std::shared_ptr<IdValuesV2>>> typeNameMap;
1061     std::shared_ptr<MmapFile> mMap;
1062     tmp->Init(keys, idMap, typeNameMap, mMap);
1063     std::string res = tmp->GetResourcePath();
1064     res.append("entry/resources/zh_CN-mdpi/media/icon.png");
1065 
1066     auto rc = CreateResConfig();
1067     if (rc == nullptr) {
1068         ASSERT_TRUE(false);
1069     }
1070     rc->SetDeviceType(DEVICE_TABLET);
1071     rc->SetColorMode(COLOR_MODE_NOT_SET);
1072     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
1073     rm->UpdateResConfig(*rc);
1074     delete rc;
1075 
1076     int density = 160;
1077     std::string outValue;
1078     RState state;
1079     int id = rmc->GetResId("icon", ResType::MEDIA);
1080     EXPECT_TRUE(id > 0);
1081     state = rm->GetMediaById(id, outValue, density);
1082     EXPECT_TRUE(state == SUCCESS);
1083     EXPECT_EQ(res, outValue);
1084     delete tmp;
1085 }
1086 
1087 /*
1088  * @tc.name: ResourceManagerGetMediaByIdTest033
1089  * @tc.desc: Test GetMediaById, to match zh_CN-ldpi determinder
1090  * @tc.type: FUNC
1091  */
1092 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest033, TestSize.Level1)
1093 {
1094     rmc->AddResource("zh", nullptr, "CN");
1095 
1096     HapResourceV2 *tmp = new HapResourceV2(FormatFullPath(g_newResFilePath).c_str(), 0);
1097     std::unordered_map<uint32_t, std::shared_ptr<ResConfigImpl>> keys;
1098     std::unordered_map<uint32_t, std::shared_ptr<IdValuesV2>> idMap;
1099     std::unordered_map<uint32_t, std::unordered_map<std::string, std::shared_ptr<IdValuesV2>>> typeNameMap;
1100     std::shared_ptr<MmapFile> mMap;
1101     tmp->Init(keys, idMap, typeNameMap, mMap);
1102     std::string res = tmp->GetResourcePath();
1103     res.append("entry/resources/zh_CN-ldpi/media/icon.png");
1104 
1105     auto rc = CreateResConfig();
1106     if (rc == nullptr) {
1107         ASSERT_TRUE(false);
1108     }
1109     rc->SetDeviceType(DEVICE_TABLET);
1110     rc->SetColorMode(COLOR_MODE_NOT_SET);
1111     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
1112     rm->UpdateResConfig(*rc);
1113     delete rc;
1114 
1115     int density = 240;
1116     std::string outValue;
1117     RState state;
1118     int id = rmc->GetResId("icon", ResType::MEDIA);
1119     EXPECT_TRUE(id > 0);
1120     state = rm->GetMediaById(id, outValue, density);
1121     EXPECT_TRUE(state == SUCCESS);
1122     EXPECT_EQ(res, outValue);
1123     delete tmp;
1124 }
1125 
1126 /*
1127  * @tc.name: ResourceManagerGetMediaByIdTest034
1128  * @tc.desc: Test GetMediaById, to match zh_CN-xldpi determinder
1129  * @tc.type: FUNC
1130  */
1131 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest034, TestSize.Level1)
1132 {
1133     rmc->AddResource("zh", nullptr, "CN");
1134 
1135     HapResourceV2 *tmp = new HapResourceV2(FormatFullPath(g_newResFilePath).c_str(), 0);
1136     std::unordered_map<uint32_t, std::shared_ptr<ResConfigImpl>> keys;
1137     std::unordered_map<uint32_t, std::shared_ptr<IdValuesV2>> idMap;
1138     std::unordered_map<uint32_t, std::unordered_map<std::string, std::shared_ptr<IdValuesV2>>> typeNameMap;
1139     std::shared_ptr<MmapFile> mMap;
1140     tmp->Init(keys, idMap, typeNameMap, mMap);
1141     std::string res = tmp->GetResourcePath();
1142     res.append("entry/resources/zh_CN-xldpi/media/icon.png");
1143 
1144     auto rc = CreateResConfig();
1145     if (rc == nullptr) {
1146         ASSERT_TRUE(false);
1147     }
1148     rc->SetDeviceType(DEVICE_TABLET);
1149     rc->SetColorMode(COLOR_MODE_NOT_SET);
1150     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
1151     rm->UpdateResConfig(*rc);
1152     delete rc;
1153 
1154     int density = 320;
1155     std::string outValue;
1156     RState state;
1157     int id = rmc->GetResId("icon", ResType::MEDIA);
1158     EXPECT_TRUE(id > 0);
1159     state = rm->GetMediaById(id, outValue, density);
1160     EXPECT_TRUE(state == SUCCESS);
1161     EXPECT_EQ(res, outValue);
1162     delete tmp;
1163 }
1164 
1165 /*
1166  * @tc.name: ResourceManagerGetMediaByIdTest035
1167  * @tc.desc: Test GetMediaById, to match zh_CN-xxldpi determinder
1168  * @tc.type: FUNC
1169  */
1170 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest035, TestSize.Level1)
1171 {
1172     rmc->AddResource("zh", nullptr, "CN");
1173 
1174     HapResourceV2 *tmp = new HapResourceV2(FormatFullPath(g_newResFilePath).c_str(), 0);
1175     std::unordered_map<uint32_t, std::shared_ptr<ResConfigImpl>> keys;
1176     std::unordered_map<uint32_t, std::shared_ptr<IdValuesV2>> idMap;
1177     std::unordered_map<uint32_t, std::unordered_map<std::string, std::shared_ptr<IdValuesV2>>> typeNameMap;
1178     std::shared_ptr<MmapFile> mMap;
1179     tmp->Init(keys, idMap, typeNameMap, mMap);
1180     std::string res = tmp->GetResourcePath();
1181     res.append("entry/resources/zh_CN-xxldpi/media/icon.png");
1182 
1183     auto rc = CreateResConfig();
1184     if (rc == nullptr) {
1185         ASSERT_TRUE(false);
1186     }
1187     rc->SetDeviceType(DEVICE_TABLET);
1188     rc->SetColorMode(COLOR_MODE_NOT_SET);
1189     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
1190     rm->UpdateResConfig(*rc);
1191     delete rc;
1192 
1193     int density = 480;
1194     std::string outValue;
1195     RState state;
1196     int id = rmc->GetResId("icon", ResType::MEDIA);
1197     EXPECT_TRUE(id > 0);
1198     state = rm->GetMediaById(id, outValue, density);
1199     EXPECT_TRUE(state == SUCCESS);
1200     EXPECT_EQ(res, outValue);
1201     delete tmp;
1202 }
1203 
1204 /*
1205  * @tc.name: ResourceManagerGetMediaByIdTest036
1206  * @tc.desc: Test GetMediaById, to match zh_CN-xxxldpi determinder
1207  * @tc.type: FUNC
1208  */
1209 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest036, TestSize.Level1)
1210 {
1211     rmc->AddResource("zh", nullptr, "CN");
1212 
1213     HapResourceV2 *tmp = new HapResourceV2(FormatFullPath(g_newResFilePath).c_str(), 0);
1214     std::unordered_map<uint32_t, std::shared_ptr<ResConfigImpl>> keys;
1215     std::unordered_map<uint32_t, std::shared_ptr<IdValuesV2>> idMap;
1216     std::unordered_map<uint32_t, std::unordered_map<std::string, std::shared_ptr<IdValuesV2>>> typeNameMap;
1217     std::shared_ptr<MmapFile> mMap;
1218     tmp->Init(keys, idMap, typeNameMap, mMap);
1219     std::string res = tmp->GetResourcePath();
1220     res.append("entry/resources/zh_CN-xxxldpi/media/icon.png");
1221 
1222     auto rc = CreateResConfig();
1223     if (rc == nullptr) {
1224         ASSERT_TRUE(false);
1225     }
1226     rc->SetDeviceType(DEVICE_TABLET);
1227     rc->SetColorMode(COLOR_MODE_NOT_SET);
1228     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
1229     rm->UpdateResConfig(*rc);
1230     delete rc;
1231 
1232     int density = 640;
1233     std::string outValue;
1234     RState state;
1235     int id = rmc->GetResId("icon", ResType::MEDIA);
1236     EXPECT_TRUE(id > 0);
1237     state = rm->GetMediaById(id, outValue, density);
1238     EXPECT_TRUE(state == SUCCESS);
1239     EXPECT_EQ(res, outValue);
1240     delete tmp;
1241 }
1242 
1243 /*
1244  * @tc.name: ResourceManagerGetMediaByIdTest037
1245  * @tc.desc: Test GetMediaById, to match mcc460_mnc101-zh_CN-phone-dark-sdpi determinder
1246  * @tc.type: FUNC
1247  */
1248 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest037, TestSize.Level1)
1249 {
1250     rmc->AddResource("zh", nullptr, "CN");
1251 
1252     HapResourceV2 *tmp = new HapResourceV2(FormatFullPath(g_newResFilePath).c_str(), 0);
1253     std::unordered_map<uint32_t, std::shared_ptr<ResConfigImpl>> keys;
1254     std::unordered_map<uint32_t, std::shared_ptr<IdValuesV2>> idMap;
1255     std::unordered_map<uint32_t, std::unordered_map<std::string, std::shared_ptr<IdValuesV2>>> typeNameMap;
1256     std::shared_ptr<MmapFile> mMap;
1257     tmp->Init(keys, idMap, typeNameMap, mMap);
1258     std::string res = tmp->GetResourcePath();
1259     res.append("entry/resources/mcc460_mnc101-zh_CN-phone-dark-sdpi/media/icon.png");
1260 
1261     auto rc = CreateResConfig();
1262     if (rc == nullptr) {
1263         ASSERT_TRUE(false);
1264     }
1265     rc->SetLocaleInfo("zh", nullptr, "CN");
1266     rc->SetMcc(460);
1267     rc->SetMnc(101);
1268     rc->SetDeviceType(DEVICE_PHONE);
1269     rc->SetColorMode(DARK);
1270     rc->SetScreenDensity(SCREEN_DENSITY_XXXLDPI / BASE_DPI);
1271     rm->UpdateResConfig(*rc);
1272     delete rc;
1273 
1274     int density = 120;
1275     std::string outValue;
1276     RState state;
1277     int id = rmc->GetResId("icon", ResType::MEDIA);
1278     EXPECT_TRUE(id > 0);
1279     state = rm->GetMediaById(id, outValue, density);
1280     EXPECT_TRUE(state == SUCCESS);
1281     EXPECT_EQ(res, outValue);
1282     delete tmp;
1283 }
1284 
1285 /*
1286  * @tc.name: ResourceManagerGetMediaByIdTest038
1287  * @tc.desc: Test GetMediaById, to match mcc460_mnc101-zh_CN-phone-dark-mdpi determinder
1288  * @tc.type: FUNC
1289  */
1290 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest038, TestSize.Level1)
1291 {
1292     rmc->AddResource("zh", nullptr, "CN");
1293 
1294     HapResourceV2 *tmp = new HapResourceV2(FormatFullPath(g_newResFilePath).c_str(), 0);
1295     std::unordered_map<uint32_t, std::shared_ptr<ResConfigImpl>> keys;
1296     std::unordered_map<uint32_t, std::shared_ptr<IdValuesV2>> idMap;
1297     std::unordered_map<uint32_t, std::unordered_map<std::string, std::shared_ptr<IdValuesV2>>> typeNameMap;
1298     std::shared_ptr<MmapFile> mMap;
1299     tmp->Init(keys, idMap, typeNameMap, mMap);
1300     std::string res = tmp->GetResourcePath();
1301     res.append("entry/resources/mcc460_mnc101-zh_CN-phone-dark-mdpi/media/icon.png");
1302 
1303     auto rc = CreateResConfig();
1304     if (rc == nullptr) {
1305         ASSERT_TRUE(false);
1306     }
1307     rc->SetLocaleInfo("zh", nullptr, "CN");
1308     rc->SetMcc(460);
1309     rc->SetMnc(101);
1310     rc->SetDeviceType(DEVICE_PHONE);
1311     rc->SetColorMode(DARK);
1312     rc->SetScreenDensity(SCREEN_DENSITY_XXXLDPI / BASE_DPI);
1313     rm->UpdateResConfig(*rc);
1314     delete rc;
1315 
1316     int density = 160;
1317     std::string outValue;
1318     RState state;
1319     int id = rmc->GetResId("icon", ResType::MEDIA);
1320     EXPECT_TRUE(id > 0);
1321     state = rm->GetMediaById(id, outValue, density);
1322     EXPECT_TRUE(state == SUCCESS);
1323     EXPECT_EQ(res, outValue);
1324     delete tmp;
1325 }
1326 
1327 /*
1328  * @tc.name: ResourceManagerGetMediaByIdTest039
1329  * @tc.desc: Test GetMediaById, to match mcc460_mnc101-zh_CN-phone-dark-ldpi determinder
1330  * @tc.type: FUNC
1331  */
1332 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest039, TestSize.Level1)
1333 {
1334     rmc->AddResource("zh", nullptr, "CN");
1335 
1336     HapResourceV2 *tmp = new HapResourceV2(FormatFullPath(g_newResFilePath).c_str(), 0);
1337     std::unordered_map<uint32_t, std::shared_ptr<ResConfigImpl>> keys;
1338     std::unordered_map<uint32_t, std::shared_ptr<IdValuesV2>> idMap;
1339     std::unordered_map<uint32_t, std::unordered_map<std::string, std::shared_ptr<IdValuesV2>>> typeNameMap;
1340     std::shared_ptr<MmapFile> mMap;
1341     tmp->Init(keys, idMap, typeNameMap, mMap);
1342     std::string res = tmp->GetResourcePath();
1343     res.append("entry/resources/mcc460_mnc101-zh_CN-phone-dark-ldpi/media/icon.png");
1344 
1345     auto rc = CreateResConfig();
1346     if (rc == nullptr) {
1347         ASSERT_TRUE(false);
1348     }
1349     rc->SetLocaleInfo("zh", nullptr, "CN");
1350     rc->SetMcc(460);
1351     rc->SetMnc(101);
1352     rc->SetDeviceType(DEVICE_PHONE);
1353     rc->SetColorMode(DARK);
1354     rc->SetScreenDensity(SCREEN_DENSITY_XXXLDPI / BASE_DPI);
1355     rm->UpdateResConfig(*rc);
1356     delete rc;
1357 
1358     int density = 240;
1359     std::string outValue;
1360     RState state;
1361     int id = rmc->GetResId("icon", ResType::MEDIA);
1362     EXPECT_TRUE(id > 0);
1363     state = rm->GetMediaById(id, outValue, density);
1364     EXPECT_TRUE(state == SUCCESS);
1365     EXPECT_EQ(res, outValue);
1366     delete tmp;
1367 }
1368 
1369 /*
1370  * @tc.name: ResourceManagerGetMediaByIdTest040
1371  * @tc.desc: Test GetMediaById, to match mcc460_mnc101-zh_CN-phone-dark-xldpi determinder
1372  * @tc.type: FUNC
1373  */
1374 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest040, TestSize.Level1)
1375 {
1376     rmc->AddResource("zh", nullptr, "CN");
1377 
1378     HapResourceV2 *tmp = new HapResourceV2(FormatFullPath(g_newResFilePath).c_str(), 0);
1379     std::unordered_map<uint32_t, std::shared_ptr<ResConfigImpl>> keys;
1380     std::unordered_map<uint32_t, std::shared_ptr<IdValuesV2>> idMap;
1381     std::unordered_map<uint32_t, std::unordered_map<std::string, std::shared_ptr<IdValuesV2>>> typeNameMap;
1382     std::shared_ptr<MmapFile> mMap;
1383     tmp->Init(keys, idMap, typeNameMap, mMap);
1384     std::string res = tmp->GetResourcePath();
1385     res.append("entry/resources/mcc460_mnc101-zh_CN-phone-dark-xldpi/media/icon.png");
1386 
1387     auto rc = CreateResConfig();
1388     if (rc == nullptr) {
1389         ASSERT_TRUE(false);
1390     }
1391     rc->SetLocaleInfo("zh", nullptr, "CN");
1392     rc->SetMcc(460);
1393     rc->SetMnc(101);
1394     rc->SetDeviceType(DEVICE_PHONE);
1395     rc->SetColorMode(DARK);
1396     rc->SetScreenDensity(SCREEN_DENSITY_XXXLDPI / BASE_DPI);
1397     rm->UpdateResConfig(*rc);
1398     delete rc;
1399 
1400     int density = 320;
1401     std::string outValue;
1402     RState state;
1403     int id = rmc->GetResId("icon", ResType::MEDIA);
1404     EXPECT_TRUE(id > 0);
1405     state = rm->GetMediaById(id, outValue, density);
1406     EXPECT_TRUE(state == SUCCESS);
1407     EXPECT_EQ(res, outValue);
1408     delete tmp;
1409 }
1410 
1411 /*
1412  * @tc.name: ResourceManagerGetMediaByIdTest041
1413  * @tc.desc: Test GetMediaById, to match mcc460_mnc101-zh_CN-phone-dark-xxldpi determinder
1414  * @tc.type: FUNC
1415  */
1416 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest041, TestSize.Level1)
1417 {
1418     rmc->AddResource("zh", nullptr, "CN");
1419 
1420     HapResourceV2 *tmp = new HapResourceV2(FormatFullPath(g_newResFilePath).c_str(), 0);
1421     std::unordered_map<uint32_t, std::shared_ptr<ResConfigImpl>> keys;
1422     std::unordered_map<uint32_t, std::shared_ptr<IdValuesV2>> idMap;
1423     std::unordered_map<uint32_t, std::unordered_map<std::string, std::shared_ptr<IdValuesV2>>> typeNameMap;
1424     std::shared_ptr<MmapFile> mMap;
1425     tmp->Init(keys, idMap, typeNameMap, mMap);
1426     std::string res = tmp->GetResourcePath();
1427     res.append("entry/resources/mcc460_mnc101-zh_CN-phone-dark-xxldpi/media/icon.png");
1428 
1429     auto rc = CreateResConfig();
1430     if (rc == nullptr) {
1431         ASSERT_TRUE(false);
1432     }
1433     rc->SetLocaleInfo("zh", nullptr, "CN");
1434     rc->SetMcc(460);
1435     rc->SetMnc(101);
1436     rc->SetDeviceType(DEVICE_PHONE);
1437     rc->SetColorMode(DARK);
1438     rc->SetScreenDensity(SCREEN_DENSITY_XXXLDPI / BASE_DPI);
1439     rm->UpdateResConfig(*rc);
1440     delete rc;
1441 
1442     int density = 480;
1443     std::string outValue;
1444     RState state;
1445     int id = rmc->GetResId("icon", ResType::MEDIA);
1446     EXPECT_TRUE(id > 0);
1447     state = rm->GetMediaById(id, outValue, density);
1448     EXPECT_TRUE(state == SUCCESS);
1449     EXPECT_EQ(res, outValue);
1450     delete tmp;
1451 }
1452 
1453 /*
1454  * @tc.name: ResourceManagerGetMediaByIdTest042
1455  * @tc.desc: Test GetMediaById, to match mcc460_mnc101-zh_CN-phone-dark-xxxldpi determinder
1456  * @tc.type: FUNC
1457  */
1458 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByIdTest042, TestSize.Level1)
1459 {
1460     rmc->AddResource("zh", nullptr, "CN");
1461 
1462     HapResourceV2 *tmp = new HapResourceV2(FormatFullPath(g_newResFilePath).c_str(), 0);
1463     std::unordered_map<uint32_t, std::shared_ptr<ResConfigImpl>> keys;
1464     std::unordered_map<uint32_t, std::shared_ptr<IdValuesV2>> idMap;
1465     std::unordered_map<uint32_t, std::unordered_map<std::string, std::shared_ptr<IdValuesV2>>> typeNameMap;
1466     std::shared_ptr<MmapFile> mMap;
1467     tmp->Init(keys, idMap, typeNameMap, mMap);
1468     std::string res = tmp->GetResourcePath();
1469     res.append("entry/resources/mcc460_mnc101-zh_CN-phone-dark-xxxldpi/media/icon.png");
1470 
1471     auto rc = CreateResConfig();
1472     if (rc == nullptr) {
1473         ASSERT_TRUE(false);
1474     }
1475     rc->SetLocaleInfo("zh", nullptr, "CN");
1476     rc->SetMcc(460);
1477     rc->SetMnc(101);
1478     rc->SetDeviceType(DEVICE_PHONE);
1479     rc->SetColorMode(DARK);
1480     rc->SetScreenDensity(SCREEN_DENSITY_XXLDPI / BASE_DPI);
1481     rm->UpdateResConfig(*rc);
1482     delete rc;
1483 
1484     int density = 640;
1485     std::string outValue;
1486     RState state;
1487     int id = rmc->GetResId("icon", ResType::MEDIA);
1488     EXPECT_TRUE(id > 0);
1489     state = rm->GetMediaById(id, outValue, density);
1490     EXPECT_TRUE(state == SUCCESS);
1491     EXPECT_EQ(res, outValue);
1492     delete tmp;
1493 }
1494 
1495 /*
1496  * @tc.name: ResourceManagerGetDrawableInfoByIdTest001
1497  * @tc.desc: Test GetDrawableInfoById
1498  * @tc.type: FUNC
1499  */
1500 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetDrawableInfoByIdTest001, TestSize.Level1)
1501 {
1502     rmc->AddResource("zh", nullptr, "CN");
1503 
1504     auto rc = CreateResConfig();
1505     if (rc == nullptr) {
1506         ASSERT_TRUE(false);
1507     }
1508     rc->SetDeviceType(DEVICE_TABLET);
1509     rc->SetColorMode(COLOR_MODE_NOT_SET);
1510     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
1511     rm->UpdateResConfig(*rc);
1512     delete rc;
1513 
1514     int density = 480;
1515     std::unique_ptr<uint8_t[]> outValue;
1516     RState state;
1517     int id = rmc->GetResId("icon", ResType::MEDIA);
1518     EXPECT_TRUE(id > 0);
1519     std::tuple<std::string, size_t, std::string> info;
1520     state = rm->GetDrawableInfoById(id, info, outValue, 1, density);
1521     EXPECT_TRUE(state == SUCCESS);
1522 }
1523 
1524 /*
1525  * @tc.name: ResourceManagerGetMediaByNameTest001
1526  * @tc.desc: Test GetMediaByName
1527  * @tc.type: FUNC
1528  */
1529 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest001, TestSize.Level1)
1530 {
1531     rmc->AddResource("zh", nullptr, "CN");
1532 
1533     HapResourceV1 *tmp = new HapResourceV1(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
1534     rmc->TestGetMediaByName(tmp);
1535     delete tmp;
1536 }
1537 
1538 /*
1539  * @tc.name: ResourceManagerGetMediaByNameTest002
1540  * @tc.desc: Test GetMediaByName
1541  * @tc.type: FUNC
1542  */
1543 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest002, TestSize.Level1)
1544 {
1545     rmc->AddResource("zh", nullptr, "CN");
1546 
1547     std::string outValue;
1548     RState state;
1549     state = rm->GetMediaByName(g_nonExistName, outValue);
1550     ASSERT_EQ(ERROR_CODE_RES_NAME_NOT_FOUND, state);
1551 }
1552 
1553 /*
1554  * @tc.name: ResourceManagerGetMediaByNameTest003
1555  * @tc.desc: Test GetMediaByName, to match sdpi determinder
1556  * @tc.type: FUNC
1557  */
1558 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest003, TestSize.Level1)
1559 {
1560     rmc->AddResource("en", nullptr, "US");
1561 
1562     HapResourceV1 *tmp = new HapResourceV1(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
1563     rmc->TestGetMediaWithDensityByName(tmp);
1564     delete tmp;
1565 }
1566 
1567 /*
1568  * @tc.name: ResourceManagerGetMediaByNameTest004
1569  * @tc.desc: Test GetMediaByName, to match mdpi determinder
1570  * @tc.type: FUNC
1571  */
1572 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest004, TestSize.Level1)
1573 {
1574     rmc->AddResource("en", nullptr, "US");
1575 
1576     HapResourceV1 *tmp = new HapResourceV1(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
1577     tmp->Init(rmc->defaultResConfig);
1578     std::string res = tmp->GetResourcePath();
1579     res.append("entry/resources/mdpi/media/icon.png");
1580 
1581     auto rc = CreateResConfig();
1582     if (rc == nullptr) {
1583         ASSERT_TRUE(false);
1584     }
1585     rc->SetDeviceType(DEVICE_PHONE);
1586     rc->SetColorMode(COLOR_MODE_NOT_SET);
1587     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
1588     rm->UpdateResConfig(*rc);
1589     delete rc;
1590 
1591     uint32_t density = 160;
1592     std::string outValue;
1593     RState state;
1594     state = rm->GetMediaByName("icon", outValue, density);
1595     EXPECT_TRUE(state == SUCCESS);
1596     EXPECT_EQ(res, outValue);
1597     delete tmp;
1598 }
1599 
1600 /*
1601  * @tc.name: ResourceManagerGetMediaByNameTest005
1602  * @tc.desc: Test GetMediaByName, to match ldpi determinder
1603  * @tc.type: FUNC
1604  */
1605 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest005, TestSize.Level1)
1606 {
1607     rmc->AddResource("en", nullptr, "US");
1608 
1609     HapResourceV1 *tmp = new HapResourceV1(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
1610     tmp->Init(rmc->defaultResConfig);
1611     std::string res = tmp->GetResourcePath();
1612     res.append("entry/resources/ldpi/media/icon.png");
1613 
1614     auto rc = CreateResConfig();
1615     if (rc == nullptr) {
1616         ASSERT_TRUE(false);
1617     }
1618     rc->SetDeviceType(DEVICE_PHONE);
1619     rc->SetColorMode(COLOR_MODE_NOT_SET);
1620     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
1621     rm->UpdateResConfig(*rc);
1622     delete rc;
1623 
1624     uint32_t density = 240;
1625     std::string outValue;
1626     RState state;
1627     state = rm->GetMediaByName("icon", outValue, density);
1628     EXPECT_TRUE(state == SUCCESS);
1629     EXPECT_EQ(res, outValue);
1630     delete tmp;
1631 }
1632 
1633 /*
1634  * @tc.name: ResourceManagerGetMediaByNameTest006
1635  * @tc.desc: Test GetMediaByName, to match xldpi determinder
1636  * @tc.type: FUNC
1637  */
1638 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest006, TestSize.Level1)
1639 {
1640     rmc->AddResource("en", nullptr, "US");
1641 
1642     HapResourceV1 *tmp = new HapResourceV1(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
1643     tmp->Init(rmc->defaultResConfig);
1644     std::string res = tmp->GetResourcePath();
1645     res.append("entry/resources/xldpi/media/icon.png");
1646 
1647     auto rc = CreateResConfig();
1648     if (rc == nullptr) {
1649         ASSERT_TRUE(false);
1650     }
1651     rc->SetDeviceType(DEVICE_PHONE);
1652     rc->SetColorMode(COLOR_MODE_NOT_SET);
1653     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
1654     rm->UpdateResConfig(*rc);
1655     delete rc;
1656 
1657     uint32_t density = 320;
1658     std::string outValue;
1659     RState state;
1660     state = rm->GetMediaByName("icon", outValue, density);
1661     EXPECT_TRUE(state == SUCCESS);
1662     EXPECT_EQ(res, outValue);
1663     delete tmp;
1664 }
1665 
1666 /*
1667  * @tc.name: ResourceManagerGetMediaByNameTest007
1668  * @tc.desc: Test GetMediaByName, to match xxldpi determinder
1669  * @tc.type: FUNC
1670  */
1671 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest007, TestSize.Level1)
1672 {
1673     rmc->AddResource("en", nullptr, "US");
1674 
1675     HapResourceV1 *tmp = new HapResourceV1(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
1676     tmp->Init(rmc->defaultResConfig);
1677     std::string res = tmp->GetResourcePath();
1678     res.append("entry/resources/xxldpi/media/icon.png");
1679 
1680     auto rc = CreateResConfig();
1681     if (rc == nullptr) {
1682         ASSERT_TRUE(false);
1683     }
1684     rc->SetDeviceType(DEVICE_PHONE);
1685     rc->SetColorMode(COLOR_MODE_NOT_SET);
1686     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
1687     rm->UpdateResConfig(*rc);
1688     delete rc;
1689 
1690     uint32_t density = 480;
1691     std::string outValue;
1692     RState state;
1693     state = rm->GetMediaByName("icon", outValue, density);
1694     EXPECT_TRUE(state == SUCCESS);
1695     EXPECT_EQ(res, outValue);
1696     delete tmp;
1697 }
1698 
1699 /*
1700  * @tc.name: ResourceManagerGetMediaByNameTest008
1701  * @tc.desc: Test GetMediaByName, to match xxxldpi determinder
1702  * @tc.type: FUNC
1703  */
1704 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest008, TestSize.Level1)
1705 {
1706     rmc->AddResource("en", nullptr, "US");
1707 
1708     HapResourceV1 *tmp = new HapResourceV1(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
1709     tmp->Init(rmc->defaultResConfig);
1710     std::string res = tmp->GetResourcePath();
1711     res.append("entry/resources/xxxldpi/media/icon.png");
1712 
1713     auto rc = CreateResConfig();
1714     if (rc == nullptr) {
1715         ASSERT_TRUE(false);
1716     }
1717     rc->SetDeviceType(DEVICE_PHONE);
1718     rc->SetColorMode(COLOR_MODE_NOT_SET);
1719     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
1720     rm->UpdateResConfig(*rc);
1721     delete rc;
1722 
1723     uint32_t density = 640;
1724     std::string outValue;
1725     RState state;
1726     state = rm->GetMediaByName("icon", outValue, density);
1727     EXPECT_TRUE(state == SUCCESS);
1728     EXPECT_EQ(res, outValue);
1729     delete tmp;
1730 }
1731 
1732 /*
1733  * @tc.name: ResourceManagerGetMediaByNameTest009
1734  * @tc.desc: Test GetMediaByName, to match unsupport density
1735  * @tc.type: FUNC
1736  */
1737 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest009, TestSize.Level1)
1738 {
1739     rmc->AddResource("en", nullptr, "US");
1740 
1741     uint32_t density1 = 420;
1742     uint32_t density2 = 800;
1743     uint32_t density3 = 10;
1744     std::string outValue;
1745     RState state1;
1746     RState state2;
1747     RState state3;
1748     state1 = rm->GetMediaByName("icon", outValue, density1);
1749     state2 = rm->GetMediaByName("icon", outValue, density2);
1750     state3 = rm->GetMediaByName("icon", outValue, density3);
1751     EXPECT_TRUE(state1 == ERROR_CODE_INVALID_INPUT_PARAMETER);
1752     EXPECT_TRUE(state2 == ERROR_CODE_INVALID_INPUT_PARAMETER);
1753     EXPECT_TRUE(state3 == ERROR_CODE_INVALID_INPUT_PARAMETER);
1754 }
1755 
1756 /*
1757  * @tc.name: ResourceManagerGetMediaByNameTest010
1758  * @tc.desc: Test GetMediaByName, to match with no density param
1759  * @tc.type: FUNC
1760  */
1761 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest010, TestSize.Level1)
1762 {
1763     rmc->AddResource("en", nullptr, "US");
1764 
1765     uint32_t density = 0;
1766     std::string outValue1;
1767     std::string outValue2;
1768     RState state1;
1769     RState state2;
1770     state1 = rm->GetMediaByName("icon", outValue1, density);
1771     state2 = rm->GetMediaByName("icon", outValue2);
1772     EXPECT_TRUE(state1 == SUCCESS);
1773     EXPECT_TRUE(state2 == SUCCESS);
1774     EXPECT_EQ(outValue1, outValue2);
1775 }
1776 
1777 /*
1778  * @tc.name: ResourceManagerGetMediaByNameTest011
1779  * @tc.desc: Test GetMediaByName, to match zh_CN-sdpi determinder
1780  * @tc.type: FUNC
1781  */
1782 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest011, TestSize.Level1)
1783 {
1784     rmc->AddResource("zh", nullptr, "CN");
1785 
1786     HapResourceV1 *tmp = new HapResourceV1(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
1787     tmp->Init(rmc->defaultResConfig);
1788     std::string res = tmp->GetResourcePath();
1789     res.append("entry/resources/zh_CN-sdpi/media/icon.png");
1790 
1791     auto rc = CreateResConfig();
1792     if (rc == nullptr) {
1793         ASSERT_TRUE(false);
1794     }
1795     rc->SetDeviceType(DEVICE_TABLET);
1796     rc->SetColorMode(COLOR_MODE_NOT_SET);
1797     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
1798     rm->UpdateResConfig(*rc);
1799     delete rc;
1800 
1801     int density = 120;
1802     std::string outValue;
1803     RState state;
1804     state = rm->GetMediaByName("icon", outValue, density);
1805     EXPECT_TRUE(state == SUCCESS);
1806     EXPECT_EQ(res, outValue);
1807     delete tmp;
1808 }
1809 
1810 /*
1811  * @tc.name: ResourceManagerGetMediaByNameTest012
1812  * @tc.desc: Test GetMediaByName, to match zh_CN-mdpi determinder
1813  * @tc.type: FUNC
1814  */
1815 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest012, TestSize.Level1)
1816 {
1817     rmc->AddResource("zh", nullptr, "CN");
1818 
1819     HapResourceV1 *tmp = new HapResourceV1(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
1820     tmp->Init(rmc->defaultResConfig);
1821     std::string res = tmp->GetResourcePath();
1822     res.append("entry/resources/zh_CN-mdpi/media/icon.png");
1823 
1824     auto rc = CreateResConfig();
1825     if (rc == nullptr) {
1826         ASSERT_TRUE(false);
1827     }
1828     rc->SetDeviceType(DEVICE_TABLET);
1829     rc->SetColorMode(COLOR_MODE_NOT_SET);
1830     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
1831     rm->UpdateResConfig(*rc);
1832     delete rc;
1833 
1834     int density = 160;
1835     std::string outValue;
1836     RState state;
1837     state = rm->GetMediaByName("icon", outValue, density);
1838     EXPECT_TRUE(state == SUCCESS);
1839     EXPECT_EQ(res, outValue);
1840     delete tmp;
1841 }
1842 
1843 /*
1844  * @tc.name: ResourceManagerGetMediaByNameTest013
1845  * @tc.desc: Test GetMediaByName, to match zh_CN-ldpi determinder
1846  * @tc.type: FUNC
1847  */
1848 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest013, TestSize.Level1)
1849 {
1850     rmc->AddResource("zh", nullptr, "CN");
1851 
1852     HapResourceV1 *tmp = new HapResourceV1(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
1853     tmp->Init(rmc->defaultResConfig);
1854     std::string res = tmp->GetResourcePath();
1855     res.append("entry/resources/zh_CN-ldpi/media/icon.png");
1856 
1857     auto rc = CreateResConfig();
1858     if (rc == nullptr) {
1859         ASSERT_TRUE(false);
1860     }
1861     rc->SetDeviceType(DEVICE_TABLET);
1862     rc->SetColorMode(COLOR_MODE_NOT_SET);
1863     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
1864     rm->UpdateResConfig(*rc);
1865     delete rc;
1866 
1867     int density = 240;
1868     std::string outValue;
1869     RState state;
1870     state = rm->GetMediaByName("icon", outValue, density);
1871     EXPECT_TRUE(state == SUCCESS);
1872     EXPECT_EQ(res, outValue);
1873     delete tmp;
1874 }
1875 
1876 /*
1877  * @tc.name: ResourceManagerGetMediaByNameTest014
1878  * @tc.desc: Test GetMediaByName, to match zh_CN-xldpi determinder
1879  * @tc.type: FUNC
1880  */
1881 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest014, TestSize.Level1)
1882 {
1883     rmc->AddResource("zh", nullptr, "CN");
1884 
1885     HapResourceV1 *tmp = new HapResourceV1(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
1886     tmp->Init(rmc->defaultResConfig);
1887     std::string res = tmp->GetResourcePath();
1888     res.append("entry/resources/zh_CN-xldpi/media/icon.png");
1889 
1890     auto rc = CreateResConfig();
1891     if (rc == nullptr) {
1892         ASSERT_TRUE(false);
1893     }
1894     rc->SetDeviceType(DEVICE_TABLET);
1895     rc->SetColorMode(COLOR_MODE_NOT_SET);
1896     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
1897     rm->UpdateResConfig(*rc);
1898     delete rc;
1899 
1900     int density = 320;
1901     std::string outValue;
1902     RState state;
1903     state = rm->GetMediaByName("icon", outValue, density);
1904     EXPECT_TRUE(state == SUCCESS);
1905     EXPECT_EQ(res, outValue);
1906     delete tmp;
1907 }
1908 
1909 /*
1910  * @tc.name: ResourceManagerGetMediaByNameTest015
1911  * @tc.desc: Test GetMediaByName, to match zh_CN-xxldpi determinder
1912  * @tc.type: FUNC
1913  */
1914 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest015, TestSize.Level1)
1915 {
1916     rmc->AddResource("zh", nullptr, "CN");
1917 
1918     HapResourceV1 *tmp = new HapResourceV1(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
1919     tmp->Init(rmc->defaultResConfig);
1920     std::string res = tmp->GetResourcePath();
1921     res.append("entry/resources/zh_CN-xxldpi/media/icon.png");
1922 
1923     auto rc = CreateResConfig();
1924     if (rc == nullptr) {
1925         ASSERT_TRUE(false);
1926     }
1927     rc->SetDeviceType(DEVICE_TABLET);
1928     rc->SetColorMode(COLOR_MODE_NOT_SET);
1929     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
1930     rm->UpdateResConfig(*rc);
1931     delete rc;
1932 
1933     int density = 480;
1934     std::string outValue;
1935     RState state;
1936     state = rm->GetMediaByName("icon", outValue, density);
1937     EXPECT_TRUE(state == SUCCESS);
1938     EXPECT_EQ(res, outValue);
1939     delete tmp;
1940 }
1941 
1942 /*
1943  * @tc.name: ResourceManagerGetMediaByNameTest016
1944  * @tc.desc: Test GetMediaByName, to match zh_CN-xxxldpi determinder
1945  * @tc.type: FUNC
1946  */
1947 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest016, TestSize.Level1)
1948 {
1949     rmc->AddResource("zh", nullptr, "CN");
1950 
1951     HapResourceV1 *tmp = new HapResourceV1(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
1952     tmp->Init(rmc->defaultResConfig);
1953     std::string res = tmp->GetResourcePath();
1954     res.append("entry/resources/zh_CN-xxxldpi/media/icon.png");
1955 
1956     auto rc = CreateResConfig();
1957     if (rc == nullptr) {
1958         ASSERT_TRUE(false);
1959     }
1960     rc->SetDeviceType(DEVICE_TABLET);
1961     rc->SetColorMode(COLOR_MODE_NOT_SET);
1962     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
1963     rm->UpdateResConfig(*rc);
1964     delete rc;
1965 
1966     int density = 640;
1967     std::string outValue;
1968     RState state;
1969     state = rm->GetMediaByName("icon", outValue, density);
1970     EXPECT_TRUE(state == SUCCESS);
1971     EXPECT_EQ(res, outValue);
1972     delete tmp;
1973 }
1974 
1975 /*
1976  * @tc.name: ResourceManagerGetMediaByNameTest017
1977  * @tc.desc: Test GetMediaByName, to match mcc460_mnc101-zh_CN-phone-dark-sdpi determinder
1978  * @tc.type: FUNC
1979  */
1980 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest017, TestSize.Level1)
1981 {
1982     rmc->AddResource("zh", nullptr, "CN");
1983 
1984     HapResourceV1 *tmp = new HapResourceV1(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
1985     tmp->Init(rmc->defaultResConfig);
1986     std::string res = tmp->GetResourcePath();
1987     res.append("entry/resources/mcc460_mnc101-zh_CN-phone-dark-sdpi/media/icon.png");
1988 
1989     auto rc = CreateResConfig();
1990     if (rc == nullptr) {
1991         ASSERT_TRUE(false);
1992     }
1993     rc->SetMcc(460);
1994     rc->SetMnc(101);
1995     rc->SetLocaleInfo("zh", nullptr, "CN");
1996     rc->SetDeviceType(DEVICE_PHONE);
1997     rc->SetColorMode(DARK);
1998     rc->SetScreenDensity(SCREEN_DENSITY_XXXLDPI / BASE_DPI);
1999     rm->UpdateResConfig(*rc);
2000     delete rc;
2001 
2002     int density = 120;
2003     std::string outValue;
2004     RState state;
2005     state = rm->GetMediaByName("icon", outValue, density);
2006     EXPECT_TRUE(state == SUCCESS);
2007     EXPECT_EQ(res, outValue);
2008     delete tmp;
2009 }
2010 
2011 /*
2012  * @tc.name: ResourceManagerGetMediaByNameTest018
2013  * @tc.desc: Test GetMediaByName, to match mcc460_mnc101-zh_CN-phone-dark-mdpi determinder
2014  * @tc.type: FUNC
2015  */
2016 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest018, TestSize.Level1)
2017 {
2018     rmc->AddResource("zh", nullptr, "CN");
2019 
2020     HapResourceV1 *tmp = new HapResourceV1(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
2021     tmp->Init(rmc->defaultResConfig);
2022     std::string res = tmp->GetResourcePath();
2023     res.append("entry/resources/mcc460_mnc101-zh_CN-phone-dark-mdpi/media/icon.png");
2024 
2025     auto rc = CreateResConfig();
2026     if (rc == nullptr) {
2027         ASSERT_TRUE(false);
2028     }
2029     rc->SetMcc(460);
2030     rc->SetMnc(101);
2031     rc->SetLocaleInfo("zh", nullptr, "CN");
2032     rc->SetDeviceType(DEVICE_PHONE);
2033     rc->SetColorMode(DARK);
2034     rc->SetScreenDensity(SCREEN_DENSITY_XXXLDPI / BASE_DPI);
2035     rm->UpdateResConfig(*rc);
2036     delete rc;
2037 
2038     int density = 160;
2039     std::string outValue;
2040     RState state;
2041     state = rm->GetMediaByName("icon", outValue, density);
2042     EXPECT_TRUE(state == SUCCESS);
2043     EXPECT_EQ(res, outValue);
2044     delete tmp;
2045 }
2046 
2047 /*
2048  * @tc.name: ResourceManagerGetMediaByNameTest019
2049  * @tc.desc: Test GetMediaByName, to match mcc460_mnc101-zh_CN-phone-dark-ldpi determinder
2050  * @tc.type: FUNC
2051  */
2052 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest019, TestSize.Level1)
2053 {
2054     rmc->AddResource("zh", nullptr, "CN");
2055 
2056     HapResourceV1 *tmp = new HapResourceV1(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
2057     tmp->Init(rmc->defaultResConfig);
2058     std::string res = tmp->GetResourcePath();
2059     res.append("entry/resources/mcc460_mnc101-zh_CN-phone-dark-ldpi/media/icon.png");
2060 
2061     auto rc = CreateResConfig();
2062     if (rc == nullptr) {
2063         ASSERT_TRUE(false);
2064     }
2065     rc->SetMcc(460);
2066     rc->SetMnc(101);
2067     rc->SetLocaleInfo("zh", nullptr, "CN");
2068     rc->SetDeviceType(DEVICE_PHONE);
2069     rc->SetColorMode(DARK);
2070     rc->SetScreenDensity(SCREEN_DENSITY_XXXLDPI / BASE_DPI);
2071     rm->UpdateResConfig(*rc);
2072     delete rc;
2073 
2074     int density = 240;
2075     std::string outValue;
2076     RState state;
2077     state = rm->GetMediaByName("icon", outValue, density);
2078     EXPECT_TRUE(state == SUCCESS);
2079     EXPECT_EQ(res, outValue);
2080     delete tmp;
2081 }
2082 
2083 /*
2084  * @tc.name: ResourceManagerGetMediaByNameTest020
2085  * @tc.desc: Test GetMediaByName, to match mcc460_mnc101-zh_CN-phone-dark-xldpi determinder
2086  * @tc.type: FUNC
2087  */
2088 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest020, TestSize.Level1)
2089 {
2090     rmc->AddResource("zh", nullptr, "CN");
2091 
2092     HapResourceV1 *tmp = new HapResourceV1(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
2093     tmp->Init(rmc->defaultResConfig);
2094     std::string res = tmp->GetResourcePath();
2095     res.append("entry/resources/mcc460_mnc101-zh_CN-phone-dark-xldpi/media/icon.png");
2096 
2097     auto rc = CreateResConfig();
2098     if (rc == nullptr) {
2099         ASSERT_TRUE(false);
2100     }
2101     rc->SetMcc(460);
2102     rc->SetMnc(101);
2103     rc->SetLocaleInfo("zh", nullptr, "CN");
2104     rc->SetDeviceType(DEVICE_PHONE);
2105     rc->SetColorMode(DARK);
2106     rc->SetScreenDensity(SCREEN_DENSITY_XXXLDPI / BASE_DPI);
2107     rm->UpdateResConfig(*rc);
2108     delete rc;
2109 
2110     int density = 320;
2111     std::string outValue;
2112     RState state;
2113     state = rm->GetMediaByName("icon", outValue, density);
2114     EXPECT_TRUE(state == SUCCESS);
2115     EXPECT_EQ(res, outValue);
2116     delete tmp;
2117 }
2118 
2119 /*
2120  * @tc.name: ResourceManagerGetMediaByNameTest021
2121  * @tc.desc: Test GetMediaByName, to match mcc460_mnc101-zh_CN-phone-dark-xxldpi determinder
2122  * @tc.type: FUNC
2123  */
2124 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest021, TestSize.Level1)
2125 {
2126     rmc->AddResource("zh", nullptr, "CN");
2127 
2128     HapResourceV1 *tmp = new HapResourceV1(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
2129     tmp->Init(rmc->defaultResConfig);
2130     std::string res = tmp->GetResourcePath();
2131     res.append("entry/resources/mcc460_mnc101-zh_CN-phone-dark-xxldpi/media/icon.png");
2132 
2133     auto rc = CreateResConfig();
2134     if (rc == nullptr) {
2135         ASSERT_TRUE(false);
2136     }
2137     rc->SetMcc(460);
2138     rc->SetMnc(101);
2139     rc->SetLocaleInfo("zh", nullptr, "CN");
2140     rc->SetDeviceType(DEVICE_PHONE);
2141     rc->SetColorMode(DARK);
2142     rc->SetScreenDensity(SCREEN_DENSITY_XXXLDPI / BASE_DPI);
2143     rm->UpdateResConfig(*rc);
2144     delete rc;
2145 
2146     int density = 480;
2147     std::string outValue;
2148     RState state;
2149     state = rm->GetMediaByName("icon", outValue, density);
2150     EXPECT_TRUE(state == SUCCESS);
2151     EXPECT_EQ(res, outValue);
2152     delete tmp;
2153 }
2154 
2155 /*
2156  * @tc.name: ResourceManagerGetMediaByNameTest022
2157  * @tc.desc: Test GetMediaByName, to match mcc460_mnc101-zh_CN-phone-dark-xxxldpi determinder
2158  * @tc.type: FUNC
2159  */
2160 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest022, TestSize.Level1)
2161 {
2162     rmc->AddResource("zh", nullptr, "CN");
2163 
2164     HapResourceV1 *tmp = new HapResourceV1(FormatFullPath(g_resFilePath).c_str(), 0, nullptr);
2165     tmp->Init(rmc->defaultResConfig);
2166     std::string res = tmp->GetResourcePath();
2167     res.append("entry/resources/mcc460_mnc101-zh_CN-phone-dark-xxxldpi/media/icon.png");
2168 
2169     auto rc = CreateResConfig();
2170     if (rc == nullptr) {
2171         ASSERT_TRUE(false);
2172     }
2173     rc->SetMcc(460);
2174     rc->SetMnc(101);
2175     rc->SetLocaleInfo("zh", nullptr, "CN");
2176     rc->SetDeviceType(DEVICE_PHONE);
2177     rc->SetColorMode(DARK);
2178     rc->SetScreenDensity(SCREEN_DENSITY_XXXLDPI / BASE_DPI);
2179     rm->UpdateResConfig(*rc);
2180     delete rc;
2181 
2182     int density = 640;
2183     std::string outValue;
2184     RState state;
2185     state = rm->GetMediaByName("icon", outValue, density);
2186     EXPECT_TRUE(state == SUCCESS);
2187     EXPECT_EQ(res, outValue);
2188     delete tmp;
2189 }
2190 
2191 /*
2192  * @tc.name: ResourceManagerGetMediaByNameTest023
2193  * @tc.desc: Test GetMediaByName
2194  * @tc.type: FUNC
2195  */
2196 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest023, TestSize.Level1)
2197 {
2198     rmc->AddResource("zh", nullptr, "CN");
2199 
2200     HapResourceV2 *tmp = new HapResourceV2(FormatFullPath(g_newResFilePath).c_str(), 0);
2201     rmc->TestGetMediaByName(tmp);
2202     delete tmp;
2203 }
2204 
2205 /*
2206  * @tc.name: ResourceManagerGetMediaByNameTest024
2207  * @tc.desc: Test GetMediaByName, to match sdpi determinder
2208  * @tc.type: FUNC
2209  */
2210 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest024, TestSize.Level1)
2211 {
2212     rmc->AddResource("en", nullptr, "US");
2213 
2214     HapResourceV2 *tmp = new HapResourceV2(FormatFullPath(g_newResFilePath).c_str(), 0);
2215     rmc->TestGetMediaWithDensityByName(tmp);
2216     delete tmp;
2217 }
2218 
2219 /*
2220  * @tc.name: ResourceManagerGetMediaByNameTest025
2221  * @tc.desc: Test GetMediaByName, to match mdpi determinder
2222  * @tc.type: FUNC
2223  */
2224 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest025, TestSize.Level1)
2225 {
2226     rmc->AddResource("en", nullptr, "US");
2227 
2228     HapResourceV2 *tmp = new HapResourceV2(FormatFullPath(g_newResFilePath).c_str(), 0);
2229     std::unordered_map<uint32_t, std::shared_ptr<ResConfigImpl>> keys;
2230     std::unordered_map<uint32_t, std::shared_ptr<IdValuesV2>> idMap;
2231     std::unordered_map<uint32_t, std::unordered_map<std::string, std::shared_ptr<IdValuesV2>>> typeNameMap;
2232     std::shared_ptr<MmapFile> mMap;
2233     tmp->Init(keys, idMap, typeNameMap, mMap);
2234     std::string res = tmp->GetResourcePath();
2235     res.append("entry/resources/mdpi/media/icon.png");
2236 
2237     auto rc = CreateResConfig();
2238     if (rc == nullptr) {
2239         ASSERT_TRUE(false);
2240     }
2241     rc->SetDeviceType(DEVICE_PHONE);
2242     rc->SetColorMode(COLOR_MODE_NOT_SET);
2243     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
2244     rm->UpdateResConfig(*rc);
2245     delete rc;
2246 
2247     uint32_t density = 160;
2248     std::string outValue;
2249     RState state;
2250     state = rm->GetMediaByName("icon", outValue, density);
2251     EXPECT_TRUE(state == SUCCESS);
2252     EXPECT_EQ(res, outValue);
2253     delete tmp;
2254 }
2255 
2256 /*
2257  * @tc.name: ResourceManagerGetMediaByNameTest026
2258  * @tc.desc: Test GetMediaByName, to match ldpi determinder
2259  * @tc.type: FUNC
2260  */
2261 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest026, TestSize.Level1)
2262 {
2263     rmc->AddResource("en", nullptr, "US");
2264 
2265     HapResourceV2 *tmp = new HapResourceV2(FormatFullPath(g_newResFilePath).c_str(), 0);
2266     std::unordered_map<uint32_t, std::shared_ptr<ResConfigImpl>> keys;
2267     std::unordered_map<uint32_t, std::shared_ptr<IdValuesV2>> idMap;
2268     std::unordered_map<uint32_t, std::unordered_map<std::string, std::shared_ptr<IdValuesV2>>> typeNameMap;
2269     std::shared_ptr<MmapFile> mMap;
2270     tmp->Init(keys, idMap, typeNameMap, mMap);
2271     std::string res = tmp->GetResourcePath();
2272     res.append("entry/resources/ldpi/media/icon.png");
2273 
2274     auto rc = CreateResConfig();
2275     if (rc == nullptr) {
2276         ASSERT_TRUE(false);
2277     }
2278     rc->SetDeviceType(DEVICE_PHONE);
2279     rc->SetColorMode(COLOR_MODE_NOT_SET);
2280     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
2281     rm->UpdateResConfig(*rc);
2282     delete rc;
2283 
2284     uint32_t density = 240;
2285     std::string outValue;
2286     RState state;
2287     state = rm->GetMediaByName("icon", outValue, density);
2288     EXPECT_TRUE(state == SUCCESS);
2289     EXPECT_EQ(res, outValue);
2290     delete tmp;
2291 }
2292 
2293 /*
2294  * @tc.name: ResourceManagerGetMediaByNameTest027
2295  * @tc.desc: Test GetMediaByName, to match xldpi determinder
2296  * @tc.type: FUNC
2297  */
2298 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest027, TestSize.Level1)
2299 {
2300     rmc->AddResource("en", nullptr, "US");
2301 
2302     HapResourceV2 *tmp = new HapResourceV2(FormatFullPath(g_newResFilePath).c_str(), 0);
2303     std::unordered_map<uint32_t, std::shared_ptr<ResConfigImpl>> keys;
2304     std::unordered_map<uint32_t, std::shared_ptr<IdValuesV2>> idMap;
2305     std::unordered_map<uint32_t, std::unordered_map<std::string, std::shared_ptr<IdValuesV2>>> typeNameMap;
2306     std::shared_ptr<MmapFile> mMap;
2307     tmp->Init(keys, idMap, typeNameMap, mMap);
2308     std::string res = tmp->GetResourcePath();
2309     res.append("entry/resources/xldpi/media/icon.png");
2310 
2311     auto rc = CreateResConfig();
2312     if (rc == nullptr) {
2313         ASSERT_TRUE(false);
2314     }
2315     rc->SetDeviceType(DEVICE_PHONE);
2316     rc->SetColorMode(COLOR_MODE_NOT_SET);
2317     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
2318     rm->UpdateResConfig(*rc);
2319     delete rc;
2320 
2321     uint32_t density = 320;
2322     std::string outValue;
2323     RState state;
2324     state = rm->GetMediaByName("icon", outValue, density);
2325     EXPECT_TRUE(state == SUCCESS);
2326     EXPECT_EQ(res, outValue);
2327     delete tmp;
2328 }
2329 
2330 /*
2331  * @tc.name: ResourceManagerGetMediaByNameTest028
2332  * @tc.desc: Test GetMediaByName, to match xxldpi determinder
2333  * @tc.type: FUNC
2334  */
2335 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest028, TestSize.Level1)
2336 {
2337     rmc->AddResource("en", nullptr, "US");
2338 
2339     HapResourceV2 *tmp = new HapResourceV2(FormatFullPath(g_newResFilePath).c_str(), 0);
2340     std::unordered_map<uint32_t, std::shared_ptr<ResConfigImpl>> keys;
2341     std::unordered_map<uint32_t, std::shared_ptr<IdValuesV2>> idMap;
2342     std::unordered_map<uint32_t, std::unordered_map<std::string, std::shared_ptr<IdValuesV2>>> typeNameMap;
2343     std::shared_ptr<MmapFile> mMap;
2344     tmp->Init(keys, idMap, typeNameMap, mMap);
2345     std::string res = tmp->GetResourcePath();
2346     res.append("entry/resources/xxldpi/media/icon.png");
2347 
2348     auto rc = CreateResConfig();
2349     if (rc == nullptr) {
2350         ASSERT_TRUE(false);
2351     }
2352     rc->SetDeviceType(DEVICE_PHONE);
2353     rc->SetColorMode(COLOR_MODE_NOT_SET);
2354     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
2355     rm->UpdateResConfig(*rc);
2356     delete rc;
2357 
2358     uint32_t density = 480;
2359     std::string outValue;
2360     RState state;
2361     state = rm->GetMediaByName("icon", outValue, density);
2362     EXPECT_TRUE(state == SUCCESS);
2363     EXPECT_EQ(res, outValue);
2364     delete tmp;
2365 }
2366 
2367 /*
2368  * @tc.name: ResourceManagerGetMediaByNameTest029
2369  * @tc.desc: Test GetMediaByName, to match xxxldpi determinder
2370  * @tc.type: FUNC
2371  */
2372 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest029, TestSize.Level1)
2373 {
2374     rmc->AddResource("en", nullptr, "US");
2375 
2376     HapResourceV2 *tmp = new HapResourceV2(FormatFullPath(g_newResFilePath).c_str(), 0);
2377     std::unordered_map<uint32_t, std::shared_ptr<ResConfigImpl>> keys;
2378     std::unordered_map<uint32_t, std::shared_ptr<IdValuesV2>> idMap;
2379     std::unordered_map<uint32_t, std::unordered_map<std::string, std::shared_ptr<IdValuesV2>>> typeNameMap;
2380     std::shared_ptr<MmapFile> mMap;
2381     tmp->Init(keys, idMap, typeNameMap, mMap);
2382     std::string res = tmp->GetResourcePath();
2383     res.append("entry/resources/xxxldpi/media/icon.png");
2384 
2385     auto rc = CreateResConfig();
2386     if (rc == nullptr) {
2387         ASSERT_TRUE(false);
2388     }
2389     rc->SetDeviceType(DEVICE_PHONE);
2390     rc->SetColorMode(COLOR_MODE_NOT_SET);
2391     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
2392     rm->UpdateResConfig(*rc);
2393     delete rc;
2394 
2395     uint32_t density = 640;
2396     std::string outValue;
2397     RState state;
2398     state = rm->GetMediaByName("icon", outValue, density);
2399     EXPECT_TRUE(state == SUCCESS);
2400     EXPECT_EQ(res, outValue);
2401     delete tmp;
2402 }
2403 
2404 /*
2405  * @tc.name: ResourceManagerGetMediaByNameTest030
2406  * @tc.desc: Test GetMediaByName, to match zh_CN-sdpi determinder
2407  * @tc.type: FUNC
2408  */
2409 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest030, TestSize.Level1)
2410 {
2411     rmc->AddResource("zh", nullptr, "CN");
2412 
2413     HapResourceV2 *tmp = new HapResourceV2(FormatFullPath(g_newResFilePath).c_str(), 0);
2414     std::unordered_map<uint32_t, std::shared_ptr<ResConfigImpl>> keys;
2415     std::unordered_map<uint32_t, std::shared_ptr<IdValuesV2>> idMap;
2416     std::unordered_map<uint32_t, std::unordered_map<std::string, std::shared_ptr<IdValuesV2>>> typeNameMap;
2417     std::shared_ptr<MmapFile> mMap;
2418     tmp->Init(keys, idMap, typeNameMap, mMap);
2419     std::string res = tmp->GetResourcePath();
2420     res.append("entry/resources/zh_CN-sdpi/media/icon.png");
2421 
2422     auto rc = CreateResConfig();
2423     if (rc == nullptr) {
2424         ASSERT_TRUE(false);
2425     }
2426     rc->SetDeviceType(DEVICE_TABLET);
2427     rc->SetColorMode(COLOR_MODE_NOT_SET);
2428     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
2429     rm->UpdateResConfig(*rc);
2430     delete rc;
2431 
2432     int density = 120;
2433     std::string outValue;
2434     RState state;
2435     state = rm->GetMediaByName("icon", outValue, density);
2436     EXPECT_TRUE(state == SUCCESS);
2437     EXPECT_EQ(res, outValue);
2438     delete tmp;
2439 }
2440 
2441 /*
2442  * @tc.name: ResourceManagerGetMediaByNameTest031
2443  * @tc.desc: Test GetMediaByName, to match zh_CN-mdpi determinder
2444  * @tc.type: FUNC
2445  */
2446 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest031, TestSize.Level1)
2447 {
2448     rmc->AddResource("zh", nullptr, "CN");
2449 
2450     HapResourceV2 *tmp = new HapResourceV2(FormatFullPath(g_newResFilePath).c_str(), 0);
2451     std::unordered_map<uint32_t, std::shared_ptr<ResConfigImpl>> keys;
2452     std::unordered_map<uint32_t, std::shared_ptr<IdValuesV2>> idMap;
2453     std::unordered_map<uint32_t, std::unordered_map<std::string, std::shared_ptr<IdValuesV2>>> typeNameMap;
2454     std::shared_ptr<MmapFile> mMap;
2455     tmp->Init(keys, idMap, typeNameMap, mMap);
2456     std::string res = tmp->GetResourcePath();
2457     res.append("entry/resources/zh_CN-mdpi/media/icon.png");
2458 
2459     auto rc = CreateResConfig();
2460     if (rc == nullptr) {
2461         ASSERT_TRUE(false);
2462     }
2463     rc->SetDeviceType(DEVICE_TABLET);
2464     rc->SetColorMode(COLOR_MODE_NOT_SET);
2465     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
2466     rm->UpdateResConfig(*rc);
2467     delete rc;
2468 
2469     int density = 160;
2470     std::string outValue;
2471     RState state;
2472     state = rm->GetMediaByName("icon", outValue, density);
2473     EXPECT_TRUE(state == SUCCESS);
2474     EXPECT_EQ(res, outValue);
2475     delete tmp;
2476 }
2477 
2478 /*
2479  * @tc.name: ResourceManagerGetMediaByNameTest032
2480  * @tc.desc: Test GetMediaByName, to match zh_CN-ldpi determinder
2481  * @tc.type: FUNC
2482  */
2483 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest032, TestSize.Level1)
2484 {
2485     rmc->AddResource("zh", nullptr, "CN");
2486 
2487     HapResourceV2 *tmp = new HapResourceV2(FormatFullPath(g_newResFilePath).c_str(), 0);
2488     std::unordered_map<uint32_t, std::shared_ptr<ResConfigImpl>> keys;
2489     std::unordered_map<uint32_t, std::shared_ptr<IdValuesV2>> idMap;
2490     std::unordered_map<uint32_t, std::unordered_map<std::string, std::shared_ptr<IdValuesV2>>> typeNameMap;
2491     std::shared_ptr<MmapFile> mMap;
2492     tmp->Init(keys, idMap, typeNameMap, mMap);
2493     std::string res = tmp->GetResourcePath();
2494     res.append("entry/resources/zh_CN-ldpi/media/icon.png");
2495 
2496     auto rc = CreateResConfig();
2497     if (rc == nullptr) {
2498         ASSERT_TRUE(false);
2499     }
2500     rc->SetDeviceType(DEVICE_TABLET);
2501     rc->SetColorMode(COLOR_MODE_NOT_SET);
2502     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
2503     rm->UpdateResConfig(*rc);
2504     delete rc;
2505 
2506     int density = 240;
2507     std::string outValue;
2508     RState state;
2509     state = rm->GetMediaByName("icon", outValue, density);
2510     EXPECT_TRUE(state == SUCCESS);
2511     EXPECT_EQ(res, outValue);
2512     delete tmp;
2513 }
2514 
2515 /*
2516  * @tc.name: ResourceManagerGetMediaByNameTest033
2517  * @tc.desc: Test GetMediaByName, to match zh_CN-xldpi determinder
2518  * @tc.type: FUNC
2519  */
2520 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest033, TestSize.Level1)
2521 {
2522     rmc->AddResource("zh", nullptr, "CN");
2523 
2524     HapResourceV2 *tmp = new HapResourceV2(FormatFullPath(g_newResFilePath).c_str(), 0);
2525     std::unordered_map<uint32_t, std::shared_ptr<ResConfigImpl>> keys;
2526     std::unordered_map<uint32_t, std::shared_ptr<IdValuesV2>> idMap;
2527     std::unordered_map<uint32_t, std::unordered_map<std::string, std::shared_ptr<IdValuesV2>>> typeNameMap;
2528     std::shared_ptr<MmapFile> mMap;
2529     tmp->Init(keys, idMap, typeNameMap, mMap);
2530     std::string res = tmp->GetResourcePath();
2531     res.append("entry/resources/zh_CN-xldpi/media/icon.png");
2532 
2533     auto rc = CreateResConfig();
2534     if (rc == nullptr) {
2535         ASSERT_TRUE(false);
2536     }
2537     rc->SetDeviceType(DEVICE_TABLET);
2538     rc->SetColorMode(COLOR_MODE_NOT_SET);
2539     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
2540     rm->UpdateResConfig(*rc);
2541     delete rc;
2542 
2543     int density = 320;
2544     std::string outValue;
2545     RState state;
2546     state = rm->GetMediaByName("icon", outValue, density);
2547     EXPECT_TRUE(state == SUCCESS);
2548     EXPECT_EQ(res, outValue);
2549     delete tmp;
2550 }
2551 
2552 /*
2553  * @tc.name: ResourceManagerGetMediaByNameTest034
2554  * @tc.desc: Test GetMediaByName, to match zh_CN-xxldpi determinder
2555  * @tc.type: FUNC
2556  */
2557 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest034, TestSize.Level1)
2558 {
2559     rmc->AddResource("zh", nullptr, "CN");
2560 
2561     HapResourceV2 *tmp = new HapResourceV2(FormatFullPath(g_newResFilePath).c_str(), 0);
2562     std::unordered_map<uint32_t, std::shared_ptr<ResConfigImpl>> keys;
2563     std::unordered_map<uint32_t, std::shared_ptr<IdValuesV2>> idMap;
2564     std::unordered_map<uint32_t, std::unordered_map<std::string, std::shared_ptr<IdValuesV2>>> typeNameMap;
2565     std::shared_ptr<MmapFile> mMap;
2566     tmp->Init(keys, idMap, typeNameMap, mMap);
2567     std::string res = tmp->GetResourcePath();
2568     res.append("entry/resources/zh_CN-xxldpi/media/icon.png");
2569 
2570     auto rc = CreateResConfig();
2571     if (rc == nullptr) {
2572         ASSERT_TRUE(false);
2573     }
2574     rc->SetDeviceType(DEVICE_TABLET);
2575     rc->SetColorMode(COLOR_MODE_NOT_SET);
2576     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
2577     rm->UpdateResConfig(*rc);
2578     delete rc;
2579 
2580     int density = 480;
2581     std::string outValue;
2582     RState state;
2583     state = rm->GetMediaByName("icon", outValue, density);
2584     EXPECT_TRUE(state == SUCCESS);
2585     EXPECT_EQ(res, outValue);
2586     delete tmp;
2587 }
2588 
2589 /*
2590  * @tc.name: ResourceManagerGetMediaByNameTest035
2591  * @tc.desc: Test GetMediaByName, to match zh_CN-xxxldpi determinder
2592  * @tc.type: FUNC
2593  */
2594 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest035, TestSize.Level1)
2595 {
2596     rmc->AddResource("zh", nullptr, "CN");
2597 
2598     HapResourceV2 *tmp = new HapResourceV2(FormatFullPath(g_newResFilePath).c_str(), 0);
2599     std::unordered_map<uint32_t, std::shared_ptr<ResConfigImpl>> keys;
2600     std::unordered_map<uint32_t, std::shared_ptr<IdValuesV2>> idMap;
2601     std::unordered_map<uint32_t, std::unordered_map<std::string, std::shared_ptr<IdValuesV2>>> typeNameMap;
2602     std::shared_ptr<MmapFile> mMap;
2603     tmp->Init(keys, idMap, typeNameMap, mMap);
2604     std::string res = tmp->GetResourcePath();
2605     res.append("entry/resources/zh_CN-xxxldpi/media/icon.png");
2606 
2607     auto rc = CreateResConfig();
2608     if (rc == nullptr) {
2609         ASSERT_TRUE(false);
2610     }
2611     rc->SetDeviceType(DEVICE_TABLET);
2612     rc->SetColorMode(COLOR_MODE_NOT_SET);
2613     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
2614     rm->UpdateResConfig(*rc);
2615     delete rc;
2616 
2617     int density = 640;
2618     std::string outValue;
2619     RState state;
2620     state = rm->GetMediaByName("icon", outValue, density);
2621     EXPECT_TRUE(state == SUCCESS);
2622     EXPECT_EQ(res, outValue);
2623     delete tmp;
2624 }
2625 
2626 /*
2627  * @tc.name: ResourceManagerGetMediaByNameTest036
2628  * @tc.desc: Test GetMediaByName, to match mcc460_mnc101-zh_CN-phone-dark-sdpi determinder
2629  * @tc.type: FUNC
2630  */
2631 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest036, TestSize.Level1)
2632 {
2633     rmc->AddResource("zh", nullptr, "CN");
2634 
2635     HapResourceV2 *tmp = new HapResourceV2(FormatFullPath(g_newResFilePath).c_str(), 0);
2636     std::unordered_map<uint32_t, std::shared_ptr<ResConfigImpl>> keys;
2637     std::unordered_map<uint32_t, std::shared_ptr<IdValuesV2>> idMap;
2638     std::unordered_map<uint32_t, std::unordered_map<std::string, std::shared_ptr<IdValuesV2>>> typeNameMap;
2639     std::shared_ptr<MmapFile> mMap;
2640     tmp->Init(keys, idMap, typeNameMap, mMap);
2641     std::string res = tmp->GetResourcePath();
2642     res.append("entry/resources/mcc460_mnc101-zh_CN-phone-dark-sdpi/media/icon.png");
2643 
2644     auto rc = CreateResConfig();
2645     if (rc == nullptr) {
2646         ASSERT_TRUE(false);
2647     }
2648     rc->SetMcc(460);
2649     rc->SetMnc(101);
2650     rc->SetLocaleInfo("zh", nullptr, "CN");
2651     rc->SetDeviceType(DEVICE_PHONE);
2652     rc->SetColorMode(DARK);
2653     rc->SetScreenDensity(SCREEN_DENSITY_XXXLDPI / BASE_DPI);
2654     rm->UpdateResConfig(*rc);
2655     delete rc;
2656 
2657     int density = 120;
2658     std::string outValue;
2659     RState state;
2660     state = rm->GetMediaByName("icon", outValue, density);
2661     EXPECT_TRUE(state == SUCCESS);
2662     EXPECT_EQ(res, outValue);
2663     delete tmp;
2664 }
2665 
2666 /*
2667  * @tc.name: ResourceManagerGetMediaByNameTest037
2668  * @tc.desc: Test GetMediaByName, to match mcc460_mnc101-zh_CN-phone-dark-mdpi determinder
2669  * @tc.type: FUNC
2670  */
2671 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest037, TestSize.Level1)
2672 {
2673     rmc->AddResource("zh", nullptr, "CN");
2674 
2675     HapResourceV2 *tmp = new HapResourceV2(FormatFullPath(g_newResFilePath).c_str(), 0);
2676     std::unordered_map<uint32_t, std::shared_ptr<ResConfigImpl>> keys;
2677     std::unordered_map<uint32_t, std::shared_ptr<IdValuesV2>> idMap;
2678     std::unordered_map<uint32_t, std::unordered_map<std::string, std::shared_ptr<IdValuesV2>>> typeNameMap;
2679     std::shared_ptr<MmapFile> mMap;
2680     tmp->Init(keys, idMap, typeNameMap, mMap);
2681     std::string res = tmp->GetResourcePath();
2682     res.append("entry/resources/mcc460_mnc101-zh_CN-phone-dark-mdpi/media/icon.png");
2683 
2684     auto rc = CreateResConfig();
2685     if (rc == nullptr) {
2686         ASSERT_TRUE(false);
2687     }
2688     rc->SetMcc(460);
2689     rc->SetMnc(101);
2690     rc->SetLocaleInfo("zh", nullptr, "CN");
2691     rc->SetDeviceType(DEVICE_PHONE);
2692     rc->SetColorMode(DARK);
2693     rc->SetScreenDensity(SCREEN_DENSITY_XXXLDPI / BASE_DPI);
2694     rm->UpdateResConfig(*rc);
2695     delete rc;
2696 
2697     int density = 160;
2698     std::string outValue;
2699     RState state;
2700     state = rm->GetMediaByName("icon", outValue, density);
2701     EXPECT_TRUE(state == SUCCESS);
2702     EXPECT_EQ(res, outValue);
2703     delete tmp;
2704 }
2705 
2706 /*
2707  * @tc.name: ResourceManagerGetMediaByNameTest038
2708  * @tc.desc: Test GetMediaByName, to match mcc460_mnc101-zh_CN-phone-dark-ldpi determinder
2709  * @tc.type: FUNC
2710  */
2711 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest038, TestSize.Level1)
2712 {
2713     rmc->AddResource("zh", nullptr, "CN");
2714 
2715     HapResourceV2 *tmp = new HapResourceV2(FormatFullPath(g_newResFilePath).c_str(), 0);
2716     std::unordered_map<uint32_t, std::shared_ptr<ResConfigImpl>> keys;
2717     std::unordered_map<uint32_t, std::shared_ptr<IdValuesV2>> idMap;
2718     std::unordered_map<uint32_t, std::unordered_map<std::string, std::shared_ptr<IdValuesV2>>> typeNameMap;
2719     std::shared_ptr<MmapFile> mMap;
2720     tmp->Init(keys, idMap, typeNameMap, mMap);
2721     std::string res = tmp->GetResourcePath();
2722     res.append("entry/resources/mcc460_mnc101-zh_CN-phone-dark-ldpi/media/icon.png");
2723 
2724     auto rc = CreateResConfig();
2725     if (rc == nullptr) {
2726         ASSERT_TRUE(false);
2727     }
2728     rc->SetMcc(460);
2729     rc->SetMnc(101);
2730     rc->SetLocaleInfo("zh", nullptr, "CN");
2731     rc->SetDeviceType(DEVICE_PHONE);
2732     rc->SetColorMode(DARK);
2733     rc->SetScreenDensity(SCREEN_DENSITY_XXXLDPI / BASE_DPI);
2734     rm->UpdateResConfig(*rc);
2735     delete rc;
2736 
2737     int density = 240;
2738     std::string outValue;
2739     RState state;
2740     state = rm->GetMediaByName("icon", outValue, density);
2741     EXPECT_TRUE(state == SUCCESS);
2742     EXPECT_EQ(res, outValue);
2743     delete tmp;
2744 }
2745 
2746 /*
2747  * @tc.name: ResourceManagerGetMediaByNameTest039
2748  * @tc.desc: Test GetMediaByName, to match mcc460_mnc101-zh_CN-phone-dark-xldpi determinder
2749  * @tc.type: FUNC
2750  */
2751 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest039, TestSize.Level1)
2752 {
2753     rmc->AddResource("zh", nullptr, "CN");
2754 
2755     HapResourceV2 *tmp = new HapResourceV2(FormatFullPath(g_newResFilePath).c_str(), 0);
2756     std::unordered_map<uint32_t, std::shared_ptr<ResConfigImpl>> keys;
2757     std::unordered_map<uint32_t, std::shared_ptr<IdValuesV2>> idMap;
2758     std::unordered_map<uint32_t, std::unordered_map<std::string, std::shared_ptr<IdValuesV2>>> typeNameMap;
2759     std::shared_ptr<MmapFile> mMap;
2760     tmp->Init(keys, idMap, typeNameMap, mMap);
2761     std::string res = tmp->GetResourcePath();
2762     res.append("entry/resources/mcc460_mnc101-zh_CN-phone-dark-xldpi/media/icon.png");
2763 
2764     auto rc = CreateResConfig();
2765     if (rc == nullptr) {
2766         ASSERT_TRUE(false);
2767     }
2768     rc->SetMcc(460);
2769     rc->SetMnc(101);
2770     rc->SetLocaleInfo("zh", nullptr, "CN");
2771     rc->SetDeviceType(DEVICE_PHONE);
2772     rc->SetColorMode(DARK);
2773     rc->SetScreenDensity(SCREEN_DENSITY_XXXLDPI / BASE_DPI);
2774     rm->UpdateResConfig(*rc);
2775     delete rc;
2776 
2777     int density = 320;
2778     std::string outValue;
2779     RState state;
2780     state = rm->GetMediaByName("icon", outValue, density);
2781     EXPECT_TRUE(state == SUCCESS);
2782     EXPECT_EQ(res, outValue);
2783     delete tmp;
2784 }
2785 
2786 /*
2787  * @tc.name: ResourceManagerGetMediaByNameTest040
2788  * @tc.desc: Test GetMediaByName, to match mcc460_mnc101-zh_CN-phone-dark-xxldpi determinder
2789  * @tc.type: FUNC
2790  */
2791 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest040, TestSize.Level1)
2792 {
2793     rmc->AddResource("zh", nullptr, "CN");
2794 
2795     HapResourceV2 *tmp = new HapResourceV2(FormatFullPath(g_newResFilePath).c_str(), 0);
2796     std::unordered_map<uint32_t, std::shared_ptr<ResConfigImpl>> keys;
2797     std::unordered_map<uint32_t, std::shared_ptr<IdValuesV2>> idMap;
2798     std::unordered_map<uint32_t, std::unordered_map<std::string, std::shared_ptr<IdValuesV2>>> typeNameMap;
2799     std::shared_ptr<MmapFile> mMap;
2800     tmp->Init(keys, idMap, typeNameMap, mMap);
2801     std::string res = tmp->GetResourcePath();
2802     res.append("entry/resources/mcc460_mnc101-zh_CN-phone-dark-xxldpi/media/icon.png");
2803 
2804     auto rc = CreateResConfig();
2805     if (rc == nullptr) {
2806         ASSERT_TRUE(false);
2807     }
2808     rc->SetMcc(460);
2809     rc->SetMnc(101);
2810     rc->SetLocaleInfo("zh", nullptr, "CN");
2811     rc->SetDeviceType(DEVICE_PHONE);
2812     rc->SetColorMode(DARK);
2813     rc->SetScreenDensity(SCREEN_DENSITY_XXXLDPI / BASE_DPI);
2814     rm->UpdateResConfig(*rc);
2815     delete rc;
2816 
2817     int density = 480;
2818     std::string outValue;
2819     RState state;
2820     state = rm->GetMediaByName("icon", outValue, density);
2821     EXPECT_TRUE(state == SUCCESS);
2822     EXPECT_EQ(res, outValue);
2823     delete tmp;
2824 }
2825 
2826 /*
2827  * @tc.name: ResourceManagerGetMediaByNameTest041
2828  * @tc.desc: Test GetMediaByName, to match mcc460_mnc101-zh_CN-phone-dark-xxxldpi determinder
2829  * @tc.type: FUNC
2830  */
2831 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetMediaByNameTest041, TestSize.Level1)
2832 {
2833     rmc->AddResource("zh", nullptr, "CN");
2834 
2835     HapResourceV2 *tmp = new HapResourceV2(FormatFullPath(g_newResFilePath).c_str(), 0);
2836     std::unordered_map<uint32_t, std::shared_ptr<ResConfigImpl>> keys;
2837     std::unordered_map<uint32_t, std::shared_ptr<IdValuesV2>> idMap;
2838     std::unordered_map<uint32_t, std::unordered_map<std::string, std::shared_ptr<IdValuesV2>>> typeNameMap;
2839     std::shared_ptr<MmapFile> mMap;
2840     tmp->Init(keys, idMap, typeNameMap, mMap);
2841     std::string res = tmp->GetResourcePath();
2842     res.append("entry/resources/mcc460_mnc101-zh_CN-phone-dark-xxxldpi/media/icon.png");
2843 
2844     auto rc = CreateResConfig();
2845     if (rc == nullptr) {
2846         ASSERT_TRUE(false);
2847     }
2848     rc->SetMcc(460);
2849     rc->SetMnc(101);
2850     rc->SetLocaleInfo("zh", nullptr, "CN");
2851     rc->SetDeviceType(DEVICE_PHONE);
2852     rc->SetColorMode(DARK);
2853     rc->SetScreenDensity(SCREEN_DENSITY_XXXLDPI / BASE_DPI);
2854     rm->UpdateResConfig(*rc);
2855     delete rc;
2856 
2857     int density = 640;
2858     std::string outValue;
2859     RState state;
2860     state = rm->GetMediaByName("icon", outValue, density);
2861     EXPECT_TRUE(state == SUCCESS);
2862     EXPECT_EQ(res, outValue);
2863     delete tmp;
2864 }
2865 
2866 /*
2867  * @tc.name: ResourceManagerGetDrawableInfoByNameTest001
2868  * @tc.desc: Test GetDrawableInfoByName
2869  * @tc.type: FUNC
2870  */
2871 HWTEST_F(ResourceManagerTestMedia, ResourceManagerGetDrawableInfoByNameTest001, TestSize.Level1)
2872 {
2873     rmc->AddResource("zh", nullptr, "CN");
2874 
2875     auto rc = CreateResConfig();
2876     if (rc == nullptr) {
2877         ASSERT_TRUE(false);
2878     }
2879     rc->SetDeviceType(DEVICE_TABLET);
2880     rc->SetColorMode(COLOR_MODE_NOT_SET);
2881     rc->SetScreenDensity(SCREEN_DENSITY_NOT_SET);
2882     rm->UpdateResConfig(*rc);
2883     delete rc;
2884 
2885     int density = 480;
2886     std::unique_ptr<uint8_t[]> outValue;
2887     RState state;
2888     std::tuple<std::string, size_t, std::string> info;
2889     state = rm->GetDrawableInfoByName("icon", info, outValue, 1, density);
2890     EXPECT_TRUE(state == SUCCESS);
2891 }
2892 }
2893