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

!7122 doAbilityBackground&doAbilityForeground错误码整改

Merge pull request !7122 from yangliang36/yl0105
...@@ -37,12 +37,35 @@ export default function abilityTest() { ...@@ -37,12 +37,35 @@ export default function abilityTest() {
Subscriber.publish("ACTS_AddAbilityMonitor_0100", AddAbilityData, publishCallback); Subscriber.publish("ACTS_AddAbilityMonitor_0100", AddAbilityData, publishCallback);
} }
console.debug("====>ACTS_AddAbilityMonitor_0100 start====>"); console.debug("====>ACTS_AddAbilityMonitor_0100 start====>");
var AddAbilityData var AddAbilityData;
var commonEventSubscribeInfo = { var commonEventSubscribeInfo = {
events: ["ACTS_AddAbilityMonitor_0100"] events: ["ACTS_AddAbilityMonitor_0100"]
}; };
var data = abilityDelegatorRegistry.getAbilityDelegator() var data = abilityDelegatorRegistry.getAbilityDelegator();
console.log("0100getAbilityDelegator data is" + JSON.stringify(data)) console.log("0100getAbilityDelegator data is" + JSON.stringify(data));
Subscriber.createSubscriber(commonEventSubscribeInfo, async (err, data) => {
console.info("===ACTS_AddAbilityMonitor_0100===createSubscriber" + JSON.stringify(data));
var AddAbility = data;
await Subscriber.subscribe(AddAbility, (err, data) => {
console.log('===ACTS_AddAbilityMonitor_0100CallBack==='
+ err.code + JSON.stringify(data));
Subscriber.unsubscribe(AddAbility, (err, data) => {
console.log('===UnSubscribeCallBacka===' + err.code);
});
if (data.code == 1) {
expect(data.code).assertEqual(1);
setTimeout(() => {
done();
}, 2500);
}
else {
expect().assertFail();
setTimeout(() => {
done();
}, 2500);
}
});
});
data.addAbilityMonitor( data.addAbilityMonitor(
{ {
abilityName: 'MainAbility2', abilityName: 'MainAbility2',
...@@ -55,31 +78,8 @@ export default function abilityTest() { ...@@ -55,31 +78,8 @@ export default function abilityTest() {
abilityName: 'MainAbility2' abilityName: 'MainAbility2'
}).then(async () => { }).then(async () => {
console.debug("====>0100startAbility success====>"); console.debug("====>0100startAbility success====>");
await Subscriber.createSubscriber(commonEventSubscribeInfo, async (err, data) => { });
console.info("===ACTS_AddAbilityMonitor_0100===createSubscriber" + JSON.stringify(data)); }));
var AddAbility = data
await Subscriber.subscribe(AddAbility, (err, data) => {
console.log('===ACTS_AddAbilityMonitor_0100CallBack==='
+ err.code + JSON.stringify(data))
Subscriber.unsubscribe(AddAbility, (err, data) => {
console.log('===UnSubscribeCallBacka===' + err.code)
})
if (data.code == 1) {
expect(data.code).assertEqual(1);
setTimeout(() => {
done();
}, 2500)
}
else {
expect().assertFail();
setTimeout(() => {
done();
}, 2500)
}
})
})
})
}))
}) })
/** /**
...@@ -176,7 +176,7 @@ export default function abilityTest() { ...@@ -176,7 +176,7 @@ export default function abilityTest() {
console.info("===ACTS_AddAbilityMonitor_0300===createSubscriber" + JSON.stringify(data)); console.info("===ACTS_AddAbilityMonitor_0300===createSubscriber" + JSON.stringify(data));
var AddAbility = data var AddAbility = data
Delegator.getCurrentTopAbility().then((ability) => { Delegator.getCurrentTopAbility().then((ability) => {
console.info("===ACTS_AddAbilityMonitor_0300===ability" + JSON.stringify(ability)); console.info("===ACTS_AddAbilityMonitor_0300===ability " + JSON.stringify(ability).length);
Subscriber.subscribe(AddAbility, (err, data) => { Subscriber.subscribe(AddAbility, (err, data) => {
console.log('===ACTS_AddAbilityMonitor_0300CallBack===' console.log('===ACTS_AddAbilityMonitor_0300CallBack==='
+ err.code + JSON.stringify(data)) + err.code + JSON.stringify(data))
...@@ -198,9 +198,12 @@ export default function abilityTest() { ...@@ -198,9 +198,12 @@ export default function abilityTest() {
} }
}) })
Delegator.doAbilityBackground(ability).then(async (data) => { Delegator.doAbilityBackground(ability).then(async (data) => {
console.info("===ACTS_AddAbilityMonitor_0300===data" + JSON.stringify(data)); console.info("===ACTS_AddAbilityMonitor_0300===data succeed.");
expect(data).assertEqual(true) expect(true).assertTrue();
}) }).catch((err: any) => {
console.info("===ACTS_AddAbilityMonitor_0300===data failed.");
expect(false).assertTrue();
});
}) })
}) })
} }
...@@ -655,10 +658,10 @@ export default function abilityTest() { ...@@ -655,10 +658,10 @@ export default function abilityTest() {
console.info("===ACTS_AddAbilityMonitor_1000===createSubscriber" + JSON.stringify(data)); console.info("===ACTS_AddAbilityMonitor_1000===createSubscriber" + JSON.stringify(data));
var AddAbility = data var AddAbility = data
Delegator.getCurrentTopAbility().then((ability) => { Delegator.getCurrentTopAbility().then((ability) => {
console.info("===ACTS_AddAbilityMonitor_1000===ability" + JSON.stringify(ability)); console.info("===ACTS_AddAbilityMonitor_1000===ability" + JSON.stringify(ability).length);
Delegator.doAbilityBackground(ability).then(async (data) => { Delegator.doAbilityBackground(ability).then(async () => {
console.info("===ACTS_AddAbilityMonitor_1000===data" + JSON.stringify(data)); console.info("===ACTS_AddAbilityMonitor_1000===data succeed.");
expect(data).assertEqual(true) expect(true).assertTrue();
await Subscriber.subscribe(AddAbility, (err, data) => { await Subscriber.subscribe(AddAbility, (err, data) => {
console.log('===ACTS_AddAbilityMonitor_1000CallBack===' console.log('===ACTS_AddAbilityMonitor_1000CallBack==='
+ err.code + JSON.stringify(data)) + err.code + JSON.stringify(data))
...@@ -679,7 +682,10 @@ export default function abilityTest() { ...@@ -679,7 +682,10 @@ export default function abilityTest() {
}, 2500) }, 2500)
} }
}) })
}) }).catch(() => {
console.info("===ACTS_AddAbilityMonitor_1000===data succeed.");
expect(false).assertTrue();
});
}) })
}) })
} }
......
...@@ -35,9 +35,9 @@ export default function abilityTest() { ...@@ -35,9 +35,9 @@ export default function abilityTest() {
abilityDelegator.getCurrentTopAbility((err, data)=>{ abilityDelegator.getCurrentTopAbility((err, data)=>{
console.debug("====>getCurrentTopAbility_0200 err:" + JSON.stringify(err) + " data:" + JSON.stringify(data)); console.debug("====>getCurrentTopAbility_0200 err:" + JSON.stringify(err) + " data:" + JSON.stringify(data));
ability = data; ability = data;
abilityDelegator.doAbilityBackground(ability, (err, isBackground)=>{ abilityDelegator.doAbilityBackground(ability, (err)=>{
console.debug("====>doAbilityBackground_0200 data:" + JSON.stringify(isBackground)); console.debug("====>doAbilityBackground_0200 data:" + JSON.stringify(err));
expect(isBackground).assertTrue(); expect(err.code).assertEqual(0);
}) })
}) })
} }
...@@ -98,9 +98,9 @@ export default function abilityTest() { ...@@ -98,9 +98,9 @@ export default function abilityTest() {
expect(state).assertEqual(AbilityDelegatorRegistry.AbilityLifecycleState.FOREGROUND); expect(state).assertEqual(AbilityDelegatorRegistry.AbilityLifecycleState.FOREGROUND);
expect(state != AbilityDelegatorRegistry.AbilityLifecycleState.CREATE).assertTrue() expect(state != AbilityDelegatorRegistry.AbilityLifecycleState.CREATE).assertTrue()
expect(state != AbilityDelegatorRegistry.AbilityLifecycleState.DESTROY).assertTrue() expect(state != AbilityDelegatorRegistry.AbilityLifecycleState.DESTROY).assertTrue()
abilityDelegator.doAbilityBackground(ability, (err, isBackground)=>{ abilityDelegator.doAbilityBackground(ability, (err)=>{
console.debug("====>doAbilityBackground_0300 data:" + JSON.stringify(isBackground)); console.debug("====>doAbilityBackground_0300 data:" + JSON.stringify(err));
expect(isBackground).assertTrue(); expect(err.code).assertEqual(0);
console.debug("====>ACTS_GetAbilityState_0300 end===="); console.debug("====>ACTS_GetAbilityState_0300 end====");
flag=false; flag=false;
done(); done();
......
...@@ -54,9 +54,9 @@ export default function abilityTest() { ...@@ -54,9 +54,9 @@ export default function abilityTest() {
function SubscribeCallBack(err, data) { function SubscribeCallBack(err, data) {
expect(data.event == "ACTS_DoAbility_Event").assertTrue(); expect(data.event == "ACTS_DoAbility_Event").assertTrue();
console.log("====>0100 Subscribe CallBack data:====>" + JSON.stringify(data)); console.log("====>0100 Subscribe CallBack data:====>" + JSON.stringify(data));
globalThis.abilitydelegator.doAbilityForeground(ability, (err, data) => { globalThis.abilitydelegator.doAbilityForeground(ability, (err) => {
console.log("====>ACTS_DoAbilityForeground_0100 data:====>" + JSON.stringify(data)); console.log("====>ACTS_DoAbilityForeground_0100 data:====>" + JSON.stringify(err));
expect(data).assertEqual(true); expect(err.code).assertEqual(0);
setTimeout(() => { setTimeout(() => {
var num = globalThis.abilitydelegator.getAbilityState(ability) var num = globalThis.abilitydelegator.getAbilityState(ability)
console.log("====>ACTS_DoAbilityForeground_0100 getAbilityState:====>" + JSON.stringify(num)); console.log("====>ACTS_DoAbilityForeground_0100 getAbilityState:====>" + JSON.stringify(num));
...@@ -108,9 +108,9 @@ export default function abilityTest() { ...@@ -108,9 +108,9 @@ export default function abilityTest() {
ability = data ability = data
expect(JSON.stringify(data) == JSON.stringify(mainability)).assertTrue(); expect(JSON.stringify(data) == JSON.stringify(mainability)).assertTrue();
console.log("====>getCurrentTopAbility ability data:====>" + JSON.stringify(ability)); console.log("====>getCurrentTopAbility ability data:====>" + JSON.stringify(ability));
globalThis.abilitydelegator.doAbilityForeground(ability, (err, data) => { globalThis.abilitydelegator.doAbilityForeground(ability, (err) => {
console.log("====>ACTS_DoAbilityForeground_0200 data:====>" + JSON.stringify(data)); console.log("====>ACTS_DoAbilityForeground_0200 data:====>" + JSON.stringify(err));
expect(data).assertEqual(true); expect(err.code).assertEqual(0);
setTimeout(() => { setTimeout(() => {
var num = globalThis.abilitydelegator.getAbilityState(ability) var num = globalThis.abilitydelegator.getAbilityState(ability)
console.log("====>ACTS_DoAbilityForeground_0200 getAbilityState:====>" + JSON.stringify(num)); console.log("====>ACTS_DoAbilityForeground_0200 getAbilityState:====>" + JSON.stringify(num));
...@@ -143,9 +143,9 @@ export default function abilityTest() { ...@@ -143,9 +143,9 @@ export default function abilityTest() {
function SubscribeCallBack(err, data) { function SubscribeCallBack(err, data) {
expect(data.event == "ACTS_DoAbility_Event").assertTrue(); expect(data.event == "ACTS_DoAbility_Event").assertTrue();
console.log("====>0400 Subscribe CallBack data:====>" + JSON.stringify(data)); console.log("====>0400 Subscribe CallBack data:====>" + JSON.stringify(data));
globalThis.abilitydelegator.doAbilityForeground(ability).then((data) => { globalThis.abilitydelegator.doAbilityForeground(ability).then(() => {
console.log("====>ACTS_DoAbilityForeground_0400 data:====>" + JSON.stringify(data)); console.log("====>ACTS_DoAbilityForeground_0400 data:====>");
expect(data).assertEqual(true); expect(true).assertTrue();
setTimeout(() => { setTimeout(() => {
var num = globalThis.abilitydelegator.getAbilityState(ability) var num = globalThis.abilitydelegator.getAbilityState(ability)
console.log("====>ACTS_DoAbilityForeground_0400 getAbilityState:====>" + JSON.stringify(num)); console.log("====>ACTS_DoAbilityForeground_0400 getAbilityState:====>" + JSON.stringify(num));
...@@ -198,9 +198,9 @@ export default function abilityTest() { ...@@ -198,9 +198,9 @@ export default function abilityTest() {
console.log("====>getCurrentTopAbility mainability:====>" + JSON.stringify(mainability)); console.log("====>getCurrentTopAbility mainability:====>" + JSON.stringify(mainability));
expect(JSON.stringify(data) == JSON.stringify(mainability)).assertTrue(); expect(JSON.stringify(data) == JSON.stringify(mainability)).assertTrue();
console.log("====>getCurrentTopAbility ability data:====>" + JSON.stringify(ability)); console.log("====>getCurrentTopAbility ability data:====>" + JSON.stringify(ability));
globalThis.abilitydelegator.doAbilityForeground(ability).then((data) => { globalThis.abilitydelegator.doAbilityForeground(ability).then(() => {
console.log("====>ACTS_DoAbilityForeground_0500 data:====>" + JSON.stringify(data)); console.log("====>ACTS_DoAbilityForeground_0500 data:====>");
expect(data).assertEqual(true); expect(true).assertTrue();
setTimeout(() => { setTimeout(() => {
var num = globalThis.abilitydelegator.getAbilityState(ability) var num = globalThis.abilitydelegator.getAbilityState(ability)
console.log("====>ACTS_DoAbilityForeground_0500 getAbilityState:====>" + JSON.stringify(num)); console.log("====>ACTS_DoAbilityForeground_0500 getAbilityState:====>" + JSON.stringify(num));
...@@ -235,9 +235,9 @@ export default function abilityTest() { ...@@ -235,9 +235,9 @@ export default function abilityTest() {
console.log("====>0100 Subscribe CallBack data:====>" + JSON.stringify(data)); console.log("====>0100 Subscribe CallBack data:====>" + JSON.stringify(data));
globalThis.abilitydelegator.getCurrentTopAbility().then((ability) => { globalThis.abilitydelegator.getCurrentTopAbility().then((ability) => {
console.log("====>getCurrentTopAbility ability data:====>" + JSON.stringify(ability)); console.log("====>getCurrentTopAbility ability data:====>" + JSON.stringify(ability));
globalThis.abilitydelegator.doAbilityBackground(ability, (err, data1) => { globalThis.abilitydelegator.doAbilityBackground(ability, (err) => {
console.log("====>ACTS_DoAbilityBackground_0100 data:====>" + JSON.stringify(data1)); console.log("====>ACTS_DoAbilityBackground_0100 data:====>");
expect(data1).assertEqual(true); expect(err.code).assertEqual(0);
setTimeout(() => { setTimeout(() => {
var num = globalThis.abilitydelegator.getAbilityState(ability) var num = globalThis.abilitydelegator.getAbilityState(ability)
console.log("====>ACTS_DoAbilityBackground_0100 getAbilityState:====>" + JSON.stringify(num)); console.log("====>ACTS_DoAbilityBackground_0100 getAbilityState:====>" + JSON.stringify(num));
...@@ -296,9 +296,9 @@ export default function abilityTest() { ...@@ -296,9 +296,9 @@ export default function abilityTest() {
console.log("====>0500 Subscribe CallBack data:====>" + JSON.stringify(data)); console.log("====>0500 Subscribe CallBack data:====>" + JSON.stringify(data));
globalThis.abilitydelegator.getCurrentTopAbility().then((ability2) => { globalThis.abilitydelegator.getCurrentTopAbility().then((ability2) => {
console.log("====>getCurrentTopAbility ability2 data:====>" + JSON.stringify(ability2)); console.log("====>getCurrentTopAbility ability2 data:====>" + JSON.stringify(ability2));
globalThis.abilitydelegator.doAbilityBackground(ability2).then((data1) => { globalThis.abilitydelegator.doAbilityBackground(ability2).then(() => {
console.log("====>ACTS_DoAbilityBackground_0500 data:====>" + JSON.stringify(data1)); console.log("====>ACTS_DoAbilityBackground_0500 data:====>");
expect(data1).assertEqual(true); expect(true).assertTrue();
setTimeout(() => { setTimeout(() => {
var num = globalThis.abilitydelegator.getAbilityState(ability2) var num = globalThis.abilitydelegator.getAbilityState(ability2)
console.log("====>ACTS_DoAbilityBackground_0500 getAbilityState:====>" + JSON.stringify(num)); console.log("====>ACTS_DoAbilityBackground_0500 getAbilityState:====>" + JSON.stringify(num));
...@@ -357,32 +357,32 @@ export default function abilityTest() { ...@@ -357,32 +357,32 @@ export default function abilityTest() {
globalThis.abilitydelegator.getCurrentTopAbility().then((ability2) => { globalThis.abilitydelegator.getCurrentTopAbility().then((ability2) => {
console.log("====>getCurrentTopAbility ability2 data:====>" + JSON.stringify(ability2)); console.log("====>getCurrentTopAbility ability2 data:====>" + JSON.stringify(ability2));
console.log("====>0700newabilityname:====>" + JSON.stringify(ability2.context.abilityInfo.name)); console.log("====>0700newabilityname:====>" + JSON.stringify(ability2.context.abilityInfo.name));
globalThis.abilitydelegator.doAbilityBackground(ability2).then((data1) => { globalThis.abilitydelegator.doAbilityBackground(ability2).then(() => {
console.log("====>doAbilityBackground data1:====>" + JSON.stringify(data1)); console.log("====>doAbilityBackground data1:====>");
expect(data1).assertEqual(true); expect(true).assertTrue();
setTimeout(() => { setTimeout(() => {
num1 = globalThis.abilitydelegator.getAbilityState(ability2) num1 = globalThis.abilitydelegator.getAbilityState(ability2)
console.log("====>ACTS_DoAbilityBackground_0700 getAbilityState1:====>" + " " + JSON.stringify(num1)); console.log("====>ACTS_DoAbilityBackground_0700 getAbilityState1:====>" + " " + JSON.stringify(num1));
expect(num1).assertEqual(3); expect(num1).assertEqual(3);
globalThis.abilitydelegator.doAbilityForeground(ability2, (err, data) => { globalThis.abilitydelegator.doAbilityForeground(ability2, (err) => {
console.log("====>doAbilityForeground data:====>" + JSON.stringify(data)); console.log("====>doAbilityForeground data:====>" + JSON.stringify(err));
expect(data).assertEqual(true); expect(err.code).assertEqual(0);
setTimeout(() => { setTimeout(() => {
num2 = globalThis.abilitydelegator.getAbilityState(ability2) num2 = globalThis.abilitydelegator.getAbilityState(ability2)
console.log("====>ACTS_DoAbilityBackground_0700 getAbilityState2:====>" + console.log("====>ACTS_DoAbilityBackground_0700 getAbilityState2:====>" +
" " + JSON.stringify(num2)); " " + JSON.stringify(num2));
expect(num2).assertEqual(2); expect(num2).assertEqual(2);
globalThis.abilitydelegator.doAbilityBackground(ability2).then((data1) => { globalThis.abilitydelegator.doAbilityBackground(ability2).then(() => {
console.log("====>doAbilityBackground data1:====>" + JSON.stringify(data1)); console.log("====>doAbilityBackground data1:====>");
expect(data1).assertEqual(true); expect(true).assertTrue();
setTimeout(() => { setTimeout(() => {
num1 = globalThis.abilitydelegator.getAbilityState(ability2) num1 = globalThis.abilitydelegator.getAbilityState(ability2)
console.log("====>ACTS_DoAbilityBackground_0700 getAbilityState1:====>" + console.log("====>ACTS_DoAbilityBackground_0700 getAbilityState1:====>" +
" " + JSON.stringify(num1)); " " + JSON.stringify(num1));
expect(num1).assertEqual(3); expect(num1).assertEqual(3);
globalThis.abilitydelegator.doAbilityForeground(ability2, (err, data) => { globalThis.abilitydelegator.doAbilityForeground(ability2, (err) => {
console.log("====>doAbilityForeground data:====>" + JSON.stringify(data)); console.log("====>doAbilityForeground data:====>");
expect(data).assertEqual(true); expect(err.code).assertEqual(0);
setTimeout(() => { setTimeout(() => {
num2 = globalThis.abilitydelegator.getAbilityState(ability2) num2 = globalThis.abilitydelegator.getAbilityState(ability2)
console.log("====>ACTS_DoAbilityBackground_0700 getAbilityState2:====>" + console.log("====>ACTS_DoAbilityBackground_0700 getAbilityState2:====>" +
...@@ -448,32 +448,32 @@ export default function abilityTest() { ...@@ -448,32 +448,32 @@ export default function abilityTest() {
globalThis.abilitydelegator.getCurrentTopAbility().then((ability2) => { globalThis.abilitydelegator.getCurrentTopAbility().then((ability2) => {
console.log("====>getCurrentTopAbility ability2 data:====>" + JSON.stringify(ability2)); console.log("====>getCurrentTopAbility ability2 data:====>" + JSON.stringify(ability2));
console.log("====>0800newabilityname:====>" + JSON.stringify(ability2.context.abilityInfo.name)); console.log("====>0800newabilityname:====>" + JSON.stringify(ability2.context.abilityInfo.name));
globalThis.abilitydelegator.doAbilityBackground(ability2, (err, data1) => { globalThis.abilitydelegator.doAbilityBackground(ability2, (err) => {
console.log("====>doAbilityBackground data1:====>" + JSON.stringify(data1)); console.log("====>doAbilityBackground data1:====>" + JSON.stringify(err));
expect(data1).assertEqual(true); expect(err.code).assertEqual(0);
setTimeout(() => { setTimeout(() => {
num1 = globalThis.abilitydelegator.getAbilityState(ability2) num1 = globalThis.abilitydelegator.getAbilityState(ability2)
console.log("====>ACTS_DoAbilityBackground_0800 getAbilityState1:====>" + " " + JSON.stringify(num1)); console.log("====>ACTS_DoAbilityBackground_0800 getAbilityState1:====>" + " " + JSON.stringify(num1));
expect(num1).assertEqual(3); expect(num1).assertEqual(3);
globalThis.abilitydelegator.doAbilityForeground(ability2).then((data) => { globalThis.abilitydelegator.doAbilityForeground(ability2).then(() => {
console.log("====>doAbilityForeground data:====>" + JSON.stringify(data)); console.log("====>doAbilityForeground data:====>");
expect(data).assertEqual(true); expect(true).assertTrue();
setTimeout(() => { setTimeout(() => {
num2 = globalThis.abilitydelegator.getAbilityState(ability2) num2 = globalThis.abilitydelegator.getAbilityState(ability2)
console.log("====>ACTS_DoAbilityBackground_0800 getAbilityState2:====>" + console.log("====>ACTS_DoAbilityBackground_0800 getAbilityState2:====>" +
" " + JSON.stringify(num2)); " " + JSON.stringify(num2));
expect(num2).assertEqual(2); expect(num2).assertEqual(2);
globalThis.abilitydelegator.doAbilityBackground(ability2, (err, data1) => { globalThis.abilitydelegator.doAbilityBackground(ability2, (err) => {
console.log("====>doAbilityBackground data1:====>" + JSON.stringify(data1)); console.log("====>doAbilityBackground data1:====>" + JSON.stringify(err));
expect(data1).assertEqual(true); expect(err.code).assertEqual(0);
setTimeout(() => { setTimeout(() => {
num1 = globalThis.abilitydelegator.getAbilityState(ability2) num1 = globalThis.abilitydelegator.getAbilityState(ability2)
console.log("====>ACTS_DoAbilityBackground_0800 getAbilityState1:====>" + console.log("====>ACTS_DoAbilityBackground_0800 getAbilityState1:====>" +
" " + JSON.stringify(num1)); " " + JSON.stringify(num1));
expect(num1).assertEqual(3); expect(num1).assertEqual(3);
globalThis.abilitydelegator.doAbilityForeground(ability2).then((data) => { globalThis.abilitydelegator.doAbilityForeground(ability2).then(() => {
console.log("====>doAbilityForeground data:====>" + JSON.stringify(data)); console.log("====>doAbilityForeground data:====>");
expect(data).assertEqual(true); expect(true).assertTrue();
setTimeout(() => { setTimeout(() => {
num2 = globalThis.abilitydelegator.getAbilityState(ability2) num2 = globalThis.abilitydelegator.getAbilityState(ability2)
console.log("====>ACTS_DoAbilityBackground_0800 getAbilityState2:====>" + console.log("====>ACTS_DoAbilityBackground_0800 getAbilityState2:====>" +
...@@ -538,9 +538,9 @@ export default function abilityTest() { ...@@ -538,9 +538,9 @@ export default function abilityTest() {
console.log("====>0300 Subscribe CallBack globalThis.ability3:====>" + JSON.stringify(globalThis.ability3)); console.log("====>0300 Subscribe CallBack globalThis.ability3:====>" + JSON.stringify(globalThis.ability3));
console.log("====>0300 ability3 name:====>" + JSON.stringify(globalThis.ability3.context.abilityInfo.name)); console.log("====>0300 ability3 name:====>" + JSON.stringify(globalThis.ability3.context.abilityInfo.name));
setTimeout(() => { setTimeout(() => {
result = globalThis.abilitydelegator.doAbilityForeground(globalThis.ability3, (err, data) => { result = globalThis.abilitydelegator.doAbilityForeground(globalThis.ability3, (err) => {
console.log("====>ACTS_DoAbilityForeground_0300 data:====>" + JSON.stringify(data)); console.log("====>ACTS_DoAbilityForeground_0300 data:====>" + JSON.stringify(err));
expect().assertFail(); expect(err.code).assertEqual(0);
}) })
console.log("====>0300 result:====>" + JSON.stringify(result)); console.log("====>0300 result:====>" + JSON.stringify(result));
expect(result).assertEqual(undefined); expect(result).assertEqual(undefined);
...@@ -645,9 +645,9 @@ export default function abilityTest() { ...@@ -645,9 +645,9 @@ export default function abilityTest() {
expect(data.event == "ACTS_DoAbility_Event").assertTrue(); expect(data.event == "ACTS_DoAbility_Event").assertTrue();
console.log("====>0300 Subscribe CallBack data:====>" + JSON.stringify(data)); console.log("====>0300 Subscribe CallBack data:====>" + JSON.stringify(data));
setTimeout(() => { setTimeout(() => {
result = globalThis.abilitydelegator.doAbilityBackground(globalThis.ability3, (err, data) => { result = globalThis.abilitydelegator.doAbilityBackground(globalThis.ability3, (err) => {
console.log("====>ACTS_DoAbilityBackground_0300 data:====>" + JSON.stringify(data)); console.log("====>ACTS_DoAbilityBackground_0300 data:====>" + JSON.stringify(err));
expect().assertFail(); expect(err.code).assertEqual(0);
}) })
console.log("====>DoAbilityBackground0300 result:====>" + JSON.stringify(result)); console.log("====>DoAbilityBackground0300 result:====>" + JSON.stringify(result));
expect(result).assertEqual(undefined); expect(result).assertEqual(undefined);
......
...@@ -132,14 +132,14 @@ export default function startAbilityTest(abilityContext) { ...@@ -132,14 +132,14 @@ export default function startAbilityTest(abilityContext) {
}); });
async function abilityForeground(tag) { async function abilityForeground(tag) {
globalThis.delegator.doAbilityForeground(globalThis.ability, (err: any, data: any) => { globalThis.delegator.doAbilityForeground(globalThis.ability, (err: any) => {
console.info(tag + "doAbilityForeground err: " + JSON.stringify(err) + ", data: " + JSON.stringify(data)); console.info(tag + "doAbilityForeground err: " + JSON.stringify(err));
}); });
} }
async function abilityBackground(tag) { async function abilityBackground(tag) {
globalThis.delegator.doAbilityBackground(globalThis.ability, (err: any, data: any) => { globalThis.delegator.doAbilityBackground(globalThis.ability, (err: any) => {
console.info(tag + "abilityBackground err: " + JSON.stringify(err) + ", data: " + JSON.stringify(data)); console.info(tag + "abilityBackground err: " + JSON.stringify(err));
}); });
} }
......
...@@ -87,8 +87,8 @@ export default function startAbilityTest(abilityContext) { ...@@ -87,8 +87,8 @@ export default function startAbilityTest(abilityContext) {
}); });
async function abilityForeground(tag) { async function abilityForeground(tag) {
globalThis.delegator.doAbilityForeground(globalThis.ability, (err: any, data: any) => { globalThis.delegator.doAbilityForeground(globalThis.ability, (err: any) => {
console.info(tag + "doAbilityForeground err:" + JSON.stringify(err) + ", data:" + JSON.stringify(data)); console.info(tag + "doAbilityForeground err:" + JSON.stringify(err));
}); });
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册