提交 09aaa0db 编写于 作者: H HuangXW

XTS ServiceAbilityTest用例修改

Change-Id: I690725a7ba5e5a0be27a0f996330ee6cf1d653c5
Signed-off-by: NHuangXW <huangxinwei4@huawei.com>
上级 f9c07c93
...@@ -377,17 +377,19 @@ describe('ActsStServiceAbilityTest', function () { ...@@ -377,17 +377,19 @@ describe('ActsStServiceAbilityTest', function () {
+ ("json err【") + JSON.stringify(err) + ("") + ("json err【") + JSON.stringify(err) + ("")
+ ("json data【") + JSON.stringify(data) + ("") + ("json data【") + JSON.stringify(data) + ("")
+ " ,err=" + err + " ,data=" + data); + " ,err=" + err + " ,data=" + data);
if (data.event != "ACTS_SerivceAbilityServer_onDisConnect") { if (data.event == "ACTS_SerivceAbilityServer_onConnect_PageConnectService_0500") {
expect("ACTS_SerivceAbilityServer_onConnect_PageConnectService_0500").assertEqual( console.info("ACTS_JsServiceAbility_0500 disconnnectAbility start")
data.event); featureAbility.disconnectAbility(mConnIdJsPromise).then((err) => {
featureAbility.disconnectAbility(mConnIdJsPromise).then(() => { console.debug("=ACTS_JsServiceAbility_0500 disconnectAbility err====>"
+ ("json err=") + JSON.stringify(err));
}).catch(err => { }).catch(err => {
expect(".catch").assertEqual(err); expect().assertFail()
console.debug('ACTS_JsServiceAbility_0500====<end .catch(err)'); console.debug('ACTS_JsServiceAbility_0500==== err: ' + JSON.stringify(err));
done(); done()
}) })
} else { } else {
expect("ACTS_SerivceAbilityServer_onDisConnect").assertEqual(data.event); expect("ACTS_SerivceAbilityServer_onDisConnect_PageConnectService_0500")
.assertEqual(data.event);
unsubscribe("ACTS_JsServiceAbility_0500_unsubscribe", subscriber0500); unsubscribe("ACTS_JsServiceAbility_0500_unsubscribe", subscriber0500);
console.debug('ACTS_JsServiceAbility_0500====<end'); console.debug('ACTS_JsServiceAbility_0500====<end');
done(); done();
......
...@@ -49,6 +49,15 @@ class StubTest extends rpc.RemoteObject { ...@@ -49,6 +49,15 @@ class StubTest extends rpc.RemoteObject {
} }
} }
function sleep(delay) {
let start = new Date().getTime();
while (true) {
if (new Date().getTime() - start > delay) {
break;
}
}
}
export default { export default {
onStart(want) { onStart(want) {
console.debug('ACTS_SerivceAbilityServer 0425 ====>onStart .ts 0851 =' console.debug('ACTS_SerivceAbilityServer 0425 ====>onStart .ts 0851 ='
...@@ -58,11 +67,6 @@ export default { ...@@ -58,11 +67,6 @@ export default {
onStop() { onStop() {
console.debug('ACTS_SerivceAbilityServer ====<onStop'); console.debug('ACTS_SerivceAbilityServer ====<onStop');
commonEvent.publish("ACTS_SerivceAbilityServer_onStop", (err) => { }); commonEvent.publish("ACTS_SerivceAbilityServer_onStop", (err) => { });
particleAbility.terminateSelf().then((data) => {
console.log('ACTS_SerivceAbilityServer terminateSelf data:' + JSON.stringify(data));
}).catch((error) => {
console.log('ACTS_SerivceAbilityServer terminateSelf error:' + JSON.stringify(error));
});
}, },
onCommand(want, restart, startId) { onCommand(want, restart, startId) {
console.debug('ACTS_SerivceAbilityServer ====>onCommand=' console.debug('ACTS_SerivceAbilityServer ====>onCommand='
...@@ -79,11 +83,7 @@ export default { ...@@ -79,11 +83,7 @@ export default {
}, },
} }
); );
particleAbility.terminateSelf().then((data) => { sleep(600)
console.log('ACTS_SerivceAbilityServer terminateSelf data:' + JSON.stringify(data));
}).catch((error) => {
console.log('ACTS_SerivceAbilityServer terminateSelf error:' + JSON.stringify(error));
});
} else if (want.action == 'ServiceStartService_1000') { } else if (want.action == 'ServiceStartService_1000') {
particleAbility.startAbility( particleAbility.startAbility(
{ {
...@@ -96,11 +96,6 @@ export default { ...@@ -96,11 +96,6 @@ export default {
}, (err, data) => { }, (err, data) => {
console.debug('ACTS_SerivceAbilityServer start Ability 1000 callback=====' console.debug('ACTS_SerivceAbilityServer start Ability 1000 callback====='
+ err + ', data= ' + data + " , JSON." + JSON.stringify(data)); + err + ', data= ' + data + " , JSON." + JSON.stringify(data));
particleAbility.terminateSelf().then((data) => {
console.log('ACTS_SerivceAbilityServer terminateSelf data:' + JSON.stringify(data));
}).catch((error) => {
console.log('ACTS_SerivceAbilityServer terminateSelf error:' + JSON.stringify(error));
});
} }
); );
} else { } else {
...@@ -108,13 +103,8 @@ export default { ...@@ -108,13 +103,8 @@ export default {
if (!err.code) { if (!err.code) {
if (want.action == 'PageStartService_0100' || want.action == 'PageStartService_0200' if (want.action == 'PageStartService_0100' || want.action == 'PageStartService_0200'
|| want.action == 'PageStartService_0301' || want.action == 'PageStartService_0401') { || want.action == 'PageStartService_0301' || want.action == 'PageStartService_0401') {
console.debug('ACTS_SerivceAbilityServer_onCommand 100 200 301 401.terminateSelf()=====>' console.debug('ACTS_SerivceAbilityServer_onCommand 100 200 301 401.=====>'
+ want.action); + want.action);
particleAbility.terminateSelf().then((data) => {
console.log('ACTS_SerivceAbilityServer terminateSelf data:' + JSON.stringify(data));
}).catch((error) => {
console.log('ACTS_SerivceAbilityServer terminateSelf error:' + JSON.stringify(error));
});
} }
} else { } else {
console.debug('ACTS_SerivceAbilityServer_onCommand publish err=====>' + err); console.debug('ACTS_SerivceAbilityServer_onCommand publish err=====>' + err);
...@@ -169,11 +159,11 @@ export default { ...@@ -169,11 +159,11 @@ export default {
onDisconnect(want) { onDisconnect(want) {
console.debug('ACTS_SerivceAbilityServer ====>onDisConnect=' console.debug('ACTS_SerivceAbilityServer ====>onDisConnect='
+ want + " , JSON." + JSON.stringify(want)); + want + " , JSON." + JSON.stringify(want));
commonEvent.publish("ACTS_SerivceAbilityServer_onDisConnect", (err) => { commonEvent.publish("ACTS_SerivceAbilityServer_onDisConnect" + want.action, (err) => {
if (err.code) { if (err.code) {
console.debug('ACTS_SerivceAbilityServer_onDisConnect publish err=====>' + err); console.debug('ACTS_SerivceAbilityServer_onDisConnect publish err=====>' + err);
} else { } else {
console.debug('ACTS_SerivceAbilityServer_onDisConnect featureAbility.terminateSelf()=====<' console.debug('ACTS_SerivceAbilityServer_onDisConnect =====<'
+ want.action); + want.action);
if (want.action == 'ServiceConnectService_1300' || want.action == 'ServiceConnectService_1400' if (want.action == 'ServiceConnectService_1300' || want.action == 'ServiceConnectService_1400'
|| want.action == 'ServiceConnectService_1500' || want.action == 'ServiceConnectService_1501' || want.action == 'ServiceConnectService_1500' || want.action == 'ServiceConnectService_1501'
...@@ -184,11 +174,6 @@ export default { ...@@ -184,11 +174,6 @@ export default {
+ ("json err=") + JSON.stringify(err) + " , " + want.action); + ("json err=") + JSON.stringify(err) + " , " + want.action);
}) })
} }
particleAbility.terminateSelf().then((data) => {
console.log('ACTS_SerivceAbilityServer terminateSelf data:' + JSON.stringify(data));
}).catch((error) => {
console.log('ACTS_SerivceAbilityServer terminateSelf error:' + JSON.stringify(error));
});
} }
}); });
}, },
......
...@@ -49,6 +49,15 @@ class StubTest extends rpc.RemoteObject { ...@@ -49,6 +49,15 @@ class StubTest extends rpc.RemoteObject {
} }
} }
function sleep(delay) {
let start = new Date().getTime();
while (true) {
if (new Date().getTime() - start > delay) {
break;
}
}
}
export default { export default {
onStart(want) { onStart(want) {
console.debug('ACTS_SerivceAbilityServerSecond ====>onStart=' console.debug('ACTS_SerivceAbilityServerSecond ====>onStart='
...@@ -58,22 +67,16 @@ export default { ...@@ -58,22 +67,16 @@ export default {
onStop() { onStop() {
console.debug('ACTS_SerivceAbilityServerSecond ====<onStop'); console.debug('ACTS_SerivceAbilityServerSecond ====<onStop');
commonEvent.publish("ACTS_SerivceAbilityServerSecond_onStop", (err) => { }); commonEvent.publish("ACTS_SerivceAbilityServerSecond_onStop", (err) => { });
particleAbility.terminateSelf().then((data) => {
console.log('ACTS_SerivceAbilityServer terminateSelf data:' + JSON.stringify(data));
}).catch((error) => {
console.log('ACTS_SerivceAbilityServer terminateSelf error:' + JSON.stringify(error));
});
}, },
onCommand(want, restart, startId) { onCommand(want, restart, startId) {
console.debug('ACTS_SerivceAbilityServerSecond ====>onCommand=' console.debug('ACTS_SerivceAbilityServerSecond ====>onCommand='
+ "JSON(want)=" + JSON.stringify(want) + "JSON(want)=" + JSON.stringify(want)
+ " ,restart=" + restart + " ,startId=" + startId); + " ,restart=" + restart + " ,startId=" + startId);
commonEvent.publish("ACTS_SerivceAbilityServerSecond_onCommand" + "_" + want.action, (err) => { }); commonEvent.publish("ACTS_SerivceAbilityServerSecond_onCommand" + "_" + want.action, (err) => {
particleAbility.terminateSelf().then((data) => { console.debug("ACTS_SerivceAbilityServerSecond_onCommand" + "_" + want.action +
console.log('ACTS_SerivceAbilityServer terminateSelf data:' + JSON.stringify(data)); "err: " + JSON.stringify(err))
}).catch((error) => {
console.log('ACTS_SerivceAbilityServer terminateSelf error:' + JSON.stringify(error));
}); });
sleep(500)
}, },
onConnect(want) { onConnect(want) {
console.info('ACTS_SerivceAbilityServerSecond ====< onConnect'); console.info('ACTS_SerivceAbilityServerSecond ====< onConnect');
...@@ -158,7 +161,7 @@ export default { ...@@ -158,7 +161,7 @@ export default {
if (err.code) { if (err.code) {
console.debug('ACTS_SerivceAbilityServerSecond_onDisConnect publish err=====>' + err); console.debug('ACTS_SerivceAbilityServerSecond_onDisConnect publish err=====>' + err);
} else { } else {
console.debug('ACTS_SerivceAbilityServerSecond_onDisConnect featureAbility.terminateSelf()=====<' console.debug('ACTS_SerivceAbilityServerSecond_onDisConnect =====<'
+ want.action); + want.action);
if (want.action == 'ServiceConnectService_1500' || want.action == 'ServiceConnectService_1501' if (want.action == 'ServiceConnectService_1500' || want.action == 'ServiceConnectService_1501'
|| want.action == 'ServiceConnectService_1600' || want.action == 'ServiceConnectService_1601' || want.action == 'ServiceConnectService_1600' || want.action == 'ServiceConnectService_1601'
...@@ -168,11 +171,6 @@ export default { ...@@ -168,11 +171,6 @@ export default {
+ ("json err=") + JSON.stringify(err) + " , " + want.action); + ("json err=") + JSON.stringify(err) + " , " + want.action);
}) })
} }
particleAbility.terminateSelf().then((data) => {
console.log('ACTS_SerivceAbilityServer terminateSelf data:' + JSON.stringify(data));
}).catch((error) => {
console.log('ACTS_SerivceAbilityServer terminateSelf error:' + JSON.stringify(error));
});
} }
}); });
}, },
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册