未验证 提交 461ca6c8 编写于 作者: O openharmony_ci 提交者: Gitee

!2469 sync to 3.1 rls review issues

Merge pull request !2469 from 杨清/cherry-pick-1647338443
......@@ -44,6 +44,12 @@
"launchType": "standard"
}
],
"reqPermissions": [
{
"name":"ohos.permission.GET_BUNDLE_INFO",
"reason":"need use ohos.permission.GET_BUNDLE_INFO"
}
],
"js": [
{
"pages": [
......
......@@ -19,6 +19,45 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '
describe('I18nTest', function () {
console.log('*************start I18NTest*************');
let hour = I18n.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.is24HourClock()
+ ' prelang: ' + I18n.getPreferredLanguageList()
+ ' syslocale: ' + I18n.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(){
let afterValue = I18n.set24HourClock(hour);
console.log('step after every cases.' + afterValue);
console.log('24 hour clock after every cases ' + I18n.is24HourClock());
})
/* *
* execute this step after all testcases
*/
afterAll(function(){
console.log('step after all cases in I18n.'
+ ' 24hour: ' + I18n.is24HourClock()
+ ' prelang: ' + I18n.getPreferredLanguageList()
+ ' syslocale: ' + I18n.getSystemLocale());
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_0100
* @tc.name getSystemLanguage
......
......@@ -20,6 +20,45 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '
describe('intlTest', function () {
console.log('*************start IntlTest*************');
let hour = I18n.is24HourClock();
console.log('init 24 hour clock value ' + hour);
/* *
* execute this step before all testcases
*/
beforeAll(function(){
console.log('step before all cases in intl.'
+ ' 24hour: ' + I18n.is24HourClock()
+ ' prelang: ' + I18n.getPreferredLanguageList()
+ ' syslocale: ' + I18n.getSystemLocale());
})
/* *
* execute this step before every testcase
*/
beforeEach(function(){
console.log('step before every case in intl.');
})
/* *
* execute this step after every testcase
*/
afterEach(function(){
let afterValue = I18n.set24HourClock(hour);
console.log('step after every cases.' + afterValue);
console.log('24 hour clock after every cases ' + I18n.is24HourClock());
})
/* *
* execute this step after all testcases
*/
afterAll(function(){
console.log('step after all cases in intl.'
+ ' 24hour: ' + I18n.is24HourClock()
+ ' prelang: ' + I18n.getPreferredLanguageList()
+ ' syslocale: ' + I18n.getSystemLocale());
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_LOCALE_0100
* @tc.name test the language in en-Latn-GB locale
......@@ -568,7 +607,7 @@ describe('intlTest', function () {
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');
expect(datefmt.format(date)).assertEqual('2020年12月20日星期日');
})
/* *
......
......@@ -21,6 +21,7 @@ describe('LangTest', function () {
let initPreferredLang = I18n.getPreferredLanguageList();
let initLen = initPreferredLang.length;
let hour = I18n.is24HourClock();
/* *
* get the current preferred language list
......@@ -77,11 +78,20 @@ describe('LangTest', function () {
console.log('i18n_test_preferredlanguage_restoreLang ' + I18n.getPreferredLanguageList());
}
/* *
* execute this step before all testcases
*/
beforeAll(function(){
console.log('step before all cases in lang.'
+ ' 24hour: ' + I18n.is24HourClock()
+ ' prelang: ' + I18n.getPreferredLanguageList()
+ ' syslocale: ' + I18n.getSystemLocale());
})
/* *
* execute this step before every testcase
*/
beforeEach(function(){
I18n.set24HourClock(false);
console.log('i18n_test_preferredlanguage_beforeEach ' + getCurrentPreferredLang());
})
......@@ -93,6 +103,19 @@ describe('LangTest', function () {
console.log('i18n_test_preferredlanguage_afterEach ' + currLang);
clearLang(currLang);
restoreLang();
let afterValue = I18n.set24HourClock(hour);
console.log('step after every cases.' + afterValue);
console.log('24 hour clock after every cases ' + I18n.is24HourClock());
})
/* *
* execute this step after all testcases
*/
afterAll(function(){
console.log('step after all cases.'
+ ' 24hour: ' + I18n.is24HourClock()
+ ' prelang: ' + I18n.getPreferredLanguageList()
+ ' syslocale: ' + I18n.getSystemLocale());
})
/* *
......@@ -527,5 +550,226 @@ describe('LangTest', function () {
expect(value).assertEqual('the sky is in blue-style!');
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_TIMEZONE_0100
* @tc.name test getTimeZone method
* @tc.desc get the getTimeZone value
*/
it('timezone_test_0100', 0, function () {
console.log('timezone_test_0100 ' + 'start');
let timezone = I18n.getTimeZone();
let value = timezone.getID();
console.log('timezone_test_0100 ' + value);
expect(value).assertEqual('UTC');
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_TIMEZONE_0200
* @tc.name test getDisplayName method
* @tc.desc get the getDisplayName value
*/
it('timezone_test_0200', 0, function () {
console.log('timezone_test_0200 ' + 'start');
let timezone = I18n.getTimeZone();
let value = timezone.getDisplayName();
console.log('timezone_test_0200 ' + value);
expect(value).assertEqual('GMT');
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_TIMEZONE_0300
* @tc.name test getDisplayName method with zh-CN param
* @tc.desc get the getDisplayName value
*/
it('timezone_test_0300', 0, function () {
console.log('timezone_test_0300 ' + 'start');
let timezone = I18n.getTimeZone();
let value = timezone.getDisplayName('zh-CN');
console.log('timezone_test_0300 ' + value);
expect(value).assertEqual('GMT');
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_TIMEZONE_0400
* @tc.name test getDisplayName method with true param
* @tc.desc get the getDisplayName value
*/
it('timezone_test_0400', 0, function () {
console.log('timezone_test_0400 ' + 'start');
let timezone = I18n.getTimeZone();
let value = timezone.getDisplayName(true);
console.log('timezone_test_0400 ' + value);
expect(value).assertEqual('GMT');
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_TIMEZONE_0500
* @tc.name test getDisplayName method with false param
* @tc.desc get the getDisplayName value
*/
it('timezone_test_0500', 0, function () {
console.log('timezone_test_0500 ' + 'start');
let timezone = I18n.getTimeZone();
let value = timezone.getDisplayName(false);
console.log('timezone_test_0500 ' + value);
expect(value).assertEqual('GMT');
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_TIMEZONE_0600
* @tc.name test getRawOffset method
* @tc.desc get the getRawOffset value
*/
it('timezone_test_0600', 0, function () {
console.log('timezone_test_0600 ' + 'start');
let timezone = I18n.getTimeZone();
let value = timezone.getRawOffset();
console.log('timezone_test_0600 ' + value);
expect(value >= 0).assertEqual(true);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_TIMEZONE_0700
* @tc.name test getOffset method
* @tc.desc get the getOffset value
*/
it('timezone_test_0700', 0, function () {
console.log('timezone_test_0700 ' + 'start');
let timezone = I18n.getTimeZone();
let value = timezone.getOffset();
console.log('timezone_test_0700 ' + value);
expect(value >= 0).assertEqual(true);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_TIMEZONE_0800
* @tc.name test getOffset method with date param
* @tc.desc get the getOffset value
*/
it('timezone_test_0800', 0, function () {
console.log('timezone_test_0800 ' + 'start');
let timezone = I18n.getTimeZone();
let value = timezone.getOffset(10540800000);
console.log('timezone_test_0800 ' + value);
expect(value >= 0).assertEqual(true);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_TIMEZONE_0900
* @tc.name test getID
* @tc.desc get the getID value
*/
it('timezone_test_0900', 0, function () {
console.log('timezone_test_0900 ' + 'start');
let timezone = I18n.getTimeZone('ACT');
let value = timezone.getID();
console.log('timezone_test_0900 ' + value);
expect(value).assertEqual('ACT');
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_TIMEZONE_1000
* @tc.name test getDisplayName with timezone id
* @tc.desc get the getID value
*/
it('timezone_test_1000', 0, function () {
console.log('timezone_test_1000 ' + 'start');
let timezone = I18n.getTimeZone('ACT');
let value = timezone.getDisplayName();
console.log('timezone_test_1000 ' + value);
expect(value).assertEqual('澳大利亚中部标准时间');
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_TIMEZONE_1100
* @tc.name test getDisplayName with locale
* @tc.desc get the getID value
*/
it('timezone_test_1100', 0, function () {
console.log('timezone_test_1100 ' + 'start');
let timezone = I18n.getTimeZone('Asia/Shanghai');
let value = timezone.getDisplayName('zh-CN');
console.log('timezone_test_1100 ' + value);
expect(value).assertEqual('中国标准时间');
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_TIMEZONE_1200
* @tc.name test getDisplayName with locale
* @tc.desc get the getID value
*/
it('timezone_test_1200', 0, function () {
console.log('timezone_test_1200 ' + 'start');
let timezone = I18n.getTimeZone('Asia/Shanghai');
let value = timezone.getDisplayName('zh-CN', true);
console.log('timezone_test_1200 ' + value);
expect(value).assertEqual('中国标准时间');
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_TIMEZONE_1300
* @tc.name test getDisplayName with en-US and true param
* @tc.desc get the getID value
*/
it('timezone_test_1300', 0, function () {
console.log('timezone_test_1300 ' + 'start');
let timezone = I18n.getTimeZone('Asia/Shanghai');
let value = timezone.getDisplayName('en-US', true);
console.log('timezone_test_1300 ' + value);
expect(value).assertEqual('China Standard Time');
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_TIMEZONE_1400
* @tc.name test getDisplayName with zh-CN and false param
* @tc.desc get the getID value
*/
it('timezone_test_1400', 0, function () {
console.log('timezone_test_1400 ' + 'start');
let timezone = I18n.getTimeZone('Asia/Shanghai');
let value = timezone.getDisplayName('zh-CN', false);
console.log('timezone_test_1400 ' + value);
expect(value).assertEqual('中国标准时间');
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_TIMEZONE_1500
* @tc.name test getRawOffset method with timezone id
* @tc.desc get the getRawOffset value
*/
it('timezone_test_1500', 0, function () {
console.log('timezone_test_1500 ' + 'start');
let timezone = I18n.getTimeZone('ACT');
let value = timezone.getRawOffset();
console.log('timezone_test_1500 ' + value);
expect(value > 0).assertEqual(true);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_TIMEZONE_1600
* @tc.name test getOffset method with timezone id
* @tc.desc get the getOffset value
*/
it('timezone_test_1600', 0, function () {
console.log('timezone_test_1600 ' + 'start');
let timezone = I18n.getTimeZone('ACT');
let value = timezone.getOffset();
console.log('timezone_test_1600 ' + value);
expect(value > 0).assertEqual(true);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_TIMEZONE_1700
* @tc.name test getOffset method with date and timezone id param
* @tc.desc get the getOffset value
*/
it('timezone_test_1700', 0, function () {
console.log('timezone_test_1700 ' + 'start');
let timezone = I18n.getTimeZone('ACT');
let value = timezone.getOffset(10540800000);
console.log('timezone_test_1700 ' + value);
expect(value > 0).assertEqual(true);
})
console.log('*************end LangTest*************');
})
\ No newline at end of file
......@@ -23,6 +23,7 @@ describe('PerfTest', function () {
let EXETIME = 1000;
let initPreferredLang = I18n.getPreferredLanguageList();
let initLen = initPreferredLang.length;
let hour = I18n.is24HourClock();
/* *
* get the current preferred language list
......@@ -66,15 +67,21 @@ describe('PerfTest', function () {
console.log('i18n_test_preferredlanguage_restoreLang ' + I18n.getPreferredLanguageList());
}
/* *
* execute this step before all testcases
*/
beforeAll(function(){
console.log('step before all cases.');
console.log('step before all cases in perf.'
+ ' 24hour: ' + I18n.is24HourClock()
+ ' prelang: ' + I18n.getPreferredLanguageList()
+ ' syslocale: ' + I18n.getSystemLocale());
})
/* *
* execute this step before every testcase
*/
beforeEach(function(){
console.log('step before every case.');
console.log('step before every case in perf.');
console.log('i18n_test_preferredlanguage_beforeEach ' + getCurrentPreferredLang());
})
......@@ -82,15 +89,21 @@ describe('PerfTest', function () {
* execute this step after every testcase
*/
afterEach(function(){
console.log('step after every case.');
console.log('step after every case in perf.');
let currLang = getCurrentPreferredLang();
console.log('i18n_test_preferredlanguage_afterEach ' + currLang);
clearLang(currLang);
restoreLang();
})
/* *
* execute this step after all testcases
*/
afterAll(function(){
console.log('step after all cases.');
console.log('step after all cases in perf.'
+ ' 24hour: ' + I18n.is24HourClock()
+ ' prelang: ' + I18n.getPreferredLanguageList()
+ ' syslocale: ' + I18n.getSystemLocale());
})
/* *
......@@ -100,8 +113,8 @@ describe('PerfTest', function () {
*/
it('perf_test_0100', 0, function () {
console.log('perf_test_0100 ' + 'start');
let startTime = new Date().getTime();
let lang = 'test';
let startTime = new Date().getTime();
for(let i = 0; i < EXETIME; i++){
lang = I18n.getSystemLanguage();
}
......@@ -126,8 +139,8 @@ describe('PerfTest', function () {
*/
it('perf_test_0200', 0, function () {
console.log('perf_test_0200 ' + 'start');
let startTime = new Date().getTime();
let region = 'test';
let startTime = new Date().getTime();
for(let i = 0; i < EXETIME; i++){
region = I18n.getSystemRegion();
}
......@@ -152,8 +165,8 @@ describe('PerfTest', function () {
*/
it('perf_test_0300', 0, function () {
console.log('perf_test_0300 ' + 'start');
let startTime = new Date().getTime();
let locale = 'test';
let startTime = new Date().getTime();
for(let i = 0; i < EXETIME; i++){
locale = I18n.getSystemLocale();
}
......@@ -178,8 +191,8 @@ describe('PerfTest', function () {
*/
it('perf_test_0400', 0, function () {
console.log('perf_test_0400 ' + 'start');
let startTime = new Date().getTime();
let value = false;
let startTime = new Date().getTime();
for(let i = 0; i < EXETIME; i++){
value = I18n.setSystemLanguage('en');
}
......@@ -204,8 +217,8 @@ describe('PerfTest', function () {
*/
it('perf_test_0500', 0, function () {
console.log('perf_test_0500 ' + 'start');
let startTime = new Date().getTime();
let value = false;
let startTime = new Date().getTime();
for(let i = 0; i < EXETIME; i++){
value = I18n.setSystemRegion('US');
}
......@@ -230,8 +243,8 @@ describe('PerfTest', function () {
*/
it('perf_test_0600', 0, function () {
console.log('perf_test_0600 ' + 'start');
let startTime = new Date().getTime();
let value = false;
let startTime = new Date().getTime();
for(let i = 0; i < EXETIME; i++){
value = I18n.setSystemLocale('en-Latn-US');
}
......@@ -256,8 +269,8 @@ describe('PerfTest', function () {
*/
it('perf_test_0700', 0, function () {
console.log('perf_test_0700 ' + 'start');
let startTime = new Date().getTime();
let value = new Array();
let startTime = new Date().getTime();
for(let i = 0; i < EXETIME; i++){
value = I18n.getSystemLanguages();
}
......@@ -282,8 +295,8 @@ describe('PerfTest', function () {
*/
it('perf_test_0800', 0, function () {
console.log('perf_test_0800 ' + 'start');
let startTime = new Date().getTime();
let value = new Array();
let startTime = new Date().getTime();
for(let i = 0; i < EXETIME; i++){
value = I18n.getSystemCountries('en');
}
......@@ -308,8 +321,8 @@ describe('PerfTest', function () {
*/
it('perf_test_0900', 0, function () {
console.log('perf_test_0900 ' + 'start');
let startTime = new Date().getTime();
let value = false;
let startTime = new Date().getTime();
for(let i = 0; i < EXETIME; i++){
value = I18n.isSuggested('en');
}
......@@ -334,8 +347,8 @@ describe('PerfTest', function () {
*/
it('perf_test_1000', 0, function () {
console.log('perf_test_1000 ' + 'start');
let startTime = new Date().getTime();
let value = 'test';
let startTime = new Date().getTime();
for(let i = 0; i < EXETIME; i++){
value = I18n.getDisplayCountry('zh-Hans-CN', 'en-US', true);
}
......@@ -360,8 +373,8 @@ describe('PerfTest', function () {
*/
it('perf_test_1100', 0, function () {
console.log('perf_test_1100 ' + 'start');
let startTime = new Date().getTime();
let value = 'test';
let startTime = new Date().getTime();
for(let i = 0; i < EXETIME; i++){
value = I18n.getDisplayLanguage('zh-Hans-CN', 'en-US', true);
}
......@@ -1517,6 +1530,7 @@ describe('PerfTest', function () {
else{
expect(false).assertTrue();
}
I18n.set24HourClock(hour);
})
/* *
......@@ -2002,7 +2016,7 @@ describe('PerfTest', function () {
/* *
* @tc.number SUB_GLOBAL_PERF_JS_7300
* @tc.name test the performance of Collator.compare
* @tc.name test the performance of Collator.compare with same param
* @tc.desc check the performance of Collator.compare
*/
it('perf_test_7300', 0, function () {
......@@ -2011,7 +2025,7 @@ describe('PerfTest', function () {
let value = 0;
let startTime = new Date().getTime();
for(let i = 0; i < EXETIME; i++){
value = coll.compare('a', 'b');
value = coll.compare('a', 'a');
}
let exeTime = new Date().getTime() - startTime;
let avgTime = exeTime/EXETIME;
......@@ -2185,5 +2199,163 @@ describe('PerfTest', function () {
}
})
/* *
* @tc.number SUB_GLOBAL_PERF_JS_8000
* @tc.name test the performance of getTimeZone
* @tc.desc check the performance of getTimeZone
*/
it('perf_test_8000', 0, function () {
console.log('perf_test_8000 ' + 'start');
let timezone = null;
let startTime = new Date().getTime();
for(let i = 0; i < EXETIME; i++){
timezone = I18n.getTimeZone();
}
let exeTime = new Date().getTime() - startTime;
let avgTime = exeTime/EXETIME;
console.log('perf_test_8000--'
+ ' exeTime: ' + exeTime
+ ' avgTime: ' + avgTime);
if(avgTime < 10){
expect(true).assertTrue();
}
else{
expect(false).assertTrue();
}
})
/* *
* @tc.number SUB_GLOBAL_PERF_JS_8100
* @tc.name test the performance of getTimeZone with zoneID param
* @tc.desc check the performance of getTimeZone
*/
it('perf_test_8100', 0, function () {
console.log('perf_test_8100 ' + 'start');
let timezone = null;
let startTime = new Date().getTime();
for(let i = 0; i < EXETIME; i++){
timezone = I18n.getTimeZone('ACT');
}
let exeTime = new Date().getTime() - startTime;
let avgTime = exeTime/EXETIME;
console.log('perf_test_8100--'
+ ' exeTime: ' + exeTime
+ ' avgTime: ' + avgTime);
if(avgTime < 10){
expect(true).assertTrue();
}
else{
expect(false).assertTrue();
}
})
/* *
* @tc.number SUB_GLOBAL_PERF_JS_8200
* @tc.name test the performance of getID
* @tc.desc check the performance of getID
*/
it('perf_test_8200', 0, function () {
console.log('perf_test_8200 ' + 'start');
let timezone = I18n.getTimeZone('ACT');
let value = 'test';
let startTime = new Date().getTime();
for(let i = 0; i < EXETIME; i++){
value = timezone.getID();
}
let exeTime = new Date().getTime() - startTime;
let avgTime = exeTime/EXETIME;
console.log('perf_test_8200--'
+ 'value: ' + value
+ ' exeTime: ' + exeTime
+ ' avgTime: ' + avgTime);
if(avgTime < 10){
expect(true).assertTrue();
}
else{
expect(false).assertTrue();
}
})
/* *
* @tc.number SUB_GLOBAL_PERF_JS_8300
* @tc.name test the performance of getDisplayName
* @tc.desc check the performance of getDisplayName
*/
it('perf_test_8300', 0, function () {
console.log('perf_test_8300 ' + 'start');
let timezone = I18n.getTimeZone('Asia/Shanghai');
let value = 'test';
let startTime = new Date().getTime();
for(let i = 0; i < EXETIME; i++){
value = timezone.getDisplayName('zh-CN');
}
let exeTime = new Date().getTime() - startTime;
let avgTime = exeTime/EXETIME;
console.log('perf_test_8300--'
+ 'value: ' + value
+ ' exeTime: ' + exeTime
+ ' avgTime: ' + avgTime);
if(avgTime < 10){
expect(true).assertTrue();
}
else{
expect(false).assertTrue();
}
})
/* *
* @tc.number SUB_GLOBAL_PERF_JS_8400
* @tc.name test the performance of getRawOffset
* @tc.desc check the performance of getRawOffset
*/
it('perf_test_8400', 0, function () {
console.log('perf_test_8400 ' + 'start');
let timezone = I18n.getTimeZone('ACT');
let value = 0;
let startTime = new Date().getTime();
for(let i = 0; i < EXETIME; i++){
value = timezone.getRawOffset();
}
let exeTime = new Date().getTime() - startTime;
let avgTime = exeTime/EXETIME;
console.log('perf_test_8400--'
+ 'value: ' + value
+ ' exeTime: ' + exeTime
+ ' avgTime: ' + avgTime);
if(avgTime < 10){
expect(true).assertTrue();
}
else{
expect(false).assertTrue();
}
})
/* *
* @tc.number SUB_GLOBAL_PERF_JS_8500
* @tc.name test the performance of getOffset
* @tc.desc check the performance of getOffset
*/
it('perf_test_8500', 0, function () {
console.log('perf_test_8500 ' + 'start');
let timezone = I18n.getTimeZone('ACT');
let value = 0;
let startTime = new Date().getTime();
for(let i = 0; i < EXETIME; i++){
value = timezone.getOffset();
}
let exeTime = new Date().getTime() - startTime;
let avgTime = exeTime/EXETIME;
console.log('perf_test_8500--'
+ 'value: ' + value
+ ' exeTime: ' + exeTime
+ ' avgTime: ' + avgTime);
if(avgTime < 10){
expect(true).assertTrue();
}
else{
expect(false).assertTrue();
}
})
console.log('*************end PerfTest*************');
})
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册