From e7793130d7217e3cae7e0759e29b1d1067a2e474 Mon Sep 17 00:00:00 2001 From: zhoujun62 Date: Thu, 25 Aug 2022 10:43:11 +0800 Subject: [PATCH] solve stage life cycle problem Signed-off-by: zhoujun62 --- .../entry/src/main/ets/test/LifecycleTest.ets | 146 ++++++++------ .../entry/src/main/ets/test/LifeCycleTest.ets | 182 +++++++++--------- 2 files changed, 171 insertions(+), 157 deletions(-) diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/test/LifecycleTest.ets b/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/test/LifecycleTest.ets index aa6ef64d5..f235c47d5 100755 --- a/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/test/LifecycleTest.ets +++ b/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/test/LifecycleTest.ets @@ -66,6 +66,7 @@ export default function abilityTest() { console.info("---------------Multihap_WindowStageLifecycleTest_001 is start---------------") TAG = "Multihap_WindowStageLifecycleTest_001"; listKeyTemp = []; + var transferStr0 = ""; globalThis.abilityContext.startAbility({ bundleName: "com.example.lifecycletest", @@ -87,14 +88,15 @@ export default function abilityTest() { for (var i = 0;i < globalThis.mainAbility4ListKey.length; i++) { if (globalThis.mainAbility4ListKey[i].substring(0, 16) == "Hap2MainAbility3") { listKeyTemp.push(globalThis.mainAbility4ListKey[i]); + transferStr0 += globalThis.mainAbility4ListKey[i]; } } console.log(TAG + "listKeyTemp is :" + listKeyTemp); console.log(TAG + "globalThis.mainAbility4CallBackId is :" + globalThis.mainAbility4CallBackId); - expect(listKeyTemp[0]).assertEqual("Hap2MainAbility3 onWindowStageCreate"); - expect(listKeyTemp[1]).assertEqual("Hap2MainAbility3 onWindowStageActive"); - expect(listKeyTemp[2]).assertEqual("Hap2MainAbility3 onWindowStageInactive"); - expect(listKeyTemp[3]).assertEqual("Hap2MainAbility3 onWindowStageDestroy"); + expect(transferStr0.indexOf("Hap2MainAbility3 onWindowStageCreate")!=-1).assertTrue(); + expect(transferStr0.indexOf("Hap2MainAbility3 onWindowStageActive")!=-1).assertTrue(); + expect(transferStr0.indexOf("Hap2MainAbility3 onWindowStageInactive")!=-1).assertTrue(); + expect(transferStr0.indexOf("Hap2MainAbility3 onWindowStageDestroy")!=-1).assertTrue(); console.info(TAG + "globalThis.ApplicationContext4 is :" + JSON.stringify(globalThis.ApplicationContext4)); globalThis.ApplicationContext4 .unregisterAbilityLifecycleCallback(globalThis.mainAbility4CallBackId, (error, data) => { @@ -118,6 +120,7 @@ export default function abilityTest() { console.log("------------Multihap_WindowStageLifecycleTest_002 start-------------"); TAG = "Multihap_WindowStageLifecycleTest_002"; listKeyTemp = []; + var transferStr0 = ""; globalThis.abilityContext.startAbility({ bundleName: "com.example.lifecycletest", @@ -149,14 +152,15 @@ export default function abilityTest() { for (var i = 0; i < globalThis.mainAbility4ListKey.length; i++) { if (globalThis.mainAbility4ListKey[i].substring(0, 16) == "Hap2MainAbility4") { listKeyTemp.push(globalThis.mainAbility4ListKey[i]); + transferStr0 += globalThis.mainAbility4ListKey[i]; } } console.log(TAG + "listKeyTemp is :" + listKeyTemp); console.log(TAG + "globalThis.mainAbility4CallBackId is :" + globalThis.mainAbility4CallBackId); - expect(listKeyTemp[0]).assertEqual("Hap2MainAbility4 onWindowStageCreate"); - expect(listKeyTemp[1]).assertEqual("Hap2MainAbility4 onWindowStageActive"); - expect(listKeyTemp[2]).assertEqual("Hap2MainAbility4 onWindowStageInactive"); - expect(listKeyTemp[3]).assertEqual("Hap2MainAbility4 onWindowStageDestroy"); + expect(transferStr0.indexOf("Hap2MainAbility4 onWindowStageCreate")!=-1).assertTrue(); + expect(transferStr0.indexOf("Hap2MainAbility4 onWindowStageActive")!=-1).assertTrue(); + expect(transferStr0.indexOf("Hap2MainAbility4 onWindowStageInactive")!=-1).assertTrue(); + expect(transferStr0.indexOf("Hap2MainAbility4 onWindowStageDestroy")!=-1).assertTrue(); globalThis.ApplicationContext4 .unregisterAbilityLifecycleCallback(globalThis.mainAbility4CallBackId, (error, data) => { console.log(TAG + ": unregisterAbilityLifecycleCallback success, err: " + JSON.stringify(error) + @@ -179,6 +183,7 @@ export default function abilityTest() { console.log("------------Multihap_WindowStageLifecycleTest_003 start-------------"); TAG = "Multihap_WindowStageLifecycleTest_003"; listKeyTemp = []; + var transferStr0 = ""; globalThis.abilityContext.startAbility({ bundleName: "com.example.lifecycletest", @@ -210,19 +215,19 @@ export default function abilityTest() { for (var i = 0;i < globalThis.mainAbility4ListKey.length; i++) { if (globalThis.mainAbility4ListKey[i].substring(0, 16) == "Hap2MainAbility5") { listKeyTemp.push(globalThis.mainAbility4ListKey[i]); + transferStr0 += globalThis.mainAbility4ListKey[i]; } } console.log(TAG + "listKeyTemp is :" + listKeyTemp); console.log(TAG + "globalThis.mainAbility4CallBackId is :" + globalThis.mainAbility4CallBackId); - expect(listKeyTemp[0]).assertEqual("Hap2MainAbility5 onWindowStageCreate"); - expect(listKeyTemp[1]).assertEqual("Hap2MainAbility5 onWindowStageActive"); - expect(listKeyTemp[2]).assertEqual("Hap2MainAbility5 onWindowStageCreate"); - var transferStr0 = listKeyTemp[3] + listKeyTemp[4]; + expect(transferStr0.indexOf("Hap2MainAbility5 onWindowStageCreate")!=-1).assertTrue(); expect(transferStr0.indexOf("Hap2MainAbility5 onWindowStageActive")!=-1).assertTrue(); + expect(transferStr0.indexOf("Hap2MainAbility5 onWindowStageCreate")!=-1).assertTrue(); + expect(transferStr0.indexOf("Hap2MainAbility5 onWindowStageActive")!=-1).assertTrue(); + expect(transferStr0.indexOf("Hap2MainAbility5 onWindowStageInactive")!=-1).assertTrue(); + expect(transferStr0.indexOf("Hap2MainAbility5 onWindowStageDestroy")!=-1).assertTrue(); expect(transferStr0.indexOf("Hap2MainAbility5 onWindowStageInactive")!=-1).assertTrue(); - expect(listKeyTemp[5]).assertEqual("Hap2MainAbility5 onWindowStageDestroy"); - expect(listKeyTemp[6]).assertEqual("Hap2MainAbility5 onWindowStageInactive"); - expect(listKeyTemp[7]).assertEqual("Hap2MainAbility5 onWindowStageDestroy"); + expect(transferStr0.indexOf("Hap2MainAbility5 onWindowStageDestroy")!=-1).assertTrue(); globalThis.ApplicationContext4 .unregisterAbilityLifecycleCallback(globalThis.mainAbility4CallBackId, (error, data) => { console.log(TAG + ": unregisterAbilityLifecycleCallback success, err: " + JSON.stringify(error) + @@ -246,6 +251,8 @@ export default function abilityTest() { TAG = "Multihap_WindowStageLifecycleTest_004"; listKeyTemp = []; listKeyTemp1 = []; + var transferStr0 = ""; + var transferStr1 = ""; globalThis.abilityContext.startAbility({ bundleName: "com.example.lifecycletest", @@ -277,23 +284,24 @@ export default function abilityTest() { for (var i = 0;i < globalThis.mainAbility4ListKey.length; i++) { if (globalThis.mainAbility4ListKey[i].substring(0, 16) == "Hap2MainAbility6") { listKeyTemp.push(globalThis.mainAbility4ListKey[i]); + transferStr0 += globalThis.mainAbility4ListKey[i]; } else if (globalThis.mainAbility4ListKey[i].substring(0, 16) == "Hap3MainAbility2") { listKeyTemp1.push(globalThis.mainAbility4ListKey[i]); + transferStr1 += globalThis.mainAbility4ListKey[i]; } } console.log(TAG + "listKeyTemp is :" + listKeyTemp); console.log(TAG + "listKeyTemp1 is :" + listKeyTemp1); console.log(TAG + "globalThis.mainAbility4CallBackId is :" + globalThis.mainAbility4CallBackId); - expect(listKeyTemp[0]).assertEqual("Hap2MainAbility6 onWindowStageCreate"); - expect(listKeyTemp[1]).assertEqual("Hap2MainAbility6 onWindowStageActive"); - expect(listKeyTemp[2]).assertEqual("Hap2MainAbility6 onWindowStageInactive"); - expect(listKeyTemp[3]).assertEqual("Hap2MainAbility6 onWindowStageDestroy"); - - expect(listKeyTemp1[0]).assertEqual("Hap3MainAbility2 onWindowStageCreate"); - expect(listKeyTemp1[1]).assertEqual("Hap3MainAbility2 onWindowStageActive"); - expect(listKeyTemp1[2]).assertEqual("Hap3MainAbility2 onWindowStageInactive"); - expect(listKeyTemp1[3]).assertEqual("Hap3MainAbility2 onWindowStageDestroy"); - + expect(transferStr0.indexOf("Hap2MainAbility6 onWindowStageCreate")!=-1).assertTrue(); + expect(transferStr0.indexOf("Hap2MainAbility6 onWindowStageActive")!=-1).assertTrue(); + expect(transferStr0.indexOf("Hap2MainAbility6 onWindowStageInactive")!=-1).assertTrue(); + expect(transferStr0.indexOf("Hap2MainAbility6 onWindowStageDestroy")!=-1).assertTrue(); + + expect(transferStr1.indexOf("Hap3MainAbility2 onWindowStageCreate")!=-1).assertTrue(); + expect(transferStr1.indexOf("Hap3MainAbility2 onWindowStageActive")!=-1).assertTrue(); + expect(transferStr1.indexOf("Hap3MainAbility2 onWindowStageInactive")!=-1).assertTrue(); + expect(transferStr1.indexOf("Hap3MainAbility2 onWindowStageDestroy")!=-1).assertTrue(); globalThis.ApplicationContext4 .unregisterAbilityLifecycleCallback(globalThis.mainAbility4CallBackId, (error, data) => { console.log(TAG + ": unregisterAbilityLifecycleCallback success, err: " + JSON.stringify(error) + @@ -317,6 +325,8 @@ export default function abilityTest() { TAG = "Multihap_WindowStageLifecycleTest_005"; listKeyTemp = []; listKeyTemp1 = []; + var transferStr0 = ""; + var transferStr1 = ""; globalThis.abilityContext.startAbility({ bundleName: "com.example.lifecycletest", @@ -348,22 +358,24 @@ export default function abilityTest() { for (var i = 0;i < globalThis.mainAbility4ListKey.length; i++) { if (globalThis.mainAbility4ListKey[i].substring(0, 16) == "Hap2MainAbility6") { listKeyTemp.push(globalThis.mainAbility4ListKey[i]); + transferStr0 += globalThis.mainAbility4ListKey[i]; } else if (globalThis.mainAbility4ListKey[i].substring(0, 16) == "Hap2MainAbility7") { listKeyTemp1.push(globalThis.mainAbility4ListKey[i]); + transferStr1 += globalThis.mainAbility4ListKey[i]; } } console.log(TAG + "listKeyTemp is :" + listKeyTemp); console.log(TAG + "listKeyTemp1 is :" + listKeyTemp1); console.log(TAG + "globalThis.mainAbility4CallBackId is :" + globalThis.mainAbility4CallBackId); - expect(listKeyTemp[0]).assertEqual("Hap2MainAbility6 onWindowStageCreate"); - expect(listKeyTemp[1]).assertEqual("Hap2MainAbility6 onWindowStageActive"); - expect(listKeyTemp[2]).assertEqual("Hap2MainAbility6 onWindowStageInactive"); - expect(listKeyTemp[3]).assertEqual("Hap2MainAbility6 onWindowStageDestroy"); + expect(transferStr0.indexOf("Hap2MainAbility6 onWindowStageCreate")!=-1).assertTrue(); + expect(transferStr0.indexOf("Hap2MainAbility6 onWindowStageActive")!=-1).assertTrue(); + expect(transferStr0.indexOf("Hap2MainAbility6 onWindowStageInactive")!=-1).assertTrue(); + expect(transferStr0.indexOf("Hap2MainAbility6 onWindowStageDestroy")!=-1).assertTrue(); - expect(listKeyTemp1[0]).assertEqual("Hap2MainAbility7 onWindowStageCreate"); - expect(listKeyTemp1[1]).assertEqual("Hap2MainAbility7 onWindowStageActive"); - expect(listKeyTemp1[2]).assertEqual("Hap2MainAbility7 onWindowStageInactive"); - expect(listKeyTemp1[3]).assertEqual("Hap2MainAbility7 onWindowStageDestroy"); + expect(transferStr1.indexOf("Hap2MainAbility7 onWindowStageCreate")!=-1).assertTrue(); + expect(transferStr1.indexOf("Hap2MainAbility7 onWindowStageActive")!=-1).assertTrue(); + expect(transferStr1.indexOf("Hap2MainAbility7 onWindowStageInactive")!=-1).assertTrue(); + expect(transferStr1.indexOf("Hap2MainAbility7 onWindowStageDestroy")!=-1).assertTrue(); globalThis.ApplicationContext4 .unregisterAbilityLifecycleCallback(globalThis.mainAbility4CallBackId, (error, data) => { @@ -470,6 +482,8 @@ export default function abilityTest() { TAG = "Multihap_WindowStageLifecycleTest_007"; listKeyTemp = []; listKeyTemp1 = []; + var transferStr0 = ""; + var transferStr1 = ""; var callBackId1; var callBackId2; var flag; @@ -494,17 +508,17 @@ export default function abilityTest() { for (var i = 0;i < globalThis.mainAbility6ListKey.length; i++) { if (globalThis.mainAbility6ListKey[i].substring(0, 16) == "Hap2MainAbility9") { listKeyTemp.push(globalThis.mainAbility6ListKey[i]); + transferStr0 += globalThis.mainAbility6ListKey[i]; } } console.log(TAG + "listKeyTemp is :" + listKeyTemp); console.log(TAG + "first globalThis.mainAbility6CallBackId is :" + globalThis.mainAbility6CallBackId); callBackId1 = globalThis.mainAbility6CallBackId console.log(TAG + "callBackId1 is :" + callBackId1); - expect(listKeyTemp[0]).assertEqual("Hap2MainAbility9 onWindowStageCreate"); - expect(listKeyTemp[1]).assertEqual("Hap2MainAbility9 onWindowStageActive"); - expect(listKeyTemp[2]).assertEqual("Hap2MainAbility9 onWindowStageInactive"); - expect(listKeyTemp[3]).assertEqual("Hap2MainAbility9 onWindowStageDestroy"); - + expect(transferStr0.indexOf("Hap2MainAbility9 onWindowStageCreate")!=-1).assertTrue(); + expect(transferStr0.indexOf("Hap2MainAbility9 onWindowStageActive")!=-1).assertTrue(); + expect(transferStr0.indexOf("Hap2MainAbility9 onWindowStageInactive")!=-1).assertTrue(); + expect(transferStr0.indexOf("Hap2MainAbility9 onWindowStageDestroy")!=-1).assertTrue(); globalThis.ApplicationContext6 .unregisterAbilityLifecycleCallback(globalThis.mainAbility6CallBackId, (error, data) => { console.log(TAG + ": first unregisterAbilityLifecycleCallback success, err: " + JSON.stringify(error) + @@ -542,6 +556,7 @@ export default function abilityTest() { for (var i = 0;i < globalThis.mainAbility6ListKey.length; i++) { if (globalThis.mainAbility6ListKey[i].substring(0, 16) == "Hap2MainAbility9") { listKeyTemp1.push(globalThis.mainAbility6ListKey[i]); + transferStr1 += globalThis.mainAbility6ListKey[i]; } } console.log(TAG + "listKeyTemp1 is :" + listKeyTemp1); @@ -549,11 +564,10 @@ export default function abilityTest() { callBackId2 = globalThis.mainAbility6CallBackId console.log(TAG + "callBackId2 is :" + callBackId2); expect(callBackId2).assertEqual(callBackId1 + 1) - expect(listKeyTemp1[0]).assertEqual("Hap2MainAbility9 onWindowStageCreate"); - expect(listKeyTemp1[1]).assertEqual("Hap2MainAbility9 onWindowStageActive"); - expect(listKeyTemp1[2]).assertEqual("Hap2MainAbility9 onWindowStageInactive"); - expect(listKeyTemp1[3]).assertEqual("Hap2MainAbility9 onWindowStageDestroy"); - + expect(transferStr1.indexOf("Hap2MainAbility9 onWindowStageCreate")!=-1).assertTrue(); + expect(transferStr1.indexOf("Hap2MainAbility9 onWindowStageActive")!=-1).assertTrue(); + expect(transferStr1.indexOf("Hap2MainAbility9 onWindowStageInactive")!=-1).assertTrue(); + expect(transferStr1.indexOf("Hap2MainAbility9 onWindowStageDestroy")!=-1).assertTrue(); globalThis.ApplicationContext6 .unregisterAbilityLifecycleCallback(globalThis.mainAbility6CallBackId, (error, data) => { console.log(TAG + ": second unregisterAbilityLifecycleCallback success, err: " + JSON.stringify(error) + @@ -581,6 +595,7 @@ export default function abilityTest() { console.log("------------Multihap_WindowStageLifecycleTest_008 start-------------"); TAG = "Multihap_WindowStageLifecycleTest_008"; listKeyTemp = []; + var transferStr0 = ""; globalThis.abilityContext.startAbility({ bundleName: "com.example.lifecycletest", @@ -603,15 +618,15 @@ export default function abilityTest() { for (var i = 0;i < globalThis.mainAbility4ListKey.length; i++) { if (globalThis.mainAbility4ListKey[i].substring(0, 16) == "Hap2MainAbility6") { listKeyTemp.push(globalThis.mainAbility4ListKey[i]); + transferStr0 += globalThis.mainAbility4ListKey[i]; } } console.log(TAG + "listKeyTemp is :" + listKeyTemp); console.log(TAG + "globalThis.mainAbility4CallBackId is :" + globalThis.mainAbility4CallBackId); - expect(listKeyTemp[0]).assertEqual("Hap2MainAbility6 onWindowStageCreate"); - expect(listKeyTemp[1]).assertEqual("Hap2MainAbility6 onWindowStageActive"); - expect(listKeyTemp[2]).assertEqual("Hap2MainAbility6 onWindowStageInactive"); - expect(listKeyTemp[3]).assertEqual("Hap2MainAbility6 onWindowStageDestroy"); - + expect(transferStr0.indexOf("Hap2MainAbility6 onWindowStageCreate")!=-1).assertTrue(); + expect(transferStr0.indexOf("Hap2MainAbility6 onWindowStageActive")!=-1).assertTrue(); + expect(transferStr0.indexOf("Hap2MainAbility6 onWindowStageInactive")!=-1).assertTrue(); + expect(transferStr0.indexOf("Hap2MainAbility6 onWindowStageDestroy")!=-1).assertTrue(); globalThis.ApplicationContext4 .unregisterAbilityLifecycleCallback(globalThis.mainAbility4CallBackId, (error, data) => { console.log(TAG + ": first unregisterAbilityLifecycleCallback, err: " + JSON.stringify(error) + @@ -641,6 +656,8 @@ export default function abilityTest() { TAG = "Multihap_WindowStageLifecycleTest_009"; listKeyTemp = []; listKeyTemp1 = []; + var transferStr0 = ""; + var transferStr1 = ""; globalThis.abilityContext.startAbility({ bundleName: "com.example.lifecycletest", @@ -709,29 +726,30 @@ export default function abilityTest() { for (var i = 0;i < globalThis.mainAbility4ListKey.length; i++) { if (globalThis.mainAbility4ListKey[i].substring(0, 17) == "Hap2MainAbility10") { listKeyTemp.push(globalThis.mainAbility4ListKey[i]); + transferStr0 += globalThis.mainAbility4ListKey[i]; } else if (globalThis.mainAbility4ListKey[i].substring(0, 16) == "Hap3MainAbility3") { listKeyTemp1.push(globalThis.mainAbility4ListKey[i]); + transferStr1 += globalThis.mainAbility4ListKey[i]; } } console.log(TAG + " listKeyTemp is :" + listKeyTemp); console.log(TAG + " listKeyTemp1 is :" + listKeyTemp1); console.log(TAG + " globalThis.mainAbility4CallBackId is :" + globalThis.mainAbility4CallBackId); - expect(listKeyTemp[0]).assertEqual("Hap2MainAbility10 onWindowStageCreate"); - expect(listKeyTemp[1]).assertEqual("Hap2MainAbility10 onWindowStageActive"); - expect(listKeyTemp[2]).assertEqual("Hap2MainAbility10 onWindowStageInactive"); - expect(listKeyTemp[3]).assertEqual("Hap2MainAbility10 onWindowStageActive"); - expect(listKeyTemp[4]).assertEqual("Hap2MainAbility10 onWindowStageInactive"); - expect(listKeyTemp[5]).assertEqual("Hap2MainAbility10 onWindowStageActive"); - expect(listKeyTemp[6]).assertEqual("Hap2MainAbility10 onWindowStageInactive"); - - expect(listKeyTemp1[0]).assertEqual("Hap3MainAbility3 onWindowStageCreate"); - expect(listKeyTemp1[1]).assertEqual("Hap3MainAbility3 onWindowStageActive"); - expect(listKeyTemp1[2]).assertEqual("Hap3MainAbility3 onWindowStageInactive"); - expect(listKeyTemp1[3]).assertEqual("Hap3MainAbility3 onWindowStageActive"); - expect(listKeyTemp1[4]).assertEqual("Hap3MainAbility3 onWindowStageInactive"); - expect(listKeyTemp1[5]).assertEqual("Hap3MainAbility3 onWindowStageActive"); - + expect(transferStr0.indexOf("Hap2MainAbility10 onWindowStageCreate")!=-1).assertTrue(); + expect(transferStr0.indexOf("Hap2MainAbility10 onWindowStageActive")!=-1).assertTrue(); + expect(transferStr0.indexOf("Hap2MainAbility10 onWindowStageInactive")!=-1).assertTrue(); + expect(transferStr0.indexOf("Hap2MainAbility10 onWindowStageActive")!=-1).assertTrue(); + expect(transferStr0.indexOf("Hap2MainAbility10 onWindowStageInactive")!=-1).assertTrue(); + expect(transferStr0.indexOf("Hap2MainAbility10 onWindowStageActive")!=-1).assertTrue(); + expect(transferStr0.indexOf("Hap2MainAbility10 onWindowStageInactive")!=-1).assertTrue(); + + expect(transferStr1.indexOf("Hap3MainAbility3 onWindowStageCreate")!=-1).assertTrue(); + expect(transferStr1.indexOf("Hap3MainAbility3 onWindowStageActive")!=-1).assertTrue(); + expect(transferStr1.indexOf("Hap3MainAbility3 onWindowStageInactive")!=-1).assertTrue(); + expect(transferStr1.indexOf("Hap3MainAbility3 onWindowStageActive")!=-1).assertTrue(); + expect(transferStr1.indexOf("Hap3MainAbility3 onWindowStageInactive")!=-1).assertTrue(); + expect(transferStr1.indexOf("Hap3MainAbility3 onWindowStageActive")!=-1).assertTrue(); globalThis.ApplicationContext4 .unregisterAbilityLifecycleCallback(globalThis.mainAbility4CallBackId, (error, data) => { console.log(TAG + ": unregisterAbilityLifecycleCallback success, err: " + JSON.stringify(error) + @@ -795,4 +813,4 @@ export default function abilityTest() { console.info("---------------Multihap_WindowStageLifecycleTest_010 is end---------------") }) }) -} \ No newline at end of file +} diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/test/LifeCycleTest.ets b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/test/LifeCycleTest.ets index d3790a1ac..52691b5b2 100755 --- a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/test/LifeCycleTest.ets +++ b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/test/LifeCycleTest.ets @@ -96,14 +96,15 @@ export default function lifecycleTest() { console.log(TAG + " registerAbilityLifecycleCallback tempCallbackId : " + JSON.stringify(tempCallbackId)); var strtemp = ""; var listtemp = []; + var transferStr0 = ""; for (var i = 0; i < globalThis.list.length; i++) { strtemp = globalThis.list[i].substring(0, 12); if (strtemp === "MainAbility2") { listtemp.push(globalThis.list[i]); + transferStr0 += globalThis.list[i]; } } console.log(TAG + " listtemp is :" + JSON.stringify(listtemp)); - let exlist = listtemp; globalThis.applicationContext .unregisterAbilityLifecycleCallback(tempCallbackId, (error, data) => { console.log(TAG + ": unregisterAbilityLifecycleCallback success, err: " + JSON.stringify(error) + @@ -111,10 +112,10 @@ export default function lifecycleTest() { code = error.code; }); setTimeout(function () { - expect(exlist[0]).assertEqual("MainAbility2 onWindowStageCreate"); - expect(exlist[1]).assertEqual("MainAbility2 onWindowStageActive"); - expect(exlist[2]).assertEqual("MainAbility2 onWindowStageInactive"); - expect(exlist[3]).assertEqual("MainAbility2 onWindowStageDestroy"); + expect(transferStr0.indexOf("MainAbility2 onWindowStageCreate")!=-1).assertTrue(); + expect(transferStr0.indexOf("MainAbility2 onWindowStageActive")!=-1).assertTrue(); + expect(transferStr0.indexOf("MainAbility2 onWindowStageInactive")!=-1).assertTrue(); + expect(transferStr0.indexOf("MainAbility2 onWindowStageDestroy")!=-1).assertTrue(); expect(code).assertEqual(0); console.log("------------Singlehap_WindowStageLifeCycleTest_0100 END-------------"); done(); @@ -159,14 +160,15 @@ export default function lifecycleTest() { console.log(TAG + " registerAbilityLifecycleCallback callbackid : " + JSON.stringify(globalThis.callbackid1)); var strtemp = ""; var listtemp = []; + var transferStr0 = ""; for (var i = 0; i < globalThis.list1.length; i++) { strtemp = globalThis.list1[i].substring(0, 12); if (strtemp === "MainAbility1" || strtemp === "MainAbility2") { listtemp.push(globalThis.list1[i]); + transferStr0 += globalThis.list1[i]; } } console.log(TAG + " listtemp is :" + JSON.stringify(listtemp)); - let exlist = listtemp; globalThis.applicationContext1 .unregisterAbilityLifecycleCallback(globalThis.callbackid1, (error, data) => { console.log(TAG + ": unregisterAbilityLifecycleCallback success, err: " + JSON.stringify(error) + @@ -174,16 +176,14 @@ export default function lifecycleTest() { code = error.code; }) setTimeout(function () { - expect(exlist[0]).assertEqual("MainAbility1 onWindowStageCreate"); - expect(exlist[1]).assertEqual("MainAbility1 onWindowStageActive"); - expect(exlist[2]).assertEqual("MainAbility2 onWindowStageCreate"); - var transferStr0 = exlist[3] + exlist[4]; + expect(transferStr0.indexOf("MainAbility1 onWindowStageCreate")!=-1).assertTrue(); + expect(transferStr0.indexOf("MainAbility1 onWindowStageActive")!=-1).assertTrue(); + expect(transferStr0.indexOf("MainAbility2 onWindowStageCreate")!=-1).assertTrue(); expect(transferStr0.indexOf("MainAbility1 onWindowStageInactive")!=-1).assertTrue(); expect(transferStr0.indexOf("MainAbility2 onWindowStageActive")!=-1).assertTrue(); - var transferStr1 = exlist[5] + exlist[6]; - expect(transferStr1.indexOf("MainAbility1 onWindowStageActive")!=-1).assertTrue(); - expect(transferStr1.indexOf("MainAbility2 onWindowStageInactive")!=-1).assertTrue(); - expect(exlist[7]).assertEqual("MainAbility2 onWindowStageDestroy"); + expect(transferStr0.indexOf("MainAbility1 onWindowStageActive")!=-1).assertTrue(); + expect(transferStr0.indexOf("MainAbility2 onWindowStageInactive")!=-1).assertTrue(); + expect(transferStr0.indexOf("MainAbility2 onWindowStageDestroy")!=-1).assertTrue(); expect(code).assertEqual(0); console.log("------------Singlehap_WindowStageLifeCycleTest_0200 END-------------"); done(); @@ -228,14 +228,15 @@ export default function lifecycleTest() { console.log(TAG + " registerAbilityLifecycleCallback callbackid : " + JSON.stringify(globalThis.callbackid1)); var strtemp = ""; var listtemp = []; + var transferStr0 = ""; for (var i = 0; i < globalThis.list1.length; i++) { strtemp = globalThis.list1[i].substring(0, 12); if (strtemp === "MainAbility1" || strtemp === "MainAbility2") { listtemp.push(globalThis.list1[i]); + transferStr0 += globalThis.list1[i]; } } console.log(TAG + " listtemp is :" + JSON.stringify(listtemp)); - let exlist = listtemp; globalThis.applicationContext1 .unregisterAbilityLifecycleCallback(globalThis.callbackid1) .then((data) => { @@ -254,16 +255,14 @@ export default function lifecycleTest() { }) }, 500); setTimeout(function () { - expect(exlist[0]).assertEqual("MainAbility1 onWindowStageCreate"); - expect(exlist[1]).assertEqual("MainAbility1 onWindowStageActive"); - expect(exlist[2]).assertEqual("MainAbility2 onWindowStageCreate"); - var transferStr0 = exlist[3] + exlist[4]; + expect(transferStr0.indexOf("MainAbility1 onWindowStageCreate")!=-1).assertTrue(); + expect(transferStr0.indexOf("MainAbility1 onWindowStageActive")!=-1).assertTrue(); + expect(transferStr0.indexOf("MainAbility2 onWindowStageCreate")!=-1).assertTrue(); expect(transferStr0.indexOf("MainAbility1 onWindowStageInactive")!=-1).assertTrue(); expect(transferStr0.indexOf("MainAbility2 onWindowStageActive")!=-1).assertTrue(); - var transferStr0 = exlist[5] + exlist[6]; expect(transferStr0.indexOf("MainAbility2 onWindowStageInactive")!=-1).assertTrue(); expect(transferStr0.indexOf("MainAbility1 onWindowStageActive")!=-1).assertTrue(); - expect(exlist[7]).assertEqual("MainAbility2 onWindowStageDestroy"); + expect(transferStr0.indexOf("MainAbility2 onWindowStageDestroy")!=-1).assertTrue(); expect(code).assertEqual(1); console.log("------------Singlehap_WindowStageLifeCycleTest_0300 END-------------"); done(); @@ -308,10 +307,12 @@ export default function lifecycleTest() { console.log(TAG + " registerAbilityLifecycleCallback callbackid : " + JSON.stringify(globalThis.callbackid3)); var strtemp = ""; var listtemp = []; + var transferStr0 = ""; for (var i = 0; i < globalThis.list3.length; i++) { strtemp = globalThis.list3[i].substring(0, 12); if (strtemp === "MainAbility3" || strtemp === "MainAbility2") { listtemp.push(globalThis.list3[i]); + transferStr0 += globalThis.list3[i]; } } console.log(TAG + " listtemp is :" + JSON.stringify(listtemp)); @@ -339,16 +340,14 @@ export default function lifecycleTest() { }) }, 500); setTimeout(function () { - expect(exlist[0]).assertEqual("MainAbility3 onWindowStageCreate"); - expect(exlist[1]).assertEqual("MainAbility3 onWindowStageActive"); - expect(exlist[2]).assertEqual("MainAbility2 onWindowStageCreate"); - var transferStr0 = exlist[3] + exlist[4]; + expect(transferStr0.indexOf("MainAbility3 onWindowStageCreate")!=-1).assertTrue(); + expect(transferStr0.indexOf("MainAbility3 onWindowStageActive")!=-1).assertTrue(); + expect(transferStr0.indexOf("MainAbility2 onWindowStageCreate")!=-1).assertTrue(); expect(transferStr0.indexOf("MainAbility3 onWindowStageInactive")!=-1).assertTrue(); expect(transferStr0.indexOf("MainAbility2 onWindowStageActive")!=-1).assertTrue(); - var transferStr0 = exlist[5] + exlist[6]; expect(transferStr0.indexOf("MainAbility2 onWindowStageInactive")!=-1).assertTrue(); expect(transferStr0.indexOf("MainAbility3 onWindowStageActive")!=-1).assertTrue(); - expect(exlist[7]).assertEqual("MainAbility2 onWindowStageDestroy"); + expect(transferStr0.indexOf("MainAbility2 onWindowStageDestroy")!=-1).assertTrue(); expect(code).assertEqual(0); console.log("------------Singlehap_WindowStageLifeCycleTest_0400 END-------------"); done(); @@ -404,23 +403,23 @@ export default function lifecycleTest() { console.log(TAG + " callbackid1 : " + JSON.stringify(globalThis.callbackid1)); var strtemp = ""; var listtemp = []; + var transferStr0 = ""; for (var i = 0; i < globalThis.list1.length; i++) { strtemp = globalThis.list1[i].substring(0, 12); if (strtemp == "MainAbility5" || strtemp == "MainAbility2") { listtemp.push(globalThis.list1[i]); + transferStr0 += globalThis.list1[i]; } } console.log(TAG + " listtemp is :" + JSON.stringify(listtemp)); - let exlist = listtemp; - expect(exlist[0]).assertEqual("MainAbility5 onWindowStageCreate"); - expect(exlist[1]).assertEqual("MainAbility5 onWindowStageActive"); - expect(exlist[2]).assertEqual("MainAbility2 onWindowStageCreate"); - var transferStr0 = exlist[3] + exlist[4]; + expect(transferStr0.indexOf("MainAbility5 onWindowStageCreate")!=-1).assertTrue(); + expect(transferStr0.indexOf("MainAbility5 onWindowStageActive")!=-1).assertTrue(); + expect(transferStr0.indexOf("MainAbility2 onWindowStageCreate")!=-1).assertTrue(); expect(transferStr0.indexOf("MainAbility2 onWindowStageActive")!=-1).assertTrue(); expect(transferStr0.indexOf("MainAbility5 onWindowStageInactive")!=-1).assertTrue(); - expect(exlist[5]).assertEqual("MainAbility5 onWindowStageDestroy"); - expect(exlist[6]).assertEqual("MainAbility2 onWindowStageInactive"); - expect(exlist[7]).assertEqual("MainAbility2 onWindowStageDestroy"); + expect(transferStr0.indexOf("MainAbility5 onWindowStageDestroy")!=-1).assertTrue(); + expect(transferStr0.indexOf("MainAbility2 onWindowStageInactive")!=-1).assertTrue(); + expect(transferStr0.indexOf("MainAbility2 onWindowStageDestroy")!=-1).assertTrue(); globalThis.applicationContext1 .unregisterAbilityLifecycleCallback(globalThis.callbackid1, (error, data) => { console.log(TAG + ": unregisterAbilityLifecycleCallback success, err: " + JSON.stringify(error) + @@ -493,34 +492,30 @@ export default function lifecycleTest() { console.log(TAG + " registerAbilityLifecycleCallback callbackid : " + JSON.stringify(globalThis.callbackid1)); var strtemp = ""; var listtemp = []; + var transferStr0 = ""; for (var i = 0; i < globalThis.list1.length; i++) { strtemp = globalThis.list1[i].substring(0, 12); if (strtemp === "MainAbility1" || strtemp === "MainAbility2") { listtemp.push(globalThis.list1[i]); + transferStr0 += globalThis.list1[i]; } } console.log(TAG + " listtemp is :" + listtemp); - let exlist = listtemp; - expect(exlist[0]).assertEqual("MainAbility1 onWindowStageCreate"); - expect(exlist[1]).assertEqual("MainAbility1 onWindowStageActive"); - expect(exlist[2]).assertEqual("MainAbility2 onWindowStageCreate"); - var transferStr0 = exlist[3] + exlist[4]; + expect(transferStr0.indexOf("MainAbility1 onWindowStageCreate")!=-1).assertTrue(); + expect(transferStr0.indexOf("MainAbility1 onWindowStageActive")!=-1).assertTrue(); + expect(transferStr0.indexOf("MainAbility2 onWindowStageCreate")!=-1).assertTrue(); expect(transferStr0.indexOf("MainAbility2 onWindowStageActive")!=-1).assertTrue(); expect(transferStr0.indexOf("MainAbility1 onWindowStageInactive")!=-1).assertTrue(); - var transferStr0 = exlist[5] + exlist[6]; expect(transferStr0.indexOf("MainAbility1 onWindowStageActive")!=-1).assertTrue(); expect(transferStr0.indexOf("MainAbility2 onWindowStageInactive")!=-1).assertTrue(); - expect(exlist[7]).assertEqual("MainAbility2 onWindowStageDestroy"); - expect(exlist[8]).assertEqual("MainAbility2 onWindowStageCreate"); - var transferStr0 = exlist[9] + exlist[10]; + expect(transferStr0.indexOf("MainAbility2 onWindowStageDestroy")!=-1).assertTrue(); + expect(transferStr0.indexOf("MainAbility2 onWindowStageCreate")!=-1).assertTrue(); expect(transferStr0.indexOf("MainAbility2 onWindowStageActive")!=-1).assertTrue(); expect(transferStr0.indexOf("MainAbility1 onWindowStageInactive")!=-1).assertTrue(); - var transferStr0 = exlist[11] + exlist[12]; expect(transferStr0.indexOf("MainAbility1 onWindowStageActive")!=-1).assertTrue(); expect(transferStr0.indexOf("MainAbility2 onWindowStageInactive")!=-1).assertTrue(); - expect(exlist[13]).assertEqual("MainAbility2 onWindowStageDestroy"); - expect(exlist[14]).assertEqual("MainAbility2 onWindowStageCreate"); - var transferStr0 = exlist[15] + exlist[16]; + expect(transferStr0.indexOf("MainAbility2 onWindowStageDestroy")!=-1).assertTrue(); + expect(transferStr0.indexOf("MainAbility2 onWindowStageCreate")!=-1).assertTrue(); expect(transferStr0.indexOf("MainAbility2 onWindowStageActive")!=-1).assertTrue(); expect(transferStr0.indexOf("MainAbility1 onWindowStageInactive")!=-1).assertTrue(); globalThis.applicationContext1 @@ -581,32 +576,29 @@ export default function lifecycleTest() { console.log(TAG + " registerAbilityLifecycleCallback callbackid : " + JSON.stringify(globalThis.callbackid1)); var strtemp = ""; var listtemp = []; + var transferStr0 = ""; for (var i = 0; i < globalThis.list1.length; i++) { strtemp = globalThis.list1[i].substring(0, 12); if (strtemp === "MainAbility1" || strtemp === "MainAbility2") { listtemp.push(globalThis.list1[i]); + transferStr0 += globalThis.list1[i]; } } console.log(TAG + " listtemp is :" + listtemp); - let exlist = listtemp; - expect(exlist[0]).assertEqual("MainAbility1 onWindowStageCreate"); - expect(exlist[1]).assertEqual("MainAbility1 onWindowStageActive"); - expect(exlist[2]).assertEqual("MainAbility2 onWindowStageCreate"); - var transferStr0 = exlist[3] + exlist[4]; + expect(transferStr0.indexOf("MainAbility1 onWindowStageCreate")!=-1).assertTrue(); + expect(transferStr0.indexOf("MainAbility1 onWindowStageActive")!=-1).assertTrue(); + expect(transferStr0.indexOf("MainAbility2 onWindowStageCreate")!=-1).assertTrue(); expect(transferStr0.indexOf("MainAbility2 onWindowStageActive")!=-1).assertTrue(); expect(transferStr0.indexOf("MainAbility1 onWindowStageInactive")!=-1).assertTrue(); - var transferStr0 = exlist[5] + exlist[6]; expect(transferStr0.indexOf("MainAbility1 onWindowStageActive")!=-1).assertTrue(); expect(transferStr0.indexOf("MainAbility2 onWindowStageInactive")!=-1).assertTrue(); - expect(exlist[7]).assertEqual("MainAbility2 onWindowStageDestroy"); - expect(exlist[8]).assertEqual("MainAbility2 onWindowStageCreate"); - var transferStr0 = exlist[9] + exlist[10]; + expect(transferStr0.indexOf("MainAbility2 onWindowStageDestroy")!=-1).assertTrue(); + expect(transferStr0.indexOf("MainAbility2 onWindowStageCreate")!=-1).assertTrue(); expect(transferStr0.indexOf("MainAbility2 onWindowStageActive")!=-1).assertTrue(); expect(transferStr0.indexOf("MainAbility1 onWindowStageInactive")!=-1).assertTrue(); - var transferStr0 = exlist[11] + exlist[12]; expect(transferStr0.indexOf("MainAbility1 onWindowStageActive")!=-1).assertTrue(); expect(transferStr0.indexOf("MainAbility2 onWindowStageInactive")!=-1).assertTrue(); - expect(exlist[13]).assertEqual("MainAbility2 onWindowStageDestroy"); + expect(transferStr0.indexOf("MainAbility2 onWindowStageDestroy")!=-1).assertTrue(); globalThis.applicationContext1 .unregisterAbilityLifecycleCallback(globalThis.callbackid1, (error, data) => { console.log(TAG + ": unregisterAbilityLifecycleCallback success, err: " + JSON.stringify(error) + @@ -680,6 +672,7 @@ export default function lifecycleTest() { console.log("------------Singlehap_WindowStageLifeCycleTest_0900 start-------------"); TAG = "Singlehap_WindowStageLifeCycleTest_0900"; listKeyTemp = []; + var transferStr0 = ""; globalThis.abilityContext.startAbility({ bundleName: "com.example.windowstagelifecycle_xts", abilityName: "MainAbility9" @@ -706,14 +699,15 @@ export default function lifecycleTest() { for (var i = 0; i < globalThis.mainAbility9ListKey.length; i++) { if (globalThis.mainAbility9ListKey[i].substring(0, 16) == "Hap1MainAbility1") { listKeyTemp.push(globalThis.mainAbility9ListKey[i]); + transferStr0 += globalThis.mainAbility9ListKey[i]; } } console.log(TAG + "listKeyTemp is :" + listKeyTemp); console.log(TAG + "globalThis.mainAbility9CallBackId is :" + globalThis.mainAbility9CallBackId); - expect(listKeyTemp[0]).assertEqual("Hap1MainAbility1 onWindowStageCreate"); - expect(listKeyTemp[1]).assertEqual("Hap1MainAbility1 onWindowStageActive"); - expect(listKeyTemp[2]).assertEqual("Hap1MainAbility1 onWindowStageInactive"); - expect(listKeyTemp[3]).assertEqual("Hap1MainAbility1 onWindowStageDestroy"); + expect(transferStr0.indexOf("Hap1MainAbility1 onWindowStageCreate")!=-1).assertTrue(); + expect(transferStr0.indexOf("Hap1MainAbility1 onWindowStageActive")!=-1).assertTrue(); + expect(transferStr0.indexOf("Hap1MainAbility1 onWindowStageInactive")!=-1).assertTrue(); + expect(transferStr0.indexOf("Hap1MainAbility1 onWindowStageDestroy")!=-1).assertTrue(); globalThis.applicationContext9 .unregisterAbilityLifecycleCallback(globalThis.mainAbility9CallBackId, (error, data) => { console.log(TAG + ": unregisterAbilityLifecycleCallback success, err: " + JSON.stringify(error) + @@ -735,6 +729,7 @@ export default function lifecycleTest() { console.log("------------Singlehap_WindowStageLifeCycleTest_1000 start-------------"); TAG = "Singlehap_WindowStageLifeCycleTest_1000"; listKeyTemp = []; + var transferStr0 = ""; globalThis.abilityContext.startAbility({ bundleName: "com.example.windowstagelifecycle_xts", abilityName: "MainAbility9" @@ -761,19 +756,19 @@ export default function lifecycleTest() { for (var i = 0;i < globalThis.mainAbility9ListKey.length; i++) { if (globalThis.mainAbility9ListKey[i].substring(0, 16) == "Hap1MainAbility2") { listKeyTemp.push(globalThis.mainAbility9ListKey[i]); + transferStr0 += globalThis.mainAbility9ListKey[i]; } } console.log(TAG + "listKeyTemp is :" + listKeyTemp); console.log(TAG + "globalThis.mainAbility9CallBackId is :" + globalThis.mainAbility9CallBackId); - expect(listKeyTemp[0]).assertEqual("Hap1MainAbility2 onWindowStageCreate"); - expect(listKeyTemp[1]).assertEqual("Hap1MainAbility2 onWindowStageActive"); - expect(listKeyTemp[2]).assertEqual("Hap1MainAbility2 onWindowStageCreate"); - var transferStr0 = listKeyTemp[3] + listKeyTemp[4]; + expect(transferStr0.indexOf("Hap1MainAbility2 onWindowStageCreate")!=-1).assertTrue(); expect(transferStr0.indexOf("Hap1MainAbility2 onWindowStageActive")!=-1).assertTrue(); + expect(transferStr0.indexOf("Hap1MainAbility2 onWindowStageCreate")!=-1).assertTrue(); + expect(transferStr0.indexOf("Hap1MainAbility2 onWindowStageActive")!=-1).assertTrue(); + expect(transferStr0.indexOf("Hap1MainAbility2 onWindowStageInactive")!=-1).assertTrue(); + expect(transferStr0.indexOf("Hap1MainAbility2 onWindowStageDestroy")!=-1).assertTrue(); expect(transferStr0.indexOf("Hap1MainAbility2 onWindowStageInactive")!=-1).assertTrue(); - expect(listKeyTemp[5]).assertEqual("Hap1MainAbility2 onWindowStageDestroy"); - expect(listKeyTemp[6]).assertEqual("Hap1MainAbility2 onWindowStageInactive"); - expect(listKeyTemp[7]).assertEqual("Hap1MainAbility2 onWindowStageDestroy"); + expect(transferStr0.indexOf("Hap1MainAbility2 onWindowStageDestroy")!=-1).assertTrue(); globalThis.applicationContext9 .unregisterAbilityLifecycleCallback(globalThis.mainAbility9CallBackId, (error, data) => { console.log(TAG + ": unregisterAbilityLifecycleCallback success, err: " + JSON.stringify(error) + @@ -852,18 +847,19 @@ export default function lifecycleTest() { console.log(TAG + " secondCallback id : " + JSON.stringify(id2)); var strtemp = ""; var listtemp = []; + var transferStr0 = ""; for (var i = 0; i < globalThis.list11.length; i++) { strtemp = globalThis.list11[i].substring(0, 12); if (strtemp == "MainAbility2") { listtemp.push(globalThis.list11[i]); + transferStr0 += globalThis.list11[i]; } } console.log(TAG + " listtemp is :" + JSON.stringify(listtemp)); - let exlist = listtemp; - expect(exlist[0]).assertEqual("MainAbility2 onWindowStageCreate"); - expect(exlist[1]).assertEqual("MainAbility2 onWindowStageActive"); - expect(exlist[2]).assertEqual("MainAbility2 onWindowStageInactive"); - expect(exlist[3]).assertEqual("MainAbility2 onWindowStageDestroy"); + expect(transferStr0.indexOf("MainAbility2 onWindowStageCreate")!=-1).assertTrue(); + expect(transferStr0.indexOf("MainAbility2 onWindowStageActive")!=-1).assertTrue(); + expect(transferStr0.indexOf("MainAbility2 onWindowStageInactive")!=-1).assertTrue(); + expect(transferStr0.indexOf("MainAbility2 onWindowStageDestroy")!=-1).assertTrue(); expect(id1 + 1).assertEqual(id2); globalThis.applicationContext11 .unregisterAbilityLifecycleCallback(globalThis.callbackid11, (error, data) => { @@ -959,18 +955,19 @@ export default function lifecycleTest() { console.log(TAG + " secondCallback id : " + JSON.stringify(id2)); var strtemp = ""; var listtemp = []; + var transferStr0 = ""; for (var i = 0; i < globalThis.list12.length; i++) { strtemp = globalThis.list12[i].substring(0, 12); if (strtemp == "MainAbility2") { listtemp.push(globalThis.list12[i]); + transferStr0 += globalThis.list12[i]; } } console.log(TAG + " listtemp is :" + JSON.stringify(listtemp)); - let exlist = listtemp; - expect(exlist[0]).assertEqual("MainAbility2 onWindowStageCreate"); - expect(exlist[1]).assertEqual("MainAbility2 onWindowStageActive"); - expect(exlist[2]).assertEqual("MainAbility2 onWindowStageInactive"); - expect(exlist[3]).assertEqual("MainAbility2 onWindowStageDestroy"); + expect(transferStr0.indexOf("MainAbility2 onWindowStageCreate")!=-1).assertTrue(); + expect(transferStr0.indexOf("MainAbility2 onWindowStageActive")!=-1).assertTrue(); + expect(transferStr0.indexOf("MainAbility2 onWindowStageInactive")!=-1).assertTrue(); + expect(transferStr0.indexOf("MainAbility2 onWindowStageDestroy")!=-1).assertTrue(); expect(id1 + 1).assertEqual(id2); globalThis.applicationContext12 .unregisterAbilityLifecycleCallback(id2, (error, data) => { @@ -1121,40 +1118,39 @@ export default function lifecycleTest() { console.log(TAG + " secondCallback id12 : " + JSON.stringify(id4)); var strtemp = ""; var listtemp = []; + var transferStr0 = ""; for (var i = 0; i < templist1.length; i++) { strtemp = templist1[i].substring(0, 13); if (strtemp === "MainAbility2 " || strtemp === "MainAbility12") { listtemp.push(templist1[i]); + transferStr0 += templist1[i]; } } console.log(TAG + " listtemp is :" + JSON.stringify(listtemp)); setTimeout(function () { var strtemp1 = ""; var listtemp1 = []; + var transferStr1 = ""; for (var j = 0; j < templist2.length; j++) { strtemp1 = templist2[j].substring(0, 12); if (strtemp1 === "MainAbility2") { listtemp1.push(templist2[j]); + transferStr1 += templist2[j]; } } console.log(TAG + " listtemp1 is :" + JSON.stringify(listtemp1)); - let exlist = listtemp; - let exlist1 = listtemp1; - expect(exlist[0]).assertEqual("MainAbility12 onWindowStageCreate"); - expect(exlist[1]).assertEqual("MainAbility12 onWindowStageActive"); - expect(exlist[2]).assertEqual("MainAbility2 onWindowStageCreate"); - var transferStr0 = exlist[3] + exlist[4]; + expect(transferStr0.indexOf("MainAbility12 onWindowStageCreate")!=-1).assertTrue(); + expect(transferStr0.indexOf("MainAbility12 onWindowStageActive")!=-1).assertTrue(); + expect(transferStr0.indexOf("MainAbility2 onWindowStageCreate")!=-1).assertTrue(); expect(transferStr0.indexOf("MainAbility2 onWindowStageActive")!=-1).assertTrue(); expect(transferStr0.indexOf("MainAbility12 onWindowStageInactive")!=-1).assertTrue(); - var transferStr0 = exlist[5] + exlist[6]; expect(transferStr0.indexOf("MainAbility12 onWindowStageActive")!=-1).assertTrue(); expect(transferStr0.indexOf("MainAbility2 onWindowStageInactive")!=-1).assertTrue(); - expect(exlist[7]).assertEqual("MainAbility2 onWindowStageDestroy"); - expect(exlist1[0]).assertEqual("MainAbility2 onWindowStageCreate"); - var transferStr0 = exlist1[1] + exlist1[2]; - expect(transferStr0.indexOf("MainAbility2 onWindowStageActive")!=-1).assertTrue(); - expect(transferStr0.indexOf("MainAbility2 onWindowStageInactive")!=-1).assertTrue(); - expect(exlist1[3]).assertEqual("MainAbility2 onWindowStageDestroy"); + expect(transferStr0.indexOf("MainAbility2 onWindowStageDestroy")!=-1).assertTrue(); + expect(transferStr1.indexOf("MainAbility2 onWindowStageCreate")!=-1).assertTrue();; + expect(transferStr1.indexOf("MainAbility2 onWindowStageActive")!=-1).assertTrue(); + expect(transferStr1.indexOf("MainAbility2 onWindowStageInactive")!=-1).assertTrue(); + expect(transferStr1.indexOf("MainAbility2 onWindowStageDestroy")!=-1).assertTrue(); expect(id1 + 1).assertEqual(id2); expect(id3 + 1).assertEqual(id4); globalThis.applicationContext12 -- GitLab