未验证 提交 4671ca88 编写于 作者: O openharmony_ci 提交者: Gitee

!8159 xts-getCurrentTopAbility问题修改

Merge pull request !8159 from chengxingzhen/master
......@@ -36,6 +36,13 @@ export default class MainAbility extends Ability {
globalThis.ability3Context = this.context
windowStage.setUIContent(this.context, "pages/index1", null)
windowStage.on('windowStageEvent', (data) => {
console.log(`ActsGetCurrentTopAbilityStagebTest onWindwoStage is : ${JSON.stringify(data)}`)
if (data == 2 ) {
console.log(`ActsGetCurrentTopAbilityStagebTest getWindowStageActive is sucess`)
commonEvent.publish("GetCurrentTopAbility", publishCallBackOne);
}
})
}
onWindowStageDestroy() {
......@@ -46,7 +53,6 @@ export default class MainAbility extends Ability {
onForeground() {
// Ability has brought to foreground
console.log("Ability1 onForeground")
commonEvent.publish("GetCurrentTopAbility", publishCallBackOne);
}
......
......@@ -36,7 +36,20 @@ export default class TestAbility extends Ability {
onWindowStageCreate(windowStage) {
console.log('TestAbility onWindowStageCreate')
globalThis.onWindowStageActive = false;
let count = 0;
windowStage.setUIContent(this.context, 'MainAbility/pages/index', null)
windowStage.on('windowStageEvent', (data) => {
console.log(`ActsApiTest onWindwoStage is : ${JSON.stringify(data)}`)
if (data == 2 ) {
console.log(`ActsApiTest onWindwoStage count is : ${count}`)
count++;
if (count == 2) {
console.log(`ActsApiTest onWindwoStage count is : ${count}`)
globalThis.onWindowStageActive = true;
}
}
})
}
onWindowStageDestroy() {
......
......@@ -31,7 +31,18 @@ export default function abilityTest() {
describe('ActsChangeAbilityStagetest', function () {
beforeAll(async function (done) {
console.info('beforeAll called')
await sleep(2000)
let delay = 3000;
let start = new Date().getTime();
while (true) {
if (globalThis.onWindowStageActive) {
console.log(`ActsApiTest getWindwoStageActive is success`)
break;
}
if (new Date().getTime() - start > delay) {
console.log(`ActsApiTest getWindwoStageActive is failed`)
break;
}
}
await globalThis.abilitydelegator.getCurrentTopAbility().then((data) => {
mainability = data
done()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册