diff --git a/ability/ability_runtime/actssupportfunction/actsonandoffscreentest/entry/src/main/ets/test/OnAndOffScreenTest.test.ets b/ability/ability_runtime/actssupportfunction/actsonandoffscreentest/entry/src/main/ets/test/OnAndOffScreenTest.test.ets index 60599d30167320ce427e5b339aacb330a8797a65..4e83017c1f27a12249af367c929b2be48e0ebd04 100644 --- a/ability/ability_runtime/actssupportfunction/actsonandoffscreentest/entry/src/main/ets/test/OnAndOffScreenTest.test.ets +++ b/ability/ability_runtime/actssupportfunction/actsonandoffscreentest/entry/src/main/ets/test/OnAndOffScreenTest.test.ets @@ -441,7 +441,7 @@ export default function OnAndOffScreenTest() { let flag = false; let status1 = undefined; - let lifeList = []; + let lifeSet = new Set(); let listCheck = ["onCreate", "onWindowStageCreate", "onForeground", "onBackground"]; let onCreate = "StageOnAndOffScreen_MainAbility2_onCreate"; let onWindowStageCreate = "StageOnAndOffScreen_MainAbility2_onWindowStageCreate"; @@ -465,27 +465,27 @@ export default function OnAndOffScreenTest() { console.log(TAG + "SubscribeInfoCallback : " + JSON.stringify(data)); if (data.event == onCreate) { - lifeList.push("onCreate"); + lifeSet.add("onCreate"); } if (data.event == onWindowStageCreate) { - lifeList.push("onWindowStageCreate"); + lifeSet.add("onWindowStageCreate"); } if (data.event == onForeground) { - lifeList.push("onForeground"); + lifeSet.add("onForeground"); } if (data.event == onBackground) { - lifeList.push("onBackground"); + lifeSet.add("onBackground"); } if (data.event == onWindowStageDestroy) { - lifeList.push("onWindowStageDestroy"); + lifeSet.add("onWindowStageDestroy"); } if (data.event == onDestroy) { - lifeList.push("onDestroy"); + lifeSet.add("onDestroy"); } if (data.event == onForeground2 && !flag) { @@ -497,7 +497,9 @@ export default function OnAndOffScreenTest() { setTimeout(async () => { commonEvent.unsubscribe(subscriber, async (err, data) => { console.log(TAG + "UnSubscribeInfoCallback : " + JSON.stringify(data)); - expect(JSON.stringify(lifeList)).assertEqual(JSON.stringify(listCheck)); + for (let i in listCheck) { + expect(lifeSet.has(listCheck[i])).assertTrue(); + } expect(status1).assertTrue(); done(); }); 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 997b34c0319fcff85df1cc9950a071fd5f69e2a5..aa96dda98260fa2d021f489562cdad8ca7c0c72e 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 @@ -496,32 +496,31 @@ export default function lifecycleTest() { console.log(TAG + " listKey1 : " + JSON.stringify(globalThis.list1)); console.log(TAG + " callbackid1 : " + JSON.stringify(globalThis.callbackid1)); var strtemp = ""; - var listtemp = []; - var listtemp2 = []; + let settemp = new Set(); + let settemp2 = new Set(); for (var i = 0; i < globalThis.list1.length; i++) { strtemp = globalThis.list1[i].substring(0, 12); if (strtemp == "MainAbility2") { - listtemp.push(globalThis.list1[i]); + settemp.add(globalThis.list1[i]); + console.log(TAG + " set1 is :" + JSON.stringify(globalThis.list1[i])); } else if (strtemp == "MainAbility5") { - listtemp2.push(globalThis.list1[i]); + settemp2.add(globalThis.list1[i]); + console.log(TAG + " set2 is :" + JSON.stringify(globalThis.list1[i])); } } - console.log(TAG + " listtemp is :" + JSON.stringify(listtemp)); - console.log(TAG + " listtemp2 is :" + JSON.stringify(listtemp2)); - let exlist = listtemp; - let exlist2 = listtemp2; - expect(exlist[0]).assertEqual("MainAbility2 onAbilityCreate"); - expect(exlist[1]).assertEqual("MainAbility2 onWindowStageCreate"); - expect(exlist[2]).assertEqual("MainAbility2 onAbilityForeground"); - expect(exlist[3]).assertEqual("MainAbility2 onAbilityBackground"); - expect(exlist[4]).assertEqual("MainAbility2 onWindowStageDestroy"); - expect(exlist[5]).assertEqual("MainAbility2 onAbilityDestroy"); - expect(exlist2[0]).assertEqual("MainAbility5 onAbilityCreate"); - expect(exlist2[1]).assertEqual("MainAbility5 onWindowStageCreate"); - expect(exlist2[2]).assertEqual("MainAbility5 onAbilityForeground"); - expect(exlist2[3]).assertEqual("MainAbility5 onAbilityBackground"); - expect(exlist2[4]).assertEqual("MainAbility5 onWindowStageDestroy"); - expect(exlist2[5]).assertEqual("MainAbility5 onAbilityDestroy"); + expect(settemp.has("MainAbility2 onAbilityCreate")).assertTrue(); + expect(settemp.has("MainAbility2 onWindowStageCreate")).assertTrue(); + expect(settemp.has("MainAbility2 onAbilityForeground")).assertTrue(); + expect(settemp.has("MainAbility2 onAbilityBackground")).assertTrue(); + expect(settemp.has("MainAbility2 onWindowStageDestroy")).assertTrue(); + expect(settemp.has("MainAbility2 onAbilityDestroy")).assertTrue(); + + expect(settemp2.has("MainAbility5 onAbilityCreate")).assertTrue(); + expect(settemp2.has("MainAbility5 onWindowStageCreate")).assertTrue(); + expect(settemp2.has("MainAbility5 onAbilityForeground")).assertTrue(); + expect(settemp2.has("MainAbility5 onAbilityBackground")).assertTrue(); + expect(settemp2.has("MainAbility5 onWindowStageDestroy")).assertTrue(); + expect(settemp2.has("MainAbility5 onAbilityDestroy")).assertTrue(); globalThis.applicationContext1 .unregisterAbilityLifecycleCallback(globalThis.callbackid1, (error, data) => {