未验证 提交 630f5f2b 编写于 作者: O openharmony_ci 提交者: Gitee

!10009 修复ActsLifecycleMultiHapTest用例

Merge pull request !10009 from 于文泽/master
...@@ -331,8 +331,6 @@ export default function abilityTest() { ...@@ -331,8 +331,6 @@ export default function abilityTest() {
it("Multihap_LifecycleTest_005", 0, async function (done) { it("Multihap_LifecycleTest_005", 0, async function (done) {
console.log("------------Multihap_LifecycleTest_005 start-------------"); console.log("------------Multihap_LifecycleTest_005 start-------------");
TAG = "Multihap_LifecycleTest_005"; TAG = "Multihap_LifecycleTest_005";
listKeyTemp = [];
listKeyTemp1 = [];
globalThis.abilityContext.startAbility({ globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest", bundleName: "com.example.lifecycletest",
...@@ -361,31 +359,31 @@ export default function abilityTest() { ...@@ -361,31 +359,31 @@ export default function abilityTest() {
setTimeout(() => { setTimeout(() => {
console.log(TAG + ": second Hap2MainAbility7 startAbility success, err: " + JSON.stringify(error) + console.log(TAG + ": second Hap2MainAbility7 startAbility success, err: " + JSON.stringify(error) +
",data: " + JSON.stringify(data)); ",data: " + JSON.stringify(data));
for (var i = 0;i < globalThis.mainAbility4ListKey.length; i++) { let setTemp = new Set();
let setTemp1 = new Set();
for (var i = 0; i < globalThis.mainAbility4ListKey.length; i++) {
if (globalThis.mainAbility4ListKey[i].substring(0, 16) == "Hap2MainAbility6") { if (globalThis.mainAbility4ListKey[i].substring(0, 16) == "Hap2MainAbility6") {
listKeyTemp.push(globalThis.mainAbility4ListKey[i]); setTemp.add(globalThis.mainAbility4ListKey[i]);
console.log(TAG + " setTemp entry is :" + JSON.stringify(globalThis.mainAbility4ListKey[i]));
} else if (globalThis.mainAbility4ListKey[i].substring(0, 16) == "Hap2MainAbility7") { } else if (globalThis.mainAbility4ListKey[i].substring(0, 16) == "Hap2MainAbility7") {
listKeyTemp1.push(globalThis.mainAbility4ListKey[i]); setTemp1.add(globalThis.mainAbility4ListKey[i]);
console.log(TAG + " setTemp1 entry is :" + JSON.stringify(globalThis.mainAbility4ListKey[i]));
} }
} }
console.log(TAG + "listKeyTemp is :" + listKeyTemp);
console.log(TAG + "listKeyTemp1 is :" + listKeyTemp1);
console.log(TAG + "globalThis.mainAbility4CallBackId is :" + globalThis.mainAbility4CallBackId); console.log(TAG + "globalThis.mainAbility4CallBackId is :" + globalThis.mainAbility4CallBackId);
expect(listKeyTemp[0]).assertEqual("Hap2MainAbility6 onAbilityCreate"); expect(setTemp.has("Hap2MainAbility6 onAbilityCreate")).assertTrue();
expect(listKeyTemp[1]).assertEqual("Hap2MainAbility6 onWindowStageCreate"); expect(setTemp.has("Hap2MainAbility6 onWindowStageCreate")).assertTrue();
expect(listKeyTemp[2]).assertEqual("Hap2MainAbility6 onAbilityForeground"); expect(setTemp.has("Hap2MainAbility6 onAbilityForeground")).assertTrue();
expect(listKeyTemp[3]).assertEqual("Hap2MainAbility6 onAbilityBackground"); expect(setTemp.has("Hap2MainAbility6 onAbilityBackground")).assertTrue();
var transferStr0 = listKeyTemp[4] + listKeyTemp[5]; expect(setTemp.has("Hap2MainAbility6 onWindowStageDestroy")).assertTrue();
expect(transferStr0.indexOf("Hap2MainAbility6 onWindowStageDestroy")!=-1).assertTrue(); expect(setTemp.has("Hap2MainAbility6 onAbilityDestroy")).assertTrue();
expect(transferStr0.indexOf("Hap2MainAbility6 onAbilityDestroy")!=-1).assertTrue();
expect(setTemp1.has("Hap2MainAbility7 onAbilityCreate")).assertTrue();
expect(listKeyTemp1[0]).assertEqual("Hap2MainAbility7 onAbilityCreate"); expect(setTemp1.has("Hap2MainAbility7 onWindowStageCreate")).assertTrue();
expect(listKeyTemp1[1]).assertEqual("Hap2MainAbility7 onWindowStageCreate"); expect(setTemp1.has("Hap2MainAbility7 onAbilityForeground")).assertTrue();
expect(listKeyTemp1[2]).assertEqual("Hap2MainAbility7 onAbilityForeground"); expect(setTemp1.has("Hap2MainAbility7 onAbilityBackground")).assertTrue();
expect(listKeyTemp1[3]).assertEqual("Hap2MainAbility7 onAbilityBackground"); expect(setTemp1.has("Hap2MainAbility7 onWindowStageDestroy")).assertTrue();
var transferStr0 = listKeyTemp1[4] + listKeyTemp1[5]; expect(setTemp1.has("Hap2MainAbility7 onAbilityDestroy")).assertTrue();
expect(transferStr0.indexOf("Hap2MainAbility7 onWindowStageDestroy")!=-1).assertTrue();
expect(transferStr0.indexOf("Hap2MainAbility7 onAbilityDestroy")!=-1).assertTrue();
globalThis.ApplicationContext4 globalThis.ApplicationContext4
.unregisterAbilityLifecycleCallback(globalThis.mainAbility4CallBackId, (error, data) => { .unregisterAbilityLifecycleCallback(globalThis.mainAbility4CallBackId, (error, data) => {
......
...@@ -32,8 +32,6 @@ export default class TestAbility extends Ability { ...@@ -32,8 +32,6 @@ export default class TestAbility extends Ability {
} }
console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)) console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data))
}); });
globalThis.abilityContext = this.context;
} }
onWindowStageDestroy() { onWindowStageDestroy() {
......
...@@ -94,15 +94,14 @@ export default function lifecycleTest() { ...@@ -94,15 +94,14 @@ export default function lifecycleTest() {
tempCallbackId = globalThis.callbackid; tempCallbackId = globalThis.callbackid;
console.log(TAG + " registerAbilityLifecycleCallback tempCallbackId : " + JSON.stringify(tempCallbackId)); console.log(TAG + " registerAbilityLifecycleCallback tempCallbackId : " + JSON.stringify(tempCallbackId));
var strtemp = ""; var strtemp = "";
var listtemp = []; let settemp = new Set();
for (var i = 0; i < globalThis.list.length; i++) { for (var i = 0; i < globalThis.list.length; i++) {
strtemp = globalThis.list[i].substring(0, 12); strtemp = globalThis.list[i].substring(0, 12);
if (strtemp === "MainAbility2") { if (strtemp === "MainAbility2") {
listtemp.push(globalThis.list[i]); settemp.add(globalThis.list[i]);
console.log(TAG + " entry is :" + JSON.stringify(globalThis.list[i]));
} }
} }
console.log(TAG + " listtemp is :" + JSON.stringify(listtemp));
let exlist = listtemp;
globalThis.applicationContext globalThis.applicationContext
.unregisterAbilityLifecycleCallback(tempCallbackId, (error, data) => { .unregisterAbilityLifecycleCallback(tempCallbackId, (error, data) => {
console.log(TAG + ": unregisterAbilityLifecycleCallback success, err: " + JSON.stringify(error) + console.log(TAG + ": unregisterAbilityLifecycleCallback success, err: " + JSON.stringify(error) +
...@@ -110,12 +109,12 @@ export default function lifecycleTest() { ...@@ -110,12 +109,12 @@ export default function lifecycleTest() {
code = error.code; code = error.code;
}); });
setTimeout(function () { setTimeout(function () {
expect(exlist[0]).assertEqual("MainAbility2 onAbilityCreate"); expect(settemp.has("MainAbility2 onAbilityCreate")).assertTrue();
expect(exlist[1]).assertEqual("MainAbility2 onWindowStageCreate"); expect(settemp.has("MainAbility2 onWindowStageCreate")).assertTrue();
expect(exlist[2]).assertEqual("MainAbility2 onAbilityForeground"); expect(settemp.has("MainAbility2 onAbilityForeground")).assertTrue();
expect(exlist[3]).assertEqual("MainAbility2 onAbilityBackground"); expect(settemp.has("MainAbility2 onAbilityBackground")).assertTrue();
expect(exlist[4]).assertEqual("MainAbility2 onWindowStageDestroy"); expect(settemp.has("MainAbility2 onWindowStageDestroy")).assertTrue();
expect(exlist[5]).assertEqual("MainAbility2 onAbilityDestroy"); expect(settemp.has("MainAbility2 onAbilityDestroy")).assertTrue();
expect(code).assertEqual(0); expect(code).assertEqual(0);
console.log("------------Singlehap_LifeCycleTest_0100 END-------------"); console.log("------------Singlehap_LifeCycleTest_0100 END-------------");
done(); done();
...@@ -159,20 +158,23 @@ export default function lifecycleTest() { ...@@ -159,20 +158,23 @@ export default function lifecycleTest() {
console.log(TAG + " registerAbilityLifecycleCallback listKey : " + JSON.stringify(globalThis.list1)); console.log(TAG + " registerAbilityLifecycleCallback listKey : " + JSON.stringify(globalThis.list1));
console.log(TAG + " registerAbilityLifecycleCallback callbackid : " + JSON.stringify(globalThis.callbackid1)); console.log(TAG + " registerAbilityLifecycleCallback callbackid : " + JSON.stringify(globalThis.callbackid1));
var strtemp = ""; var strtemp = "";
var listtemp = []; let maptemp = new Map();
var listtemp1 = []; let settemp = new Set();
for (var i = 0; i < globalThis.list1.length; i++) { for (var i = 0; i < globalThis.list1.length; i++) {
strtemp = globalThis.list1[i].substring(0, 12); strtemp = globalThis.list1[i].substring(0, 12);
if (strtemp === "MainAbility1") { if (strtemp === "MainAbility1") {
listtemp.push(globalThis.list1[i]); if (maptemp.has(globalThis.list1[i])) {
let value = maptemp.get(globalThis.list1[i]);
maptemp.set(globalThis.list1[i], value + 1);
} else {
maptemp.set(globalThis.list1[i], 1);
}
console.log(TAG + " maptemp entry is :" + JSON.stringify(globalThis.list1[i]));
} else if (strtemp === "MainAbility2") { } else if (strtemp === "MainAbility2") {
listtemp1.push(globalThis.list1[i]); settemp.add(globalThis.list1[i]);
console.log(TAG + " settemp entry is :" + JSON.stringify(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 globalThis.applicationContext1
.unregisterAbilityLifecycleCallback(globalThis.callbackid1, (error, data) => { .unregisterAbilityLifecycleCallback(globalThis.callbackid1, (error, data) => {
console.log(TAG + ": unregisterAbilityLifecycleCallback success, err: " + JSON.stringify(error) + console.log(TAG + ": unregisterAbilityLifecycleCallback success, err: " + JSON.stringify(error) +
...@@ -180,16 +182,16 @@ export default function lifecycleTest() { ...@@ -180,16 +182,16 @@ export default function lifecycleTest() {
code = error.code; code = error.code;
}) })
setTimeout(function () { setTimeout(function () {
expect(exlist[0]).assertEqual("MainAbility1 onWindowStageCreate"); expect(maptemp.has("MainAbility1 onWindowStageCreate")).assertTrue();
expect(exlist[1]).assertEqual("MainAbility1 onAbilityForeground"); expect(maptemp.get("MainAbility1 onAbilityForeground")).assertEqual(2);
expect(exlist[2]).assertEqual("MainAbility1 onAbilityBackground"); expect(maptemp.has("MainAbility1 onAbilityBackground")).assertTrue();
expect(exlist[3]).assertEqual("MainAbility1 onAbilityForeground");
expect(exlist1[0]).assertEqual("MainAbility2 onAbilityCreate"); expect(settemp.has("MainAbility2 onAbilityCreate")).assertTrue();
expect(exlist1[1]).assertEqual("MainAbility2 onWindowStageCreate"); expect(settemp.has("MainAbility2 onWindowStageCreate")).assertTrue();
expect(exlist1[2]).assertEqual("MainAbility2 onAbilityForeground"); expect(settemp.has("MainAbility2 onAbilityForeground")).assertTrue();
expect(exlist1[3]).assertEqual("MainAbility2 onAbilityBackground"); expect(settemp.has("MainAbility2 onAbilityBackground")).assertTrue();
expect(exlist1[4]).assertEqual("MainAbility2 onWindowStageDestroy"); expect(settemp.has("MainAbility2 onWindowStageDestroy")).assertTrue();
expect(exlist1[5]).assertEqual("MainAbility2 onAbilityDestroy"); expect(settemp.has("MainAbility2 onAbilityDestroy")).assertTrue();
expect(code).assertEqual(0); expect(code).assertEqual(0);
console.log("------------Singlehap_LifeCycleTest_0200 END-------------"); console.log("------------Singlehap_LifeCycleTest_0200 END-------------");
done(); done();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册