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

!7122 doAbilityBackground&doAbilityForeground错误码整改

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