From 6b844dd219f5ae5f615a895036ecd2469a2083c5 Mon Sep 17 00:00:00 2001 From: y00314596 Date: Fri, 11 Mar 2022 16:42:58 +0800 Subject: [PATCH] add by yangqing3@huawei.com Signed-off-by: y00314596 --- .../src/main/js/default/test/Lang.test.js | 2 +- .../src/main/js/default/test/Perf.test.js | 55 +++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) 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 f124c9fd4..d1aeca47c 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 @@ -81,6 +81,7 @@ describe('LangTest', function () { * execute this step before every testcase */ beforeEach(function(){ + I18n.set24HourClock(false); console.log('i18n_test_preferredlanguage_beforeEach ' + getCurrentPreferredLang()); }) @@ -92,7 +93,6 @@ describe('LangTest', function () { console.log('i18n_test_preferredlanguage_afterEach ' + currLang); clearLang(currLang); restoreLang(); - I18n.set24HourClock(false); }) /* * 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 04df5b7de..f5db7215c 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 @@ -21,17 +21,72 @@ describe('PerfTest', function () { console.log('*************start PerfTest*************'); let EXETIME = 1000; + let initPreferredLang = I18n.getPreferredLanguageList(); + let initLen = initPreferredLang.length; + + /* * + * get the current preferred language list + */ + function getCurrentPreferredLang(){ + let value = I18n.getPreferredLanguageList(); + return value; + } + + /* * + * clear the preferred language list if exists + */ + function clearLang(langList){ + let len = langList.length; + while(len > 0){ + console.log('i18n_test_preferredlanguage_clearLang ' + len); + let par = len - 1; + console.log('i18n_test_preferredlanguage_clearLang ' + par); + let value = I18n.removePreferredLanguage(par); + console.log('i18n_test_preferredlanguage_clearLang ' + value); + len--; + } + console.log('i18n_test_preferredlanguage_clearLang ' + I18n.getPreferredLanguageList()); + } + + /* * + * execute this step after every testcase + */ + function restoreLang(){ + for(let j = 0; j < initLen; j++){ + let value = I18n.addPreferredLanguage(initPreferredLang[j], j); + console.log('i18n_test_preferredlanguage_restoreLang ' + value); + expect(value).assertTrue(); + } + let currLen = getCurrentPreferredLang().length; + while(currLen > initLen) { + let rem = I18n.removePreferredLanguage(currLen - 1); + console.log('i18n_test_preferredlanguage_restoreLang ' + rem); + currLen--; + } + console.log('i18n_test_preferredlanguage_restoreLang ' + I18n.getPreferredLanguageList()); + } beforeAll(function(){ console.log('step before all cases.'); }) + /* * + * execute this step before every testcase + */ beforeEach(function(){ console.log('step before every case.'); + console.log('i18n_test_preferredlanguage_beforeEach ' + getCurrentPreferredLang()); }) + /* * + * execute this step after every testcase + */ afterEach(function(){ console.log('step after every case.'); + let currLang = getCurrentPreferredLang(); + console.log('i18n_test_preferredlanguage_afterEach ' + currLang); + clearLang(currLang); + restoreLang(); }) afterAll(function(){ -- GitLab