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

!5570 ActsServiceAbilityClientTest测试套用例优化

Merge pull request !5570 from chengxingzhen/cherry-pick-1663732072
...@@ -15,849 +15,813 @@ ...@@ -15,849 +15,813 @@
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
import commonEvent from '@ohos.commonEvent' import commonEvent from '@ohos.commonEvent'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' import { describe, afterEach, it, expect } from '@ohos/hypium'
export default function ActsStServiceAbilityTest() { export default function ActsStServiceAbilityTest() {
describe('ActsStServiceAbilityTest', function () { describe('ActsStServiceAbilityTest', function () {
let bundleName = "com.amsst.stserviceabilityserver"; let bundleName = "com.amsst.stserviceabilityserver";
let abilityName = "com.amsst.stserviceabilityserver.ServiceAbility"; let abilityName = "com.amsst.stserviceabilityserver.ServiceAbility";
var subscriber0100; let subscriber0100;
var CommonEventSubscribeInfo0100 = { let CommonEventSubscribeInfo0100 = {
events: ["ACTS_SerivceAbilityServer_onCommand_PageStartService_0100", events: ["ACTS_SerivceAbilityServer_onCommand_PageStartService_0100",
], ],
}; };
var subscriber0200; let subscriber0200;
var CommonEventSubscribeInfo0200 = { let CommonEventSubscribeInfo0200 = {
events: ["ACTS_SerivceAbilityServer_onCommand_PageStartService_0200", events: ["ACTS_SerivceAbilityServer_onCommand_PageStartService_0200",
], ],
}; };
var subscriber0300; let subscriber0300;
var CommonEventSubscribeInfo0300 = { let CommonEventSubscribeInfo0300 = {
events: ["ACTS_SerivceAbilityServer_onCommand_PageStartService_0300", events: ["ACTS_SerivceAbilityServer_onCommand_PageStartService_0300",
"ACTS_SerivceAbilityServer_onCommand_PageStartService_0301", "ACTS_SerivceAbilityServer_onCommand_PageStartService_0301",
], ],
}; };
var subscriber0400; let subscriber0400;
var CommonEventSubscribeInfo0400 = { let CommonEventSubscribeInfo0400 = {
events: ["ACTS_SerivceAbilityServer_onCommand_PageStartService_0400", events: ["ACTS_SerivceAbilityServer_onCommand_PageStartService_0400",
"ACTS_SerivceAbilityServer_onCommand_PageStartService_0401", "ACTS_SerivceAbilityServer_onCommand_PageStartService_0401",
], ],
}; };
var subscriber0500; let subscriber0500;
var CommonEventSubscribeInfo0500 = { let CommonEventSubscribeInfo0500 = {
events: ["ACTS_SerivceAbilityServer_onConnect_PageConnectService_0500", events: ["ACTS_SerivceAbilityServer_onConnect_PageConnectService_0500",
"ACTS_SerivceAbilityServer_onDisConnect", "ACTS_SerivceAbilityServer_onDisConnect_PageConnectService_0500",
], ],
}; };
var subscriber0600; let subscriber0600;
var CommonEventSubscribeInfo0600 = { let CommonEventSubscribeInfo0600 = {
events: ["ACTS_SerivceAbilityServer_onConnect_PageConnectService_0600", events: ["ACTS_SerivceAbilityServer_onConnect_PageConnectService_0600",
"ACTS_SerivceAbilityServer_onDisConnect", "ACTS_SerivceAbilityServer_onDisConnect_PageConnectService_0600",
], ],
}; };
var subscriber0900; let subscriber0900;
var CommonEventSubscribeInfo0900 = { let CommonEventSubscribeInfo0900 = {
events: ["ACTS_SerivceAbilityServerSecond_onCommand_ServiceStartService_0900", events: ["ACTS_SerivceAbilityServerSecond_onCommand_ServiceStartService_0900",
], ],
}; };
var subscriber1000; let subscriber1000;
var CommonEventSubscribeInfo1000 = { let CommonEventSubscribeInfo1000 = {
events: ["ACTS_SerivceAbilityServerSecond_onCommand_ServiceStartService_1000", events: ["ACTS_SerivceAbilityServerSecond_onCommand_ServiceStartService_1000",
], ],
}; };
var subscriber1300; let subscriber1300;
var CommonEventSubscribeInfo1300 = { let CommonEventSubscribeInfo1300 = {
events: ["ACTS_SerivceAbilityServerSecond_onConnect_ServiceConnectService_1300", events: ["ACTS_SerivceAbilityServerSecond_onConnect_ServiceConnectService_1300",
"ACTS_SerivceAbilityServerSecond_onDisConnect", "ACTS_SerivceAbilityServerSecond_onDisConnect_ServiceConnectService_1300",
], ],
}; };
var subscriber1400; let subscriber1400;
var CommonEventSubscribeInfo1400 = { let CommonEventSubscribeInfo1400 = {
events: ["ACTS_SerivceAbilityServerSecond_onConnect_ServiceConnectService_1400", events: ["ACTS_SerivceAbilityServerSecond_onConnect_ServiceConnectService_1400",
"ACTS_SerivceAbilityServerSecond_onDisConnect", "ACTS_SerivceAbilityServerSecond_onDisConnect_ServiceConnectService_1400",
], ],
}; };
var subscriber1500; let subscriber1500;
var CommonEventSubscribeInfo1500 = { let CommonEventSubscribeInfo1500 = {
events: ["ACTS_SerivceAbilityServerSecond_onConnect_ServiceConnectService_1500", events: ["ACTS_SerivceAbilityServerSecond_onConnect_ServiceConnectService_1500",
"ACTS_SerivceAbilityServer_onDisConnect", "ACTS_SerivceAbilityServer_onDisConnect_ServiceConnectService_1500",
], ],
}; };
function unsubscribe(caller, subscriber) { function unsubscribe(caller, subscriber) {
commonEvent.unsubscribe(subscriber, (err, data) => { commonEvent.unsubscribe(subscriber, (err, data) => {
console.debug("=ACTS_unsubscribe (err,data)=======>" console.debug("=ACTS_unsubscribe (err,data)=======>"
+ (caller) + (caller)
+ (" , json err【") + JSON.stringify(err) + ("") + (" , json err【") + JSON.stringify(err) + ("")
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,err=" + err + " ,data=" + data);
});
}
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
let gSetTimeout = 1000
beforeAll(async (done) => {
console.debug('= ACTS_beforeAll ====<begin');
console.debug('= ACTS_beforeAll ====<end');
done();
})
beforeEach(async (done) => {
setTimeout(function () {
done();
}, gSetTimeout);
})
afterEach(async (done) => {
setTimeout(function () {
done();
}, gSetTimeout);
})
afterAll((done) => {
console.debug('= ACTS_afterAll ====<begin');
setTimeout(function () {
console.debug('= ACTS_afterAll ====<end');
featureAbility.terminateSelf();
done();
}, gSetTimeout);
})
/*
* @tc.number: ACTS_JsServiceAbility_0100
* @tc.name: featureAbility.startAbility : Use page to test startAbiltiy service.
* @tc.desc: Check the return value of the interface (by Promise)
*/
it('ACTS_JsServiceAbility_0100', 0, async function (done) {
console.debug('ACTS_JsServiceAbility_0100====<begin');
try {
await commonEvent.createSubscriber(CommonEventSubscribeInfo0100).then(async (data) => {
console.debug("=ACTS_JsServiceAbility_0100 createSubscriber .then(data)=======>"
+ ("json data【") + JSON.stringify(data) + ("") + ("json data【") + JSON.stringify(data) + ("")
+ " ,data=" + data); + " ,err=" + err + " ,data=" + data);
subscriber0100 = data; });
commonEvent.subscribe(subscriber0100, async (err, data) => {
console.debug("=ACTS_JsServiceAbility_0100 subscribe (err,data)=======>"
+ ("json err【") + JSON.stringify(err) + ("")
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,err=" + err + " ,data=" + data);
expect("ACTS_SerivceAbilityServer_onCommand_PageStartService_0100").assertEqual(
data.event);
unsubscribe("ACTS_JsServiceAbility_0100_unsubscribe", subscriber0100);
console.debug('ACTS_JsServiceAbility_0100====<end');
done();
});
})
featureAbility.startAbility(
{
want:
{
bundleName: bundleName,
abilityName: abilityName,
action: "PageStartService_0100",
},
}
).then(data => {
console.debug("=ACTS_JsServiceAbility_0100 .then(data)=======>"
+ ("abilityStartSetting json data【") + JSON.stringify(data) + ("")
+ " ,data=" + data);
}).catch(err => {
expect(".catch").assertEqual(err);
console.debug('ACTS_JsServiceAbility_0100====<end .catch(err):'+ JSON.stringify(err));
done();
})
} catch (err) {
expect("catch").assertEqual(err);
console.debug('ACTS_JsServiceAbility_0100====<end catch(err)');
done();
} }
}) function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
/*
* @tc.number: ACTS_JsServiceAbility_0200
* @tc.name: featureAbility.startAbility : Use page to test startAbiltiy service.
* @tc.desc: Check the return value of the interface (by AsyncCallback)
*/
it('ACTS_JsServiceAbility_0200', 0, async function (done) {
console.debug('ACTS_JsServiceAbility_0200====<begin');
try {
await commonEvent.createSubscriber(CommonEventSubscribeInfo0200).then(async (data) => {
console.debug("=ACTS_JsServiceAbility_0200 createSubscriber .then(data)=======>"
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,data=" + data);
subscriber0200 = data;
commonEvent.subscribe(subscriber0200, async (err, data) => {
console.debug("=ACTS_JsServiceAbility_0200 subscribe (err,data)=======>"
+ ("json err【") + JSON.stringify(err) + ("")
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,err=" + err + " ,data=" + data);
expect("ACTS_SerivceAbilityServer_onCommand_PageStartService_0200").assertEqual(
data.event);
unsubscribe("ACTS_JsServiceAbility_0200_unsubscribe", subscriber0200);
console.debug('ACTS_JsServiceAbility_0200====<end');
done()
});
})
featureAbility.startAbility(
{
want:
{
bundleName: bundleName,
abilityName: abilityName,
action: "PageStartService_0200",
},
}, (err, data) => {
console.debug("=ACTS_JsServiceAbility_0200 startAbility (err,data)=======>"
+ ("abilityStartSetting json err【") + JSON.stringify(err) + ("")
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,err=" + err + " ,data=" + data);
}
)
} catch (err) {
expect("catch").assertEqual(err);
console.debug('ACTS_JsServiceAbility_0200====<end catch(err)');
done();
} }
}) let gSetTimeout = 2000
afterEach(async (done) => {
setTimeout(function () {
done();
}, gSetTimeout);
})
/* /*
* @tc.number: ACTS_JsServiceAbility_0300 * @tc.number: ACTS_JsServiceAbility_0100
* @tc.name: featureAbility.startAbility : Use page to test startAbiltiy service. * @tc.name: featureAbility.startAbility : Use page to test startAbiltiy service.
* @tc.desc: Check the return value of the interface (by Promise) * @tc.desc: Check the return value of the interface (by Promise)
*/ */
it('ACTS_JsServiceAbility_0300', 0, async function (done) { it('ACTS_JsServiceAbility_0100', 0, async function (done) {
console.debug('ACTS_JsServiceAbility_0300====<begin'); console.debug('ACTS_JsServiceAbility_0100====<begin');
try { try {
await commonEvent.createSubscriber(CommonEventSubscribeInfo0300).then(async (data) => { await commonEvent.createSubscriber(CommonEventSubscribeInfo0100).then((data) => {
console.debug("=ACTS_JsServiceAbility_0300 createSubscriber .then(data)=======>" console.debug("=ACTS_JsServiceAbility_0100 createSubscriber .then(data)=======>"
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,data=" + data);
subscriber0300 = data;
commonEvent.subscribe(subscriber0300, async (err, data) => {
console.debug("=ACTS_JsServiceAbility_0300 subscribe (err,data)=======>"
+ ("json err【") + JSON.stringify(err) + ("")
+ ("json data【") + JSON.stringify(data) + ("") + ("json data【") + JSON.stringify(data) + ("")
+ " ,err=" + err + " ,data=" + data); + " ,data=" + data);
if (data.event == "ACTS_SerivceAbilityServer_onCommand_PageStartService_0300") { subscriber0100 = data;
expect("ACTS_SerivceAbilityServer_onCommand_PageStartService_0300").assertEqual( commonEvent.subscribe(subscriber0100, (err, data) => {
data.event); console.debug("=ACTS_JsServiceAbility_0100 subscribe (err,data)=======>"
featureAbility.startAbility( + ("json err【") + JSON.stringify(err) + ("")
{ + ("json data【") + JSON.stringify(data) + ("")
want: + " ,err=" + err + " ,data=" + data);
{ expect("ACTS_SerivceAbilityServer_onCommand_PageStartService_0100").assertEqual(
bundleName: bundleName,
abilityName: abilityName,
action: "PageStartService_0301",
},
}
).then(data => {
console.debug("=ACTS_JsServiceAbility_0300 .then(data) 2=======>"
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,data=" + data);
}).catch(err => {
expect(".catch").assertEqual(err);
console.debug('ACTS_JsServiceAbility_0300====<end .catch(err) 2');
done();
})
} else {
expect("ACTS_SerivceAbilityServer_onCommand_PageStartService_0301").assertEqual(
data.event); data.event);
unsubscribe("ACTS_JsServiceAbility_0300_unsubscribe", subscriber0300); unsubscribe("ACTS_JsServiceAbility_0100_unsubscribe", subscriber0100);
console.debug('ACTS_JsServiceAbility_0300====<end'); console.debug('ACTS_JsServiceAbility_0100====<end');
done(); done();
} });
}); })
}) featureAbility.startAbility(
featureAbility.startAbility(
{
want:
{ {
bundleName: bundleName, want:
abilityName: abilityName, {
action: "PageStartService_0300", bundleName: bundleName,
}, abilityName: abilityName,
} action: "PageStartService_0100",
).then(data => { },
console.debug("=ACTS_JsServiceAbility_0300 .then(data) 1=======>" }
+ ("json data【") + JSON.stringify(data) + ("") ).then(data => {
+ " ,data=" + data); console.debug("=ACTS_JsServiceAbility_0100 .then(data)=======>"
}).catch(err => { + ("abilityStartSetting json data【") + JSON.stringify(data) + ("")
expect(".catch").assertEqual(err); + " ,data=" + data);
console.debug('ACTS_JsServiceAbility_0300====<end .catch(err) 1'); }).catch(err => {
expect(".catch").assertEqual(err);
console.debug('ACTS_JsServiceAbility_0100====<end .catch(err):' + JSON.stringify(err));
done();
})
} catch (err) {
expect().assertFail()
console.debug('ACTS_JsServiceAbility_0100==== err: ' + JSON.stringify(err));
done(); done();
}) }
} catch (err) { })
expect("catch").assertEqual(err);
console.debug('ACTS_JsServiceAbility_0300====<end catch(err)');
done();
}
})
/* /*
* @tc.number: ACTS_JsServiceAbility_0400 * @tc.number: ACTS_JsServiceAbility_0200
* @tc.name: featureAbility.startAbility : Use page to test startAbiltiy service. * @tc.name: featureAbility.startAbility : Use page to test startAbiltiy service.
* @tc.desc: Check the return value of the interface (by AsyncCallback) * @tc.desc: Check the return value of the interface (by AsyncCallback)
*/ */
it('ACTS_JsServiceAbility_0400', 0, async function (done) { it('ACTS_JsServiceAbility_0200', 0, async function (done) {
console.debug('ACTS_JsServiceAbility_0400====<begin'); console.debug('ACTS_JsServiceAbility_0200====<begin');
try { try {
await commonEvent.createSubscriber(CommonEventSubscribeInfo0400).then(async (data) => { await commonEvent.createSubscriber(CommonEventSubscribeInfo0200).then((data) => {
console.debug("=ACTS_JsServiceAbility_0400 createSubscriber .then(data)=======>" console.debug("=ACTS_JsServiceAbility_0200 createSubscriber .then(data)=======>"
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,data=" + data);
subscriber0400 = data;
commonEvent.subscribe(subscriber0400, async (err, data) => {
console.debug("=ACTS_JsServiceAbility_0400 subscribe (err,data)=======>"
+ ("json err【") + JSON.stringify(err) + ("")
+ ("json data【") + JSON.stringify(data) + ("") + ("json data【") + JSON.stringify(data) + ("")
+ " ,err=" + err + " ,data=" + data); + " ,data=" + data);
if (data.event == "ACTS_SerivceAbilityServer_onCommand_PageStartService_0400") { subscriber0200 = data;
expect("ACTS_SerivceAbilityServer_onCommand_PageStartService_0400").assertEqual( commonEvent.subscribe(subscriber0200, (err, data) => {
console.debug("=ACTS_JsServiceAbility_0200 subscribe (err,data)=======>"
+ ("json err【") + JSON.stringify(err) + ("")
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,err=" + err + " ,data=" + data);
expect("ACTS_SerivceAbilityServer_onCommand_PageStartService_0200").assertEqual(
data.event); data.event);
featureAbility.startAbility( unsubscribe("ACTS_JsServiceAbility_0200_unsubscribe", subscriber0200);
{ console.debug('ACTS_JsServiceAbility_0200====<end');
want: done()
{ });
bundleName: bundleName, })
abilityName: abilityName, featureAbility.startAbility(
action: "PageStartService_0401",
},
}, (err, data) => {
console.debug("=ACTS_JsServiceAbility_0400 startAbility (err,data) 2=======>"
+ ("json err【") + JSON.stringify(err) + ("")
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,err=" + err + " ,data=" + data);
}
)
} else {
expect("ACTS_SerivceAbilityServer_onCommand_PageStartService_0401").assertEqual(
data.event);
unsubscribe("ACTS_JsServiceAbility_0400_unsubscribe", subscriber0400);
console.debug('ACTS_JsServiceAbility_0400====<end');
done();
}
});
})
featureAbility.startAbility(
{
want:
{ {
bundleName: bundleName, want:
abilityName: abilityName, {
action: "PageStartService_0400", bundleName: bundleName,
}, abilityName: abilityName,
}, (err, data) => { action: "PageStartService_0200",
console.debug("=ACTS_JsServiceAbility_0400 startAbility (err,data) 1=======>" },
+ ("json err【") + JSON.stringify(err) + ("") }, (err, data) => {
+ ("json data【") + JSON.stringify(data) + ("") console.debug("=ACTS_JsServiceAbility_0200 startAbility (err,data)=======>"
+ " ,err=" + err + " ,data=" + data); + ("abilityStartSetting json err【") + JSON.stringify(err) + ("")
} + ("json data【") + JSON.stringify(data) + ("")
) + " ,err=" + err + " ,data=" + data);
} catch (err) { }
expect("catch").assertEqual(err); )
console.debug('ACTS_JsServiceAbility_0400====<end catch(err)'); } catch (err) {
done(); expect().assertFail()
} console.debug('ACTS_JsServiceAbility_0200==== err: ' + JSON.stringify(err));
}) done();
}
})
/* /*
* @tc.number: ACTS_JsServiceAbility_0500 * @tc.number: ACTS_JsServiceAbility_0300
* @tc.name: featureAbility.ConnectAbility : Connects an ability to a Service ability. * @tc.name: featureAbility.startAbility : Use page to test startAbiltiy service.
* @tc.desc: Check the return value of the interface (by Promise) * @tc.desc: Check the return value of the interface (by Promise)
*/ */
it('ACTS_JsServiceAbility_0500', 0, async function (done) { it('ACTS_JsServiceAbility_0300', 0, async function (done) {
console.log('ACTS_JsServiceAbility_0500====<begin'); console.debug('ACTS_JsServiceAbility_0300====<begin');
try { try {
var mConnIdJsPromise; await commonEvent.createSubscriber(CommonEventSubscribeInfo0300).then((data) => {
await commonEvent.createSubscriber(CommonEventSubscribeInfo0500).then(async (data) => { console.debug("=ACTS_JsServiceAbility_0300 createSubscriber .then(data)=======>"
console.debug("=ACTS_JsServiceAbility_0500 createSubscriber .then(data)=======>"
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,data=" + data);
subscriber0500 = data;
commonEvent.subscribe(subscriber0500, async (err, data) => {
console.debug("=ACTS_JsServiceAbility_0500 subscribe (err,data)=======>"
+ ("json err【") + JSON.stringify(err) + ("")
+ ("json data【") + JSON.stringify(data) + ("") + ("json data【") + JSON.stringify(data) + ("")
+ " ,err=" + err + " ,data=" + data); + " ,data=" + data);
if (data.event != "ACTS_SerivceAbilityServer_onDisConnect") { subscriber0300 = data;
expect("ACTS_SerivceAbilityServer_onConnect_PageConnectService_0500").assertEqual( commonEvent.subscribe(subscriber0300, (err, data) => {
data.event); console.debug("=ACTS_JsServiceAbility_0300 subscribe (err,data)=======>"
featureAbility.disconnectAbility(mConnIdJsPromise).then(() => { + ("json err【") + JSON.stringify(err) + ("")
}).catch(err => { + ("json data【") + JSON.stringify(data) + ("")
expect(".catch").assertEqual(err); + " ,err=" + err + " ,data=" + data);
console.debug('ACTS_JsServiceAbility_0500====<end .catch(err)'); if (data.event == "ACTS_SerivceAbilityServer_onCommand_PageStartService_0300") {
expect("ACTS_SerivceAbilityServer_onCommand_PageStartService_0300").assertEqual(
data.event);
featureAbility.startAbility(
{
want:
{
bundleName: bundleName,
abilityName: abilityName,
action: "PageStartService_0301",
},
}
).then(data => {
console.debug("=ACTS_JsServiceAbility_0300 .then(data) 2=======>"
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,data=" + data);
}).catch(err => {
expect().assertFail()
console.debug('ACTS_JsServiceAbility_0300==== err: ' + JSON.stringify(err));
done();
})
} else {
expect("ACTS_SerivceAbilityServer_onCommand_PageStartService_0301").assertEqual(
data.event);
unsubscribe("ACTS_JsServiceAbility_0300_unsubscribe", subscriber0300);
console.debug('ACTS_JsServiceAbility_0300====<end');
done(); done();
}) }
} else { });
expect("ACTS_SerivceAbilityServer_onDisConnect").assertEqual(data.event); })
unsubscribe("ACTS_JsServiceAbility_0500_unsubscribe", subscriber0500); featureAbility.startAbility(
console.debug('ACTS_JsServiceAbility_0500====<end'); {
done(); want:
{
bundleName: bundleName,
abilityName: abilityName,
action: "PageStartService_0300",
},
} }
}); ).then(data => {
}) console.debug("=ACTS_JsServiceAbility_0300 .then(data) 1=======>"
function onConnectCallback(element, remote) { + ("json data【") + JSON.stringify(data) + ("")
console.debug('ACTS_JsServiceAbility_0500_onConnectCallback ====> mConnIdJsPromise=' + " ,data=" + data);
+ JSON.stringify(mConnIdJsPromise) + " , " + mConnIdJsPromise); }).catch(err => {
console.debug('ACTS_JsServiceAbility_0500_onConnectCallback ====> element=' expect(".catch").assertEqual(err);
+ JSON.stringify(element) + " , " + element); console.debug('ACTS_JsServiceAbility_0300====<end .catch(err) 1');
console.debug('ACTS_JsServiceAbility_0500_onConnectCallback ====> remote=' done();
+ JSON.stringify(remote) + " , " + remote); })
console.debug('ACTS_JsServiceAbility_0500_onConnectCallback ====> remote is proxy:' } catch (err) {
+ (remote instanceof rpc.RemoteProxy)); expect().assertFail()
} console.debug('ACTS_JsServiceAbility_0300==== err: ' + JSON.stringify(err));
done();
function onDisconnectCallback(element) {
console.debug('ACTS_JsServiceAbility_0500_onDisconnectCallback ====> element='
+ JSON.stringify(element) + " , " + element);
}
function onFailedCallback(code) {
console.debug('ACTS_JsServiceAbility_0500_onFailedCallback ====> code='
+ JSON.stringify(code) + " , " + code)
} }
})
mConnIdJsPromise = featureAbility.connectAbility( /*
{ * @tc.number: ACTS_JsServiceAbility_0400
bundleName: bundleName, * @tc.name: featureAbility.startAbility : Use page to test startAbiltiy service.
abilityName: abilityName, * @tc.desc: Check the return value of the interface (by AsyncCallback)
action: "PageConnectService_0500", */
}, it('ACTS_JsServiceAbility_0400', 0, async function (done) {
{ console.debug('ACTS_JsServiceAbility_0400====<begin');
onConnect: onConnectCallback, try {
onDisconnect: onDisconnectCallback, await commonEvent.createSubscriber(CommonEventSubscribeInfo0400).then((data) => {
onFailed: onFailedCallback, console.debug("=ACTS_JsServiceAbility_0400 createSubscriber .then(data)=======>"
},
)
} catch (err) {
expect("catch").assertEqual(err);
console.log('ACTS_JsServiceAbility_0500====<end err')
done();
}
})
/*
* @tc.number: ACTS_JsServiceAbility_0600
* @tc.name: featureAbility.ConnectAbility : Connects an ability to a Service ability.
* @tc.desc: Check the return value of the interface (by AsyncCallback)
*/
it('ACTS_JsServiceAbility_0600', 0, async function (done) {
console.log('ACTS_JsServiceAbility_0600====<begin');
try {
var currentAlertTimeout;
var mConnIdJsAsyncCallback;
await commonEvent.createSubscriber(CommonEventSubscribeInfo0600).then(async (data) => {
console.debug("=ACTS_JsServiceAbility_0600 createSubscriber .then(data)=======>"
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,data=" + data);
subscriber0600 = data;
commonEvent.subscribe(subscriber0600, async (err, data) => {
console.debug("=ACTS_JsServiceAbility_0600 subscribe (err,data)=======>"
+ ("json err【") + JSON.stringify(err) + ("")
+ ("json data【") + JSON.stringify(data) + ("") + ("json data【") + JSON.stringify(data) + ("")
+ " ,err=" + err + " ,data=" + data); + " ,data=" + data);
if (data.event != "ACTS_SerivceAbilityServer_onDisConnect") { subscriber0400 = data;
expect("ACTS_SerivceAbilityServer_onConnect_PageConnectService_0600").assertEqual( commonEvent.subscribe(subscriber0400, (err, data) => {
data.event); console.debug("=ACTS_JsServiceAbility_0400 subscribe (err,data)=======>"
featureAbility.disconnectAbility(mConnIdJsAsyncCallback, (err) => { + ("json err【") + JSON.stringify(err) + ("")
console.debug("=ACTS_JsServiceAbility_0600 disconnectAbility err====>" + ("json data【") + JSON.stringify(data) + ("")
+ ("json err=") + JSON.stringify(err)); + " ,err=" + err + " ,data=" + data);
}) if (data.event == "ACTS_SerivceAbilityServer_onCommand_PageStartService_0400") {
currentAlertTimeout = setTimeout(() => { expect("ACTS_SerivceAbilityServer_onCommand_PageStartService_0400").assertEqual(
console.log('ACTS_JsServiceAbility_0600====<end steTimeout') data.event);
unsubscribe("ACTS_JsServiceAbility_0600_unsubscribe", subscriber0600); featureAbility.startAbility(
{
want:
{
bundleName: bundleName,
abilityName: abilityName,
action: "PageStartService_0401",
},
}, (err, data) => {
console.debug("=ACTS_JsServiceAbility_0400 startAbility (err,data) 2=======>"
+ ("json err【") + JSON.stringify(err) + ("")
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,err=" + err + " ,data=" + data);
}
)
} else {
expect("ACTS_SerivceAbilityServer_onCommand_PageStartService_0401").assertEqual(
data.event);
unsubscribe("ACTS_JsServiceAbility_0400_unsubscribe", subscriber0400);
console.debug('ACTS_JsServiceAbility_0400====<end');
done(); done();
}, gSetTimeout); }
} else { });
clearTimeout(currentAlertTimeout); })
expect("ACTS_SerivceAbilityServer_onDisConnect").assertEqual( featureAbility.startAbility(
data.event); {
unsubscribe("ACTS_JsServiceAbility_0600_unsubscribe", subscriber0600); want:
console.log('ACTS_JsServiceAbility_0600====<end') {
done(); bundleName: bundleName,
abilityName: abilityName,
action: "PageStartService_0400",
},
}, (err, data) => {
console.debug("=ACTS_JsServiceAbility_0400 startAbility (err,data) 1=======>"
+ ("json err【") + JSON.stringify(err) + ("")
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,err=" + err + " ,data=" + data);
} }
}); )
}) } catch (err) {
function onConnectCallback(element, remote) { expect().assertFail()
console.debug('ACTS_JsServiceAbility_0600_onConnectCallback ====> mConnIdJsAsyncCallback=' console.debug('ACTS_JsServiceAbility_0400==== err: ' + JSON.stringify(err));
+ JSON.stringify(mConnIdJsAsyncCallback) + " , " + mConnIdJsAsyncCallback); done();
console.debug('ACTS_JsServiceAbility_0600_onConnectCallback ====> element='
+ JSON.stringify(element) + " , " + element);
console.debug('ACTS_JsServiceAbility_0600_onConnectCallback ====> remote='
+ JSON.stringify(remote) + " , " + remote);
console.debug('ACTS_JsServiceAbility_0600_onConnectCallback ====> remote is proxy:'
+ (remote instanceof rpc.RemoteProxy));
} }
})
function onDisconnectCallback(element) { /*
console.debug('ACTS_JsServiceAbility_0600_onDisconnectCallback ====> element=' * @tc.number: ACTS_JsServiceAbility_0500
+ JSON.stringify(element) + " , " + element); * @tc.name: featureAbility.ConnectAbility : Connects an ability to a Service ability.
} * @tc.desc: Check the return value of the interface (by Promise)
*/
it('ACTS_JsServiceAbility_0500', 0, async function (done) {
console.log('ACTS_JsServiceAbility_0500====<begin');
try {
let mConnIdJsPromise;
await commonEvent.createSubscriber(CommonEventSubscribeInfo0500).then((data) => {
console.debug("=ACTS_JsServiceAbility_0500 createSubscriber .then(data)=======>"
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,data=" + data);
subscriber0500 = data;
commonEvent.subscribe(subscriber0500, (err, data) => {
console.debug("=ACTS_JsServiceAbility_0500 subscribe (err,data)=======>"
+ ("json err【") + JSON.stringify(err) + ("")
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,err=" + err + " ,data=" + data);
if (data.event == "ACTS_SerivceAbilityServer_onConnect_PageConnectService_0500") {
console.info("ACTS_JsServiceAbility_0500 disconnnectAbility start")
featureAbility.disconnectAbility(mConnIdJsPromise).then((err) => {
console.debug("=ACTS_JsServiceAbility_0500 disconnectAbility err====>"
+ ("json err=") + JSON.stringify(err));
}).catch(err => {
expect().assertFail()
console.debug('ACTS_JsServiceAbility_0500==== err: ' + JSON.stringify(err));
done()
})
} else {
expect("ACTS_SerivceAbilityServer_onDisConnect_PageConnectService_0500")
.assertEqual(data.event);
unsubscribe("ACTS_JsServiceAbility_0500_unsubscribe", subscriber0500);
console.debug('ACTS_JsServiceAbility_0500====<end');
done();
}
});
})
function onConnectCallback(element, remote) {
console.debug('ACTS_JsServiceAbility_0500_onConnectCallback ====> mConnIdJsPromise='
+ JSON.stringify(mConnIdJsPromise) + " , " + mConnIdJsPromise);
console.debug('ACTS_JsServiceAbility_0500_onConnectCallback ====> element='
+ JSON.stringify(element) + " , " + element);
console.debug('ACTS_JsServiceAbility_0500_onConnectCallback ====> remote='
+ JSON.stringify(remote) + " , " + remote);
console.debug('ACTS_JsServiceAbility_0500_onConnectCallback ====> remote is proxy:'
+ (remote instanceof rpc.RemoteProxy));
}
function onFailedCallback(code) { function onDisconnectCallback(element) {
console.debug('ACTS_JsServiceAbility_0600_onFailedCallback ====> code=' console.debug('ACTS_JsServiceAbility_0500_onDisconnectCallback ====> element='
+ JSON.stringify(code) + " , " + code) + JSON.stringify(element) + " , " + element);
expect(code==featureAbility.ErrorCode.ABILITY_NOT_FOUND }
|| (code!=featureAbility.ErrorCode.NO_ERROR
|| code!=featureAbility.ErrorCode.INVALID_PARAMETER
|| code!=featureAbility.ErrorCode.PERMISSION_DENY
)).assertTrue();
}
mConnIdJsAsyncCallback = featureAbility.connectAbility( function onFailedCallback(code) {
{ console.debug('ACTS_JsServiceAbility_0500_onFailedCallback ====> code='
bundleName: bundleName, + JSON.stringify(code) + " , " + code)
abilityName: abilityName, }
action: "PageConnectService_0600",
},
{
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback,
},
)
} catch (err) {
expect("catch").assertEqual(err);
console.log('ACTS_JsServiceAbility_0600====<end err')
done();
}
})
/* mConnIdJsPromise = featureAbility.connectAbility(
* @tc.number: ACTS_JsServiceAbility_0900
* @tc.name: particleability.startAbility : Use page to test startAbiltiy service.
* @tc.desc: Check the return value of the interface (by Promise)
*/
it('ACTS_JsServiceAbility_0900', 0, async function (done) {
console.debug('ACTS_JsServiceAbility_0900====<begin');
try {
await commonEvent.createSubscriber(CommonEventSubscribeInfo0900).then(async (data) => {
console.debug("=ACTS_JsServiceAbility_0900 createSubscriber .then(data)=======>"
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,data=" + data);
subscriber0900 = data;
commonEvent.subscribe(subscriber0900, async (err, data) => {
console.debug("=ACTS_JsServiceAbility_0900 subscribe (err,data)=======>"
+ ("json err【") + JSON.stringify(err) + ("")
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,err=" + err + " ,data=" + data);
expect("ACTS_SerivceAbilityServerSecond_onCommand_ServiceStartService_0900").assertEqual(
data.event);
await sleep(1000)
unsubscribe("ACTS_JsServiceAbility_0900_unsubscribe", subscriber0900);
console.debug('ACTS_JsServiceAbility_0900====<end');
done();
});
})
await sleep(500)
featureAbility.startAbility(
{
want:
{ {
bundleName: bundleName, bundleName: bundleName,
abilityName: abilityName, abilityName: abilityName,
action: "ServiceStartService_0900", action: "PageConnectService_0500",
}, },
} {
).then(data => { onConnect: onConnectCallback,
console.debug("=ACTS_JsServiceAbility_0900 .then(data)=======>" onDisconnect: onDisconnectCallback,
+ ("json data【") + JSON.stringify(data) + ("") onFailed: onFailedCallback,
+ " ,data=" + data); },
}).catch(err => { )
expect(".catch").assertEqual(err); } catch (err) {
console.debug('ACTS_JsServiceAbility_0900====<end .catch(err)'); expect().assertFail()
console.log('ACTS_JsServiceAbility_0500==== err: ' + JSON.stringify(err))
done(); done();
}) }
} catch (err) { })
expect("catch").assertEqual(err);
console.debug('ACTS_JsServiceAbility_0900====<end catch(err)');
done();
}
})
/* /*
* @tc.number: ACTS_JsServiceAbility_1000 * @tc.number: ACTS_JsServiceAbility_0600
* @tc.name: particleability.startAbility : Use page to test startAbiltiy service. * @tc.name: featureAbility.ConnectAbility : Connects an ability to a Service ability.
* @tc.desc: Check the return value of the interface (by AsyncCallback) * @tc.desc: Check the return value of the interface (by AsyncCallback)
*/ */
it('ACTS_JsServiceAbility_1000', 0, async function (done) { it('ACTS_JsServiceAbility_0600', 0, async function (done) {
console.debug('ACTS_JsServiceAbility_1000====<begin'); console.log('ACTS_JsServiceAbility_0600====<begin');
try { try {
await commonEvent.createSubscriber(CommonEventSubscribeInfo1000).then(async (data) => { let mConnIdJsAsyncCallback;
console.debug("=ACTS_JsServiceAbility_1000 createSubscriber .then(data)=======>" await commonEvent.createSubscriber(CommonEventSubscribeInfo0600).then((data) => {
+ ("json data【") + JSON.stringify(data) + ("") console.debug("=ACTS_JsServiceAbility_0600 createSubscriber .then(data)=======>"
+ " ,data=" + data);
subscriber1000 = data;
commonEvent.subscribe(subscriber1000, async (err, data) => {
console.debug("=ACTS_JsServiceAbility_1000 subscribe (err,data)=======>"
+ ("json err【") + JSON.stringify(err) + ("")
+ ("json data【") + JSON.stringify(data) + ("") + ("json data【") + JSON.stringify(data) + ("")
+ " ,err=" + err + " ,data=" + data); + " ,data=" + data);
expect("ACTS_SerivceAbilityServerSecond_onCommand_ServiceStartService_1000").assertEqual( subscriber0600 = data;
data.event); commonEvent.subscribe(subscriber0600, (err, data) => {
await sleep(1000) console.debug("=ACTS_JsServiceAbility_0600 subscribe (err,data)=======>"
unsubscribe("ACTS_JsServiceAbility_1000_unsubscribe", subscriber1000); + ("json err【") + JSON.stringify(err) + ("")
console.debug('ACTS_JsServiceAbility_1000====<end'); + ("json data【") + JSON.stringify(data) + ("")
done() + " ,err=" + err + " ,data=" + data);
}); if (data.event == "ACTS_SerivceAbilityServer_onConnect_PageConnectService_0600") {
}) featureAbility.disconnectAbility(mConnIdJsAsyncCallback, (err) => {
await sleep(500) console.debug("=ACTS_JsServiceAbility_0600 disconnectAbility err====>"
featureAbility.startAbility( + ("json err=") + JSON.stringify(err));
{ })
want: } else {
expect("ACTS_SerivceAbilityServer_onDisConnect_PageConnectService_0600")
.assertEqual(data.event);
unsubscribe("ACTS_JsServiceAbility_0600_unsubscribe", subscriber0600);
console.log('ACTS_JsServiceAbility_0600====<end')
done();
}
});
})
function onConnectCallback(element, remote) {
console.debug('ACTS_JsServiceAbility_0600_onConnectCallback ====> mConnIdJsAsyncCallback='
+ JSON.stringify(mConnIdJsAsyncCallback) + " , " + mConnIdJsAsyncCallback);
console.debug('ACTS_JsServiceAbility_0600_onConnectCallback ====> element='
+ JSON.stringify(element) + " , " + element);
console.debug('ACTS_JsServiceAbility_0600_onConnectCallback ====> remote='
+ JSON.stringify(remote) + " , " + remote);
console.debug('ACTS_JsServiceAbility_0600_onConnectCallback ====> remote is proxy:'
+ (remote instanceof rpc.RemoteProxy));
}
function onDisconnectCallback(element) {
console.debug('ACTS_JsServiceAbility_0600_onDisconnectCallback ====> element='
+ JSON.stringify(element) + " , " + element);
}
function onFailedCallback(code) {
console.debug('ACTS_JsServiceAbility_0600_onFailedCallback ====> code='
+ JSON.stringify(code) + " , " + code)
expect(code == featureAbility.ErrorCode.ABILITY_NOT_FOUND
|| (code != featureAbility.ErrorCode.NO_ERROR
|| code != featureAbility.ErrorCode.INVALID_PARAMETER
|| code != featureAbility.ErrorCode.PERMISSION_DENY
)).assertTrue();
}
mConnIdJsAsyncCallback = featureAbility.connectAbility(
{ {
bundleName: bundleName, bundleName: bundleName,
abilityName: abilityName, abilityName: abilityName,
action: "ServiceStartService_1000", action: "PageConnectService_0600",
}, },
}, (err, data) => { {
console.debug("=ACTS_JsServiceAbility_1000 startAbility (err,data)=======>" onConnect: onConnectCallback,
+ ("json err【") + JSON.stringify(err) + ("") onDisconnect: onDisconnectCallback,
+ ("json data【") + JSON.stringify(data) + ("") onFailed: onFailedCallback,
+ " ,err=" + err + " ,data=" + data); },
} )
) } catch (err) {
} catch (err) { expect().assertFail()
expect("catch").assertEqual(err); console.log('ACTS_JsServiceAbility_0600==== err: ' + JSON.stringify(err))
console.debug('ACTS_JsServiceAbility_1000====<end catch(err)'); done();
done(); }
} })
})
/* /*
* @tc.number: ACTS_JsServiceAbility_1300 * @tc.number: ACTS_JsServiceAbility_0900
* @tc.name: particleability.ConnectAbility : Connects an ability to a Service ability. * @tc.name: particleability.startAbility : Use page to test startAbiltiy service.
* @tc.desc: Check the return value of the interface (by Promise) * @tc.desc: Check the return value of the interface (by Promise)
*/ */
it('ACTS_JsServiceAbility_1300', 0, async function (done) { it('ACTS_JsServiceAbility_0900', 0, async function (done) {
console.log('ACTS_JsServiceAbility_1300====<begin'); console.debug('ACTS_JsServiceAbility_0900====<begin');
try { try {
var mConnIdJsPromise; await commonEvent.createSubscriber(CommonEventSubscribeInfo0900).then((data) => {
await commonEvent.createSubscriber(CommonEventSubscribeInfo1300).then(async (data) => { console.debug("=ACTS_JsServiceAbility_0900 createSubscriber .then(data)=======>"
console.debug("=ACTS_JsServiceAbility_1300 createSubscriber .then(data)=======>"
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,data=" + data);
subscriber1300 = data;
commonEvent.subscribe(subscriber1300, async (err, data) => {
console.debug("=ACTS_JsServiceAbility_1300 subscribe (err,data)=======>"
+ ("json err【") + JSON.stringify(err) + ("")
+ ("json data【") + JSON.stringify(data) + ("") + ("json data【") + JSON.stringify(data) + ("")
+ " ,err=" + err + " ,data=" + data); + " ,data=" + data);
if (data.event != "ACTS_SerivceAbilityServerSecond_onDisConnect") { subscriber0900 = data;
expect("ACTS_SerivceAbilityServerSecond_onConnect_ServiceConnectService_1300" commonEvent.subscribe(subscriber0900, (err, data) => {
).assertEqual(data.event); console.debug("=ACTS_JsServiceAbility_0900 subscribe (err,data)=======>"
featureAbility.disconnectAbility(mConnIdJsPromise).then((err) => { + ("json err【") + JSON.stringify(err) + ("")
console.debug("=ACTS_JsServiceAbility_1300 disconnectAbility err====>" + ("json data【") + JSON.stringify(data) + ("")
+ ("json err=") + JSON.stringify(err)); + " ,err=" + err + " ,data=" + data);
}) expect("ACTS_SerivceAbilityServerSecond_onCommand_ServiceStartService_0900").assertEqual(
} else {
expect("ACTS_SerivceAbilityServerSecond_onDisConnect").assertEqual(
data.event); data.event);
unsubscribe("ACTS_JsServiceAbility_1300_unsubscribe", subscriber1300); unsubscribe("ACTS_JsServiceAbility_0900_unsubscribe", subscriber0900);
console.log('ACTS_JsServiceAbility_1300====<end') console.debug('ACTS_JsServiceAbility_0900====<end');
done(); done();
});
})
await sleep(500)
featureAbility.startAbility(
{
want:
{
bundleName: bundleName,
abilityName: abilityName,
action: "ServiceStartService_0900",
},
} }
}); ).then(data => {
}) console.debug("=ACTS_JsServiceAbility_0900 .then(data)=======>"
function onConnectCallback(element, remote) { + ("json data【") + JSON.stringify(data) + ("")
console.debug('ACTS_JsServiceAbility_1300_onConnectCallback ====> mConnIdJsPromise=' + " ,data=" + data);
+ JSON.stringify(mConnIdJsPromise) + " , " + mConnIdJsPromise); }).catch(err => {
console.debug('ACTS_JsServiceAbility_1300_onConnectCallback ====> element=' expect(".catch").assertEqual(err);
+ JSON.stringify(element) + " , " + element); console.debug('ACTS_JsServiceAbility_0900====<end .catch(err)');
console.debug('ACTS_JsServiceAbility_1300_onConnectCallback ====> remote=' done();
+ JSON.stringify(remote) + " , " + remote); })
console.debug('ACTS_JsServiceAbility_1300_onConnectCallback ====> remote is proxy:' } catch (err) {
+ (remote instanceof rpc.RemoteProxy)); expect().assertFail()
console.debug('ACTS_JsServiceAbility_0900==== err: ' + JSON.stringify(err));
done();
} }
})
function onDisconnectCallback(element) { /*
console.debug('ACTS_JsServiceAbility_1300_onDisconnectCallback ====> element=' * @tc.number: ACTS_JsServiceAbility_1000
+ JSON.stringify(element) + " , " + element); * @tc.name: particleability.startAbility : Use page to test startAbiltiy service.
unsubscribe("ACTS_JsServiceAbility_1300_unsubscribe", subscriber1300); * @tc.desc: Check the return value of the interface (by AsyncCallback)
console.log('ACTS_JsServiceAbility_1300====<end onDisconnectCallback') */
it('ACTS_JsServiceAbility_1000', 0, async function (done) {
console.debug('ACTS_JsServiceAbility_1000====<begin');
await sleep(2000)
try {
await commonEvent.createSubscriber(CommonEventSubscribeInfo1000).then((data) => {
console.debug("=ACTS_JsServiceAbility_1000 createSubscriber .then(data)=======>"
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,data=" + data);
subscriber1000 = data;
commonEvent.subscribe(subscriber1000, (err, data) => {
console.debug("=ACTS_JsServiceAbility_1000 subscribe (err,data)=======>"
+ ("json err【") + JSON.stringify(err) + ("")
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,err=" + err + " ,data=" + data);
expect("ACTS_SerivceAbilityServerSecond_onCommand_ServiceStartService_1000")
.assertEqual(data.event);
unsubscribe("ACTS_JsServiceAbility_1000_unsubscribe", subscriber1000);
console.debug('ACTS_JsServiceAbility_1000====<end');
done()
});
})
await sleep(500)
featureAbility.startAbility(
{
want:
{
bundleName: bundleName,
abilityName: abilityName,
action: "ServiceStartService_1000",
},
}, (err, data) => {
console.debug("=ACTS_JsServiceAbility_1000 startAbility (err,data)=======>"
+ ("json err【") + JSON.stringify(err) + ("")
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,err=" + err + " ,data=" + data);
}
)
} catch (err) {
expect().assertFail()
console.debug('ACTS_JsServiceAbility_1000==== err: ' + JSON.stringify(err));
done(); done();
} }
})
function onFailedCallback(code) { /*
console.debug('ACTS_JsServiceAbility_1300_onFailedCallback ====> code=' * @tc.number: ACTS_JsServiceAbility_1300
+ JSON.stringify(code) + " , " + code) * @tc.name: particleability.ConnectAbility : Connects an ability to a Service ability.
} * @tc.desc: Check the return value of the interface (by Promise)
*/
it('ACTS_JsServiceAbility_1300', 0, async function (done) {
console.log('ACTS_JsServiceAbility_1300====<begin');
try {
let mConnIdJsPromise;
await commonEvent.createSubscriber(CommonEventSubscribeInfo1300).then((data) => {
console.debug("=ACTS_JsServiceAbility_1300 createSubscriber .then(data)=======>"
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,data=" + data);
subscriber1300 = data;
commonEvent.subscribe(subscriber1300, (err, data) => {
console.debug("=ACTS_JsServiceAbility_1300 subscribe (err,data)=======>"
+ ("json err【") + JSON.stringify(err) + ("")
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,err=" + err + " ,data=" + data);
if (data.event == "ACTS_SerivceAbilityServerSecond_onConnect_ServiceConnectService_1300") {
featureAbility.disconnectAbility(mConnIdJsPromise).then((err) => {
console.debug("=ACTS_JsServiceAbility_1300 disconnectAbility err====>"
+ ("json err=") + JSON.stringify(err));
})
}
else {
expect("ACTS_SerivceAbilityServerSecond_onDisConnect_ServiceConnectService_1300")
.assertEqual(data.event);
unsubscribe("ACTS_JsServiceAbility_1300_unsubscribe", subscriber1300);
console.log('ACTS_JsServiceAbility_1300====<end')
done();
}
});
})
function onConnectCallback(element, remote) {
console.debug('ACTS_JsServiceAbility_1300_onConnectCallback ====> mConnIdJsPromise='
+ JSON.stringify(mConnIdJsPromise) + " , " + mConnIdJsPromise);
console.debug('ACTS_JsServiceAbility_1300_onConnectCallback ====> element='
+ JSON.stringify(element) + " , " + element);
console.debug('ACTS_JsServiceAbility_1300_onConnectCallback ====> remote='
+ JSON.stringify(remote) + " , " + remote);
console.debug('ACTS_JsServiceAbility_1300_onConnectCallback ====> remote is proxy:'
+ (remote instanceof rpc.RemoteProxy));
}
mConnIdJsPromise = featureAbility.connectAbility( function onDisconnectCallback(element) {
{ console.debug('ACTS_JsServiceAbility_1300_onDisconnectCallback ====> element='
bundleName: bundleName, + JSON.stringify(element) + " , " + element);
abilityName: abilityName, unsubscribe("ACTS_JsServiceAbility_1300_unsubscribe", subscriber1300);
action: "ServiceConnectService_1300", console.log('ACTS_JsServiceAbility_1300====<end onDisconnectCallback')
}, done();
{ }
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback,
},
)
} catch (err) {
expect("catch").assertEqual(err);
console.log('ACTS_JsServiceAbility_1300====<end err')
done();
}
})
/* function onFailedCallback(code) {
* @tc.number: ACTS_JsServiceAbility_1400 console.debug('ACTS_JsServiceAbility_1300_onFailedCallback ====> code='
* @tc.name: particleability.ConnectAbility : Connects an ability to a Service ability. + JSON.stringify(code) + " , " + code)
* @tc.desc: Check the return value of the interface (by AsyncCallback) }
*/
it('ACTS_JsServiceAbility_1400', 0, async function (done) { mConnIdJsPromise = featureAbility.connectAbility(
console.log('ACTS_JsServiceAbility_1400====<begin'); {
try { bundleName: bundleName,
var currentAlertTimeout; abilityName: abilityName,
var mConnIdJsAsyncCallback; action: "ServiceConnectService_1300",
await commonEvent.createSubscriber(CommonEventSubscribeInfo1400).then(async (data) => { },
console.debug("=ACTS_JsServiceAbility_1400 createSubscriber .then(data)=======>" {
+ ("json data【") + JSON.stringify(data) + ("") onConnect: onConnectCallback,
+ " ,data=" + data); onDisconnect: onDisconnectCallback,
subscriber1400 = data; onFailed: onFailedCallback,
commonEvent.subscribe(subscriber1400, async (err, data) => { },
console.debug("=ACTS_JsServiceAbility_1400 subscribe (err,data)=======>" )
+ ("json err【") + JSON.stringify(err) + ("") } catch (err) {
expect().assertFail()
console.log('ACTS_JsServiceAbility_1300====<end err: ' + JSON.stringify(err))
done();
}
})
/*
* @tc.number: ACTS_JsServiceAbility_1400
* @tc.name: particleability.ConnectAbility : Connects an ability to a Service ability.
* @tc.desc: Check the return value of the interface (by AsyncCallback)
*/
it('ACTS_JsServiceAbility_1400', 0, async function (done) {
console.log('ACTS_JsServiceAbility_1400====<begin');
try {
let mConnIdJsAsyncCallback;
await commonEvent.createSubscriber(CommonEventSubscribeInfo1400).then((data) => {
console.debug("=ACTS_JsServiceAbility_1400 createSubscriber .then(data)=======>"
+ ("json data【") + JSON.stringify(data) + ("") + ("json data【") + JSON.stringify(data) + ("")
+ " ,err=" + err + " ,data=" + data); + " ,data=" + data);
if (data.event != "ACTS_SerivceAbilityServerSecond_onDisConnect") { subscriber1400 = data;
expect("ACTS_SerivceAbilityServerSecond_onConnect_ServiceConnectService_1400" commonEvent.subscribe(subscriber1400, (err, data) => {
).assertEqual(data.event); console.debug("=ACTS_JsServiceAbility_1400 subscribe (err,data)=======>"
featureAbility.disconnectAbility(mConnIdJsAsyncCallback, (err) => { + ("json err【") + JSON.stringify(err) + ("")
console.debug("=ACTS_JsServiceAbility_1400 disconnectAbility err====>" + ("json data【") + JSON.stringify(data) + ("")
+ ("json err=") + JSON.stringify(err)); + " ,err=" + err + " ,data=" + data);
}) if (data.event == "ACTS_SerivceAbilityServerSecond_onConnect_ServiceConnectService_1400") {
currentAlertTimeout = setTimeout(() => { featureAbility.disconnectAbility(mConnIdJsAsyncCallback, (err) => {
console.log('ACTS_JsServiceAbility_1400====<end steTimeout') console.debug("=ACTS_JsServiceAbility_1400 disconnectAbility err====>"
+ ("json err=") + JSON.stringify(err));
})
} else {
expect("ACTS_SerivceAbilityServerSecond_onDisConnect_ServiceConnectService_1400")
.assertEqual(data.event);
unsubscribe("ACTS_JsServiceAbility_1400_unsubscribe", subscriber1400); unsubscribe("ACTS_JsServiceAbility_1400_unsubscribe", subscriber1400);
console.log('ACTS_JsServiceAbility_1400====<end')
done(); done();
}, gSetTimeout); }
} else { });
clearTimeout(currentAlertTimeout); })
expect("ACTS_SerivceAbilityServerSecond_onDisConnect").assertEqual( function onConnectCallback(element, remote) {
data.event); console.debug('ACTS_JsServiceAbility_1400_onConnectCallback ====> mConnIdJsAsyncCallback='
unsubscribe("ACTS_JsServiceAbility_1400_unsubscribe", subscriber1400); + JSON.stringify(mConnIdJsAsyncCallback) + " , " + mConnIdJsAsyncCallback);
console.log('ACTS_JsServiceAbility_1400====<end') console.debug('ACTS_JsServiceAbility_1400_onConnectCallback ====> element='
done(); + JSON.stringify(element) + " , " + element);
} console.debug('ACTS_JsServiceAbility_1400_onConnectCallback ====> remote='
}); + JSON.stringify(remote) + " , " + remote);
}) console.debug('ACTS_JsServiceAbility_1400_onConnectCallback ====> remote is proxy:'
function onConnectCallback(element, remote) { + (remote instanceof rpc.RemoteProxy));
console.debug('ACTS_JsServiceAbility_1400_onConnectCallback ====> mConnIdJsAsyncCallback=' }
+ JSON.stringify(mConnIdJsAsyncCallback) + " , " + mConnIdJsAsyncCallback);
console.debug('ACTS_JsServiceAbility_1400_onConnectCallback ====> element='
+ JSON.stringify(element) + " , " + element);
console.debug('ACTS_JsServiceAbility_1400_onConnectCallback ====> remote='
+ JSON.stringify(remote) + " , " + remote);
console.debug('ACTS_JsServiceAbility_1400_onConnectCallback ====> remote is proxy:'
+ (remote instanceof rpc.RemoteProxy));
}
function onDisconnectCallback(element) { function onDisconnectCallback(element) {
console.debug('ACTS_JsServiceAbility_1400_onDisconnectCallback ====> element=' console.debug('ACTS_JsServiceAbility_1400_onDisconnectCallback ====> element='
+ JSON.stringify(element) + " , " + element); + JSON.stringify(element) + " , " + element);
} }
function onFailedCallback(code) { function onFailedCallback(code) {
console.debug('ACTS_JsServiceAbility_1400_onFailedCallback ====> code=' console.debug('ACTS_JsServiceAbility_1400_onFailedCallback ====> code='
+ JSON.stringify(code) + " , " + code) + JSON.stringify(code) + " , " + code)
} }
mConnIdJsAsyncCallback = featureAbility.connectAbility( mConnIdJsAsyncCallback = featureAbility.connectAbility(
{ {
bundleName: bundleName, bundleName: bundleName,
abilityName: abilityName, abilityName: abilityName,
action: "ServiceConnectService_1400", action: "ServiceConnectService_1400",
}, },
{ {
onConnect: onConnectCallback, onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback, onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback, onFailed: onFailedCallback,
}, },
) )
} catch (err) { } catch (err) {
expect("catch").assertEqual(err); expect().assertFail()
console.log('ACTS_JsServiceAbility_1400====<end err') console.log('ACTS_JsServiceAbility_1400====<end err: ' + JSON.stringify(err))
done(); done();
} }
}) })
/* /*
* @tc.number: ACTS_JsServiceAbility_1500 * @tc.number: ACTS_JsServiceAbility_1500
* @tc.name: particleability.ConnectAbility : Connects an ability to a Service ability. * @tc.name: particleability.ConnectAbility : Connects an ability to a Service ability.
* @tc.desc: Check the return value of the interface (by Promise) * @tc.desc: Check the return value of the interface (by Promise)
*/ */
it('ACTS_JsServiceAbility_1500', 0, async function (done) { it('ACTS_JsServiceAbility_1500', 0, async function (done) {
console.log('ACTS_JsServiceAbility_1500====<begin'); console.log('ACTS_JsServiceAbility_1500====<begin');
try { try {
var mConnIdJsPromise; let mConnIdJsPromise;
await commonEvent.createSubscriber(CommonEventSubscribeInfo1500).then(async (data) => { await commonEvent.createSubscriber(CommonEventSubscribeInfo1500).then((data) => {
console.debug("=ACTS_JsServiceAbility_1500 createSubscriber .then(data)=======>" console.debug("=ACTS_JsServiceAbility_1500 createSubscriber .then(data)=======>"
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,data=" + data);
subscriber1500 = data;
commonEvent.subscribe(subscriber1500, async (err, data) => {
console.debug("=ACTS_JsServiceAbility_1500 subscribe (err,data)=======>"
+ ("json err【") + JSON.stringify(err) + ("")
+ ("json data【") + JSON.stringify(data) + ("") + ("json data【") + JSON.stringify(data) + ("")
+ " ,err=" + err + " ,data=" + data); + " ,data=" + data);
if (data.event != "ACTS_SerivceAbilityServer_onDisConnect") { subscriber1500 = data;
expect("ACTS_SerivceAbilityServerSecond_onConnect_ServiceConnectService_1500").assertEqual( commonEvent.subscribe(subscriber1500, (err, data) => {
data.event); console.debug("=ACTS_JsServiceAbility_1500 subscribe (err,data)=======>"
featureAbility.disconnectAbility(mConnIdJsPromise).then(() => { + ("json err【") + JSON.stringify(err) + ("")
}).catch(err => { + ("json data【") + JSON.stringify(data) + ("")
expect(".catch").assertEqual(err); + " ,err=" + err + " ,data=" + data);
console.debug('ACTS_JsServiceAbility_1500====<end .catch(err)'); if (data.event == "ACTS_SerivceAbilityServerSecond_onConnect_ServiceConnectService_1500") {
featureAbility.disconnectAbility(mConnIdJsPromise).then((err) => {
console.debug('ACTS_JsServiceAbility_1500===disconnectAbility data:' +
JSON.stringify(err));
}).catch(err => {
expect().assertFail()
console.debug('ACTS_JsServiceAbility_1500==== err: ' + JSON.stringify(err));
done();
})
} else {
expect("ACTS_SerivceAbilityServer_onDisConnect_ServiceConnectService_1500")
.assertEqual(data.event);
unsubscribe("ACTS_JsServiceAbility_1500_unsubscribe", subscriber1500);
console.log('ACTS_JsServiceAbility_1500====<end')
done(); done();
}) }
} else { });
expect("ACTS_SerivceAbilityServer_onDisConnect").assertEqual( })
data.event); function onConnectCallback(element, remote) {
unsubscribe("ACTS_JsServiceAbility_1500_unsubscribe", subscriber1500); console.debug('ACTS_JsServiceAbility_1500_onConnectCallback ====> mConnIdJsPromise='
console.log('ACTS_JsServiceAbility_1500====<end') + JSON.stringify(mConnIdJsPromise) + " , " + mConnIdJsPromise);
done(); console.debug('ACTS_JsServiceAbility_1500_onConnectCallback ====> element='
} + JSON.stringify(element) + " , " + element);
}); console.debug('ACTS_JsServiceAbility_1500_onConnectCallback ====> remote='
}) + JSON.stringify(remote) + " , " + remote);
function onConnectCallback(element, remote) { }
console.debug('ACTS_JsServiceAbility_1500_onConnectCallback ====> mConnIdJsPromise='
+ JSON.stringify(mConnIdJsPromise) + " , " + mConnIdJsPromise);
console.debug('ACTS_JsServiceAbility_1500_onConnectCallback ====> element='
+ JSON.stringify(element) + " , " + element);
console.debug('ACTS_JsServiceAbility_1500_onConnectCallback ====> remote='
+ JSON.stringify(remote) + " , " + remote);
}
function onDisconnectCallback(element) { function onDisconnectCallback(element) {
console.debug('ACTS_JsServiceAbility_1500_onDisconnectCallback ====> element=' console.debug('ACTS_JsServiceAbility_1500_onDisconnectCallback ====> element='
+ JSON.stringify(element) + " , " + element); + JSON.stringify(element) + " , " + element);
unsubscribe("ACTS_JsServiceAbility_1500_unsubscribe", subscriber1500); unsubscribe("ACTS_JsServiceAbility_1500_unsubscribe", subscriber1500);
console.log('ACTS_JsServiceAbility_1500====<end onDisconnectCallback') console.log('ACTS_JsServiceAbility_1500====<end onDisconnectCallback')
done(); done();
} }
function onFailedCallback(code) { function onFailedCallback(code) {
console.debug('ACTS_JsServiceAbility_1500_onFailedCallback ====> code=' console.debug('ACTS_JsServiceAbility_1500_onFailedCallback ====> code='
+ JSON.stringify(code) + " , " + code) + JSON.stringify(code) + " , " + code)
} }
mConnIdJsPromise = featureAbility.connectAbility( mConnIdJsPromise = featureAbility.connectAbility(
{ {
bundleName: bundleName, bundleName: bundleName,
abilityName: abilityName, abilityName: abilityName,
action: "ServiceConnectService_1500", action: "ServiceConnectService_1500",
}, },
{ {
onConnect: onConnectCallback, onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback, onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback, onFailed: onFailedCallback,
}, },
) )
} catch (err) { } catch (err) {
expect("catch").assertEqual(err); expect("catch").assertEqual(err);
console.log('ACTS_JsServiceAbility_1500====<end err') console.log('ACTS_JsServiceAbility_1500====<end err')
done(); done();
} }
})
}) })
})
} }
\ No newline at end of file
...@@ -48,7 +48,6 @@ class StubTest extends rpc.RemoteObject { ...@@ -48,7 +48,6 @@ class StubTest extends rpc.RemoteObject {
console.log('ACTS_SerivceAbilityServer ====< method called.') console.log('ACTS_SerivceAbilityServer ====< method called.')
} }
} }
export default { export default {
onStart(want) { onStart(want) {
console.debug('ACTS_SerivceAbilityServer 0425 ====>onStart .ts 0851 =' console.debug('ACTS_SerivceAbilityServer 0425 ====>onStart .ts 0851 ='
...@@ -60,9 +59,9 @@ export default { ...@@ -60,9 +59,9 @@ export default {
commonEvent.publish("ACTS_SerivceAbilityServer_onStop", (err) => { }); commonEvent.publish("ACTS_SerivceAbilityServer_onStop", (err) => { });
particleAbility.terminateSelf().then((data) => { particleAbility.terminateSelf().then((data) => {
console.log('ACTS_SerivceAbilityServer terminateSelf data:' + JSON.stringify(data)); console.log('ACTS_SerivceAbilityServer terminateSelf data:' + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
console.log('ACTS_SerivceAbilityServer terminateSelf error:' + JSON.stringify(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='
...@@ -81,9 +80,9 @@ export default { ...@@ -81,9 +80,9 @@ export default {
); );
particleAbility.terminateSelf().then((data) => { particleAbility.terminateSelf().then((data) => {
console.log('ACTS_SerivceAbilityServer terminateSelf data:' + JSON.stringify(data)); console.log('ACTS_SerivceAbilityServer terminateSelf data:' + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
console.log('ACTS_SerivceAbilityServer terminateSelf error:' + JSON.stringify(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 +95,11 @@ export default { ...@@ -96,11 +95,11 @@ 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) => { particleAbility.terminateSelf().then((data) => {
console.log('ACTS_SerivceAbilityServer terminateSelf data:' + JSON.stringify(data)); console.log('ACTS_SerivceAbilityServer terminateSelf data:' + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
console.log('ACTS_SerivceAbilityServer terminateSelf error:' + JSON.stringify(error)); console.log('ACTS_SerivceAbilityServer terminateSelf error:' + JSON.stringify(error));
}); });
} }
); );
} else { } else {
...@@ -110,11 +109,11 @@ export default { ...@@ -110,11 +109,11 @@ export default {
|| 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.terminateSelf()=====>'
+ want.action); + want.action);
particleAbility.terminateSelf().then((data) => { particleAbility.terminateSelf().then((data) => {
console.log('ACTS_SerivceAbilityServer terminateSelf data:' + JSON.stringify(data)); console.log('ACTS_SerivceAbilityServer terminateSelf data:' + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
console.log('ACTS_SerivceAbilityServer terminateSelf error:' + JSON.stringify(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);
...@@ -127,6 +126,7 @@ export default { ...@@ -127,6 +126,7 @@ export default {
try { try {
console.debug('ACTS_SerivceAbilityServer ====>onConnect=' console.debug('ACTS_SerivceAbilityServer ====>onConnect='
+ want + " , JSON." + JSON.stringify(want)); + want + " , JSON." + JSON.stringify(want));
commonEvent.publish("ACTS_SerivceAbilityServer_onConnect" + "_" + want.action, (err) => { });
function onConnectCallback(element, remote) { function onConnectCallback(element, remote) {
console.debug('ACTS_SerivceAbilityServer_onConnectCallback ====> mConnIdJs=' console.debug('ACTS_SerivceAbilityServer_onConnectCallback ====> mConnIdJs='
+ JSON.stringify(mConnIdJs) + " , " + mConnIdJs); + JSON.stringify(mConnIdJs) + " , " + mConnIdJs);
...@@ -157,8 +157,6 @@ export default { ...@@ -157,8 +157,6 @@ export default {
onFailed: onFailedCallback, onFailed: onFailedCallback,
}, },
) )
} else {
commonEvent.publish("ACTS_SerivceAbilityServer_onConnect" + "_" + want.action, (err) => { });
} }
} catch (err) { } catch (err) {
console.log("ACTS_SerivceAbilityServer ====< error:" + err) console.log("ACTS_SerivceAbilityServer ====< error:" + err)
...@@ -169,27 +167,22 @@ export default { ...@@ -169,27 +167,22 @@ 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) { console.debug('ACTS_SerivceAbilityServer_onDisConnect ===' + want.action);
console.debug('ACTS_SerivceAbilityServer_onDisConnect publish err=====>' + err); });
} else { if (want.action == 'ServiceConnectService_1300' || want.action == 'ServiceConnectService_1400'
console.debug('ACTS_SerivceAbilityServer_onDisConnect featureAbility.terminateSelf()=====<' || want.action == 'ServiceConnectService_1500' || want.action == 'ServiceConnectService_1501'
+ want.action); || want.action == 'ServiceConnectService_1600' || want.action == 'ServiceConnectService_1601'
if (want.action == 'ServiceConnectService_1300' || want.action == 'ServiceConnectService_1400' ) {
|| want.action == 'ServiceConnectService_1500' || want.action == 'ServiceConnectService_1501' particleAbility.disconnectAbility(mConnIdJs, (err) => {
|| want.action == 'ServiceConnectService_1600' || want.action == 'ServiceConnectService_1601' console.debug("=ACTS_SerivceAbilityServer_onDisConnect 13 14 15 16 err====>"
) { + ("json err=") + JSON.stringify(err) + " , " + want.action);
particleAbility.disconnectAbility(mConnIdJs, (err) => { })
console.debug("=ACTS_SerivceAbilityServer_onDisConnect 13 14 15 16 err====>" }
+ ("json err=") + JSON.stringify(err) + " , " + want.action); particleAbility.terminateSelf().then((data) => {
}) console.log('ACTS_SerivceAbilityServer terminateSelf data:' + JSON.stringify(data));
} }).catch((error) => {
particleAbility.terminateSelf().then((data) => { console.log('ACTS_SerivceAbilityServer terminateSelf error:' + JSON.stringify(error));
console.log('ACTS_SerivceAbilityServer terminateSelf data:' + JSON.stringify(data));
}).catch((error) => {
console.log('ACTS_SerivceAbilityServer terminateSelf error:' + JSON.stringify(error));
});
}
}); });
}, },
onReady() { onReady() {
......
...@@ -49,6 +49,9 @@ class StubTest extends rpc.RemoteObject { ...@@ -49,6 +49,9 @@ class StubTest extends rpc.RemoteObject {
} }
} }
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
export default { export default {
onStart(want) { onStart(want) {
console.debug('ACTS_SerivceAbilityServerSecond ====>onStart=' console.debug('ACTS_SerivceAbilityServerSecond ====>onStart='
...@@ -60,20 +63,24 @@ export default { ...@@ -60,20 +63,24 @@ export default {
commonEvent.publish("ACTS_SerivceAbilityServerSecond_onStop", (err) => { }); commonEvent.publish("ACTS_SerivceAbilityServerSecond_onStop", (err) => { });
particleAbility.terminateSelf().then((data) => { particleAbility.terminateSelf().then((data) => {
console.log('ACTS_SerivceAbilityServer terminateSelf data:' + JSON.stringify(data)); console.log('ACTS_SerivceAbilityServer terminateSelf data:' + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
console.log('ACTS_SerivceAbilityServer terminateSelf error:' + JSON.stringify(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) => {
console.debug("ACTS_SerivceAbilityServerSecond_onCommand" + "_" + want.action +
"err: " + JSON.stringify(err))
});
sleep(500)
particleAbility.terminateSelf().then((data) => { particleAbility.terminateSelf().then((data) => {
console.log('ACTS_SerivceAbilityServer terminateSelf data:' + JSON.stringify(data)); console.log('ACTS_SerivceAbilityServer terminateSelf data:' + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
console.log('ACTS_SerivceAbilityServer terminateSelf error:' + JSON.stringify(error)); console.log('ACTS_SerivceAbilityServer terminateSelf error:' + JSON.stringify(error));
}); });
}, },
onConnect(want) { onConnect(want) {
console.info('ACTS_SerivceAbilityServerSecond ====< onConnect'); console.info('ACTS_SerivceAbilityServerSecond ====< onConnect');
...@@ -154,7 +161,7 @@ export default { ...@@ -154,7 +161,7 @@ export default {
onDisconnect(want) { onDisconnect(want) {
console.debug('ACTS_SerivceAbilityServerSecond ====>onDisConnect=' console.debug('ACTS_SerivceAbilityServerSecond ====>onDisConnect='
+ want + " , JSON." + JSON.stringify(want)); + want + " , JSON." + JSON.stringify(want));
commonEvent.publish("ACTS_SerivceAbilityServerSecond_onDisConnect", (err) => { commonEvent.publish("ACTS_SerivceAbilityServerSecond_onDisConnect_" + want.action, (err) => {
if (err.code) { if (err.code) {
console.debug('ACTS_SerivceAbilityServerSecond_onDisConnect publish err=====>' + err); console.debug('ACTS_SerivceAbilityServerSecond_onDisConnect publish err=====>' + err);
} else { } else {
...@@ -170,9 +177,9 @@ export default { ...@@ -170,9 +177,9 @@ export default {
} }
particleAbility.terminateSelf().then((data) => { particleAbility.terminateSelf().then((data) => {
console.log('ACTS_SerivceAbilityServer terminateSelf data:' + JSON.stringify(data)); console.log('ACTS_SerivceAbilityServer terminateSelf data:' + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
console.log('ACTS_SerivceAbilityServer terminateSelf error:' + JSON.stringify(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.
先完成此消息的编辑!
想要评论请 注册