提交 8039e4fe 编写于 作者: H HuangXW

和Beta3同步

Change-Id: Ic1b2e6aeaa95672fa5fbd9d4dad92f02135dab0e
Signed-off-by: NHuangXW <huangxinwei4@huawei.com>
上级 09aaa0db
......@@ -15,72 +15,72 @@
import featureAbility from '@ohos.ability.featureAbility'
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() {
describe('ActsStServiceAbilityTest', function () {
describe('ActsStServiceAbilityTest', function () {
let bundleName = "com.amsst.stserviceabilityserver";
let abilityName = "com.amsst.stserviceabilityserver.ServiceAbility";
var subscriber0100;
var CommonEventSubscribeInfo0100 = {
let subscriber0100;
let CommonEventSubscribeInfo0100 = {
events: ["ACTS_SerivceAbilityServer_onCommand_PageStartService_0100",
],
};
var subscriber0200;
var CommonEventSubscribeInfo0200 = {
let subscriber0200;
let CommonEventSubscribeInfo0200 = {
events: ["ACTS_SerivceAbilityServer_onCommand_PageStartService_0200",
],
};
var subscriber0300;
var CommonEventSubscribeInfo0300 = {
let subscriber0300;
let CommonEventSubscribeInfo0300 = {
events: ["ACTS_SerivceAbilityServer_onCommand_PageStartService_0300",
"ACTS_SerivceAbilityServer_onCommand_PageStartService_0301",
],
};
var subscriber0400;
var CommonEventSubscribeInfo0400 = {
let subscriber0400;
let CommonEventSubscribeInfo0400 = {
events: ["ACTS_SerivceAbilityServer_onCommand_PageStartService_0400",
"ACTS_SerivceAbilityServer_onCommand_PageStartService_0401",
],
};
var subscriber0500;
var CommonEventSubscribeInfo0500 = {
let subscriber0500;
let CommonEventSubscribeInfo0500 = {
events: ["ACTS_SerivceAbilityServer_onConnect_PageConnectService_0500",
"ACTS_SerivceAbilityServer_onDisConnect",
"ACTS_SerivceAbilityServer_onDisConnect_PageConnectService_0500",
],
};
var subscriber0600;
var CommonEventSubscribeInfo0600 = {
let subscriber0600;
let CommonEventSubscribeInfo0600 = {
events: ["ACTS_SerivceAbilityServer_onConnect_PageConnectService_0600",
"ACTS_SerivceAbilityServer_onDisConnect",
"ACTS_SerivceAbilityServer_onDisConnect_PageConnectService_0600",
],
};
var subscriber0900;
var CommonEventSubscribeInfo0900 = {
let subscriber0900;
let CommonEventSubscribeInfo0900 = {
events: ["ACTS_SerivceAbilityServerSecond_onCommand_ServiceStartService_0900",
],
};
var subscriber1000;
var CommonEventSubscribeInfo1000 = {
let subscriber1000;
let CommonEventSubscribeInfo1000 = {
events: ["ACTS_SerivceAbilityServerSecond_onCommand_ServiceStartService_1000",
],
};
var subscriber1300;
var CommonEventSubscribeInfo1300 = {
let subscriber1300;
let CommonEventSubscribeInfo1300 = {
events: ["ACTS_SerivceAbilityServerSecond_onConnect_ServiceConnectService_1300",
"ACTS_SerivceAbilityServerSecond_onDisConnect",
"ACTS_SerivceAbilityServerSecond_onDisConnect_ServiceConnectService_1300",
],
};
var subscriber1400;
var CommonEventSubscribeInfo1400 = {
let subscriber1400;
let CommonEventSubscribeInfo1400 = {
events: ["ACTS_SerivceAbilityServerSecond_onConnect_ServiceConnectService_1400",
"ACTS_SerivceAbilityServerSecond_onDisConnect",
"ACTS_SerivceAbilityServerSecond_onDisConnect_ServiceConnectService_1400",
],
};
var subscriber1500;
var CommonEventSubscribeInfo1500 = {
let subscriber1500;
let CommonEventSubscribeInfo1500 = {
events: ["ACTS_SerivceAbilityServerSecond_onConnect_ServiceConnectService_1500",
"ACTS_SerivceAbilityServer_onDisConnect",
"ACTS_SerivceAbilityServer_onDisConnect_ServiceConnectService_1500",
],
};
......@@ -96,30 +96,12 @@ describe('ActsStServiceAbilityTest', function () {
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);
})
let gSetTimeout = 2000
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
......@@ -129,12 +111,12 @@ describe('ActsStServiceAbilityTest', function () {
it('ACTS_JsServiceAbility_0100', 0, async function (done) {
console.debug('ACTS_JsServiceAbility_0100====<begin');
try {
await commonEvent.createSubscriber(CommonEventSubscribeInfo0100).then(async (data) => {
await commonEvent.createSubscriber(CommonEventSubscribeInfo0100).then((data) => {
console.debug("=ACTS_JsServiceAbility_0100 createSubscriber .then(data)=======>"
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,data=" + data);
subscriber0100 = data;
commonEvent.subscribe(subscriber0100, async (err, data) => {
commonEvent.subscribe(subscriber0100, (err, data) => {
console.debug("=ACTS_JsServiceAbility_0100 subscribe (err,data)=======>"
+ ("json err【") + JSON.stringify(err) + ("")
+ ("json data【") + JSON.stringify(data) + ("")
......@@ -161,12 +143,12 @@ describe('ActsStServiceAbilityTest', function () {
+ " ,data=" + data);
}).catch(err => {
expect(".catch").assertEqual(err);
console.debug('ACTS_JsServiceAbility_0100====<end .catch(err):'+ JSON.stringify(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)');
expect().assertFail()
console.debug('ACTS_JsServiceAbility_0100==== err: ' + JSON.stringify(err));
done();
}
})
......@@ -179,12 +161,12 @@ describe('ActsStServiceAbilityTest', function () {
it('ACTS_JsServiceAbility_0200', 0, async function (done) {
console.debug('ACTS_JsServiceAbility_0200====<begin');
try {
await commonEvent.createSubscriber(CommonEventSubscribeInfo0200).then(async (data) => {
await commonEvent.createSubscriber(CommonEventSubscribeInfo0200).then((data) => {
console.debug("=ACTS_JsServiceAbility_0200 createSubscriber .then(data)=======>"
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,data=" + data);
subscriber0200 = data;
commonEvent.subscribe(subscriber0200, async (err, data) => {
commonEvent.subscribe(subscriber0200, (err, data) => {
console.debug("=ACTS_JsServiceAbility_0200 subscribe (err,data)=======>"
+ ("json err【") + JSON.stringify(err) + ("")
+ ("json data【") + JSON.stringify(data) + ("")
......@@ -212,8 +194,8 @@ describe('ActsStServiceAbilityTest', function () {
}
)
} catch (err) {
expect("catch").assertEqual(err);
console.debug('ACTS_JsServiceAbility_0200====<end catch(err)');
expect().assertFail()
console.debug('ACTS_JsServiceAbility_0200==== err: ' + JSON.stringify(err));
done();
}
})
......@@ -226,12 +208,12 @@ describe('ActsStServiceAbilityTest', function () {
it('ACTS_JsServiceAbility_0300', 0, async function (done) {
console.debug('ACTS_JsServiceAbility_0300====<begin');
try {
await commonEvent.createSubscriber(CommonEventSubscribeInfo0300).then(async (data) => {
await commonEvent.createSubscriber(CommonEventSubscribeInfo0300).then((data) => {
console.debug("=ACTS_JsServiceAbility_0300 createSubscriber .then(data)=======>"
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,data=" + data);
subscriber0300 = data;
commonEvent.subscribe(subscriber0300, async (err, data) => {
commonEvent.subscribe(subscriber0300, (err, data) => {
console.debug("=ACTS_JsServiceAbility_0300 subscribe (err,data)=======>"
+ ("json err【") + JSON.stringify(err) + ("")
+ ("json data【") + JSON.stringify(data) + ("")
......@@ -253,8 +235,8 @@ describe('ActsStServiceAbilityTest', function () {
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,data=" + data);
}).catch(err => {
expect(".catch").assertEqual(err);
console.debug('ACTS_JsServiceAbility_0300====<end .catch(err) 2');
expect().assertFail()
console.debug('ACTS_JsServiceAbility_0300==== err: ' + JSON.stringify(err));
done();
})
} else {
......@@ -285,8 +267,8 @@ describe('ActsStServiceAbilityTest', function () {
done();
})
} catch (err) {
expect("catch").assertEqual(err);
console.debug('ACTS_JsServiceAbility_0300====<end catch(err)');
expect().assertFail()
console.debug('ACTS_JsServiceAbility_0300==== err: ' + JSON.stringify(err));
done();
}
})
......@@ -299,12 +281,12 @@ describe('ActsStServiceAbilityTest', function () {
it('ACTS_JsServiceAbility_0400', 0, async function (done) {
console.debug('ACTS_JsServiceAbility_0400====<begin');
try {
await commonEvent.createSubscriber(CommonEventSubscribeInfo0400).then(async (data) => {
await commonEvent.createSubscriber(CommonEventSubscribeInfo0400).then((data) => {
console.debug("=ACTS_JsServiceAbility_0400 createSubscriber .then(data)=======>"
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,data=" + data);
subscriber0400 = data;
commonEvent.subscribe(subscriber0400, async (err, data) => {
commonEvent.subscribe(subscriber0400, (err, data) => {
console.debug("=ACTS_JsServiceAbility_0400 subscribe (err,data)=======>"
+ ("json err【") + JSON.stringify(err) + ("")
+ ("json data【") + JSON.stringify(data) + ("")
......@@ -352,8 +334,8 @@ describe('ActsStServiceAbilityTest', function () {
}
)
} catch (err) {
expect("catch").assertEqual(err);
console.debug('ACTS_JsServiceAbility_0400====<end catch(err)');
expect().assertFail()
console.debug('ACTS_JsServiceAbility_0400==== err: ' + JSON.stringify(err));
done();
}
})
......@@ -366,13 +348,13 @@ describe('ActsStServiceAbilityTest', function () {
it('ACTS_JsServiceAbility_0500', 0, async function (done) {
console.log('ACTS_JsServiceAbility_0500====<begin');
try {
var mConnIdJsPromise;
await commonEvent.createSubscriber(CommonEventSubscribeInfo0500).then(async (data) => {
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, async (err, data) => {
commonEvent.subscribe(subscriber0500, (err, data) => {
console.debug("=ACTS_JsServiceAbility_0500 subscribe (err,data)=======>"
+ ("json err【") + JSON.stringify(err) + ("")
+ ("json data【") + JSON.stringify(data) + ("")
......@@ -430,8 +412,8 @@ describe('ActsStServiceAbilityTest', function () {
},
)
} catch (err) {
expect("catch").assertEqual(err);
console.log('ACTS_JsServiceAbility_0500====<end err')
expect().assertFail()
console.log('ACTS_JsServiceAbility_0500==== err: ' + JSON.stringify(err))
done();
}
})
......@@ -444,34 +426,25 @@ describe('ActsStServiceAbilityTest', function () {
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) => {
let mConnIdJsAsyncCallback;
await commonEvent.createSubscriber(CommonEventSubscribeInfo0600).then((data) => {
console.debug("=ACTS_JsServiceAbility_0600 createSubscriber .then(data)=======>"
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,data=" + data);
subscriber0600 = data;
commonEvent.subscribe(subscriber0600, async (err, data) => {
commonEvent.subscribe(subscriber0600, (err, data) => {
console.debug("=ACTS_JsServiceAbility_0600 subscribe (err,data)=======>"
+ ("json err【") + JSON.stringify(err) + ("")
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,err=" + err + " ,data=" + data);
if (data.event != "ACTS_SerivceAbilityServer_onDisConnect") {
expect("ACTS_SerivceAbilityServer_onConnect_PageConnectService_0600").assertEqual(
data.event);
if (data.event == "ACTS_SerivceAbilityServer_onConnect_PageConnectService_0600") {
featureAbility.disconnectAbility(mConnIdJsAsyncCallback, (err) => {
console.debug("=ACTS_JsServiceAbility_0600 disconnectAbility err====>"
+ ("json err=") + JSON.stringify(err));
})
currentAlertTimeout = setTimeout(() => {
console.log('ACTS_JsServiceAbility_0600====<end steTimeout')
unsubscribe("ACTS_JsServiceAbility_0600_unsubscribe", subscriber0600);
done();
}, gSetTimeout);
} else {
clearTimeout(currentAlertTimeout);
expect("ACTS_SerivceAbilityServer_onDisConnect").assertEqual(
data.event);
expect("ACTS_SerivceAbilityServer_onDisConnect_PageConnectService_0600")
.assertEqual(data.event);
unsubscribe("ACTS_JsServiceAbility_0600_unsubscribe", subscriber0600);
console.log('ACTS_JsServiceAbility_0600====<end')
done();
......@@ -497,10 +470,10 @@ describe('ActsStServiceAbilityTest', function () {
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
expect(code == featureAbility.ErrorCode.ABILITY_NOT_FOUND
|| (code != featureAbility.ErrorCode.NO_ERROR
|| code != featureAbility.ErrorCode.INVALID_PARAMETER
|| code != featureAbility.ErrorCode.PERMISSION_DENY
)).assertTrue();
}
......@@ -517,8 +490,8 @@ describe('ActsStServiceAbilityTest', function () {
},
)
} catch (err) {
expect("catch").assertEqual(err);
console.log('ACTS_JsServiceAbility_0600====<end err')
expect().assertFail()
console.log('ACTS_JsServiceAbility_0600==== err: ' + JSON.stringify(err))
done();
}
})
......@@ -531,19 +504,18 @@ describe('ActsStServiceAbilityTest', function () {
it('ACTS_JsServiceAbility_0900', 0, async function (done) {
console.debug('ACTS_JsServiceAbility_0900====<begin');
try {
await commonEvent.createSubscriber(CommonEventSubscribeInfo0900).then(async (data) => {
await commonEvent.createSubscriber(CommonEventSubscribeInfo0900).then((data) => {
console.debug("=ACTS_JsServiceAbility_0900 createSubscriber .then(data)=======>"
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,data=" + data);
subscriber0900 = data;
commonEvent.subscribe(subscriber0900, async (err, data) => {
commonEvent.subscribe(subscriber0900, (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();
......@@ -569,8 +541,8 @@ describe('ActsStServiceAbilityTest', function () {
done();
})
} catch (err) {
expect("catch").assertEqual(err);
console.debug('ACTS_JsServiceAbility_0900====<end catch(err)');
expect().assertFail()
console.debug('ACTS_JsServiceAbility_0900==== err: ' + JSON.stringify(err));
done();
}
})
......@@ -582,20 +554,20 @@ describe('ActsStServiceAbilityTest', function () {
*/
it('ACTS_JsServiceAbility_1000', 0, async function (done) {
console.debug('ACTS_JsServiceAbility_1000====<begin');
await sleep(2000)
try {
await commonEvent.createSubscriber(CommonEventSubscribeInfo1000).then(async (data) => {
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, async (err, 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);
await sleep(1000)
expect("ACTS_SerivceAbilityServerSecond_onCommand_ServiceStartService_1000")
.assertEqual(data.event);
unsubscribe("ACTS_JsServiceAbility_1000_unsubscribe", subscriber1000);
console.debug('ACTS_JsServiceAbility_1000====<end');
done()
......@@ -618,8 +590,8 @@ describe('ActsStServiceAbilityTest', function () {
}
)
} catch (err) {
expect("catch").assertEqual(err);
console.debug('ACTS_JsServiceAbility_1000====<end catch(err)');
expect().assertFail()
console.debug('ACTS_JsServiceAbility_1000==== err: ' + JSON.stringify(err));
done();
}
})
......@@ -632,27 +604,26 @@ describe('ActsStServiceAbilityTest', function () {
it('ACTS_JsServiceAbility_1300', 0, async function (done) {
console.log('ACTS_JsServiceAbility_1300====<begin');
try {
var mConnIdJsPromise;
await commonEvent.createSubscriber(CommonEventSubscribeInfo1300).then(async (data) => {
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, async (err, 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_onDisConnect") {
expect("ACTS_SerivceAbilityServerSecond_onConnect_ServiceConnectService_1300"
).assertEqual(data.event);
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").assertEqual(
data.event);
}
else {
expect("ACTS_SerivceAbilityServerSecond_onDisConnect_ServiceConnectService_1300")
.assertEqual(data.event);
unsubscribe("ACTS_JsServiceAbility_1300_unsubscribe", subscriber1300);
console.log('ACTS_JsServiceAbility_1300====<end')
done();
......@@ -696,8 +667,8 @@ describe('ActsStServiceAbilityTest', function () {
},
)
} catch (err) {
expect("catch").assertEqual(err);
console.log('ACTS_JsServiceAbility_1300====<end err')
expect().assertFail()
console.log('ACTS_JsServiceAbility_1300====<end err: ' + JSON.stringify(err))
done();
}
})
......@@ -710,34 +681,25 @@ describe('ActsStServiceAbilityTest', function () {
it('ACTS_JsServiceAbility_1400', 0, async function (done) {
console.log('ACTS_JsServiceAbility_1400====<begin');
try {
var currentAlertTimeout;
var mConnIdJsAsyncCallback;
await commonEvent.createSubscriber(CommonEventSubscribeInfo1400).then(async (data) => {
let mConnIdJsAsyncCallback;
await commonEvent.createSubscriber(CommonEventSubscribeInfo1400).then((data) => {
console.debug("=ACTS_JsServiceAbility_1400 createSubscriber .then(data)=======>"
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,data=" + data);
subscriber1400 = data;
commonEvent.subscribe(subscriber1400, async (err, data) => {
commonEvent.subscribe(subscriber1400, (err, data) => {
console.debug("=ACTS_JsServiceAbility_1400 subscribe (err,data)=======>"
+ ("json err【") + JSON.stringify(err) + ("")
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,err=" + err + " ,data=" + data);
if (data.event != "ACTS_SerivceAbilityServerSecond_onDisConnect") {
expect("ACTS_SerivceAbilityServerSecond_onConnect_ServiceConnectService_1400"
).assertEqual(data.event);
if (data.event == "ACTS_SerivceAbilityServerSecond_onConnect_ServiceConnectService_1400") {
featureAbility.disconnectAbility(mConnIdJsAsyncCallback, (err) => {
console.debug("=ACTS_JsServiceAbility_1400 disconnectAbility err====>"
+ ("json err=") + JSON.stringify(err));
})
currentAlertTimeout = setTimeout(() => {
console.log('ACTS_JsServiceAbility_1400====<end steTimeout')
unsubscribe("ACTS_JsServiceAbility_1400_unsubscribe", subscriber1400);
done();
}, gSetTimeout);
} else {
clearTimeout(currentAlertTimeout);
expect("ACTS_SerivceAbilityServerSecond_onDisConnect").assertEqual(
data.event);
expect("ACTS_SerivceAbilityServerSecond_onDisConnect_ServiceConnectService_1400")
.assertEqual(data.event);
unsubscribe("ACTS_JsServiceAbility_1400_unsubscribe", subscriber1400);
console.log('ACTS_JsServiceAbility_1400====<end')
done();
......@@ -778,8 +740,8 @@ describe('ActsStServiceAbilityTest', function () {
},
)
} catch (err) {
expect("catch").assertEqual(err);
console.log('ACTS_JsServiceAbility_1400====<end err')
expect().assertFail()
console.log('ACTS_JsServiceAbility_1400====<end err: ' + JSON.stringify(err))
done();
}
})
......@@ -792,29 +754,29 @@ describe('ActsStServiceAbilityTest', function () {
it('ACTS_JsServiceAbility_1500', 0, async function (done) {
console.log('ACTS_JsServiceAbility_1500====<begin');
try {
var mConnIdJsPromise;
await commonEvent.createSubscriber(CommonEventSubscribeInfo1500).then(async (data) => {
let mConnIdJsPromise;
await commonEvent.createSubscriber(CommonEventSubscribeInfo1500).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) => {
commonEvent.subscribe(subscriber1500, (err, data) => {
console.debug("=ACTS_JsServiceAbility_1500 subscribe (err,data)=======>"
+ ("json err【") + JSON.stringify(err) + ("")
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,err=" + err + " ,data=" + data);
if (data.event != "ACTS_SerivceAbilityServer_onDisConnect") {
expect("ACTS_SerivceAbilityServerSecond_onConnect_ServiceConnectService_1500").assertEqual(
data.event);
featureAbility.disconnectAbility(mConnIdJsPromise).then(() => {
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(".catch").assertEqual(err);
console.debug('ACTS_JsServiceAbility_1500====<end .catch(err)');
expect().assertFail()
console.debug('ACTS_JsServiceAbility_1500==== err: ' + JSON.stringify(err));
done();
})
} else {
expect("ACTS_SerivceAbilityServer_onDisConnect").assertEqual(
data.event);
expect("ACTS_SerivceAbilityServer_onDisConnect_ServiceConnectService_1500")
.assertEqual(data.event);
unsubscribe("ACTS_JsServiceAbility_1500_unsubscribe", subscriber1500);
console.log('ACTS_JsServiceAbility_1500====<end')
done();
......@@ -861,5 +823,5 @@ describe('ActsStServiceAbilityTest', function () {
done();
}
})
})
})
}
......@@ -117,6 +117,7 @@ export default {
try {
console.debug('ACTS_SerivceAbilityServer ====>onConnect='
+ want + " , JSON." + JSON.stringify(want));
commonEvent.publish("ACTS_SerivceAbilityServer_onConnect" + "_" + want.action, (err) => { });
function onConnectCallback(element, remote) {
console.debug('ACTS_SerivceAbilityServer_onConnectCallback ====> mConnIdJs='
+ JSON.stringify(mConnIdJs) + " , " + mConnIdJs);
......@@ -147,8 +148,6 @@ export default {
onFailed: onFailedCallback,
},
)
} else {
commonEvent.publish("ACTS_SerivceAbilityServer_onConnect" + "_" + want.action, (err) => { });
}
} catch (err) {
console.log("ACTS_SerivceAbilityServer ====< error:" + err)
......@@ -159,12 +158,9 @@ export default {
onDisconnect(want) {
console.debug('ACTS_SerivceAbilityServer ====>onDisConnect='
+ want + " , JSON." + JSON.stringify(want));
commonEvent.publish("ACTS_SerivceAbilityServer_onDisConnect" + want.action, (err) => {
if (err.code) {
console.debug('ACTS_SerivceAbilityServer_onDisConnect publish err=====>' + err);
} else {
console.debug('ACTS_SerivceAbilityServer_onDisConnect =====<'
+ want.action);
commonEvent.publish("ACTS_SerivceAbilityServer_onDisConnect_" + want.action, (err) => {
console.debug('ACTS_SerivceAbilityServer_onDisConnect ===' + want.action);
});
if (want.action == 'ServiceConnectService_1300' || want.action == 'ServiceConnectService_1400'
|| want.action == 'ServiceConnectService_1500' || want.action == 'ServiceConnectService_1501'
|| want.action == 'ServiceConnectService_1600' || want.action == 'ServiceConnectService_1601'
......@@ -174,8 +170,6 @@ export default {
+ ("json err=") + JSON.stringify(err) + " , " + want.action);
})
}
}
});
},
onReady() {
console.debug('ACTS_SerivceAbilityServer ====<onReady');
......
......@@ -49,15 +49,9 @@ class StubTest extends rpc.RemoteObject {
}
}
function sleep(delay) {
let start = new Date().getTime();
while (true) {
if (new Date().getTime() - start > delay) {
break;
}
}
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
export default {
onStart(want) {
console.debug('ACTS_SerivceAbilityServerSecond ====>onStart='
......@@ -157,7 +151,7 @@ export default {
onDisconnect(want) {
console.debug('ACTS_SerivceAbilityServerSecond ====>onDisConnect='
+ want + " , JSON." + JSON.stringify(want));
commonEvent.publish("ACTS_SerivceAbilityServerSecond_onDisConnect", (err) => {
commonEvent.publish("ACTS_SerivceAbilityServerSecond_onDisConnect_" + want.action, (err) => {
if (err.code) {
console.debug('ACTS_SerivceAbilityServerSecond_onDisConnect publish err=====>' + err);
} else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册