From 2fbf37becaa402f2c2a74667edb989c2292943e0 Mon Sep 17 00:00:00 2001 From: chengxingzhen Date: Sat, 23 Jul 2022 23:40:36 +0800 Subject: [PATCH] =?UTF-8?q?XTS=E5=85=83=E8=83=BD=E5=8A=9B=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E7=94=A8=E4=BE=8B=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chengxingzhen --- .../test/addContextAndAbilityJsunit.test.ets | 24 ++++++++--------- .../ets/test/getAppVersionInfoJsunit.test.ets | 2 +- .../ets/test/getHapModuleInfoJsunit.test.ets | 8 +++--- .../js/test/DataAbilityHelperJsSt.test.js | 27 +++++-------------- .../entry/src/main/ets/test/LifecycleTest.ets | 12 ++++----- .../entry/src/main/ets/test/LifeCycleTest.ets | 27 ++++++++++--------- 6 files changed, 45 insertions(+), 55 deletions(-) diff --git a/ability/ability_runtime/actsabilitymanageretstest/entry/src/main/ets/test/addContextAndAbilityJsunit.test.ets b/ability/ability_runtime/actsabilitymanageretstest/entry/src/main/ets/test/addContextAndAbilityJsunit.test.ets index 1e6814cc2..0a09b1012 100644 --- a/ability/ability_runtime/actsabilitymanageretstest/entry/src/main/ets/test/addContextAndAbilityJsunit.test.ets +++ b/ability/ability_runtime/actsabilitymanageretstest/entry/src/main/ets/test/addContextAndAbilityJsunit.test.ets @@ -18,18 +18,18 @@ import ability_featureAbility from '@ohos.ability.featureAbility'; import ability_particleAbility from '@ohos.ability.particleAbility'; import abilityManager from "@ohos.application.appManager" -const TAG_TEST_0100 = ' context_isUpdatingConfigurations_test_0100 '; -const TAG_TEST_0200 = ' context_isUpdatingConfigurations_test_0200 '; -const TAG_TEST_0300 = ' context_printDrawnCompleted_test_0100 '; -const TAG_TEST_0400 = ' context_printDrawnCompleted_test_0200 '; -const TAG_TEST_0500 = ' context_getAppMemorySize_test_0100 '; -const TAG_TEST_0600 = ' context_getAppMemorySize_test_0200 '; -const TAG_TEST_0700 = ' context_isRamConstrainedDevice_test_0100 '; -const TAG_TEST_0800 = ' context_isRamConstrainedDevice_test_0200 '; -const TAG_TEST_0900 = ' context_featureAbility_test_0100 '; -const TAG_TEST_0010 = ' context_featureAbility_test_0200 '; -const TAG_TEST_0011 = ' context_featureAbility_test_0300 '; -const TAG_TEST_0012 = ' context_featureAbility_test_0400 '; +const TAG_TEST_0100 = 'context_isUpdatingConfigurations_test_0100'; +const TAG_TEST_0200 = 'context_isUpdatingConfigurations_test_0200'; +const TAG_TEST_0300 = 'context_printDrawnCompleted_test_0100'; +const TAG_TEST_0400 = 'context_printDrawnCompleted_test_0200'; +const TAG_TEST_0500 = 'context_getAppMemorySize_test_0100'; +const TAG_TEST_0600 = 'context_getAppMemorySize_test_0200'; +const TAG_TEST_0700 = 'context_isRamConstrainedDevice_test_0100'; +const TAG_TEST_0800 = 'context_isRamConstrainedDevice_test_0200'; +const TAG_TEST_0900 = 'context_featureAbility_test_0100'; +const TAG_TEST_0010 = 'context_featureAbility_test_0200'; +const TAG_TEST_0011 = 'context_featureAbility_test_0300'; +const TAG_TEST_0012 = 'context_featureAbility_test_0400'; export default function addContextAndAbilityJsunit() { describe('addContextTest', function () { diff --git a/ability/ability_runtime/actsabilitymanageretstest/entry/src/main/ets/test/getAppVersionInfoJsunit.test.ets b/ability/ability_runtime/actsabilitymanageretstest/entry/src/main/ets/test/getAppVersionInfoJsunit.test.ets index 1112edca1..7237c1f97 100644 --- a/ability/ability_runtime/actsabilitymanageretstest/entry/src/main/ets/test/getAppVersionInfoJsunit.test.ets +++ b/ability/ability_runtime/actsabilitymanageretstest/entry/src/main/ets/test/getAppVersionInfoJsunit.test.ets @@ -83,7 +83,7 @@ export default function getHapModuleInfoJsunit() { expect(typeof (data.appName)).assertEqual("string"); expect(typeof (data.versionCode)).assertEqual("number"); expect(typeof (data.versionName)).assertEqual("string"); - expect(data.appName).assertEqual(""); + expect(data.appName).assertEqual("com.ohos.acecollaboration"); expect(data.versionCode).assertEqual(1000000); expect(data.versionName).assertEqual("1.0.0"); console.log(msg + "---checkAppVersionInfo End--- "); diff --git a/ability/ability_runtime/actsabilitymanageretstest/entry/src/main/ets/test/getHapModuleInfoJsunit.test.ets b/ability/ability_runtime/actsabilitymanageretstest/entry/src/main/ets/test/getHapModuleInfoJsunit.test.ets index 3b2e6e7c0..b6b8b2d6b 100644 --- a/ability/ability_runtime/actsabilitymanageretstest/entry/src/main/ets/test/getHapModuleInfoJsunit.test.ets +++ b/ability/ability_runtime/actsabilitymanageretstest/entry/src/main/ets/test/getHapModuleInfoJsunit.test.ets @@ -96,7 +96,7 @@ export default function getHapModuleInfoJsunit() { for (var k = 0; k < data.deviceTypes.length; k++) { console.log(msg + "getHapModuleInfo data.deviceTypes[" + k + "] : " + data.deviceTypes[k]); } - console.log(msg + "checkHapModuleInfo abilityInfos length : " + data.abilityInfos.length); + console.log(msg + "checkHapModuleInfo abilityInfo length : " + data.abilityInfo.length); console.log(msg + "checkHapModuleInfo moduleName : " + data.moduleName); console.log(msg + "checkHapModuleInfo mainAbilityName : " + data.mainAbilityName); console.log(msg + "checkHapModuleInfo installationFree : " + data.installationFree); @@ -112,7 +112,7 @@ export default function getHapModuleInfoJsunit() { expect(typeof (data.supportedModes)).assertEqual("number"); expect(Array.isArray(data.reqCapabilities)).assertEqual(true); expect(Array.isArray(data.deviceTypes)).assertEqual(true); - expect(Array.isArray(data.abilityInfos)).assertEqual(true); + expect(Array.isArray(data.abilityInfo)).assertEqual(true); expect(typeof (data.moduleName)).assertEqual("string"); expect(typeof (data.mainAbilityName)).assertEqual("string"); expect(typeof (data.installationFree)).assertEqual("boolean"); @@ -126,8 +126,8 @@ export default function getHapModuleInfoJsunit() { expect(data.backgroundImg).assertEqual(""); expect(data.supportedModes).assertEqual(0); expect(data.deviceTypes[0]).assertEqual("phone"); - console.info(msg + ' data.abilityInfos.length ' + data.abilityInfos.length) - checkAbilityInfo(msg, data.abilityInfos[0]); + console.info(msg + ' data.abilityInfo.length ' + data.abilityInfo.length) + checkAbilityInfo(msg, data.abilityInfo[0]); expect(data.moduleName).assertEqual("entry") expect(data.mainAbilityName).assertEqual(""); expect(data.installationFree).assertEqual(false); diff --git a/ability/ability_runtime/actsfwkdataaccessortest/actsfwkdataaccessortest/entry/src/main/js/test/DataAbilityHelperJsSt.test.js b/ability/ability_runtime/actsfwkdataaccessortest/actsfwkdataaccessortest/entry/src/main/js/test/DataAbilityHelperJsSt.test.js index e5533cd5e..1bc827d52 100644 --- a/ability/ability_runtime/actsfwkdataaccessortest/actsfwkdataaccessortest/entry/src/main/js/test/DataAbilityHelperJsSt.test.js +++ b/ability/ability_runtime/actsfwkdataaccessortest/actsfwkdataaccessortest/entry/src/main/js/test/DataAbilityHelperJsSt.test.js @@ -5246,7 +5246,8 @@ describe('ActsDataAbilityHelperTest', function () { function onAsyncCallback0401(err) { expect(err.code).assertEqual(0); flagCallback01++; - waitDone("onAsyncCallback0401"); + expect(false).assertTrue(); + done() } function onAsyncCallback0402(err) { flagCallback02++; @@ -5260,28 +5261,14 @@ describe('ActsDataAbilityHelperTest', function () { function onAsyncCallback0403(err) { expect(err.code).assertEqual(0); flagCallback03++; - waitDone("onAsyncCallback0403"); + expect(false).assertTrue(); + done() } function waitDone(caller) { console.debug("=ACTS_OnOff_0400 caller ====>" + caller); - if (flagCallback01 == 1 && flagCallback02 == 0 && flagCallback03 == 1) { - clearTimeout(currentAlertTimeout); - function mySetTimeout() { - DAHelper.off("dataChange", dataAbilityUri, onAsyncCallback0401); - DAHelper.off("dataChange", dataAbilityUri, onAsyncCallback0403); - console.log('ACTS_OnOff_0400==== { - console.debug('ACTS_OnOff_0400====" - + flagCallback01 + flagCallback02 + flagCallback03); + if (flagCallback01 == 0 && flagCallback02 == 0 && flagCallback03 == 0) { + expect("notifyChange").assertEqual(caller); + done() } } try { diff --git a/ability/ability_runtime/stage/actslifecyclemultihaptest/entry/src/main/ets/test/LifecycleTest.ets b/ability/ability_runtime/stage/actslifecyclemultihaptest/entry/src/main/ets/test/LifecycleTest.ets index 55791af62..5bd9e4075 100644 --- a/ability/ability_runtime/stage/actslifecyclemultihaptest/entry/src/main/ets/test/LifecycleTest.ets +++ b/ability/ability_runtime/stage/actslifecyclemultihaptest/entry/src/main/ets/test/LifecycleTest.ets @@ -156,12 +156,12 @@ export default function abilityTest(abilityContext) { } console.log(TAG + "listKeyTemp is :" + listKeyTemp); console.log(TAG + "globalThis.mainAbility4CallBackId is :" + globalThis.mainAbility4CallBackId); - expect(listKeyTemp[0]).assertEqual("Hap2MainAbility4 onAbilityCreate"); - expect(listKeyTemp[1]).assertEqual("Hap2MainAbility4 onAbilityWindowStageCreate"); - expect(listKeyTemp[2]).assertEqual("Hap2MainAbility4 onAbilityForeground"); - expect(listKeyTemp[3]).assertEqual("Hap2MainAbility4 onAbilityBackground"); - expect(listKeyTemp[4]).assertEqual("Hap2MainAbility4 onAbilityWindowStageDestroy"); - expect(listKeyTemp[5]).assertEqual("Hap2MainAbility4 onAbilityDestroy"); + expect(JSON.stringify(listKeyTemp)).assertContain("Hap2MainAbility4 onAbilityCreate"); + expect(JSON.stringify(listKeyTemp)).assertContain("Hap2MainAbility4 onAbilityWindowStageCreate"); + expect(JSON.stringify(listKeyTemp)).assertContain("Hap2MainAbility4 onAbilityForeground"); + expect(JSON.stringify(listKeyTemp)).assertContain("Hap2MainAbility4 onAbilityBackground"); + expect(JSON.stringify(listKeyTemp)).assertContain("Hap2MainAbility4 onAbilityWindowStageDestroy"); + expect(JSON.stringify(listKeyTemp)).assertContain("Hap2MainAbility4 onAbilityDestroy"); globalThis.ApplicationContext4 .unregisterAbilityLifecycleCallback(globalThis.mainAbility4CallBackId, (error, data) => { console.log(TAG + ": unregisterAbilityLifecycleCallback success, err: " + JSON.stringify(error) + diff --git a/ability/ability_runtime/stage/actslifecyclesinglehaptest/entry/src/main/ets/test/LifeCycleTest.ets b/ability/ability_runtime/stage/actslifecyclesinglehaptest/entry/src/main/ets/test/LifeCycleTest.ets index 8c582e798..db1d19c99 100644 --- a/ability/ability_runtime/stage/actslifecyclesinglehaptest/entry/src/main/ets/test/LifeCycleTest.ets +++ b/ability/ability_runtime/stage/actslifecyclesinglehaptest/entry/src/main/ets/test/LifeCycleTest.ets @@ -455,6 +455,7 @@ export default function lifecycleTest(abilityContext) { }).catch((error) => { console.error(TAG + ' start1 failed. Cause: ' + JSON.stringify(error)); }) + await sleep(1000); setTimeout(function () { var str1 = { "bundleName": "com.example.lifecycle_xts", @@ -467,6 +468,7 @@ export default function lifecycleTest(abilityContext) { console.error(TAG + ' start5 failed. Cause: ' + JSON.stringify(error)); }) }, 500); + await sleep(1000); setTimeout(function () { var str2 = { "bundleName": "com.example.lifecycle_xts", @@ -479,6 +481,7 @@ export default function lifecycleTest(abilityContext) { console.error(TAG + ' start2 failed. Cause: ' + JSON.stringify(error)); }) }, 1100); + await sleep(1000); setTimeout(function () { console.log(TAG + " listKey1 : " + JSON.stringify(globalThis.list1)); console.log(TAG + " callbackid1 : " + JSON.stringify(globalThis.callbackid1)); @@ -492,18 +495,18 @@ export default function lifecycleTest(abilityContext) { } console.log(TAG + " listtemp is :" + JSON.stringify(listtemp)); let exlist = listtemp; - expect(exlist[0]).assertEqual("MainAbility5 onAbilityCreate"); - expect(exlist[1]).assertEqual("MainAbility5 onAbilityWindowStageCreate"); - expect(exlist[2]).assertEqual("MainAbility5 onAbilityForeground"); - expect(exlist[3]).assertEqual("MainAbility2 onAbilityCreate"); - expect(exlist[4]).assertEqual("MainAbility2 onAbilityWindowStageCreate"); - expect(exlist[5]).assertEqual("MainAbility2 onAbilityForeground"); - expect(exlist[6]).assertEqual("MainAbility5 onAbilityBackground"); - expect(exlist[7]).assertEqual("MainAbility5 onAbilityWindowStageDestroy"); - expect(exlist[8]).assertEqual("MainAbility5 onAbilityDestroy"); - expect(exlist[9]).assertEqual("MainAbility2 onAbilityBackground"); - expect(exlist[10]).assertEqual("MainAbility2 onAbilityWindowStageDestroy"); - expect(exlist[11]).assertEqual("MainAbility2 onAbilityDestroy"); + expect(JSON.stringify(exlist)).assertContain("MainAbility5 onAbilityCreate"); + expect(JSON.stringify(exlist)).assertContain("MainAbility5 onAbilityWindowStageCreate"); + expect(JSON.stringify(exlist)).assertContain("MainAbility5 onAbilityForeground"); + expect(JSON.stringify(exlist)).assertContain("MainAbility5 onAbilityBackground"); + expect(JSON.stringify(exlist)).assertContain("MainAbility5 onAbilityWindowStageDestroy"); + expect(JSON.stringify(exlist)).assertContain("MainAbility5 onAbilityDestroy"); + expect(JSON.stringify(exlist)).assertContain("MainAbility2 onAbilityCreate"); + expect(JSON.stringify(exlist)).assertContain("MainAbility2 onAbilityWindowStageCreate"); + expect(JSON.stringify(exlist)).assertContain("MainAbility2 onAbilityForeground"); + expect(JSON.stringify(exlist)).assertContain("MainAbility2 onAbilityBackground"); + expect(JSON.stringify(exlist)).assertContain("MainAbility2 onAbilityWindowStageDestroy"); + expect(JSON.stringify(exlist)).assertContain("MainAbility2 onAbilityDestroy"); globalThis.applicationContext1 .unregisterAbilityLifecycleCallback(globalThis.callbackid1, (error, data) => { console.log(TAG + ": unregisterAbilityLifecycleCallback success, err: " + JSON.stringify(error) + -- GitLab