diff --git a/aafwk_lite/ability_posix/BUILD.gn b/aafwk_lite/ability_posix/BUILD.gn
index 6b6ed2632652de9e2ffaedb0a0bf4bcd78fca13e..9f0d1c4e795db5d579463e32066aaac7e0e18d36 100755
--- a/aafwk_lite/ability_posix/BUILD.gn
+++ b/aafwk_lite/ability_posix/BUILD.gn
@@ -51,12 +51,9 @@ hcpptest_suite("ActsAbilityMgrTest") {
"${appexecfwk_lite_path}/interfaces/innerkits/bundlemgr_lite/",
"//foundation/distributedschedule/samgr_lite/interfaces/kits/registry",
"//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr",
- "//kernel/liteos_a/kernel/include",
- "//kernel/liteos_a/kernel/common",
"//third_party/bounds_checking_function/include",
"//third_party/cJSON",
"//utils/native/lite/include",
- "//kernel/liteos_a/lib/libsec/include",
"${appexecfwk_lite_path}/interfaces/innerkits/bundlemgr_lite",
"//foundation/graphic/ui/interfaces/kits",
"//foundation/graphic/utils/interfaces/innerkits",
diff --git a/appexecfwk_lite/appexecfwk_posix/BUILD.gn b/appexecfwk_lite/appexecfwk_posix/BUILD.gn
index e7647c3c15e0e22694a7ccd4152753d04865f532..5066813bc7fd457882b0f61dbd7037e4ddc384ce 100755
--- a/appexecfwk_lite/appexecfwk_posix/BUILD.gn
+++ b/appexecfwk_lite/appexecfwk_posix/BUILD.gn
@@ -31,8 +31,6 @@ hcpptest_suite("ActsBundleMgrTest") {
"//third_party/googletest/googletest/include",
"//utils/native/lite/include",
"${aafwk_lite_path}/interfaces/innerkits/intent_lite",
- "//kernel/liteos_a/kernel/include",
- "//kernel/liteos_a/kernel/common",
"//third_party/cJSON",
]
deps = [
diff --git a/communication_lite/softbus_posix/BUILD.gn b/communication_lite/softbus_posix/BUILD.gn
index a47d12cda5179e84389881f65c60122e07da1e54..1c546b032d62b4c2eb93613ef89575a750df8b68 100755
--- a/communication_lite/softbus_posix/BUILD.gn
+++ b/communication_lite/softbus_posix/BUILD.gn
@@ -31,7 +31,6 @@ hcpptest_suite("ActsSoftBusTest") {
"//third_party/cJSON",
"//third_party/mbedtls/include",
"//third_party/bounds_checking_function/include",
- "//kernel/liteos_a/lib/libsec/include",
"//base/startup/syspara_lite/interfaces/kits/include",
"//base/security/deviceauth/interfaces/innerkits/deviceauth_lite",
"//base/security/deviceauth/frameworks/deviceauth_lite/source/huks_adapter/",
diff --git a/demo/hjsunit/Assertion/README_zh.md b/demo/hjsunit/Assertion/README_zh.md
new file mode 100755
index 0000000000000000000000000000000000000000..e4bedae2772d019d51aa2992b81174927e31f275
--- /dev/null
+++ b/demo/hjsunit/Assertion/README_zh.md
@@ -0,0 +1,3 @@
+# Assertion
+
+- Assertion,HJSUnit测试框架提供的断言能力,通过expect(XXX).assertXX的断言方式检查结果。
\ No newline at end of file
diff --git a/demo/hjsunit/Assertion/entry/src/main/js/default/app.js b/demo/hjsunit/Assertion/entry/src/main/js/default/app.js
new file mode 100755
index 0000000000000000000000000000000000000000..4b241cccbaa71f0c5cbd9e7dc437a0feb224c7d5
--- /dev/null
+++ b/demo/hjsunit/Assertion/entry/src/main/js/default/app.js
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+export default {
+ onCreate() {
+ console.info('AceApplication onCreate');
+ },
+ onDestroy() {
+ console.info('AceApplication onDestroy');
+ }
+};
diff --git a/demo/hjsunit/Assertion/entry/src/main/js/default/pages/index/index.css b/demo/hjsunit/Assertion/entry/src/main/js/default/pages/index/index.css
new file mode 100755
index 0000000000000000000000000000000000000000..2b1965821483f4f8c8b97c86ef07fe87ea767d01
--- /dev/null
+++ b/demo/hjsunit/Assertion/entry/src/main/js/default/pages/index/index.css
@@ -0,0 +1,44 @@
+.container {
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
+}
+
+.title {
+ font-size: 40px;
+ color: #000000;
+ opacity: 0.9;
+}
+
+@media screen and (device-type: tablet) and (orientation: landscape) {
+ .title {
+ font-size: 100px;
+ }
+}
+
+@media screen and (device-type: wearable) {
+ .title {
+ font-size: 28px;
+ color: #FFFFFF;
+ }
+}
+
+@media screen and (device-type: tv) {
+ .container {
+ background-image: url("../../common/images/Wallpaper.png");
+ background-size: cover;
+ background-repeat: no-repeat;
+ background-position: center;
+ }
+
+ .title {
+ font-size: 100px;
+ color: #FFFFFF;
+ }
+}
+
+@media screen and (device-type: phone) and (orientation: landscape) {
+ .title {
+ font-size: 60px;
+ }
+}
diff --git a/demo/hjsunit/Assertion/entry/src/main/js/default/pages/index/index.hml b/demo/hjsunit/Assertion/entry/src/main/js/default/pages/index/index.hml
new file mode 100755
index 0000000000000000000000000000000000000000..f64b040a5ae394dbaa5e185e1ecd4f4556b92184
--- /dev/null
+++ b/demo/hjsunit/Assertion/entry/src/main/js/default/pages/index/index.hml
@@ -0,0 +1,5 @@
+
+
+ {{ $t('strings.hello') }} {{ title }}
+
+
diff --git a/demo/hjsunit/Assertion/entry/src/main/js/default/pages/index/index.js b/demo/hjsunit/Assertion/entry/src/main/js/default/pages/index/index.js
new file mode 100755
index 0000000000000000000000000000000000000000..49eb46a053db5a2da9542526b61eed164fa44d26
--- /dev/null
+++ b/demo/hjsunit/Assertion/entry/src/main/js/default/pages/index/index.js
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+export default {
+ data: {
+ title: ""
+ },
+ onInit() {
+ this.title = this.$t('strings.world');
+ }
+}
diff --git a/demo/hjsunit/Assertion/entry/src/ohosTest/js/default/app.js b/demo/hjsunit/Assertion/entry/src/ohosTest/js/default/app.js
new file mode 100755
index 0000000000000000000000000000000000000000..044bffa75e29d7a5fe32644e19cc1bbbc5e9a7b1
--- /dev/null
+++ b/demo/hjsunit/Assertion/entry/src/ohosTest/js/default/app.js
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+export default {
+ onCreate() {
+ console.info('TestApplication onCreate');
+ },
+ onDestroy() {
+ console.info('TestApplication onDestroy');
+ }
+};
diff --git a/demo/hjsunit/Assertion/entry/src/ohosTest/js/default/pages/index/index.css b/demo/hjsunit/Assertion/entry/src/ohosTest/js/default/pages/index/index.css
new file mode 100755
index 0000000000000000000000000000000000000000..6fda792753f2e15f22b529c7b90a82185b2770bf
--- /dev/null
+++ b/demo/hjsunit/Assertion/entry/src/ohosTest/js/default/pages/index/index.css
@@ -0,0 +1,9 @@
+.container {
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
+}
+
+.title {
+ font-size: 100px;
+}
diff --git a/demo/hjsunit/Assertion/entry/src/ohosTest/js/default/pages/index/index.hml b/demo/hjsunit/Assertion/entry/src/ohosTest/js/default/pages/index/index.hml
new file mode 100755
index 0000000000000000000000000000000000000000..f64b040a5ae394dbaa5e185e1ecd4f4556b92184
--- /dev/null
+++ b/demo/hjsunit/Assertion/entry/src/ohosTest/js/default/pages/index/index.hml
@@ -0,0 +1,5 @@
+
+
+ {{ $t('strings.hello') }} {{ title }}
+
+
diff --git a/demo/hjsunit/Assertion/entry/src/ohosTest/js/default/pages/index/index.js b/demo/hjsunit/Assertion/entry/src/ohosTest/js/default/pages/index/index.js
new file mode 100755
index 0000000000000000000000000000000000000000..793667c97f947fdfc22f424847e85718bad72c49
--- /dev/null
+++ b/demo/hjsunit/Assertion/entry/src/ohosTest/js/default/pages/index/index.js
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import file from '@system.file'
+import app from '@system.app'
+import device from '@system.device'
+import router from '@system.router'
+import {Core, Constant, ExpectExtend, ReportExtend, InstrumentLog} from 'deccjsunit/index'
+
+export default {
+ data: {
+ title: ""
+ },
+ onInit() {
+ this.title = this.$t('strings.world');
+ },
+ onShow() {
+ console.info('onShow finish')
+ const core = Core.getInstance()
+ const expectExtend = new ExpectExtend({
+ 'id': 'extend'
+ })
+ const reportExtend = new ReportExtend(file)
+ const instrumentLog = new InstrumentLog({
+ 'id': 'report',
+ 'version': '1.0.3'
+ })
+ core.addService('expect', expectExtend)
+ core.addService('report', reportExtend)
+ core.addService('report', instrumentLog)
+ core.init()
+ core.subscribeEvent('spec', instrumentLog)
+ core.subscribeEvent('suite', instrumentLog)
+ core.subscribeEvent('task', instrumentLog)
+
+ const configService = core.getDefaultService('config')
+ configService.setConfig(this)
+
+ require('../../../test/List.test')
+ core.execute()
+ },
+ onReady() {
+ },
+}
\ No newline at end of file
diff --git a/demo/hjsunit/Assertion/entry/src/ohosTest/js/test/ExampleJsunit.test.js b/demo/hjsunit/Assertion/entry/src/ohosTest/js/test/ExampleJsunit.test.js
new file mode 100755
index 0000000000000000000000000000000000000000..bdc0912bf7939add431943ded7146f3940144f13
--- /dev/null
+++ b/demo/hjsunit/Assertion/entry/src/ohosTest/js/test/ExampleJsunit.test.js
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import app from '@system.app'
+import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
+
+describe('appInfoTest', function () {
+ it('app_info_test_001', 0, function () {
+ var info = app.getInfo()
+ expect(info.versionName).assertEqual('1.0')
+ expect(info.versionCode).assertEqual('3')
+ })
+})
\ No newline at end of file
diff --git a/demo/hjsunit/Assertion/entry/src/ohosTest/js/test/assertClose.test.js b/demo/hjsunit/Assertion/entry/src/ohosTest/js/test/assertClose.test.js
new file mode 100755
index 0000000000000000000000000000000000000000..c082d4bd454032b2ad394e3cc0b35fe82d28c579
--- /dev/null
+++ b/demo/hjsunit/Assertion/entry/src/ohosTest/js/test/assertClose.test.js
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import {describe, it, expect} from 'deccjsunit/index'
+
+describe('assertClose', function () {
+ it('assertCloseSuccess001', 0, function () {
+ let a = 100;
+ let b = 0.1
+ expect(a).assertClose(99, b)
+ })
+ it('assertCloseFail002', 0, function () {
+ let a = 100;
+ let b = 0.1
+ expect(a).assertClose(1, b)
+ })
+ it('assertCloseFail003', 0, function () {
+ let a = 100;
+ let b = 0.1
+ expect(a).assertClose(null, b)
+ })
+ it('assertCloseFail004', 0, function () {
+ expect(null).assertClose(null, 0)
+ })
+})
\ No newline at end of file
diff --git a/demo/hjsunit/Assertion/entry/src/ohosTest/js/test/assertContain.test.js b/demo/hjsunit/Assertion/entry/src/ohosTest/js/test/assertContain.test.js
new file mode 100755
index 0000000000000000000000000000000000000000..9c5713a1e9a1858b9d8f1e0ee694b583988ec641
--- /dev/null
+++ b/demo/hjsunit/Assertion/entry/src/ohosTest/js/test/assertContain.test.js
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import {describe, it, expect} from 'deccjsunit/index'
+
+describe('assertContain', function () {
+ it('assertContainSuccessOnString', 0, function () {
+ let a = 'abc';
+ let b = 'b'
+ expect(a).assertContain(b)
+ })
+ it('assertContainSuccessOnArray', 0, function () {
+ let a = ['a', 'b', 'c'];
+ let b = 'b'
+ expect(a).assertContain(b)
+ })
+ it('assertContainFailOnString', 0, function () {
+ let a = 'abc';
+ let b = 'd'
+ expect(a).assertContain(b)
+ })
+ it('assertContainFailOnArray', 0, function () {
+ let a = ['a', 'b', 'c'];
+ let b = 'd'
+ expect(a).assertContain(b)
+ })
+})
\ No newline at end of file
diff --git a/demo/hjsunit/Assertion/entry/src/ohosTest/js/test/assertFail.test.js b/demo/hjsunit/Assertion/entry/src/ohosTest/js/test/assertFail.test.js
new file mode 100755
index 0000000000000000000000000000000000000000..c09318bf0cf9b960925d7ca5329237a4c57db338
--- /dev/null
+++ b/demo/hjsunit/Assertion/entry/src/ohosTest/js/test/assertFail.test.js
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import {describe, it, expect} from 'deccjsunit/index'
+
+describe('assertFail', function () {
+ it('assertFail', 0, function () {
+ let a = null
+ expect(a).assertFail()
+ })
+})
\ No newline at end of file
diff --git a/demo/hjsunit/Assertion/entry/src/ohosTest/js/test/assertFalse.test.js b/demo/hjsunit/Assertion/entry/src/ohosTest/js/test/assertFalse.test.js
new file mode 100755
index 0000000000000000000000000000000000000000..f5cb010066369d406d1510dbff106158df2cae2a
--- /dev/null
+++ b/demo/hjsunit/Assertion/entry/src/ohosTest/js/test/assertFalse.test.js
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import {describe, it, expect} from 'deccjsunit/index'
+
+describe('assertFalse', function () {
+ it('assertFalseSuccess', 0, function () {
+ let d = false
+ expect(d).assertFalse()
+ })
+ it('assertFalseFail', 0, function () {
+ let d = true
+ expect(d).assertFalse()
+ })
+})
\ No newline at end of file
diff --git a/demo/hjsunit/Assertion/entry/src/ohosTest/js/test/assertInstantceOf.test.js b/demo/hjsunit/Assertion/entry/src/ohosTest/js/test/assertInstantceOf.test.js
new file mode 100755
index 0000000000000000000000000000000000000000..8c41cbecaf2c859dd4f3e5830dab4d3c10dc3beb
--- /dev/null
+++ b/demo/hjsunit/Assertion/entry/src/ohosTest/js/test/assertInstantceOf.test.js
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import {describe, it, expect} from 'deccjsunit/index'
+
+describe('assertInstanceOf', function () {
+ it('assertInstanceOfSuccessOnNumber', 0, function () {
+ let a = 12;
+ expect(a).assertInstanceOf('Number')
+ })
+ it('assertInstanceOfFailOnNumber', 0, function () {
+ let a = "abc";
+ expect(a).assertInstanceOf('String');
+ expect(a).assertInstanceOf('Number');
+ })
+})
diff --git a/demo/hjsunit/Assertion/entry/src/ohosTest/js/test/assertLarger.test.js b/demo/hjsunit/Assertion/entry/src/ohosTest/js/test/assertLarger.test.js
new file mode 100755
index 0000000000000000000000000000000000000000..48de09018de0968fd39b7b2402042afc95fb3d63
--- /dev/null
+++ b/demo/hjsunit/Assertion/entry/src/ohosTest/js/test/assertLarger.test.js
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import {describe, it, expect} from 'deccjsunit/index'
+
+describe('assertLarger', function () {
+ it('assertLargerSuccess', 0, function () {
+ let a = 12;
+ let b = 10;
+ expect(a).assertLarger(b)
+ })
+ it('assertLargerFail', 0, function () {
+ let a = 12;
+ let b = 13;
+ expect(a).assertLarger(b);
+ })
+})
\ No newline at end of file
diff --git a/demo/hjsunit/Assertion/entry/src/ohosTest/js/test/assertLess.test.js b/demo/hjsunit/Assertion/entry/src/ohosTest/js/test/assertLess.test.js
new file mode 100755
index 0000000000000000000000000000000000000000..5e404524cdc6b69d65a22a1884542757f4901ed8
--- /dev/null
+++ b/demo/hjsunit/Assertion/entry/src/ohosTest/js/test/assertLess.test.js
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import {describe, it, expect} from 'deccjsunit/index'
+
+describe('assertLess', function () {
+ it('assertLessSuccess', 0, function () {
+ let a = 12;
+ let b = 15;
+ expect(a).assertLess(b)
+ })
+ it('assertLessFail', 0, function () {
+ let a = 12;
+ let b = 10;
+ expect(a).assertLess(b);
+ })
+})
\ No newline at end of file
diff --git a/demo/hjsunit/Assertion/entry/src/ohosTest/js/test/assertNull.test.js b/demo/hjsunit/Assertion/entry/src/ohosTest/js/test/assertNull.test.js
new file mode 100755
index 0000000000000000000000000000000000000000..0e774c6edbfe8a8c763bfbc2d6e9fa0f98f31ba7
--- /dev/null
+++ b/demo/hjsunit/Assertion/entry/src/ohosTest/js/test/assertNull.test.js
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import {describe, it, expect} from 'deccjsunit/index'
+
+describe('assertNull', function () {
+ it('assertNullSuccess', 0, function () {
+ let d
+ expect(d).assertNull()
+ })
+ it('assertNullFail', 0, function () {
+ let d = 100
+ expect(d).assertNull()
+ })
+})
\ No newline at end of file
diff --git a/demo/hjsunit/Assertion/entry/src/ohosTest/js/test/assertThrowError.test.js b/demo/hjsunit/Assertion/entry/src/ohosTest/js/test/assertThrowError.test.js
new file mode 100755
index 0000000000000000000000000000000000000000..7aba149a470d80a8d340d8fc9f857008eff0bb4e
--- /dev/null
+++ b/demo/hjsunit/Assertion/entry/src/ohosTest/js/test/assertThrowError.test.js
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import {describe, it, expect} from 'deccjsunit/index'
+
+describe('assertThrowError', function () {
+ it('assertThrowErrorFail001', 0, function () {
+ let a = 12;
+ expect(a).assertThrowError()
+ })
+ it('assertThrowErrorSuccess', 0, function () {
+ let a = test
+ function test() {
+ throw Error("exception")
+ }
+ expect(a).assertThrowError("exception");
+ })
+ it('assertThrowErrorFail002', 0, function () {
+ let a = test
+ function test() {
+ throw Error("exception")
+ }
+ expect(a).assertThrowError("test");
+ })
+})
\ No newline at end of file
diff --git a/demo/hjsunit/Assertion/entry/src/ohosTest/js/test/assertUndefined.test.js b/demo/hjsunit/Assertion/entry/src/ohosTest/js/test/assertUndefined.test.js
new file mode 100755
index 0000000000000000000000000000000000000000..3c00a513c85eff8e8af56a366e1c2a8f86fa15c5
--- /dev/null
+++ b/demo/hjsunit/Assertion/entry/src/ohosTest/js/test/assertUndefined.test.js
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import {describe, it, expect} from 'deccjsunit/index'
+
+describe('assertUndefined', function () {
+ it('assertUndefinedSuccess', 0, function () {
+ let a = undefined
+ expect(a).assertUndefined()
+ })
+ it('assertUndefinedFail', 0, function () {
+ let a = 100
+ expect(a).assertUndefined()
+ })
+})
\ No newline at end of file
diff --git a/demo/hjsunit/Async/README_zh.md b/demo/hjsunit/Async/README_zh.md
new file mode 100755
index 0000000000000000000000000000000000000000..0bec3ed89f86af8a999afa357e3cc221971a064a
--- /dev/null
+++ b/demo/hjsunit/Async/README_zh.md
@@ -0,0 +1,3 @@
+# Async
+
+- 异步,HJSUnit测试框架针对测试用例提供的异步能力。测试框架识别异步用例的关键字为async,用法如下:在回调函数function前加“async”关键字,调用异步接口时需加上“await”前缀;回调函数中添加“done”参数和用例结尾的加上“done()”,保证可以在执行该异步用例时强制获取到用例执行结果。
\ No newline at end of file
diff --git a/demo/hjsunit/Async/entry/src/main/js/default/app.js b/demo/hjsunit/Async/entry/src/main/js/default/app.js
new file mode 100755
index 0000000000000000000000000000000000000000..4b241cccbaa71f0c5cbd9e7dc437a0feb224c7d5
--- /dev/null
+++ b/demo/hjsunit/Async/entry/src/main/js/default/app.js
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+export default {
+ onCreate() {
+ console.info('AceApplication onCreate');
+ },
+ onDestroy() {
+ console.info('AceApplication onDestroy');
+ }
+};
diff --git a/demo/hjsunit/Async/entry/src/main/js/default/pages/index/index.css b/demo/hjsunit/Async/entry/src/main/js/default/pages/index/index.css
new file mode 100755
index 0000000000000000000000000000000000000000..2b1965821483f4f8c8b97c86ef07fe87ea767d01
--- /dev/null
+++ b/demo/hjsunit/Async/entry/src/main/js/default/pages/index/index.css
@@ -0,0 +1,44 @@
+.container {
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
+}
+
+.title {
+ font-size: 40px;
+ color: #000000;
+ opacity: 0.9;
+}
+
+@media screen and (device-type: tablet) and (orientation: landscape) {
+ .title {
+ font-size: 100px;
+ }
+}
+
+@media screen and (device-type: wearable) {
+ .title {
+ font-size: 28px;
+ color: #FFFFFF;
+ }
+}
+
+@media screen and (device-type: tv) {
+ .container {
+ background-image: url("../../common/images/Wallpaper.png");
+ background-size: cover;
+ background-repeat: no-repeat;
+ background-position: center;
+ }
+
+ .title {
+ font-size: 100px;
+ color: #FFFFFF;
+ }
+}
+
+@media screen and (device-type: phone) and (orientation: landscape) {
+ .title {
+ font-size: 60px;
+ }
+}
diff --git a/demo/hjsunit/Async/entry/src/main/js/default/pages/index/index.hml b/demo/hjsunit/Async/entry/src/main/js/default/pages/index/index.hml
new file mode 100755
index 0000000000000000000000000000000000000000..f64b040a5ae394dbaa5e185e1ecd4f4556b92184
--- /dev/null
+++ b/demo/hjsunit/Async/entry/src/main/js/default/pages/index/index.hml
@@ -0,0 +1,5 @@
+
+
+ {{ $t('strings.hello') }} {{ title }}
+
+
diff --git a/demo/hjsunit/Async/entry/src/main/js/default/pages/index/index.js b/demo/hjsunit/Async/entry/src/main/js/default/pages/index/index.js
new file mode 100755
index 0000000000000000000000000000000000000000..49eb46a053db5a2da9542526b61eed164fa44d26
--- /dev/null
+++ b/demo/hjsunit/Async/entry/src/main/js/default/pages/index/index.js
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+export default {
+ data: {
+ title: ""
+ },
+ onInit() {
+ this.title = this.$t('strings.world');
+ }
+}
diff --git a/demo/hjsunit/Async/entry/src/ohosTest/js/default/app.js b/demo/hjsunit/Async/entry/src/ohosTest/js/default/app.js
new file mode 100755
index 0000000000000000000000000000000000000000..044bffa75e29d7a5fe32644e19cc1bbbc5e9a7b1
--- /dev/null
+++ b/demo/hjsunit/Async/entry/src/ohosTest/js/default/app.js
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+export default {
+ onCreate() {
+ console.info('TestApplication onCreate');
+ },
+ onDestroy() {
+ console.info('TestApplication onDestroy');
+ }
+};
diff --git a/demo/hjsunit/Async/entry/src/ohosTest/js/default/pages/index/index.css b/demo/hjsunit/Async/entry/src/ohosTest/js/default/pages/index/index.css
new file mode 100755
index 0000000000000000000000000000000000000000..6fda792753f2e15f22b529c7b90a82185b2770bf
--- /dev/null
+++ b/demo/hjsunit/Async/entry/src/ohosTest/js/default/pages/index/index.css
@@ -0,0 +1,9 @@
+.container {
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
+}
+
+.title {
+ font-size: 100px;
+}
diff --git a/demo/hjsunit/Async/entry/src/ohosTest/js/default/pages/index/index.hml b/demo/hjsunit/Async/entry/src/ohosTest/js/default/pages/index/index.hml
new file mode 100755
index 0000000000000000000000000000000000000000..f64b040a5ae394dbaa5e185e1ecd4f4556b92184
--- /dev/null
+++ b/demo/hjsunit/Async/entry/src/ohosTest/js/default/pages/index/index.hml
@@ -0,0 +1,5 @@
+
+
+ {{ $t('strings.hello') }} {{ title }}
+
+
diff --git a/demo/hjsunit/Async/entry/src/ohosTest/js/default/pages/index/index.js b/demo/hjsunit/Async/entry/src/ohosTest/js/default/pages/index/index.js
new file mode 100755
index 0000000000000000000000000000000000000000..793667c97f947fdfc22f424847e85718bad72c49
--- /dev/null
+++ b/demo/hjsunit/Async/entry/src/ohosTest/js/default/pages/index/index.js
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import file from '@system.file'
+import app from '@system.app'
+import device from '@system.device'
+import router from '@system.router'
+import {Core, Constant, ExpectExtend, ReportExtend, InstrumentLog} from 'deccjsunit/index'
+
+export default {
+ data: {
+ title: ""
+ },
+ onInit() {
+ this.title = this.$t('strings.world');
+ },
+ onShow() {
+ console.info('onShow finish')
+ const core = Core.getInstance()
+ const expectExtend = new ExpectExtend({
+ 'id': 'extend'
+ })
+ const reportExtend = new ReportExtend(file)
+ const instrumentLog = new InstrumentLog({
+ 'id': 'report',
+ 'version': '1.0.3'
+ })
+ core.addService('expect', expectExtend)
+ core.addService('report', reportExtend)
+ core.addService('report', instrumentLog)
+ core.init()
+ core.subscribeEvent('spec', instrumentLog)
+ core.subscribeEvent('suite', instrumentLog)
+ core.subscribeEvent('task', instrumentLog)
+
+ const configService = core.getDefaultService('config')
+ configService.setConfig(this)
+
+ require('../../../test/List.test')
+ core.execute()
+ },
+ onReady() {
+ },
+}
\ No newline at end of file
diff --git a/demo/hjsunit/Async/entry/src/ohosTest/js/test/Callback.test.js b/demo/hjsunit/Async/entry/src/ohosTest/js/test/Callback.test.js
new file mode 100755
index 0000000000000000000000000000000000000000..6b95d985aa91a130b816932fb55ea7fbe8c9beed
--- /dev/null
+++ b/demo/hjsunit/Async/entry/src/ohosTest/js/test/Callback.test.js
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import {describe, it} from 'deccjsunit/index'
+
+describe('callback', function () {
+ it('callbackDemo', 0, async function (done) {
+ await a()
+ })
+})
+
+function a(done){
+ setTimeout(function(){
+ console.log("run a after 1000ms")
+ },1000)
+ done()
+}
\ No newline at end of file
diff --git a/demo/hjsunit/Async/entry/src/ohosTest/js/test/List.test.js b/demo/hjsunit/Async/entry/src/ohosTest/js/test/List.test.js
new file mode 100755
index 0000000000000000000000000000000000000000..e397df520f9e3dac80fe8bf7498c68e6379de420
--- /dev/null
+++ b/demo/hjsunit/Async/entry/src/ohosTest/js/test/List.test.js
@@ -0,0 +1,16 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+require('./Callback.test.js')
+require('./Promise.test.js')
\ No newline at end of file
diff --git a/demo/hjsunit/Async/entry/src/ohosTest/js/test/Promise.test.js b/demo/hjsunit/Async/entry/src/ohosTest/js/test/Promise.test.js
new file mode 100755
index 0000000000000000000000000000000000000000..785f3e87792b1fc7e40c90a41f3c90b4bbeb0739
--- /dev/null
+++ b/demo/hjsunit/Async/entry/src/ohosTest/js/test/Promise.test.js
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import {describe, it} from 'deccjsunit/index'
+
+describe('promise', function () {
+ it('promiseDemo', 0, async function (done) {
+ await new Promise(
+ function (resolve, reject) {
+ // 一段耗时的异步操作
+ resolve('成功') // 数据处理完成
+ // reject('失败') // 数据处理出错
+ }).then(
+ (res) => {console.log(res)}, // 成功
+ (err) => {console.log(err)} // 失败
+ )
+ done()
+ })
+})
\ No newline at end of file
diff --git a/demo/hjsunit/DataDriver/README_zh.md b/demo/hjsunit/DataDriver/README_zh.md
new file mode 100755
index 0000000000000000000000000000000000000000..0c3247bcde664ed2978666eca0f591f0b899b821
--- /dev/null
+++ b/demo/hjsunit/DataDriver/README_zh.md
@@ -0,0 +1,3 @@
+# DataDriver
+
+- DataDriver,HJSUnit测试框架提供的数据驱动能力。通过配置data.json文件,实现针对指定测试套、测试用例的参数传递,亦或是根据指定测试套、测试用例的执行次数做压力测试。
\ No newline at end of file
diff --git a/demo/hjsunit/DataDriver/entry/src/main/js/default/app.js b/demo/hjsunit/DataDriver/entry/src/main/js/default/app.js
new file mode 100755
index 0000000000000000000000000000000000000000..4b241cccbaa71f0c5cbd9e7dc437a0feb224c7d5
--- /dev/null
+++ b/demo/hjsunit/DataDriver/entry/src/main/js/default/app.js
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+export default {
+ onCreate() {
+ console.info('AceApplication onCreate');
+ },
+ onDestroy() {
+ console.info('AceApplication onDestroy');
+ }
+};
diff --git a/demo/hjsunit/DataDriver/entry/src/main/js/default/pages/index/index.css b/demo/hjsunit/DataDriver/entry/src/main/js/default/pages/index/index.css
new file mode 100755
index 0000000000000000000000000000000000000000..2b1965821483f4f8c8b97c86ef07fe87ea767d01
--- /dev/null
+++ b/demo/hjsunit/DataDriver/entry/src/main/js/default/pages/index/index.css
@@ -0,0 +1,44 @@
+.container {
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
+}
+
+.title {
+ font-size: 40px;
+ color: #000000;
+ opacity: 0.9;
+}
+
+@media screen and (device-type: tablet) and (orientation: landscape) {
+ .title {
+ font-size: 100px;
+ }
+}
+
+@media screen and (device-type: wearable) {
+ .title {
+ font-size: 28px;
+ color: #FFFFFF;
+ }
+}
+
+@media screen and (device-type: tv) {
+ .container {
+ background-image: url("../../common/images/Wallpaper.png");
+ background-size: cover;
+ background-repeat: no-repeat;
+ background-position: center;
+ }
+
+ .title {
+ font-size: 100px;
+ color: #FFFFFF;
+ }
+}
+
+@media screen and (device-type: phone) and (orientation: landscape) {
+ .title {
+ font-size: 60px;
+ }
+}
diff --git a/demo/hjsunit/DataDriver/entry/src/main/js/default/pages/index/index.hml b/demo/hjsunit/DataDriver/entry/src/main/js/default/pages/index/index.hml
new file mode 100755
index 0000000000000000000000000000000000000000..f64b040a5ae394dbaa5e185e1ecd4f4556b92184
--- /dev/null
+++ b/demo/hjsunit/DataDriver/entry/src/main/js/default/pages/index/index.hml
@@ -0,0 +1,5 @@
+
+
+ {{ $t('strings.hello') }} {{ title }}
+
+
diff --git a/demo/hjsunit/DataDriver/entry/src/main/js/default/pages/index/index.js b/demo/hjsunit/DataDriver/entry/src/main/js/default/pages/index/index.js
new file mode 100755
index 0000000000000000000000000000000000000000..49eb46a053db5a2da9542526b61eed164fa44d26
--- /dev/null
+++ b/demo/hjsunit/DataDriver/entry/src/main/js/default/pages/index/index.js
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+export default {
+ data: {
+ title: ""
+ },
+ onInit() {
+ this.title = this.$t('strings.world');
+ }
+}
diff --git a/demo/hjsunit/DataDriver/entry/src/ohosTest/js/default/app.js b/demo/hjsunit/DataDriver/entry/src/ohosTest/js/default/app.js
new file mode 100755
index 0000000000000000000000000000000000000000..044bffa75e29d7a5fe32644e19cc1bbbc5e9a7b1
--- /dev/null
+++ b/demo/hjsunit/DataDriver/entry/src/ohosTest/js/default/app.js
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+export default {
+ onCreate() {
+ console.info('TestApplication onCreate');
+ },
+ onDestroy() {
+ console.info('TestApplication onDestroy');
+ }
+};
diff --git a/demo/hjsunit/DataDriver/entry/src/ohosTest/js/default/pages/index/index.css b/demo/hjsunit/DataDriver/entry/src/ohosTest/js/default/pages/index/index.css
new file mode 100755
index 0000000000000000000000000000000000000000..6fda792753f2e15f22b529c7b90a82185b2770bf
--- /dev/null
+++ b/demo/hjsunit/DataDriver/entry/src/ohosTest/js/default/pages/index/index.css
@@ -0,0 +1,9 @@
+.container {
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
+}
+
+.title {
+ font-size: 100px;
+}
diff --git a/demo/hjsunit/DataDriver/entry/src/ohosTest/js/default/pages/index/index.hml b/demo/hjsunit/DataDriver/entry/src/ohosTest/js/default/pages/index/index.hml
new file mode 100755
index 0000000000000000000000000000000000000000..f64b040a5ae394dbaa5e185e1ecd4f4556b92184
--- /dev/null
+++ b/demo/hjsunit/DataDriver/entry/src/ohosTest/js/default/pages/index/index.hml
@@ -0,0 +1,5 @@
+
+
+ {{ $t('strings.hello') }} {{ title }}
+
+
diff --git a/demo/hjsunit/DataDriver/entry/src/ohosTest/js/default/pages/index/index.js b/demo/hjsunit/DataDriver/entry/src/ohosTest/js/default/pages/index/index.js
new file mode 100755
index 0000000000000000000000000000000000000000..4ada57fb31e4c492c605ec5a827878a01bc0cc10
--- /dev/null
+++ b/demo/hjsunit/DataDriver/entry/src/ohosTest/js/default/pages/index/index.js
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import file from '@system.file'
+import app from '@system.app'
+import device from '@system.device'
+import router from '@system.router'
+import {Core, Constant, DataDriver, ExpectExtend, ReportExtend, InstrumentLog} from 'deccjsunit/index'
+
+import data from '../../../test/data.json'
+
+export default {
+ data: {
+ title: ""
+ },
+ onInit() {
+ this.title = this.$t('strings.world');
+ },
+ onShow() {
+ console.info('onShow finish')
+ const core = Core.getInstance()
+ const dataDriver = new DataDriver({data:data})
+ const expectExtend = new ExpectExtend({
+ 'id': 'extend'
+ })
+ const reportExtend = new ReportExtend(file)
+ const instrumentLog = new InstrumentLog({
+ 'id': 'report',
+ 'version': '1.0.3'
+ })
+ core.addService('dataDriver',dataDriver)
+ core.addService('expect', expectExtend)
+ core.addService('report', reportExtend)
+ core.addService('report', instrumentLog)
+ core.init()
+ core.subscribeEvent('spec', instrumentLog)
+ core.subscribeEvent('suite', instrumentLog)
+ core.subscribeEvent('task', instrumentLog)
+
+ const configService = core.getDefaultService('config')
+ configService.setConfig(this)
+
+ require('../../../test/List.test')
+ core.execute()
+ },
+ onReady() {
+ },
+}
\ No newline at end of file
diff --git a/demo/hjsunit/DataDriver/entry/src/ohosTest/js/test/DataDriver.test.js b/demo/hjsunit/DataDriver/entry/src/ohosTest/js/test/DataDriver.test.js
new file mode 100755
index 0000000000000000000000000000000000000000..a7c331fddc5bfc901302a63e93b7fc3ea1d4b67e
--- /dev/null
+++ b/demo/hjsunit/DataDriver/entry/src/ohosTest/js/test/DataDriver.test.js
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import {describe, it, expect} from 'deccjsunit/index'
+
+describe('testSuite01', function () {
+ it('testSpec01', function (data) {
+ console.info('testSpec01......' + JSON.stringify(data))
+ })
+ it('testSpec02', function (data) {
+ console.info('testSpec02......' + JSON.stringify(data))
+ })
+})
\ No newline at end of file
diff --git a/demo/hjsunit/DataDriver/entry/src/ohosTest/js/test/List.test.js b/demo/hjsunit/DataDriver/entry/src/ohosTest/js/test/List.test.js
new file mode 100755
index 0000000000000000000000000000000000000000..ee629d2674217d3e6f2beb14661afe07ce140ce4
--- /dev/null
+++ b/demo/hjsunit/DataDriver/entry/src/ohosTest/js/test/List.test.js
@@ -0,0 +1,15 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+require('./DataDriver.test.js')
\ No newline at end of file
diff --git a/demo/hjsunit/DataDriver/entry/src/ohosTest/js/test/data.json b/demo/hjsunit/DataDriver/entry/src/ohosTest/js/test/data.json
new file mode 100755
index 0000000000000000000000000000000000000000..ab74ea0df4d7110e83deccf744fd07bcaccbe350
--- /dev/null
+++ b/demo/hjsunit/DataDriver/entry/src/ohosTest/js/test/data.json
@@ -0,0 +1,26 @@
+{
+ "suites": [{
+ "describe":["testSuite01"],
+ "params":{
+ "suiteParam01": "suiteParam"
+ }
+ },{
+ "describe":["testSuite01","testSpec02"],
+ "params":{
+ "suiteParam": "suiteParam"
+ }
+ },{
+ "describe":"testSuite01",
+ "stress": 8,
+ "items":[{
+ "it":"testSpec01",
+ "stress": 1,
+ "params":[{
+ "name":"tom"
+ }]
+ },{
+ "it":"testSpec02",
+ "stress": 2
+ }]
+ }]
+}
\ No newline at end of file
diff --git a/demo/hjsunit/README.md b/demo/hjsunit/README.md
new file mode 100755
index 0000000000000000000000000000000000000000..0cde70f22bf5b9a2be51b524a963b16d05979f1e
--- /dev/null
+++ b/demo/hjsunit/README.md
@@ -0,0 +1,19 @@
+# App Samples
+
+- [Introduction](#section_HJSUnit_001)
+- [Usage](#section_HJSUnit_002)
+- [Limitations](#section_HJSUnit_003)
+
+## Introduction
+
+We provide a series of app samples to help you quickly get familiar with the test capabilities and how to use of the HJSUnit. Each app sample is an independent project in DevEco Studio. You can import sample code from a project to a customized project to learn how to use APIs by browsing code, building the project, and installing and running the app.
+
+## Usage
+
+1. Development tool: Devco Studio 2.2.0.200 or later
+2. Procedure: Create a blank JS template project in Devco Studio, import the sample code in the ohosTest directory of the sample project to the ohosTest directory of the user-defined project, and compile, build, run, and debug the project.
+3. After HAP installation and execution, you can view the execution effect of the sample on the device and then conduct debugging.
+
+## Limitations
+
+Before installing and running the sample, check the **deviceType** field in the **config.json** file to obtain the device types supported by the sample. You can modify this field to enable the sample to run on your target device. \(The **config.json** file is generally stored in the **entry/src/main** directory, which may be different depending on the samples.\)
\ No newline at end of file
diff --git a/demo/hjsunit/README_zh.md b/demo/hjsunit/README_zh.md
new file mode 100755
index 0000000000000000000000000000000000000000..0b1b7d7188babfd7728e4f456fc75a67e4aa44ff
--- /dev/null
+++ b/demo/hjsunit/README_zh.md
@@ -0,0 +1,19 @@
+# 应用示例
+
+- [概要简介](#section_HJSUnit_001)
+- [使用说明](#section_HJSUnit_002)
+- [约束与限制](#section_HJSUnit_003)
+
+## 概要简介
+
+为帮助测试人员快速熟悉HJSUnit所提供的测试能力和如何使用,我们提供了一系列的应用示例,即Sample。每一个应用示例都是一个独立的DevEco Studio工程项目,测试人员可以将工程中的代码导入到自定义工程中,通过浏览代码、编译工程、安装和运行应用示例来了解应用示例中涉及测试能力的使用方法。
+
+## 使用说明
+
+1. 开发工具:2.2.0.200版本及以上的Deveco Studio
+2. 使用步骤:①在Deveco Studio中新建空白JS模板项目,将示例工程ohosTest目录下的示例代码导入到自定义工程的ohosTest目录下,进行编译构建及运行调试。
+3. 安装运行后,即可在设备上查看应用示例运行效果,以及进行相关调试。
+
+## 约束与限制
+
+安装运行应用示例之前,请先通过config.json文件中的"deviceType"字段来确认该应用示例支持的设备类型,可尝试通过修改该字段使其可以在相应类型的设备上运行(config.json文件一般在代码的entry/src/main路径下,不同的Sample可能会有不同)。
\ No newline at end of file
diff --git a/distributeddatamgr/distributedfilejstest/hap/entry-debug-rich-signed.hap b/distributeddatamgr/distributedfilejstest/hap/entry-debug-rich-signed.hap
index 6b577198f7e4025425dfa6c7af34434a3956cda2..1e7e627b2611ff03c28822e681f9b715070f7a69 100644
Binary files a/distributeddatamgr/distributedfilejstest/hap/entry-debug-rich-signed.hap and b/distributeddatamgr/distributedfilejstest/hap/entry-debug-rich-signed.hap differ
diff --git a/distributeddatamgr/distributedfilejstest/project/entry/src/main/js/test/FileIO.test.js b/distributeddatamgr/distributedfilejstest/project/entry/src/main/js/test/FileIO.test.js
index 81c6cd659a51b98db09edf521143d3f270d9b58e..13212a963a385b5897729d3f409ded96805f2b22 100755
--- a/distributeddatamgr/distributedfilejstest/project/entry/src/main/js/test/FileIO.test.js
+++ b/distributeddatamgr/distributedfilejstest/project/entry/src/main/js/test/FileIO.test.js
@@ -561,7 +561,7 @@ describe('fileIOTest', function () {
try {
expect(fileio.chmodSync(fpath, 0o660)).assertNull()
- expect(fileio.Stat.statSync(fpath).mode & 0o777).assertEqual(0o660)
+ expect(fileio.statSync(fpath).mode & 0o777).assertEqual(0o660)
expect(fileio.unlinkSync(fpath)).assertNull()
} catch (e) {
console.log("fileio_test_chmod_sync_000 has failed for " + e)
@@ -661,7 +661,7 @@ describe('fileIOTest', function () {
try {
expect(fileio.truncateSync(fpath)).assertNull()
- expect(fileio.Stat.statSync(fpath).size).assertEqual(0)
+ expect(fileio.statSync(fpath).size).assertEqual(0)
expect(fileio.unlinkSync(fpath)).assertNull()
} catch (e) {
console.log("fileio_test_truncate_sync_000 has failed for " + e)
@@ -761,7 +761,7 @@ describe('fileIOTest', function () {
try {
let fd = fileio.openSync(fpath, 0o2)
expect(fileio.fchmodSync(fd, 0o660)).assertNull()
- expect(fileio.Stat.statSync(fpath).mode & 0o777).assertEqual(0o660)
+ expect(fileio.statSync(fpath).mode & 0o777).assertEqual(0o660)
expect(fileio.unlinkSync(fpath)).assertNull()
} catch (e) {
console.log("fileio_test_fchmod_sync_000 has failed for " + e)
@@ -794,7 +794,7 @@ describe('fileIOTest', function () {
try {
let fd = fileio.openSync(fpath, 0o2)
expect(fileio.ftruncateSync(fd)).assertNull()
- expect(fileio.Stat.statSync(fpath).size).assertEqual(0)
+ expect(fileio.statSync(fpath).size).assertEqual(0)
expect(fileio.unlinkSync(fpath)).assertNull()
} catch (e) {
console.log("fileio_test_ftruncate_sync_000 has failed for " + e)
diff --git a/distributeddatamgr/distributedfilejstest/project/entry/src/main/js/test/FileIODir.test.js b/distributeddatamgr/distributedfilejstest/project/entry/src/main/js/test/FileIODir.test.js
index 08b8079b6fd223a8fab7c8181b70c37d9cc98fd6..01bd141ddf068efa4532c2ccd3270dbb8ba9bbc9 100755
--- a/distributeddatamgr/distributedfilejstest/project/entry/src/main/js/test/FileIODir.test.js
+++ b/distributeddatamgr/distributedfilejstest/project/entry/src/main/js/test/FileIODir.test.js
@@ -29,7 +29,7 @@ describe('fileIOTestDir', function () {
try {
expect(fileio.mkdirSync(dpath)).assertNull()
- let dd = fileio.Dir.opendirSync(dpath)
+ let dd = fileio.opendirSync(dpath)
expect(dd !== null).assertTrue()
expect(dd.closeSync()).assertNull()
expect(fileio.rmdirSync(dpath)).assertNull()
@@ -46,7 +46,7 @@ describe('fileIOTestDir', function () {
*/
it('fileio_test_dir_open_close_sync_001', 0, function () {
try {
- fileio.Dir.opendirSync()
+ fileio.opendirSync()
expect(null).assertFail()
} catch (e) {
}
@@ -61,7 +61,7 @@ describe('fileIOTestDir', function () {
let dpath = nextFileName('fileio_test_dir_read_sync_000') + 'd'
try {
- fileio.Dir.opendirSync(dpath)
+ fileio.opendirSync(dpath)
expect(null).assertFail()
} catch (e) {
}
@@ -79,7 +79,7 @@ describe('fileIOTestDir', function () {
try {
expect(fileio.mkdirSync(dpath)).assertNull()
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue()
- let dd = fileio.Dir.opendirSync(dpath)
+ let dd = fileio.opendirSync(dpath)
expect(dd !== null).assertTrue()
expect(dd.readSync() != null).assertTrue()
expect(dd.closeSync()).assertNull()
@@ -105,7 +105,7 @@ describe('fileIOTestDir', function () {
try {
expect(fileio.mkdirSync(dpath)).assertNull()
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue()
- dd = fileio.Dir.opendirSync(dpath)
+ dd = fileio.opendirSync(dpath)
expect(dd !== null).assertTrue()
expect(dd.readSync(-1) != null).assertTrue()
expect(null).assertFail()
diff --git a/distributeddatamgr/distributedfilejstest/project/entry/src/main/js/test/FileIODirent.test.js b/distributeddatamgr/distributedfilejstest/project/entry/src/main/js/test/FileIODirent.test.js
index 349cce9e3c074241182c77aab98b2d796d8ecc8e..22b5a810a582b32b623f3e9688db736297eb8deb 100755
--- a/distributeddatamgr/distributedfilejstest/project/entry/src/main/js/test/FileIODirent.test.js
+++ b/distributeddatamgr/distributedfilejstest/project/entry/src/main/js/test/FileIODirent.test.js
@@ -31,7 +31,7 @@ describe('fileIOTestDirent', function () {
try {
expect(fileio.mkdirSync(dpath)).assertNull()
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue()
- let dd = fileio.Dir.opendirSync(dpath)
+ let dd = fileio.opendirSync(dpath)
expect(dd !== null).assertTrue()
let dirent = dd.readSync()
expect(dirent !== null).assertTrue()
@@ -57,7 +57,7 @@ describe('fileIOTestDirent', function () {
try {
expect(fileio.mkdirSync(dpath)).assertNull()
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue()
- let dd = fileio.Dir.opendirSync(dpath)
+ let dd = fileio.opendirSync(dpath)
expect(dd !== null).assertTrue()
let dirent = dd.readSync()
expect(dirent !== null).assertTrue()
@@ -84,7 +84,7 @@ describe('fileIOTestDirent', function () {
try {
expect(fileio.mkdirSync(dpath)).assertNull()
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue()
- dd = fileio.Dir.opendirSync(dpath)
+ dd = fileio.opendirSync(dpath)
expect(dd !== null).assertTrue()
let dirent = dd.readSync()
expect(dirent !== null).assertTrue()
@@ -109,7 +109,7 @@ describe('fileIOTestDirent', function () {
try {
expect(fileio.mkdirSync(dpath)).assertNull()
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue()
- let dd = fileio.Dir.opendirSync(dpath)
+ let dd = fileio.opendirSync(dpath)
expect(dd !== null).assertTrue()
let dirent = dd.readSync()
expect(dirent !== null).assertTrue()
@@ -136,7 +136,7 @@ describe('fileIOTestDirent', function () {
try {
expect(fileio.mkdirSync(dpath)).assertNull()
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue()
- dd = fileio.Dir.opendirSync(dpath)
+ dd = fileio.opendirSync(dpath)
expect(dd !== null).assertTrue()
let dirent = dd.readSync()
expect(dirent !== null).assertTrue()
@@ -161,7 +161,7 @@ describe('fileIOTestDirent', function () {
try {
expect(fileio.mkdirSync(dpath)).assertNull()
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue()
- let dd = fileio.Dir.opendirSync(dpath)
+ let dd = fileio.opendirSync(dpath)
expect(dd !== null).assertTrue()
let dirent = dd.readSync()
expect(dirent !== null).assertTrue()
@@ -188,7 +188,7 @@ describe('fileIOTestDirent', function () {
try {
expect(fileio.mkdirSync(dpath)).assertNull()
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue()
- dd = fileio.Dir.opendirSync(dpath)
+ dd = fileio.opendirSync(dpath)
expect(dd !== null).assertTrue()
let dirent = dd.readSync()
expect(dirent !== null).assertTrue()
@@ -213,7 +213,7 @@ describe('fileIOTestDirent', function () {
try {
expect(fileio.mkdirSync(dpath)).assertNull()
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue()
- let dd = fileio.Dir.opendirSync(dpath)
+ let dd = fileio.opendirSync(dpath)
expect(dd !== null).assertTrue()
let dirent = dd.readSync()
expect(dirent !== null).assertTrue()
@@ -240,7 +240,7 @@ describe('fileIOTestDirent', function () {
try {
expect(fileio.mkdirSync(dpath)).assertNull()
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue()
- dd = fileio.Dir.opendirSync(dpath)
+ dd = fileio.opendirSync(dpath)
expect(dd !== null).assertTrue()
let dirent = dd.readSync()
expect(dirent !== null).assertTrue()
@@ -265,7 +265,7 @@ describe('fileIOTestDirent', function () {
try {
expect(fileio.mkdirSync(dpath)).assertNull()
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue()
- let dd = fileio.Dir.opendirSync(dpath)
+ let dd = fileio.opendirSync(dpath)
expect(dd !== null).assertTrue()
let dirent = dd.readSync()
expect(dirent !== null).assertTrue()
@@ -292,7 +292,7 @@ describe('fileIOTestDirent', function () {
try {
expect(fileio.mkdirSync(dpath)).assertNull()
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue()
- dd = fileio.Dir.opendirSync(dpath)
+ dd = fileio.opendirSync(dpath)
expect(dd !== null).assertTrue()
let dirent = dd.readSync()
expect(dirent !== null).assertTrue()
@@ -317,7 +317,7 @@ describe('fileIOTestDirent', function () {
try {
expect(fileio.mkdirSync(dpath)).assertNull()
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue()
- let dd = fileio.Dir.opendirSync(dpath)
+ let dd = fileio.opendirSync(dpath)
expect(dd !== null).assertTrue()
let dirent = dd.readSync()
expect(dirent !== null).assertTrue()
@@ -344,7 +344,7 @@ describe('fileIOTestDirent', function () {
try {
expect(fileio.mkdirSync(dpath)).assertNull()
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue()
- dd = fileio.Dir.opendirSync(dpath)
+ dd = fileio.opendirSync(dpath)
expect(dd !== null).assertTrue()
let dirent = dd.readSync()
expect(dirent !== null).assertTrue()
@@ -369,7 +369,7 @@ describe('fileIOTestDirent', function () {
try {
expect(fileio.mkdirSync(dpath)).assertNull()
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue()
- let dd = fileio.Dir.opendirSync(dpath)
+ let dd = fileio.opendirSync(dpath)
expect(dd !== null).assertTrue()
let dirent = dd.readSync()
expect(dirent !== null).assertTrue()
@@ -396,7 +396,7 @@ describe('fileIOTestDirent', function () {
try {
expect(fileio.mkdirSync(dpath)).assertNull()
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue()
- dd = fileio.Dir.opendirSync(dpath)
+ dd = fileio.opendirSync(dpath)
expect(dd !== null).assertTrue()
let dirent = dd.readSync()
expect(dirent !== null).assertTrue()
diff --git a/distributeddatamgr/distributedfilejstest/project/entry/src/main/js/test/FileIOStat.test.js b/distributeddatamgr/distributedfilejstest/project/entry/src/main/js/test/FileIOStat.test.js
index 4dd67607d2e89ebacf9de96369e8c2528fb24c52..a4331db908369f9de8526c4c13218b9d6ec83cfd 100755
--- a/distributeddatamgr/distributedfilejstest/project/entry/src/main/js/test/FileIOStat.test.js
+++ b/distributeddatamgr/distributedfilejstest/project/entry/src/main/js/test/FileIOStat.test.js
@@ -65,7 +65,7 @@ describe('fileIOTestStat', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue()
try {
- let stat = fileio.Stat.statSync(fpath)
+ let stat = fileio.statSync(fpath)
expect(stat !== null).assertTrue()
expect(fileio.unlinkSync(fpath)).assertNull()
} catch (e) {
@@ -83,7 +83,7 @@ describe('fileIOTestStat', function () {
let fpath = nextFileName('fileio_test_stat_stat_sync_001')
try {
- let stat = fileio.Stat.statSync(fpath)
+ let stat = fileio.statSync(fpath)
expect(null).assertFail()
} catch (e) {
}
@@ -99,7 +99,7 @@ describe('fileIOTestStat', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue()
try {
- let stat = fileio.Stat.statSync(fpath)
+ let stat = fileio.statSync(fpath)
expect(stat.dev).assertInstanceOf('Number')
expect(fileio.unlinkSync(fpath)).assertNull()
} catch (e) {
@@ -118,7 +118,7 @@ describe('fileIOTestStat', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue()
try {
- let stat = fileio.Stat.statSync(fpath)
+ let stat = fileio.statSync(fpath)
expect(stat.ino).assertInstanceOf('Number')
expect(fileio.unlinkSync(fpath)).assertNull()
} catch (e) {
@@ -137,7 +137,7 @@ describe('fileIOTestStat', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue()
try {
- let stat = fileio.Stat.statSync(fpath)
+ let stat = fileio.statSync(fpath)
expect(stat.mode).assertInstanceOf('Number')
expect(fileio.unlinkSync(fpath)).assertNull()
} catch (e) {
@@ -156,7 +156,7 @@ describe('fileIOTestStat', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue()
try {
- let stat = fileio.Stat.statSync(fpath)
+ let stat = fileio.statSync(fpath)
expect(stat.nlink).assertInstanceOf('Number')
expect(fileio.unlinkSync(fpath)).assertNull()
} catch (e) {
@@ -175,7 +175,7 @@ describe('fileIOTestStat', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue()
try {
- let stat = fileio.Stat.statSync(fpath)
+ let stat = fileio.statSync(fpath)
expect(stat.uid).assertInstanceOf('Number')
expect(fileio.unlinkSync(fpath)).assertNull()
} catch (e) {
@@ -194,7 +194,7 @@ describe('fileIOTestStat', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue()
try {
- let stat = fileio.Stat.statSync(fpath)
+ let stat = fileio.statSync(fpath)
expect(stat.gid).assertInstanceOf('Number')
expect(fileio.unlinkSync(fpath)).assertNull()
} catch (e) {
@@ -213,7 +213,7 @@ describe('fileIOTestStat', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue()
try {
- let stat = fileio.Stat.statSync(fpath)
+ let stat = fileio.statSync(fpath)
expect(stat.rdev).assertInstanceOf('Number')
expect(fileio.unlinkSync(fpath)).assertNull()
} catch (e) {
@@ -232,7 +232,7 @@ describe('fileIOTestStat', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue()
try {
- let stat = fileio.Stat.statSync(fpath)
+ let stat = fileio.statSync(fpath)
expect(stat.size).assertInstanceOf('Number')
expect(fileio.unlinkSync(fpath)).assertNull()
} catch (e) {
@@ -251,7 +251,7 @@ describe('fileIOTestStat', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue()
try {
- let stat = fileio.Stat.statSync(fpath)
+ let stat = fileio.statSync(fpath)
expect(stat.blocks).assertInstanceOf('Number')
expect(fileio.unlinkSync(fpath)).assertNull()
} catch (e) {
@@ -270,7 +270,7 @@ describe('fileIOTestStat', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue()
try {
- let stat = fileio.Stat.statSync(fpath)
+ let stat = fileio.statSync(fpath)
expect(stat.atime).assertInstanceOf('Number')
expect(fileio.unlinkSync(fpath)).assertNull()
} catch (e) {
@@ -289,7 +289,7 @@ describe('fileIOTestStat', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue()
try {
- let stat = fileio.Stat.statSync(fpath)
+ let stat = fileio.statSync(fpath)
expect(stat.mtime).assertInstanceOf('Number')
expect(fileio.unlinkSync(fpath)).assertNull()
} catch (e) {
@@ -308,7 +308,7 @@ describe('fileIOTestStat', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue()
try {
- let stat = fileio.Stat.statSync(fpath)
+ let stat = fileio.statSync(fpath)
expect(stat.ctime).assertInstanceOf('Number')
expect(fileio.unlinkSync(fpath)).assertNull()
} catch (e) {
@@ -327,7 +327,7 @@ describe('fileIOTestStat', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue()
try {
- let stat = fileio.Stat.statSync(fpath)
+ let stat = fileio.statSync(fpath)
expect(stat.isBlockDevice()).assertInstanceOf('Boolean')
expect(fileio.unlinkSync(fpath)).assertNull()
} catch (e) {
@@ -346,7 +346,7 @@ describe('fileIOTestStat', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue()
try {
- let stat = fileio.Stat.statSync(fpath)
+ let stat = fileio.statSync(fpath)
expect(stat.isBlockDevice()).assertFalse()
expect(fileio.unlinkSync(fpath)).assertNull()
} catch (e) {
@@ -365,7 +365,7 @@ describe('fileIOTestStat', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue()
try {
- let stat = fileio.Stat.statSync(fpath)
+ let stat = fileio.statSync(fpath)
expect(stat.isBlockDevice(-1)).assertFalse()
expect(null).assertFail()
} catch (e) {
@@ -383,7 +383,7 @@ describe('fileIOTestStat', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue()
try {
- let stat = fileio.Stat.statSync(fpath)
+ let stat = fileio.statSync(fpath)
expect(stat.isCharacterDevice()).assertInstanceOf('Boolean')
expect(fileio.unlinkSync(fpath)).assertNull()
} catch (e) {
@@ -402,7 +402,7 @@ describe('fileIOTestStat', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue()
try {
- let stat = fileio.Stat.statSync(fpath)
+ let stat = fileio.statSync(fpath)
expect(stat.isCharacterDevice()).assertFalse()
expect(fileio.unlinkSync(fpath)).assertNull()
} catch (e) {
@@ -421,7 +421,7 @@ describe('fileIOTestStat', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue()
try {
- let stat = fileio.Stat.statSync(fpath)
+ let stat = fileio.statSync(fpath)
expect(stat.isCharacterDevice(-1)).assertFalse()
expect(null).assertFail()
} catch (e) {
@@ -439,7 +439,7 @@ describe('fileIOTestStat', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue()
try {
- let stat = fileio.Stat.statSync(fpath)
+ let stat = fileio.statSync(fpath)
expect(stat.isDirectory()).assertInstanceOf('Boolean')
expect(fileio.unlinkSync(fpath)).assertNull()
} catch (e) {
@@ -458,7 +458,7 @@ describe('fileIOTestStat', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue()
try {
- let stat = fileio.Stat.statSync(fpath)
+ let stat = fileio.statSync(fpath)
expect(stat.isDirectory()).assertFalse()
expect(fileio.unlinkSync(fpath)).assertNull()
} catch (e) {
@@ -477,7 +477,7 @@ describe('fileIOTestStat', function () {
try {
expect(fileio.mkdirSync(dpath)).assertNull()
- let stat = fileio.Stat.statSync(dpath)
+ let stat = fileio.statSync(dpath)
expect(stat.isDirectory()).assertTrue()
expect(fileio.rmdirSync(dpath)).assertNull()
} catch (e) {
@@ -496,7 +496,7 @@ describe('fileIOTestStat', function () {
try {
expect(fileio.mkdirSync(dpath)).assertNull()
- let stat = fileio.Stat.statSync(dpath)
+ let stat = fileio.statSync(dpath)
expect(stat.isDirectory(-1)).assertTrue()
expect(null).assertFail()
} catch (e) {
@@ -514,7 +514,7 @@ describe('fileIOTestStat', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue()
try {
- let stat = fileio.Stat.statSync(fpath)
+ let stat = fileio.statSync(fpath)
expect(stat.isFIFO()).assertInstanceOf('Boolean')
expect(fileio.unlinkSync(fpath)).assertNull()
} catch (e) {
@@ -533,7 +533,7 @@ describe('fileIOTestStat', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue()
try {
- let stat = fileio.Stat.statSync(fpath)
+ let stat = fileio.statSync(fpath)
expect(stat.isFIFO()).assertFalse()
expect(fileio.unlinkSync(fpath)).assertNull()
} catch (e) {
@@ -552,7 +552,7 @@ describe('fileIOTestStat', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue()
try {
- let stat = fileio.Stat.statSync(fpath)
+ let stat = fileio.statSync(fpath)
expect(stat.isFIFO(-1)).assertFalse()
expect(null).assertFail()
} catch (e) {
@@ -570,7 +570,7 @@ describe('fileIOTestStat', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertInstanceOf('Boolean')
try {
- let stat = fileio.Stat.statSync(fpath)
+ let stat = fileio.statSync(fpath)
expect(stat.isFile()).assertInstanceOf('Boolean')
expect(fileio.unlinkSync(fpath)).assertNull()
} catch (e) {
@@ -589,7 +589,7 @@ describe('fileIOTestStat', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertInstanceOf('Boolean')
try {
- let stat = fileio.Stat.statSync(fpath)
+ let stat = fileio.statSync(fpath)
expect(stat.isFile()).assertTrue()
expect(fileio.unlinkSync(fpath)).assertNull()
} catch (e) {
@@ -608,7 +608,7 @@ describe('fileIOTestStat', function () {
try {
expect(fileio.mkdirSync(dpath)).assertNull()
- let stat = fileio.Stat.statSync(dpath)
+ let stat = fileio.statSync(dpath)
expect(stat.isFile()).assertFalse()
expect(fileio.rmdirSync(dpath)).assertNull()
} catch (e) {
@@ -627,7 +627,7 @@ describe('fileIOTestStat', function () {
try {
expect(fileio.mkdirSync(dpath)).assertNull()
- let stat = fileio.Stat.statSync(dpath)
+ let stat = fileio.statSync(dpath)
expect(stat.isFile(-1)).assertFalse()
expect(null).assertFail()
} catch (e) {
@@ -645,7 +645,7 @@ describe('fileIOTestStat', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue()
try {
- let stat = fileio.Stat.statSync(fpath)
+ let stat = fileio.statSync(fpath)
expect(stat.isSocket()).assertInstanceOf('Boolean')
expect(fileio.unlinkSync(fpath)).assertNull()
} catch (e) {
@@ -664,7 +664,7 @@ describe('fileIOTestStat', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue()
try {
- let stat = fileio.Stat.statSync(fpath)
+ let stat = fileio.statSync(fpath)
expect(stat.isSocket()).assertFalse()
expect(fileio.unlinkSync(fpath)).assertNull()
} catch (e) {
@@ -683,7 +683,7 @@ describe('fileIOTestStat', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue()
try {
- let stat = fileio.Stat.statSync(fpath)
+ let stat = fileio.statSync(fpath)
expect(stat.isSocket(-1)).assertFalse()
expect(null).assertFail()
} catch (e) {
@@ -701,7 +701,7 @@ describe('fileIOTestStat', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue()
try {
- let stat = fileio.Stat.statSync(fpath)
+ let stat = fileio.statSync(fpath)
expect(stat.isSymbolicLink()).assertInstanceOf('Boolean')
expect(fileio.unlinkSync(fpath)).assertNull()
} catch (e) {
@@ -720,7 +720,7 @@ describe('fileIOTestStat', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue()
try {
- let stat = fileio.Stat.statSync(fpath)
+ let stat = fileio.statSync(fpath)
expect(stat.isSymbolicLink()).assertFalse()
expect(fileio.unlinkSync(fpath)).assertNull()
} catch (e) {
@@ -739,7 +739,7 @@ describe('fileIOTestStat', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue()
try {
- let stat = fileio.Stat.statSync(fpath)
+ let stat = fileio.statSync(fpath)
expect(stat.isSymbolicLink(-1)).assertFalse()
expect(null).assertFail()
} catch (e) {
diff --git a/distributeddatamgr/distributedfilejstest/project/entry/src/main/js/test/FileIOStream.test.js b/distributeddatamgr/distributedfilejstest/project/entry/src/main/js/test/FileIOStream.test.js
index 174614de1c3e4bb26eb6cb8063e9d06253f48e50..0c7f598e2a1dece71e28259f17cbf827242296ab 100755
--- a/distributeddatamgr/distributedfilejstest/project/entry/src/main/js/test/FileIOStream.test.js
+++ b/distributeddatamgr/distributedfilejstest/project/entry/src/main/js/test/FileIOStream.test.js
@@ -29,7 +29,7 @@ describe('fileIOTestStream', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue()
try {
- var ss = fileio.Stream.createStreamSync(fpath, "r+")
+ var ss = fileio.createStreamSync(fpath, "r+")
expect(ss !== null).assertTrue()
expect(ss.closeSync()).assertNull()
expect(fileio.unlinkSync(fpath)).assertNull()
@@ -48,7 +48,7 @@ describe('fileIOTestStream', function () {
let fpath = nextFileName('fileio_test_stream_create_stream_sync_001')
try {
- fileio.Stream.createStreamSync(fpath, "r+")
+ fileio.createStreamSync(fpath, "r+")
expect(null).assertFail()
} catch (e) {
}
@@ -64,7 +64,7 @@ describe('fileIOTestStream', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue()
try {
- fileio.Stream.createStreamSync(fpath, "ohos")
+ fileio.createStreamSync(fpath, "ohos")
expect(null).assertFail()
} catch (e) {
expect(fileio.unlinkSync(fpath)).assertNull()
@@ -82,7 +82,7 @@ describe('fileIOTestStream', function () {
try {
var fd = fileio.openSync(fpath, 0o2)
- let ss = fileio.Stream.fdopenStreamSync(fd, "r+")
+ let ss = fileio.fdopenStreamSync(fd, "r+")
expect(ss !== null).assertTrue()
expect(ss.closeSync()).assertNull()
expect(fileio.unlinkSync(fpath)).assertNull()
@@ -99,7 +99,7 @@ describe('fileIOTestStream', function () {
*/
it('fileio_test_stream_fdopen_stream_sync_001', 0, function () {
try {
- let ss = fileio.Stream.fdopenStreamSync(-1, "r+")
+ let ss = fileio.fdopenStreamSync(-1, "r+")
expect(null).assertFail()
} catch (e) {
}
@@ -115,7 +115,7 @@ describe('fileIOTestStream', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue()
try {
- let ss = fileio.Stream.createStreamSync(fpath, "r+")
+ let ss = fileio.createStreamSync(fpath, "r+")
expect(ss !== null).assertTrue()
let len = ss.readSync(new ArrayBuffer(4096))
expect(len).assertEqual(FILE_CONTENT.length)
@@ -137,7 +137,7 @@ describe('fileIOTestStream', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue()
try {
- let ss = fileio.Stream.createStreamSync(fpath, "r+")
+ let ss = fileio.createStreamSync(fpath, "r+")
expect(ss !== null).assertTrue()
expect(ss.writeSync(FILE_CONTENT)).assertEqual(FILE_CONTENT.length)
expect(ss.closeSync()).assertNull()
@@ -158,7 +158,7 @@ describe('fileIOTestStream', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue()
try {
- let ss = fileio.Stream.createStreamSync(fpath, "r+")
+ let ss = fileio.createStreamSync(fpath, "r+")
expect(ss !== null).assertTrue()
expect(ss.writeSync(FILE_CONTENT)).assertEqual(FILE_CONTENT.length)
expect(ss.flushSync()).assertNull()
diff --git a/global_lite/i18n_lite/BUILD.gn b/global_lite/i18n_lite/BUILD.gn
index bca233ceea109d54c8386823163f1f74318ff90c..6015fbfa646555920827ff56cdd8d96c4cea744a 100755
--- a/global_lite/i18n_lite/BUILD.gn
+++ b/global_lite/i18n_lite/BUILD.gn
@@ -17,5 +17,9 @@ group("ActsGlobalTest") {
"//test/xts/acts/global_lite/i18n_lite/numberrecall_posix:ActsNumberRecallTest",
"//test/xts/acts/global_lite/i18n_lite/datetime_posix:ActsGlobalDateTimeTest",
"//test/xts/acts/global_lite/i18n_lite/datetimerecall_posix:ActsGlobalDateTimeRecallTest",
+ "//test/xts/acts/global_lite/i18n_lite/week_plural_number/src:WeekPluralNumbertest",
+
+ # depend on the resources
+ #"//test/xts/acts/global_lite/i18n_lite/resource_parse_load/src:ResourceParseLoadtest",
]
}
diff --git a/global_lite/i18n_lite/resource_parse_load/src/BUILD.gn b/global_lite/i18n_lite/resource_parse_load/src/BUILD.gn
new file mode 100755
index 0000000000000000000000000000000000000000..023207d6014b4d80b8979ba361d41316ce190458
--- /dev/null
+++ b/global_lite/i18n_lite/resource_parse_load/src/BUILD.gn
@@ -0,0 +1,43 @@
+# Copyright (C) 2021 Huawei Device Co., Ltd.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import("//test/xts/tools/lite/build/suite_lite.gni")
+
+hcpptest_suite("ResourceParseLoadtest") {
+ suite_name = "acts"
+ sources = [
+ "global_test.cpp",
+ "hap_manager_test.cpp",
+ "hap_parser_test.cpp",
+ "hap_resource_test.cpp",
+ "locale_info_test.cpp",
+ "res_config_impl_test.cpp",
+ "res_config_test.cpp",
+ "res_desc_test.cpp",
+ "resource_manager_performance_test.cpp",
+ "resource_manager_test.cpp",
+ "string_utils_test.cpp",
+ "test_common.cpp",
+ ]
+
+ include_dirs = [
+ "//base/global/i18n_lite/interfaces/kits/i18n/include",
+ "//base/global/resmgr_lite/frameworks/resmgr_lite/include",
+ "//base/global/resmgr_lite/interfaces/innerkits/include",
+ ]
+
+ deps = [
+ "//base/global/resmgr_lite/frameworks/resmgr_lite:global_resmgr",
+ #"//third_party/bounds_checking_function:libsec_shared",
+ ]
+}
diff --git a/global_lite/i18n_lite/resource_parse_load/src/Test.json b/global_lite/i18n_lite/resource_parse_load/src/Test.json
new file mode 100755
index 0000000000000000000000000000000000000000..3181ef0a455daed10f3ce8faba8c15d193215fd3
--- /dev/null
+++ b/global_lite/i18n_lite/resource_parse_load/src/Test.json
@@ -0,0 +1,21 @@
+{
+ "kits": [
+ {
+ "push": [
+ "ResourceParseLoadtest->/data/local/tmp/ResourceParseLoadtest"
+ ],
+ "type": "PushKit",
+ "post-push": [
+ "chmod -R 777 /data/local/tmp/*"
+ ]
+ }
+ ],
+ "driver": {
+ "native-test-timeout": "120000",
+ "type": "CppTest",
+ "module-name": "ResourceParseLoadtest",
+ "runtime-hint": "1s",
+ "native-test-device-path": "/data/local/tmp"
+ },
+ "description": "ResourceParseLoadtest Tests"
+}
\ No newline at end of file
diff --git a/global_lite/i18n_lite/resource_parse_load/src/global_test.cpp b/global_lite/i18n_lite/resource_parse_load/src/global_test.cpp
new file mode 100755
index 0000000000000000000000000000000000000000..4fd22a9554297abbd66ea1b5b3ea7405a2e75510
--- /dev/null
+++ b/global_lite/i18n_lite/resource_parse_load/src/global_test.cpp
@@ -0,0 +1,158 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "global_test.h"
+
+#include
+
+#include "test_common.h"
+#include "utils/errors.h"
+#include "utils/string_utils.h"
+
+#define private public
+
+#include "global.h"
+
+using namespace OHOS::Global::Resource;
+using namespace testing::ext;
+
+class GlobalTest : public testing::Test {
+public:
+ static void SetUpTestCase(void);
+
+ static void TearDownTestCase(void);
+
+ void SetUp();
+
+ void TearDown();
+};
+
+void GlobalTest::SetUpTestCase(void)
+{
+ // step 1: input testsuit setup step
+ g_logLevel = LOG_DEBUG;
+}
+
+void GlobalTest::TearDownTestCase()
+{
+ // step 2: input testsuit teardown step
+}
+
+void GlobalTest::SetUp()
+{
+ // step 3: input testcase setup step
+}
+
+void GlobalTest::TearDown()
+{
+ // step 4: input testcase teardown step
+}
+
+int GetResId(const std::string &name, ResType resType)
+{
+ auto rc = new ResConfigImpl;
+ rc->SetLocaleInfo("en", nullptr, "US");
+ std::string resPath = FormatFullPath(g_resFilePath);
+ const char *path = resPath.c_str();
+
+ const HapResource *pResource = HapResource::LoadFromIndex(path, rc);
+
+ int ret = pResource->GetIdByName(name.c_str(), resType);
+ delete pResource;
+ delete rc;
+ return ret;
+}
+
+/*
+ * @tc.name: GlobalFuncTest001
+ * @tc.desc: Test GLOBAL_ConfigLanguage function, file case.
+ * @tc.type: FUNC
+ */
+HWTEST_F(GlobalTest, GlobalFuncTest001, TestSize.Level1)
+{
+ char lan[10];
+ char region[10];
+
+ GLOBAL_ConfigLanguage("en-Latn-US");
+ int32_t ret = GLOBAL_GetLanguage(lan, 10);
+ ASSERT_EQ(OK, ret);
+ ASSERT_EQ(std::string("en"), lan);
+ ret = GLOBAL_GetRegion(region, 10);
+ ASSERT_EQ(OK, ret);
+ ASSERT_EQ(std::string("US"), region);
+
+ GLOBAL_ConfigLanguage("en_Latn_US");
+ ret = GLOBAL_GetLanguage(lan, 10);
+ ASSERT_EQ(OK, ret);
+ ASSERT_EQ(std::string("en"), lan);
+ ret = GLOBAL_GetRegion(region, 10);
+ ASSERT_EQ(OK, ret);
+ ASSERT_EQ(std::string("US"), region);
+
+ GLOBAL_ConfigLanguage("en-US");
+ ret = GLOBAL_GetLanguage(lan, 10);
+ ASSERT_EQ(OK, ret);
+ ASSERT_EQ(std::string("en"), lan);
+ ret = GLOBAL_GetRegion(region, 10);
+ ASSERT_EQ(OK, ret);
+ ASSERT_EQ(std::string("US"), region);
+
+ GLOBAL_ConfigLanguage("en_US");
+ ret = GLOBAL_GetLanguage(lan, 10);
+ ASSERT_EQ(OK, ret);
+ ASSERT_EQ(std::string("en"), lan);
+ ret = GLOBAL_GetRegion(region, 10);
+ ASSERT_EQ(OK, ret);
+ ASSERT_EQ(std::string("US"), region);
+
+ GLOBAL_ConfigLanguage("en");
+ ret = GLOBAL_GetLanguage(lan, 10);
+ ASSERT_EQ(OK, ret);
+ ASSERT_EQ(std::string("en"), lan);
+}
+
+/*
+ * @tc.name: GlobalFuncTest002
+ * @tc.desc: Test GLOBAL_GetValueByName function, file case.
+ * @tc.type: FUNC
+ */
+HWTEST_F(GlobalTest, GlobalFuncTest002, TestSize.Level1)
+{
+ GLOBAL_ConfigLanguage("en_Latn_US");
+ char *values = nullptr;
+ int32_t ret = GLOBAL_GetValueByName("app_name", FormatFullPath(g_resFilePath).c_str(), &values);
+ // when ret != OK , values has been freed.
+ ASSERT_EQ(OK, ret);
+ EXPECT_EQ(std::string("App Name"), values);
+ free(values);
+}
+
+/*
+ * @tc.name: GlobalFuncTest003
+ * @tc.desc: Test GLOBAL_GetValueById function, file case.
+ * @tc.type: FUNC
+ */
+HWTEST_F(GlobalTest, GlobalFuncTest003, TestSize.Level1)
+{
+ GLOBAL_ConfigLanguage("en_Latn_US");
+ char *values = nullptr;
+ int id = GetResId("app_name", ResType::STRING);
+ ASSERT_TRUE(id > 0);
+ int32_t ret = GLOBAL_GetValueById(static_cast(id), FormatFullPath(g_resFilePath).c_str(), &values);
+ // when ret != OK , values has been freed.
+ ASSERT_EQ(OK, ret);
+ EXPECT_EQ(std::string("App Name"), values);
+ free(values);
+}
diff --git a/global_lite/i18n_lite/resource_parse_load/src/global_test.h b/global_lite/i18n_lite/resource_parse_load/src/global_test.h
new file mode 100755
index 0000000000000000000000000000000000000000..c5196fe30a555b64f2d9c4da756d7e2564a6f369
--- /dev/null
+++ b/global_lite/i18n_lite/resource_parse_load/src/global_test.h
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef RESOURCE_MANAGER_GLOBAL_TEST_H
+#define RESOURCE_MANAGER_GLOBAL_TEST_H
+
+int GlobalFuncTest001();
+int GlobalFuncTest002();
+int GlobalFuncTest003();
+
+#endif
diff --git a/global_lite/i18n_lite/resource_parse_load/src/hap_manager_test.cpp b/global_lite/i18n_lite/resource_parse_load/src/hap_manager_test.cpp
new file mode 100755
index 0000000000000000000000000000000000000000..1dd131114d9733a46bc3dd9483218b568c27548b
--- /dev/null
+++ b/global_lite/i18n_lite/resource_parse_load/src/hap_manager_test.cpp
@@ -0,0 +1,154 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "hap_manager_test.h"
+
+#include
+
+#include "test_common.h"
+#include "utils/string_utils.h"
+
+#define private public
+
+#include "hap_manager.h"
+
+using namespace OHOS::Global::Resource;
+using namespace testing::ext;
+
+class HapManagerTest : public testing::Test {
+public:
+ static void SetUpTestCase(void);
+
+ static void TearDownTestCase(void);
+
+ void SetUp();
+
+ void TearDown();
+};
+
+void HapManagerTest::SetUpTestCase(void)
+{
+ // step 1: input testsuit setup step
+ g_logLevel = LOG_DEBUG;
+}
+
+void HapManagerTest::TearDownTestCase()
+{
+ // step 2: input testsuit teardown step
+}
+
+void HapManagerTest::SetUp()
+{
+ // step 3: input testcase setup step
+ HILOG_DEBUG("HapManagerTest setup");
+}
+
+void HapManagerTest::TearDown()
+{
+ // step 4: input testcase teardown step
+ HILOG_DEBUG("HapManagerTest teardown");
+}
+
+/*
+ * this test shows how to load a hap, then find value list by id
+ * @tc.name: HapManagerFuncTest001
+ * @tc.desc: Test AddResourcePath & GetResourceList function, file case.
+ * @tc.type: FUNC
+ */
+HWTEST_F(HapManagerTest, HapManagerFuncTest001, TestSize.Level1)
+{
+ HapManager *hapManager = new HapManager(new ResConfigImpl);
+ bool ret = hapManager->AddResourcePath(FormatFullPath(g_resFilePath).c_str());
+
+ EXPECT_TRUE(ret);
+
+ int id = 16777217;
+ const HapResource::IdValues *idValues = hapManager->GetResourceList(id);
+ if (idValues == nullptr) {
+ delete hapManager;
+ EXPECT_TRUE(false);
+ return;
+ }
+
+ PrintIdValues(idValues);
+ delete hapManager;
+}
+
+/*
+ * this test shows how to reload a hap
+ * @tc.name: HapManagerFuncTest002
+ * @tc.desc: Test UpdateResConfig & AddResourcePath function, file case.
+ * @tc.type: FUNC
+ */
+HWTEST_F(HapManagerTest, HapManagerFuncTest002, TestSize.Level1)
+{
+ ResConfig *rc = CreateResConfig();
+ if (rc == nullptr) {
+ EXPECT_TRUE(false);
+ return;
+ }
+ rc->SetLocaleInfo("en", nullptr, "US");
+ std::string resPath = FormatFullPath(g_resFilePath);
+ const char *path = resPath.c_str();
+ HapManager *hapManager = new HapManager(new ResConfigImpl);
+ if (hapManager == nullptr) {
+ delete (rc);
+ EXPECT_TRUE(false);
+ return;
+ }
+ hapManager->UpdateResConfig(*rc);
+ bool ret = hapManager->AddResourcePath(path);
+
+ EXPECT_TRUE(ret);
+
+ int id = 16777228;
+ const HapResource::IdValues *idValues = hapManager->GetResourceList(id);
+ if (idValues == nullptr) {
+ delete (hapManager);
+ delete (rc);
+ EXPECT_TRUE(false);
+ return;
+ }
+
+ EXPECT_EQ(static_cast(1), idValues->GetLimitPathsConst().size());
+ PrintIdValues(idValues);
+
+ // reload
+
+ ResConfig* rc2 = CreateResConfig();
+ if (rc2 == nullptr) {
+ delete (hapManager);
+ delete (rc);
+ EXPECT_TRUE(false);
+ return;
+ }
+
+ rc2->SetLocaleInfo("zh", nullptr, "CN");
+ hapManager->UpdateResConfig(*rc2);
+ do {
+ idValues = hapManager->GetResourceList(id);
+ if (idValues == nullptr) {
+ EXPECT_TRUE(false);
+ break;
+ }
+
+ EXPECT_EQ(static_cast(2), idValues->GetLimitPathsConst().size());
+
+ PrintIdValues(idValues);
+ } while (false);
+ delete (hapManager);
+ delete (rc2);
+ delete (rc);
+}
\ No newline at end of file
diff --git a/global_lite/i18n_lite/resource_parse_load/src/hap_manager_test.h b/global_lite/i18n_lite/resource_parse_load/src/hap_manager_test.h
new file mode 100755
index 0000000000000000000000000000000000000000..93b053760fb97a05080967ad338f81f3c9e1dad9
--- /dev/null
+++ b/global_lite/i18n_lite/resource_parse_load/src/hap_manager_test.h
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef RESOURCE_MANAGER_HAP_MANAGER_TEST_H
+#define RESOURCE_MANAGER_HAP_MANAGER_TEST_H
+
+int HapManagerFuncTest001();
+int HapManagerFuncTest002();
+
+#endif
diff --git a/global_lite/i18n_lite/resource_parse_load/src/hap_parser_test.cpp b/global_lite/i18n_lite/resource_parse_load/src/hap_parser_test.cpp
new file mode 100755
index 0000000000000000000000000000000000000000..13decd68f7e1157c7e796a0dafabb203fb9b5329
--- /dev/null
+++ b/global_lite/i18n_lite/resource_parse_load/src/hap_parser_test.cpp
@@ -0,0 +1,183 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "hap_parser_test.h"
+
+#include
+
+#include "test_common.h"
+#include "utils/string_utils.h"
+
+#define private public
+
+#include "hap_parser.h"
+
+using namespace OHOS::Global::Resource;
+using namespace testing::ext;
+
+class HapParserTest : public testing::Test {
+public:
+ static void SetUpTestCase(void);
+
+ static void TearDownTestCase(void);
+
+ void SetUp();
+
+ void TearDown();
+};
+
+void HapParserTest::SetUpTestCase(void)
+{
+ // step 1: input testsuit setup step
+ g_logLevel = LOG_DEBUG;
+}
+
+void HapParserTest::TearDownTestCase()
+{
+ // step 2: input testsuit teardown step
+}
+
+void HapParserTest::SetUp()
+{
+ // step 3: input testcase setup step
+}
+
+void HapParserTest::TearDown()
+{
+ // step 4: input testcase teardown step
+}
+
+/*
+ * @tc.name: HapParserFuncTest001
+ * @tc.desc: Test CreateResConfigFromKeyParams
+ * @tc.type: FUNC
+ */
+HWTEST_F(HapParserTest, HapParserFuncTest001, TestSize.Level1)
+{
+ std::vector keyParams;
+ auto kp = new KeyParam();
+ kp->type_ = LANGUAGES;
+ kp->value_ = 31336;
+ kp->InitStr();
+ keyParams.push_back(kp);
+ kp = new KeyParam();
+ kp->type_ = REGION;
+ kp->value_ = 17230;
+ kp->InitStr();
+ keyParams.push_back(kp);
+ kp = new KeyParam();
+ kp->type_ = SCREEN_DENSITY;
+ kp->value_ = SCREEN_DENSITY_SDPI;
+ kp->InitStr();
+ keyParams.push_back(kp);
+ kp = new KeyParam();
+ kp->type_ = DEVICETYPE;
+ kp->value_ = DEVICE_CAR;
+ kp->InitStr();
+ keyParams.push_back(kp);
+ kp = new KeyParam();
+ kp->type_ = DIRECTION;
+ kp->value_ = DIRECTION_VERTICAL;
+ kp->InitStr();
+ keyParams.push_back(kp);
+ auto config = HapParser::CreateResConfigFromKeyParams(keyParams);
+ if (config != nullptr) {
+ EXPECT_EQ(std::string("zh"), config->GetLocaleInfo()->GetLanguage());
+ EXPECT_EQ(std::string("CN"), config->GetLocaleInfo()->GetRegion());
+ EXPECT_EQ(std::string("Hans"), config->GetLocaleInfo()->GetScript());
+ EXPECT_EQ(DEVICE_CAR, config->GetDeviceType());
+ EXPECT_EQ(DIRECTION_VERTICAL, config->GetDirection());
+ EXPECT_EQ(SCREEN_DENSITY_SDPI, config->GetScreenDensity());
+ } else {
+ EXPECT_TRUE(false);
+ }
+
+ for (auto kp = keyParams.begin(); kp != keyParams.end(); kp++) {
+ delete *kp;
+ }
+ delete config;
+}
+
+/*
+ * @tc.name: HapParserFuncTest002
+ * @tc.desc: Test GetDeviceType
+ * @tc.type: FUNC
+ */
+HWTEST_F(HapParserTest, HapParserFuncTest002, TestSize.Level1)
+{
+ ASSERT_EQ(DEVICE_CAR, HapParser::GetDeviceType(DEVICE_CAR));
+ ASSERT_EQ(DEVICE_PC, HapParser::GetDeviceType(DEVICE_PC));
+ ASSERT_EQ(DEVICE_PHONE, HapParser::GetDeviceType(DEVICE_PHONE));
+ ASSERT_EQ(DEVICE_TABLET, HapParser::GetDeviceType(DEVICE_TABLET));
+ ASSERT_EQ(DEVICE_TV, HapParser::GetDeviceType(DEVICE_TV));
+ ASSERT_EQ(DEVICE_WEARABLE, HapParser::GetDeviceType(DEVICE_WEARABLE));
+ ASSERT_EQ(DEVICE_NOT_SET, HapParser::GetDeviceType(1000000));
+}
+
+/*
+ * @tc.name: HapParserFuncTest003
+ * @tc.desc: Test GetScreenDensity
+ * @tc.type: FUNC
+ */
+HWTEST_F(HapParserTest, HapParserFuncTest003, TestSize.Level1)
+{
+ ASSERT_EQ(SCREEN_DENSITY_SDPI, HapParser::GetScreenDensity(SCREEN_DENSITY_SDPI));
+ ASSERT_EQ(SCREEN_DENSITY_MDPI, HapParser::GetScreenDensity(SCREEN_DENSITY_MDPI));
+ ASSERT_EQ(SCREEN_DENSITY_LDPI, HapParser::GetScreenDensity(SCREEN_DENSITY_LDPI));
+ ASSERT_EQ(SCREEN_DENSITY_XLDPI, HapParser::GetScreenDensity(SCREEN_DENSITY_XLDPI));
+ ASSERT_EQ(SCREEN_DENSITY_XXLDPI, HapParser::GetScreenDensity(SCREEN_DENSITY_XXLDPI));
+ ASSERT_EQ(SCREEN_DENSITY_XXXLDPI, HapParser::GetScreenDensity(SCREEN_DENSITY_XXXLDPI));
+ ASSERT_EQ(SCREEN_DENSITY_NOT_SET, HapParser::GetScreenDensity(10000000));
+}
+
+/*
+ * @tc.name: HapParserFuncTest004
+ * @tc.desc: Test ToFolderPath
+ * @tc.type: FUNC
+ */
+HWTEST_F(HapParserTest, HapParserFuncTest004, TestSize.Level1)
+{
+ std::vector keyParams;
+ auto kp = new KeyParam();
+ kp->type_ = LANGUAGES;
+ kp->value_ = 31336;
+ kp->InitStr();
+ keyParams.push_back(kp);
+ kp = new KeyParam();
+ kp->type_ = REGION;
+ kp->value_ = 17230;
+ kp->InitStr();
+ keyParams.push_back(kp);
+ kp = new KeyParam();
+ kp->type_ = SCREEN_DENSITY;
+ kp->value_ = SCREEN_DENSITY_SDPI;
+ kp->InitStr();
+ keyParams.push_back(kp);
+ kp = new KeyParam();
+ kp->type_ = DEVICETYPE;
+ kp->value_ = DEVICE_CAR;
+ kp->InitStr();
+ keyParams.push_back(kp);
+ kp = new KeyParam();
+ kp->type_ = DIRECTION;
+ kp->value_ = DIRECTION_VERTICAL;
+ kp->InitStr();
+ keyParams.push_back(kp);
+ std::string folder = HapParser::ToFolderPath(keyParams);
+ ASSERT_EQ("zh_CN-vertical-car-sdpi", folder);
+ for (auto kp = keyParams.begin(); kp != keyParams.end(); kp++) {
+ delete *kp;
+ }
+}
\ No newline at end of file
diff --git a/global_lite/i18n_lite/resource_parse_load/src/hap_parser_test.h b/global_lite/i18n_lite/resource_parse_load/src/hap_parser_test.h
new file mode 100755
index 0000000000000000000000000000000000000000..7c5ef8d407c0902def1871732eb6ee376548ac65
--- /dev/null
+++ b/global_lite/i18n_lite/resource_parse_load/src/hap_parser_test.h
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef RESOURCE_MANAGER_HAP_RESOURCE_TEST_H
+#define RESOURCE_MANAGER_HAP_RESOURCE_TEST_H
+
+int HapParserFuncTest001();
+int HapParserFuncTest002();
+int HapParserFuncTest003();
+int HapParserFuncTest004();
+
+#endif
diff --git a/global_lite/i18n_lite/resource_parse_load/src/hap_resource_test.cpp b/global_lite/i18n_lite/resource_parse_load/src/hap_resource_test.cpp
new file mode 100755
index 0000000000000000000000000000000000000000..872646f88c6e525baef00cec8bf2b5afee6f066b
--- /dev/null
+++ b/global_lite/i18n_lite/resource_parse_load/src/hap_resource_test.cpp
@@ -0,0 +1,304 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "hap_resource_test.h"
+
+#include
+#include
+
+#include "hap_parser.h"
+#include "hap_resource.h"
+#include "test_common.h"
+#include "utils/date_utils.h"
+#include "utils/errors.h"
+#include "utils/string_utils.h"
+
+#define private public
+
+using namespace OHOS::Global::Resource;
+using namespace testing::ext;
+
+class HapResourceTest : public testing::Test {
+public:
+ static void SetUpTestCase(void);
+
+ static void TearDownTestCase(void);
+
+ void SetUp();
+
+ void TearDown();
+};
+
+void HapResourceTest::SetUpTestCase(void)
+{
+ // step 1: input testsuit setup step
+ g_logLevel = LOG_DEBUG;
+}
+
+void HapResourceTest::TearDownTestCase(void)
+{
+ // step 2: input testsuit teardown step
+}
+
+void HapResourceTest::SetUp()
+{
+ // step 3: input testcase setup step
+}
+
+void HapResourceTest::TearDown()
+{
+ // step 4: input testcase teardown step
+}
+
+/*
+ * this test shows how to load a hap, defaultConfig set to null
+ * @tc.name: HapResourceFuncTest001
+ * @tc.desc: Test Load & GetIdValues & GetIdValuesByName function, file case.
+ * @tc.type: FUNC
+ */
+HWTEST_F(HapResourceTest, HapResourceFuncTest001, TestSize.Level1)
+{
+ auto start = CurrentTimeUsec();
+ const HapResource *pResource = HapResource::LoadFromIndex(FormatFullPath(g_resFilePath).c_str(), nullptr);
+ auto cost = CurrentTimeUsec() - start;
+ HILOG_DEBUG("load cost: %ld us.", cost);
+
+ if (pResource == nullptr) {
+ EXPECT_TRUE(false);
+ return;
+ }
+ EXPECT_EQ(static_cast(80), pResource->IdSize());
+
+ int id = pResource->GetIdByName("app_name", ResType::STRING);
+ start = CurrentTimeUsec();
+ auto idValues = pResource->GetIdValues(id);
+ cost = CurrentTimeUsec() - start;
+ EXPECT_EQ(static_cast(3), idValues->GetLimitPathsConst().size());
+ HILOG_DEBUG("GetIdValues by id cost: %ld us.", cost);
+ PrintIdValues(idValues);
+ {
+ auto limitPath = idValues->GetLimitPathsConst()[0];
+ EXPECT_TRUE(limitPath->GetFolder() == "en_US");
+ EXPECT_TRUE(limitPath->GetIdItem()->name_ == "app_name");
+ EXPECT_TRUE(limitPath->GetIdItem()->value_ == "App Name");
+ }
+ {
+ auto limitPath = idValues->GetLimitPathsConst()[1];
+ EXPECT_TRUE(limitPath->GetFolder() == "zh_CN");
+ EXPECT_TRUE(limitPath->GetIdItem()->name_ == "app_name");
+ EXPECT_TRUE(limitPath->GetIdItem()->value_ == "应用名称");
+ }
+ {
+ auto limitPath = idValues->GetLimitPathsConst()[2];
+ EXPECT_TRUE(limitPath->GetFolder() == "default");
+ EXPECT_TRUE(limitPath->GetIdItem()->name_ == "app_name");
+ EXPECT_TRUE(limitPath->GetIdItem()->value_ == "About");
+ }
+
+ std::string name = std::string("app_name");
+ start = CurrentTimeUsec();
+ auto idValues2 = pResource->GetIdValuesByName(name, ResType::STRING);
+ cost = CurrentTimeUsec() - start;
+ EXPECT_EQ(static_cast(3), idValues2->GetLimitPathsConst().size());
+ HILOG_DEBUG("GetIdValues by name cost: %ld us.", cost);
+ PrintIdValues(idValues);
+ {
+ auto limitPath = idValues->GetLimitPathsConst()[0];
+ EXPECT_TRUE(limitPath->GetFolder() == "en_US");
+ EXPECT_TRUE(limitPath->GetIdItem()->name_ == "app_name");
+ EXPECT_TRUE(limitPath->GetIdItem()->value_ == "App Name");
+ }
+ {
+ auto limitPath = idValues->GetLimitPathsConst()[1];
+ EXPECT_TRUE(limitPath->GetFolder() == "zh_CN");
+ EXPECT_TRUE(limitPath->GetIdItem()->name_ == "app_name");
+ EXPECT_TRUE(limitPath->GetIdItem()->value_ == "应用名称");
+ }
+ {
+ auto limitPath = idValues->GetLimitPathsConst()[2];
+ EXPECT_TRUE(limitPath->GetFolder() == "default");
+ EXPECT_TRUE(limitPath->GetIdItem()->name_ == "app_name");
+ EXPECT_TRUE(limitPath->GetIdItem()->value_ == "About");
+ }
+
+ delete (pResource);
+}
+
+/*
+ * load a hap, set config en_US
+ * @tc.name: HapResourceFuncTest002
+ * @tc.desc: Test Load & GetIdValues & GetIdValuesByName function, file case.
+ * @tc.type: FUNC
+ */
+HWTEST_F(HapResourceTest, HapResourceFuncTest002, TestSize.Level1)
+{
+ ResConfigImpl *rc = new ResConfigImpl;
+ rc->SetLocaleInfo("en", nullptr, "US");
+ std::string resPath = FormatFullPath(g_resFilePath);
+ const char *path = resPath.c_str();
+
+ auto start = CurrentTimeUsec();
+ const HapResource *pResource = HapResource::LoadFromIndex(path, rc);
+ auto cost = CurrentTimeUsec() - start;
+ HILOG_DEBUG("load cost: %ld us.", cost);
+
+ if (pResource == nullptr) {
+ delete rc;
+ EXPECT_TRUE(false);
+ return;
+ }
+
+ EXPECT_EQ(static_cast(79), pResource->IdSize());
+
+ int id = pResource->GetIdByName("app_name", ResType::STRING);
+ start = CurrentTimeUsec();
+ auto idValues = pResource->GetIdValues(id);
+ cost = CurrentTimeUsec() - start;
+ EXPECT_EQ(static_cast(2), idValues->GetLimitPathsConst().size());
+ HILOG_DEBUG("GetIdValues by id cost: %ld us.", cost);
+ PrintIdValues(idValues);
+
+ {
+ auto limitPath = idValues->GetLimitPathsConst()[0];
+ EXPECT_TRUE(limitPath->GetFolder() == "en_US");
+ EXPECT_TRUE(limitPath->GetIdItem()->name_ == "app_name");
+ EXPECT_TRUE(limitPath->GetIdItem()->value_ == "App Name");
+ }
+
+ {
+ auto limitPath = idValues->GetLimitPathsConst()[1];
+ EXPECT_TRUE(limitPath->GetFolder() == "default");
+ EXPECT_TRUE(limitPath->GetIdItem()->name_ == "app_name");
+ EXPECT_TRUE(limitPath->GetIdItem()->value_ == "About");
+ }
+
+ std::string name = std::string("app_name");
+ start = CurrentTimeUsec();
+ auto idValues2 = pResource->GetIdValuesByName(name, ResType::STRING);
+ cost = CurrentTimeUsec() - start;
+ EXPECT_EQ(static_cast(2), idValues2->GetLimitPathsConst().size());
+ HILOG_DEBUG("GetIdValues by name cost: %ld us.", cost);
+ PrintIdValues(idValues);
+
+ {
+ auto limitPath = idValues2->GetLimitPathsConst()[0];
+ EXPECT_TRUE(limitPath->GetFolder() == "en_US");
+ EXPECT_TRUE(limitPath->GetIdItem()->id_ == static_cast(id));
+ EXPECT_TRUE(limitPath->GetIdItem()->value_ == "App Name");
+ }
+
+ {
+ auto limitPath = idValues->GetLimitPathsConst()[1];
+ EXPECT_TRUE(limitPath->GetFolder() == "default");
+ EXPECT_TRUE(limitPath->GetIdItem()->id_ == static_cast(id));
+ EXPECT_TRUE(limitPath->GetIdItem()->value_ == "About");
+ }
+ delete pResource;
+ delete rc;
+}
+
+/*
+ * load a hap, get a value which is ref
+ * @tc.name: HapResourceFuncTest003
+ * @tc.desc: Test GetIdValuesByName function, file case.
+ * @tc.type: FUNC
+ */
+HWTEST_F(HapResourceTest, HapResourceFuncTest003, TestSize.Level1)
+{
+ auto start = CurrentTimeUsec();
+ const HapResource *pResource = HapResource::LoadFromIndex(FormatFullPath(g_resFilePath).c_str(), nullptr);
+ auto cost = CurrentTimeUsec() - start;
+ HILOG_DEBUG("load cost: %ld us.", cost);
+
+ if (pResource == nullptr) {
+ EXPECT_TRUE(false);
+ return;
+ }
+
+ auto idv = pResource->GetIdValuesByName(std::string("integer_ref"), ResType::INTEGER);
+ PrintIdValues(idv);
+
+ idv = pResource->GetIdValuesByName(std::string("string_ref"), ResType::STRING);
+ PrintIdValues(idv);
+
+ // ref propagation
+ idv = pResource->GetIdValuesByName(std::string("string_ref2"), ResType::STRING);
+ PrintIdValues(idv);
+
+ idv = pResource->GetIdValuesByName(std::string("boolean_ref"), ResType::BOOLEAN);
+ PrintIdValues(idv);
+
+ idv = pResource->GetIdValuesByName(std::string("color_ref"), ResType::COLOR);
+ PrintIdValues(idv);
+
+ idv = pResource->GetIdValuesByName(std::string("float_ref"), ResType::FLOAT);
+ PrintIdValues(idv);
+
+ // ref in array ,
+ idv = pResource->GetIdValuesByName(std::string("intarray_1"), ResType::INTARRAY);
+ PrintIdValues(idv);
+
+ // "parent": was ref too
+ idv = pResource->GetIdValuesByName(std::string("child"), ResType::PATTERN);
+ PrintIdValues(idv);
+}
+
+ResDesc *LoadFromHap(const char *hapPath, const ResConfigImpl *defaultConfig)
+{
+ std::string errOut;
+ void *buf = nullptr;
+ size_t bufLen;
+ int32_t out = HapParser::ReadIndexFromFile(hapPath,
+ &buf, bufLen, errOut);
+ if (out != OK) {
+ HILOG_ERROR("ReadIndexFromFile failed! retcode:%d,err:%s", out, errOut.c_str());
+ return nullptr;
+ }
+ HILOG_DEBUG("extract success, bufLen:%zu", bufLen);
+
+ ResDesc *resDesc = new ResDesc();
+ out = HapParser::ParseResHex((char *)buf, bufLen, *resDesc, defaultConfig);
+ if (out != OK) {
+ delete (resDesc);
+ free(buf);
+ HILOG_ERROR("ParseResHex failed! retcode:%d", out);
+ return nullptr;
+ } else {
+ HILOG_DEBUG("ParseResHex success:\n%s", resDesc->ToString().c_str());
+ }
+ free(buf);
+ // construct hapresource
+ return resDesc;
+}
+
+/*
+ * @tc.name: HapResourceFuncTest004
+ * @tc.desc: Test HapParser::ReadIndexFromFile function, file case.
+ * @tc.type: FUNC
+ */
+HWTEST_F(HapResourceTest, HapResourceFuncTest004, TestSize.Level1)
+{
+ // 1. normal case
+ ResDesc *resDesc = LoadFromHap(FormatFullPath("all.hap").c_str(), nullptr);
+ ASSERT_TRUE(resDesc != nullptr);
+
+ // 2. hap file exists, config.json does not exist
+ resDesc = LoadFromHap(FormatFullPath("err-config.json-1.hap").c_str(), nullptr);
+ ASSERT_TRUE(resDesc == nullptr);
+
+ // 3. hap file exists, config.json error: missing "moduleName"
+ resDesc = LoadFromHap(FormatFullPath("err-config.json-2.hap").c_str(), nullptr);
+ ASSERT_TRUE(resDesc == nullptr);
+}
\ No newline at end of file
diff --git a/global_lite/i18n_lite/resource_parse_load/src/hap_resource_test.h b/global_lite/i18n_lite/resource_parse_load/src/hap_resource_test.h
new file mode 100755
index 0000000000000000000000000000000000000000..7ea1b99256d8ee8a9bd6a00c5a13921e1cc73179
--- /dev/null
+++ b/global_lite/i18n_lite/resource_parse_load/src/hap_resource_test.h
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef RESOURCE_MANAGER_HAP_RESOURCE_TEST_H
+#define RESOURCE_MANAGER_HAP_RESOURCE_TEST_H
+
+int HapResourceFuncTest001();
+int HapResourceFuncTest002();
+int HapResourceFuncTest003();
+int HapResourceFuncTest004();
+
+#endif
diff --git a/global_lite/i18n_lite/resource_parse_load/src/locale_info_test.cpp b/global_lite/i18n_lite/resource_parse_load/src/locale_info_test.cpp
new file mode 100755
index 0000000000000000000000000000000000000000..eb0af69dd1fc56aed889b8a938c460d0bfefcd76
--- /dev/null
+++ b/global_lite/i18n_lite/resource_parse_load/src/locale_info_test.cpp
@@ -0,0 +1,609 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "locale_info_test.h"
+
+#include
+#include
+#include
+#include
+
+#include "hilog_wrapper.h"
+#include "locale_info.h"
+#include "test_common.h"
+
+using namespace OHOS::Global::Resource;
+using namespace testing::ext;
+
+class LocaleInfoTest : public testing::Test {
+public:
+ static void SetUpTestCase(void);
+
+ static void TearDownTestCase(void);
+
+ void SetUp();
+
+ void TearDown();
+};
+
+void LocaleInfoTest::SetUpTestCase(void)
+{
+ // step 1: input testsuit setup step
+}
+
+void LocaleInfoTest::TearDownTestCase(void)
+{
+ // step 2: input testsuit teardown step
+}
+
+void LocaleInfoTest::SetUp()
+{
+}
+
+void LocaleInfoTest::TearDown()
+{
+}
+
+/*
+ * @tc.name: LocaleInfoFindAndSortTest001
+ * @tc.desc: Test FindAndSort
+ * @tc.type: FUNC
+ */
+HWTEST_F(LocaleInfoTest, LocaleInfoFindAndSortTest001, TestSize.Level1)
+{
+ std::vector request;
+ std::vector outValue;
+ request.push_back("en");
+ request.push_back("en-CN");
+ request.push_back("en-US");
+ request.push_back("en-GB");
+ request.push_back("");
+ std::string current = "en-US";
+ FindAndSort(current, request, outValue);
+ EXPECT_TRUE(outValue.at(0) == "en-US");
+ EXPECT_TRUE(outValue.at(1) == "en");
+ EXPECT_TRUE(outValue.at(2) == "");
+ EXPECT_TRUE(outValue.at(3) == "en-CN");
+ EXPECT_TRUE(outValue.at(4) == "en-GB");
+}
+
+/*
+ * @tc.name: LocaleInfoFindAndSortTest002
+ * @tc.desc: Test FindAndSort
+ * @tc.type: FUNC
+ */
+HWTEST_F(LocaleInfoTest, LocaleInfoFindAndSortTest002, TestSize.Level1)
+{
+ std::vector request;
+ std::vector outValue;
+ request.push_back("zh-CN");
+ request.push_back("zh-TW");
+ request.push_back("zh");
+ request.push_back("zh-HK");
+ request.push_back("");
+ std::string current = "zh-CN";
+ FindAndSort(current, request, outValue);
+ EXPECT_TRUE(outValue.at(0) == "zh-CN");
+ EXPECT_TRUE(outValue.at(1) == "zh");
+ EXPECT_TRUE(outValue.at(2) == "");
+}
+
+/*
+ * @tc.name: LocaleInfoFindAndSortTest003
+ * @tc.desc: Test FindAndSort
+ * @tc.type: FUNC
+ */
+HWTEST_F(LocaleInfoTest, LocaleInfoFindAndSortTest003, TestSize.Level1)
+{
+ std::vector request;
+ std::vector outValue;
+ request.push_back("en");
+ request.push_back("en-CA");
+ request.push_back("en-GB");
+ request.push_back("");
+ std::string current = "en-CN";
+ FindAndSort(current, request, outValue);
+ EXPECT_TRUE(outValue.at(0) == "en");
+ EXPECT_TRUE(outValue.at(1) == "en-CA");
+ EXPECT_TRUE(outValue.at(2) == "");
+ EXPECT_TRUE(outValue.at(3) == "en-GB");
+}
+
+/*
+ * @tc.name: LocaleInfoFindAndSortTest004
+ * @tc.desc: Test FindAndSort
+ * @tc.type: FUNC
+ */
+HWTEST_F(LocaleInfoTest, LocaleInfoFindAndSortTest004, TestSize.Level1)
+{
+ std::vector request;
+ std::vector outValue;
+ request.push_back("en");
+ request.push_back("en-CA");
+ request.push_back("en-GB");
+ request.push_back("");
+ std::string current = "en-Qaag";
+ FindAndSort(current, request, outValue);
+ EXPECT_TRUE(outValue.at(0) == "en");
+ EXPECT_TRUE(outValue.at(1) == "en-GB");
+ EXPECT_TRUE(outValue.at(2) == "en-CA");
+ EXPECT_TRUE(outValue.at(3) == "");
+}
+
+/*
+ * @tc.name: LocaleInfoFindAndSortTest005
+ * @tc.desc: Test FindAndSort
+ * @tc.type: FUNC
+ */
+HWTEST_F(LocaleInfoTest, LocaleInfoFindAndSortTest005, TestSize.Level1)
+{
+ std::vector request;
+ std::vector outValue;
+ request.push_back("en");
+ request.push_back("en-001");
+ request.push_back("en-CA");
+ request.push_back("en-GB");
+ request.push_back("");
+ std::string current = "en-AI";
+ FindAndSort(current, request, outValue);
+ EXPECT_TRUE(outValue.at(0) == "en-001");
+ EXPECT_TRUE(outValue.at(1) == "en");
+ EXPECT_TRUE(outValue.at(2) == "en-GB");
+ EXPECT_TRUE(outValue.at(3) == "en-CA");
+ EXPECT_TRUE(outValue.at(4) == "");
+}
+
+/*
+ * @tc.name: LocaleInfoGetSysDefaultTest001
+ * @tc.desc: Test GetSysDefault
+ * @tc.type: FUNC
+ */
+HWTEST_F(LocaleInfoTest, LocaleInfoGetSysDefaultTest001, TestSize.Level1)
+{
+ RState state = SUCCESS;
+ LocaleInfo* localeInfo = BuildFromString("zh-CN", '-', state);
+ if (localeInfo == nullptr) {
+ EXPECT_TRUE(false);
+ return;
+ }
+ UpdateSysDefault(*localeInfo, false);
+ const LocaleInfo* currentLocaleInfo = GetSysDefault();
+ if (currentLocaleInfo == nullptr) {
+ EXPECT_TRUE(false);
+ delete localeInfo;
+ return;
+ }
+ EXPECT_TRUE(std::strcmp("zh", currentLocaleInfo->GetLanguage()) == 0);
+ EXPECT_TRUE(std::strcmp("CN", currentLocaleInfo->GetRegion()) == 0);
+ delete localeInfo;
+ localeInfo = nullptr;
+}
+
+/*
+ * @tc.name: LocaleInfoUpdateSysDefaultTest001
+ * @tc.desc: Test UpdateSysDefault
+ * @tc.type: FUNC
+ */
+HWTEST_F(LocaleInfoTest, LocaleInfoUpdateSysDefaultTest001, TestSize.Level1)
+{
+ RState state = SUCCESS;
+ LocaleInfo* localeInfo = BuildFromString("zh-CN", '-', state);
+ if (localeInfo == nullptr) {
+ EXPECT_TRUE(false);
+ return;
+ }
+ UpdateSysDefault(*localeInfo, false);
+ const LocaleInfo* currentLocaleInfo = GetSysDefault();
+ if (currentLocaleInfo == nullptr) {
+ EXPECT_TRUE(false);
+ delete localeInfo;
+ return;
+ }
+ EXPECT_TRUE(std::strcmp("zh", currentLocaleInfo->GetLanguage()) == 0);
+ EXPECT_TRUE(std::strcmp("CN", currentLocaleInfo->GetRegion()) == 0);
+ delete localeInfo;
+ localeInfo = BuildFromString("en-US", '-', state);
+ UpdateSysDefault(*localeInfo, false);
+ currentLocaleInfo = GetSysDefault();
+ if (currentLocaleInfo == nullptr) {
+ EXPECT_TRUE(false);
+ delete localeInfo;
+ return;
+ }
+ EXPECT_TRUE(std::strcmp("en", currentLocaleInfo->GetLanguage()) == 0);
+ EXPECT_TRUE(std::strcmp("US", currentLocaleInfo->GetRegion()) == 0);
+ delete localeInfo;
+ localeInfo = BuildFromString("en-Qaag-US", '-', state);
+ if (localeInfo == nullptr) {
+ EXPECT_TRUE(false);
+ return;
+ }
+ UpdateSysDefault(*localeInfo, false);
+ currentLocaleInfo = GetSysDefault();
+ if (currentLocaleInfo == nullptr) {
+ EXPECT_TRUE(false);
+ delete localeInfo;
+ return;
+ }
+ EXPECT_TRUE(std::strcmp("en", currentLocaleInfo->GetLanguage()) == 0);
+ EXPECT_TRUE(std::strcmp("US", currentLocaleInfo->GetRegion()) == 0);
+ EXPECT_TRUE(std::strcmp("Qaag", currentLocaleInfo->GetScript()) == 0);
+ delete localeInfo;
+ localeInfo = nullptr;
+}
+
+/*
+ * @tc.name: LocaleInfoGetLanguageTest001
+ * @tc.desc: Test LocaleInfo GetLanguage
+ * @tc.type: FUNC
+ */
+HWTEST_F(LocaleInfoTest, LocaleInfoGetLanguageTest001, TestSize.Level1)
+{
+ RState state = SUCCESS;
+ LocaleInfo* localeInfo = BuildFromString("zh-CN", '-', state);
+ if (localeInfo == nullptr) {
+ EXPECT_TRUE(false);
+ return;
+ }
+ EXPECT_TRUE(std::strcmp("zh", localeInfo->GetLanguage()) == 0);
+ delete localeInfo;
+ localeInfo = nullptr;
+}
+
+/*
+ * @tc.name: LocaleInfoGetRegionTest001
+ * @tc.desc: Test LocaleInfo GetRegion
+ * @tc.type: FUNC
+ */
+HWTEST_F(LocaleInfoTest, LocaleInfoGetRegionTest001, TestSize.Level1)
+{
+ RState state = SUCCESS;
+ LocaleInfo* localeInfo = BuildFromString("zh-CN", '-', state);
+ if (localeInfo == nullptr) {
+ EXPECT_TRUE(false);
+ return;
+ }
+ EXPECT_TRUE(std::strcmp("CN", localeInfo->GetRegion()) == 0);
+ delete localeInfo;
+ localeInfo = nullptr;
+}
+
+/*
+ * @tc.name: LocaleInfoGetScriptTest001
+ * @tc.desc: Test LocaleInfo GetScript
+ * @tc.type: FUNC
+ */
+HWTEST_F(LocaleInfoTest, LocaleInfoGetScriptTest001, TestSize.Level1)
+{
+ RState state = SUCCESS;
+ LocaleInfo* localeInfo = BuildFromString("zh-Hant-CN", '-', state);
+ if (localeInfo == nullptr) {
+ EXPECT_TRUE(false);
+ return;
+ }
+ EXPECT_TRUE(std::strcmp("Hant", localeInfo->GetScript()) == 0);
+ delete localeInfo;
+ localeInfo = nullptr;
+}
+
+/*
+ * @tc.name: LocaleInfoBuildFromPartsTest001
+ * @tc.desc: Test BuildFromParts
+ * @tc.type: FUNC
+ */
+HWTEST_F(LocaleInfoTest, LocaleInfoBuildFromPartsTest001, TestSize.Level1)
+{
+ RState state = SUCCESS;
+ LocaleInfo* localeInfo = BuildFromParts("zh", "Hant", "CN", state);
+ if (localeInfo == nullptr) {
+ EXPECT_TRUE(false);
+ return;
+ }
+ EXPECT_TRUE(state == SUCCESS);
+ EXPECT_TRUE(std::strcmp("zh", localeInfo->GetLanguage()) == 0);
+ EXPECT_TRUE(std::strcmp("Hant", localeInfo->GetScript()) == 0);
+ EXPECT_TRUE(std::strcmp("CN", localeInfo->GetRegion()) == 0);
+ delete localeInfo;
+ localeInfo = nullptr;
+}
+
+/*
+ * @tc.name: LocaleInfoBuildFromPartsTest002
+ * @tc.desc: Test BuildFromParts
+ * @tc.type: FUNC
+ */
+HWTEST_F(LocaleInfoTest, LocaleInfoBuildFromPartsTest002, TestSize.Level1)
+{
+ RState state = SUCCESS;
+ LocaleInfo* localeInfo = BuildFromParts("zh1", "Hant", "CN", state);
+ EXPECT_TRUE(state == INVALID_BCP47_LANGUAGE_SUBTAG);
+ EXPECT_TRUE(localeInfo == nullptr);
+ delete localeInfo;
+ localeInfo = nullptr;
+}
+
+/*
+ * @tc.name: LocaleInfoBuildFromPartsTest003
+ * @tc.desc: Test BuildFromParts
+ * @tc.type: FUNC
+ */
+HWTEST_F(LocaleInfoTest, LocaleInfoBuildFromPartsTest003, TestSize.Level1)
+{
+ RState state = SUCCESS;
+ LocaleInfo* localeInfo = BuildFromParts("zh", "Hants", "CN", state);
+ EXPECT_TRUE(state == INVALID_BCP47_SCRIPT_SUBTAG);
+ EXPECT_TRUE(localeInfo == nullptr);
+ delete localeInfo;
+ localeInfo = nullptr;
+}
+
+/*
+ * @tc.name: LocaleInfoBuildFromPartsTest004
+ * @tc.desc: Test BuildFromParts
+ * @tc.type: FUNC
+ */
+HWTEST_F(LocaleInfoTest, LocaleInfoBuildFromPartsTest004, TestSize.Level1)
+{
+ RState state = SUCCESS;
+ LocaleInfo* localeInfo = BuildFromParts("zh", "Hant", "C", state);
+ EXPECT_TRUE(state == INVALID_BCP47_REGION_SUBTAG);
+ EXPECT_TRUE(localeInfo == nullptr);
+ delete localeInfo;
+ localeInfo = nullptr;
+}
+
+/*
+ * @tc.name: LocaleInfoBuildFromPartsTest005
+ * @tc.desc: Test BuildFromParts
+ * @tc.type: FUNC
+ */
+HWTEST_F(LocaleInfoTest, LocaleInfoBuildFromPartsTest005, TestSize.Level1)
+{
+ RState state = SUCCESS;
+ LocaleInfo* localeInfo = BuildFromParts(nullptr, "Hants", "CN", state);
+ EXPECT_TRUE(state == INVALID_BCP47_LANGUAGE_SUBTAG);
+ EXPECT_TRUE(localeInfo == nullptr);
+ delete localeInfo;
+ localeInfo = nullptr;
+}
+
+/*
+ * @tc.name: LocaleInfoBuildFromPartsTest006
+ * @tc.desc: Test BuildFromParts
+ * @tc.type: FUNC
+ */
+HWTEST_F(LocaleInfoTest, LocaleInfoBuildFromPartsTest006, TestSize.Level1)
+{
+ RState state = SUCCESS;
+ LocaleInfo* localeInfo = BuildFromParts("zh", nullptr, nullptr, state);
+ if (localeInfo == nullptr) {
+ EXPECT_TRUE(false);
+ return;
+ }
+ EXPECT_TRUE(state == SUCCESS);
+ EXPECT_TRUE(std::strcmp("zh", localeInfo->GetLanguage()) == 0);
+ EXPECT_TRUE(localeInfo->GetScript() == nullptr);
+ EXPECT_TRUE(localeInfo->GetRegion() == nullptr);
+ delete localeInfo;
+ localeInfo = nullptr;
+}
+
+/*
+ * @tc.name: LocaleInfoBuildFromStringTest001
+ * @tc.desc: Test BuildFromString
+ * @tc.type: FUNC
+ */
+HWTEST_F(LocaleInfoTest, LocaleInfoBuildFromStringTest001, TestSize.Level1)
+{
+ RState state = SUCCESS;
+ LocaleInfo* localeInfo = BuildFromString("zh-Hant-CN", '-', state);
+ if (localeInfo == nullptr) {
+ EXPECT_TRUE(false);
+ return;
+ }
+ EXPECT_TRUE(state == SUCCESS);
+ EXPECT_TRUE(std::strcmp("zh", localeInfo->GetLanguage()) == 0);
+ EXPECT_TRUE(std::strcmp("Hant", localeInfo->GetScript()) == 0);
+ EXPECT_TRUE(std::strcmp("CN", localeInfo->GetRegion()) == 0);
+ delete localeInfo;
+ localeInfo = nullptr;
+}
+
+/*
+ * @tc.name: LocaleInfoBuildFromStringTest002
+ * @tc.desc: Test BuildFromString
+ * @tc.type: FUNC
+ */
+HWTEST_F(LocaleInfoTest, LocaleInfoBuildFromStringTest002, TestSize.Level1)
+{
+ RState state = SUCCESS;
+ LocaleInfo* localeInfo = BuildFromString("zh1-Hant-CN", '-', state);
+ EXPECT_TRUE(state == INVALID_BCP47_LANGUAGE_SUBTAG);
+ EXPECT_TRUE(localeInfo == nullptr);
+ delete localeInfo;
+ localeInfo = nullptr;
+}
+
+/*
+ * @tc.name: LocaleInfoBuildFromStringTest003
+ * @tc.desc: Test BuildFromString
+ * @tc.type: FUNC
+ */
+HWTEST_F(LocaleInfoTest, LocaleInfoBuildFromStringTest003, TestSize.Level1)
+{
+ RState state = SUCCESS;
+ LocaleInfo* localeInfo = BuildFromString("-Hant-CN", '-', state);
+ EXPECT_TRUE(state == INVALID_BCP47_LANGUAGE_SUBTAG);
+ EXPECT_TRUE(localeInfo == nullptr);
+ delete localeInfo;
+ localeInfo = nullptr;
+}
+
+/*
+ * @tc.name: LocaleInfoBuildFromStringTest004
+ * @tc.desc: Test BuildFromString
+ * @tc.type: FUNC
+ */
+HWTEST_F(LocaleInfoTest, LocaleInfoBuildFromStringTest004, TestSize.Level1)
+{
+ RState state = SUCCESS;
+ LocaleInfo* localeInfo = BuildFromString("zh", '-', state);
+ if (localeInfo == nullptr) {
+ EXPECT_TRUE(false);
+ return;
+ }
+ EXPECT_TRUE(state == SUCCESS);
+ EXPECT_TRUE(std::strcmp("zh", localeInfo->GetLanguage()) == 0);
+ EXPECT_TRUE(localeInfo->GetScript() == nullptr);
+ EXPECT_TRUE(localeInfo->GetRegion() == nullptr);
+ delete localeInfo;
+ localeInfo = nullptr;
+}
+
+/*
+ * @tc.name: LocaleInfoBuildFromStringTest005
+ * @tc.desc: Test BuildFromString
+ * @tc.type: FUNC
+ */
+HWTEST_F(LocaleInfoTest, LocaleInfoBuildFromStringTest005, TestSize.Level1)
+{
+ RState state = SUCCESS;
+ LocaleInfo* localeInfo = BuildFromString("en_US", '_', state);
+ if (localeInfo == nullptr) {
+ EXPECT_TRUE(false);
+ return;
+ }
+ EXPECT_TRUE(state == SUCCESS);
+ EXPECT_TRUE(std::strcmp("en", localeInfo->GetLanguage()) == 0);
+ EXPECT_TRUE(localeInfo->GetScript() == nullptr);
+ EXPECT_TRUE(std::strcmp("US", localeInfo->GetRegion()) == 0);
+ delete localeInfo;
+ localeInfo = nullptr;
+}
+
+/*
+ * @tc.name: LocaleInfoBuildFromStringTest006
+ * @tc.desc: Test BuildFromString
+ * @tc.type: FUNC
+ */
+HWTEST_F(LocaleInfoTest, LocaleInfoBuildFromStringTest006, TestSize.Level1)
+{
+ RState state = SUCCESS;
+ LocaleInfo* localeInfo = BuildFromString("en_Latn_US", '&', state);
+ EXPECT_TRUE(state == NOT_SUPPORT_SEP);
+ EXPECT_TRUE(localeInfo == nullptr);
+ delete localeInfo;
+ localeInfo = nullptr;
+}
+
+/*
+ * @tc.name: LocaleInfoBuildFromStringTest007
+ * @tc.desc: Test BuildFromString
+ * @tc.type: FUNC
+ */
+HWTEST_F(LocaleInfoTest, LocaleInfoBuildFromStringTest007, TestSize.Level1)
+{
+ RState state = SUCCESS;
+ LocaleInfo* localeInfo = BuildFromString("en_Latn_US", '_', state);
+ if (localeInfo == nullptr) {
+ EXPECT_TRUE(false);
+ return;
+ }
+ EXPECT_TRUE(state == SUCCESS);
+ EXPECT_TRUE(std::strcmp("en", localeInfo->GetLanguage()) == 0);
+ EXPECT_TRUE(std::strcmp("Latn", localeInfo->GetScript()) == 0);
+ EXPECT_TRUE(std::strcmp("US", localeInfo->GetRegion()) == 0);
+ delete localeInfo;
+ localeInfo = nullptr;
+}
+
+/*
+ * @tc.name: LocaleInfoBuildFromStringTest008
+ * @tc.desc: Test BuildFromString
+ * @tc.type: FUNC
+ */
+HWTEST_F(LocaleInfoTest, LocaleInfoBuildFromStringTest008, TestSize.Level1)
+{
+ RState state = SUCCESS;
+ LocaleInfo* localeInfo = BuildFromString("zh-Hants-CN", '-', state);
+ EXPECT_TRUE(state == INVALID_BCP47_SCRIPT_SUBTAG);
+ EXPECT_TRUE(localeInfo == nullptr);
+ delete localeInfo;
+ localeInfo = nullptr;
+}
+
+/*
+ * @tc.name: LocaleInfoBuildFromStringTest009
+ * @tc.desc: Test BuildFromString
+ * @tc.type: FUNC
+ */
+HWTEST_F(LocaleInfoTest, LocaleInfoBuildFromStringTest009, TestSize.Level1)
+{
+ RState state = SUCCESS;
+ LocaleInfo* localeInfo = BuildFromString("zh-Hant-C", '-', state);
+ EXPECT_TRUE(state == INVALID_BCP47_REGION_SUBTAG);
+ EXPECT_TRUE(localeInfo == nullptr);
+ delete localeInfo;
+ localeInfo = nullptr;
+}
+
+/*
+ * @tc.name: LocaleInfoBuildFromStringTest0010
+ * @tc.desc: Test BuildFromString
+ * @tc.type: FUNC
+ */
+HWTEST_F(LocaleInfoTest, LocaleInfoBuildFromStringTest0010, TestSize.Level1)
+{
+ RState state = SUCCESS;
+ LocaleInfo* localeInfo = BuildFromString("zh-CN-xxxx", '-', state);
+ if (localeInfo == nullptr) {
+ EXPECT_TRUE(false);
+ return;
+ }
+ EXPECT_TRUE(state == SUCCESS);
+ EXPECT_TRUE(std::strcmp("zh", localeInfo->GetLanguage()) == 0);
+ EXPECT_TRUE(localeInfo->GetScript() == nullptr);
+ EXPECT_TRUE(std::strcmp("CN", localeInfo->GetRegion()) == 0);
+ delete localeInfo;
+ localeInfo = nullptr;
+}
+
+/*
+ * @tc.name: LocaleInfoPerformanceFuncTest001
+ * @tc.desc: Test FindAndSort Performance
+ * @tc.type: FUNC
+ */
+HWTEST_F(LocaleInfoTest, LocaleInfoPerformanceFuncTest001, TestSize.Level1)
+{
+ unsigned long long total = 0;
+ double average = 0;
+ std::vector outValue;
+ for (int k = 0; k < 1000; ++k) {
+ auto t1 = std::chrono::high_resolution_clock::now();
+ std::vector request;
+ std::vector outValue;
+ request.push_back("en");
+ request.push_back("en-CN");
+ request.push_back("en-US");
+ request.push_back("en-GB");
+ request.push_back("");
+ std::string current = "en-US";
+ FindAndSort(current, request, outValue);
+ auto t2 = std::chrono::high_resolution_clock::now();
+ total += std::chrono::duration_cast(t2 - t1).count();
+ }
+ average = total / 1000.0;
+ HILOG_DEBUG("avg cost FindAndSort: %f us", average);
+ EXPECT_LT(average, 500);
+};
\ No newline at end of file
diff --git a/global_lite/i18n_lite/resource_parse_load/src/locale_info_test.h b/global_lite/i18n_lite/resource_parse_load/src/locale_info_test.h
new file mode 100755
index 0000000000000000000000000000000000000000..6512ab3cb0f20178afe6aed75e4afa820c104cba
--- /dev/null
+++ b/global_lite/i18n_lite/resource_parse_load/src/locale_info_test.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef RESOURCE_MANAGER_LOCALE_INFO_TEST_H
+#define RESOURCE_MANAGER_LOCALE_INFO_TEST_H
+
+int LocaleInfoFindAndSortTest001();
+int LocaleInfoFindAndSortTest002();
+int LocaleInfoFindAndSortTest003();
+int LocaleInfoFindAndSortTest004();
+int LocaleInfoFindAndSortTest005();
+int LocaleInfoUpdateSysDefaultTest001();
+int LocaleInfoGetSysDefaultTest001();
+int LocaleInfoGetLanguageTest001();
+int LocaleInfoGetRegionTest001();
+int LocaleInfoGetScriptTest001();
+int LocaleInfoBuildFromPartsTest001();
+int LocaleInfoBuildFromPartsTest002();
+int LocaleInfoBuildFromPartsTest003();
+int LocaleInfoBuildFromPartsTest004();
+int LocaleInfoBuildFromPartsTest005();
+int LocaleInfoBuildFromPartsTest006();
+int LocaleInfoBuildFromStringTest001();
+int LocaleInfoBuildFromStringTest002();
+int LocaleInfoBuildFromStringTest003();
+int LocaleInfoBuildFromStringTest004();
+int LocaleInfoBuildFromStringTest005();
+int LocaleInfoBuildFromStringTest006();
+int LocaleInfoBuildFromStringTest007();
+int LocaleInfoBuildFromStringTest008();
+int LocaleInfoBuildFromStringTest009();
+int LocaleInfoBuildFromStringTest0010();
+int LocaleInfoPerformanceFuncTest001();
+
+#endif // RESOURCE_MANAGER_LOCALE_INFO_TEST_H
diff --git a/global_lite/i18n_lite/resource_parse_load/src/res_config_impl_test.cpp b/global_lite/i18n_lite/resource_parse_load/src/res_config_impl_test.cpp
new file mode 100755
index 0000000000000000000000000000000000000000..b58d3b84b3e54fbf4bcaddf202e8b19b12a8d52e
--- /dev/null
+++ b/global_lite/i18n_lite/resource_parse_load/src/res_config_impl_test.cpp
@@ -0,0 +1,1395 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "res_config_impl_test.h"
+
+#include
+#include
+#include
+
+#include "res_config_impl.h"
+#include "test_common.h"
+
+using namespace OHOS::Global::Resource;
+using namespace testing::ext;
+
+class ResConfigImplTest : public testing::Test {
+public:
+ static void SetUpTestCase(void);
+
+ static void TearDownTestCase(void);
+
+ void SetUp();
+
+ void TearDown();
+};
+
+void ResConfigImplTest::SetUpTestCase(void)
+{
+ // step 1: input testsuit setup step
+}
+
+void ResConfigImplTest::TearDownTestCase(void)
+{
+ // step 2: input testsuit teardown step
+}
+
+void ResConfigImplTest::SetUp()
+{
+}
+
+void ResConfigImplTest::TearDown()
+{
+}
+
+ResConfigImpl *CreateResConfigImpl(const char *language, const char *script, const char *region)
+{
+ ResConfigImpl *resConfigImpl = new ResConfigImpl;
+ resConfigImpl->SetLocaleInfo(language, script, region);
+ return resConfigImpl;
+}
+
+/*
+ * @tc.name: ResConfigImplMatchTest001
+ * @tc.desc: Test ResConfig Match
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplMatchTest001, TestSize.Level1)
+{
+ ResConfigImpl *other = CreateResConfigImpl(nullptr, nullptr, nullptr);
+ ResConfigImpl *current = CreateResConfigImpl("fr", nullptr, "CA");
+ EXPECT_TRUE(current->Match(other));
+ delete current;
+ delete other;
+};
+
+/*
+ * @tc.name: ResConfigImplMatchTest002
+ * @tc.desc: Test ResConfig Match
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplMatchTest002, TestSize.Level1)
+{
+ ResConfigImpl *other = CreateResConfigImpl("en", nullptr, "CA");
+ ResConfigImpl *current = CreateResConfigImpl("fr", nullptr, "CA");
+ EXPECT_FALSE(current->Match(other));
+ delete current;
+ delete other;
+};
+
+/*
+ * @tc.name: ResConfigImplMatchTest003
+ * @tc.desc: Test ResConfig Match
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplMatchTest003, TestSize.Level1)
+{
+ ResConfigImpl *other = CreateResConfigImpl("tl", nullptr, "PH");
+ ResConfigImpl *current = CreateResConfigImpl("fil", nullptr, "PH");
+ EXPECT_TRUE(current->Match(other));
+ delete current;
+ delete other;
+};
+
+/*
+ * @tc.name: ResConfigImplMatchTest004
+ * @tc.desc: Test ResConfig Match
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplMatchTest004, TestSize.Level1)
+{
+ ResConfigImpl *other = CreateResConfigImpl("qaa", nullptr, nullptr);
+ ResConfigImpl *current = CreateResConfigImpl("qaa", nullptr, "CA");
+ EXPECT_TRUE(current->Match(other));
+ delete current;
+ delete other;
+};
+
+/*
+ * @tc.name: ResConfigImplMatchTest005
+ * @tc.desc: Test ResConfig Match
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplMatchTest005, TestSize.Level1)
+{
+ ResConfigImpl *other = CreateResConfigImpl("qaa", nullptr, "CA");
+ ResConfigImpl *current = CreateResConfigImpl("qaa", nullptr, "CA");
+ EXPECT_TRUE(current->Match(other));
+ delete current;
+ delete other;
+};
+
+/*
+ * @tc.name: ResConfigImplMatchTest006
+ * @tc.desc: Test ResConfig Match
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplMatchTest006, TestSize.Level1)
+{
+ ResConfigImpl *other = CreateResConfigImpl("az", nullptr, nullptr);
+ ResConfigImpl *current = CreateResConfigImpl("az", "Latn", nullptr);
+ EXPECT_TRUE(current->Match(other));
+ delete current;
+ delete other;
+};
+
+/*
+ * @tc.name: ResConfigImplMatchTest007
+ * @tc.desc: Test ResConfig Match
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplMatchTest007, TestSize.Level1)
+{
+ ResConfigImpl *other = CreateResConfigImpl("az", nullptr, "IR");
+ ResConfigImpl *current = CreateResConfigImpl("az", "Arab", nullptr);
+ EXPECT_TRUE(current->Match(other));
+ delete current;
+ delete other;
+};
+
+/*
+ * @tc.name: ResConfigImplMatchTest008
+ * @tc.desc: Test ResConfig Match
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplMatchTest008, TestSize.Level1)
+{
+ ResConfigImpl *other = CreateResConfigImpl("ar", nullptr, "EG");
+ ResConfigImpl *current = CreateResConfigImpl("ar", nullptr, "TN");
+ EXPECT_TRUE(current->Match(other));
+ delete current;
+ delete other;
+};
+
+/*
+ * @tc.name: ResConfigImplMatchTest009
+ * @tc.desc: Test ResConfig Match
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplMatchTest009, TestSize.Level1)
+{
+ ResConfigImpl *other = CreateResConfigImpl("qaa", "Latn", "FR");
+ ResConfigImpl *current = CreateResConfigImpl("qaa", nullptr, "CA");
+ EXPECT_FALSE(current->Match(other));
+ delete current;
+ delete other;
+};
+
+/*
+ * @tc.name: ResConfigImplMatchTest010
+ * @tc.desc: Test ResConfig Match
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplMatchTest010, TestSize.Level1)
+{
+ ResConfigImpl *other = CreateResConfigImpl("qaa", nullptr, "FR");
+ ResConfigImpl *current = CreateResConfigImpl("qaa", "Latn", "CA");
+ EXPECT_FALSE(current->Match(other));
+ delete current;
+ delete other;
+};
+
+/*
+ * @tc.name: ResConfigImplMatchTest011
+ * @tc.desc: Test ResConfig Match
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplMatchTest011, TestSize.Level1)
+{
+ ResConfigImpl *other = CreateResConfigImpl("az", nullptr, nullptr);
+ ResConfigImpl *current = CreateResConfigImpl("az", "Cyrl", nullptr);
+ EXPECT_FALSE(current->Match(other));
+ delete current;
+ delete other;
+};
+
+/*
+ * @tc.name: ResConfigImplMatchTest012
+ * @tc.desc: Test ResConfig Match
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplMatchTest012, TestSize.Level1)
+{
+ ResConfigImpl *other = CreateResConfigImpl("az", nullptr, nullptr);
+ ResConfigImpl *current = CreateResConfigImpl("az", nullptr, "IR");
+ EXPECT_FALSE(current->Match(other));
+ delete current;
+ delete other;
+};
+
+/*
+ * @tc.name: ResConfigImplMatchTest013
+ * @tc.desc: Test ResConfig Match
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplMatchTest013, TestSize.Level1)
+{
+ ResConfigImpl *other = CreateResConfigImpl("qaa", nullptr, "FR");
+ ResConfigImpl *current = CreateResConfigImpl("qaa", nullptr, "CA");
+ EXPECT_FALSE(current->Match(other));
+ delete current;
+ delete other;
+};
+
+/*
+ * @tc.name: ResConfigImplMatchTest014
+ * @tc.desc: Test ResConfig Match
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplMatchTest014, TestSize.Level1)
+{
+ ResConfigImpl *other = CreateResConfigImpl("he", nullptr, nullptr);
+ ResConfigImpl *current = CreateResConfigImpl("iw", nullptr, nullptr);
+ EXPECT_TRUE(current->Match(other));
+ EXPECT_TRUE(other->Match(current));
+ delete current;
+ delete other;
+};
+
+/*
+ * @tc.name: ResConfigImplMatchTest015
+ * @tc.desc: Test ResConfig Match
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplMatchTest015, TestSize.Level1)
+{
+ ResConfigImpl *other = CreateResConfigImpl("ji", nullptr, nullptr);
+ ResConfigImpl *current = CreateResConfigImpl("yi", nullptr, nullptr);
+ EXPECT_TRUE(current->Match(other));
+ EXPECT_TRUE(other->Match(current));
+ delete current;
+ delete other;
+};
+
+/*
+ * @tc.name: ResConfigImplMatchTest016
+ * @tc.desc: Test ResConfig Match
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplMatchTest016, TestSize.Level1)
+{
+ ResConfigImpl *other = CreateResConfigImpl("jw", nullptr, nullptr);
+ ResConfigImpl *current = CreateResConfigImpl("jv", nullptr, nullptr);
+ EXPECT_TRUE(current->Match(other));
+ EXPECT_TRUE(other->Match(current));
+ delete current;
+ delete other;
+};
+
+/*
+ * @tc.name: ResConfigImplMatchTest017
+ * @tc.desc: Test ResConfig Match
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplMatchTest017, TestSize.Level1)
+{
+ ResConfigImpl *other = CreateResConfigImpl("in", nullptr, nullptr);
+ ResConfigImpl *current = CreateResConfigImpl("id", nullptr, nullptr);
+ EXPECT_TRUE(current->Match(other));
+ EXPECT_TRUE(other->Match(current));
+ delete current;
+ delete other;
+};
+
+/*
+ * @tc.name: ResConfigImplMatchTest018
+ * @tc.desc: Test ResConfig Match
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplMatchTest018, TestSize.Level1)
+{
+ ResConfigImpl *other = CreateResConfigImpl("en", "Latn", nullptr);
+ ResConfigImpl *current = CreateResConfigImpl("en", "Qaag", nullptr);
+ EXPECT_TRUE(current->Match(other));
+ delete current;
+ delete other;
+};
+
+/*
+ * @tc.name: ResConfigImplMatchTest019
+ * @tc.desc: Test ResConfig Match
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplMatchTest019, TestSize.Level1)
+{
+ ResConfigImpl *other = CreateResConfigImpl("en", nullptr, nullptr);
+ ResConfigImpl *current = CreateResConfigImpl("en", nullptr, nullptr);
+ current->SetDeviceType(DeviceType::DEVICE_CAR);
+ other->SetDeviceType(DeviceType::DEVICE_CAR);
+ EXPECT_TRUE(current->Match(other));
+ delete current;
+ delete other;
+};
+
+/*
+ * @tc.name: ResConfigImplMatchTest020
+ * @tc.desc: Test ResConfig Match
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplMatchTest020, TestSize.Level1)
+{
+ ResConfigImpl *other = CreateResConfigImpl("en", nullptr, nullptr);
+ ResConfigImpl *current = CreateResConfigImpl("en", nullptr, nullptr);
+ current->SetDeviceType(DeviceType::DEVICE_CAR);
+ other->SetDeviceType(DeviceType::DEVICE_PC);
+ EXPECT_FALSE(current->Match(other));
+ delete current;
+ delete other;
+};
+
+/*
+ * @tc.name: ResConfigImplMatchTest021
+ * @tc.desc: Test ResConfig Match
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplMatchTest021, TestSize.Level1)
+{
+ ResConfigImpl *other = CreateResConfigImpl("en", nullptr, nullptr);
+ ResConfigImpl *current = CreateResConfigImpl("en", nullptr, nullptr);
+ other->SetDeviceType(DeviceType::DEVICE_PC);
+ EXPECT_TRUE(current->Match(other));
+ delete current;
+ delete other;
+};
+
+/*
+ * @tc.name: ResConfigImplMatchTest022
+ * @tc.desc: Test ResConfig Match
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplMatchTest022, TestSize.Level1)
+{
+ ResConfigImpl *other = CreateResConfigImpl("en", nullptr, nullptr);
+ ResConfigImpl *current = CreateResConfigImpl("en", nullptr, nullptr);
+ current->SetDeviceType(DeviceType::DEVICE_PC);
+ EXPECT_TRUE(current->Match(other));
+ delete current;
+ delete other;
+};
+
+/*
+ * @tc.name: ResConfigImplMatchTest023
+ * @tc.desc: Test ResConfig Match
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplMatchTest023, TestSize.Level1)
+{
+ ResConfigImpl *other = CreateResConfigImpl("en", nullptr, nullptr);
+ ResConfigImpl *current = CreateResConfigImpl("en", nullptr, nullptr);
+ current->SetDirection(Direction::DIRECTION_HORIZONTAL);
+ other->SetDirection(Direction::DIRECTION_HORIZONTAL);
+ EXPECT_TRUE(current->Match(other));
+ delete current;
+ delete other;
+};
+
+/*
+ * @tc.name: ResConfigImplMatchTest024
+ * @tc.desc: Test ResConfig Match
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplMatchTest024, TestSize.Level1)
+{
+ ResConfigImpl *other = CreateResConfigImpl("en", nullptr, nullptr);
+ ResConfigImpl *current = CreateResConfigImpl("en", nullptr, nullptr);
+ current->SetDirection(Direction::DIRECTION_HORIZONTAL);
+ other->SetDirection(Direction::DIRECTION_VERTICAL);
+ EXPECT_FALSE(current->Match(other));
+ delete current;
+ delete other;
+};
+
+/*
+ * @tc.name: ResConfigImplMatchTest025
+ * @tc.desc: Test ResConfig Match
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplMatchTest025, TestSize.Level1)
+{
+ ResConfigImpl *other = CreateResConfigImpl("en", nullptr, nullptr);
+ ResConfigImpl *current = CreateResConfigImpl("en", nullptr, nullptr);
+ other->SetDirection(Direction::DIRECTION_HORIZONTAL);
+ EXPECT_TRUE(current->Match(other));
+ delete current;
+ delete other;
+};
+
+/*
+ * @tc.name: ResConfigImplMatchTest026
+ * @tc.desc: Test ResConfig Match
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplMatchTest026, TestSize.Level1)
+{
+ ResConfigImpl *other = CreateResConfigImpl("en", nullptr, nullptr);
+ ResConfigImpl *current = CreateResConfigImpl("en", nullptr, nullptr);
+ current->SetDirection(Direction::DIRECTION_VERTICAL);
+ EXPECT_TRUE(current->Match(other));
+ delete current;
+ delete other;
+};
+
+/*
+ * @tc.name: ResConfigImplMatchTest027
+ * @tc.desc: Test ResConfig Match
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplMatchTest027, TestSize.Level1)
+{
+ ResConfigImpl *other = CreateResConfigImpl("en", nullptr, nullptr);
+ ResConfigImpl *current = CreateResConfigImpl("en", nullptr, nullptr);
+ current->SetDirection(Direction::DIRECTION_VERTICAL);
+ current->SetDeviceType(DeviceType::DEVICE_PHONE);
+ other->SetDirection(Direction::DIRECTION_VERTICAL);
+ other->SetDeviceType(DeviceType::DEVICE_PHONE);
+ EXPECT_TRUE(current->Match(other));
+ delete current;
+ delete other;
+};
+
+/*
+ * @tc.name: ResConfigImplMatchTest028
+ * @tc.desc: Test ResConfig Match
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplMatchTest028, TestSize.Level1)
+{
+ ResConfigImpl *other = CreateResConfigImpl("en", nullptr, nullptr);
+ ResConfigImpl *current = CreateResConfigImpl("en", nullptr, nullptr);
+ current->SetDirection(Direction::DIRECTION_VERTICAL);
+ current->SetDeviceType(DeviceType::DEVICE_PHONE);
+ other->SetDeviceType(DeviceType::DEVICE_PHONE);
+ EXPECT_TRUE(current->Match(other));
+ delete current;
+ delete other;
+};
+
+/*
+ * @tc.name: ResConfigImplMatchTest029
+ * @tc.desc: Test ResConfig Match
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplMatchTest029, TestSize.Level1)
+{
+ ResConfigImpl *other = CreateResConfigImpl("en", nullptr, nullptr);
+ ResConfigImpl *current = CreateResConfigImpl("en", nullptr, nullptr);
+ current->SetDirection(Direction::DIRECTION_VERTICAL);
+ current->SetDeviceType(DeviceType::DEVICE_PHONE);
+ other->SetDeviceType(DeviceType::DEVICE_PHONE);
+ other->SetDirection(Direction::DIRECTION_HORIZONTAL);
+ EXPECT_FALSE(current->Match(other));
+ delete current;
+ delete other;
+};
+
+/*
+ * @tc.name: ResConfigImplIsMoreSuitableTest001
+ * @tc.desc: Test ResConfig IsMoreSuitable
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplIsMoreSuitableTest001, TestSize.Level1)
+{
+ ResConfigImpl *request = CreateResConfigImpl(nullptr, nullptr, nullptr);
+ ResConfigImpl *current = CreateResConfigImpl("fr", nullptr, "FR");
+ ResConfigImpl *other = CreateResConfigImpl("fr", nullptr, "CA");
+ EXPECT_TRUE(current->IsMoreSuitable(other, request));
+ EXPECT_TRUE(other->IsMoreSuitable(current, request));
+ delete request;
+ delete current;
+ delete other;
+}
+
+/*
+ * @tc.name: ResConfigImplIsMoreSuitableTest002
+ * @tc.desc: Test ResConfig IsMoreSuitable
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplIsMoreSuitableTest002, TestSize.Level1)
+{
+ ResConfigImpl *request = CreateResConfigImpl("fr", nullptr, "CA");
+ ResConfigImpl *current = CreateResConfigImpl(nullptr, nullptr, nullptr);
+ ResConfigImpl *other = CreateResConfigImpl(nullptr, nullptr, nullptr);
+ EXPECT_TRUE(current->IsMoreSuitable(other, request));
+ EXPECT_TRUE(other->IsMoreSuitable(current, request));
+ delete request;
+ delete current;
+ delete other;
+}
+
+/*
+ * @tc.name: ResConfigImplIsMoreSuitableTest003
+ * @tc.desc: Test ResConfig IsMoreSuitable
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplIsMoreSuitableTest003, TestSize.Level1)
+{
+ ResConfigImpl *request = CreateResConfigImpl("fr", nullptr, "CA");
+ ResConfigImpl *current = CreateResConfigImpl("fr", nullptr, "FR");
+ ResConfigImpl *other = CreateResConfigImpl(nullptr, nullptr, nullptr);
+ EXPECT_TRUE(current->IsMoreSuitable(other, request));
+ EXPECT_FALSE(other->IsMoreSuitable(current, request));
+ delete request;
+ delete current;
+ delete other;
+}
+
+/*
+ * @tc.name: ResConfigImplIsMoreSuitableTest004
+ * @tc.desc: Test ResConfig IsMoreSuitable
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplIsMoreSuitableTest004, TestSize.Level1)
+{
+ ResConfigImpl *request = CreateResConfigImpl("fil", nullptr, "PH");
+ ResConfigImpl *current = CreateResConfigImpl("tl", nullptr, "PH");
+ ResConfigImpl *other = CreateResConfigImpl("fil", nullptr, "US");
+ EXPECT_TRUE(current->IsMoreSuitable(other, request));
+ EXPECT_FALSE(other->IsMoreSuitable(current, request));
+ delete request;
+ delete current;
+ delete other;
+}
+
+/*
+ * @tc.name: ResConfigImplIsMoreSuitableTest005
+ * @tc.desc: Test ResConfig IsMoreSuitable
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplIsMoreSuitableTest005, TestSize.Level1)
+{
+ ResConfigImpl *request = CreateResConfigImpl("fil", nullptr, "PH");
+ ResConfigImpl *current = CreateResConfigImpl("fil", nullptr, "PH");
+ ResConfigImpl *other = CreateResConfigImpl("tl", nullptr, "PH");
+ EXPECT_TRUE(current->IsMoreSuitable(other, request));
+ EXPECT_FALSE(other->IsMoreSuitable(current, request));
+ delete request;
+ delete current;
+ delete other;
+}
+
+/*
+ * @tc.name: ResConfigImplIsMoreSuitableTest006
+ * @tc.desc: Test ResConfig IsMoreSuitable
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplIsMoreSuitableTest006, TestSize.Level1)
+{
+ ResConfigImpl *request = CreateResConfigImpl("es", nullptr, "AR");
+ ResConfigImpl *current = CreateResConfigImpl("es", nullptr, "419");
+ ResConfigImpl *other = CreateResConfigImpl("es", nullptr, "419");
+ EXPECT_TRUE(current->IsMoreSuitable(other, request));
+ EXPECT_TRUE(other->IsMoreSuitable(current, request));
+ delete request;
+ delete current;
+ delete other;
+}
+
+/*
+ * @tc.name: ResConfigImplIsMoreSuitableTest007
+ * @tc.desc: Test ResConfig IsMoreSuitable
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplIsMoreSuitableTest007, TestSize.Level1)
+{
+ ResConfigImpl *request = CreateResConfigImpl("es", nullptr, "AR");
+ ResConfigImpl *current = CreateResConfigImpl("es", nullptr, "AR");
+ ResConfigImpl *other = CreateResConfigImpl("es", nullptr, "419");
+ EXPECT_TRUE(current->IsMoreSuitable(other, request));
+ EXPECT_FALSE(other->IsMoreSuitable(current, request));
+ delete request;
+ delete current;
+ delete other;
+}
+
+/*
+ * @tc.name: ResConfigImplIsMoreSuitableTest008
+ * @tc.desc: Test ResConfig IsMoreSuitable
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplIsMoreSuitableTest008, TestSize.Level1)
+{
+ ResConfigImpl *request = CreateResConfigImpl("es", nullptr, "AR");
+ ResConfigImpl *current = CreateResConfigImpl("es", nullptr, "419");
+ ResConfigImpl *other = CreateResConfigImpl("es", nullptr, nullptr);
+ EXPECT_TRUE(current->IsMoreSuitable(other, request));
+ EXPECT_FALSE(other->IsMoreSuitable(current, request));
+ delete request;
+ delete current;
+ delete other;
+}
+
+/*
+ * @tc.name: ResConfigImplIsMoreSuitableTest009
+ * @tc.desc: Test ResConfig IsMoreSuitable
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplIsMoreSuitableTest009, TestSize.Level1)
+{
+ ResConfigImpl *request = CreateResConfigImpl("es", nullptr, "AR");
+ ResConfigImpl *current = CreateResConfigImpl("es", nullptr, "419");
+ ResConfigImpl *other = CreateResConfigImpl("es", nullptr, "ES");
+ EXPECT_TRUE(current->IsMoreSuitable(other, request));
+ EXPECT_FALSE(other->IsMoreSuitable(current, request));
+ delete request;
+ delete current;
+ delete other;
+}
+
+/*
+ * @tc.name: ResConfigImplIsMoreSuitableTest010
+ * @tc.desc: Test ResConfig IsMoreSuitable
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplIsMoreSuitableTest010, TestSize.Level1)
+{
+ ResConfigImpl *request = CreateResConfigImpl("es", nullptr, "AR");
+ ResConfigImpl *current = CreateResConfigImpl("es", nullptr, nullptr);
+ ResConfigImpl *other = CreateResConfigImpl("es", nullptr, "ES");
+ EXPECT_TRUE(current->IsMoreSuitable(other, request));
+ EXPECT_FALSE(other->IsMoreSuitable(current, request));
+ delete request;
+ delete current;
+ delete other;
+}
+
+/*
+ * @tc.name: ResConfigImplIsMoreSuitableTest011
+ * @tc.desc: Test ResConfig IsMoreSuitable
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplIsMoreSuitableTest011, TestSize.Level1)
+{
+ ResConfigImpl *request = CreateResConfigImpl("es", nullptr, "AR");
+ ResConfigImpl *current = CreateResConfigImpl("es", nullptr, "PE");
+ ResConfigImpl *other = CreateResConfigImpl("es", nullptr, "ES");
+ EXPECT_TRUE(current->IsMoreSuitable(other, request));
+ EXPECT_FALSE(other->IsMoreSuitable(current, request));
+ delete request;
+ delete current;
+ delete other;
+}
+
+/*
+ * @tc.name: ResConfigImplIsMoreSuitableTest012
+ * @tc.desc: Test ResConfig IsMoreSuitable
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplIsMoreSuitableTest012, TestSize.Level1)
+{
+ ResConfigImpl *request = CreateResConfigImpl("es", nullptr, "AR");
+ ResConfigImpl *current = CreateResConfigImpl("es", nullptr, "AR");
+ ResConfigImpl *other = CreateResConfigImpl("es", nullptr, nullptr);
+ EXPECT_TRUE(current->IsMoreSuitable(other, request));
+ EXPECT_FALSE(other->IsMoreSuitable(current, request));
+ delete request;
+ delete current;
+ delete other;
+}
+
+/*
+ * @tc.name: ResConfigImplIsMoreSuitableTest013
+ * @tc.desc: Test ResConfig IsMoreSuitable
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplIsMoreSuitableTest013, TestSize.Level1)
+{
+ ResConfigImpl *request = CreateResConfigImpl("es", nullptr, "AR");
+ ResConfigImpl *current = CreateResConfigImpl("es", nullptr, "US");
+ ResConfigImpl *other = CreateResConfigImpl("es", nullptr, "BO");
+ EXPECT_TRUE(current->IsMoreSuitable(other, request));
+ EXPECT_FALSE(other->IsMoreSuitable(current, request));
+ delete request;
+ delete current;
+ delete other;
+}
+
+/*
+ * @tc.name: ResConfigImplIsMoreSuitableTest014
+ * @tc.desc: Test ResConfig IsMoreSuitable
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplIsMoreSuitableTest014, TestSize.Level1)
+{
+ ResConfigImpl *request = CreateResConfigImpl("es", nullptr, "IC");
+ ResConfigImpl *current = CreateResConfigImpl("es", nullptr, "ES");
+ ResConfigImpl *other = CreateResConfigImpl("es", nullptr, "GQ");
+ EXPECT_TRUE(current->IsMoreSuitable(other, request));
+ EXPECT_FALSE(other->IsMoreSuitable(current, request));
+ delete request;
+ delete current;
+ delete other;
+}
+
+/*
+ * @tc.name: ResConfigImplIsMoreSuitableTest015
+ * @tc.desc: Test ResConfig IsMoreSuitable
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplIsMoreSuitableTest015, TestSize.Level1)
+{
+ ResConfigImpl *request = CreateResConfigImpl("es", nullptr, "GQ");
+ ResConfigImpl *current = CreateResConfigImpl("es", nullptr, "IC");
+ ResConfigImpl *other = CreateResConfigImpl("es", nullptr, "419");
+ EXPECT_TRUE(current->IsMoreSuitable(other, request));
+ EXPECT_FALSE(other->IsMoreSuitable(current, request));
+ delete request;
+ delete current;
+ delete other;
+}
+
+/*
+ * @tc.name: ResConfigImplIsMoreSuitableTest016
+ * @tc.desc: Test ResConfig IsMoreSuitable
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplIsMoreSuitableTest016, TestSize.Level1)
+{
+ ResConfigImpl *request = CreateResConfigImpl("en", nullptr, "GB");
+ ResConfigImpl *current = CreateResConfigImpl("en", nullptr, "001");
+ ResConfigImpl *other = CreateResConfigImpl("en", nullptr, nullptr);
+ EXPECT_TRUE(current->IsMoreSuitable(other, request));
+ EXPECT_FALSE(other->IsMoreSuitable(current, request));
+ delete request;
+ delete current;
+ delete other;
+}
+
+/*
+ * @tc.name: ResConfigImplIsMoreSuitableTest017
+ * @tc.desc: Test ResConfig IsMoreSuitable
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplIsMoreSuitableTest017, TestSize.Level1)
+{
+ ResConfigImpl *request = CreateResConfigImpl("en", nullptr, "PR");
+ ResConfigImpl *current = CreateResConfigImpl("en", nullptr, nullptr);
+ ResConfigImpl *other = CreateResConfigImpl("en", nullptr, "001");
+ EXPECT_TRUE(current->IsMoreSuitable(other, request));
+ EXPECT_FALSE(other->IsMoreSuitable(current, request));
+ delete request;
+ delete current;
+ delete other;
+}
+
+/*
+ * @tc.name: ResConfigImplIsMoreSuitableTest018
+ * @tc.desc: Test ResConfig IsMoreSuitable
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplIsMoreSuitableTest018, TestSize.Level1)
+{
+ ResConfigImpl *request = CreateResConfigImpl("en", nullptr, "DE");
+ ResConfigImpl *current = CreateResConfigImpl("en", nullptr, "150");
+ ResConfigImpl *other = CreateResConfigImpl("en", nullptr, "001");
+ EXPECT_TRUE(current->IsMoreSuitable(other, request));
+ EXPECT_FALSE(other->IsMoreSuitable(current, request));
+ delete request;
+ delete current;
+ delete other;
+}
+
+/*
+ * @tc.name: ResConfigImplIsMoreSuitableTest019
+ * @tc.desc: Test ResConfig IsMoreSuitable
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplIsMoreSuitableTest019, TestSize.Level1)
+{
+ ResConfigImpl *request = CreateResConfigImpl("en", nullptr, "IN");
+ ResConfigImpl *current = CreateResConfigImpl("en", nullptr, "AU");
+ ResConfigImpl *other = CreateResConfigImpl("en", nullptr, "US");
+ EXPECT_TRUE(current->IsMoreSuitable(other, request));
+ EXPECT_FALSE(other->IsMoreSuitable(current, request));
+ delete request;
+ delete current;
+ delete other;
+}
+
+/*
+ * @tc.name: ResConfigImplIsMoreSuitableTest020
+ * @tc.desc: Test ResConfig IsMoreSuitable
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplIsMoreSuitableTest020, TestSize.Level1)
+{
+ ResConfigImpl *request = CreateResConfigImpl("en", nullptr, "PR");
+ ResConfigImpl *current = CreateResConfigImpl("en", nullptr, "001");
+ ResConfigImpl *other = CreateResConfigImpl("en", nullptr, "GB");
+ EXPECT_TRUE(current->IsMoreSuitable(other, request));
+ EXPECT_FALSE(other->IsMoreSuitable(current, request));
+ delete request;
+ delete current;
+ delete other;
+}
+
+/*
+ * @tc.name: ResConfigImplIsMoreSuitableTest021
+ * @tc.desc: Test ResConfig IsMoreSuitable
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplIsMoreSuitableTest021, TestSize.Level1)
+{
+ ResConfigImpl *request = CreateResConfigImpl("en", nullptr, "IN");
+ ResConfigImpl *current = CreateResConfigImpl("en", nullptr, "GB");
+ ResConfigImpl *other = CreateResConfigImpl("en", nullptr, "AU");
+ EXPECT_TRUE(current->IsMoreSuitable(other, request));
+ EXPECT_FALSE(other->IsMoreSuitable(current, request));
+ delete request;
+ delete current;
+ delete other;
+}
+
+/*
+ * @tc.name: ResConfigImplIsMoreSuitableTest022
+ * @tc.desc: Test ResConfig IsMoreSuitable
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplIsMoreSuitableTest022, TestSize.Level1)
+{
+ ResConfigImpl *request = CreateResConfigImpl("en", nullptr, "IN");
+ ResConfigImpl *current = CreateResConfigImpl("en", nullptr, "AU");
+ ResConfigImpl *other = CreateResConfigImpl("en", nullptr, "CA");
+ EXPECT_TRUE(current->IsMoreSuitable(other, request));
+ EXPECT_FALSE(other->IsMoreSuitable(current, request));
+ delete request;
+ delete current;
+ delete other;
+}
+
+/*
+ * @tc.name: ResConfigImplIsMoreSuitableTest023
+ * @tc.desc: Test ResConfig IsMoreSuitable
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplIsMoreSuitableTest023, TestSize.Level1)
+{
+ ResConfigImpl *request = CreateResConfigImpl("pt", nullptr, "MZ");
+ ResConfigImpl *current = CreateResConfigImpl("pt", nullptr, "PT");
+ ResConfigImpl *other = CreateResConfigImpl("pt", nullptr, nullptr);
+ EXPECT_TRUE(current->IsMoreSuitable(other, request));
+ EXPECT_FALSE(other->IsMoreSuitable(current, request));
+ delete request;
+ delete current;
+ delete other;
+}
+
+/*
+ * @tc.name: ResConfigImplIsMoreSuitableTest024
+ * @tc.desc: Test ResConfig IsMoreSuitable
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplIsMoreSuitableTest024, TestSize.Level1)
+{
+ ResConfigImpl *request = CreateResConfigImpl("pt", nullptr, "MZ");
+ ResConfigImpl *current = CreateResConfigImpl("pt", nullptr, "PT");
+ ResConfigImpl *other = CreateResConfigImpl("pt", nullptr, "BR");
+ EXPECT_TRUE(current->IsMoreSuitable(other, request));
+ EXPECT_FALSE(other->IsMoreSuitable(current, request));
+ delete request;
+ delete current;
+ delete other;
+}
+
+/*
+ * @tc.name: ResConfigImplIsMoreSuitableTest025
+ * @tc.desc: Test ResConfig IsMoreSuitable
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplIsMoreSuitableTest025, TestSize.Level1)
+{
+ ResConfigImpl *request = CreateResConfigImpl("zh", "Hant", "MO");
+ ResConfigImpl *current = CreateResConfigImpl("zh", "Hant", "HK");
+ ResConfigImpl *other = CreateResConfigImpl("zh", "Hant", "TW");
+ EXPECT_TRUE(current->IsMoreSuitable(other, request));
+ EXPECT_FALSE(other->IsMoreSuitable(current, request));
+ delete request;
+ delete current;
+ delete other;
+}
+
+/*
+ * @tc.name: ResConfigImplIsMoreSuitableTest026
+ * @tc.desc: Test ResConfig IsMoreSuitable
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplIsMoreSuitableTest026, TestSize.Level1)
+{
+ ResConfigImpl *request = CreateResConfigImpl("zh", "Hant", "US");
+ ResConfigImpl *current = CreateResConfigImpl("zh", "Hant", "TW");
+ ResConfigImpl *other = CreateResConfigImpl("zh", "Hant", "HK");
+ EXPECT_TRUE(current->IsMoreSuitable(other, request));
+ EXPECT_FALSE(other->IsMoreSuitable(current, request));
+ delete request;
+ delete current;
+ delete other;
+}
+
+/*
+ * @tc.name: ResConfigImplIsMoreSuitableTest027
+ * @tc.desc: Test ResConfig IsMoreSuitable
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplIsMoreSuitableTest027, TestSize.Level1)
+{
+ ResConfigImpl *request = CreateResConfigImpl("ar", nullptr, "DZ");
+ ResConfigImpl *current = CreateResConfigImpl("ar", nullptr, "015");
+ ResConfigImpl *other = CreateResConfigImpl("ar", nullptr, nullptr);
+ EXPECT_TRUE(current->IsMoreSuitable(other, request));
+ EXPECT_FALSE(other->IsMoreSuitable(current, request));
+ delete request;
+ delete current;
+ delete other;
+}
+
+/*
+ * @tc.name: ResConfigImplIsMoreSuitableTest028
+ * @tc.desc: Test ResConfig IsMoreSuitable
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplIsMoreSuitableTest028, TestSize.Level1)
+{
+ ResConfigImpl *request = CreateResConfigImpl("ar", nullptr, "EG");
+ ResConfigImpl *current = CreateResConfigImpl("ar", nullptr, nullptr);
+ ResConfigImpl *other = CreateResConfigImpl("ar", nullptr, "015");
+ EXPECT_TRUE(current->IsMoreSuitable(other, request));
+ EXPECT_FALSE(other->IsMoreSuitable(current, request));
+ delete request;
+ delete current;
+ delete other;
+}
+
+/*
+ * @tc.name: ResConfigImplIsMoreSuitableTest029
+ * @tc.desc: Test ResConfig IsMoreSuitable
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplIsMoreSuitableTest029, TestSize.Level1)
+{
+ ResConfigImpl *request = CreateResConfigImpl("ar", nullptr, "QA");
+ ResConfigImpl *current = CreateResConfigImpl("ar", nullptr, "EG");
+ ResConfigImpl *other = CreateResConfigImpl("ar", nullptr, "BH");
+ EXPECT_TRUE(current->IsMoreSuitable(other, request));
+ EXPECT_FALSE(other->IsMoreSuitable(current, request));
+ delete request;
+ delete current;
+ delete other;
+}
+
+/*
+ * @tc.name: ResConfigImplIsMoreSuitableTest030
+ * @tc.desc: Test ResConfig IsMoreSuitable
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplIsMoreSuitableTest030, TestSize.Level1)
+{
+ ResConfigImpl *request = CreateResConfigImpl("ar", nullptr, "QA");
+ ResConfigImpl *current = CreateResConfigImpl("ar", nullptr, "SA");
+ ResConfigImpl *other = CreateResConfigImpl("ar", nullptr, "015");
+ EXPECT_TRUE(current->IsMoreSuitable(other, request));
+ EXPECT_FALSE(other->IsMoreSuitable(current, request));
+ delete request;
+ delete current;
+ delete other;
+}
+
+/*
+ * @tc.name: ResConfigImplIsMoreSuitableTest031
+ * @tc.desc: Test ResConfig IsMoreSuitable
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplIsMoreSuitableTest031, TestSize.Level1)
+{
+ ResConfigImpl *request = CreateResConfigImpl("en", nullptr, "US");
+ ResConfigImpl *current = CreateResConfigImpl(nullptr, nullptr, nullptr);
+ ResConfigImpl *other = CreateResConfigImpl("en", nullptr, "001");
+ EXPECT_TRUE(current->IsMoreSuitable(other, request));
+ EXPECT_FALSE(other->IsMoreSuitable(current, request));
+ delete request;
+ delete current;
+ delete other;
+}
+
+/*
+ * @tc.name: ResConfigImplIsMoreSuitableTest032
+ * @tc.desc: Test ResConfig IsMoreSuitable
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplIsMoreSuitableTest032, TestSize.Level1)
+{
+ ResConfigImpl *request = CreateResConfigImpl("en", nullptr, "US");
+ ResConfigImpl *current = CreateResConfigImpl(nullptr, nullptr, nullptr);
+ ResConfigImpl *other = CreateResConfigImpl("en", nullptr, "GB");
+ EXPECT_TRUE(current->IsMoreSuitable(other, request));
+ EXPECT_FALSE(other->IsMoreSuitable(current, request));
+ delete request;
+ delete current;
+ delete other;
+}
+
+/*
+ * @tc.name: ResConfigImplIsMoreSuitableTest033
+ * @tc.desc: Test ResConfig IsMoreSuitable
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplIsMoreSuitableTest033, TestSize.Level1)
+{
+ ResConfigImpl *request = CreateResConfigImpl("en", nullptr, "PR");
+ ResConfigImpl *current = CreateResConfigImpl(nullptr, nullptr, nullptr);
+ ResConfigImpl *other = CreateResConfigImpl("en", nullptr, "001");
+ EXPECT_TRUE(current->IsMoreSuitable(other, request));
+ EXPECT_FALSE(other->IsMoreSuitable(current, request));
+ delete request;
+ delete current;
+ delete other;
+}
+
+/*
+ * @tc.name: ResConfigImplIsMoreSuitableTest034
+ * @tc.desc: Test ResConfig IsMoreSuitable
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplIsMoreSuitableTest034, TestSize.Level1)
+{
+ ResConfigImpl *request = CreateResConfigImpl("en", nullptr, "US");
+ ResConfigImpl *current = CreateResConfigImpl("en", nullptr, nullptr);
+ ResConfigImpl *other = CreateResConfigImpl(nullptr, nullptr, nullptr);
+ EXPECT_TRUE(current->IsMoreSuitable(other, request));
+ EXPECT_FALSE(other->IsMoreSuitable(current, request));
+ delete request;
+ delete current;
+ delete other;
+}
+
+/*
+ * @tc.name: ResConfigImplIsMoreSuitableTest035
+ * @tc.desc: Test ResConfig IsMoreSuitable
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplIsMoreSuitableTest035, TestSize.Level1)
+{
+ ResConfigImpl *request = CreateResConfigImpl("en", nullptr, "PR");
+ ResConfigImpl *current = CreateResConfigImpl("en", nullptr, nullptr);
+ ResConfigImpl *other = CreateResConfigImpl(nullptr, nullptr, nullptr);
+ EXPECT_TRUE(current->IsMoreSuitable(other, request));
+ EXPECT_FALSE(other->IsMoreSuitable(current, request));
+ delete request;
+ delete current;
+ delete other;
+}
+
+/*
+ * @tc.name: ResConfigImplIsMoreSuitableTest036
+ * @tc.desc: Test ResConfig IsMoreSuitable
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplIsMoreSuitableTest036, TestSize.Level1)
+{
+ ResConfigImpl *request = CreateResConfigImpl("en", nullptr, "US");
+ ResConfigImpl *current = CreateResConfigImpl(nullptr, nullptr, nullptr);
+ ResConfigImpl *other = CreateResConfigImpl("en", nullptr, "PR");
+ EXPECT_TRUE(current->IsMoreSuitable(other, request));
+ EXPECT_FALSE(other->IsMoreSuitable(current, request));
+ delete request;
+ delete current;
+ delete other;
+}
+
+/*
+ * @tc.name: ResConfigImplIsMoreSuitableTest037
+ * @tc.desc: Test ResConfig IsMoreSuitable
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplIsMoreSuitableTest037, TestSize.Level1)
+{
+ ResConfigImpl *request = CreateResConfigImpl("en", nullptr, "CN");
+ ResConfigImpl *current = CreateResConfigImpl(nullptr, nullptr, nullptr);
+ ResConfigImpl *other = CreateResConfigImpl("en", nullptr, "GB");
+ EXPECT_TRUE(current->IsMoreSuitable(other, request));
+ EXPECT_FALSE(other->IsMoreSuitable(current, request));
+ delete request;
+ delete current;
+ delete other;
+}
+
+/*
+ * @tc.name: ResConfigImplIsMoreSuitableTest038
+ * @tc.desc: Test ResConfig IsMoreSuitable
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplIsMoreSuitableTest038, TestSize.Level1)
+{
+ ResConfigImpl *request = CreateResConfigImpl("en", "Qaag", nullptr);
+ ResConfigImpl *current = CreateResConfigImpl("en", nullptr, "GB");
+ ResConfigImpl *other = CreateResConfigImpl("en", nullptr, "CA");
+ EXPECT_TRUE(current->IsMoreSuitable(other, request));
+ EXPECT_FALSE(other->IsMoreSuitable(current, request));
+ delete request;
+ delete current;
+ delete other;
+}
+
+/*
+ * @tc.name: ResConfigImplIsMoreSuitableTest039
+ * @tc.desc: Test ResConfig IsMoreSuitable
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplIsMoreSuitableTest039, TestSize.Level1)
+{
+ ResConfigImpl *request = CreateResConfigImpl("en", "Qaag", nullptr);
+ ResConfigImpl *current = CreateResConfigImpl(nullptr, nullptr, nullptr);
+ ResConfigImpl *other = CreateResConfigImpl("en", nullptr, "CA");
+ EXPECT_FALSE(current->IsMoreSuitable(other, request));
+ EXPECT_TRUE(other->IsMoreSuitable(current, request));
+ delete request;
+ delete current;
+ delete other;
+}
+
+/*
+ * @tc.name: ResConfigImplIsMoreSuitableTest040
+ * @tc.desc: Test ResConfig IsMoreSuitable
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplIsMoreSuitableTest040, TestSize.Level1)
+{
+ ResConfigImpl *request = CreateResConfigImpl("en", nullptr, "US");
+ ResConfigImpl *current = CreateResConfigImpl("en", nullptr, "CN");
+ ResConfigImpl *other = CreateResConfigImpl("en", nullptr, "GB");
+ EXPECT_TRUE(current->IsMoreSuitable(other, request));
+ EXPECT_FALSE(other->IsMoreSuitable(current, request));
+ delete request;
+ delete current;
+ delete other;
+}
+
+/*
+ * @tc.name: ResConfigImplIsMoreSuitableTest041
+ * @tc.desc: Test ResConfig IsMoreSuitable
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplIsMoreSuitableTest041, TestSize.Level1)
+{
+ ResConfigImpl *request = CreateResConfigImpl("en", nullptr, "US");
+ ResConfigImpl *current = CreateResConfigImpl("en", nullptr, "US");
+ ResConfigImpl *other = CreateResConfigImpl("en", nullptr, "US");
+ request->SetDirection(Direction::DIRECTION_HORIZONTAL);
+ current->SetDirection(Direction::DIRECTION_HORIZONTAL);
+ EXPECT_TRUE(current->IsMoreSuitable(other, request));
+ EXPECT_FALSE(other->IsMoreSuitable(current, request));
+ delete request;
+ delete current;
+ delete other;
+}
+
+/*
+ * @tc.name: ResConfigImplIsMoreSuitableTest042
+ * @tc.desc: Test ResConfig IsMoreSuitable
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplIsMoreSuitableTest042, TestSize.Level1)
+{
+ ResConfigImpl *request = CreateResConfigImpl("en", nullptr, "US");
+ ResConfigImpl *current = CreateResConfigImpl("en", nullptr, "US");
+ ResConfigImpl *other = CreateResConfigImpl("en", nullptr, "US");
+ request->SetDirection(Direction::DIRECTION_HORIZONTAL);
+ request->SetDeviceType(DeviceType::DEVICE_PHONE);
+ current->SetDirection(Direction::DIRECTION_HORIZONTAL);
+ current->SetDeviceType(DeviceType::DEVICE_PHONE);
+ other->SetDeviceType(DeviceType::DEVICE_PHONE);
+ EXPECT_TRUE(current->IsMoreSuitable(other, request));
+ EXPECT_FALSE(other->IsMoreSuitable(current, request));
+ delete request;
+ delete current;
+ delete other;
+}
+
+/*
+ * @tc.name: ResConfigImplIsMoreSuitableTest043
+ * @tc.desc: Test ResConfig IsMoreSuitable
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplIsMoreSuitableTest043, TestSize.Level1)
+{
+ ResConfigImpl *request = CreateResConfigImpl("en", nullptr, "US");
+ ResConfigImpl *current = CreateResConfigImpl("en", nullptr, "US");
+ ResConfigImpl *other = CreateResConfigImpl("en", nullptr, "US");
+ request->SetDirection(Direction::DIRECTION_HORIZONTAL);
+ request->SetDeviceType(DeviceType::DEVICE_PHONE);
+ request->SetScreenDensity(ScreenDensity::SCREEN_DENSITY_LDPI);
+ current->SetDirection(Direction::DIRECTION_HORIZONTAL);
+ current->SetDeviceType(DeviceType::DEVICE_PHONE);
+ current->SetScreenDensity(ScreenDensity::SCREEN_DENSITY_LDPI);
+ other->SetScreenDensity(ScreenDensity::SCREEN_DENSITY_LDPI);
+ other->SetDeviceType(DeviceType::DEVICE_PHONE);
+ EXPECT_TRUE(current->IsMoreSuitable(other, request));
+ EXPECT_FALSE(other->IsMoreSuitable(current, request));
+ delete request;
+ delete current;
+ delete other;
+}
+
+/*
+ * @tc.name: ResConfigImplIsMoreSuitableTest044
+ * @tc.desc: Test ResConfig IsMoreSuitable
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplIsMoreSuitableTest044, TestSize.Level1)
+{
+ ResConfigImpl *request = CreateResConfigImpl("en", nullptr, "US");
+ ResConfigImpl *current = CreateResConfigImpl("en", nullptr, "US");
+ ResConfigImpl *other = CreateResConfigImpl("en", nullptr, "US");
+ request->SetDirection(Direction::DIRECTION_HORIZONTAL);
+ request->SetDeviceType(DeviceType::DEVICE_PHONE);
+ request->SetScreenDensity(ScreenDensity::SCREEN_DENSITY_LDPI);
+ current->SetDeviceType(DeviceType::DEVICE_PHONE);
+ current->SetScreenDensity(ScreenDensity::SCREEN_DENSITY_LDPI);
+ other->SetScreenDensity(ScreenDensity::SCREEN_DENSITY_LDPI);
+ EXPECT_TRUE(current->IsMoreSuitable(other, request));
+ EXPECT_FALSE(other->IsMoreSuitable(current, request));
+ delete request;
+ delete current;
+ delete other;
+}
+
+/*
+ * @tc.name: ResConfigImplIsMoreSuitableTest045
+ * @tc.desc: Test ResConfig IsMoreSuitable
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplIsMoreSuitableTest045, TestSize.Level1)
+{
+ ResConfigImpl *request = CreateResConfigImpl("en", nullptr, "US");
+ ResConfigImpl *current = CreateResConfigImpl("en", nullptr, "US");
+ ResConfigImpl *other = CreateResConfigImpl("en", nullptr, "US");
+ request->SetDirection(Direction::DIRECTION_HORIZONTAL);
+ request->SetDeviceType(DeviceType::DEVICE_PHONE);
+ request->SetScreenDensity(ScreenDensity::SCREEN_DENSITY_LDPI);
+ current->SetDeviceType(DeviceType::DEVICE_PHONE);
+ current->SetDirection(Direction::DIRECTION_HORIZONTAL);
+ current->SetScreenDensity(ScreenDensity::SCREEN_DENSITY_XLDPI);
+ other->SetDeviceType(DeviceType::DEVICE_PHONE);
+ other->SetDirection(Direction::DIRECTION_HORIZONTAL);
+ other->SetScreenDensity(ScreenDensity::SCREEN_DENSITY_XXLDPI);
+ EXPECT_TRUE(current->IsMoreSuitable(other, request));
+ EXPECT_FALSE(other->IsMoreSuitable(current, request));
+ delete request;
+ delete current;
+ delete other;
+}
+
+/*
+ * @tc.name: ResConfigImplIsMoreSuitableTest046
+ * @tc.desc: Test ResConfig IsMoreSuitable
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplIsMoreSuitableTest046, TestSize.Level1)
+{
+ ResConfigImpl *request = CreateResConfigImpl("en", nullptr, "US");
+ ResConfigImpl *current = CreateResConfigImpl("en", nullptr, "US");
+ ResConfigImpl *other = CreateResConfigImpl("en", nullptr, "US");
+ request->SetDirection(Direction::DIRECTION_HORIZONTAL);
+ request->SetDeviceType(DeviceType::DEVICE_PHONE);
+ request->SetScreenDensity(ScreenDensity::SCREEN_DENSITY_LDPI);
+ current->SetDeviceType(DeviceType::DEVICE_PHONE);
+ current->SetDirection(Direction::DIRECTION_HORIZONTAL);
+ current->SetScreenDensity(ScreenDensity::SCREEN_DENSITY_MDPI);
+ other->SetDeviceType(DeviceType::DEVICE_PHONE);
+ other->SetDirection(Direction::DIRECTION_HORIZONTAL);
+ other->SetScreenDensity(ScreenDensity::SCREEN_DENSITY_SDPI);
+ EXPECT_TRUE(current->IsMoreSuitable(other, request));
+ EXPECT_FALSE(other->IsMoreSuitable(current, request));
+ delete request;
+ delete current;
+ delete other;
+}
+
+/*
+ * @tc.name: ResConfigImplIsMoreSuitableTest047
+ * @tc.desc: Test ResConfig IsMoreSuitable
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplIsMoreSuitableTest047, TestSize.Level1)
+{
+ ResConfigImpl *request = CreateResConfigImpl("en", nullptr, "US");
+ ResConfigImpl *current = CreateResConfigImpl("en", nullptr, "US");
+ ResConfigImpl *other = CreateResConfigImpl("en", nullptr, "US");
+ request->SetDirection(Direction::DIRECTION_HORIZONTAL);
+ request->SetDeviceType(DeviceType::DEVICE_PHONE);
+ request->SetScreenDensity(ScreenDensity::SCREEN_DENSITY_LDPI);
+ current->SetDeviceType(DeviceType::DEVICE_PHONE);
+ current->SetDirection(Direction::DIRECTION_HORIZONTAL);
+ current->SetScreenDensity(ScreenDensity::SCREEN_DENSITY_XXXLDPI);
+ other->SetDeviceType(DeviceType::DEVICE_PHONE);
+ other->SetDirection(Direction::DIRECTION_HORIZONTAL);
+ other->SetScreenDensity(ScreenDensity::SCREEN_DENSITY_SDPI);
+ EXPECT_TRUE(current->IsMoreSuitable(other, request));
+ EXPECT_FALSE(other->IsMoreSuitable(current, request));
+ delete request;
+ delete current;
+ delete other;
+}
+
+/*
+ * @tc.name: ResConfigImplIsMoreSuitableTest048
+ * @tc.desc: Test ResConfig IsMoreSuitable
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplIsMoreSuitableTest048, TestSize.Level1)
+{
+ ResConfigImpl *request = CreateResConfigImpl("en", nullptr, "US");
+ ResConfigImpl *current = CreateResConfigImpl("en", nullptr, "US");
+ ResConfigImpl *other = CreateResConfigImpl("en", nullptr, "US");
+ current->SetDeviceType(DeviceType::DEVICE_PHONE);
+ EXPECT_TRUE(current->IsMoreSuitable(other, request));
+ EXPECT_FALSE(other->IsMoreSuitable(current, request));
+ delete request;
+ delete current;
+ delete other;
+}
+
+/*
+ * @tc.name: ResConfigImplIsMoreSuitableTest049
+ * @tc.desc: Test ResConfig IsMoreSuitable
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplIsMoreSuitableTest049, TestSize.Level1)
+{
+ ResConfigImpl *request = CreateResConfigImpl("en", nullptr, "US");
+ ResConfigImpl *current = CreateResConfigImpl("en", nullptr, "US");
+ ResConfigImpl *other = CreateResConfigImpl("en", nullptr, "US");
+ current->SetDirection(Direction::DIRECTION_HORIZONTAL);
+ EXPECT_TRUE(current->IsMoreSuitable(other, request));
+ EXPECT_FALSE(other->IsMoreSuitable(current, request));
+ delete request;
+ delete current;
+ delete other;
+}
+
+/*
+ * @tc.name: ResConfigImplIsMoreSuitableTest050
+ * @tc.desc: Test ResConfig IsMoreSuitable
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigImplTest, ResConfigImplIsMoreSuitableTest050, TestSize.Level1)
+{
+ ResConfigImpl *request = CreateResConfigImpl("en", nullptr, "US");
+ ResConfigImpl *current = CreateResConfigImpl("en", nullptr, "US");
+ ResConfigImpl *other = CreateResConfigImpl("en", nullptr, "US");
+ current->SetScreenDensity(ScreenDensity::SCREEN_DENSITY_SDPI);
+ EXPECT_TRUE(current->IsMoreSuitable(other, request));
+ EXPECT_FALSE(other->IsMoreSuitable(current, request));
+ delete request;
+ delete current;
+ delete other;
+}
\ No newline at end of file
diff --git a/global_lite/i18n_lite/resource_parse_load/src/res_config_impl_test.h b/global_lite/i18n_lite/resource_parse_load/src/res_config_impl_test.h
new file mode 100755
index 0000000000000000000000000000000000000000..3a102ee5ea467446ee8a4a69f8aa857eed8f8379
--- /dev/null
+++ b/global_lite/i18n_lite/resource_parse_load/src/res_config_impl_test.h
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef RESOURCE_MANAGER_RES_CONFIG_IMPL_TEST_H
+#define RESOURCE_MANAGER_RES_CONFIG_IMPL_TEST_H
+
+int ResConfigImplMatchTest001();
+int ResConfigImplMatchTest002();
+int ResConfigImplMatchTest003();
+int ResConfigImplMatchTest004();
+int ResConfigImplMatchTest005();
+int ResConfigImplMatchTest006();
+int ResConfigImplMatchTest007();
+int ResConfigImplMatchTest008();
+int ResConfigImplMatchTest009();
+int ResConfigImplMatchTest010();
+int ResConfigImplMatchTest011();
+int ResConfigImplMatchTest012();
+int ResConfigImplMatchTest013();
+int ResConfigImplMatchTest014();
+int ResConfigImplMatchTest015();
+int ResConfigImplMatchTest016();
+int ResConfigImplMatchTest017();
+int ResConfigImplMatchTest018();
+int ResConfigImplMatchTest019();
+int ResConfigImplMatchTest020();
+int ResConfigImplMatchTest021();
+int ResConfigImplMatchTest022();
+int ResConfigImplMatchTest023();
+int ResConfigImplMatchTest024();
+int ResConfigImplMatchTest025();
+int ResConfigImplMatchTest026();
+int ResConfigImplMatchTest027();
+int ResConfigImplMatchTest028();
+int ResConfigImplMatchTest029();
+int ResConfigImplIsMoreSuitableTest001();
+int ResConfigImplIsMoreSuitableTest002();
+int ResConfigImplIsMoreSuitableTest003();
+int ResConfigImplIsMoreSuitableTest004();
+int ResConfigImplIsMoreSuitableTest005();
+int ResConfigImplIsMoreSuitableTest006();
+int ResConfigImplIsMoreSuitableTest007();
+int ResConfigImplIsMoreSuitableTest008();
+int ResConfigImplIsMoreSuitableTest009();
+int ResConfigImplIsMoreSuitableTest010();
+int ResConfigImplIsMoreSuitableTest011();
+int ResConfigImplIsMoreSuitableTest012();
+int ResConfigImplIsMoreSuitableTest013();
+int ResConfigImplIsMoreSuitableTest014();
+int ResConfigImplIsMoreSuitableTest015();
+int ResConfigImplIsMoreSuitableTest016();
+int ResConfigImplIsMoreSuitableTest017();
+int ResConfigImplIsMoreSuitableTest018();
+int ResConfigImplIsMoreSuitableTest019();
+int ResConfigImplIsMoreSuitableTest020();
+int ResConfigImplIsMoreSuitableTest021();
+int ResConfigImplIsMoreSuitableTest022();
+int ResConfigImplIsMoreSuitableTest023();
+int ResConfigImplIsMoreSuitableTest024();
+int ResConfigImplIsMoreSuitableTest025();
+int ResConfigImplIsMoreSuitableTest026();
+int ResConfigImplIsMoreSuitableTest027();
+int ResConfigImplIsMoreSuitableTest028();
+int ResConfigImplIsMoreSuitableTest029();
+int ResConfigImplIsMoreSuitableTest030();
+int ResConfigImplIsMoreSuitableTest031();
+int ResConfigImplIsMoreSuitableTest032();
+int ResConfigImplIsMoreSuitableTest033();
+int ResConfigImplIsMoreSuitableTest034();
+int ResConfigImplIsMoreSuitableTest035();
+int ResConfigImplIsMoreSuitableTest036();
+int ResConfigImplIsMoreSuitableTest037();
+int ResConfigImplIsMoreSuitableTest038();
+int ResConfigImplIsMoreSuitableTest039();
+int ResConfigImplIsMoreSuitableTest040();
+int ResConfigImplIsMoreSuitableTest041();
+int ResConfigImplIsMoreSuitableTest042();
+int ResConfigImplIsMoreSuitableTest043();
+int ResConfigImplIsMoreSuitableTest044();
+int ResConfigImplIsMoreSuitableTest045();
+int ResConfigImplIsMoreSuitableTest046();
+int ResConfigImplIsMoreSuitableTest047();
+int ResConfigImplIsMoreSuitableTest048();
+int ResConfigImplIsMoreSuitableTest049();
+int ResConfigImplIsMoreSuitableTest050();
+
+#endif
diff --git a/global_lite/i18n_lite/resource_parse_load/src/res_config_test.cpp b/global_lite/i18n_lite/resource_parse_load/src/res_config_test.cpp
new file mode 100755
index 0000000000000000000000000000000000000000..2682b32ec6ef016bf557d0450102742f8b9e925c
--- /dev/null
+++ b/global_lite/i18n_lite/resource_parse_load/src/res_config_test.cpp
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "res_config_test.h"
+
+#include
+#include
+#include
+
+#include "hap_resource.h"
+#include "res_config.h"
+#include "resource_manager_impl.h"
+#include "test_common.h"
+
+using namespace OHOS::Global::Resource;
+using namespace testing::ext;
+
+class ResConfigTest : public testing::Test {
+public:
+ static void SetUpTestCase(void);
+
+ static void TearDownTestCase(void);
+
+ void SetUp();
+
+ void TearDown();
+};
+
+void ResConfigTest::SetUpTestCase(void)
+{
+ // step 1: input testsuit setup step
+ g_logLevel = LOG_DEBUG;
+}
+
+void ResConfigTest::TearDownTestCase(void)
+{
+ // step 2: input testsuit teardown step
+}
+
+void ResConfigTest::SetUp()
+{
+}
+
+void ResConfigTest::TearDown()
+{
+}
+
+/*
+ * @tc.name: ResConfigFuncTest001
+ * @tc.desc: Test Config function, non file case.
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResConfigTest, ResConfigFuncTest001, TestSize.Level1)
+{
+ ResConfigImpl *rc = new ResConfigImpl;
+ rc->SetLocaleInfo("en", nullptr, "AU");
+ ResConfigImpl *current = new ResConfigImpl;
+ current->SetLocaleInfo("en", nullptr, "GB");
+ ResConfigImpl *target = new ResConfigImpl;
+ target->SetLocaleInfo("zh", nullptr, "CN");
+ EXPECT_TRUE(rc->Match(current));
+ EXPECT_TRUE(rc->Match(target) == false);
+ delete target;
+ delete current;
+ delete rc;
+};
\ No newline at end of file
diff --git a/global_lite/i18n_lite/resource_parse_load/src/res_config_test.h b/global_lite/i18n_lite/resource_parse_load/src/res_config_test.h
new file mode 100755
index 0000000000000000000000000000000000000000..2b689eda164b35be5bfa6e7118fa939342980e22
--- /dev/null
+++ b/global_lite/i18n_lite/resource_parse_load/src/res_config_test.h
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef RESOURCE_MANAGER_RES_CONFIG_TEST_H
+#define RESOURCE_MANAGER_RES_CONFIG_TEST_H
+
+int ResConfigFuncTest001();
+
+#endif
diff --git a/global_lite/i18n_lite/resource_parse_load/src/res_desc_test.cpp b/global_lite/i18n_lite/resource_parse_load/src/res_desc_test.cpp
new file mode 100755
index 0000000000000000000000000000000000000000..7b19f0b7eb5e9c1ba5655a8eb8292fe592a73b9c
--- /dev/null
+++ b/global_lite/i18n_lite/resource_parse_load/src/res_desc_test.cpp
@@ -0,0 +1,156 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "res_desc_test.h"
+
+#include
+
+#include "res_desc.h"
+#include "test_common.h"
+#include "utils/string_utils.h"
+
+using namespace OHOS::Global::Resource;
+using namespace testing::ext;
+
+class ResDescTest : public testing::Test {
+public:
+ static void SetUpTestCase(void);
+
+ static void TearDownTestCase(void);
+
+ void SetUp();
+
+ void TearDown();
+};
+
+void ResDescTest::SetUpTestCase(void)
+{
+ // step 1: input testsuit setup step
+ g_logLevel = LOG_DEBUG;
+}
+
+void ResDescTest::TearDownTestCase(void)
+{
+ // step 2: input testsuit teardown step
+}
+
+void ResDescTest::SetUp()
+{
+ // step 3: input testcase setup step
+ HILOG_DEBUG("ResDescTest setup");
+}
+
+void ResDescTest::TearDown()
+{
+ // step 4: input testcase teardown step
+ HILOG_DEBUG("ResDescTest teardown");
+}
+
+/*
+ * @tc.name: ResDescFuncTest001
+ * @tc.desc: Test IsRef function, non file case.
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResDescTest, ResDescFuncTest001, TestSize.Level1)
+{
+ std::string str;
+ int id;
+ ResType resType;
+ str.assign("abc");
+ EXPECT_TRUE(!IdItem::IsRef(str, resType, id));
+
+ str.assign("$abc");
+ EXPECT_TRUE(!IdItem::IsRef(str, resType, id));
+
+ str.assign("$abc:");
+ EXPECT_TRUE(!IdItem::IsRef(str, resType, id));
+
+ str.assign("$abc:abc");
+ EXPECT_TRUE(!IdItem::IsRef(str, resType, id));
+
+ str.assign("$abc:123456");
+ EXPECT_TRUE(!IdItem::IsRef(str, resType, id));
+
+ str.assign("$string:123456");
+ EXPECT_TRUE(IdItem::IsRef(str, resType, id));
+ EXPECT_EQ(ResType::STRING, resType);
+ EXPECT_EQ(123456, id);
+ str.assign("$boolean:100001");
+ EXPECT_TRUE(IdItem::IsRef(str, resType, id));
+ EXPECT_EQ(ResType::BOOLEAN, resType);
+ EXPECT_EQ(100001, id);
+ str.assign("$color:66666");
+ EXPECT_TRUE(IdItem::IsRef(str, resType, id));
+ EXPECT_EQ(ResType::COLOR, resType);
+ EXPECT_EQ(66666, id);
+ str.assign("$float:100002");
+ EXPECT_TRUE(IdItem::IsRef(str, resType, id));
+ EXPECT_EQ(ResType::FLOAT, resType);
+ EXPECT_EQ(100002, id);
+ str.assign("$integer:2008168");
+ EXPECT_TRUE(IdItem::IsRef(str, resType, id));
+ EXPECT_EQ(ResType::INTEGER, resType);
+ EXPECT_EQ(2008168, id);
+ str.assign("$pattern:654321");
+ EXPECT_TRUE(IdItem::IsRef(str, resType, id));
+ EXPECT_EQ(ResType::PATTERN, resType);
+ EXPECT_EQ(654321, id);
+ str.assign("$theme:99999");
+ EXPECT_TRUE(IdItem::IsRef(str, resType, id));
+ EXPECT_EQ(ResType::THEME, resType);
+ EXPECT_EQ(99999, id);
+}
+
+void TestKeyParam(KeyType keyType, int value, std::string expectStr)
+{
+ KeyParam keyParam;
+ keyParam.type_ = keyType;
+ keyParam.value_ = value;
+ keyParam.InitStr();
+ EXPECT_EQ(expectStr, keyParam.str_);
+}
+
+/*
+ * @tc.name: ResDescFuncTest002
+ * @tc.desc: Test IsRef function, non file case.
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResDescTest, ResDescFuncTest002, TestSize.Level1)
+{
+ TestKeyParam(KeyType::LANGUAGES, 25966, "en");
+ TestKeyParam(KeyType::LANGUAGES, 31336, "zh");
+
+ TestKeyParam(KeyType::REGION, 21843, "US");
+ TestKeyParam(KeyType::REGION, 17230, "CN");
+
+ TestKeyParam(KeyType::DIRECTION, 0, VERTICAL);
+ TestKeyParam(KeyType::DIRECTION, 1, HORIZONTAL);
+
+ TestKeyParam(KeyType::DEVICETYPE, DeviceType::DEVICE_PHONE, PHONE_STR);
+ TestKeyParam(KeyType::DEVICETYPE, DeviceType::DEVICE_TABLET, TABLET_STR);
+ TestKeyParam(KeyType::DEVICETYPE, DeviceType::DEVICE_CAR, CAR_STR);
+ TestKeyParam(KeyType::DEVICETYPE, DeviceType::DEVICE_PC, PC_STR);
+ TestKeyParam(KeyType::DEVICETYPE, DeviceType::DEVICE_TV, TV_STR);
+ TestKeyParam(KeyType::DEVICETYPE, DeviceType::DEVICE_WEARABLE, WEARABLE_STR);
+ TestKeyParam(KeyType::DEVICETYPE, DeviceType::DEVICE_NOT_SET, "not_device_type");
+
+ TestKeyParam(KeyType::SCREEN_DENSITY, ScreenDensity::SCREEN_DENSITY_SDPI, RE_120_STR);
+ TestKeyParam(KeyType::SCREEN_DENSITY, ScreenDensity::SCREEN_DENSITY_MDPI, RE_160_STR);
+ TestKeyParam(KeyType::SCREEN_DENSITY, ScreenDensity::SCREEN_DENSITY_LDPI, RE_240_STR);
+ TestKeyParam(KeyType::SCREEN_DENSITY, ScreenDensity::SCREEN_DENSITY_XLDPI, RE_320_STR);
+ TestKeyParam(KeyType::SCREEN_DENSITY, ScreenDensity::SCREEN_DENSITY_XXLDPI, RE_480_STR);
+ TestKeyParam(KeyType::SCREEN_DENSITY, ScreenDensity::SCREEN_DENSITY_XXXLDPI, RE_640_STR);
+ TestKeyParam(KeyType::SCREEN_DENSITY, ScreenDensity::SCREEN_DENSITY_NOT_SET, "not_screen_density");
+}
\ No newline at end of file
diff --git a/global_lite/i18n_lite/resource_parse_load/src/res_desc_test.h b/global_lite/i18n_lite/resource_parse_load/src/res_desc_test.h
new file mode 100755
index 0000000000000000000000000000000000000000..416f3486ebafe64a9147e58fa5db62249525da51
--- /dev/null
+++ b/global_lite/i18n_lite/resource_parse_load/src/res_desc_test.h
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef RESOURCE_MANAGER_RES_DESC_TEST_H
+#define RESOURCE_MANAGER_RES_DESC_TEST_H
+
+int ResDescFuncTest001();
+int ResDescFuncTest002();
+
+#endif
diff --git a/global_lite/i18n_lite/resource_parse_load/src/resource_manager_performance_test.cpp b/global_lite/i18n_lite/resource_parse_load/src/resource_manager_performance_test.cpp
new file mode 100755
index 0000000000000000000000000000000000000000..0e028d4c763583fd7debfb41c1ed6df72169a926
--- /dev/null
+++ b/global_lite/i18n_lite/resource_parse_load/src/resource_manager_performance_test.cpp
@@ -0,0 +1,1055 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "resource_manager_performance_test.h"
+
+#include
+#include
+#include
+#include
+#include
+
+#define private public
+
+#include "resource_manager.h"
+#include "resource_manager_impl.h"
+#include "test_common.h"
+#include "utils/errors.h"
+
+using namespace OHOS::Global::Resource;
+using namespace testing::ext;
+using namespace std;
+
+class ResourceManagerPerformanceTest : public testing::Test {
+public:
+ static void SetUpTestCase(void);
+
+ static void TearDownTestCase(void);
+
+ void SetUp();
+
+ void TearDown();
+
+ ResourceManagerPerformanceTest() : rm(nullptr)
+ {}
+
+ ~ResourceManagerPerformanceTest()
+ {}
+
+public:
+ ResourceManager *rm;
+
+ int GetResId(std::string name, ResType resType) const;
+};
+
+int ResourceManagerPerformanceTest::GetResId(std::string name, ResType resType) const
+{
+ auto idv = ((ResourceManagerImpl *)rm)->hapManager_->GetResourceListByName(name.c_str(), resType);
+ if (idv == nullptr) {
+ return -1;
+ }
+
+ if (idv->GetLimitPathsConst().size() > 0) {
+ return idv->GetLimitPathsConst()[0]->GetIdItem()->id_;
+ }
+ return OBJ_NOT_FOUND;
+}
+
+void ResourceManagerPerformanceTest::SetUpTestCase(void)
+{
+ // step 1: input testsuit setup step
+}
+
+void ResourceManagerPerformanceTest::TearDownTestCase(void)
+{
+ // step 2: input testsuit teardown step
+}
+
+void ResourceManagerPerformanceTest::SetUp(void)
+{
+ // PerformanceTest need higher log level
+ g_logLevel = LOG_INFO;
+ this->rm = CreateResourceManager();
+ if (rm == nullptr) {
+ return;
+ }
+ auto rc = CreateResConfig();
+ if (rc == nullptr) {
+ return;
+ }
+ rc->SetLocaleInfo("zh", nullptr, nullptr);
+ rm->UpdateResConfig(*rc);
+ delete rc;
+ bool ret = rm->AddResource(FormatFullPath(g_resFilePath).c_str());
+ if (!ret) {
+ HILOG_ERROR("AddResource failed. test would fail.");
+ }
+}
+
+void ResourceManagerPerformanceTest::TearDown(void)
+{
+ if (this->rm != nullptr) {
+ delete this->rm;
+ this->rm = nullptr;
+ }
+}
+
+/*
+ * @tc.name: ResourceManagerPerformanceFuncTest001
+ * @tc.desc: Test AddResource
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest001, TestSize.Level1)
+{
+ unsigned long long total = 0;
+ double average = 0;
+ for (int k = 0; k < 1000; ++k) {
+ auto tmpRm = CreateResourceManager();
+ if (tmpRm == nullptr) {
+ EXPECT_TRUE(false);
+ return;
+ }
+ auto t1 = std::chrono::high_resolution_clock::now();
+ tmpRm->AddResource(FormatFullPath(g_resFilePath).c_str());
+ auto t2 = std::chrono::high_resolution_clock::now();
+ total += std::chrono::duration_cast(t2 - t1).count();
+ delete tmpRm;
+ }
+ average = total / 1000.0;
+ g_logLevel = LOG_DEBUG;
+ HILOG_DEBUG("avg cost 001: %f us", average);
+ EXPECT_LT(average, 9000);
+};
+
+/*
+ * @tc.name: ResourceManagerPerformanceFuncTest002
+ * @tc.desc: Test UpdateResConfig
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest002, TestSize.Level1)
+{
+ unsigned long long total = 0;
+ double average = 0;
+ auto tmpRm = CreateResourceManager();
+ if (tmpRm == nullptr) {
+ EXPECT_TRUE(false);
+ return;
+ }
+ ResConfig *rc = CreateResConfig();
+ if (rc == nullptr) {
+ EXPECT_TRUE(false);
+ delete tmpRm;
+ return;
+ }
+ rc->SetLocaleInfo("en", nullptr, "US");
+ rc->SetDeviceType(DeviceType::DEVICE_CAR);
+ for (int k = 0; k < 1000; ++k) {
+ auto t1 = std::chrono::high_resolution_clock::now();
+ tmpRm->UpdateResConfig(*rc);
+ auto t2 = std::chrono::high_resolution_clock::now();
+ total += std::chrono::duration_cast(t2 - t1).count();
+ }
+ delete tmpRm;
+ delete rc;
+ average = total / 1000.0;
+ g_logLevel = LOG_DEBUG;
+ HILOG_DEBUG("avg cost 002: %f us", average);
+ EXPECT_LT(average, 500);
+};
+
+/*
+ * @tc.name: ResourceManagerPerformanceFuncTest003
+ * @tc.desc: Test GetResConfig
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest003, TestSize.Level1)
+{
+ if (rm == nullptr) {
+ EXPECT_TRUE(false);
+ return;
+ }
+ unsigned long long total = 0;
+ double average = 0;
+ ResConfig *rc = CreateResConfig();
+ if (rc == nullptr) {
+ EXPECT_TRUE(false);
+ return;
+ }
+ rc->SetLocaleInfo("en", nullptr, "US");
+ rc->SetDeviceType(DeviceType::DEVICE_CAR);
+ ResConfigImpl rci;
+ for (int k = 0; k < 1000; ++k) {
+ auto t1 = std::chrono::high_resolution_clock::now();
+ rm->GetResConfig(rci);
+ auto t2 = std::chrono::high_resolution_clock::now();
+ total += std::chrono::duration_cast(t2 - t1).count();
+ }
+ delete rc;
+ average = total / 1000.0;
+ g_logLevel = LOG_DEBUG;
+ HILOG_DEBUG("avg cost 003: %f us", average);
+ EXPECT_LT(average, 500);
+};
+
+/*
+ * @tc.name: ResourceManagerPerformanceFuncTest004
+ * @tc.desc: Test GetStringByID
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest004, TestSize.Level1)
+{
+ if (rm == nullptr) {
+ EXPECT_TRUE(false);
+ return;
+ }
+ unsigned long long total = 0;
+ double average = 0;
+ string name[] = {"app_name", "title"};
+ vector ids;
+ int count = 2;
+ for (int i = 0; i < count; ++i) {
+ int id = GetResId(name[i], ResType::STRING);
+ ASSERT_TRUE(id > 0);
+ ids.push_back(static_cast(id));
+ }
+
+ std::string outValue;
+ for (int k = 0; k < 1000; ++k) {
+ for (int i = 0; i < count; ++i) {
+ auto t1 = std::chrono::high_resolution_clock::now();
+ rm->GetStringById(ids[i], outValue);
+ auto t2 = std::chrono::high_resolution_clock::now();
+ total += std::chrono::duration_cast(t2 - t1).count();
+ }
+ }
+ average = total / (1000.0 * count);
+ g_logLevel = LOG_DEBUG;
+ HILOG_DEBUG("avg cost 004: %f us", average);
+ EXPECT_LT(average, 500);
+};
+
+/*
+ * @tc.name: ResourceManagerPerformanceFuncTest005
+ * @tc.desc: Test GetStringByName
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest005, TestSize.Level1)
+{
+ if (rm == nullptr) {
+ EXPECT_TRUE(false);
+ return;
+ }
+ unsigned long long total = 0;
+ double average = 0;
+ string name[] = {"app_name", "title"};
+ int count = 2;
+ std::string outValue;
+ for (int k = 0; k < 1000; ++k) {
+ for (int i = 0; i < count; ++i) {
+ auto t1 = std::chrono::high_resolution_clock::now();
+ rm->GetStringByName(name[i].c_str(), outValue);
+ auto t2 = std::chrono::high_resolution_clock::now();
+ total += std::chrono::duration_cast(t2 - t1).count();
+ }
+ }
+ average = total / (1000.0 * count);
+ g_logLevel = LOG_DEBUG;
+ HILOG_DEBUG("avg cost 005: %f us", average);
+ EXPECT_LT(average, 500);
+};
+
+/*
+ * @tc.name: ResourceManagerPerformanceFuncTest006
+ * @tc.desc: Test GetStringByName
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest006, TestSize.Level1)
+{
+ if (rm == nullptr) {
+ EXPECT_TRUE(false);
+ return;
+ }
+ unsigned long long total = 0;
+ double average = 0;
+ string name[] = {"string_ref", "string_ref2"};
+ int count = 2;
+ std::string outValue;
+ for (int k = 0; k < 1000; ++k) {
+ for (int i = 0; i < count; ++i) {
+ auto t1 = std::chrono::high_resolution_clock::now();
+ rm->GetStringByName(name[i].c_str(), outValue);
+ auto t2 = std::chrono::high_resolution_clock::now();
+ total += std::chrono::duration_cast(t2 - t1).count();
+ }
+ }
+ average = total / (1000.0 * count);
+ g_logLevel = LOG_DEBUG;
+ HILOG_DEBUG("avg cost 006: %f us", average);
+ EXPECT_LT(average, 500);
+};
+
+/*
+ * @tc.name: ResourceManagerPerformanceFuncTest007
+ * @tc.desc: Test GetStringFormatById
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest007, TestSize.Level1)
+{
+ if (rm == nullptr) {
+ EXPECT_TRUE(false);
+ return;
+ }
+ unsigned long long total = 0;
+ double average = 0;
+ string name[] = {"app_name", "title"};
+ vector ids;
+ int count = 2;
+ for (int i = 0; i < count; ++i) {
+ int id = GetResId(name[i], ResType::STRING);
+ ASSERT_TRUE(id > 0);
+ ids.push_back(static_cast(id));
+ }
+
+ std::string outValue;
+ for (int k = 0; k < 1000; ++k) {
+ for (int i = 0; i < count; ++i) {
+ auto t1 = std::chrono::high_resolution_clock::now();
+ rm->GetStringFormatById(outValue, ids[i], 12);
+ auto t2 = std::chrono::high_resolution_clock::now();
+ total += std::chrono::duration_cast(t2 - t1).count();
+ }
+ }
+ average = total / (1000.0 * count);
+ g_logLevel = LOG_DEBUG;
+ HILOG_DEBUG("avg cost 007: %f us", average);
+ EXPECT_LT(average, 500);
+};
+
+/*
+ * @tc.name: ResourceManagerPerformanceFuncTest008
+ * @tc.desc: Test GetStringFormatByName
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest008, TestSize.Level1)
+{
+ if (rm == nullptr) {
+ EXPECT_TRUE(false);
+ return;
+ }
+ unsigned long long total = 0;
+ double average = 0;
+ string name[] = {"app_name", "title"};
+ int count = 2;
+ std::string outValue;
+ for (int k = 0; k < 1000; ++k) {
+ for (int i = 0; i < count; ++i) {
+ auto t1 = std::chrono::high_resolution_clock::now();
+ rm->GetStringFormatByName(outValue, name[i].c_str(), 123);
+ auto t2 = std::chrono::high_resolution_clock::now();
+ total += std::chrono::duration_cast(t2 - t1).count();
+ }
+ }
+ average = total / (1000.0 * count);
+ g_logLevel = LOG_DEBUG;
+ HILOG_DEBUG("avg cost 008: %f us", average);
+ EXPECT_LT(average, 500);
+};
+
+/*
+ * @tc.name: ResourceManagerPerformanceFuncTest009
+ * @tc.desc: Test GetStringArrayById
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest009, TestSize.Level1)
+{
+ if (rm == nullptr) {
+ EXPECT_TRUE(false);
+ return;
+ }
+ unsigned long long total = 0;
+ double average = 0;
+ int id = GetResId("size", ResType::STRINGARRAY);
+ ASSERT_TRUE(id > 0);
+
+ std::vector outValue;
+ for (int k = 0; k < 1000; ++k) {
+ auto t1 = std::chrono::high_resolution_clock::now();
+ rm->GetStringArrayById(id, outValue);
+ auto t2 = std::chrono::high_resolution_clock::now();
+ total += std::chrono::duration_cast(t2 - t1).count();
+ }
+ average = total / 1000.0;
+ g_logLevel = LOG_DEBUG;
+ HILOG_DEBUG("avg cost 009: %f us", average);
+ EXPECT_LT(average, 500);
+};
+
+/*
+ * @tc.name: ResourceManagerPerformanceFuncTest010
+ * @tc.desc: Test GetStringArrayByName
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest010, TestSize.Level1)
+{
+ if (rm == nullptr) {
+ EXPECT_TRUE(false);
+ return;
+ }
+ unsigned long long total = 0;
+ double average = 0;
+ std::vector outValue;
+ for (int k = 0; k < 1000; ++k) {
+ auto t1 = std::chrono::high_resolution_clock::now();
+ rm->GetStringArrayByName("size", outValue);
+ auto t2 = std::chrono::high_resolution_clock::now();
+ total += std::chrono::duration_cast(t2 - t1).count();
+ }
+ average = total / 1000.0;
+ g_logLevel = LOG_DEBUG;
+ HILOG_DEBUG("avg cost 010: %f us", average);
+ EXPECT_LT(average, 500);
+};
+
+/*
+ * @tc.name: ResourceManagerPerformanceFuncTest011
+ * @tc.desc: Test GetPatternById
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest011, TestSize.Level1)
+{
+ if (rm == nullptr) {
+ EXPECT_TRUE(false);
+ return;
+ }
+ unsigned long long total = 0;
+ double average = 0;
+ string name[] = {"base", "child"};
+ vector ids;
+ int count = 2;
+ for (int i = 0; i < count; ++i) {
+ int id = GetResId(name[i], ResType::PATTERN);
+ ASSERT_TRUE(id > 0);
+ ids.push_back(static_cast(id));
+ }
+ std::map outValue;
+ for (int k = 0; k < 1000; ++k) {
+ for (int i = 0; i < count; ++i) {
+ auto t1 = std::chrono::high_resolution_clock::now();
+ rm->GetPatternById(ids[i], outValue);
+ auto t2 = std::chrono::high_resolution_clock::now();
+ total += std::chrono::duration_cast(t2 - t1).count();
+ }
+ }
+ average = total / (1000.0 * count);
+ g_logLevel = LOG_DEBUG;
+ HILOG_DEBUG("avg cost 011: %f us", average);
+ EXPECT_LT(average, 500);
+};
+
+/*
+ * @tc.name: ResourceManagerPerformanceFuncTest012
+ * @tc.desc: Test GetPatternByName
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest012, TestSize.Level1)
+{
+ if (rm == nullptr) {
+ EXPECT_TRUE(false);
+ return;
+ }
+ unsigned long long total = 0;
+ double average = 0;
+ string name[] = {"base", "child"};
+ int count = 2;
+ std::map outValue;
+ for (int k = 0; k < 1000; ++k) {
+ for (int i = 0; i < count; ++i) {
+ auto t1 = std::chrono::high_resolution_clock::now();
+ rm->GetPatternByName(name[i].c_str(), outValue);
+ auto t2 = std::chrono::high_resolution_clock::now();
+ total += std::chrono::duration_cast(t2 - t1).count();
+ }
+ }
+ average = total / (1000.0 * count);
+ g_logLevel = LOG_DEBUG;
+ HILOG_DEBUG("avg cost 012: %f us", average);
+ EXPECT_LT(average, 500);
+};
+
+/*
+ * @tc.name: ResourceManagerPerformanceFuncTest013
+ * @tc.desc: Test GetPluralStringById
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest013, TestSize.Level1)
+{
+ if (rm == nullptr) {
+ EXPECT_TRUE(false);
+ return;
+ }
+ unsigned long long total = 0;
+ double average = 0;
+ int quantity[] = {1, 100};
+ int count = 2;
+ int id = GetResId("eat_apple", ResType::PLURALS);
+ ASSERT_TRUE(id > 0);
+
+ string outValue;
+ for (int k = 0; k < 1000; ++k) {
+ for (int i = 0; i < count; ++i) {
+ auto t1 = std::chrono::high_resolution_clock::now();
+ rm->GetPluralStringById(id, quantity[i], outValue);
+ auto t2 = std::chrono::high_resolution_clock::now();
+ total += std::chrono::duration_cast(t2 - t1).count();
+ }
+ }
+ average = total / (1000.0 * count);
+ g_logLevel = LOG_DEBUG;
+ HILOG_DEBUG("avg cost 013: %f us", average);
+ EXPECT_LT(average, 500);
+};
+
+/*
+ * @tc.name: ResourceManagerPerformanceFuncTest014
+ * @tc.desc: Test GetPluralStringByName
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest014, TestSize.Level1)
+{
+ if (rm == nullptr) {
+ EXPECT_TRUE(false);
+ return;
+ }
+ unsigned long long total = 0;
+ double average = 0;
+ int quantity[] = {1, 100};
+ int count = 2;
+ string outValue;
+ for (int k = 0; k < 1000; ++k) {
+ for (int i = 0; i < count; ++i) {
+ auto t1 = std::chrono::high_resolution_clock::now();
+ rm->GetPluralStringByName("eat_apple", quantity[i], outValue);
+ auto t2 = std::chrono::high_resolution_clock::now();
+ total += std::chrono::duration_cast(t2 - t1).count();
+ }
+ }
+ average = total / (1000.0 * count);
+ g_logLevel = LOG_DEBUG;
+ HILOG_DEBUG("avg cost 014: %f us", average);
+ EXPECT_LT(average, 500);
+};
+
+/*
+ * @tc.name: ResourceManagerPerformanceFuncTest015
+ * @tc.desc: Test GetPluralStringByIdFormat
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest015, TestSize.Level1)
+{
+ if (rm == nullptr) {
+ EXPECT_TRUE(false);
+ return;
+ }
+ unsigned long long total = 0;
+ double average = 0;
+ int quantity[] = {1, 100};
+ int count = 2;
+ int id = GetResId("eat_apple", ResType::PLURALS);
+ ASSERT_TRUE(id > 0);
+
+ string outValue;
+ for (int k = 0; k < 1000; ++k) {
+ for (int i = 0; i < count; ++i) {
+ auto t1 = std::chrono::high_resolution_clock::now();
+ rm->GetPluralStringByIdFormat(outValue, id, quantity[i], quantity[i]);
+ auto t2 = std::chrono::high_resolution_clock::now();
+ total += std::chrono::duration_cast(t2 - t1).count();
+ }
+ }
+ average = total / (1000.0 * count);
+ g_logLevel = LOG_DEBUG;
+ HILOG_DEBUG("avg cost 015: %f us", average);
+ EXPECT_LT(average, 500);
+};
+
+/*
+ * @tc.name: ResourceManagerPerformanceFuncTest016
+ * @tc.desc: Test GetPluralStringByNameFormat
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest016, TestSize.Level1)
+{
+ if (rm == nullptr) {
+ EXPECT_TRUE(false);
+ return;
+ }
+ unsigned long long total = 0;
+ double average = 0;
+ int quantity[] = {1, 100};
+ int count = 2;
+ string outValue;
+ for (int k = 0; k < 1000; ++k) {
+ for (int i = 0; i < count; ++i) {
+ auto t1 = std::chrono::high_resolution_clock::now();
+ rm->GetPluralStringByNameFormat(outValue, "eat_apple", quantity[i], quantity[i]);
+ auto t2 = std::chrono::high_resolution_clock::now();
+ total += std::chrono::duration_cast(t2 - t1).count();
+ }
+ }
+ average = total / (1000.0 * count);
+ g_logLevel = LOG_DEBUG;
+ HILOG_DEBUG("avg cost 016: %f us", average);
+ EXPECT_LT(average, 500);
+};
+
+/*
+ * @tc.name: ResourceManagerPerformanceFuncTest017
+ * @tc.desc: Test GetThemeById
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest017, TestSize.Level1)
+{
+ if (rm == nullptr) {
+ EXPECT_TRUE(false);
+ return;
+ }
+ unsigned long long total = 0;
+ double average = 0;
+ int id = GetResId("app_theme", ResType::THEME);
+ ASSERT_TRUE(id > 0);
+
+ std::map outValue;
+ for (int k = 0; k < 1000; ++k) {
+ auto t1 = std::chrono::high_resolution_clock::now();
+ rm->GetThemeById(id, outValue);
+ auto t2 = std::chrono::high_resolution_clock::now();
+ total += std::chrono::duration_cast(t2 - t1).count();
+ }
+ average = total / 1000.0;
+ g_logLevel = LOG_DEBUG;
+ HILOG_DEBUG("avg cost 017: %f us", average);
+ EXPECT_LT(average, 500);
+};
+
+/*
+ * @tc.name: ResourceManagerPerformanceFuncTest018
+ * @tc.desc: Test GetThemeByName
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest018, TestSize.Level1)
+{
+ if (rm == nullptr) {
+ EXPECT_TRUE(false);
+ return;
+ }
+ unsigned long long total = 0;
+ double average = 0;
+ std::map outValue;
+ for (int k = 0; k < 1000; ++k) {
+ auto t1 = std::chrono::high_resolution_clock::now();
+ rm->GetThemeByName("app_theme", outValue);
+ auto t2 = std::chrono::high_resolution_clock::now();
+ total += std::chrono::duration_cast(t2 - t1).count();
+ }
+ average = total / 1000.0;
+ g_logLevel = LOG_DEBUG;
+ HILOG_DEBUG("avg cost 018: %f us", average);
+ EXPECT_LT(average, 500);
+};
+
+/*
+ * @tc.name: ResourceManagerPerformanceFuncTest019
+ * @tc.desc: Test GetBooleanById
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest019, TestSize.Level1)
+{
+ if (rm == nullptr) {
+ EXPECT_TRUE(false);
+ return;
+ }
+ unsigned long long total = 0;
+ double average = 0;
+ int id = GetResId("boolean_1", ResType::BOOLEAN);
+ ASSERT_TRUE(id > 0);
+
+ bool outValue = true;
+ for (int k = 0; k < 1000; ++k) {
+ auto t1 = std::chrono::high_resolution_clock::now();
+ rm->GetBooleanById(id, outValue);
+ auto t2 = std::chrono::high_resolution_clock::now();
+ total += std::chrono::duration_cast(t2 - t1).count();
+ }
+ average = total / 1000.0;
+ g_logLevel = LOG_DEBUG;
+ HILOG_DEBUG("avg cost 019: %f us", average);
+ EXPECT_LT(average, 500);
+};
+
+/*
+ * @tc.name: ResourceManagerPerformanceFuncTest020
+ * @tc.desc: Test GetBooleanByName
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest020, TestSize.Level1)
+{
+ if (rm == nullptr) {
+ EXPECT_TRUE(false);
+ return;
+ }
+ unsigned long long total = 0;
+ double average = 0;
+ bool outValue = true;
+ for (int k = 0; k < 1000; ++k) {
+ auto t1 = std::chrono::high_resolution_clock::now();
+ rm->GetBooleanByName("boolean_1", outValue);
+ auto t2 = std::chrono::high_resolution_clock::now();
+ total += std::chrono::duration_cast(t2 - t1).count();
+ }
+ average = total / 1000.0;
+ g_logLevel = LOG_DEBUG;
+ HILOG_DEBUG("avg cost 020: %f us", average);
+ EXPECT_LT(average, 500);
+};
+
+/*
+ * @tc.name: ResourceManagerPerformanceFuncTest021
+ * @tc.desc: Test GetIntegerById
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest021, TestSize.Level1)
+{
+ if (rm == nullptr) {
+ EXPECT_TRUE(false);
+ return;
+ }
+ unsigned long long total = 0;
+ double average = 0;
+ int id = GetResId("integer_1", ResType::INTEGER);
+ ASSERT_TRUE(id > 0);
+
+ int outValue = 0;
+ for (int k = 0; k < 1000; ++k) {
+ auto t1 = std::chrono::high_resolution_clock::now();
+ rm->GetIntegerById(id, outValue);
+ auto t2 = std::chrono::high_resolution_clock::now();
+ total += std::chrono::duration_cast(t2 - t1).count();
+ }
+ average = total / 1000.0;
+ g_logLevel = LOG_DEBUG;
+ HILOG_DEBUG("avg cost 021: %f us", average);
+ EXPECT_LT(average, 500);
+};
+
+/*
+ * @tc.name: ResourceManagerPerformanceFuncTest022
+ * @tc.desc: Test GetIntegerByName
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest022, TestSize.Level1)
+{
+ if (rm == nullptr) {
+ EXPECT_TRUE(false);
+ return;
+ }
+ unsigned long long total = 0;
+ double average = 0;
+ int outValue = 0;
+ for (int k = 0; k < 1000; ++k) {
+ auto t1 = std::chrono::high_resolution_clock::now();
+ rm->GetIntegerByName("integer_ref", outValue);
+ auto t2 = std::chrono::high_resolution_clock::now();
+ total += std::chrono::duration_cast(t2 - t1).count();
+ }
+ average = total / 1000.0;
+ g_logLevel = LOG_DEBUG;
+ HILOG_DEBUG("avg cost 022: %f us", average);
+ EXPECT_LT(average, 500);
+};
+
+/*
+ * @tc.name: ResourceManagerPerformanceFuncTest023
+ * @tc.desc: Test GetFloatById
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest023, TestSize.Level1)
+{
+ if (rm == nullptr) {
+ EXPECT_TRUE(false);
+ return;
+ }
+ unsigned long long total = 0;
+ double average = 0;
+ int id = GetResId("width_appBar_backButton_touchTarget", ResType::FLOAT);
+ ASSERT_TRUE(id > 0);
+
+ float outValue = 0.0;
+ for (int k = 0; k < 1000; ++k) {
+ auto t1 = std::chrono::high_resolution_clock::now();
+ rm->GetFloatById(id, outValue);
+ auto t2 = std::chrono::high_resolution_clock::now();
+ total += std::chrono::duration_cast(t2 - t1).count();
+ }
+ average = total / 1000.0;
+ g_logLevel = LOG_DEBUG;
+ HILOG_DEBUG("avg cost 023: %f us", average);
+ EXPECT_LT(average, 500);
+};
+
+/*
+ * @tc.name: ResourceManagerPerformanceFuncTest024
+ * @tc.desc: Test GetFloatByName
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest024, TestSize.Level1)
+{
+ if (rm == nullptr) {
+ EXPECT_TRUE(false);
+ return;
+ }
+ unsigned long long total = 0;
+ double average = 0;
+ float outValue = 0;
+ for (int k = 0; k < 1000; ++k) {
+ auto t1 = std::chrono::high_resolution_clock::now();
+ rm->GetFloatByName("width_appBar_backButton_touchTarget", outValue);
+ auto t2 = std::chrono::high_resolution_clock::now();
+ total += std::chrono::duration_cast(t2 - t1).count();
+ }
+ average = total / 1000.0;
+ g_logLevel = LOG_DEBUG;
+ HILOG_DEBUG("avg cost 024: %f us", average);
+ EXPECT_LT(average, 500);
+};
+
+/*
+ * @tc.name: ResourceManagerPerformanceFuncTest025
+ * @tc.desc: Test GetIntArrayById
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest025, TestSize.Level1)
+{
+ if (rm == nullptr) {
+ EXPECT_TRUE(false);
+ return;
+ }
+ unsigned long long total = 0;
+ double average = 0;
+ int id = GetResId("intarray_1", ResType::INTARRAY);
+ ASSERT_TRUE(id > 0);
+
+ std::vector outValue;
+ for (int k = 0; k < 1000; ++k) {
+ auto t1 = std::chrono::high_resolution_clock::now();
+ rm->GetIntArrayById(id, outValue);
+ auto t2 = std::chrono::high_resolution_clock::now();
+ total += std::chrono::duration_cast(t2 - t1).count();
+ }
+ average = total / 1000.0;
+ g_logLevel = LOG_DEBUG;
+ HILOG_DEBUG("avg cost 025: %f us", average);
+ EXPECT_LT(average, 500);
+};
+
+/*
+ * @tc.name: ResourceManagerPerformanceFuncTest026
+ * @tc.desc: Test GetIntArrayByName
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest026, TestSize.Level1)
+{
+ if (rm == nullptr) {
+ EXPECT_TRUE(false);
+ return;
+ }
+ unsigned long long total = 0;
+ double average = 0;
+ std::vector outValue;
+ for (int k = 0; k < 1000; ++k) {
+ auto t1 = std::chrono::high_resolution_clock::now();
+ rm->GetIntArrayByName("intarray_1", outValue);
+ auto t2 = std::chrono::high_resolution_clock::now();
+ total += std::chrono::duration_cast(t2 - t1).count();
+ }
+ average = total / 1000.0;
+ g_logLevel = LOG_DEBUG;
+ HILOG_DEBUG("avg cost 026: %f us", average);
+ EXPECT_LT(average, 500);
+};
+
+/*
+ * @tc.name: ResourceManagerPerformanceFuncTest027
+ * @tc.desc: Test GetColorById
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest027, TestSize.Level1)
+{
+ if (rm == nullptr) {
+ EXPECT_TRUE(false);
+ return;
+ }
+ unsigned long long total = 0;
+ double average = 0;
+ int id = GetResId("divider_color", ResType::COLOR);
+ ASSERT_TRUE(id > 0);
+
+ uint32_t outValue;
+ for (int k = 0; k < 1000; ++k) {
+ auto t1 = std::chrono::high_resolution_clock::now();
+ rm->GetColorById(id, outValue);
+ auto t2 = std::chrono::high_resolution_clock::now();
+ total += std::chrono::duration_cast(t2 - t1).count();
+ }
+ average = total / 1000.0;
+ g_logLevel = LOG_DEBUG;
+ HILOG_DEBUG("avg cost 027: %f us", average);
+ EXPECT_LT(average, 500);
+};
+
+/*
+ * @tc.name: ResourceManagerPerformanceFuncTest028
+ * @tc.desc: Test GetColorByName
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest028, TestSize.Level1)
+{
+ if (rm == nullptr) {
+ EXPECT_TRUE(false);
+ return;
+ }
+ unsigned long long total = 0;
+ double average = 0;
+ uint32_t outValue;
+ for (int k = 0; k < 1000; ++k) {
+ auto t1 = std::chrono::high_resolution_clock::now();
+ rm->GetColorByName("divider_color", outValue);
+ auto t2 = std::chrono::high_resolution_clock::now();
+ total += std::chrono::duration_cast(t2 - t1).count();
+ }
+ average = total / 1000.0;
+ g_logLevel = LOG_DEBUG;
+ HILOG_DEBUG("avg cost 028: %f us", average);
+ EXPECT_LT(average, 500);
+};
+
+/*
+ * @tc.name: ResourceManagerPerformanceFuncTest029
+ * @tc.desc: Test GetProfileById
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest029, TestSize.Level1)
+{
+ if (rm == nullptr) {
+ EXPECT_TRUE(false);
+ return;
+ }
+ unsigned long long total = 0;
+ double average = 0;
+ int id = GetResId("test_common", ResType::PROF);
+ ASSERT_TRUE(id > 0);
+
+ string outValue;
+ for (int k = 0; k < 1000; ++k) {
+ auto t1 = std::chrono::high_resolution_clock::now();
+ rm->GetProfileById(id, outValue);
+ auto t2 = std::chrono::high_resolution_clock::now();
+ total += std::chrono::duration_cast(t2 - t1).count();
+ }
+ average = total / 1000.0;
+ g_logLevel = LOG_DEBUG;
+ HILOG_DEBUG("avg cost 029: %f us", average);
+ EXPECT_LT(average, 500);
+};
+
+/*
+ * @tc.name: ResourceManagerPerformanceFuncTest030
+ * @tc.desc: Test GetProfileByName
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest030, TestSize.Level1)
+{
+ if (rm == nullptr) {
+ EXPECT_TRUE(false);
+ return;
+ }
+ unsigned long long total = 0;
+ double average = 0;
+ string outValue;
+ for (int k = 0; k < 1000; ++k) {
+ auto t1 = std::chrono::high_resolution_clock::now();
+ rm->GetProfileByName("test_common", outValue);
+ auto t2 = std::chrono::high_resolution_clock::now();
+ total += std::chrono::duration_cast(t2 - t1).count();
+ }
+ average = total / 1000.0;
+ g_logLevel = LOG_DEBUG;
+ HILOG_DEBUG("avg cost 030: %f us", average);
+ EXPECT_LT(average, 500);
+};
+
+/*
+ * @tc.name: ResourceManagerPerformanceFuncTest031
+ * @tc.desc: Test GetMediaById
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest031, TestSize.Level1)
+{
+ if (rm == nullptr) {
+ EXPECT_TRUE(false);
+ return;
+ }
+ unsigned long long total = 0;
+ double average = 0;
+ int id = GetResId("icon", ResType::MEDIA);
+ ASSERT_TRUE(id > 0);
+
+ string outValue;
+ for (int k = 0; k < 1000; ++k) {
+ auto t1 = std::chrono::high_resolution_clock::now();
+ rm->GetMediaById(id, outValue);
+ auto t2 = std::chrono::high_resolution_clock::now();
+ total += std::chrono::duration_cast(t2 - t1).count();
+ }
+ average = total / 1000.0;
+ g_logLevel = LOG_DEBUG;
+ HILOG_DEBUG("avg cost 031: %f us", average);
+ EXPECT_LT(average, 500);
+};
+
+/*
+ * @tc.name: ResourceManagerPerformanceFuncTest032
+ * @tc.desc: Test GetMediaByName
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerPerformanceTest, ResourceManagerPerformanceFuncTest032, TestSize.Level1)
+{
+ if (rm == nullptr) {
+ EXPECT_TRUE(false);
+ return;
+ }
+ unsigned long long total = 0;
+ double average = 0;
+ string outValue;
+ for (int k = 0; k < 1000; ++k) {
+ auto t1 = std::chrono::high_resolution_clock::now();
+ rm->GetMediaByName("icon", outValue);
+ auto t2 = std::chrono::high_resolution_clock::now();
+ total += std::chrono::duration_cast(t2 - t1).count();
+ }
+ average = total / 1000.0;
+ g_logLevel = LOG_DEBUG;
+ HILOG_DEBUG("avg cost 032: %f us", average);
+ EXPECT_LT(average, 500);
+};
diff --git a/global_lite/i18n_lite/resource_parse_load/src/resource_manager_performance_test.h b/global_lite/i18n_lite/resource_parse_load/src/resource_manager_performance_test.h
new file mode 100755
index 0000000000000000000000000000000000000000..7269ed78ad136a794094e58cdfc7b3ab32e94d8e
--- /dev/null
+++ b/global_lite/i18n_lite/resource_parse_load/src/resource_manager_performance_test.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef RESOURCE_MANAGER_RESOURCE_MANANGER_PERF_TEST_H
+#define RESOURCE_MANAGER_RESOURCE_MANANGER_PERF_TEST_H
+
+int ResourceManagerPerformanceFuncTest001();
+int ResourceManagerPerformanceFuncTest002();
+int ResourceManagerPerformanceFuncTest003();
+int ResourceManagerPerformanceFuncTest004();
+int ResourceManagerPerformanceFuncTest005();
+int ResourceManagerPerformanceFuncTest006();
+int ResourceManagerPerformanceFuncTest007();
+int ResourceManagerPerformanceFuncTest008();
+int ResourceManagerPerformanceFuncTest009();
+int ResourceManagerPerformanceFuncTest010();
+int ResourceManagerPerformanceFuncTest011();
+int ResourceManagerPerformanceFuncTest012();
+int ResourceManagerPerformanceFuncTest013();
+int ResourceManagerPerformanceFuncTest014();
+int ResourceManagerPerformanceFuncTest015();
+int ResourceManagerPerformanceFuncTest016();
+int ResourceManagerPerformanceFuncTest017();
+int ResourceManagerPerformanceFuncTest018();
+int ResourceManagerPerformanceFuncTest019();
+int ResourceManagerPerformanceFuncTest020();
+int ResourceManagerPerformanceFuncTest021();
+int ResourceManagerPerformanceFuncTest022();
+int ResourceManagerPerformanceFuncTest023();
+int ResourceManagerPerformanceFuncTest024();
+int ResourceManagerPerformanceFuncTest025();
+int ResourceManagerPerformanceFuncTest026();
+int ResourceManagerPerformanceFuncTest027();
+int ResourceManagerPerformanceFuncTest028();
+int ResourceManagerPerformanceFuncTest029();
+int ResourceManagerPerformanceFuncTest030();
+int ResourceManagerPerformanceFuncTest031();
+int ResourceManagerPerformanceFuncTest032();
+
+#endif
diff --git a/global_lite/i18n_lite/resource_parse_load/src/resource_manager_test.cpp b/global_lite/i18n_lite/resource_parse_load/src/resource_manager_test.cpp
new file mode 100755
index 0000000000000000000000000000000000000000..78896733b748ddbc80bbe9476b667016a8fbec9f
--- /dev/null
+++ b/global_lite/i18n_lite/resource_parse_load/src/resource_manager_test.cpp
@@ -0,0 +1,1703 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "resource_manager_test.h"
+
+#include
+#include
+#include
+#define private public
+
+#include "res_config.h"
+#include "resource_manager.h"
+#include "resource_manager_impl.h"
+#include "test_common.h"
+#include "utils/errors.h"
+#include "utils/string_utils.h"
+
+using namespace OHOS::Global::Resource;
+using namespace testing::ext;
+
+static const int NON_EXIST_ID = 1111;
+
+static const char *g_nonExistName = "non_existent_name";
+class ResourceManagerTest : public testing::Test {
+public:
+ static void SetUpTestCase(void);
+
+ static void TearDownTestCase(void);
+
+ void SetUp();
+
+ void TearDown();
+
+ ResourceManagerTest() : rm(nullptr)
+ {}
+
+ ~ResourceManagerTest()
+ {}
+
+public:
+ ResourceManager *rm;
+
+ int GetResId(std::string name, ResType resType) const;
+
+ void TestStringByName(const char *name, const char *cmp) const;
+
+ void TestStringById(const char *name, const char *cmp) const;
+
+ void TestPluralStringById(int quantity, const char *cmp, bool format = false) const;
+
+ void TestPluralStringByName(int quantity, const char *cmp, bool format = false) const;
+
+ void AddResource(const char *language, const char *script, const char *region);
+};
+
+int ResourceManagerTest::GetResId(std::string name, ResType resType) const
+{
+ auto idv = ((ResourceManagerImpl *)rm)->hapManager_->GetResourceListByName(name.c_str(), resType);
+ if (idv == nullptr) {
+ return -1;
+ }
+
+ PrintIdValues(idv);
+ if (idv->GetLimitPathsConst().size() > 0) {
+ return idv->GetLimitPathsConst()[0]->GetIdItem()->id_;
+ }
+ return OBJ_NOT_FOUND;
+}
+
+void ResourceManagerTest::TestStringByName(const char *name, const char *cmp) const
+{
+ RState rState;
+ std::string outValue;
+ rState = rm->GetStringByName(name, outValue);
+ ASSERT_EQ(SUCCESS, rState);
+ HILOG_DEBUG("%s : %s", name, outValue.c_str());
+ ASSERT_EQ(std::string(cmp), outValue);
+}
+
+void ResourceManagerTest::TestStringById(const char *name, const char *cmp) const
+{
+ RState rState;
+ std::string outValue;
+ int id = GetResId(name, ResType::STRING);
+ ASSERT_TRUE(id > 0);
+ rState = rm->GetStringById(id, outValue);
+ ASSERT_EQ(SUCCESS, rState);
+ ASSERT_EQ(std::string(cmp), outValue);
+}
+
+void ResourceManagerTest::AddResource(const char *language, const char *script, const char *region)
+{
+ if (language != nullptr || region != nullptr) {
+ auto rc = CreateResConfig();
+ if (rc == nullptr) {
+ EXPECT_TRUE(false);
+ return;
+ }
+ rc->SetLocaleInfo(language, script, region);
+ rm->UpdateResConfig(*rc);
+ delete rc;
+ }
+ bool ret = rm->AddResource(FormatFullPath(g_resFilePath).c_str());
+ ASSERT_TRUE(ret);
+}
+
+void ResourceManagerTest::TestPluralStringById(int quantity, const char *cmp, bool format) const
+{
+ RState ret;
+ std::string outValue;
+ int id = GetResId("eat_apple", ResType::PLURALS);
+ if (format) {
+ ret = rm->GetPluralStringByIdFormat(outValue, id, quantity, quantity);
+ } else {
+ ret = rm->GetPluralStringById(id, quantity, outValue);
+ }
+
+ ASSERT_EQ(SUCCESS, ret);
+ ASSERT_EQ(std::string(cmp), outValue);
+}
+
+void ResourceManagerTest::TestPluralStringByName(int quantity, const char *cmp, bool format) const
+{
+ RState ret;
+ std::string outValue;
+ const char *name = "eat_apple";
+ if (format) {
+ ret = rm->GetPluralStringByNameFormat(outValue, name, quantity, quantity);
+ } else {
+ ret = rm->GetPluralStringByName(name, quantity, outValue);
+ }
+
+ ASSERT_EQ(SUCCESS, ret);
+ ASSERT_EQ(std::string(cmp), outValue);
+}
+
+void ResourceManagerTest::SetUpTestCase(void)
+{
+ // step 1: input testsuit setup step
+ g_logLevel = LOG_DEBUG;
+}
+
+void ResourceManagerTest::TearDownTestCase(void)
+{
+ // step 2: input testsuit teardown step
+}
+
+void ResourceManagerTest::SetUp(void)
+{
+ this->rm = CreateResourceManager();
+}
+
+void ResourceManagerTest::TearDown(void)
+{
+ delete this->rm;
+}
+
+/*
+ * @tc.name: ResourceManagerAddResourceTest001
+ * @tc.desc: Test AddResource function, file case.
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerAddResourceTest001, TestSize.Level1)
+{
+ // success cases
+ bool ret = rm->AddResource(FormatFullPath(g_resFilePath).c_str());
+ ASSERT_TRUE(ret);
+};
+
+/*
+ * @tc.name: ResourceManagerAddResourceTest002
+ * @tc.desc: Test AddResource function, file case.
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerAddResourceTest002, TestSize.Level1)
+{
+ // error cases
+ // file not exist
+ bool ret = rm->AddResource("/data/test/do_not_exist.resources");
+ ASSERT_TRUE(!ret);
+}
+
+/*
+ * @tc.name: ResourceManagerAddResourceTest003
+ * @tc.desc: Test AddResource function, file case.
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerAddResourceTest003, TestSize.Level1)
+{
+ // error cases
+ // reload the same path
+ bool ret = rm->AddResource(FormatFullPath(g_resFilePath).c_str());
+ ASSERT_TRUE(ret);
+ ret = rm->AddResource(FormatFullPath(g_resFilePath).c_str());
+ ASSERT_TRUE(!ret);
+}
+
+/*
+ * @tc.name: ResourceManagerUpdateResConfigTest001
+ * @tc.desc: Test UpdateResConfig function
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerUpdateResConfigTest001, TestSize.Level1)
+{
+ // success cases
+ RState state;
+ ResConfig *rc = CreateResConfig();
+ if (rc == nullptr) {
+ EXPECT_TRUE(false);
+ return;
+ }
+ rc->SetLocaleInfo("en", nullptr, "US");
+ rc->SetDeviceType(DeviceType::DEVICE_CAR);
+ state = rm->UpdateResConfig(*rc);
+ delete rc;
+ EXPECT_EQ(SUCCESS, state);
+}
+
+/*
+ * @tc.name: ResourceManagerUpdateResConfigTest002
+ * @tc.desc: Test UpdateResConfig function
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerUpdateResConfigTest002, TestSize.Level1)
+{
+ // error cases
+ RState state;
+ ResConfig *rc = CreateResConfig();
+ if (rc == nullptr) {
+ EXPECT_TRUE(false);
+ return;
+ }
+ state = rm->UpdateResConfig(*rc);
+ delete rc;
+ EXPECT_EQ(LOCALEINFO_IS_NULL, state);
+}
+
+/*
+ * @tc.name: ResourceManagerUpdateResConfigTest003
+ * @tc.desc: Test UpdateResConfig function
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerUpdateResConfigTest003, TestSize.Level1)
+{
+ // error cases
+ RState state;
+ ResConfig *rc = CreateResConfig();
+ if (rc == nullptr) {
+ EXPECT_TRUE(false);
+ return;
+ }
+ rc->SetLocaleInfo(nullptr, nullptr, "US");
+ state = rm->UpdateResConfig(*rc);
+ delete rc;
+ EXPECT_EQ(LOCALEINFO_IS_NULL, state);
+}
+
+/*
+ * load a hap, defaultConfig set to en, then switch to zh
+ * @tc.name: ResourceManagerUpdateResConfigTest004
+ * @tc.desc: Test UpdateResConfig function
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerUpdateResConfigTest004, TestSize.Level1)
+{
+ // success case
+ bool ret = true;
+ RState state;
+ ResConfig *rc = CreateResConfig();
+ if (rc == nullptr) {
+ EXPECT_TRUE(false);
+ return;
+ }
+ rc->SetLocaleInfo("en", nullptr, nullptr);
+ state = rm->UpdateResConfig(*rc);
+ EXPECT_EQ(SUCCESS, state);
+ ret = rm->AddResource(FormatFullPath(g_resFilePath).c_str());
+ if (!ret) {
+ EXPECT_TRUE(false);
+ delete rc;
+ return;
+ }
+ // update to another language, will trigger reload
+ // before reload:
+ TestStringByName("app_name", "App Name");
+
+ rc->SetLocaleInfo("zh", nullptr, nullptr);
+ state = rm->UpdateResConfig(*rc);
+ delete rc;
+ EXPECT_EQ(SUCCESS, state);
+ // after reload:
+ TestStringByName("app_name", "应用名称");
+}
+
+/*
+ * @tc.name: ResourceManagerUpdateResConfigTest005
+ * @tc.desc: Test UpdateResConfig function
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerUpdateResConfigTest005, TestSize.Level1)
+{
+ // error case
+ AddResource("zh", nullptr, nullptr);
+
+ // make a fake hapResource, then reload will fail
+ HapResource *hapResource = new HapResource("/data/test/non_exist", 0, nullptr, nullptr);
+ ((ResourceManagerImpl *)rm)->hapManager_->hapResources_.push_back(hapResource);
+ RState state;
+ ResConfig *rc = CreateResConfig();
+ if (rc == nullptr) {
+ EXPECT_TRUE(false);
+ return;
+ }
+ rc->SetLocaleInfo("en", nullptr, "US");
+ state = rm->UpdateResConfig(*rc);
+ delete rc;
+ EXPECT_EQ(HAP_INIT_FAILED, state);
+}
+
+/*
+ * @tc.name: ResourceManagerGetResConfigTest001
+ * @tc.desc: Test GetResConfig function
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetResConfigTest001, TestSize.Level1)
+{
+ // success cases
+ ResConfigImpl rc;
+ rm->GetResConfig(rc);
+ EXPECT_EQ(nullptr, rc.GetLocaleInfo());
+ EXPECT_EQ(DIRECTION_NOT_SET, rc.GetDirection());
+ EXPECT_EQ(SCREEN_DENSITY_NOT_SET, rc.GetScreenDensity());
+ EXPECT_EQ(DEVICE_NOT_SET, rc.GetDeviceType());
+}
+
+/*
+ * @tc.name: ResourceManagerGetResConfigTest002
+ * @tc.desc: Test GetResConfig function
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetResConfigTest002, TestSize.Level1)
+{
+ // success cases
+ RState state;
+ {
+ ResConfig *rc = CreateResConfig();
+ if (rc == nullptr) {
+ EXPECT_TRUE(false);
+ return;
+ }
+ rc->SetLocaleInfo("en", nullptr, "US");
+ rc->SetDeviceType(DeviceType::DEVICE_CAR);
+ state = rm->UpdateResConfig(*rc);
+ delete rc;
+ EXPECT_EQ(SUCCESS, state);
+ }
+
+ ResConfigImpl rc;
+ rm->GetResConfig(rc);
+ EXPECT_EQ("en", std::string(rc.GetLocaleInfo()->GetLanguage()));
+ EXPECT_EQ(DEVICE_CAR, rc.GetDeviceType());
+}
+
+/*
+ * @tc.name: ResourceManagerGetStringByIdTest001
+ * @tc.desc: Test GetStringById function
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetStringByIdTest001, TestSize.Level1)
+{
+ AddResource("en", nullptr, nullptr);
+
+ TestStringById("app_name", "App Name");
+
+ TestStringById("copyright_text", "XXXXXX All rights reserved. ©2011-2019");
+
+ TestStringById("string_ref", "XXXXXX All rights reserved. ©2011-2019");
+
+ TestStringById("string_ref2", "XXXXXX All rights reserved. ©2011-2019");
+}
+
+/*
+ * @tc.name: ResourceManagerGetStringByIdTest002
+ * @tc.desc: Test GetStringById function
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetStringByIdTest002, TestSize.Level1)
+{
+ AddResource("zh", nullptr, nullptr);
+
+ TestStringById("app_name", "应用名称");
+
+ TestStringById("copyright_text", "版权所有 ©2011-2019 XXXX有限公司保留一切权利");
+
+ TestStringById("string_ref", "$aaaaa");
+
+ TestStringById("string_ref2", "$aaaaa");
+}
+
+/*
+ * @tc.name: ResourceManagerGetStringByIdTest003
+ * @tc.desc: Test GetStringById function
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetStringByIdTest003, TestSize.Level1)
+{
+ AddResource("zh", nullptr, nullptr);
+
+ std::string outValue;
+ RState state = rm->GetStringById(NON_EXIST_ID, outValue);
+ ASSERT_EQ(NOT_FOUND, state);
+}
+
+/*
+ * @tc.name: ResourceManagerGetStringByNameTest001
+ * @tc.desc: Test GetStringByName function
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetStringByNameTest001, TestSize.Level1)
+{
+ AddResource("en", nullptr, nullptr);
+
+ TestStringByName("app_name", "App Name");
+
+ TestStringByName("copyright_text", "XXXXXX All rights reserved. ©2011-2019");
+
+ TestStringByName("string_ref", "XXXXXX All rights reserved. ©2011-2019");
+
+ TestStringByName("string_ref2", "XXXXXX All rights reserved. ©2011-2019");
+}
+
+/*
+ * @tc.name: ResourceManagerGetStringByNameTest002
+ * @tc.desc: Test GetStringByName function
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetStringByNameTest002, TestSize.Level1)
+{
+ AddResource("zh", nullptr, nullptr);
+
+ TestStringByName("app_name", "应用名称");
+
+ TestStringByName("copyright_text", "版权所有 ©2011-2019 XXXX有限公司保留一切权利");
+
+ TestStringByName("string_ref", "$aaaaa");
+
+ TestStringByName("string_ref2", "$aaaaa");
+}
+
+/*
+ * @tc.name: ResourceManagerGetStringByNameTest003
+ * @tc.desc: Test GetStringByName function
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetStringByNameTest003, TestSize.Level1)
+{
+ AddResource("zh", nullptr, nullptr);
+
+ std::string outValue;
+ RState state = rm->GetStringByName(g_nonExistName, outValue);
+ ASSERT_EQ(NOT_FOUND, state);
+}
+
+/*
+ * @tc.name: ResourceManagerGetStringFormatByIdTest001
+ * @tc.desc: Test GetStringFormatById function
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetStringFormatByIdTest001, TestSize.Level1)
+{
+ AddResource("zh", nullptr, nullptr);
+
+ const char *name = "app_name";
+ int id = GetResId(name, ResType::STRING);
+ ASSERT_TRUE(id > 0);
+ std::string outValue;
+ RState state = rm->GetStringFormatById(outValue, id, 101);
+ ASSERT_EQ(SUCCESS, state);
+ ASSERT_EQ("应用名称", outValue);
+}
+
+/*
+ * @tc.name: ResourceManagerGetStringFormatByIdTest002
+ * @tc.desc: Test GetStringFormatById function
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetStringFormatByIdTest002, TestSize.Level1)
+{
+ AddResource("zh", nullptr, nullptr);
+
+ std::string outValue;
+ RState state = rm->GetStringFormatById(outValue, NON_EXIST_ID, 101);
+ ASSERT_EQ(NOT_FOUND, state);
+}
+
+/*
+ * @tc.name: ResourceManagerGetStringFormatByNameTest001
+ * @tc.desc: Test GetStringFormatByName function
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetStringFormatByNameTest001, TestSize.Level1)
+{
+ AddResource("zh", nullptr, nullptr);
+
+ const char *name = "app_name";
+ std::string outValue;
+ RState state = rm->GetStringFormatByName(outValue, name, 101);
+ ASSERT_EQ(SUCCESS, state);
+ ASSERT_EQ("应用名称", outValue);
+}
+
+/*
+ * @tc.name: ResourceManagerGetStringFormatByNameTest002
+ * @tc.desc: Test GetStringFormatByName function
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetStringFormatByNameTest002, TestSize.Level1)
+{
+ AddResource("zh", nullptr, nullptr);
+
+ std::string outValue;
+ RState state = rm->GetStringFormatByName(outValue, g_nonExistName, 101);
+ ASSERT_EQ(NOT_FOUND, state);
+}
+
+/*
+ * @tc.name: ResourceManagerGetStringArrayByIdTest001
+ * @tc.desc: Test GetStringArrayById function, file case.
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetStringArrayByIdTest001, TestSize.Level1)
+{
+ AddResource("zh", nullptr, nullptr);
+
+ int id;
+ std::vector outValue;
+ RState state;
+
+ id = GetResId("size", ResType::STRINGARRAY);
+ state = rm->GetStringArrayById(id, outValue);
+ ASSERT_EQ(SUCCESS, state);
+ ASSERT_EQ(static_cast(4), outValue.size());
+ PrintVectorString(outValue);
+
+ // by name
+ state = rm->GetStringArrayByName("size", outValue);
+ ASSERT_EQ(SUCCESS, state);
+ ASSERT_EQ(static_cast(4), outValue.size());
+ PrintVectorString(outValue);
+}
+
+/*
+ * @tc.name: ResourceManagerGetStringArrayByIdTest002
+ * @tc.desc: Test GetStringArrayById function, file case.
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetStringArrayByIdTest002, TestSize.Level1)
+{
+ AddResource("zh", nullptr, nullptr);
+
+ RState state;
+ // error case
+ // not found case
+ std::vector outValue;
+ state = rm->GetStringArrayById(NON_EXIST_ID, outValue);
+ ASSERT_EQ(NOT_FOUND, state);
+}
+
+/*
+ * @tc.name: ResourceManagerGetStringArrayByNameTest001
+ * @tc.desc: Test GetStringArrayByName function, file case.
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetStringArrayByNameTest001, TestSize.Level1)
+{
+ AddResource("zh", nullptr, nullptr);
+
+ std::vector outValue;
+ RState state;
+
+ // by name
+ state = rm->GetStringArrayByName("size", outValue);
+ ASSERT_EQ(SUCCESS, state);
+ ASSERT_EQ(static_cast(4), outValue.size());
+ PrintVectorString(outValue);
+}
+
+/*
+ * @tc.name: ResourceManagerGetStringArrayByNameTest002
+ * @tc.desc: Test GetStringArrayByName function, file case.
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetStringArrayByNameTest002, TestSize.Level1)
+{
+ AddResource("zh", nullptr, nullptr);
+
+ RState state;
+ // error case
+ // not found case
+ std::vector outValue;
+ state = rm->GetStringArrayByName(g_nonExistName, outValue);
+ ASSERT_EQ(NOT_FOUND, state);
+}
+
+/*
+ * @tc.name: ResourceManagerGetPatternByIdTest001
+ * @tc.desc: Test GetPatternById function, file case.
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetPatternByIdTest001, TestSize.Level1)
+{
+ AddResource("zh", nullptr, nullptr);
+
+ int id;
+ std::map outValue;
+ RState state;
+
+ id = GetResId("base", ResType::PATTERN);
+ state = rm->GetPatternById(id, outValue);
+ ASSERT_EQ(SUCCESS, state);
+ ASSERT_EQ(static_cast(3), outValue.size());
+ PrintMapString(outValue);
+}
+
+/*
+ * @tc.name: ResourceManagerGetPatternByIdTest002
+ * @tc.desc: Test GetPatternById function, file case.
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetPatternByIdTest002, TestSize.Level1)
+{
+ AddResource("zh", nullptr, nullptr);
+
+ int id;
+ std::map outValue;
+ RState state;
+
+ id = GetResId("child", ResType::PATTERN);
+ state = rm->GetPatternById(id, outValue);
+ ASSERT_EQ(SUCCESS, state);
+ ASSERT_EQ(static_cast(4), outValue.size());
+ PrintMapString(outValue);
+}
+
+/*
+ * @tc.name: ResourceManagerGetPatternByIdTest003
+ * @tc.desc: Test GetPatternById function, file case.
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetPatternByIdTest003, TestSize.Level1)
+{
+ AddResource("zh", nullptr, nullptr);
+
+ int id;
+ std::map outValue;
+ RState state;
+
+ id = GetResId("ccchild", ResType::PATTERN);
+ state = rm->GetPatternById(id, outValue);
+ ASSERT_EQ(SUCCESS, state);
+ ASSERT_EQ(static_cast(5), outValue.size());
+ PrintMapString(outValue);
+}
+
+/*
+ * @tc.name: ResourceManagerGetPatternByIdTest004
+ * @tc.desc: Test GetPatternById function, file case.
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetPatternByIdTest004, TestSize.Level1)
+{
+ AddResource("zh", nullptr, nullptr);
+
+ std::map outValue;
+ RState state;
+
+ // not found case
+ state = rm->GetPatternById(NON_EXIST_ID, outValue);
+ ASSERT_EQ(NOT_FOUND, state);
+}
+
+/*
+ * @tc.name: ResourceManagerGetPatternByNameTest001
+ * @tc.desc: Test GetPatternByName function, file case.
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetPatternByNameTest001, TestSize.Level1)
+{
+ AddResource("zh", nullptr, nullptr);
+
+ std::map outValue;
+ RState state;
+
+ state = rm->GetPatternByName("base", outValue);
+ ASSERT_EQ(SUCCESS, state);
+ ASSERT_EQ(static_cast(3), outValue.size());
+ PrintMapString(outValue);
+}
+
+/*
+ * @tc.name: ResourceManagerGetPatternByNameTest002
+ * @tc.desc: Test GetPatternByName function, file case.
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetPatternByNameTest002, TestSize.Level1)
+{
+ AddResource("zh", nullptr, nullptr);
+
+ std::map outValue;
+ RState state;
+
+ state = rm->GetPatternByName("child", outValue);
+ ASSERT_EQ(SUCCESS, state);
+ ASSERT_EQ(static_cast(4), outValue.size());
+ PrintMapString(outValue);
+}
+
+/*
+ * @tc.name: ResourceManagerGetPatternByNameTest003
+ * @tc.desc: Test GetPatternByName function, file case.
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetPatternByNameTest003, TestSize.Level1)
+{
+ AddResource("zh", nullptr, nullptr);
+
+ std::map outValue;
+ RState state;
+
+ state = rm->GetPatternByName("ccchild", outValue);
+ ASSERT_EQ(SUCCESS, state);
+ ASSERT_EQ(static_cast(5), outValue.size());
+ PrintMapString(outValue);
+}
+
+/*
+ * @tc.name: ResourceManagerGetPatternByNameTest004
+ * @tc.desc: Test GetPatternByName function, file case.
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetPatternByNameTest004, TestSize.Level1)
+{
+ AddResource("zh", nullptr, nullptr);
+
+ std::map outValue;
+ RState state;
+
+ // not found case
+ state = rm->GetPatternByName(g_nonExistName, outValue);
+ ASSERT_EQ(NOT_FOUND, state);
+}
+
+/*
+ * @tc.name: ResourceManagerGetPluralStringByIdTest001
+ * @tc.desc: Test GetPluralStringById function, file case.
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetPluralStringByIdTest001, TestSize.Level1)
+{
+ AddResource("en", nullptr, "US");
+
+ int quantity = 1;
+ TestPluralStringById(quantity, "%d apple", false);
+
+ quantity = 101;
+ TestPluralStringById(quantity, "%d apples", false);
+}
+
+/*
+ * @tc.name: ResourceManagerGetPluralStringByIdTest002
+ * @tc.desc: Test GetPluralStringById function, file case.
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetPluralStringByIdTest002, TestSize.Level1)
+{
+ AddResource("zh", nullptr, "CN");
+
+ int quantity = 1;
+ TestPluralStringById(quantity, "%d apples", false);
+
+ quantity = 101;
+ TestPluralStringById(quantity, "%d apples", false);
+}
+
+/*
+ * @tc.name: ResourceManagerGetPluralStringByIdTest003
+ * @tc.desc: Test GetPluralStringById function, file case.
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetPluralStringByIdTest003, TestSize.Level1)
+{
+ AddResource("pl", nullptr, "PL");
+
+ int quantity = 1;
+ TestPluralStringById(quantity, "1 jabłko");
+
+ quantity = 2;
+ TestPluralStringById(quantity, "%d jabłka");
+
+ quantity = 23;
+ TestPluralStringById(quantity, "%d jabłka");
+
+ quantity = 12;
+ TestPluralStringById(quantity, "%d jabłek");
+}
+
+/*
+ * @tc.name: ResourceManagerGetPluralStringByIdTest004
+ * @tc.desc: Test GetPluralStringById function, file case.
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetPluralStringByIdTest004, TestSize.Level1)
+{
+ AddResource("ar", nullptr, "SA");
+
+ int quantity = 0;
+ TestPluralStringById(quantity, "zero-0");
+ quantity = 1;
+ TestPluralStringById(quantity, "one-1");
+ quantity = 2;
+ TestPluralStringById(quantity, "two-2");
+ quantity = 5;
+ TestPluralStringById(quantity, "few-%d");
+ quantity = 12;
+ TestPluralStringById(quantity, "many-%d");
+ quantity = 500;
+ TestPluralStringById(quantity, "other-%d");
+}
+
+/*
+ * @tc.name: ResourceManagerGetPluralStringByIdTest005
+ * @tc.desc: Test GetPluralStringById function, file case.
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetPluralStringByIdTest005, TestSize.Level1)
+{
+ AddResource("ar", nullptr, "SA");
+
+ RState state;
+ std::string outValue;
+ state = rm->GetPluralStringById(NON_EXIST_ID, 1, outValue);
+ ASSERT_EQ(NOT_FOUND, state);
+}
+
+/*
+ * @tc.name: ResourceManagerGetPluralStringByNameTest001
+ * @tc.desc: Test GetPluralStringByName function, file case.
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetPluralStringByNameTest001, TestSize.Level1)
+{
+ AddResource("en", nullptr, "US");
+
+ int quantity = 1;
+ TestPluralStringByName(quantity, "%d apple", false);
+
+ quantity = 101;
+ TestPluralStringByName(quantity, "%d apples", false);
+}
+
+/*
+ * @tc.name: ResourceManagerGetPluralStringByNameTest002
+ * @tc.desc: Test GetPluralStringByName function, file case.
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetPluralStringByNameTest002, TestSize.Level1)
+{
+ AddResource("ar", nullptr, "SA");
+
+ RState state;
+ std::string outValue;
+ state = rm->GetPluralStringByName(g_nonExistName, 1, outValue);
+ ASSERT_EQ(NOT_FOUND, state);
+}
+
+/*
+ * @tc.name: ResourceManagerGetPluralStringByIdFormatTest001
+ * @tc.desc: Test GetPluralStringByIdFormat function, file case.
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetPluralStringByIdFormatTest001, TestSize.Level1)
+{
+ AddResource("zh", nullptr, "CN");
+
+ int quantity = 1;
+ TestPluralStringById(quantity, "1 apples", true);
+
+ quantity = 101;
+ TestPluralStringById(quantity, "101 apples", true);
+}
+
+/*
+ * @tc.name: ResourceManagerGetPluralStringByIdFormatTest002
+ * @tc.desc: Test GetPluralStringByIdFormat function, file case.
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetPluralStringByIdFormatTest002, TestSize.Level1)
+{
+ AddResource("ar", nullptr, "SA");
+
+ RState state;
+ std::string outValue;
+ state = rm->GetPluralStringByIdFormat(outValue, NON_EXIST_ID, 1, 1);
+ ASSERT_EQ(NOT_FOUND, state);
+}
+
+/*
+ * @tc.name: ResourceManagerGetPluralStringByNameFormatTest001
+ * @tc.desc: Test GetPluralStringByNameFormat function, file case.
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetPluralStringByNameFormatTest001, TestSize.Level1)
+{
+ AddResource("zh", nullptr, "CN");
+
+ int quantity = 1;
+ TestPluralStringByName(quantity, "1 apples", true);
+
+ quantity = 101;
+ TestPluralStringByName(quantity, "101 apples", true);
+}
+
+/*
+ * @tc.name: ResourceManagerGetPluralStringByNameFormatTest002
+ * @tc.desc: Test GetPluralStringByNameFormat function, file case.
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetPluralStringByNameFormatTest002, TestSize.Level1)
+{
+ AddResource("ar", nullptr, "SA");
+
+ RState state;
+ std::string outValue;
+ state = rm->GetPluralStringByNameFormat(outValue, g_nonExistName, 1, 1);
+ ASSERT_EQ(NOT_FOUND, state);
+}
+
+/*
+ * @tc.name: ResourceManagerGetThemeByIdTest001
+ * @tc.desc: Test GetThemeById
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetThemeByIdTest001, TestSize.Level1)
+{
+ AddResource("zh", nullptr, "CN");
+
+ std::map outValue;
+ RState state;
+ int id = GetResId("app_theme", ResType::THEME);
+ ASSERT_TRUE(id > 0);
+ state = rm->GetThemeById(id, outValue);
+ ASSERT_EQ(SUCCESS, state);
+ PrintMapString(outValue);
+}
+
+/*
+ * @tc.name: ResourceManagerGetThemeByIdTest002
+ * @tc.desc: Test GetThemeById
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetThemeByIdTest002, TestSize.Level1)
+{
+ AddResource("zh", nullptr, "CN");
+
+ std::map outValue;
+ RState state;
+ state = rm->GetThemeById(NON_EXIST_ID, outValue);
+ ASSERT_EQ(NOT_FOUND, state);
+}
+
+/*
+ * @tc.name: ResourceManagerGetThemeByNameTest001
+ * @tc.desc: Test GetThemeByName
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetThemeByNameTest001, TestSize.Level1)
+{
+ AddResource("zh", nullptr, "CN");
+
+ std::map outValue;
+ RState state;
+ state = rm->GetThemeByName("app_theme", outValue);
+ ASSERT_EQ(SUCCESS, state);
+ PrintMapString(outValue);
+
+ state = rm->GetThemeByName("activity_theme", outValue);
+ ASSERT_EQ(SUCCESS, state);
+ PrintMapString(outValue);
+}
+
+/*
+ * @tc.name: ResourceManagerGetThemeByNameTest002
+ * @tc.desc: Test GetThemeByName
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetThemeByNameTest002, TestSize.Level1)
+{
+ AddResource("zh", nullptr, "CN");
+
+ std::map outValue;
+ RState state;
+ state = rm->GetThemeByName(g_nonExistName, outValue);
+ ASSERT_EQ(NOT_FOUND, state);
+}
+
+/*
+ * @tc.name: ResourceManagerGetBooleanByIdTest001
+ * @tc.desc: Test GetBooleanById
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetBooleanByIdTest001, TestSize.Level1)
+{
+ AddResource("zh", nullptr, "CN");
+
+ bool outValue = true;
+ RState state;
+ int id = GetResId("boolean_1", ResType::BOOLEAN);
+ ASSERT_TRUE(id > 0);
+ state = rm->GetBooleanById(id, outValue);
+ ASSERT_EQ(SUCCESS, state);
+ EXPECT_TRUE(outValue);
+
+ id = GetResId("boolean_ref", ResType::BOOLEAN);
+ ASSERT_TRUE(id > 0);
+ state = rm->GetBooleanById(id, outValue);
+ ASSERT_EQ(SUCCESS, state);
+ EXPECT_TRUE(outValue);
+}
+
+/*
+ * @tc.name: ResourceManagerGetBooleanByIdTest002
+ * @tc.desc: Test GetBooleanById
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetBooleanByIdTest002, TestSize.Level1)
+{
+ AddResource("zh", nullptr, "CN");
+
+ bool outValue = true;
+ RState state;
+ state = rm->GetBooleanById(NON_EXIST_ID, outValue);
+ ASSERT_EQ(NOT_FOUND, state);
+}
+
+/*
+ * @tc.name: ResourceManagerGetBooleanByNameTest001
+ * @tc.desc: Test GetBooleanByName
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetBooleanByNameTest001, TestSize.Level1)
+{
+ AddResource("zh", nullptr, "CN");
+
+ bool outValue = true;
+ RState state;
+ state = rm->GetBooleanByName("boolean_1", outValue);
+ ASSERT_EQ(SUCCESS, state);
+ EXPECT_TRUE(outValue);
+
+ state = rm->GetBooleanByName("boolean_ref", outValue);
+ ASSERT_EQ(SUCCESS, state);
+ EXPECT_TRUE(outValue);
+}
+
+/*
+ * @tc.name: ResourceManagerGetBooleanByNameTest002
+ * @tc.desc: Test GetBooleanByName
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetBooleanByNameTest002, TestSize.Level1)
+{
+ AddResource("zh", nullptr, "CN");
+
+ bool outValue = true;
+ RState state;
+ state = rm->GetBooleanByName(g_nonExistName, outValue);
+ ASSERT_EQ(NOT_FOUND, state);
+}
+
+/*
+ * @tc.name: ResourceManagerGetIntegerByIdTest001
+ * @tc.desc: Test GetIntegerById
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetIntegerByIdTest001, TestSize.Level1)
+{
+ AddResource("zh", nullptr, "CN");
+
+ int outValue;
+ RState state;
+ int id = GetResId("integer_1", ResType::INTEGER);
+ ASSERT_TRUE(id > 0);
+ state = rm->GetIntegerById(id, outValue);
+ ASSERT_EQ(SUCCESS, state);
+ EXPECT_EQ(101, outValue);
+
+ id = GetResId("integer_ref", ResType::INTEGER);
+ ASSERT_TRUE(id > 0);
+ state = rm->GetIntegerById(id, outValue);
+ ASSERT_EQ(SUCCESS, state);
+ EXPECT_EQ(101, outValue);
+}
+
+/*
+ * @tc.name: ResourceManagerGetIntegerByIdTest002
+ * @tc.desc: Test GetIntegerById
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetIntegerByIdTest002, TestSize.Level1)
+{
+ AddResource("zh", nullptr, "CN");
+
+ int outValue;
+ RState state;
+ state = rm->GetIntegerById(NON_EXIST_ID, outValue);
+ ASSERT_EQ(NOT_FOUND, state);
+}
+
+/*
+ * @tc.name: ResourceManagerGetIntegerByNameTest001
+ * @tc.desc: Test GetIntegerByName
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetIntegerByNameTest001, TestSize.Level1)
+{
+ AddResource("zh", nullptr, "CN");
+
+ int outValue;
+ RState state;
+ state = rm->GetIntegerByName("integer_1", outValue);
+ ASSERT_EQ(SUCCESS, state);
+ EXPECT_EQ(101, outValue);
+
+ state = rm->GetIntegerByName("integer_ref", outValue);
+ ASSERT_EQ(SUCCESS, state);
+ EXPECT_EQ(101, outValue);
+}
+
+/*
+ * @tc.name: ResourceManagerGetIntegerByNameTest002
+ * @tc.desc: Test GetIntegerByName
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetIntegerByNameTest002, TestSize.Level1)
+{
+ AddResource("zh", nullptr, "CN");
+
+ int outValue;
+ RState state;
+ state = rm->GetIntegerByName(g_nonExistName, outValue);
+ ASSERT_EQ(NOT_FOUND, state);
+}
+
+/*
+ * @tc.name: ResourceManagerGetFloatByIdTest001
+ * @tc.desc: Test GetFloatById
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetFloatByIdTest001, TestSize.Level1)
+{
+ AddResource("zh", nullptr, "CN");
+
+ float outValue;
+ RState state;
+ int id = GetResId("width_appBar_backButton_touchTarget", ResType::FLOAT);
+ ASSERT_TRUE(id > 0);
+ state = rm->GetFloatById(id, outValue);
+ ASSERT_EQ(SUCCESS, state);
+ EXPECT_EQ(48, outValue); // 50vp
+
+ id = GetResId("float_ref", ResType::FLOAT);
+ ASSERT_TRUE(id > 0);
+ state = rm->GetFloatById(id, outValue);
+ ASSERT_EQ(SUCCESS, state);
+ EXPECT_EQ(707, outValue); // 48vp
+}
+
+/*
+ * @tc.name: ResourceManagerGetFloatByIdTest002
+ * @tc.desc: Test GetFloatById
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetFloatByIdTest002, TestSize.Level1)
+{
+ AddResource("zh", nullptr, "CN");
+
+ float outValue;
+ RState state;
+ state = rm->GetFloatById(NON_EXIST_ID, outValue);
+ ASSERT_EQ(NOT_FOUND, state);
+}
+
+/*
+ * @tc.name: ResourceManagerGetFloatByNameTest001
+ * @tc.desc: Test GetFloatByName
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetFloatByNameTest001, TestSize.Level1)
+{
+ AddResource("zh", nullptr, "CN");
+
+ float outValue;
+ RState state;
+ state = rm->GetFloatByName("width_appBar_backButton_touchTarget", outValue);
+ ASSERT_EQ(SUCCESS, state);
+ EXPECT_EQ(48, outValue); // 50vp
+
+ state = rm->GetFloatByName("float_ref", outValue);
+ ASSERT_EQ(SUCCESS, state);
+ EXPECT_EQ(707, outValue); // 48vp
+}
+
+/*
+ * @tc.name: ResourceManagerGetFloatByNameTest002
+ * @tc.desc: Test GetFloatByName
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetFloatByNameTest002, TestSize.Level1)
+{
+ AddResource("zh", nullptr, "CN");
+
+ float outValue;
+ RState state;
+ state = rm->GetFloatByName(g_nonExistName, outValue);
+ ASSERT_EQ(NOT_FOUND, state);
+}
+
+/*
+ * @tc.name: ResourceManagerGetIntArrayByIdTest001
+ * @tc.desc: Test GetIntArrayById
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetIntArrayByIdTest001, TestSize.Level1)
+{
+ AddResource("zh", nullptr, "CN");
+
+ std::vector outValue;
+ RState state;
+ int id = GetResId("intarray_1", ResType::INTARRAY);
+ EXPECT_TRUE(id > 0);
+ state = rm->GetIntArrayById(id, outValue);
+ EXPECT_TRUE(state == SUCCESS);
+ EXPECT_EQ(static_cast(3), outValue.size());
+ EXPECT_EQ(100, outValue[0]);
+ EXPECT_EQ(200, outValue[1]);
+ EXPECT_EQ(101, outValue[2]);
+}
+
+/*
+ * @tc.name: ResourceManagerGetIntArrayByIdTest002
+ * @tc.desc: Test GetIntArrayById
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetIntArrayByIdTest002, TestSize.Level1)
+{
+ AddResource("zh", nullptr, "CN");
+
+ std::vector outValue;
+ RState state;
+ state = rm->GetIntArrayById(NON_EXIST_ID, outValue);
+ ASSERT_EQ(NOT_FOUND, state);
+}
+
+/*
+ * @tc.name: ResourceManagerGetIntArrayByNameTest001
+ * @tc.desc: Test GetIntArrayByName
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetIntArrayByNameTest001, TestSize.Level1)
+{
+ AddResource("zh", nullptr, "CN");
+
+ std::vector outValue;
+ RState state;
+ state = rm->GetIntArrayByName("intarray_1", outValue);
+ EXPECT_TRUE(state == SUCCESS);
+ EXPECT_EQ(static_cast(3), outValue.size());
+ EXPECT_EQ(100, outValue[0]);
+ EXPECT_EQ(200, outValue[1]);
+ EXPECT_EQ(101, outValue[2]);
+}
+
+/*
+ * @tc.name: ResourceManagerGetIntArrayByNameTest002
+ * @tc.desc: Test GetIntArrayByName
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetIntArrayByNameTest002, TestSize.Level1)
+{
+ AddResource("zh", nullptr, "CN");
+
+ std::vector outValue;
+ RState state;
+ state = rm->GetIntArrayByName(g_nonExistName, outValue);
+ ASSERT_EQ(NOT_FOUND, state);
+}
+
+/*
+ * @tc.name: ResourceManagerGetColorByIdTest001
+ * @tc.desc: Test GetColorById
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetColorByIdTest001, TestSize.Level1)
+{
+ AddResource("zh", nullptr, "CN");
+
+ uint32_t outValue;
+ RState state;
+ int id = GetResId("divider_color", ResType::COLOR);
+ EXPECT_TRUE(id > 0);
+ state = rm->GetColorById(id, outValue);
+ EXPECT_TRUE(state == SUCCESS);
+ EXPECT_EQ(static_cast(268435456), outValue); // #10000000
+
+ id = GetResId("color_aboutPage_title_primary", ResType::COLOR);
+ EXPECT_TRUE(id > 0);
+ state = rm->GetColorById(id, outValue);
+ EXPECT_TRUE(state == SUCCESS);
+ EXPECT_EQ(4279834905, outValue); // #191919
+}
+
+/*
+ * @tc.name: ResourceManagerGetColorByIdTest002
+ * @tc.desc: Test GetColorById
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetColorByIdTest002, TestSize.Level1)
+{
+ AddResource("zh", nullptr, "CN");
+
+ uint32_t outValue;
+ RState state;
+ state = rm->GetColorById(NON_EXIST_ID, outValue);
+ ASSERT_EQ(NOT_FOUND, state);
+}
+
+/*
+ * @tc.name: ResourceManagerGetColorByNameTest001
+ * @tc.desc: Test GetColorByName
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetColorByNameTest001, TestSize.Level1)
+{
+ AddResource("zh", nullptr, "CN");
+
+ uint32_t outValue;
+ RState state;
+ state = rm->GetColorByName("divider_color", outValue);
+ EXPECT_TRUE(state == SUCCESS);
+ EXPECT_EQ(static_cast(268435456), outValue); // #10000000
+
+ state = rm->GetColorByName("color_aboutPage_title_primary", outValue);
+ EXPECT_TRUE(state == SUCCESS);
+ EXPECT_EQ(4279834905, outValue); // #191919
+}
+
+/*
+ * @tc.name: ResourceManagerGetColorByNameTest002
+ * @tc.desc: Test GetColorByName
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetColorByNameTest002, TestSize.Level1)
+{
+ AddResource("zh", nullptr, "CN");
+
+ uint32_t outValue;
+ RState state;
+ state = rm->GetColorByName(g_nonExistName, outValue);
+ ASSERT_EQ(NOT_FOUND, state);
+}
+
+/*
+ * @tc.name: ResourceManagerGetProfileByIdTest001
+ * @tc.desc: Test GetProfileById
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetProfileByIdTest001, TestSize.Level1)
+{
+ AddResource("zh", nullptr, "CN");
+
+ HapResource *tmp = new HapResource(FormatFullPath(g_resFilePath).c_str(), 0, nullptr, nullptr);
+ tmp->Init();
+ std::string res = tmp->GetResourcePath();
+ res.append("entry/resources/base/profile/test_common.h");
+
+ std::string outValue;
+ RState state;
+ int id = GetResId("test_common", ResType::PROF);
+ EXPECT_TRUE(id > 0);
+ state = rm->GetProfileById(id, outValue);
+ EXPECT_TRUE(state == SUCCESS);
+ EXPECT_EQ(res, outValue);
+ delete tmp;
+}
+
+/*
+ * @tc.name: ResourceManagerGetProfileByIdTest002
+ * @tc.desc: Test GetProfileById
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetProfileByIdTest002, TestSize.Level1)
+{
+ AddResource("zh", nullptr, "CN");
+
+ std::string outValue;
+ RState state;
+ state = rm->GetProfileById(NON_EXIST_ID, outValue);
+ ASSERT_EQ(NOT_FOUND, state);
+}
+
+/*
+ * @tc.name: ResourceManagerGetProfileByNameTest001
+ * @tc.desc: Test GetProfileByName
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetProfileByNameTest001, TestSize.Level1)
+{
+ AddResource("zh", nullptr, "CN");
+
+ HapResource *tmp = new HapResource(FormatFullPath(g_resFilePath).c_str(), 0, nullptr, nullptr);
+ tmp->Init();
+ std::string res = tmp->GetResourcePath();
+ res.append("entry/resources/base/profile/test_common.h");
+
+ std::string outValue;
+ RState state;
+ state = rm->GetProfileByName("test_common", outValue);
+ EXPECT_TRUE(state == SUCCESS);
+ EXPECT_EQ(res, outValue);
+ delete tmp;
+}
+
+/*
+ * @tc.name: ResourceManagerGetProfileByNameTest002
+ * @tc.desc: Test GetProfileByName
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetProfileByNameTest002, TestSize.Level1)
+{
+ AddResource("zh", nullptr, "CN");
+
+ std::string outValue;
+ RState state;
+ state = rm->GetProfileByName(g_nonExistName, outValue);
+ ASSERT_EQ(NOT_FOUND, state);
+}
+
+/*
+ * @tc.name: ResourceManagerGetMediaByIdTest001
+ * @tc.desc: Test GetMediaById
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetMediaByIdTest001, TestSize.Level1)
+{
+ AddResource("zh", nullptr, "CN");
+
+ HapResource *tmp = new HapResource(FormatFullPath(g_resFilePath).c_str(), 0, nullptr, nullptr);
+ tmp->Init();
+ std::string res = tmp->GetResourcePath();
+ res.append("entry/resources/base/media/icon.png");
+
+ std::string outValue;
+ RState state;
+ int id = GetResId("icon", ResType::MEDIA);
+ EXPECT_TRUE(id > 0);
+ state = rm->GetMediaById(id, outValue);
+ EXPECT_TRUE(state == SUCCESS);
+ EXPECT_EQ(res, outValue);
+ delete tmp;
+}
+
+/*
+ * @tc.name: ResourceManagerGetMediaByIdTest002
+ * @tc.desc: Test GetMediaById
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetMediaByIdTest002, TestSize.Level1)
+{
+ AddResource("zh", nullptr, "CN");
+
+ std::string outValue;
+ RState state;
+ state = rm->GetMediaById(NON_EXIST_ID, outValue);
+ ASSERT_EQ(NOT_FOUND, state);
+}
+
+/*
+ * @tc.name: ResourceManagerGetMediaByNameTest001
+ * @tc.desc: Test GetMediaByName
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetMediaByNameTest001, TestSize.Level1)
+{
+ AddResource("zh", nullptr, "CN");
+
+ HapResource *tmp = new HapResource(FormatFullPath(g_resFilePath).c_str(), 0, nullptr, nullptr);
+ tmp->Init();
+ std::string res = tmp->GetResourcePath();
+ res.append("entry/resources/base/media/icon.png");
+
+ std::string outValue;
+ RState state;
+ state = rm->GetMediaByName("icon", outValue);
+ EXPECT_TRUE(state == SUCCESS);
+ EXPECT_EQ(res, outValue);
+ delete tmp;
+}
+
+/*
+ * @tc.name: ResourceManagerGetMediaByNameTest002
+ * @tc.desc: Test GetMediaByName
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerGetMediaByNameTest002, TestSize.Level1)
+{
+ AddResource("zh", nullptr, "CN");
+
+ std::string outValue;
+ RState state;
+ state = rm->GetMediaByName(g_nonExistName, outValue);
+ ASSERT_EQ(NOT_FOUND, state);
+}
+
+/*
+ * @tc.name: ResourceManagerResolveReferenceTest001
+ * @tc.desc: Test ResolveReference function, file case.
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerResolveReferenceTest001, TestSize.Level1)
+{
+ ResConfig *rc = CreateResConfig();
+ if (rc == nullptr) {
+ EXPECT_TRUE(false);
+ return;
+ }
+ rc->SetLocaleInfo("en", nullptr, "US");
+ rm->UpdateResConfig(*rc);
+
+ rm->AddResource(FormatFullPath(g_resFilePath).c_str());
+
+ int id = GetResId("integer_1", ResType::INTEGER);
+ std::string value(FormatString("$integer:%d", id));
+ std::string outValue;
+ RState ret = ((ResourceManagerImpl *)rm)->ResolveReference(value, outValue);
+ EXPECT_EQ(SUCCESS, ret);
+ EXPECT_EQ(std::string("101"), outValue);
+
+ std::string copyright("XXXXXX All rights reserved. ©2011-2019");
+ id = GetResId("copyright_text", ResType::STRING);
+ value.assign(FormatString("$string:%d", id));
+ ret = ((ResourceManagerImpl *)rm)->ResolveReference(value, outValue);
+ EXPECT_EQ(SUCCESS, ret);
+ EXPECT_EQ(copyright, outValue);
+
+ id = GetResId("string_ref", ResType::STRING);
+ value.assign(FormatString("$string:%d", id));
+ ret = ((ResourceManagerImpl *)rm)->ResolveReference(value, outValue);
+ EXPECT_EQ(SUCCESS, ret);
+ EXPECT_EQ(copyright, outValue);
+
+ id = GetResId("boolean_1", ResType::BOOLEAN);
+ value.assign(FormatString("$boolean:%d", id));
+ ret = ((ResourceManagerImpl *)rm)->ResolveReference(value, outValue);
+ EXPECT_EQ(SUCCESS, ret);
+ EXPECT_EQ(std::string("true"), outValue);
+
+ id = GetResId("grey_background", ResType::COLOR);
+ value.assign(FormatString("$color:%d", id));
+ ret = ((ResourceManagerImpl *)rm)->ResolveReference(value, outValue);
+ EXPECT_EQ(SUCCESS, ret);
+ EXPECT_EQ(std::string("#F5F5F5"), outValue);
+
+ id = GetResId("aboutPage_minHeight", ResType::FLOAT);
+ value.assign(FormatString("$float:%d", id));
+ ret = ((ResourceManagerImpl *)rm)->ResolveReference(value, outValue);
+ EXPECT_EQ(SUCCESS, ret);
+ EXPECT_EQ(std::string("707vp"), outValue);
+
+ id = GetResId("base", ResType::PATTERN);
+ value.assign(FormatString("$pattern:%d", id));
+ ret = ((ResourceManagerImpl *)rm)->ResolveReference(value, outValue);
+ EXPECT_EQ(ERROR, ret);
+
+ // reload
+ rc->SetLocaleInfo("zh", nullptr, "CN");
+ rm->UpdateResConfig(*rc);
+ delete rc;
+
+ id = GetResId("copyright_text", ResType::STRING);
+ value.assign(FormatString("$string:%d", id));
+ ret = ((ResourceManagerImpl *)rm)->ResolveReference(value, outValue);
+ ASSERT_EQ(SUCCESS, ret);
+ ASSERT_EQ(std::string("版权所有 ©2011-2019 XXXX有限公司保留一切权利"), outValue.c_str());
+
+ id = GetResId("string_ref", ResType::STRING);
+ value.assign(FormatString("$string:%d", id));
+ ret = ((ResourceManagerImpl *)rm)->ResolveReference(value, outValue);
+ ASSERT_EQ(SUCCESS, ret);
+ ASSERT_EQ(std::string("$aaaaa"), outValue.c_str());
+
+ // error case
+ // wrong id
+ value.assign(FormatString("$boolean:%d", NON_EXIST_ID));
+ ret = ((ResourceManagerImpl *)rm)->ResolveReference(value, outValue);
+ ASSERT_EQ(ERROR, ret);
+ // wrong type
+ id = GetResId("copyright_text", ResType::STRING);
+ value.assign(FormatString("$boolean:%d", id));
+ ret = ((ResourceManagerImpl *)rm)->ResolveReference(value, outValue);
+ ASSERT_EQ(ERROR, ret);
+}
+
+/*
+ * @tc.name: ResourceManagerResolveParentReferenceTest001
+ * @tc.desc: Test ResolveParentReference function, file case.
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerResolveParentReferenceTest001, TestSize.Level1)
+{
+ rm->AddResource(FormatFullPath(g_resFilePath).c_str());
+ int id;
+ std::map outValue;
+ const IdItem *idItem;
+ RState ret;
+
+ id = GetResId("base", ResType::PATTERN);
+ idItem = ((ResourceManagerImpl *)rm)->hapManager_->FindResourceById(id);
+ ASSERT_TRUE(idItem != nullptr);
+ ret = ((ResourceManagerImpl *)rm)->ResolveParentReference(idItem, outValue);
+ ASSERT_EQ(SUCCESS, ret);
+ PrintMapString(outValue);
+
+ HILOG_DEBUG("=====");
+ id = GetResId("child", ResType::PATTERN);
+ idItem = ((ResourceManagerImpl *)rm)->hapManager_->FindResourceById(id);
+ ASSERT_TRUE(idItem != nullptr);
+ ret = ((ResourceManagerImpl *)rm)->ResolveParentReference(idItem, outValue);
+ ASSERT_EQ(SUCCESS, ret);
+ PrintMapString(outValue);
+
+ HILOG_DEBUG("=====");
+ id = GetResId("ccchild", ResType::PATTERN);
+ idItem = ((ResourceManagerImpl *)rm)->hapManager_->FindResourceById(id);
+ ASSERT_TRUE(idItem != nullptr);
+ ret = ((ResourceManagerImpl *)rm)->ResolveParentReference(idItem, outValue);
+ ASSERT_EQ(SUCCESS, ret);
+ PrintMapString(outValue);
+
+ // error case
+ ret = ((ResourceManagerImpl *)rm)->ResolveParentReference(nullptr, outValue);
+ ASSERT_EQ(ERROR, ret);
+ // wrong resType
+ IdItem *item = new IdItem;
+ for (int i = 0; i < ResType::MAX_RES_TYPE; ++i) {
+ if (i == ResType::THEME || i == ResType::PATTERN) {
+ continue;
+ }
+ item->resType_ = (ResType) i;
+ ret = ((ResourceManagerImpl *)rm)->ResolveParentReference(item, outValue);
+ EXPECT_EQ(ERROR, ret);
+ }
+ delete item;
+}
+
+/*
+ * test res with same name in different resType
+ * @tc.name: ResourceManagerSameNameTest001
+ * @tc.desc: Test GetStringByName & GetBooleanByName & GetIntegerByName function, file case.
+ * @tc.type: FUNC
+ */
+HWTEST_F(ResourceManagerTest, ResourceManagerSameNameTest001, TestSize.Level1)
+{
+ rm->AddResource(FormatFullPath(g_resFilePath).c_str());
+ std::string outValue;
+ std::string name;
+ RState state;
+
+ state = rm->GetStringByName("same_name", outValue);
+ EXPECT_TRUE(state == SUCCESS);
+ EXPECT_EQ(std::string("StringSameName"), outValue);
+
+ bool outValueB = true;
+ state = rm->GetBooleanByName("same_name", outValueB);
+ EXPECT_TRUE(state == SUCCESS);
+ EXPECT_EQ(false, outValueB);
+
+ int outValueI;
+ state = rm->GetIntegerByName("same_name", outValueI);
+ EXPECT_TRUE(state == SUCCESS);
+ EXPECT_EQ(999, outValueI);
+}
diff --git a/global_lite/i18n_lite/resource_parse_load/src/resource_manager_test.h b/global_lite/i18n_lite/resource_parse_load/src/resource_manager_test.h
new file mode 100755
index 0000000000000000000000000000000000000000..c637d048f6a07ae2b11bf5980c2e4aedbdec0c5c
--- /dev/null
+++ b/global_lite/i18n_lite/resource_parse_load/src/resource_manager_test.h
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef RESOURCE_MANAGER_RESOURCE_MANANGER_TEST_H
+#define RESOURCE_MANAGER_RESOURCE_MANANGER_TEST_H
+
+int ResourceManagerAddResourceTest001();
+int ResourceManagerAddResourceTest002();
+int ResourceManagerAddResourceTest003();
+int ResourceManagerUpdateResConfigTest001();
+int ResourceManagerUpdateResConfigTest002();
+int ResourceManagerUpdateResConfigTest003();
+int ResourceManagerUpdateResConfigTest004();
+int ResourceManagerUpdateResConfigTest005();
+int ResourceManagerGetResConfigTest001();
+int ResourceManagerGetResConfigTest002();
+int ResourceManagerGetStringByIdTest001();
+int ResourceManagerGetStringByIdTest002();
+int ResourceManagerGetStringByIdTest003();
+int ResourceManagerGetStringByNameTest001();
+int ResourceManagerGetStringByNameTest002();
+int ResourceManagerGetStringByNameTest003();
+int ResourceManagerGetStringFormatByIdTest001();
+int ResourceManagerGetStringFormatByIdTest002();
+int ResourceManagerGetStringFormatByNameTest001();
+int ResourceManagerGetStringFormatByNameTest002();
+int ResourceManagerGetStringArrayByIdTest001();
+int ResourceManagerGetStringArrayByIdTest002();
+int ResourceManagerGetStringArrayByNameTest001();
+int ResourceManagerGetStringArrayByNameTest002();
+int ResourceManagerGetPatternByIdTest001();
+int ResourceManagerGetPatternByIdTest002();
+int ResourceManagerGetPatternByIdTest003();
+int ResourceManagerGetPatternByIdTest004();
+int ResourceManagerGetPatternByNameTest001();
+int ResourceManagerGetPatternByNameTest002();
+int ResourceManagerGetPatternByNameTest003();
+int ResourceManagerGetPatternByNameTest004();
+int ResourceManagerGetPluralStringByIdTest001();
+int ResourceManagerGetPluralStringByIdTest002();
+int ResourceManagerGetPluralStringByIdTest003();
+int ResourceManagerGetPluralStringByIdTest004();
+int ResourceManagerGetPluralStringByIdTest005();
+int ResourceManagerGetPluralStringByNameTest001();
+int ResourceManagerGetPluralStringByNameTest002();
+int ResourceManagerGetPluralStringByIdFormatTest001();
+int ResourceManagerGetPluralStringByIdFormatTest002();
+int ResourceManagerGetPluralStringByNameFormatTest001();
+int ResourceManagerGetPluralStringByNameFormatTest002();
+int ResourceManagerGetThemeByIdTest001();
+int ResourceManagerGetThemeByIdTest002();
+int ResourceManagerGetThemeByNameTest001();
+int ResourceManagerGetThemeByNameTest002();
+int ResourceManagerGetBooleanByIdTest001();
+int ResourceManagerGetBooleanByIdTest002();
+int ResourceManagerGetBooleanByNameTest001();
+int ResourceManagerGetBooleanByNameTest002();
+int ResourceManagerGetIntegerByIdTest001();
+int ResourceManagerGetIntegerByIdTest002();
+int ResourceManagerGetIntegerByNameTest001();
+int ResourceManagerGetIntegerByNameTest002();
+int ResourceManagerGetFloatByIdTest001();
+int ResourceManagerGetFloatByIdTest002();
+int ResourceManagerGetFloatByNameTest001();
+int ResourceManagerGetFloatByNameTest002();
+int ResourceManagerGetIntArrayByIdTest001();
+int ResourceManagerGetIntArrayByIdTest002();
+int ResourceManagerGetIntArrayByNameTest001();
+int ResourceManagerGetIntArrayByNameTest002();
+int ResourceManagerGetColorByIdTest001();
+int ResourceManagerGetColorByIdTest002();
+int ResourceManagerGetColorByNameTest001();
+int ResourceManagerGetColorByNameTest002();
+int ResourceManagerGetProfileByIdTest001();
+int ResourceManagerGetProfileByIdTest002();
+int ResourceManagerGetProfileByNameTest001();
+int ResourceManagerGetProfileByNameTest002();
+int ResourceManagerGetMediaByIdTest001();
+int ResourceManagerGetMediaByIdTest002();
+int ResourceManagerGetMediaByNameTest001();
+int ResourceManagerGetMediaByNameTest002();
+int ResourceManagerResolveReferenceTest001();
+int ResourceManagerResolveParentReferenceTest001();
+int ResourceManagerSameNameTest001();
+
+#endif
diff --git a/global_lite/i18n_lite/resource_parse_load/src/string_utils_test.cpp b/global_lite/i18n_lite/resource_parse_load/src/string_utils_test.cpp
new file mode 100755
index 0000000000000000000000000000000000000000..cfe24af2f381d071ceb24c352fefe02cf269b8fb
--- /dev/null
+++ b/global_lite/i18n_lite/resource_parse_load/src/string_utils_test.cpp
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "string_utils_test.h"
+
+#include
+#include
+#include
+
+#include "test_common.h"
+#include "utils/string_utils.h"
+
+using namespace OHOS::Global::Resource;
+using namespace testing::ext;
+using namespace OHOS::I18N;
+
+class StringUtilsTest : public testing::Test {
+public:
+ static void SetUpTestCase(void);
+
+ static void TearDownTestCase(void);
+
+ void SetUp();
+
+ void TearDown();
+};
+
+void StringUtilsTest::SetUpTestCase(void)
+{
+ // step 1: input testsuit setup step
+ g_logLevel = LOG_DEBUG;
+}
+
+void StringUtilsTest::TearDownTestCase(void)
+{
+ // step 2: input testsuit teardown step
+}
+
+void StringUtilsTest::SetUp()
+{
+ // step 3: input testcase setup step
+}
+
+void StringUtilsTest::TearDown()
+{
+ // step 4: input testcase teardown step
+}
+
+/*
+ * @tc.name: StringUtilsFuncTest001
+ * @tc.desc: Test FormatString, none file case.
+ * @tc.type: FUNC
+ */
+HWTEST_F(StringUtilsTest, StringUtilsFuncTest001, TestSize.Level1)
+{
+ std::string result = FormatString("%d", 10001);
+ EXPECT_EQ("10001", result);
+
+ result = FormatString("I'm %s, I'm %d", "cici", 5);
+ EXPECT_EQ("I'm cici, I'm 5", result);
+}
\ No newline at end of file
diff --git a/global_lite/i18n_lite/resource_parse_load/src/string_utils_test.h b/global_lite/i18n_lite/resource_parse_load/src/string_utils_test.h
new file mode 100755
index 0000000000000000000000000000000000000000..0e5642f43b5f4d780365cce5128821c6417cdca7
--- /dev/null
+++ b/global_lite/i18n_lite/resource_parse_load/src/string_utils_test.h
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef RESOURCE_MANAGER_STRING_UTILS_TEST_H
+#define RESOURCE_MANAGER_STRING_UTILS_TEST_H
+
+int StringUtilsFuncTest001();
+
+#endif
diff --git a/global_lite/i18n_lite/resource_parse_load/src/test_common.cpp b/global_lite/i18n_lite/resource_parse_load/src/test_common.cpp
new file mode 100755
index 0000000000000000000000000000000000000000..a8d261dfe074c6c9aef10c23c3230126ad560694
--- /dev/null
+++ b/global_lite/i18n_lite/resource_parse_load/src/test_common.cpp
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "test_common.h"
+
+#include
+#include
+#include
+#include
+
+#include "hilog_wrapper.h"
+#include "utils/errors.h"
+
+#if defined(__linux__)
+#include
+#endif
+
+namespace OHOS {
+namespace Global {
+namespace Resource {
+std::string FormatFullPath(const char *fileRelativePath)
+{
+ const char *value = "/user/data";
+ std::string result(value);
+ result.append("/");
+ result.append(fileRelativePath);
+ return result;
+}
+
+void PrintIdValues(const HapResource::IdValues *idValues)
+{
+ HILOG_DEBUG("idvalues size: %u", idValues->GetLimitPathsConst().size());
+ for (size_t i = 0; i < idValues->GetLimitPathsConst().size(); ++i) {
+ auto limitPath = idValues->GetLimitPathsConst()[i];
+ HILOG_DEBUG("%zu: folder is: %s, value: %s", i, limitPath->GetFolder().c_str(),
+ limitPath->GetIdItem()->ToString().c_str());
+ }
+}
+
+void PrintMapString(const std::map &value)
+{
+ auto iter = value.begin();
+ for (; iter != value.end(); ++iter) {
+ std::string key = iter->first;
+ std::string val = iter->second;
+ HILOG_DEBUG("%s : %s", key.c_str(), val.c_str());
+ }
+}
+
+void PrintVectorString(const std::vector &value)
+{
+ for (size_t i = 0; i < value.size(); ++i) {
+ std::string val = value[i];
+ HILOG_DEBUG("%zu : %s", i, val.c_str());
+ }
+}
+
+ResConfig *CreateResConfig(const char *language, const char *script, const char *region)
+{
+ ResConfig *resConfig = CreateResConfig();
+ if (resConfig == nullptr) {
+ return nullptr;
+ }
+ resConfig->SetLocaleInfo(language, script, region);
+ return resConfig;
+}
+} // namespace Resource
+} // namespace Global
+} // namespace OHOS
diff --git a/global_lite/i18n_lite/resource_parse_load/src/test_common.h b/global_lite/i18n_lite/resource_parse_load/src/test_common.h
new file mode 100755
index 0000000000000000000000000000000000000000..53dd723c6ba31e2686657e584d6fb04e3fb513aa
--- /dev/null
+++ b/global_lite/i18n_lite/resource_parse_load/src/test_common.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef RESOURCE_MANAGER_TEST_COMMON_H
+#define RESOURCE_MANAGER_TEST_COMMON_H
+
+#include "hap_resource.h"
+#include "hilog_wrapper.h"
+
+#include