提交 dfbc7b01 编写于 作者: Z zhoujun62

XTS ActsLifecycleSingleHapTest fail because of asynchronization problem

Signed-off-by: Nzhoujun62 <zhoujun62@huawei.com>
上级 63e674ec
......@@ -160,14 +160,19 @@ export default function lifecycleTest() {
console.log(TAG + " registerAbilityLifecycleCallback callbackid : " + JSON.stringify(globalThis.callbackid1));
var strtemp = "";
var listtemp = [];
var listtemp1 = [];
for (var i = 0; i < globalThis.list1.length; i++) {
strtemp = globalThis.list1[i].substring(0, 12);
if (strtemp === "MainAbility1" || strtemp === "MainAbility2") {
if (strtemp === "MainAbility1") {
listtemp.push(globalThis.list1[i]);
} else if (strtemp === "MainAbility2") {
listtemp1.push(globalThis.list1[i]);
}
}
console.log(TAG + " listtemp is :" + JSON.stringify(listtemp));
console.log(TAG + " listtemp1 is :" + JSON.stringify(listtemp1));
let exlist = listtemp;
let exlist1 = listtemp1;
globalThis.applicationContext1
.unregisterAbilityLifecycleCallback(globalThis.callbackid1, (error, data) => {
console.log(TAG + ": unregisterAbilityLifecycleCallback success, err: " + JSON.stringify(error) +
......@@ -177,14 +182,14 @@ export default function lifecycleTest() {
setTimeout(function () {
expect(exlist[0]).assertEqual("MainAbility1 onWindowStageCreate");
expect(exlist[1]).assertEqual("MainAbility1 onAbilityForeground");
expect(exlist[2]).assertEqual("MainAbility2 onAbilityCreate");
expect(exlist[3]).assertEqual("MainAbility2 onWindowStageCreate");
expect(exlist[4]).assertEqual("MainAbility2 onAbilityForeground");
expect(exlist[5]).assertEqual("MainAbility1 onAbilityBackground");
expect(exlist[6]).assertEqual("MainAbility1 onAbilityForeground");
expect(exlist[7]).assertEqual("MainAbility2 onAbilityBackground");
expect(exlist[8]).assertEqual("MainAbility2 onWindowStageDestroy");
expect(exlist[9]).assertEqual("MainAbility2 onAbilityDestroy");
expect(exlist[2]).assertEqual("MainAbility1 onAbilityBackground");
expect(exlist[3]).assertEqual("MainAbility1 onAbilityForeground");
expect(exlist1[0]).assertEqual("MainAbility2 onAbilityCreate");
expect(exlist1[1]).assertEqual("MainAbility2 onWindowStageCreate");
expect(exlist1[2]).assertEqual("MainAbility2 onAbilityForeground");
expect(exlist1[3]).assertEqual("MainAbility2 onAbilityBackground");
expect(exlist1[4]).assertEqual("MainAbility2 onWindowStageDestroy");
expect(exlist1[5]).assertEqual("MainAbility2 onAbilityDestroy");
expect(code).assertEqual(0);
console.log("------------Singlehap_LifeCycleTest_0200 END-------------");
done();
......@@ -229,14 +234,19 @@ export default function lifecycleTest() {
console.log(TAG + " registerAbilityLifecycleCallback callbackid : " + JSON.stringify(globalThis.callbackid1));
var strtemp = "";
var listtemp = [];
var listtemp1 = [];
for (var i = 0; i < globalThis.list1.length; i++) {
strtemp = globalThis.list1[i].substring(0, 12);
if (strtemp === "MainAbility1" || strtemp === "MainAbility2") {
if (strtemp === "MainAbility1") {
listtemp.push(globalThis.list1[i]);
} else if (strtemp === "MainAbility2") {
listtemp1.push(globalThis.list1[i]);
}
}
console.log(TAG + " listtemp is :" + JSON.stringify(listtemp));
console.log(TAG + " listtemp1 is :" + JSON.stringify(listtemp1));
let exlist = listtemp;
let exlist1 = listtemp1;
globalThis.applicationContext1
.unregisterAbilityLifecycleCallback(globalThis.callbackid1)
.then((data) => {
......@@ -257,14 +267,14 @@ export default function lifecycleTest() {
setTimeout(function () {
expect(exlist[0]).assertEqual("MainAbility1 onWindowStageCreate");
expect(exlist[1]).assertEqual("MainAbility1 onAbilityForeground");
expect(exlist[2]).assertEqual("MainAbility2 onAbilityCreate");
expect(exlist[3]).assertEqual("MainAbility2 onWindowStageCreate");
expect(exlist[4]).assertEqual("MainAbility2 onAbilityForeground");
expect(exlist[5]).assertEqual("MainAbility1 onAbilityBackground");
expect(exlist[6]).assertEqual("MainAbility1 onAbilityForeground");
expect(exlist[7]).assertEqual("MainAbility2 onAbilityBackground");
expect(exlist[8]).assertEqual("MainAbility2 onWindowStageDestroy");
expect(exlist[9]).assertEqual("MainAbility2 onAbilityDestroy");
expect(exlist[2]).assertEqual("MainAbility1 onAbilityBackground");
expect(exlist[3]).assertEqual("MainAbility1 onAbilityForeground");
expect(exlist1[0]).assertEqual("MainAbility2 onAbilityCreate");
expect(exlist1[1]).assertEqual("MainAbility2 onWindowStageCreate");
expect(exlist1[2]).assertEqual("MainAbility2 onAbilityForeground");
expect(exlist1[3]).assertEqual("MainAbility2 onAbilityBackground");
expect(exlist1[4]).assertEqual("MainAbility2 onWindowStageDestroy");
expect(exlist1[5]).assertEqual("MainAbility2 onAbilityDestroy");
expect(code).assertEqual(1);
console.log("------------Singlehap_LifeCycleTest_0300 END-------------");
done();
......@@ -309,14 +319,19 @@ export default function lifecycleTest() {
console.log(TAG + " registerAbilityLifecycleCallback callbackid : " + JSON.stringify(globalThis.callbackid3));
var strtemp = "";
var listtemp = [];
var listtemp1 = [];
for (var i = 0; i < globalThis.list3.length; i++) {
strtemp = globalThis.list3[i].substring(0, 12);
if (strtemp === "MainAbility3" || strtemp === "MainAbility2") {
if (strtemp === "MainAbility3") {
listtemp.push(globalThis.list3[i]);
} else if (strtemp === "MainAbility2") {
listtemp1.push(globalThis.list3[i]);
}
}
console.log(TAG + " listtemp is :" + JSON.stringify(listtemp));
console.log(TAG + " listtemp1 is :" + JSON.stringify(listtemp1));
let exlist = listtemp;
let exlist1 = listtemp1;
var para = {
resultCode: 1,
want: {
......@@ -342,14 +357,14 @@ export default function lifecycleTest() {
setTimeout(function () {
expect(exlist[0]).assertEqual("MainAbility3 onWindowStageCreate");
expect(exlist[1]).assertEqual("MainAbility3 onAbilityForeground");
expect(exlist[2]).assertEqual("MainAbility2 onAbilityCreate");
expect(exlist[3]).assertEqual("MainAbility2 onWindowStageCreate");
expect(exlist[4]).assertEqual("MainAbility2 onAbilityForeground");
expect(exlist[5]).assertEqual("MainAbility3 onAbilityBackground");
expect(exlist[6]).assertEqual("MainAbility3 onAbilityForeground");
expect(exlist[7]).assertEqual("MainAbility2 onAbilityBackground");
expect(exlist[8]).assertEqual("MainAbility2 onWindowStageDestroy");
expect(exlist[9]).assertEqual("MainAbility2 onAbilityDestroy");
expect(exlist[2]).assertEqual("MainAbility3 onAbilityBackground");
expect(exlist[3]).assertEqual("MainAbility3 onAbilityForeground");
expect(exlist1[0]).assertEqual("MainAbility2 onAbilityCreate");
expect(exlist1[1]).assertEqual("MainAbility2 onWindowStageCreate");
expect(exlist1[2]).assertEqual("MainAbility2 onAbilityForeground");
expect(exlist1[3]).assertEqual("MainAbility2 onAbilityBackground");
expect(exlist1[4]).assertEqual("MainAbility2 onWindowStageDestroy");
expect(exlist1[5]).assertEqual("MainAbility2 onAbilityDestroy");
expect(code).assertEqual(0);
console.log("------------Singlehap_LifeCycleTest_0400 END-------------");
done();
......@@ -501,7 +516,6 @@ export default function lifecycleTest() {
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");
......@@ -702,36 +716,41 @@ export default function lifecycleTest() {
console.log(TAG + " registerAbilityLifecycleCallback callbackid : " + JSON.stringify(globalThis.callbackid1));
var strtemp = "";
var listtemp = [];
var listtemp1 = [];
for (var i = 0; i < globalThis.list1.length; i++) {
strtemp = globalThis.list1[i].substring(0, 12);
if (strtemp === "MainAbility1" || strtemp === "MainAbility2") {
if (strtemp === "MainAbility1") {
listtemp.push(globalThis.list1[i]);
} else if (strtemp === "MainAbility2") {
listtemp1.push(globalThis.list1[i]);
}
}
console.log(TAG + " listtemp is :" + listtemp);
console.log(TAG + " listtemp1 is :" + listtemp1);
let exlist = listtemp;
let exlist1 = listtemp1;
expect(exlist[0]).assertEqual("MainAbility1 onWindowStageCreate");
expect(exlist[1]).assertEqual("MainAbility1 onAbilityForeground");
expect(exlist[2]).assertEqual("MainAbility2 onAbilityCreate");
expect(exlist[3]).assertEqual("MainAbility2 onWindowStageCreate");
expect(exlist[4]).assertEqual("MainAbility2 onAbilityForeground");
expect(exlist[5]).assertEqual("MainAbility1 onAbilityBackground");
expect(exlist[6]).assertEqual("MainAbility1 onAbilityForeground");
expect(exlist[7]).assertEqual("MainAbility2 onAbilityBackground");
expect(exlist[8]).assertEqual("MainAbility2 onWindowStageDestroy");
expect(exlist[9]).assertEqual("MainAbility2 onAbilityDestroy");
expect(exlist[10]).assertEqual("MainAbility2 onAbilityCreate");
expect(exlist[11]).assertEqual("MainAbility2 onWindowStageCreate");
expect(exlist[12]).assertEqual("MainAbility2 onAbilityForeground");
expect(exlist[13]).assertEqual("MainAbility1 onAbilityBackground");
expect(exlist[14]).assertEqual("MainAbility1 onAbilityForeground");
expect(exlist[15]).assertEqual("MainAbility2 onAbilityBackground");
expect(exlist[16]).assertEqual("MainAbility2 onWindowStageDestroy");
expect(exlist[17]).assertEqual("MainAbility2 onAbilityDestroy");
expect(exlist[18]).assertEqual("MainAbility2 onAbilityCreate");
expect(exlist[19]).assertEqual("MainAbility2 onWindowStageCreate");
expect(exlist[20]).assertEqual("MainAbility2 onAbilityForeground");
expect(exlist[21]).assertEqual("MainAbility1 onAbilityBackground");
expect(exlist[2]).assertEqual("MainAbility1 onAbilityBackground");
expect(exlist[3]).assertEqual("MainAbility1 onAbilityForeground");
expect(exlist[4]).assertEqual("MainAbility1 onAbilityBackground");
expect(exlist[5]).assertEqual("MainAbility1 onAbilityForeground");
expect(exlist[6]).assertEqual("MainAbility1 onAbilityBackground");
expect(exlist1[0]).assertEqual("MainAbility2 onAbilityCreate");
expect(exlist1[1]).assertEqual("MainAbility2 onWindowStageCreate");
expect(exlist1[2]).assertEqual("MainAbility2 onAbilityForeground");
expect(exlist1[3]).assertEqual("MainAbility2 onAbilityBackground");
expect(exlist1[4]).assertEqual("MainAbility2 onWindowStageDestroy");
expect(exlist1[5]).assertEqual("MainAbility2 onAbilityDestroy");
expect(exlist1[6]).assertEqual("MainAbility2 onAbilityCreate");
expect(exlist1[7]).assertEqual("MainAbility2 onWindowStageCreate");
expect(exlist1[8]).assertEqual("MainAbility2 onAbilityForeground");
expect(exlist1[9]).assertEqual("MainAbility2 onAbilityBackground");
expect(exlist1[10]).assertEqual("MainAbility2 onWindowStageDestroy");
expect(exlist1[11]).assertEqual("MainAbility2 onAbilityDestroy");
expect(exlist1[12]).assertEqual("MainAbility2 onAbilityCreate");
expect(exlist1[13]).assertEqual("MainAbility2 onWindowStageCreate");
expect(exlist1[14]).assertEqual("MainAbility2 onAbilityForeground");
globalThis.applicationContext1
.unregisterAbilityLifecycleCallback(globalThis.callbackid1, (error, data) => {
console.log(TAG + ": unregisterAbilityLifecycleCallback success, err: " + JSON.stringify(error) +
......@@ -790,32 +809,37 @@ export default function lifecycleTest() {
console.log(TAG + " registerAbilityLifecycleCallback callbackid : " + JSON.stringify(globalThis.callbackid1));
var strtemp = "";
var listtemp = [];
var listtemp1 = [];
for (var i = 0; i < globalThis.list1.length; i++) {
strtemp = globalThis.list1[i].substring(0, 12);
if (strtemp === "MainAbility1" || strtemp === "MainAbility2") {
if (strtemp === "MainAbility1") {
listtemp.push(globalThis.list1[i]);
} else if (strtemp === "MainAbility2") {
listtemp1.push(globalThis.list1[i]);
}
}
console.log(TAG + " listtemp is :" + listtemp);
console.log(TAG + " listtemp1 is :" + listtemp1);
let exlist = listtemp;
let exlist1 = listtemp1;
expect(exlist[0]).assertEqual("MainAbility1 onWindowStageCreate");
expect(exlist[1]).assertEqual("MainAbility1 onAbilityForeground");
expect(exlist[2]).assertEqual("MainAbility2 onAbilityCreate");
expect(exlist[3]).assertEqual("MainAbility2 onWindowStageCreate");
expect(exlist[4]).assertEqual("MainAbility2 onAbilityForeground");
expect(exlist[5]).assertEqual("MainAbility1 onAbilityBackground");
expect(exlist[6]).assertEqual("MainAbility1 onAbilityForeground");
expect(exlist[7]).assertEqual("MainAbility2 onAbilityBackground");
expect(exlist[8]).assertEqual("MainAbility2 onWindowStageDestroy");
expect(exlist[9]).assertEqual("MainAbility2 onAbilityDestroy");
expect(exlist[10]).assertEqual("MainAbility2 onAbilityCreate");
expect(exlist[11]).assertEqual("MainAbility2 onWindowStageCreate");
expect(exlist[12]).assertEqual("MainAbility2 onAbilityForeground");
expect(exlist[13]).assertEqual("MainAbility1 onAbilityBackground");
expect(exlist[14]).assertEqual("MainAbility1 onAbilityForeground");
expect(exlist[15]).assertEqual("MainAbility2 onAbilityBackground");
expect(exlist[16]).assertEqual("MainAbility2 onWindowStageDestroy");
expect(exlist[17]).assertEqual("MainAbility2 onAbilityDestroy");
expect(exlist[2]).assertEqual("MainAbility1 onAbilityBackground");
expect(exlist[3]).assertEqual("MainAbility1 onAbilityForeground");
expect(exlist[4]).assertEqual("MainAbility1 onAbilityBackground");
expect(exlist[5]).assertEqual("MainAbility1 onAbilityForeground");
expect(exlist1[0]).assertEqual("MainAbility2 onAbilityCreate");
expect(exlist1[1]).assertEqual("MainAbility2 onWindowStageCreate");
expect(exlist1[2]).assertEqual("MainAbility2 onAbilityForeground");
expect(exlist1[3]).assertEqual("MainAbility2 onAbilityBackground");
expect(exlist1[4]).assertEqual("MainAbility2 onWindowStageDestroy");
expect(exlist1[5]).assertEqual("MainAbility2 onAbilityDestroy");
expect(exlist1[6]).assertEqual("MainAbility2 onAbilityCreate");
expect(exlist1[7]).assertEqual("MainAbility2 onWindowStageCreate");
expect(exlist1[8]).assertEqual("MainAbility2 onAbilityForeground");
expect(exlist1[9]).assertEqual("MainAbility2 onAbilityBackground");
expect(exlist1[10]).assertEqual("MainAbility2 onWindowStageDestroy");
expect(exlist1[11]).assertEqual("MainAbility2 onAbilityDestroy");
globalThis.applicationContext1
.unregisterAbilityLifecycleCallback(globalThis.callbackid1, (error, data) => {
console.log(TAG + ": unregisterAbilityLifecycleCallback success, err: " + JSON.stringify(error) +
......@@ -1555,13 +1579,17 @@ export default function lifecycleTest() {
console.log(TAG + " secondCallback id12 : " + JSON.stringify(id4));
var strtemp = "";
var listtemp = [];
var listtemp12 = [];
for (var i = 0; i < templist1.length; i++) {
strtemp = templist1[i].substring(0, 13);
if (strtemp === "MainAbility2 " || strtemp === "MainAbility12") {
if (strtemp === "MainAbility2 ") {
listtemp.push(templist1[i]);
} else if (strtemp === "MainAbility12") {
listtemp12.push(templist1[i]);
}
}
console.log(TAG + " listtemp is :" + JSON.stringify(listtemp));
console.log(TAG + " listtemp12 is :" + JSON.stringify(listtemp12));
setTimeout(function () {
var strtemp1 = "";
var listtemp1 = [];
......@@ -1573,18 +1601,19 @@ export default function lifecycleTest() {
}
console.log(TAG + " listtemp1 is :" + JSON.stringify(listtemp1));
let exlist = listtemp;
let exlist12 = listtemp12;
let exlist1 = listtemp1;
expect(exlist[0]).assertEqual("MainAbility12 onAbilityCreate");
expect(exlist[1]).assertEqual("MainAbility12 onWindowStageCreate");
expect(exlist[2]).assertEqual("MainAbility12 onAbilityForeground");
expect(exlist[3]).assertEqual("MainAbility2 onAbilityCreate");
expect(exlist[4]).assertEqual("MainAbility2 onWindowStageCreate");
expect(exlist[5]).assertEqual("MainAbility2 onAbilityForeground");
expect(exlist[6]).assertEqual("MainAbility12 onAbilityBackground");
expect(exlist[7]).assertEqual("MainAbility12 onAbilityForeground");
expect(exlist[8]).assertEqual("MainAbility2 onAbilityBackground");
expect(exlist[9]).assertEqual("MainAbility2 onWindowStageDestroy");
expect(exlist[10]).assertEqual("MainAbility2 onAbilityDestroy");
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(exlist12[0]).assertEqual("MainAbility2 onAbilityDestroy");
expect(exlist12[1]).assertEqual("MainAbility12 onAbilityCreate");
expect(exlist12[2]).assertEqual("MainAbility12 onWindowStageCreate");
expect(exlist12[3]).assertEqual("MainAbility12 onAbilityForeground");
expect(exlist12[4]).assertEqual("MainAbility12 onAbilityBackground");
expect(exlist12[5]).assertEqual("MainAbility12 onAbilityForeground");
expect(exlist1[0]).assertEqual("MainAbility2 onAbilityCreate");
expect(exlist1[1]).assertEqual("MainAbility2 onWindowStageCreate");
expect(exlist1[2]).assertEqual("MainAbility2 onAbilityForeground");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册