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

和Beta3同步

Change-Id: Ic1b2e6aeaa95672fa5fbd9d4dad92f02135dab0e
Signed-off-by: NHuangXW <huangxinwei4@huawei.com>
上级 09aaa0db
......@@ -15,851 +15,813 @@
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 () {
let bundleName = "com.amsst.stserviceabilityserver";
let abilityName = "com.amsst.stserviceabilityserver.ServiceAbility";
describe('ActsStServiceAbilityTest', function () {
let bundleName = "com.amsst.stserviceabilityserver";
let abilityName = "com.amsst.stserviceabilityserver.ServiceAbility";
var subscriber0100;
var CommonEventSubscribeInfo0100 = {
events: ["ACTS_SerivceAbilityServer_onCommand_PageStartService_0100",
],
};
var subscriber0200;
var CommonEventSubscribeInfo0200 = {
events: ["ACTS_SerivceAbilityServer_onCommand_PageStartService_0200",
],
};
var subscriber0300;
var CommonEventSubscribeInfo0300 = {
events: ["ACTS_SerivceAbilityServer_onCommand_PageStartService_0300",
let subscriber0100;
let CommonEventSubscribeInfo0100 = {
events: ["ACTS_SerivceAbilityServer_onCommand_PageStartService_0100",
],
};
let subscriber0200;
let CommonEventSubscribeInfo0200 = {
events: ["ACTS_SerivceAbilityServer_onCommand_PageStartService_0200",
],
};
let subscriber0300;
let CommonEventSubscribeInfo0300 = {
events: ["ACTS_SerivceAbilityServer_onCommand_PageStartService_0300",
"ACTS_SerivceAbilityServer_onCommand_PageStartService_0301",
],
};
var subscriber0400;
var CommonEventSubscribeInfo0400 = {
events: ["ACTS_SerivceAbilityServer_onCommand_PageStartService_0400",
],
};
let subscriber0400;
let CommonEventSubscribeInfo0400 = {
events: ["ACTS_SerivceAbilityServer_onCommand_PageStartService_0400",
"ACTS_SerivceAbilityServer_onCommand_PageStartService_0401",
],
};
var subscriber0500;
var CommonEventSubscribeInfo0500 = {
events: ["ACTS_SerivceAbilityServer_onConnect_PageConnectService_0500",
"ACTS_SerivceAbilityServer_onDisConnect",
],
};
var subscriber0600;
var CommonEventSubscribeInfo0600 = {
events: ["ACTS_SerivceAbilityServer_onConnect_PageConnectService_0600",
"ACTS_SerivceAbilityServer_onDisConnect",
],
};
var subscriber0900;
var CommonEventSubscribeInfo0900 = {
events: ["ACTS_SerivceAbilityServerSecond_onCommand_ServiceStartService_0900",
],
};
var subscriber1000;
var CommonEventSubscribeInfo1000 = {
events: ["ACTS_SerivceAbilityServerSecond_onCommand_ServiceStartService_1000",
],
};
var subscriber1300;
var CommonEventSubscribeInfo1300 = {
events: ["ACTS_SerivceAbilityServerSecond_onConnect_ServiceConnectService_1300",
"ACTS_SerivceAbilityServerSecond_onDisConnect",
],
};
var subscriber1400;
var CommonEventSubscribeInfo1400 = {
events: ["ACTS_SerivceAbilityServerSecond_onConnect_ServiceConnectService_1400",
"ACTS_SerivceAbilityServerSecond_onDisConnect",
],
};
var subscriber1500;
var CommonEventSubscribeInfo1500 = {
events: ["ACTS_SerivceAbilityServerSecond_onConnect_ServiceConnectService_1500",
"ACTS_SerivceAbilityServer_onDisConnect",
],
};
],
};
let subscriber0500;
let CommonEventSubscribeInfo0500 = {
events: ["ACTS_SerivceAbilityServer_onConnect_PageConnectService_0500",
"ACTS_SerivceAbilityServer_onDisConnect_PageConnectService_0500",
],
};
let subscriber0600;
let CommonEventSubscribeInfo0600 = {
events: ["ACTS_SerivceAbilityServer_onConnect_PageConnectService_0600",
"ACTS_SerivceAbilityServer_onDisConnect_PageConnectService_0600",
],
};
let subscriber0900;
let CommonEventSubscribeInfo0900 = {
events: ["ACTS_SerivceAbilityServerSecond_onCommand_ServiceStartService_0900",
],
};
let subscriber1000;
let CommonEventSubscribeInfo1000 = {
events: ["ACTS_SerivceAbilityServerSecond_onCommand_ServiceStartService_1000",
],
};
let subscriber1300;
let CommonEventSubscribeInfo1300 = {
events: ["ACTS_SerivceAbilityServerSecond_onConnect_ServiceConnectService_1300",
"ACTS_SerivceAbilityServerSecond_onDisConnect_ServiceConnectService_1300",
],
};
let subscriber1400;
let CommonEventSubscribeInfo1400 = {
events: ["ACTS_SerivceAbilityServerSecond_onConnect_ServiceConnectService_1400",
"ACTS_SerivceAbilityServerSecond_onDisConnect_ServiceConnectService_1400",
],
};
let subscriber1500;
let CommonEventSubscribeInfo1500 = {
events: ["ACTS_SerivceAbilityServerSecond_onConnect_ServiceConnectService_1500",
"ACTS_SerivceAbilityServer_onDisConnect_ServiceConnectService_1500",
],
};
function unsubscribe(caller, subscriber) {
commonEvent.unsubscribe(subscriber, (err, data) => {
console.debug("=ACTS_unsubscribe (err,data)=======>"
function unsubscribe(caller, subscriber) {
commonEvent.unsubscribe(subscriber, (err, data) => {
console.debug("=ACTS_unsubscribe (err,data)=======>"
+ (caller)
+ (" , 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);
})
});
}
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
let gSetTimeout = 2000
afterEach(async (done) => {
setTimeout(function () {
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)=======>"
/*
* @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((data) => {
console.debug("=ACTS_JsServiceAbility_0100 createSubscriber .then(data)=======>"
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,data=" + data);
subscriber0100 = data;
commonEvent.subscribe(subscriber0100, async (err, data) => {
console.debug("=ACTS_JsServiceAbility_0100 subscribe (err,data)=======>"
subscriber0100 = data;
commonEvent.subscribe(subscriber0100, (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:
expect("ACTS_SerivceAbilityServer_onCommand_PageStartService_0100").assertEqual(
data.event);
unsubscribe("ACTS_JsServiceAbility_0100_unsubscribe", subscriber0100);
console.debug('ACTS_JsServiceAbility_0100====<end');
done();
});
})
featureAbility.startAbility(
{
bundleName: bundleName,
abilityName: abilityName,
action: "PageStartService_0100",
},
}
).then(data => {
console.debug("=ACTS_JsServiceAbility_0100 .then(data)=======>"
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));
}).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();
})
} catch (err) {
expect("catch").assertEqual(err);
console.debug('ACTS_JsServiceAbility_0100====<end catch(err)');
done();
}
})
}
})
/*
* @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)=======>"
/*
* @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((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)=======>"
subscriber0200 = data;
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);
unsubscribe("ACTS_JsServiceAbility_0200_unsubscribe", subscriber0200);
console.debug('ACTS_JsServiceAbility_0200====<end');
done()
});
})
featureAbility.startAbility(
{
want:
expect("ACTS_SerivceAbilityServer_onCommand_PageStartService_0200").assertEqual(
data.event);
unsubscribe("ACTS_JsServiceAbility_0200_unsubscribe", subscriber0200);
console.debug('ACTS_JsServiceAbility_0200====<end');
done()
});
})
featureAbility.startAbility(
{
bundleName: bundleName,
abilityName: abilityName,
action: "PageStartService_0200",
},
}, (err, data) => {
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);
+ ("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();
}
})
)
} catch (err) {
expect().assertFail()
console.debug('ACTS_JsServiceAbility_0200==== err: ' + JSON.stringify(err));
done();
}
})
/*
* @tc.number: ACTS_JsServiceAbility_0300
* @tc.name: featureAbility.startAbility : Use page to test startAbiltiy service.
* @tc.desc: Check the return value of the interface (by Promise)
*/
it('ACTS_JsServiceAbility_0300', 0, async function (done) {
console.debug('ACTS_JsServiceAbility_0300====<begin');
try {
await commonEvent.createSubscriber(CommonEventSubscribeInfo0300).then(async (data) => {
console.debug("=ACTS_JsServiceAbility_0300 createSubscriber .then(data)=======>"
/*
* @tc.number: ACTS_JsServiceAbility_0300
* @tc.name: featureAbility.startAbility : Use page to test startAbiltiy service.
* @tc.desc: Check the return value of the interface (by Promise)
*/
it('ACTS_JsServiceAbility_0300', 0, async function (done) {
console.debug('ACTS_JsServiceAbility_0300====<begin');
try {
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) => {
console.debug("=ACTS_JsServiceAbility_0300 subscribe (err,data)=======>"
subscriber0300 = data;
commonEvent.subscribe(subscriber0300, (err, data) => {
console.debug("=ACTS_JsServiceAbility_0300 subscribe (err,data)=======>"
+ ("json err【") + JSON.stringify(err) + ("")
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,err=" + err + " ,data=" + data);
if (data.event == "ACTS_SerivceAbilityServer_onCommand_PageStartService_0300") {
expect("ACTS_SerivceAbilityServer_onCommand_PageStartService_0300").assertEqual(
data.event);
featureAbility.startAbility(
{
want:
if (data.event == "ACTS_SerivceAbilityServer_onCommand_PageStartService_0300") {
expect("ACTS_SerivceAbilityServer_onCommand_PageStartService_0300").assertEqual(
data.event);
featureAbility.startAbility(
{
bundleName: bundleName,
abilityName: abilityName,
action: "PageStartService_0301",
},
}
).then(data => {
console.debug("=ACTS_JsServiceAbility_0300 .then(data) 2=======>"
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(".catch").assertEqual(err);
console.debug('ACTS_JsServiceAbility_0300====<end .catch(err) 2');
}).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();
})
} else {
expect("ACTS_SerivceAbilityServer_onCommand_PageStartService_0301").assertEqual(
data.event);
unsubscribe("ACTS_JsServiceAbility_0300_unsubscribe", subscriber0300);
console.debug('ACTS_JsServiceAbility_0300====<end');
done();
}
});
})
featureAbility.startAbility(
{
want:
}
});
})
featureAbility.startAbility(
{
bundleName: bundleName,
abilityName: abilityName,
action: "PageStartService_0300",
},
}
).then(data => {
console.debug("=ACTS_JsServiceAbility_0300 .then(data) 1=======>"
want:
{
bundleName: bundleName,
abilityName: abilityName,
action: "PageStartService_0300",
},
}
).then(data => {
console.debug("=ACTS_JsServiceAbility_0300 .then(data) 1=======>"
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,data=" + data);
}).catch(err => {
expect(".catch").assertEqual(err);
console.debug('ACTS_JsServiceAbility_0300====<end .catch(err) 1');
}).catch(err => {
expect(".catch").assertEqual(err);
console.debug('ACTS_JsServiceAbility_0300====<end .catch(err) 1');
done();
})
} catch (err) {
expect().assertFail()
console.debug('ACTS_JsServiceAbility_0300==== err: ' + JSON.stringify(err));
done();
})
} catch (err) {
expect("catch").assertEqual(err);
console.debug('ACTS_JsServiceAbility_0300====<end catch(err)');
done();
}
})
}
})
/*
* @tc.number: ACTS_JsServiceAbility_0400
* @tc.name: featureAbility.startAbility : Use page to test startAbiltiy service.
* @tc.desc: Check the return value of the interface (by AsyncCallback)
*/
it('ACTS_JsServiceAbility_0400', 0, async function (done) {
console.debug('ACTS_JsServiceAbility_0400====<begin');
try {
await commonEvent.createSubscriber(CommonEventSubscribeInfo0400).then(async (data) => {
console.debug("=ACTS_JsServiceAbility_0400 createSubscriber .then(data)=======>"
/*
* @tc.number: ACTS_JsServiceAbility_0400
* @tc.name: featureAbility.startAbility : Use page to test startAbiltiy service.
* @tc.desc: Check the return value of the interface (by AsyncCallback)
*/
it('ACTS_JsServiceAbility_0400', 0, async function (done) {
console.debug('ACTS_JsServiceAbility_0400====<begin');
try {
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) => {
console.debug("=ACTS_JsServiceAbility_0400 subscribe (err,data)=======>"
subscriber0400 = data;
commonEvent.subscribe(subscriber0400, (err, data) => {
console.debug("=ACTS_JsServiceAbility_0400 subscribe (err,data)=======>"
+ ("json err【") + JSON.stringify(err) + ("")
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,err=" + err + " ,data=" + data);
if (data.event == "ACTS_SerivceAbilityServer_onCommand_PageStartService_0400") {
expect("ACTS_SerivceAbilityServer_onCommand_PageStartService_0400").assertEqual(
data.event);
featureAbility.startAbility(
{
want:
if (data.event == "ACTS_SerivceAbilityServer_onCommand_PageStartService_0400") {
expect("ACTS_SerivceAbilityServer_onCommand_PageStartService_0400").assertEqual(
data.event);
featureAbility.startAbility(
{
bundleName: bundleName,
abilityName: abilityName,
action: "PageStartService_0401",
},
}, (err, data) => {
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);
+ ("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:
)
} 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(
{
bundleName: bundleName,
abilityName: abilityName,
action: "PageStartService_0400",
},
}, (err, data) => {
want:
{
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);
+ ("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)');
done();
}
})
)
} catch (err) {
expect().assertFail()
console.debug('ACTS_JsServiceAbility_0400==== err: ' + JSON.stringify(err));
done();
}
})
/*
* @tc.number: ACTS_JsServiceAbility_0500
* @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 {
var mConnIdJsPromise;
await commonEvent.createSubscriber(CommonEventSubscribeInfo0500).then(async (data) => {
console.debug("=ACTS_JsServiceAbility_0500 createSubscriber .then(data)=======>"
/*
* @tc.number: ACTS_JsServiceAbility_0500
* @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, async (err, data) => {
console.debug("=ACTS_JsServiceAbility_0500 subscribe (err,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='
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='
console.debug('ACTS_JsServiceAbility_0500_onConnectCallback ====> element='
+ JSON.stringify(element) + " , " + element);
console.debug('ACTS_JsServiceAbility_0500_onConnectCallback ====> remote='
console.debug('ACTS_JsServiceAbility_0500_onConnectCallback ====> remote='
+ JSON.stringify(remote) + " , " + remote);
console.debug('ACTS_JsServiceAbility_0500_onConnectCallback ====> remote is proxy:'
console.debug('ACTS_JsServiceAbility_0500_onConnectCallback ====> remote is proxy:'
+ (remote instanceof rpc.RemoteProxy));
}
}
function onDisconnectCallback(element) {
console.debug('ACTS_JsServiceAbility_0500_onDisconnectCallback ====> element='
function onDisconnectCallback(element) {
console.debug('ACTS_JsServiceAbility_0500_onDisconnectCallback ====> element='
+ JSON.stringify(element) + " , " + element);
}
}
function onFailedCallback(code) {
console.debug('ACTS_JsServiceAbility_0500_onFailedCallback ====> code='
function onFailedCallback(code) {
console.debug('ACTS_JsServiceAbility_0500_onFailedCallback ====> code='
+ JSON.stringify(code) + " , " + code)
}
}
mConnIdJsPromise = featureAbility.connectAbility(
{
bundleName: bundleName,
abilityName: abilityName,
action: "PageConnectService_0500",
},
{
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback,
},
)
} catch (err) {
expect("catch").assertEqual(err);
console.log('ACTS_JsServiceAbility_0500====<end err')
done();
}
})
mConnIdJsPromise = featureAbility.connectAbility(
{
bundleName: bundleName,
abilityName: abilityName,
action: "PageConnectService_0500",
},
{
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback,
},
)
} catch (err) {
expect().assertFail()
console.log('ACTS_JsServiceAbility_0500==== err: ' + JSON.stringify(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)=======>"
/*
* @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 {
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) => {
console.debug("=ACTS_JsServiceAbility_0600 subscribe (err,data)=======>"
subscriber0600 = 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);
featureAbility.disconnectAbility(mConnIdJsAsyncCallback, (err) => {
console.debug("=ACTS_JsServiceAbility_0600 disconnectAbility err====>"
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')
})
} else {
expect("ACTS_SerivceAbilityServer_onDisConnect_PageConnectService_0600")
.assertEqual(data.event);
unsubscribe("ACTS_JsServiceAbility_0600_unsubscribe", subscriber0600);
console.log('ACTS_JsServiceAbility_0600====<end')
done();
}, gSetTimeout);
} else {
clearTimeout(currentAlertTimeout);
expect("ACTS_SerivceAbilityServer_onDisConnect").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='
}
});
})
function onConnectCallback(element, remote) {
console.debug('ACTS_JsServiceAbility_0600_onConnectCallback ====> mConnIdJsAsyncCallback='
+ JSON.stringify(mConnIdJsAsyncCallback) + " , " + mConnIdJsAsyncCallback);
console.debug('ACTS_JsServiceAbility_0600_onConnectCallback ====> element='
console.debug('ACTS_JsServiceAbility_0600_onConnectCallback ====> element='
+ JSON.stringify(element) + " , " + element);
console.debug('ACTS_JsServiceAbility_0600_onConnectCallback ====> remote='
console.debug('ACTS_JsServiceAbility_0600_onConnectCallback ====> remote='
+ JSON.stringify(remote) + " , " + remote);
console.debug('ACTS_JsServiceAbility_0600_onConnectCallback ====> remote is proxy:'
console.debug('ACTS_JsServiceAbility_0600_onConnectCallback ====> remote is proxy:'
+ (remote instanceof rpc.RemoteProxy));
}
}
function onDisconnectCallback(element) {
console.debug('ACTS_JsServiceAbility_0600_onDisconnectCallback ====> element='
function onDisconnectCallback(element) {
console.debug('ACTS_JsServiceAbility_0600_onDisconnectCallback ====> element='
+ JSON.stringify(element) + " , " + element);
}
}
function onFailedCallback(code) {
console.debug('ACTS_JsServiceAbility_0600_onFailedCallback ====> code='
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();
}
}
mConnIdJsAsyncCallback = featureAbility.connectAbility(
{
bundleName: bundleName,
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();
}
})
mConnIdJsAsyncCallback = featureAbility.connectAbility(
{
bundleName: bundleName,
abilityName: abilityName,
action: "PageConnectService_0600",
},
{
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback,
},
)
} catch (err) {
expect().assertFail()
console.log('ACTS_JsServiceAbility_0600==== err: ' + JSON.stringify(err))
done();
}
})
/*
* @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)=======>"
/*
* @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((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)=======>"
subscriber0900 = 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();
});
})
await sleep(500)
featureAbility.startAbility(
{
want:
expect("ACTS_SerivceAbilityServerSecond_onCommand_ServiceStartService_0900").assertEqual(
data.event);
unsubscribe("ACTS_JsServiceAbility_0900_unsubscribe", subscriber0900);
console.debug('ACTS_JsServiceAbility_0900====<end');
done();
});
})
await sleep(500)
featureAbility.startAbility(
{
bundleName: bundleName,
abilityName: abilityName,
action: "ServiceStartService_0900",
},
}
).then(data => {
console.debug("=ACTS_JsServiceAbility_0900 .then(data)=======>"
want:
{
bundleName: bundleName,
abilityName: abilityName,
action: "ServiceStartService_0900",
},
}
).then(data => {
console.debug("=ACTS_JsServiceAbility_0900 .then(data)=======>"
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,data=" + data);
}).catch(err => {
expect(".catch").assertEqual(err);
console.debug('ACTS_JsServiceAbility_0900====<end .catch(err)');
}).catch(err => {
expect(".catch").assertEqual(err);
console.debug('ACTS_JsServiceAbility_0900====<end .catch(err)');
done();
})
} catch (err) {
expect().assertFail()
console.debug('ACTS_JsServiceAbility_0900==== err: ' + JSON.stringify(err));
done();
})
} catch (err) {
expect("catch").assertEqual(err);
console.debug('ACTS_JsServiceAbility_0900====<end catch(err)');
done();
}
})
}
})
/*
* @tc.number: ACTS_JsServiceAbility_1000
* @tc.name: particleability.startAbility : Use page to test startAbiltiy service.
* @tc.desc: Check the return value of the interface (by AsyncCallback)
*/
it('ACTS_JsServiceAbility_1000', 0, async function (done) {
console.debug('ACTS_JsServiceAbility_1000====<begin');
try {
await commonEvent.createSubscriber(CommonEventSubscribeInfo1000).then(async (data) => {
console.debug("=ACTS_JsServiceAbility_1000 createSubscriber .then(data)=======>"
/*
* @tc.number: ACTS_JsServiceAbility_1000
* @tc.name: particleability.startAbility : Use page to test startAbiltiy service.
* @tc.desc: Check the return value of the interface (by AsyncCallback)
*/
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, async (err, data) => {
console.debug("=ACTS_JsServiceAbility_1000 subscribe (err,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);
await sleep(1000)
unsubscribe("ACTS_JsServiceAbility_1000_unsubscribe", subscriber1000);
console.debug('ACTS_JsServiceAbility_1000====<end');
done()
});
})
await sleep(500)
featureAbility.startAbility(
{
want:
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(
{
bundleName: bundleName,
abilityName: abilityName,
action: "ServiceStartService_1000",
},
}, (err, data) => {
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);
+ ("json err【") + JSON.stringify(err) + ("")
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,err=" + err + " ,data=" + data);
}
)
} catch (err) {
expect("catch").assertEqual(err);
console.debug('ACTS_JsServiceAbility_1000====<end catch(err)');
done();
}
})
)
} catch (err) {
expect().assertFail()
console.debug('ACTS_JsServiceAbility_1000==== err: ' + JSON.stringify(err));
done();
}
})
/*
* @tc.number: ACTS_JsServiceAbility_1300
* @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 {
var mConnIdJsPromise;
await commonEvent.createSubscriber(CommonEventSubscribeInfo1300).then(async (data) => {
console.debug("=ACTS_JsServiceAbility_1300 createSubscriber .then(data)=======>"
/*
* @tc.number: ACTS_JsServiceAbility_1300
* @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, async (err, data) => {
console.debug("=ACTS_JsServiceAbility_1300 subscribe (err,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_onDisConnect") {
expect("ACTS_SerivceAbilityServerSecond_onConnect_ServiceConnectService_1300"
).assertEqual(data.event);
featureAbility.disconnectAbility(mConnIdJsPromise).then((err) => {
console.debug("=ACTS_JsServiceAbility_1300 disconnectAbility err====>"
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);
unsubscribe("ACTS_JsServiceAbility_1300_unsubscribe", subscriber1300);
console.log('ACTS_JsServiceAbility_1300====<end')
done();
}
});
})
function onConnectCallback(element, remote) {
console.debug('ACTS_JsServiceAbility_1300_onConnectCallback ====> mConnIdJsPromise='
})
}
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='
console.debug('ACTS_JsServiceAbility_1300_onConnectCallback ====> element='
+ JSON.stringify(element) + " , " + element);
console.debug('ACTS_JsServiceAbility_1300_onConnectCallback ====> remote='
console.debug('ACTS_JsServiceAbility_1300_onConnectCallback ====> remote='
+ JSON.stringify(remote) + " , " + remote);
console.debug('ACTS_JsServiceAbility_1300_onConnectCallback ====> remote is proxy:'
console.debug('ACTS_JsServiceAbility_1300_onConnectCallback ====> remote is proxy:'
+ (remote instanceof rpc.RemoteProxy));
}
}
function onDisconnectCallback(element) {
console.debug('ACTS_JsServiceAbility_1300_onDisconnectCallback ====> element='
function onDisconnectCallback(element) {
console.debug('ACTS_JsServiceAbility_1300_onDisconnectCallback ====> element='
+ JSON.stringify(element) + " , " + element);
unsubscribe("ACTS_JsServiceAbility_1300_unsubscribe", subscriber1300);
console.log('ACTS_JsServiceAbility_1300====<end onDisconnectCallback')
done();
}
unsubscribe("ACTS_JsServiceAbility_1300_unsubscribe", subscriber1300);
console.log('ACTS_JsServiceAbility_1300====<end onDisconnectCallback')
done();
}
function onFailedCallback(code) {
console.debug('ACTS_JsServiceAbility_1300_onFailedCallback ====> code='
function onFailedCallback(code) {
console.debug('ACTS_JsServiceAbility_1300_onFailedCallback ====> code='
+ JSON.stringify(code) + " , " + code)
}
}
mConnIdJsPromise = featureAbility.connectAbility(
{
bundleName: bundleName,
abilityName: abilityName,
action: "ServiceConnectService_1300",
},
{
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback,
},
)
} catch (err) {
expect("catch").assertEqual(err);
console.log('ACTS_JsServiceAbility_1300====<end err')
done();
}
})
mConnIdJsPromise = featureAbility.connectAbility(
{
bundleName: bundleName,
abilityName: abilityName,
action: "ServiceConnectService_1300",
},
{
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback,
},
)
} 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 {
var currentAlertTimeout;
var mConnIdJsAsyncCallback;
await commonEvent.createSubscriber(CommonEventSubscribeInfo1400).then(async (data) => {
console.debug("=ACTS_JsServiceAbility_1400 createSubscriber .then(data)=======>"
/*
* @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) + ("")
+ " ,data=" + data);
subscriber1400 = data;
commonEvent.subscribe(subscriber1400, async (err, data) => {
console.debug("=ACTS_JsServiceAbility_1400 subscribe (err,data)=======>"
subscriber1400 = 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);
featureAbility.disconnectAbility(mConnIdJsAsyncCallback, (err) => {
console.debug("=ACTS_JsServiceAbility_1400 disconnectAbility err====>"
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')
})
} else {
expect("ACTS_SerivceAbilityServerSecond_onDisConnect_ServiceConnectService_1400")
.assertEqual(data.event);
unsubscribe("ACTS_JsServiceAbility_1400_unsubscribe", subscriber1400);
console.log('ACTS_JsServiceAbility_1400====<end')
done();
}, gSetTimeout);
} else {
clearTimeout(currentAlertTimeout);
expect("ACTS_SerivceAbilityServerSecond_onDisConnect").assertEqual(
data.event);
unsubscribe("ACTS_JsServiceAbility_1400_unsubscribe", subscriber1400);
console.log('ACTS_JsServiceAbility_1400====<end')
done();
}
});
})
function onConnectCallback(element, remote) {
console.debug('ACTS_JsServiceAbility_1400_onConnectCallback ====> mConnIdJsAsyncCallback='
}
});
})
function onConnectCallback(element, remote) {
console.debug('ACTS_JsServiceAbility_1400_onConnectCallback ====> mConnIdJsAsyncCallback='
+ JSON.stringify(mConnIdJsAsyncCallback) + " , " + mConnIdJsAsyncCallback);
console.debug('ACTS_JsServiceAbility_1400_onConnectCallback ====> element='
console.debug('ACTS_JsServiceAbility_1400_onConnectCallback ====> element='
+ JSON.stringify(element) + " , " + element);
console.debug('ACTS_JsServiceAbility_1400_onConnectCallback ====> remote='
console.debug('ACTS_JsServiceAbility_1400_onConnectCallback ====> remote='
+ JSON.stringify(remote) + " , " + remote);
console.debug('ACTS_JsServiceAbility_1400_onConnectCallback ====> remote is proxy:'
console.debug('ACTS_JsServiceAbility_1400_onConnectCallback ====> remote is proxy:'
+ (remote instanceof rpc.RemoteProxy));
}
}
function onDisconnectCallback(element) {
console.debug('ACTS_JsServiceAbility_1400_onDisconnectCallback ====> element='
function onDisconnectCallback(element) {
console.debug('ACTS_JsServiceAbility_1400_onDisconnectCallback ====> element='
+ JSON.stringify(element) + " , " + element);
}
}
function onFailedCallback(code) {
console.debug('ACTS_JsServiceAbility_1400_onFailedCallback ====> code='
function onFailedCallback(code) {
console.debug('ACTS_JsServiceAbility_1400_onFailedCallback ====> code='
+ JSON.stringify(code) + " , " + code)
}
}
mConnIdJsAsyncCallback = featureAbility.connectAbility(
{
bundleName: bundleName,
abilityName: abilityName,
action: "ServiceConnectService_1400",
},
{
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback,
},
)
} catch (err) {
expect("catch").assertEqual(err);
console.log('ACTS_JsServiceAbility_1400====<end err')
done();
}
})
mConnIdJsAsyncCallback = featureAbility.connectAbility(
{
bundleName: bundleName,
abilityName: abilityName,
action: "ServiceConnectService_1400",
},
{
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback,
},
)
} catch (err) {
expect().assertFail()
console.log('ACTS_JsServiceAbility_1400====<end err: ' + JSON.stringify(err))
done();
}
})
/*
* @tc.number: ACTS_JsServiceAbility_1500
* @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_1500', 0, async function (done) {
console.log('ACTS_JsServiceAbility_1500====<begin');
try {
var mConnIdJsPromise;
await commonEvent.createSubscriber(CommonEventSubscribeInfo1500).then(async (data) => {
console.debug("=ACTS_JsServiceAbility_1500 createSubscriber .then(data)=======>"
/*
* @tc.number: ACTS_JsServiceAbility_1500
* @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_1500', 0, async function (done) {
console.log('ACTS_JsServiceAbility_1500====<begin');
try {
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) => {
console.debug("=ACTS_JsServiceAbility_1500 subscribe (err,data)=======>"
subscriber1500 = 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(() => {
}).catch(err => {
expect(".catch").assertEqual(err);
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();
})
} else {
expect("ACTS_SerivceAbilityServer_onDisConnect").assertEqual(
data.event);
unsubscribe("ACTS_JsServiceAbility_1500_unsubscribe", subscriber1500);
console.log('ACTS_JsServiceAbility_1500====<end')
done();
}
});
})
function onConnectCallback(element, remote) {
console.debug('ACTS_JsServiceAbility_1500_onConnectCallback ====> mConnIdJsPromise='
}
});
})
function onConnectCallback(element, remote) {
console.debug('ACTS_JsServiceAbility_1500_onConnectCallback ====> mConnIdJsPromise='
+ JSON.stringify(mConnIdJsPromise) + " , " + mConnIdJsPromise);
console.debug('ACTS_JsServiceAbility_1500_onConnectCallback ====> element='
console.debug('ACTS_JsServiceAbility_1500_onConnectCallback ====> element='
+ JSON.stringify(element) + " , " + element);
console.debug('ACTS_JsServiceAbility_1500_onConnectCallback ====> remote='
console.debug('ACTS_JsServiceAbility_1500_onConnectCallback ====> remote='
+ JSON.stringify(remote) + " , " + remote);
}
}
function onDisconnectCallback(element) {
console.debug('ACTS_JsServiceAbility_1500_onDisconnectCallback ====> element='
function onDisconnectCallback(element) {
console.debug('ACTS_JsServiceAbility_1500_onDisconnectCallback ====> element='
+ JSON.stringify(element) + " , " + element);
unsubscribe("ACTS_JsServiceAbility_1500_unsubscribe", subscriber1500);
console.log('ACTS_JsServiceAbility_1500====<end onDisconnectCallback')
done();
}
unsubscribe("ACTS_JsServiceAbility_1500_unsubscribe", subscriber1500);
console.log('ACTS_JsServiceAbility_1500====<end onDisconnectCallback')
done();
}
function onFailedCallback(code) {
console.debug('ACTS_JsServiceAbility_1500_onFailedCallback ====> code='
function onFailedCallback(code) {
console.debug('ACTS_JsServiceAbility_1500_onFailedCallback ====> code='
+ JSON.stringify(code) + " , " + code)
}
}
mConnIdJsPromise = featureAbility.connectAbility(
{
bundleName: bundleName,
abilityName: abilityName,
action: "ServiceConnectService_1500",
},
{
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback,
},
)
} catch (err) {
expect("catch").assertEqual(err);
console.log('ACTS_JsServiceAbility_1500====<end err')
done();
}
mConnIdJsPromise = featureAbility.connectAbility(
{
bundleName: bundleName,
abilityName: abilityName,
action: "ServiceConnectService_1500",
},
{
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback,
},
)
} catch (err) {
expect("catch").assertEqual(err);
console.log('ACTS_JsServiceAbility_1500====<end err')
done();
}
})
})
})
}
\ No newline at end of file
}
......@@ -61,7 +61,7 @@ function sleep(delay) {
export default {
onStart(want) {
console.debug('ACTS_SerivceAbilityServer 0425 ====>onStart .ts 0851 ='
+ want + " , JSON." + JSON.stringify(want));
+ want + " , JSON." + JSON.stringify(want));
commonEvent.publish("ACTS_SerivceAbilityServer_onStart", (err) => { });
},
onStop() {
......@@ -70,8 +70,8 @@ export default {
},
onCommand(want, restart, startId) {
console.debug('ACTS_SerivceAbilityServer ====>onCommand='
+ "JSON(want)=" + JSON.stringify(want)
+ " ,restart=" + restart + " ,startId=" + startId);
+ "JSON(want)=" + JSON.stringify(want)
+ " ,restart=" + restart + " ,startId=" + startId);
if (want.action == 'ServiceStartService_0900') {
particleAbility.startAbility(
{
......@@ -83,7 +83,7 @@ export default {
},
}
);
sleep(600)
sleep(600)
} else if (want.action == 'ServiceStartService_1000') {
particleAbility.startAbility(
{
......@@ -94,17 +94,17 @@ export default {
action: "ServiceStartService_1000",
},
}, (err, data) => {
console.debug('ACTS_SerivceAbilityServer start Ability 1000 callback====='
+ err + ', data= ' + data + " , JSON." + JSON.stringify(data));
}
console.debug('ACTS_SerivceAbilityServer start Ability 1000 callback====='
+ err + ', data= ' + data + " , JSON." + JSON.stringify(data));
}
);
} else {
commonEvent.publish("ACTS_SerivceAbilityServer_onCommand" + "_" + want.action, (err) => {
if (!err.code) {
if (want.action == 'PageStartService_0100' || want.action == 'PageStartService_0200'
|| want.action == 'PageStartService_0301' || want.action == 'PageStartService_0401') {
|| want.action == 'PageStartService_0301' || want.action == 'PageStartService_0401') {
console.debug('ACTS_SerivceAbilityServer_onCommand 100 200 301 401.=====>'
+ want.action);
+ want.action);
}
} else {
console.debug('ACTS_SerivceAbilityServer_onCommand publish err=====>' + err);
......@@ -116,25 +116,26 @@ export default {
console.info('ACTS_SerivceAbilityServer ====< onConnect');
try {
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) {
console.debug('ACTS_SerivceAbilityServer_onConnectCallback ====> mConnIdJs='
+ JSON.stringify(mConnIdJs) + " , " + mConnIdJs);
+ JSON.stringify(mConnIdJs) + " , " + mConnIdJs);
console.debug('ACTS_SerivceAbilityServer_onConnectCallback ====> element='
+ JSON.stringify(element) + " , " + element);
+ JSON.stringify(element) + " , " + element);
console.debug('ACTS_SerivceAbilityServer_onConnectCallback ====> remote='
+ JSON.stringify(remote) + " , " + remote);
+ JSON.stringify(remote) + " , " + remote);
}
function onDisconnectCallback(element) {
console.debug('ACTS_SerivceAbilityServer_onDisconnectCallback ====> element='
+ JSON.stringify(element) + " , " + element);
+ JSON.stringify(element) + " , " + element);
}
function onFailedCallback(code) {
console.debug('ACTS_SerivceAbilityServer_onFailedCallback ====> code='
+ JSON.stringify(code) + " , " + code)
+ JSON.stringify(code) + " , " + code)
}
if (want.action == 'ServiceConnectService_1300' || want.action == 'ServiceConnectService_1400'
|| want.action == 'ServiceConnectService_1500' || want.action == 'ServiceConnectService_1600') {
|| want.action == 'ServiceConnectService_1500' || want.action == 'ServiceConnectService_1600') {
mConnIdJs = particleAbility.connectAbility(
{
bundleName: serversecond_bundleName,
......@@ -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)
......@@ -158,39 +157,34 @@ 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);
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'
) {
particleAbility.disconnectAbility(mConnIdJs, (err) => {
console.debug("=ACTS_SerivceAbilityServer_onDisConnect 13 14 15 16 err====>"
+ ("json err=") + JSON.stringify(err) + " , " + want.action);
})
}
}
+ want + " , JSON." + JSON.stringify(want));
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'
) {
particleAbility.disconnectAbility(mConnIdJs, (err) => {
console.debug("=ACTS_SerivceAbilityServer_onDisConnect 13 14 15 16 err====>"
+ ("json err=") + JSON.stringify(err) + " , " + want.action);
})
}
},
onReady() {
console.debug('ACTS_SerivceAbilityServer ====<onReady');
},
onReconnect(want) {
console.debug('ACTS_SerivceAbilityServer ====>onReconnect='
+ want + " , JSON." + JSON.stringify(want));
+ want + " , JSON." + JSON.stringify(want));
commonEvent.publish("ACTS_SerivceAbilityServer_onReconnect" + "_" + want.action, (err) => { });
},
OnAbilityConnectDone(element, remoteObject, resultCode) {
console.debug('ACTS_SerivceAbilityServer ====>OnAbilityConnectDone='
+ element + " , JSON." + JSON.stringify(element)
+ remoteObject + " , JSON." + JSON.stringify(remoteObject)
+ resultCode + " , JSON." + JSON.stringify(resultCode)
+ element + " , JSON." + JSON.stringify(element)
+ remoteObject + " , JSON." + JSON.stringify(remoteObject)
+ resultCode + " , JSON." + JSON.stringify(resultCode)
);
commonEvent.publish("ACTS_SerivceAbilityServer_OnAbilityConnectDone", (err) => { });
},
};
\ No newline at end of file
};
......@@ -49,19 +49,13 @@ 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='
+ want + " , JSON." + JSON.stringify(want));
+ want + " , JSON." + JSON.stringify(want));
commonEvent.publish("ACTS_SerivceAbilityServerSecond_onStart", (err) => { });
},
onStop() {
......@@ -70,26 +64,26 @@ export default {
},
onCommand(want, restart, startId) {
console.debug('ACTS_SerivceAbilityServerSecond ====>onCommand='
+ "JSON(want)=" + JSON.stringify(want)
+ " ,restart=" + restart + " ,startId=" + startId);
+ "JSON(want)=" + JSON.stringify(want)
+ " ,restart=" + restart + " ,startId=" + startId);
commonEvent.publish("ACTS_SerivceAbilityServerSecond_onCommand" + "_" + want.action, (err) => {
console.debug("ACTS_SerivceAbilityServerSecond_onCommand" + "_" + want.action +
"err: " + JSON.stringify(err))
});
});
sleep(500)
},
onConnect(want) {
console.info('ACTS_SerivceAbilityServerSecond ====< onConnect');
try {
console.debug('ACTS_SerivceAbilityServerSecond ====>onConnect='
+ want + " , JSON." + JSON.stringify(want));
+ want + " , JSON." + JSON.stringify(want));
function onConnectCallback(element, remote) {
console.debug('ACTS_SerivceAbilityServerSecond_onConnectCallback ====> want.action='
+ JSON.stringify(want.action) + " , " + want.action);
+ JSON.stringify(want.action) + " , " + want.action);
console.debug('ACTS_SerivceAbilityServerSecond_onConnectCallback ====> element='
+ JSON.stringify(element) + " , " + element);
+ JSON.stringify(element) + " , " + element);
console.debug('ACTS_SerivceAbilityServerSecond_onConnectCallback ====> remote='
+ JSON.stringify(remote) + " , " + remote);
+ JSON.stringify(remote) + " , " + remote);
if (want.action == 'ServiceConnectService_1500' || want.action == 'ServiceConnectService_1600') {
commonEvent.publish("ACTS_SerivceAbilityServerSecond_onConnect" + "_" + want.action, (err) => {
console.debug("publish = ACTS_SerivceAbilityServerSecond_onConnect" + "_" + want.action);
......@@ -99,12 +93,12 @@ export default {
function onDisconnectCallback(element) {
console.debug('ACTS_SerivceAbilityServerSecond_onDisconnectCallback ====> element='
+ JSON.stringify(element) + " , " + element);
+ JSON.stringify(element) + " , " + element);
}
function onFailedCallback(code) {
console.debug('ACTS_SerivceAbilityServerSecond_onFailedCallback ====> code='
+ JSON.stringify(code) + " , " + code)
+ JSON.stringify(code) + " , " + code)
}
if (want.action == 'ServiceConnectService_1500') {
mConnIdJs = particleAbility.connectAbility(
......@@ -156,19 +150,19 @@ export default {
},
onDisconnect(want) {
console.debug('ACTS_SerivceAbilityServerSecond ====>onDisConnect='
+ want + " , JSON." + JSON.stringify(want));
commonEvent.publish("ACTS_SerivceAbilityServerSecond_onDisConnect", (err) => {
+ want + " , JSON." + JSON.stringify(want));
commonEvent.publish("ACTS_SerivceAbilityServerSecond_onDisConnect_" + want.action, (err) => {
if (err.code) {
console.debug('ACTS_SerivceAbilityServerSecond_onDisConnect publish err=====>' + err);
} else {
console.debug('ACTS_SerivceAbilityServerSecond_onDisConnect =====<'
+ want.action);
+ want.action);
if (want.action == 'ServiceConnectService_1500' || want.action == 'ServiceConnectService_1501'
|| want.action == 'ServiceConnectService_1600' || want.action == 'ServiceConnectService_1601'
|| want.action == 'ServiceConnectService_1590') {
|| want.action == 'ServiceConnectService_1600' || want.action == 'ServiceConnectService_1601'
|| want.action == 'ServiceConnectService_1590') {
particleAbility.disconnectAbility(mConnIdJs, (err) => {
console.debug("=ACTS_SerivceAbilityServerSecond_onDisConnect err====>"
+ ("json err=") + JSON.stringify(err) + " , " + want.action);
+ ("json err=") + JSON.stringify(err) + " , " + want.action);
})
}
}
......@@ -179,13 +173,13 @@ export default {
},
onReconnect(want) {
console.debug('ACTS_SerivceAbilityServerSecond ====>onReconnect='
+ want + " , JSON." + JSON.stringify(want));
+ want + " , JSON." + JSON.stringify(want));
},
OnAbilityConnectDone(element, remoteObject, resultCode) {
console.debug('ACTS_SerivceAbilityServerSecond ====>OnAbilityConnectDone='
+ element + " , JSON." + JSON.stringify(element)
+ remoteObject + " , JSON." + JSON.stringify(remoteObject)
+ resultCode + " , JSON." + JSON.stringify(resultCode)
+ element + " , JSON." + JSON.stringify(element)
+ remoteObject + " , JSON." + JSON.stringify(remoteObject)
+ resultCode + " , JSON." + JSON.stringify(resultCode)
);
commonEvent.publish("ACTS_SerivceAbilityServerSecond_OnAbilityConnectDone", (err) => { });
},
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册