1 /*
2 * Copyright (c) 2021 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15 #include "res_config_test.h"
16
17 #include <climits>
18 #include <cstring>
19 #include <gtest/gtest.h>
20
21 #include "hap_resource.h"
22 #include "res_config.h"
23 #include "resource_manager_impl.h"
24 #include "test_common.h"
25
26 using namespace OHOS::Global::Resource;
27 using namespace testing::ext;
28
29 class ResConfigTest : public testing::Test {
30 public:
31 static void SetUpTestCase(void);
32
33 static void TearDownTestCase(void);
34
35 void SetUp();
36
37 void TearDown();
38 };
39
SetUpTestCase(void)40 void ResConfigTest::SetUpTestCase(void)
41 {
42 // step 1: input testsuit setup step
43 g_logLevel = LOG_DEBUG;
44 }
45
TearDownTestCase(void)46 void ResConfigTest::TearDownTestCase(void)
47 {
48 // step 2: input testsuit teardown step
49 }
50
SetUp()51 void ResConfigTest::SetUp()
52 {
53 }
54
TearDown()55 void ResConfigTest::TearDown()
56 {
57 }
58
59 /*
60 * @tc.name: ResConfigFuncTest001
61 * @tc.desc: Test Config function, non file case.
62 * @tc.type: FUNC
63 */
64 HWTEST_F(ResConfigTest, ResConfigFuncTest001, TestSize.Level1)
65 {
66 ResConfigImpl *rc = new ResConfigImpl;
67 rc->SetLocaleInfo("en", nullptr, "AU");
68 ResConfigImpl *current = new ResConfigImpl;
69 current->SetLocaleInfo("en", nullptr, "GB");
70 ResConfigImpl *target = new ResConfigImpl;
71 target->SetLocaleInfo("zh", nullptr, "CN");
72 EXPECT_TRUE(rc->Match(current));
73 EXPECT_TRUE(rc->Match(target) == false);
74 delete target;
75 delete current;
76 delete rc;
77 };