diff --git a/ability/ability_runtime/actsqueryfunctiontest/actsgetcurrenttopabilitystageatest/entry/src/main/ets/test/Ability.test.ets b/ability/ability_runtime/actsqueryfunctiontest/actsgetcurrenttopabilitystageatest/entry/src/main/ets/test/Ability.test.ets index 722aa88a469e301a1b4832f4b516a2c00e8fbb44..d7e3f8a86b4405e73d4b8914699496a48c399125 100644 --- a/ability/ability_runtime/actsqueryfunctiontest/actsgetcurrenttopabilitystageatest/entry/src/main/ets/test/Ability.test.ets +++ b/ability/ability_runtime/actsqueryfunctiontest/actsgetcurrenttopabilitystageatest/entry/src/main/ets/test/Ability.test.ets @@ -43,11 +43,12 @@ export default function abilityTest() { var Subscriber; var AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); - function SubscribeCallBack(err, data) { + async function SubscribeCallBack(err, data) { console.debug("ACTS_GetCurrentTopAbility_0100====>Subscribe CallBack data:====>" + JSON.stringify(data)); expect(data.event == 'GetCurrentTopAbilityB').assertTrue(); if (data.event == 'GetCurrentTopAbilityB') { + await sleep(1000); AbilityDelegator.getCurrentTopAbility((err, data) => { console.log("ACTS_GetCurrentTopAbility_0100 and"); console.debug("====>thisTopAbility_0100====>" + JSON.stringify(data)); diff --git a/ability/ability_runtime/actsqueryfunctiontest/actsgetcurrenttopabilitystagebtest/entry/src/main/ets/test/Ability.test.ets b/ability/ability_runtime/actsqueryfunctiontest/actsgetcurrenttopabilitystagebtest/entry/src/main/ets/test/Ability.test.ets index 46eead65390a1a0225f49a3927332ba5dd0c5a95..0cea374eb6d36c1dbab96ab6205d0bb75318c268 100644 --- a/ability/ability_runtime/actsqueryfunctiontest/actsgetcurrenttopabilitystagebtest/entry/src/main/ets/test/Ability.test.ets +++ b/ability/ability_runtime/actsqueryfunctiontest/actsgetcurrenttopabilitystagebtest/entry/src/main/ets/test/Ability.test.ets @@ -45,10 +45,11 @@ export default function abilityTest() { var Subscriber; var AbilityDelegator=await abilityDelegatorRegistry.getAbilityDelegator(); - function SubscribeCallBack(err, data) { + async function SubscribeCallBack(err, data) { console.debug("ACTS_GetCurrentTopAbility_0200====>Subscribe CallBack data:====>" + JSON.stringify(data)); expect(data.event == 'GetCurrentTopAbility').assertTrue(); if (data.event == 'GetCurrentTopAbility') { + await sleep(1000); AbilityDelegator.getCurrentTopAbility((err,data) => { console.debug("====>thisTopAbility====>"+JSON.stringify(data.lastRequestWant)) console.debug("====>start startAbility====>"); diff --git a/ability/ability_runtime/apitest/entry/src/main/ets/MainAbility3/MainAbility3.ts b/ability/ability_runtime/apitest/entry/src/main/ets/MainAbility3/MainAbility3.ts index 7d11ea72a3e7bbcfa3704035a332cdfa6b48be53..a859143bf4d774ec691a5ad3357f23dd5dc5055b 100644 --- a/ability/ability_runtime/apitest/entry/src/main/ets/MainAbility3/MainAbility3.ts +++ b/ability/ability_runtime/apitest/entry/src/main/ets/MainAbility3/MainAbility3.ts @@ -44,12 +44,14 @@ export default class MainAbility3 extends Ability { onForeground() { // Ability has brought to foreground - console.log("[Demo] MainAbility3 onForeground") - globalThis.abilitydelegator.getCurrentTopAbility().then((data)=>{ + console.log("[Demo] MainAbility3 onForeground"); + setTimeout(() => { + globalThis.abilitydelegator.getCurrentTopAbility().then((data)=>{ globalThis.ability3 = data console.debug("====>MainAbility getCurrentTopAbility:====>" + JSON.stringify(globalThis.ability3)); commonEvent.publish("ACTS_DoAbility_Event", PublishCallBackOne); }) + }, 1000); } onBackground() {