提交 ad9669c1 编写于 作者: O openharmony_ci 提交者: Gitee

!708 modify testcases on 20210924

Merge pull request !708 from 杨清/0911
......@@ -13,6 +13,18 @@
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "PushKit",
"push": [
"resource/global/white_languages.xml->/system/usr/ohos_locale_config/white_languages.xml"
]
},
{
"type": "ShellKit",
"run-command": [
"chmod 644 /system/usr/ohos_locale_config/white_languages.xml"
]
}
]
}
/*
* 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 I18n from '@ohos.i18n'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
describe('I18nTest', function () {
console.log('*************start I18NTest*************');
/* *
* @tc.number SUB_GLOBAL_I18N_JS_0100
* @tc.name getSystemLanguage
* @tc.desc check the getSystemLanguage
*/
it('i18n_test_0100', 0, function () {
let lang = I18n.getSystemLanguage();
console.log('i18n_test_0100 ' + lang);
expect(lang).assertInstanceOf('String');
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_0200
* @tc.name getSystemRegion
* @tc.desc check the getSystemRegion
*/
it('i18n_test_0200', 0, function () {
let region = I18n.getSystemRegion();
console.log('i18n_test_0200 ' + region);
expect(region).assertInstanceOf('String');
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_0300
* @tc.name getSystemLocale
* @tc.desc check the getSystemLocale
*/
it('i18n_test_0300', 0, function () {
let locale = I18n.getSystemLocale();
console.log('i18n_test_0300 ' + locale);
expect(locale).assertInstanceOf('String');
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_0400
* @tc.name setSystemLanguage with en param
* @tc.desc check the language
*/
it('i18n_test_0400', 0, function () {
let value = I18n.setSystemLanguage('en');
console.log('i18n_test_0400 ' + value);
expect(value).assertTrue();
let lang = I18n.getSystemLanguage();
console.log('i18n_test_0400 ' + lang);
expect(lang).assertEqual('en');
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_0500
* @tc.name setSystemLanguage with ko-KR param
* @tc.desc check the language
*/
it('i18n_test_0500', 0, function () {
let value = I18n.setSystemLanguage('ko-KR');
console.log('i18n_test_0500 ' + value);
expect(value).assertTrue();
let lang = I18n.getSystemLanguage();
console.log('i18n_test_0500 ' + lang);
expect(lang).assertEqual('ko-KR');
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_0600
* @tc.name setSystemLanguage with it-Ital-IT param
* @tc.desc check the language
*/
it('i18n_test_0600', 0, function () {
let value = I18n.setSystemLanguage('it-Ital-IT');
console.log('i18n_test_0600 ' + value);
expect(value).assertTrue();
let lang = I18n.getSystemLanguage();
console.log('i18n_test_0600 ' + lang);
expect(lang).assertEqual('it-Ital-IT');
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_0700
* @tc.name setSystemLanguage with null param
* @tc.desc check the language
*/
it('i18n_test_0700', 0, function () {
let value = I18n.setSystemLanguage('');
console.log('i18n_test_0700 ' + value);
expect(value).assertFalse();
let lang = I18n.getSystemLanguage();
console.log('i18n_test_0700 ' + lang);
expect(lang).assertEqual('it-Ital-IT');
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_0800
* @tc.name setSystemLanguage with not exist param aa
* @tc.desc check the language
*/
it('i18n_test_0800', 0, function () {
let value = I18n.setSystemLanguage('aa');
console.log('i18n_test_0800 ' + value);
expect(value).assertTrue();
let lang = I18n.getSystemLanguage();
console.log('i18n_test_0800 ' + lang);
expect(lang).assertEqual('aa');
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_0900
* @tc.name setSystemLanguage with not exist param aabb
* @tc.desc check the language
*/
it('i18n_test_0900', 0, function () {
let value = I18n.setSystemLanguage('aabb');
console.log('i18n_test_0900 ' + value);
expect(value).assertFalse();
let lang = I18n.getSystemLanguage();
console.log('i18n_test_0900 ' + lang);
expect(lang).assertEqual('aa');
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_1000
* @tc.name setSystemLanguage with es-aaaa param
* @tc.desc check the language
*/
it('i18n_test_1000', 0, function () {
let value = I18n.setSystemLanguage('es-aaaa');
console.log('i18n_test_1000 ' + value);
expect(value).assertTrue();
let lang = I18n.getSystemLanguage();
console.log('i18n_test_1000 ' + lang);
expect(lang).assertEqual('es-aaaa');
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_1100
* @tc.name setSystemLanguage with it-Ital-AA param
* @tc.desc check the language
*/
it('i18n_test_1100', 0, function () {
let value = I18n.setSystemLanguage('it-Ital-AA');
console.log('i18n_test_1100 ' + value);
expect(value).assertTrue();
let lang = I18n.getSystemLanguage();
console.log('i18n_test_1100 ' + lang);
expect(lang).assertEqual('it-Ital-AA');
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_1200
* @tc.name format the language in locale
* @tc.desc check the language
*/
it('i18n_test_1200', 0, function () {
let value = I18n.setSystemRegion('US');
console.log('i18n_test_1200 ' + value);
expect(value).assertTrue();
let region = I18n.getSystemRegion();
console.log('i18n_test_1200 ' + region);
expect(region).assertEqual('US');
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_1300
* @tc.name format the language in locale
* @tc.desc check the language
*/
it('i18n_test_1300', 0, function () {
let value = I18n.setSystemRegion('');
console.log('i18n_test_1300 ' + value);
expect(value).assertFalse();
let region = I18n.getSystemRegion();
console.log('i18n_test_1300 ' + region);
expect(region).assertEqual('US');
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_1400
* @tc.name format the language in locale
* @tc.desc check the language
*/
it('i18n_test_1400', 0, function () {
let value = I18n.setSystemRegion('AA');
console.log('i18n_test_1400 ' + value);
expect(value).assertTrue();
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_1500
* @tc.name format the language in locale
* @tc.desc check the language
*/
it('i18n_test_1500', 0, function () {
let value = I18n.setSystemRegion('zh-CN');
console.log('i18n_test_1500 ' + value);
expect(value).assertFalse();
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_1600
* @tc.name format the language in locale
* @tc.desc check the language
*/
it('i18n_test_1600', 0, function () {
let value = I18n.setSystemLocale('en-Latn-US');
console.log('i18n_test_1600 ' + value);
expect(value).assertTrue();
let locale = I18n.getSystemLocale();
console.log('i18n_test_1600 ' + locale);
expect(locale).assertEqual('en-Latn-US');
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_1700
* @tc.name format the language in locale
* @tc.desc check the language
*/
it('i18n_test_1700', 0, function () {
let value = I18n.setSystemLocale('');
console.log('i18n_test_1700 ' + value);
expect(value).assertFalse();
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_1800
* @tc.name format the language in locale
* @tc.desc check the language
*/
it('i18n_test_1800', 0, function () {
let value = I18n.setSystemLocale('aa');
console.log('i18n_test_1800 ' + value);
expect(value).assertTrue();
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_1900
* @tc.name format the language in locale
* @tc.desc check the language
*/
it('i18n_test_1900', 0, function () {
let value = I18n.setSystemLocale('zh-AAAA');
console.log('i18n_test_1900 ' + value);
expect(value).assertTrue();
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_2000
* @tc.name format the language in locale
* @tc.desc check the language
*/
it('i18n_test_2000', 0, function () {
let value = I18n.setSystemLocale('zh-Hans-AA');
console.log('i18n_test_2000 ' + value);
expect(value).assertTrue();
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_2100
* @tc.name format the language in locale
* @tc.desc check the language
*/
it('i18n_test_2100', 0, function () {
let lang = I18n.getSystemLanguages();
let len = lang.length;
console.log('i18n_test_2100 ' + len);
expect(len).assertLarger(0);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_2200
* @tc.name format the language in locale
* @tc.desc check the language
*/
it('i18n_test_2200', 0, function () {
let count = I18n.getSystemCountries('en');
let len = count.length;
console.log('i18n_test_2200 ' + len);
expect(len).assertLarger(0);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_2220
* @tc.name format the language in locale
* @tc.desc check the language
*/
it('i18n_test_2220', 0, function () {
let count = I18n.getSystemCountries('zh-CN');
let len = count.length;
console.log('i18n_test_2220 ' + len);
expect(len).assertLarger(0);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_2240
* @tc.name format the language in locale
* @tc.desc check the language
*/
it('i18n_test_2240', 0, function () {
let count = I18n.getSystemCountries('zh-Hans-CN');
let len = count.length;
console.log('i18n_test_2240 ' + len);
expect(len).assertLarger(0);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_2260
* @tc.name format the language in locale
* @tc.desc check the language
*/
it('i18n_test_2260', 0, function () {
let count = I18n.getSystemCountries('');
let len = count.length;
console.log('i18n_test_2260 ' + len);
expect(len).assertLarger(0);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_2280
* @tc.name format the language in locale
* @tc.desc check the language
*/
it('i18n_test_2280', 0, function () {
let count = I18n.getSystemCountries('aaa');
let len = count.length;
console.log('i18n_test_2280 ' + len);
expect(len).assertLarger(0);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_2300
* @tc.name format the language in locale
* @tc.desc check the language
*/
it('i18n_test_2300', 0, function () {
let region = I18n.setSystemRegion('US');
console.log('i18n_test_2300 ' + region);
expect(region).assertTrue();
let value = I18n.isSuggested('en');
console.log('i18n_test_2300 ' + value);
expect(value).assertTrue();
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_2400
* @tc.name format the language in locale
* @tc.desc check the language
*/
it('i18n_test_2400', 0, function () {
let region = I18n.setSystemRegion('CN');
console.log('i18n_test_2400 ' + region);
expect(region).assertTrue();
let value = I18n.isSuggested('zh-Hans');
console.log('i18n_test_2400 ' + value);
expect(value).assertTrue();
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_2500
* @tc.name format the language in locale
* @tc.desc check the language
*/
it('i18n_test_2500', 0, function () {
let region = I18n.setSystemRegion('CN');
console.log('i18n_test_2500 ' + region);
expect(region).assertTrue();
let value = I18n.isSuggested('zh-Hans-CN');
console.log('i18n_test_2500 ' + value);
expect(value).assertTrue();
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_2600
* @tc.name format the language in locale
* @tc.desc check the language
*/
it('i18n_test_2600', 0, function () {
let value = I18n.isSuggested('fr');
console.log('i18n_test_2600 ' + value);
expect(value).assertFalse();
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_2700
* @tc.name format the language in locale
* @tc.desc check the language
*/
it('i18n_test_2700', 0, function () {
let value = I18n.isSuggested('fr-FR');
console.log('i18n_test_2700 ' + value);
expect(value).assertFalse();
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_2800
* @tc.name format the language in locale
* @tc.desc check the language
*/
it('i18n_test_2800', 0, function () {
let value = I18n.isSuggested('az-Latn-AZ');
console.log('i18n_test_2800 ' + value);
expect(value).assertFalse();
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_2900
* @tc.name format the language in locale
* @tc.desc check the language
*/
it('i18n_test_2900', 0, function () {
let value = I18n.isSuggested('en-ZH');
console.log('i18n_test_2900 ' + value);
expect(value).assertFalse();
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_3000
* @tc.name format the language in locale
* @tc.desc check the language
*/
it('i18n_test_3000', 0, function () {
let value = I18n.isSuggested('aa');
console.log('i18n_test_3000 ' + value);
expect(value).assertFalse();
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_3100
* @tc.name format the language in locale
* @tc.desc check the language
*/
it('i18n_test_3100', 0, function () {
let region = I18n.setSystemRegion('GB');
console.log('i18n_test_3100 ' + region);
expect(region).assertTrue();
let value = I18n.isSuggested('en', 'GB');
console.log('i18n_test_3100 ' + value);
expect(value).assertFalse();
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_3150
* @tc.name format the language in locale
* @tc.desc check the language
*/
it('i18n_test_3150', 0, function () {
let region = I18n.setSystemRegion('GB');
console.log('i18n_test_3150 ' + region);
expect(region).assertTrue();
let value = I18n.isSuggested('en-SG', 'GB');
console.log('i18n_test_3150 ' + value);
expect(value).assertTrue();
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_3200
* @tc.name format the language in locale
* @tc.desc check the language
*/
it('i18n_test_3200', 0, function () {
let value = I18n.isSuggested('en', 'ZH');
console.log('i18n_test_3200 ' + value);
expect(value).assertFalse();
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_3300
* @tc.name format the language in locale
* @tc.desc check the language
*/
it('i18n_test_3300', 0, function () {
let value = I18n.isSuggested('en-GB', 'ZH');
console.log('i18n_test_3300 ' + value);
expect(value).assertFalse();
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_3400
* @tc.name format the language in locale
* @tc.desc check the language
*/
it('i18n_test_3400', 0, function () {
let value = I18n.isSuggested('en-ZH', 'GB');
console.log('i18n_test_3400 ' + value);
expect(value).assertTrue();
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_3500
* @tc.name format the language in locale
* @tc.desc check the language
*/
it('i18n_test_3500', 0, function () {
let value = I18n.isSuggested('en-ZH', 'GB');
console.log('i18n_test_3500 ' + value);
expect(value).assertTrue();
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_3600
* @tc.name format the language in locale
* @tc.desc check the language
*/
it('i18n_test_3600', 0, function () {
let value = I18n.isSuggested('zh-Hans-TW', 'CN');
console.log('i18n_test_3600 ' + value);
expect(value).assertTrue();
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_3700
* @tc.name format the language in locale
* @tc.desc check the language
*/
it('i18n_test_3700', 0, function () {
let value = I18n.isSuggested('zh-Hans-CN', 'HK');
console.log('i18n_test_3700 ' + value);
expect(value).assertTrue();
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_3800
* @tc.name format the language in locale
* @tc.desc check the language
*/
it('i18n_test_3800', 0, function () {
let value = I18n.getDisplayCountry('zh-Hans-CN', 'en-US', true);
console.log('i18n_test_3800 ' + value);
expect(value).assertEqual('China');
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_3900
* @tc.name format the language in locale
* @tc.desc check the language
*/
it('i18n_test_3900', 0, function () {
let value = I18n.getDisplayCountry('zh', 'en-US', true);
console.log('i18n_test_3900 ' + value);
expect(value).assertNull();
expect(value).assertEqual('China');
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_4000
* @tc.name format the language in locale
* @tc.desc check the language
*/
it('i18n_test_4000', 0, function () {
let value = I18n.getDisplayCountry('zh-CN', 'en-US', true);
console.log('i18n_test_4000 ' + value);
expect(value).assertEqual('China');
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_4100
* @tc.name format the language in locale
* @tc.desc check the language
*/
it('i18n_test_4100', 0, function () {
let value = I18n.getDisplayCountry('zh-Hans', 'en-US', true);
console.log('i18n_test_4100 ' + value);
expect(value).assertNull();
expect(value).assertEqual('China');
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_4200
* @tc.name format the language in locale
* @tc.desc check the language
*/
it('i18n_test_4200', 0, function () {
let value = I18n.getDisplayCountry('zh-Hans-CN', 'en-US', false);
console.log('i18n_test_4200 ' + value);
expect(value).assertEqual('China');
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_4300
* @tc.name format the language in locale
* @tc.desc check the language
*/
it('i18n_test_4300', 0, function () {
let value = I18n.getDisplayCountry('zh-Hans-CN', 'en-US');
console.log('i18n_test_4300 ' + value);
expect(value).assertEqual('China');
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_4400
* @tc.name format the language in locale
* @tc.desc check the language
*/
it('i18n_test_4400', 0, function () {
let value = I18n.getDisplayLanguage('zh-Hans-CN', 'en-US', true);
console.log('i18n_test_4400 ' + value);
expect(value).assertEqual('Chinese');
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_4500
* @tc.name format the language in locale
* @tc.desc check the language
*/
it('i18n_test_4500', 0, function () {
let value = I18n.getDisplayLanguage('zh-Hans-CN', 'en-US', true);
console.log('i18n_test_4500 ' + value);
expect(value).assertEqual('Chinese');
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_4600
* @tc.name format the language in locale
* @tc.desc check the language
*/
it('i18n_test_4600', 0, function () {
let value = I18n.getDisplayLanguage('zh', 'en-US', true);
console.log('i18n_test_4600 ' + value);
expect(value).assertEqual('Chinese');
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_4700
* @tc.name format the language in locale
* @tc.desc check the language
*/
it('i18n_test_4700', 0, function () {
let value = I18n.getDisplayLanguage('zh-CN', 'en-US', true);
console.log('i18n_test_4700 ' + value);
expect(value).assertEqual('Chinese');
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_4800
* @tc.name format the language in locale
* @tc.desc check the language
*/
it('i18n_test_4800', 0, function () {
let value = I18n.getDisplayLanguage('zh-Hans', 'en-US', true);
console.log('i18n_test_4800 ' + value);
expect(value).assertEqual('Chinese');
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_4900
* @tc.name format the language in locale
* @tc.desc check the language
*/
it('i18n_test_4900', 0, function () {
let value = I18n.getDisplayLanguage('zh-Hans-CN', 'en-US', false);
console.log('i18n_test_4900 ' + value);
expect(value).assertEqual('Chinese');
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_5000
* @tc.name format the language in locale
* @tc.desc check the language
*/
it('i18n_test_5000', 0, function () {
let value = I18n.getDisplayLanguage('zh-Hans-CN', 'en-US');
console.log('i18n_test_5000 ' + value);
expect(value).assertEqual('Chinese');
})
console.log('*************end I18NTest*************');
})
\ No newline at end of file
......@@ -323,7 +323,7 @@ describe('intlTest', function () {
it('locale_test_2203', 0, function () {
let locale = new Intl.Locale('zh-Hans-CN-u-ca-gregory-co-compact');
console.log('locale_test_2203 ' + locale.minimize().toString());
expect(locale.minimize().toString()).assertEqual('zh');
expect(locale.minimize().toString()).assertEqual('zh-u-ca-gregory-co-compact');
})
/* *
......@@ -499,12 +499,13 @@ describe('intlTest', function () {
* @tc.name format the date with aa locale
* @tc.desc check the date
*/
// it('dateTimeFormat_test_0400', 0, function () {
// let date = new Date(2021, 11, 17, 3, 24, 0);
// let datefmt = new Intl.DateTimeFormat('aa');
// console.log('dateTimeFormat_test_0400 ' + datefmt.format(date));
// expect(datefmt.format(date)).assertEqual('2021/12/17');
// })
it('dateTimeFormat_test_0400', 0, function () {
let date = new Date(2021, 11, 17, 3, 24, 0);
let datefmt = new Intl.DateTimeFormat('aa');
let value = datefmt.format(date);
console.log('dateTimeFormat_test_0400 ' + value);
expect(value).assertInstanceOf('String');
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_0500
......@@ -550,13 +551,13 @@ describe('intlTest', function () {
* @tc.name format the hour without correct locale
* @tc.desc check the hour without correct locale
*/
// it('dateTimeFormat_test_0800', 0, function () {
// let date = new Date(2020, 11, 20, 14, 23, 16);
// let option = { dateStyle: 'full' };
// let datefmt = new Intl.DateTimeFormat(['abc', 'ban'], option);
// console.log('dateTimeFormat_test_0800 ' + datefmt.format(date));
// expect(datefmt.format(date)).assertEqual('12/20/20, 2:23 PM');
// })
it('dateTimeFormat_test_0800', 0, function () {
let date = new Date(2020, 11, 20, 14, 23, 16);
let option = { dateStyle: 'full' };
let datefmt = new Intl.DateTimeFormat(['abc', 'ban'], option);
console.log('dateTimeFormat_test_0800 ' + datefmt.format(date));
expect(datefmt.format(date)).assertEqual('12/20/20, 2:23 PM');
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_0900
......
......@@ -12,4 +12,5 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
require('./I18n.test.js')
require('./Intl.test.js')
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册