diff --git a/global/i18n_standard/intljs/src/main/js/default/test/Lang.test.js b/global/i18n_standard/intljs/src/main/js/default/test/Lang.test.js index c6188d0fc2902744e12c48494e3cdb14a36771b5..f124c9fd49dde49081aee6b52d2a6674b819de12 100755 --- a/global/i18n_standard/intljs/src/main/js/default/test/Lang.test.js +++ b/global/i18n_standard/intljs/src/main/js/default/test/Lang.test.js @@ -203,12 +203,19 @@ describe('LangTest', function () { */ it('i18n_test_preferredlanguage_0300', 0, function () { console.log('i18n_test_preferredlanguage_0300 ' + 'start'); - let value = I18n.addPreferredLanguage('en', 0); - console.log('i18n_test_preferredlanguage_0300 ' + value); - expect(value).assertTrue(); let list = I18n.getPreferredLanguageList(); console.log('i18n_test_preferredlanguage_0300 ' + list); expect(list.length).assertLarger(0); + if(list[0] != 'en'){ + let value = I18n.addPreferredLanguage('en', 0); + console.log('i18n_test_preferredlanguage_0300 ' + value); + expect(value).assertTrue(); + } + else{ + let value = I18n.addPreferredLanguage('zh', 0); + console.log('i18n_test_preferredlanguage_0300 ' + value); + expect(value).assertTrue(); + } }) /* * @@ -233,12 +240,19 @@ describe('LangTest', function () { */ it('i18n_test_preferredlanguage_0340', 0, function () { console.log('i18n_test_preferredlanguage_0340 ' + 'start'); - let value = I18n.addPreferredLanguage('en', 1.5); - console.log('i18n_test_preferredlanguage_0340 ' + value); - expect(value).assertTrue(); let list = I18n.getPreferredLanguageList(); console.log('i18n_test_preferredlanguage_0340 ' + list); expect(list.length).assertLarger(0); + if(list[0] != 'en'){ + let value = I18n.addPreferredLanguage('en', 1.5); + console.log('i18n_test_preferredlanguage_0340 ' + value); + expect(value).assertTrue(); + } + else{ + let value = I18n.addPreferredLanguage('zh', 1); + console.log('i18n_test_preferredlanguage_0340 ' + value); + expect(value).assertTrue(); + } }) /* * @@ -248,12 +262,19 @@ describe('LangTest', function () { */ it('i18n_test_preferredlanguage_0400', 0, function () { console.log('i18n_test_preferredlanguage_0400 ' + 'start'); - let value = I18n.addPreferredLanguage('en', 1); - console.log('i18n_test_preferredlanguage_0400 ' + value); - expect(value).assertTrue(); let list = I18n.getPreferredLanguageList(); console.log('i18n_test_preferredlanguage_0400 ' + list); expect(list.length).assertLarger(0); + if(list[0] != 'en'){ + let value = I18n.addPreferredLanguage('en', 1); + console.log('i18n_test_preferredlanguage_0400 ' + value); + expect(value).assertTrue(); + } + else{ + let value = I18n.addPreferredLanguage('zh', 1); + console.log('i18n_test_preferredlanguage_0400 ' + value); + expect(value).assertTrue(); + } }) /* * @@ -397,13 +418,14 @@ describe('LangTest', function () { * @tc.desc check the value of preferredLanguage method */ it('i18n_test_preferredlanguage_0940', 0, function () { + console.log('i18n_test_preferredlanguage_0940 ' + 'start'); let value = I18n.addPreferredLanguage('it'); console.log('i18n_test_preferredlanguage_0940 ' + value); expect(value).assertTrue(); let value2 = I18n.addPreferredLanguage('ko'); console.log('i18n_test_preferredlanguage_0940 ' + value2); expect(value2).assertTrue(); - let value3 = I18n.addPreferredLanguage('en'); + let value3 = I18n.addPreferredLanguage('th'); console.log('i18n_test_preferredlanguage_0940 ' + value3); expect(value3).assertTrue(); let list1 = I18n.getPreferredLanguageList(); @@ -414,12 +436,12 @@ describe('LangTest', function () { let value5 = I18n.addPreferredLanguage('ko', 2); console.log('i18n_test_preferredlanguage_0940 ' + value5); expect(value5).assertTrue(); - let value6 = I18n.addPreferredLanguage('en', 1); + let value6 = I18n.addPreferredLanguage('th', 1); console.log('i18n_test_preferredlanguage_0940 ' + value6); expect(value6).assertFalse(); let list2 = I18n.getPreferredLanguageList(); console.log('i18n_test_preferredlanguage_0940 ' + list2); - expect(list2[1]).assertEqual('en'); + expect(list2[1]).assertEqual('th'); expect(list2[2]).assertEqual('ko'); expect(list2[3]).assertEqual('it'); let remove1 = I18n.removePreferredLanguage(1); @@ -446,10 +468,15 @@ describe('LangTest', function () { console.log('i18n_test_preferredlanguage_1000 ' + 'start'); let value = I18n.getFirstPreferredLanguage(); console.log('i18n_test_preferredlanguage_1000 ' + value); - expect(value).assertEqual('zh-Hans'); let list = I18n.getPreferredLanguageList(); console.log('i18n_test_preferredlanguage_1000 ' + 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'); + } }) /* * diff --git a/global/perf/perfjs/src/main/js/default/test/Perf.test.js b/global/perf/perfjs/src/main/js/default/test/Perf.test.js index d57ffeffa31bde725d50ac6c83ea5d495f2114f2..3499ced83714586725b519347fac9fd7dc7bb924 100755 --- a/global/perf/perfjs/src/main/js/default/test/Perf.test.js +++ b/global/perf/perfjs/src/main/js/default/test/Perf.test.js @@ -1017,5 +1017,400 @@ describe('PerfTest', function () { } }) + /* * + * @tc.number SUB_GLOBAL_PERF_JS_3800 + * @tc.name test the performance of getLineBreakText + * @tc.desc check the performance of getLineBreakText + */ + it('perf_test_3800', 0, function () { + console.log('perf_test_3800 ' + 'start'); + let iterator =I18n.getLineInstance('en'); + iterator.setLineBreakText('My name is Tom.Welcome to the sky world.'); + let value = 'test'; + let startTime = new Date().getTime(); + for(let i = 0; i < EXETIME; i++){ + value = iterator.getLineBreakText(); + } + let exeTime = new Date().getTime() - startTime; + let avgTime = exeTime/EXETIME; + console.log('perf_test_3800--' + + 'value: ' + value + + ' exeTime: ' + exeTime + + ' avgTime: ' + avgTime); + if(avgTime < 10){ + expect(true).assertTrue(); + } + else{ + expect(false).assertTrue(); + } + }) + + /* * + * @tc.number SUB_GLOBAL_PERF_JS_3900 + * @tc.name test the performance of isBoundary + * @tc.desc check the performance of isBoundary + */ + it('perf_test_3900', 0, function () { + console.log('perf_test_3900 ' + 'start'); + let iterator =I18n.getLineInstance('en'); + iterator.setLineBreakText('My name is Tom.Welcome to the sky world.'); + let value = false; + let startTime = new Date().getTime(); + for(let i = 0; i < EXETIME; i++){ + value = iterator.isBoundary(10); + } + let exeTime = new Date().getTime() - startTime; + let avgTime = exeTime/EXETIME; + console.log('perf_test_3900--' + + 'value: ' + value + + ' exeTime: ' + exeTime + + ' avgTime: ' + avgTime); + if(avgTime < 10){ + expect(true).assertTrue(); + } + else{ + expect(false).assertTrue(); + } + }) + + /* * + * @tc.number SUB_GLOBAL_PERF_JS_4000 + * @tc.name test the performance of getInstance + * @tc.desc check the performance of getInstance + */ + it('perf_test_4000', 0, function () { + console.log('perf_test_4000 ' + 'start'); + let index = null; + let startTime = new Date().getTime(); + for(let i = 0; i < EXETIME; i++){ + index = I18n.getInstance(); + } + let exeTime = new Date().getTime() - startTime; + let avgTime = exeTime/EXETIME; + console.log('perf_test_4000--' + + ' exeTime: ' + exeTime + + ' avgTime: ' + avgTime); + if(avgTime < 10){ + expect(true).assertTrue(); + } + else{ + expect(false).assertTrue(); + } + }) + + /* * + * @tc.number SUB_GLOBAL_PERF_JS_4100 + * @tc.name test the performance of getIndex + * @tc.desc check the performance of getIndex + */ + it('perf_test_4100', 0, function () { + console.log('perf_test_4100 ' + 'start'); + let index = I18n.getInstance(); + let value = 'test'; + let startTime = new Date().getTime(); + for(let i = 0; i < EXETIME; i++){ + value = index.getIndex('a'); + } + let exeTime = new Date().getTime() - startTime; + let avgTime = exeTime/EXETIME; + console.log('perf_test_4100--' + + 'value: ' + value + + ' exeTime: ' + exeTime + + ' avgTime: ' + avgTime); + if(avgTime < 10){ + expect(true).assertTrue(); + } + else{ + expect(false).assertTrue(); + } + }) + + /* * + * @tc.number SUB_GLOBAL_PERF_JS_4200 + * @tc.name test the performance of getIndexList + * @tc.desc check the performance of getIndexList + */ + it('perf_test_4200', 0, function () { + console.log('perf_test_4200 ' + 'start'); + let index = I18n.getInstance(); + let value = new Array(); + let startTime = new Date().getTime(); + for(let i = 0; i < EXETIME; i++){ + value = index.getIndexList(); + } + let exeTime = new Date().getTime() - startTime; + let avgTime = exeTime/EXETIME; + console.log('perf_test_4200--' + + 'value: ' + value + + ' exeTime: ' + exeTime + + ' avgTime: ' + avgTime); + if(avgTime < 10){ + expect(true).assertTrue(); + } + else{ + expect(false).assertTrue(); + } + }) + + /* * + * @tc.number SUB_GLOBAL_PERF_JS_4300 + * @tc.name test the performance of addLocale + * @tc.desc check the performance of addLocale + */ + it('perf_test_4300', 0, function () { + console.log('perf_test_4300 ' + 'start'); + let index = I18n.getInstance(); + let startTime = new Date().getTime(); + for(let i = 0; i < EXETIME; i++){ + index.addLocale('en'); + } + let exeTime = new Date().getTime() - startTime; + let avgTime = exeTime/EXETIME; + console.log('perf_test_4300--' + + ' exeTime: ' + exeTime + + ' avgTime: ' + avgTime); + if(avgTime < 10){ + expect(true).assertTrue(); + } + else{ + expect(false).assertTrue(); + } + }) + + /* * + * @tc.number SUB_GLOBAL_PERF_JS_4400 + * @tc.name test the performance of isDigit + * @tc.desc check the performance of isDigit + */ + it('perf_test_4400', 0, function () { + console.log('perf_test_4400 ' + 'start'); + let value = false; + let startTime = new Date().getTime(); + for(let i = 0; i < EXETIME; i++){ + value = I18n.Character.isDigit('abc'); + } + let exeTime = new Date().getTime() - startTime; + let avgTime = exeTime/EXETIME; + console.log('perf_test_4400--' + + 'value: ' + value + + ' exeTime: ' + exeTime + + ' avgTime: ' + avgTime); + if(avgTime < 10){ + expect(true).assertTrue(); + } + else{ + expect(false).assertTrue(); + } + }) + + /* * + * @tc.number SUB_GLOBAL_PERF_JS_4500 + * @tc.name test the performance of isSpaceChar + * @tc.desc check the performance of isSpaceChar + */ + it('perf_test_4500', 0, function () { + console.log('perf_test_4500 ' + 'start'); + let value = false; + let startTime = new Date().getTime(); + for(let i = 0; i < EXETIME; i++){ + value = I18n.Character.isSpaceChar('abc'); + } + let exeTime = new Date().getTime() - startTime; + let avgTime = exeTime/EXETIME; + console.log('perf_test_4500--' + + 'value: ' + value + + ' exeTime: ' + exeTime + + ' avgTime: ' + avgTime); + if(avgTime < 10){ + expect(true).assertTrue(); + } + else{ + expect(false).assertTrue(); + } + }) + + + /* * + * @tc.number SUB_GLOBAL_PERF_JS_4600 + * @tc.name test the performance of isWhitespace + * @tc.desc check the performance of isWhitespace + */ + it('perf_test_4600', 0, function () { + console.log('perf_test_4600 ' + 'start'); + let value = false; + let startTime = new Date().getTime(); + for(let i = 0; i < EXETIME; i++){ + value = I18n.Character.isWhitespace('abc'); + } + let exeTime = new Date().getTime() - startTime; + let avgTime = exeTime/EXETIME; + console.log('perf_test_4600--' + + 'value: ' + value + + ' exeTime: ' + exeTime + + ' avgTime: ' + avgTime); + if(avgTime < 10){ + expect(true).assertTrue(); + } + else{ + expect(false).assertTrue(); + } + }) + + /* * + * @tc.number SUB_GLOBAL_PERF_JS_4700 + * @tc.name test the performance of isRTL + * @tc.desc check the performance of isRTL + */ + it('perf_test_4700', 0, function () { + console.log('perf_test_4700 ' + 'start'); + let value = false; + let startTime = new Date().getTime(); + for(let i = 0; i < EXETIME; i++){ + value = I18n.Character.isRTL('abc'); + } + let exeTime = new Date().getTime() - startTime; + let avgTime = exeTime/EXETIME; + console.log('perf_test_4700--' + + 'value: ' + value + + ' exeTime: ' + exeTime + + ' avgTime: ' + avgTime); + if(avgTime < 10){ + expect(true).assertTrue(); + } + else{ + expect(false).assertTrue(); + } + }) + + /* * + * @tc.number SUB_GLOBAL_PERF_JS_4800 + * @tc.name test the performance of isIdeograph + * @tc.desc check the performance of isIdeograph + */ + it('perf_test_4800', 0, function () { + console.log('perf_test_4800 ' + 'start'); + let value = false; + let startTime = new Date().getTime(); + for(let i = 0; i < EXETIME; i++){ + value = I18n.Character.isIdeograph('abc'); + } + let exeTime = new Date().getTime() - startTime; + let avgTime = exeTime/EXETIME; + console.log('perf_test_4800--' + + 'value: ' + value + + ' exeTime: ' + exeTime + + ' avgTime: ' + avgTime); + if(avgTime < 10){ + expect(true).assertTrue(); + } + else{ + expect(false).assertTrue(); + } + }) + + /* * + * @tc.number SUB_GLOBAL_PERF_JS_4900 + * @tc.name test the performance of isLetter + * @tc.desc check the performance of isLetter + */ + it('perf_test_4900', 0, function () { + console.log('perf_test_4900 ' + 'start'); + let value = false; + let startTime = new Date().getTime(); + for(let i = 0; i < EXETIME; i++){ + value = I18n.Character.isLetter('abc'); + } + let exeTime = new Date().getTime() - startTime; + let avgTime = exeTime/EXETIME; + console.log('perf_test_4900--' + + 'value: ' + value + + ' exeTime: ' + exeTime + + ' avgTime: ' + avgTime); + if(avgTime < 10){ + expect(true).assertTrue(); + } + else{ + expect(false).assertTrue(); + } + }) + + /* * + * @tc.number SUB_GLOBAL_PERF_JS_5000 + * @tc.name test the performance of isLowerCase + * @tc.desc check the performance of isLowerCase + */ + it('perf_test_5000', 0, function () { + console.log('perf_test_5000 ' + 'start'); + let value = false; + let startTime = new Date().getTime(); + for(let i = 0; i < EXETIME; i++){ + value = I18n.Character.isLowerCase('abc'); + } + let exeTime = new Date().getTime() - startTime; + let avgTime = exeTime/EXETIME; + console.log('perf_test_5000--' + + 'value: ' + value + + ' exeTime: ' + exeTime + + ' avgTime: ' + avgTime); + if(avgTime < 10){ + expect(true).assertTrue(); + } + else{ + expect(false).assertTrue(); + } + }) + + /* * + * @tc.number SUB_GLOBAL_PERF_JS_5100 + * @tc.name test the performance of isUpperCase + * @tc.desc check the performance of isUpperCase + */ + it('perf_test_5100', 0, function () { + console.log('perf_test_5100 ' + 'start'); + let value = false; + let startTime = new Date().getTime(); + for(let i = 0; i < EXETIME; i++){ + value = I18n.Character.isUpperCase('ABC'); + } + let exeTime = new Date().getTime() - startTime; + let avgTime = exeTime/EXETIME; + console.log('perf_test_5100--' + + 'value: ' + value + + ' exeTime: ' + exeTime + + ' avgTime: ' + avgTime); + if(avgTime < 10){ + expect(true).assertTrue(); + } + else{ + expect(false).assertTrue(); + } + }) + + /* * + * @tc.number SUB_GLOBAL_PERF_JS_5200 + * @tc.name test the performance of getType + * @tc.desc check the performance of getType + */ + it('perf_test_5200', 0, function () { + console.log('perf_test_5200 ' + 'start'); + let value = 'test'; + let startTime = new Date().getTime(); + for(let i = 0; i < EXETIME; i++){ + value = I18n.Character.getType('a'); + } + let exeTime = new Date().getTime() - startTime; + let avgTime = exeTime/EXETIME; + console.log('perf_test_5200--' + + '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