From 27d7a37af9d900605f8dc666c55bd372e40c5751 Mon Sep 17 00:00:00 2001 From: kirl75 Date: Wed, 30 Aug 2023 14:43:29 +0800 Subject: [PATCH] =?UTF-8?q?xts=5F=E8=8E=B7=E5=8F=96=E5=BD=93=E5=89=8Dabili?= =?UTF-8?q?ty=E5=A2=9E=E5=8A=A0=E5=BB=B6=E6=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: kirl75 --- .../entry/src/main/ets/test/Ability.test.ets | 3 ++- .../entry/src/main/ets/test/Ability.test.ets | 3 ++- .../apitest/entry/src/main/ets/MainAbility3/MainAbility3.ts | 6 ++++-- 3 files changed, 8 insertions(+), 4 deletions(-) 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 722aa88a4..d7e3f8a86 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 46eead653..0cea374eb 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 7d11ea72a..a859143bf 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() { -- GitLab