未验证 提交 6ebc1469 编写于 作者: O openharmony_ci 提交者: Gitee

!9981 修复ActsOnAndOffScreenTest时序问题

Merge pull request !9981 from 于文泽/onOff
......@@ -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();
});
......
......@@ -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) => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册