diff --git a/global/i18n_standard/intljs/src/main/js/test/I18n.test.js b/global/i18n_standard/intljs/src/main/js/test/I18n.test.js index 46f442abc838ecf435e588ca507fba4f47cf9fa1..d63caafddebbc58a42017eec22231d26d62a2d3f 100644 --- a/global/i18n_standard/intljs/src/main/js/test/I18n.test.js +++ b/global/i18n_standard/intljs/src/main/js/test/I18n.test.js @@ -342,6 +342,17 @@ describe('I18nTest', function () { expect(value).assertEqual('China'); }) + /* * + * @tc.number SUB_GLOBAL_I18N_JS_3840 + * @tc.name getDisplayCountry with zh-Hans-CN and en-US and null param + * @tc.desc check the display country + */ + it('i18n_test_3840', 0, function () { + let value = I18n.getDisplayCountry('zh-Hans-CN', 'en-US', null); + console.log('i18n_test_3840 ' + value); + expect(value).assertEqual('China'); + }) + /* * * @tc.number SUB_GLOBAL_I18N_JS_3900 * @tc.name getDisplayCountry with zh and en-US and true param @@ -419,6 +430,17 @@ describe('I18nTest', function () { expect(value).assertEqual('China'); }) + /* * + * @tc.number SUB_GLOBAL_I18N_JS_4321 + * @tc.name getDisplayCountry with zh-Hans-CN and en-US and null param + * @tc.desc check the display country + */ + it('i18n_test_4321', 0, function () { + let value = I18n.System.getDisplayCountry('zh-Hans-CN', 'en-US', null); + console.log('i18n_test_4321 ' + value); + expect(value).assertEqual('China'); + }) + /* * * @tc.number SUB_GLOBAL_I18N_JS_4330 * @tc.name getDisplayCountry with zh and en-US and true param @@ -546,6 +568,17 @@ describe('I18nTest', function () { expect(value).assertEqual('Simplified Chinese'); }) + /* * + * @tc.number SUB_GLOBAL_I18N_JS_4440 + * @tc.name getDisplayLanguage with zh-Hans-CN and en-US and null param + * @tc.desc check the language + */ + it('i18n_test_4440', 0, function () { + let value = I18n.getDisplayLanguage('zh-Hans-CN', 'en-US', null); + console.log('i18n_test_4440 ' + value); + expect(value).assertEqual('Simplified Chinese'); + }) + /* * * @tc.number SUB_GLOBAL_I18N_JS_4500 * @tc.name getDisplayLanguage with zh-Hans-CN and en-GB and true param @@ -634,6 +667,17 @@ describe('I18nTest', function () { expect(value).assertEqual('Simplified Chinese'); }) + /* * + * @tc.number SUB_GLOBAL_I18N_JS_5021 + * @tc.name getDisplayLanguage with zh-Hans-CN and en-US and null param + * @tc.desc check the language + */ + it('i18n_test_5021', 0, function () { + let value = I18n.System.getDisplayLanguage('zh-Hans-CN', 'en-US', null); + console.log('i18n_test_5021 ' + value); + expect(value).assertEqual('Simplified Chinese'); + }) + /* * * @tc.number SUB_GLOBAL_I18N_JS_5030 * @tc.name getDisplayLanguage with zh-Hans-CN and en-GB and true param @@ -767,30 +811,45 @@ describe('I18nTest', function () { }) /** - * @tc.number SUB_GLOBAL_I18N_JS_5120 + * @tc.number SUB_GLOBAL_I18N_JS_5140 + * @tc.name test isValidNumber interface with 13510574676 and null param + * @tc.desc get the isValidNumber value + */ + it('i18n_test_5140', 0, function () { + console.log('i18n_test_5140 ' + 'start'); + let phonenumber = new I18n.PhoneNumberFormat('CN', null); + let ran = Math.ceil(Math.random(1) * 9); + console.log('i18n_test_5140 ' + ran); + let valid = phonenumber.isValidNumber('1351057467' + ran); + console.log('i18n_test_5140 ' + valid); + expect(valid).assertEqual(true); + }) + + /** + * @tc.number SUB_GLOBAL_I18N_JS_5160 * @tc.name test isValidNumber interface with 0755-6100088X param * @tc.desc get the isValidNumber value */ - it('i18n_test_5120', 0, function () { - console.log('i18n_test_5120 ' + 'start'); + it('i18n_test_5160', 0, function () { + console.log('i18n_test_5160 ' + 'start'); let phonenumber = new I18n.PhoneNumberFormat('CN'); let ran = Math.ceil(Math.random(1) * 9); - console.log('i18n_test_5120 ' + ran); + console.log('i18n_test_5160 ' + ran); let valid = phonenumber.isValidNumber('0755-6100088' + ran); - console.log('i18n_test_5120 ' + valid); + console.log('i18n_test_5160 ' + valid); expect(valid).assertEqual(true); }) /** - * @tc.number SUB_GLOBAL_I18N_JS_5140 + * @tc.number SUB_GLOBAL_I18N_JS_5180 * @tc.name test isValidNumber interface with 110 param * @tc.desc get the isValidNumber value */ - it('i18n_test_5140', 0, function () { - console.log('i18n_test_5140 ' + 'start'); + it('i18n_test_5180', 0, function () { + console.log('i18n_test_5180 ' + 'start'); let phonenumber = new I18n.PhoneNumberFormat('CN'); let valid = phonenumber.isValidNumber('110'); - console.log('i18n_test_5140 ' + valid); + console.log('i18n_test_5180 ' + valid); expect(valid).assertEqual(false); }) @@ -1763,7 +1822,7 @@ describe('I18nTest', function () { }) /** - * @tc.number SUB_GLOBAL_I18N_JS_9200 + * @tc.number SUB_GLOBAL_I18N_JS_9120 * @tc.name test unitConvert interface from cup to liter unit with undefined style * @tc.desc get the unitConvert value */ @@ -1778,6 +1837,22 @@ describe('I18nTest', function () { expect(value).assertEqual('236.588 L'); }) + /** + * @tc.number SUB_GLOBAL_I18N_JS_9140 + * @tc.name test unitConvert interface from cup to liter unit with null style + * @tc.desc get the unitConvert value + */ + it('i18n_test_9140', 0, function () { + console.log('i18n_test_9140 ' + 'start'); + let value = I18n.I18NUtil.unitConvert({unit: 'cup', measureSystem: 'US'}, + {unit: 'liter', measureSystem: 'SI'}, + 1000, + 'en-US', + null); + console.log('i18n_test_9140 ' + value); + expect(value).assertEqual('236.588 L'); + }) + /** * @tc.number SUB_GLOBAL_I18N_JS_9200 * @tc.name test unitConvert interface from cup to liter unit with medium style @@ -2004,6 +2079,23 @@ describe('I18nTest', function () { expect(value).assertEqual('236.588 L'); }) + /** + * @tc.number SUB_GLOBAL_I18N_JS_9931 + * @tc.name test unitConvert interface from cup to liter unit with null style + * @tc.desc get the unitConvert value + */ + it('i18n_test_9931', 0, function () { + console.log('i18n_test_9931 ' + 'start'); + let util = new I18n.Util(); + let value = util.unitConvert({unit: 'cup', measureSystem: 'US'}, + {unit: 'liter', measureSystem: 'SI'}, + 1000, + 'en-US', + null); + console.log('i18n_test_9931 ' + value); + expect(value).assertEqual('236.588 L'); + }) + /** * @tc.number SUB_GLOBAL_I18N_JS_9940 * @tc.name test unitConvert interface from cup to liter unit with medium style diff --git a/global/i18n_standard/intljs/src/main/js/test/Intl.test.js b/global/i18n_standard/intljs/src/main/js/test/Intl.test.js index 57b02804b934cdbe4b4e3fa5d12ea504bf97e99d..30a48e4cdbf2325c07ee9c6c10f68a4632a6d891 100644 --- a/global/i18n_standard/intljs/src/main/js/test/Intl.test.js +++ b/global/i18n_standard/intljs/src/main/js/test/Intl.test.js @@ -82,6 +82,19 @@ describe('intlTest', function () { expect(locale.numeric).assertFalse(); }) + /* * + * @tc.number SUB_GLOBAL_INTL_JS_LOCALE_0130 + * @tc.name test the language in en-Latn-GB locale + * @tc.desc check the language + */ + it('locale_test_0130', 0, function () { + let locale = new Intl.Locale('en-Latn-GB', null); + console.log('locale_test_0130 ' + locale.language); + console.log('locale_test_0130 ' + locale.numeric); + expect(locale.language).assertEqual('en'); + expect(locale.numeric).assertFalse(); + }) + /* * * @tc.number SUB_GLOBAL_INTL_JS_LOCALE_0140 * @tc.name test the language in locale @@ -545,6 +558,18 @@ describe('intlTest', function () { expect(datefmt.format(date)).assertContain('2021'); }) + /* * + * @tc.number SUB_GLOBAL_INTL_JS_DATETIME_0240 + * @tc.name format the date with zh locale and null options + * @tc.desc check the date + */ + it('dateTimeFormat_test_0240', 0, function () { + let date = new Date(2021, 11, 17, 3, 24, 0); + let datefmt = new Intl.DateTimeFormat('zh', null); + console.log('dateTimeFormat_test_0240 ' + datefmt.format(date)); + expect(datefmt.format(date)).assertContain('2021'); + }) + /* * * @tc.number SUB_GLOBAL_INTL_JS_DATETIME_0300 * @tc.name format the date with en locale @@ -914,6 +939,17 @@ describe('intlTest', function () { expect(numfmt.format(123456.789)).assertEqual('123,456.789'); }) + /* * + * @tc.number SUB_GLOBAL_INTL_JS_NUMBER_0160 + * @tc.name format the number in zh and null options + * @tc.desc check the number in zh + */ + it('formatNumber_test_0160', 0, function () { + let numfmt = new Intl.NumberFormat('zh', null); + console.log('formatNumber_test_0160 ' + numfmt.format(123456.789)); + expect(numfmt.format(123456.789)).assertEqual('123,456.789'); + }) + /* * * @tc.number SUB_GLOBAL_INTL_JS_NUMBER_0200 * @tc.name format the number in zh-u-nu-latn @@ -1321,6 +1357,18 @@ describe('intlTest', function () { expect(value).assertEqual('other'); }) + /* * + * @tc.number SUB_GLOBAL_INTL_JS_PLURAL_2740 + * @tc.name get PluralRules with zh locale and null options + * @tc.desc check the select result + */ + it('pluralrules_test_2740', 0, function () { + let pl = new Intl.PluralRules('zh', null); + let value = pl.select(0); + console.log('pluralrules_test_2740 ' + value); + expect(value).assertEqual('other'); + }) + /* * * @tc.number SUB_GLOBAL_INTL_JS_PLURAL_2800 * @tc.name get PluralRules with zh locale and ordinal type @@ -1465,6 +1513,18 @@ describe('intlTest', function () { expect(value).assertEqual(-1); }) + /* * + * @tc.number SUB_GLOBAL_INTL_JS_COLLATOR_3640 + * @tc.name compare two different strings with zh locale and null options + * @tc.desc check the compare result + */ + it('collator_test_3640', 0, function () { + let coll = new Intl.Collator('zh', null); + let value = coll.compare('a', 'b'); + console.log('collator_test_3640 ' + value); + expect(value).assertEqual(-1); + }) + /* * * @tc.number SUB_GLOBAL_INTL_JS_COLLATOR_3700 * @tc.name compare two different strings with zh locale and eor collation @@ -1595,6 +1655,19 @@ describe('intlTest', function () { expect(value).assertEqual('in 100 seconds'); }) + /* * + * @tc.number SUB_GLOBAL_I18N_JS_RELATIVETIMEFORMAT_0240 + * @tc.name format the relativetime with 100 second in en and null options + * @tc.desc check the relativetime + */ + it('i18n_test_relativetimeformat_0240', 0, function () { + console.log('i18n_test_relativetimeformat_0240 ' + 'start'); + let relativetimefmt = new Intl.RelativeTimeFormat('en', null); + let value = relativetimefmt.format(100,'second'); + console.log('i18n_test_relativetimeformat_0240 ' + value); + expect(value).assertEqual('in 100 seconds'); + }) + /* * * @tc.number SUB_GLOBAL_I18N_JS_RELATIVETIMEFORMAT_0300 * @tc.name format the relativetime with 100 second in narrow style diff --git a/global/i18n_standard/intljs/src/main/js/test/Lang.test.js b/global/i18n_standard/intljs/src/main/js/test/Lang.test.js index b792ba2aa4d73b4323f13065ad8e6333e9c67e68..b839b1c94aa34cc602b2254d7acb5fca29f07fda 100644 --- a/global/i18n_standard/intljs/src/main/js/test/Lang.test.js +++ b/global/i18n_standard/intljs/src/main/js/test/Lang.test.js @@ -138,6 +138,18 @@ describe('LangTest', function () { expect(value.length).assertLarger(0); }) + /* * + * @tc.number SUB_GLOBAL_I18N_JS_PREFERREDLANGUAGE_0110 + * @tc.name test the getPreferredLanguageList interface with default value + * @tc.desc check the value of getPreferredLanguageList method + */ + it('i18n_test_preferredlanguage_0110', 0, function () { + console.log('i18n_test_preferredlanguage_0110 ' + 'start'); + let value = I18n.System.getPreferredLanguageList(); + console.log('i18n_test_preferredlanguage_0110 ' + value); + expect(value.length).assertLarger(0); + }) + /* * * @tc.number SUB_GLOBAL_I18N_JS_PREFERREDLANGUAGE_0120 * @tc.name test the addPreferredLanguage interface @@ -199,6 +211,26 @@ describe('LangTest', function () { } }) + /* * + * @tc.number SUB_GLOBAL_I18N_JS_PREFERREDLANGUAGE_1020 + * @tc.name test the getFirstPreferredLanguage interface + * @tc.desc check the value of getFirstPreferredLanguage method + */ + it('i18n_test_preferredlanguage_1020', 0, function () { + console.log('i18n_test_preferredlanguage_1020 ' + 'start'); + let value = I18n.System.getFirstPreferredLanguage(); + console.log('i18n_test_preferredlanguage_1020 ' + value); + let list = I18n.System.getPreferredLanguageList(); + console.log('i18n_test_preferredlanguage_1020 ' + list); + expect(list.length).assertLarger(0); + if(list[0] == 'zh-Hans'){ + expect(value).assertEqual('zh-Hans'); + } + else if(list[0] == 'en'){ + expect(value).assertEqual('en'); + } + }) + /* * * @tc.number SUB_GLOBAL_I18N_JS_PREFERREDLANGUAGE_1100 * @tc.name test the getAppPreferredLanguage interface @@ -211,6 +243,18 @@ describe('LangTest', function () { expect(value).assertContain('zh'); }) + /* * + * @tc.number SUB_GLOBAL_I18N_JS_PREFERREDLANGUAGE_1120 + * @tc.name test the getAppPreferredLanguage interface + * @tc.desc check the value of getAppPreferredLanguage method + */ + it('i18n_test_preferredlanguage_1120', 0, function () { + console.log('i18n_test_preferredlanguage_1120 ' + 'start'); + let value = I18n.System.getAppPreferredLanguage(); + console.log('i18n_test_preferredlanguage_1120 ' + value); + expect(value).assertContain('zh'); + }) + /* * * @tc.number SUB_GLOBAL_INTL_JS_TRANSFER_0100 * @tc.name transfer from lower to upper diff --git a/global/i18n_standard/intljs/src/main/js/test/List.test.js b/global/i18n_standard/intljs/src/main/js/test/List.test.js index 468257f5c2a9f9f43a0d9f56dedae8588b66d572..cc0f032aef97b07ada7f2fa0c9a656d5d61f2d88 100644 --- a/global/i18n_standard/intljs/src/main/js/test/List.test.js +++ b/global/i18n_standard/intljs/src/main/js/test/List.test.js @@ -15,8 +15,10 @@ import I18nTest from './I18n.test.js' import intlTest from './Intl.test.js' import LangTest from './Lang.test.js' +import SystemInI18nTest from './SystemInI18n.test.js' export default function testsuite() { I18nTest() intlTest() LangTest() +SystemInI18nTest() } diff --git a/global/i18n_standard/intljs/src/main/js/test/SystemInI18n.test.js b/global/i18n_standard/intljs/src/main/js/test/SystemInI18n.test.js new file mode 100644 index 0000000000000000000000000000000000000000..36bc86d979e038307af978e40e55aac0ddc053c9 --- /dev/null +++ b/global/i18n_standard/intljs/src/main/js/test/SystemInI18n.test.js @@ -0,0 +1,574 @@ +/* + * Copyright (C) 2023 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 I18n from '@ohos.i18n' +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium' + +export default function SystemInI18nTest() { +describe('SystemInI18nTest', function () { + console.log('*************start SystemInI18nTest*************'); + + let hour = I18n.System.is24HourClock(); + console.log('init 24 hour clock value ' + hour); + + /* * + * execute this step before all testcases + */ + beforeAll(function(){ + console.log('step before all cases in I18n.' + + ' 24hour: ' + I18n.System.is24HourClock() + + ' prelang: ' + I18n.System.getPreferredLanguageList() + + ' syslocale: ' + I18n.System.getSystemLocale()); + }) + + /* * + * execute this step before every testcase + */ + beforeEach(function(){ + console.log('step before every case in I18n.'); + }) + + /* * + * execute this step after every testcase + */ + afterEach(function(){ + console.log('step after every case in I18n.'); + }) + + /* * + * execute this step after all testcases + */ + afterAll(function(){ + console.log('step after all cases in I18n.' + + ' 24hour: ' + I18n.System.is24HourClock() + + ' prelang: ' + I18n.System.getPreferredLanguageList() + + ' syslocale: ' + I18n.System.getSystemLocale()); + }) + + /* * + * @tc.number SUB_GLOBAL_I18N_SYSTEM_JS_0100 + * @tc.name getDisplayCountry with zh-Hans-CN and en-US and true param + * @tc.desc check the display country + */ + it('i18n_system_test_0100', 0, function () { + let value = I18n.System.getDisplayCountry('zh-Hans-CN', 'en-US', true); + console.log('i18n_system_test_0100 ' + value); + expect(value).assertEqual('China'); + }) + + /* * + * @tc.number SUB_GLOBAL_I18N_SYSTEM_JS_0200 + * @tc.name getDisplayCountry with zh-Hans-CN and en-US and undefined param + * @tc.desc check the display country + */ + it('i18n_system_test_0200', 0, function () { + let value = I18n.System.getDisplayCountry('zh-Hans-CN', 'en-US', undefined); + console.log('i18n_system_test_0200 ' + value); + expect(value).assertEqual('China'); + }) + + /* * + * @tc.number SUB_GLOBAL_I18N_SYSTEM_JS_0300 + * @tc.name getDisplayCountry with zh-Hans-CN and en-US and null param + * @tc.desc check the display country + */ + it('i18n_system_test_0300', 0, function () { + let value = I18n.System.getDisplayCountry('zh-Hans-CN', 'en-US', null); + console.log('i18n_system_test_0300 ' + value); + expect(value).assertEqual('China'); + }) + + /* * + * @tc.number SUB_GLOBAL_I18N_SYSTEM_JS_0400 + * @tc.name getDisplayCountry with zh and en-US and true param + * @tc.desc check the display country + */ + it('i18n_system_test_0400', 0, function () { + try{ + let value = I18n.System.getDisplayCountry('zh', 'en-US', true); + console.log('i18n_system_test_0400 ' + value); + expect(value).assertEqual(''); + }catch(e){ + console.log('i18n_system_test_0400 ' + e.code); + console.log('i18n_system_test_0400 ' + e.message); + expect(e.code).assertEqual('890001'); + expect(e.message).assertEqual('Param value not valid'); + } + }) + + /* * + * @tc.number SUB_GLOBAL_I18N_SYSTEM_JS_0500 + * @tc.name getDisplayCountry with zh-CN and en-US and true param + * @tc.desc check the display country + */ + it('i18n_system_test_0500', 0, function () { + let value = I18n.System.getDisplayCountry('zh-CN', 'en-US', true); + console.log('i18n_system_test_0500 ' + value); + expect(value).assertEqual('China'); + }) + + /* * + * @tc.number SUB_GLOBAL_I18N_SYSTEM_JS_0600 + * @tc.name getDisplayCountry with zh-Hans and en-US and true param + * @tc.desc check the display country + */ + it('i18n_system_test_0600', 0, function () { + try{ + let value = I18n.System.getDisplayCountry('zh-Hans', 'en-US', true); + console.log('i18n_system_test_0600 ' + value); + expect(value).assertEqual(''); + }catch(e){ + console.log('i18n_system_test_0600 ' + e.code); + console.log('i18n_system_test_0600 ' + e.message); + expect(e.code).assertEqual('890001'); + expect(e.message).assertEqual('Param value not valid'); + } + }) + + /* * + * @tc.number SUB_GLOBAL_I18N_SYSTEM_JS_0700 + * @tc.name getDisplayCountry with zh-Hans-CN and en-US and false param + * @tc.desc check the language + */ + it('i18n_system_test_0700', 0, function () { + let value = I18n.System.getDisplayCountry('zh-Hans-CN', 'en-US', false); + console.log('i18n_system_test_0700 ' + value); + expect(value).assertEqual('China'); + }) + + /* * + * @tc.number SUB_GLOBAL_I18N_SYSTEM_JS_0800 + * @tc.name getDisplayCountry with zh-Hans-CN and en-US param + * @tc.desc check the language + */ + it('i18n_system_test_0800', 0, function () { + let value = I18n.System.getDisplayCountry('zh-Hans-CN', 'en-US'); + console.log('i18n_system_test_0800 ' + value); + expect(value).assertEqual('China'); + }) + + /* * + * @tc.number SUB_GLOBAL_I18N_SYSTEM_JS_0900 + * @tc.name getDisplayCountry with zh-Hans-CN and en-US param + * @tc.desc check the language + */ + it('i18n_system_test_0900', 0, function () { + try{ + let value = I18n.System.getDisplayCountry('zh-Hans-CN'); + console.log('i18n_system_test_0900 ' + value); + expect(value).assertEqual('China'); + }catch(e){ + console.log('i18n_system_test_0900 ' + e.code); + console.log('i18n_system_test_0900 ' + e.message); + expect(e.code).assertEqual('401'); + expect(e.message).assertEqual('Check param failed'); + } + }) + + /* * + * @tc.number SUB_GLOBAL_I18N_SYSTEM_JS_1000 + * @tc.name getDisplayCountry with zh-Hans-CN and en-US param + * @tc.desc check the language + */ + it('i18n_system_test_1000', 0, function () { + try{ + let value = I18n.System.getDisplayCountry('zh-Hans-CN', 12345); + console.log('i18n_system_test_1000 ' + value); + expect(value).assertEqual('China'); + }catch(e){ + console.log('i18n_system_test_1000 ' + e.code); + console.log('i18n_system_test_1000 ' + e.message); + expect(e.code).assertEqual('890001'); + expect(e.message).assertEqual('Param value not valid'); + } + }) + + /* * + * @tc.number SUB_GLOBAL_I18N_SYSTEM_JS_1100 + * @tc.name getDisplayLanguage with zh-Hans-CN and en-US and true param + * @tc.desc check the language + */ + it('i18n_system_test_1100', 0, function () { + let value = I18n.System.getDisplayLanguage('zh-Hans-CN', 'en-US', true); + console.log('i18n_system_test_1100 ' + value); + expect(value).assertEqual('Simplified Chinese'); + }) + + /* * + * @tc.number SUB_GLOBAL_I18N_SYSTEM_JS_1200 + * @tc.name getDisplayLanguage with zh-Hans-CN and en-US and undefined param + * @tc.desc check the language + */ + it('i18n_system_test_1200', 0, function () { + let value = I18n.System.getDisplayLanguage('zh-Hans-CN', 'en-US', undefined); + console.log('i18n_system_test_1200 ' + value); + expect(value).assertEqual('Simplified Chinese'); + }) + + /* * + * @tc.number SUB_GLOBAL_I18N_SYSTEM_JS_1300 + * @tc.name getDisplayLanguage with zh-Hans-CN and en-US and null param + * @tc.desc check the language + */ + it('i18n_system_test_1300', 0, function () { + let value = I18n.System.getDisplayLanguage('zh-Hans-CN', 'en-US', null); + console.log('i18n_system_test_1300 ' + value); + expect(value).assertEqual('Simplified Chinese'); + }) + + /* * + * @tc.number SUB_GLOBAL_I18N_SYSTEM_JS_1400 + * @tc.name getDisplayLanguage with zh-Hans-CN and en-GB and true param + * @tc.desc check the language + */ + it('i18n_system_test_1400', 0, function () { + let value = I18n.System.getDisplayLanguage('zh-Hans-CN', 'en-GB', true); + console.log('i18n_system_test_1400 ' + value); + expect(value).assertEqual('Simplified Chinese'); + }) + + /* * + * @tc.number SUB_GLOBAL_I18N_SYSTEM_JS_1500 + * @tc.name getDisplayLanguage with zh and en-US and true param + * @tc.desc check the language + */ + it('i18n_system_test_1500', 0, function () { + let value = I18n.System.getDisplayLanguage('zh', 'en-US', true); + console.log('i18n_system_test_1500 ' + value); + expect(value).assertEqual('Chinese'); + }) + + /* * + * @tc.number SUB_GLOBAL_I18N_SYSTEM_JS_1600 + * @tc.name getDisplayLanguage with zh-CN and en-US and true param + * @tc.desc check the language + */ + it('i18n_system_test_1600', 0, function () { + let value = I18n.System.getDisplayLanguage('zh-CN', 'en-US', true); + console.log('i18n_system_test_1600 ' + value); + expect(value).assertEqual('Chinese'); + }) + + /* * + * @tc.number SUB_GLOBAL_I18N_SYSTEM_JS_1700 + * @tc.name getDisplayLanguage with zh-Hans and en-US and true param + * @tc.desc check the language + */ + it('i18n_system_test_1700', 0, function () { + let value = I18n.System.getDisplayLanguage('zh-Hans', 'en-US', true); + console.log('i18n_system_test_1700 ' + value); + expect(value).assertEqual('Simplified Chinese'); + }) + + /* * + * @tc.number SUB_GLOBAL_I18N_SYSTEM_JS_1800 + * @tc.name getDisplayLanguage with zh-Hans-CN and en-US and false param + * @tc.desc check the language + */ + it('i18n_system_test_1800', 0, function () { + let value = I18n.System.getDisplayLanguage('zh-Hans-CN', 'en-US', false); + console.log('i18n_system_test_1800 ' + value); + expect(value).assertEqual('Simplified Chinese'); + }) + + /* * + * @tc.number SUB_GLOBAL_I18N_SYSTEM_JS_1900 + * @tc.name getDisplayLanguage with zh-Hans-CN and en-US param + * @tc.desc check the language + */ + it('i18n_system_test_1900', 0, function () { + let value = I18n.System.getDisplayLanguage('zh-Hans-CN', 'en-US'); + console.log('i18n_system_test_1900 ' + value); + expect(value).assertEqual('Simplified Chinese'); + }) + + /* * + * @tc.number SUB_GLOBAL_I18N_SYSTEM_JS_2000 + * @tc.name getDisplayLanguage with zh-Hans-CN and en-US param + * @tc.desc check the language + */ + it('i18n_system_test_2000', 0, function () { + try{ + let value = I18n.System.getDisplayLanguage('zh-Hans-CN'); + console.log('i18n_system_test_2000 ' + value); + expect(value).assertEqual('Simplified Chinese'); + }catch(e){ + console.log('i18n_system_test_2000 ' + e.code); + console.log('i18n_system_test_2000 ' + e.message); + expect(e.code).assertEqual('401'); + expect(e.message).assertEqual('Check param failed'); + } + }) + + /* * + * @tc.number SUB_GLOBAL_I18N_SYSTEM_JS_2100 + * @tc.name getDisplayLanguage with zh-Hans-CN and en-US param + * @tc.desc check the language + */ + it('i18n_system_test_2100', 0, function () { + try{ + let value = I18n.System.getDisplayLanguage('zh-Hans-CN', 12345); + console.log('i18n_system_test_2100 ' + value); + expect(value).assertEqual('Simplified Chinese'); + }catch(e){ + console.log('i18n_system_test_2100 ' + e.code); + console.log('i18n_system_test_2100 ' + e.message); + expect(e.code).assertEqual('890001'); + expect(e.message).assertEqual('Param value not valid'); + } + }) + + /* * + * @tc.number SUB_GLOBAL_I18N_SYSTEM_JS_2200 + * @tc.name getSystemLanguages test + * @tc.desc check the getSystemLanguages + */ + it('i18n_system_test_2200', 0, function () { + let value = I18n.System.getSystemLanguages(); + let len = value.length; + console.log('i18n_system_test_2200 ' + len); + expect(len).assertLarger(0); + }) + + /* * + * @tc.number SUB_GLOBAL_I18N_SYSTEM_JS_2300 + * @tc.name getSystemCountries with en param + * @tc.desc check the getSystemCountries + */ + it('i18n_system_test_2300', 0, function () { + let value = I18n.System.getSystemCountries('en'); + let len = value.length; + console.log('i18n_system_test_2300 ' + len); + expect(len).assertLarger(0); + }) + + /* * + * @tc.number SUB_GLOBAL_I18N_SYSTEM_JS_2400 + * @tc.name getSystemCountries with en param + * @tc.desc check the getSystemCountries + */ + it('i18n_system_test_2400', 0, function () { + try{ + let value = I18n.System.getSystemCountries(); + let len = value.length; + console.log('i18n_system_test_2400 ' + len); + expect(len).assertLarger(0); + }catch(e){ + console.log('i18n_system_test_2400 ' + e.code); + console.log('i18n_system_test_2400 ' + e.message); + expect(e.code).assertEqual('401'); + expect(e.message).assertEqual('Check param failed'); + } + }) + + /* * + * @tc.number SUB_GLOBAL_I18N_SYSTEM_JS_2500 + * @tc.name getSystemCountries with en param + * @tc.desc check the getSystemCountries + */ + it('i18n_system_test_2500', 0, function () { + try{ + let value = I18n.System.getSystemCountries(12345); + let len = value.length; + console.log('i18n_system_test_2500 ' + len); + expect(len).assertLarger(0); + }catch(e){ + console.log('i18n_system_test_2500 ' + e.code); + console.log('i18n_system_test_2500 ' + e.message); + expect(e.code).assertEqual('890001'); + expect(e.message).assertEqual('Param value not valid'); + } + }) + + /* * + * @tc.number SUB_GLOBAL_I18N_SYSTEM_JS_2600 + * @tc.name isSuggested with zh param + * @tc.desc check the isSuggested + */ + it('i18n_system_test_2600', 0, function () { + let value = I18n.System.isSuggested('zh'); + console.log('i18n_system_test_2600 ' + value); + expect(value).assertTrue(); + }) + + /* * + * @tc.number SUB_GLOBAL_I18N_SYSTEM_JS_2700 + * @tc.name isSuggested with en param + * @tc.desc check the isSuggested + */ + it('i18n_system_test_2700', 0, function () { + let value = I18n.System.isSuggested('en'); + console.log('i18n_system_test_2700 ' + value); + expect(value).assertFalse(); + }) + + /* * + * @tc.number SUB_GLOBAL_I18N_SYSTEM_JS_2800 + * @tc.name isSuggested with zh-CN param + * @tc.desc check the isSuggested + */ + it('i18n_system_test_2800', 0, function () { + let value = I18n.System.isSuggested('zh', 'CN'); + console.log('i18n_system_test_2800 ' + value); + expect(value).assertTrue(); + }) + + /* * + * @tc.number SUB_GLOBAL_I18N_SYSTEM_JS_2900 + * @tc.name isSuggested with en-US param + * @tc.desc check the isSuggested + */ + it('i18n_system_test_2900', 0, function () { + let value = I18n.System.isSuggested('en' , 'US'); + console.log('i18n_system_test_2900 ' + value); + expect(value).assertTrue(); + }) + + /* * + * @tc.number SUB_GLOBAL_I18N_SYSTEM_JS_3000 + * @tc.name isSuggested with en-US param + * @tc.desc check the isSuggested + */ + it('i18n_system_test_3000', 0, function () { + try{ + let value = I18n.System.isSuggested(); + console.log('i18n_system_test_3000 ' + value); + expect(value).assertTrue(); + }catch(e){ + console.log('i18n_system_test_3000 ' + e.code); + console.log('i18n_system_test_3000 ' + e.message); + expect(e.code).assertEqual('401'); + expect(e.message).assertEqual('Check param failed'); + } + }) + + /* * + * @tc.number SUB_GLOBAL_I18N_SYSTEM_JS_3100 + * @tc.name isSuggested with en-US param + * @tc.desc check the isSuggested + */ + it('i18n_system_test_3100', 0, function () { + try{ + let value = I18n.System.isSuggested(12345); + console.log('i18n_system_test_3100 ' + value); + expect(value).assertTrue(); + }catch(e){ + console.log('i18n_system_test_3100 ' + e.code); + console.log('i18n_system_test_3100 ' + e.message); + expect(e.code).assertEqual('890001'); + expect(e.message).assertEqual('Param value not valid'); + } + }) + + /* * + * @tc.number SUB_GLOBAL_I18N_SYSTEM_JS_3200 + * @tc.name getSystemLanguage + * @tc.desc check the getSystemLanguage + */ + it('i18n_system_test_3200', 0, function () { + let lang = I18n.System.getSystemLanguage(); + console.log('i18n_system_test_3200 ' + lang); + expect(lang).assertInstanceOf('String'); + }) + + /* * + * @tc.number SUB_GLOBAL_I18N_SYSTEM_JS_3300 + * @tc.name getSystemRegion + * @tc.desc check the getSystemRegion + */ + it('i18n_system_test_3300', 0, function () { + let region = I18n.System.getSystemRegion(); + console.log('i18n_system_test_3300 ' + region); + expect(region).assertInstanceOf('String'); + }) + + /* * + * @tc.number SUB_GLOBAL_I18N_SYSTEM_JS_3400 + * @tc.name getSystemLocale + * @tc.desc check the getSystemLocale + */ + it('i18n_system_test_3400', 0, function () { + let locale = I18n.System.getSystemLocale(); + console.log('i18n_system_test_3400 ' + locale); + expect(locale).assertInstanceOf('String'); + }) + + /* * + * @tc.number SUB_GLOBAL_I18N_SYSTEM_JS_3500 + * @tc.name is24HourClock + * @tc.desc check the is24HourClock + */ + it('i18n_system_test_3500', 0, function () { + let value = I18n.System.is24HourClock(); + console.log('i18n_system_test_3500 ' + value); + expect(value).assertFalse(); + }) + + /* * + * @tc.number SUB_GLOBAL_I18N_SYSTEM_JS_3600 + * @tc.name test the getPreferredLanguageList interface with default value + * @tc.desc check the value of getPreferredLanguageList method + */ + it('i18n_system_test_3600', 0, function () { + console.log('i18n_system_test_3600 ' + 'start'); + let value = I18n.System.getPreferredLanguageList(); + console.log('i18n_system_test_3600 ' + value); + expect(value.length).assertLarger(0); + }) + + /* * + * @tc.number SUB_GLOBAL_I18N_SYSTEM_JS_3700 + * @tc.name test the getFirstPreferredLanguage interface + * @tc.desc check the value of getFirstPreferredLanguage method + */ + it('i18n_system_test_3700', 0, function () { + console.log('i18n_system_test_3700 ' + 'start'); + let value = I18n.System.getFirstPreferredLanguage(); + console.log('i18n_system_test_3700 ' + value); + let list = I18n.System.getPreferredLanguageList(); + console.log('i18n_system_test_3700 ' + list); + expect(list.length).assertLarger(0); + if(list[0] == 'zh-Hans'){ + expect(value).assertEqual('zh-Hans'); + } + else if(list[0] == 'en'){ + expect(value).assertEqual('en'); + } + }) + + /* * + * @tc.number SUB_GLOBAL_I18N_SYSTEM_JS_3800 + * @tc.name test the getAppPreferredLanguage interface + * @tc.desc check the value of getAppPreferredLanguage method + */ + it('i18n_system_test_3800', 0, function () { + console.log('i18n_system_test_3800 ' + 'start'); + let value = I18n.System.getAppPreferredLanguage(); + console.log('i18n_system_test_3800 ' + value); + expect(value).assertContain('zh'); + }) + + /* * + * @tc.number SUB_GLOBAL_I18N_SYSTEM_JS_3900 + * @tc.name test getUsingLocalDigit method + * @tc.desc get the getUsingLocalDigit value + */ + it('i18n_system_test_3900', 0, function () { + let value = I18n.System.getUsingLocalDigit(); + console.log('i18n_system_test_3900 ' + value); + expect(value).assertFalse(); + }) + + console.log('*************end SystemInI18nTest*************'); +})} diff --git a/global/resmgr_standard/resmgrjs/src/main/js/test/Resmgr.test.js b/global/resmgr_standard/resmgrjs/src/main/js/test/Resmgr.test.js index c51e3737b3efb2eecf317c29bfac11291c829cd8..8bc76d132d6caa63020c5c2ce222226ee1308404 100644 --- a/global/resmgr_standard/resmgrjs/src/main/js/test/Resmgr.test.js +++ b/global/resmgr_standard/resmgrjs/src/main/js/test/Resmgr.test.js @@ -1790,6 +1790,25 @@ describe('resMgrTest', function () { }) }) + /** + * @tc.number SUB_GLOBAL_RESMGR_DRAWABLE_JS_0140 + * @tc.name getDrawableDescriptor with null density + * @tc.desc test the getDrawableDescriptor method + */ + it('getDrawableDescriptor_test_0140', 0, async function (done) { + resmgr.getResourceManager((error, mgr) => { + try{ + let value = mgr.getDrawableDescriptor(0x01000017, null); + console.log('getDrawableDescriptor_test_0140 ' + JSON.stringify(value)); + expect(value != null).assertTrue(); + }catch(error){ + console.log('getDrawableDescriptor_test_0140 ' + error.code); + console.log('getDrawableDescriptor_test_0140 ' + error.message); + } + done(); + }) + }) + /** * @tc.number SUB_GLOBAL_RESMGR_DRAWABLE_JS_0200 * @tc.name getDrawableDescriptor with normal pic and density @@ -2004,6 +2023,25 @@ describe('resMgrTest', function () { done(); }) + /** + * @tc.number SUB_GLOBAL_RESMGR_DRAWABLE_JS_1140 + * @tc.name getDrawableDescriptorByName with null density + * @tc.desc test the getDrawableDescriptorByName method + */ + it('getDrawableDescriptor_test_1140', 0, async function (done) { + resmgr.getResourceManager((error, mgr) => { + try{ + let value = mgr.getDrawableDescriptorByName('icon', null); + console.log('getDrawableDescriptor_test_1140 ' + JSON.stringify(value)); + expect(value != null).assertTrue(); + }catch(error){ + console.log('getDrawableDescriptor_test_1140 ' + error.code); + console.log('getDrawableDescriptor_test_1140 ' + error.message); + } + }) + done(); + }) + /** * @tc.number SUB_GLOBAL_RESMGR_DRAWABLE_JS_1200 * @tc.name getDrawableDescriptorByName with normal pic and density