未验证 提交 57a5fd41 编写于 作者: O openharmony_ci 提交者: Gitee

!8617 add system module cases in i18n

Merge pull request !8617 from 杨清/master
...@@ -342,6 +342,17 @@ describe('I18nTest', function () { ...@@ -342,6 +342,17 @@ describe('I18nTest', function () {
expect(value).assertEqual('China'); 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.number SUB_GLOBAL_I18N_JS_3900
* @tc.name getDisplayCountry with zh and en-US and true param * @tc.name getDisplayCountry with zh and en-US and true param
...@@ -419,6 +430,17 @@ describe('I18nTest', function () { ...@@ -419,6 +430,17 @@ describe('I18nTest', function () {
expect(value).assertEqual('China'); 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.number SUB_GLOBAL_I18N_JS_4330
* @tc.name getDisplayCountry with zh and en-US and true param * @tc.name getDisplayCountry with zh and en-US and true param
...@@ -546,6 +568,17 @@ describe('I18nTest', function () { ...@@ -546,6 +568,17 @@ describe('I18nTest', function () {
expect(value).assertEqual('Simplified Chinese'); 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.number SUB_GLOBAL_I18N_JS_4500
* @tc.name getDisplayLanguage with zh-Hans-CN and en-GB and true param * @tc.name getDisplayLanguage with zh-Hans-CN and en-GB and true param
...@@ -634,6 +667,17 @@ describe('I18nTest', function () { ...@@ -634,6 +667,17 @@ describe('I18nTest', function () {
expect(value).assertEqual('Simplified Chinese'); 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.number SUB_GLOBAL_I18N_JS_5030
* @tc.name getDisplayLanguage with zh-Hans-CN and en-GB and true param * @tc.name getDisplayLanguage with zh-Hans-CN and en-GB and true param
...@@ -767,30 +811,45 @@ describe('I18nTest', function () { ...@@ -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.name test isValidNumber interface with 0755-6100088X param
* @tc.desc get the isValidNumber value * @tc.desc get the isValidNumber value
*/ */
it('i18n_test_5120', 0, function () { it('i18n_test_5160', 0, function () {
console.log('i18n_test_5120 ' + 'start'); console.log('i18n_test_5160 ' + 'start');
let phonenumber = new I18n.PhoneNumberFormat('CN'); let phonenumber = new I18n.PhoneNumberFormat('CN');
let ran = Math.ceil(Math.random(1) * 9); 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); let valid = phonenumber.isValidNumber('0755-6100088' + ran);
console.log('i18n_test_5120 ' + valid); console.log('i18n_test_5160 ' + valid);
expect(valid).assertEqual(true); 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.name test isValidNumber interface with 110 param
* @tc.desc get the isValidNumber value * @tc.desc get the isValidNumber value
*/ */
it('i18n_test_5140', 0, function () { it('i18n_test_5180', 0, function () {
console.log('i18n_test_5140 ' + 'start'); console.log('i18n_test_5180 ' + 'start');
let phonenumber = new I18n.PhoneNumberFormat('CN'); let phonenumber = new I18n.PhoneNumberFormat('CN');
let valid = phonenumber.isValidNumber('110'); let valid = phonenumber.isValidNumber('110');
console.log('i18n_test_5140 ' + valid); console.log('i18n_test_5180 ' + valid);
expect(valid).assertEqual(false); expect(valid).assertEqual(false);
}) })
...@@ -1763,7 +1822,7 @@ describe('I18nTest', function () { ...@@ -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.name test unitConvert interface from cup to liter unit with undefined style
* @tc.desc get the unitConvert value * @tc.desc get the unitConvert value
*/ */
...@@ -1778,6 +1837,22 @@ describe('I18nTest', function () { ...@@ -1778,6 +1837,22 @@ describe('I18nTest', function () {
expect(value).assertEqual('236.588 L'); 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.number SUB_GLOBAL_I18N_JS_9200
* @tc.name test unitConvert interface from cup to liter unit with medium style * @tc.name test unitConvert interface from cup to liter unit with medium style
...@@ -2004,6 +2079,23 @@ describe('I18nTest', function () { ...@@ -2004,6 +2079,23 @@ describe('I18nTest', function () {
expect(value).assertEqual('236.588 L'); 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.number SUB_GLOBAL_I18N_JS_9940
* @tc.name test unitConvert interface from cup to liter unit with medium style * @tc.name test unitConvert interface from cup to liter unit with medium style
......
...@@ -82,6 +82,19 @@ describe('intlTest', function () { ...@@ -82,6 +82,19 @@ describe('intlTest', function () {
expect(locale.numeric).assertFalse(); 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.number SUB_GLOBAL_INTL_JS_LOCALE_0140
* @tc.name test the language in locale * @tc.name test the language in locale
...@@ -545,6 +558,18 @@ describe('intlTest', function () { ...@@ -545,6 +558,18 @@ describe('intlTest', function () {
expect(datefmt.format(date)).assertContain('2021'); 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.number SUB_GLOBAL_INTL_JS_DATETIME_0300
* @tc.name format the date with en locale * @tc.name format the date with en locale
...@@ -914,6 +939,17 @@ describe('intlTest', function () { ...@@ -914,6 +939,17 @@ describe('intlTest', function () {
expect(numfmt.format(123456.789)).assertEqual('123,456.789'); 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.number SUB_GLOBAL_INTL_JS_NUMBER_0200
* @tc.name format the number in zh-u-nu-latn * @tc.name format the number in zh-u-nu-latn
...@@ -1321,6 +1357,18 @@ describe('intlTest', function () { ...@@ -1321,6 +1357,18 @@ describe('intlTest', function () {
expect(value).assertEqual('other'); 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.number SUB_GLOBAL_INTL_JS_PLURAL_2800
* @tc.name get PluralRules with zh locale and ordinal type * @tc.name get PluralRules with zh locale and ordinal type
...@@ -1465,6 +1513,18 @@ describe('intlTest', function () { ...@@ -1465,6 +1513,18 @@ describe('intlTest', function () {
expect(value).assertEqual(-1); 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.number SUB_GLOBAL_INTL_JS_COLLATOR_3700
* @tc.name compare two different strings with zh locale and eor collation * @tc.name compare two different strings with zh locale and eor collation
...@@ -1595,6 +1655,19 @@ describe('intlTest', function () { ...@@ -1595,6 +1655,19 @@ describe('intlTest', function () {
expect(value).assertEqual('in 100 seconds'); 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.number SUB_GLOBAL_I18N_JS_RELATIVETIMEFORMAT_0300
* @tc.name format the relativetime with 100 second in narrow style * @tc.name format the relativetime with 100 second in narrow style
......
...@@ -138,6 +138,18 @@ describe('LangTest', function () { ...@@ -138,6 +138,18 @@ describe('LangTest', function () {
expect(value.length).assertLarger(0); 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.number SUB_GLOBAL_I18N_JS_PREFERREDLANGUAGE_0120
* @tc.name test the addPreferredLanguage interface * @tc.name test the addPreferredLanguage interface
...@@ -199,6 +211,26 @@ describe('LangTest', function () { ...@@ -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.number SUB_GLOBAL_I18N_JS_PREFERREDLANGUAGE_1100
* @tc.name test the getAppPreferredLanguage interface * @tc.name test the getAppPreferredLanguage interface
...@@ -211,6 +243,18 @@ describe('LangTest', function () { ...@@ -211,6 +243,18 @@ describe('LangTest', function () {
expect(value).assertContain('zh'); 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.number SUB_GLOBAL_INTL_JS_TRANSFER_0100
* @tc.name transfer from lower to upper * @tc.name transfer from lower to upper
......
...@@ -15,8 +15,10 @@ ...@@ -15,8 +15,10 @@
import I18nTest from './I18n.test.js' import I18nTest from './I18n.test.js'
import intlTest from './Intl.test.js' import intlTest from './Intl.test.js'
import LangTest from './Lang.test.js' import LangTest from './Lang.test.js'
import SystemInI18nTest from './SystemInI18n.test.js'
export default function testsuite() { export default function testsuite() {
I18nTest() I18nTest()
intlTest() intlTest()
LangTest() LangTest()
SystemInI18nTest()
} }
...@@ -1790,6 +1790,25 @@ describe('resMgrTest', function () { ...@@ -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.number SUB_GLOBAL_RESMGR_DRAWABLE_JS_0200
* @tc.name getDrawableDescriptor with normal pic and density * @tc.name getDrawableDescriptor with normal pic and density
...@@ -2004,6 +2023,25 @@ describe('resMgrTest', function () { ...@@ -2004,6 +2023,25 @@ describe('resMgrTest', function () {
done(); 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.number SUB_GLOBAL_RESMGR_DRAWABLE_JS_1200
* @tc.name getDrawableDescriptorByName with normal pic and density * @tc.name getDrawableDescriptorByName with normal pic and density
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册