提交 8ed20e78 编写于 作者: O openharmony_ci 提交者: Gitee

!882 Update js test code

Merge pull request !882 from blackleon/master_1013
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
import commonEvent from "@ohos.commonevent" import commonEvent from "@ohos.commonevent"
import rpc from "@ohos.rpc" import rpc from "@ohos.rpc"
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'
const TIMEOUT = 9000; const TIMEOUT = 9000;
const START_ABILITY_TIMEOUT = 5000; const START_ABILITY_TIMEOUT = 5000;
...@@ -27,7 +27,7 @@ var subscriberInfoStartAbility_0200 = { ...@@ -27,7 +27,7 @@ var subscriberInfoStartAbility_0200 = {
events: ["ACTS_Particle_StartAbility_0200_CommonEvent"], events: ["ACTS_Particle_StartAbility_0200_CommonEvent"],
}; };
describe('ActsStServiceAbilityTest', function () { describe('ActsParticleAbilityTest', function () {
let bundleName = "com.example.particletestserver"; let bundleName = "com.example.particletestserver";
let abilityName = "com.example.particletestserver.MainAbility"; let abilityName = "com.example.particletestserver.MainAbility";
var mRemote; var mRemote;
...@@ -55,10 +55,10 @@ describe('ActsStServiceAbilityTest', function () { ...@@ -55,10 +55,10 @@ describe('ActsStServiceAbilityTest', function () {
} }
/* /*
* @tc.number: ACTS_ParticleAbility_startAbility_0100 * @tc.number: ACTS_ParticleAbility_startAbility_0100
* @tc.name: ConnectAbility : Connects an ability to a Service ability. * @tc.name: ConnectAbility : Connects an ability to a Service ability and use service to test startAbiltiy.
* @tc.desc: Check the return value of the interface (by Promise) * @tc.desc: Check the event of the interface startAbiltiy (by promise)
*/ */
it('ACTS_ParticleAbility_startAbility_0100', 0, async function (done) { it('ACTS_ParticleAbility_startAbility_0100', 0, async function (done) {
console.log('ACTS_ParticleAbility_startAbility_0100====<begin'); console.log('ACTS_ParticleAbility_startAbility_0100====<begin');
console.log('========StartConnect called'); console.log('========StartConnect called');
...@@ -118,68 +118,68 @@ describe('ActsStServiceAbilityTest', function () { ...@@ -118,68 +118,68 @@ describe('ActsStServiceAbilityTest', function () {
}, TIMEOUT); }, TIMEOUT);
}) })
/* /*
* @tc.number: ACTS_ParticleAbility_startAbility_0200 * @tc.number: ACTS_ParticleAbility_startAbility_0200
* @tc.name: ConnectAbility : Connects an ability to a Service ability. * @tc.name: ConnectAbility : Connects an ability to a Service ability and use service to test startAbiltiy.
* @tc.desc: Check the return value of the interface (by Promise) * @tc.desc: Check the event of the interface startAbiltiy (by callback)
*/ */
it('ACTS_ParticleAbility_startAbility_0200', 0, async function (done) { it('ACTS_ParticleAbility_startAbility_0200', 0, async function (done) {
console.log('ACTS_ParticleAbility_startAbility_0200====<begin'); console.log('ACTS_ParticleAbility_startAbility_0200====<begin');
console.log('========StartConnect called'); console.log('========StartConnect called');
var subscriber; var subscriber;
let id; let id;
let connId; let connId;
function subscribeCallBack(err, data) { function subscribeCallBack(err, data) {
clearTimeout(id); clearTimeout(id);
expect(data.event).assertEqual("ACTS_Particle_StartAbility_0200_CommonEvent"); expect(data.event).assertEqual("ACTS_Particle_StartAbility_0200_CommonEvent");
console.debug("====>Subscribe CallBack data:====>" + JSON.stringify(data)); console.debug("====>Subscribe CallBack data:====>" + JSON.stringify(data));
var result = featureAbility.disconnectAbility( var result = featureAbility.disconnectAbility(
connId, connId,
(error,data) => { (error, data) => {
console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data)
}, },
); );
console.log('DisconnectNative ConnectAbility result : ' + result); console.log('DisconnectNative ConnectAbility result : ' + result);
commonEvent.unsubscribe(subscriber, unSubscribeCallback) commonEvent.unsubscribe(subscriber, unSubscribeCallback)
done(); done();
} }
commonEvent.createSubscriber(subscriberInfoStartAbility_0200).then(async (data) => { commonEvent.createSubscriber(subscriberInfoStartAbility_0200).then(async (data) => {
console.debug("====>Create Subscriber====>"); console.debug("====>Create Subscriber====>");
subscriber = data; subscriber = data;
await commonEvent.subscribe(subscriber, subscribeCallBack); await commonEvent.subscribe(subscriber, subscribeCallBack);
})
function unSubscribeCallback() {
console.debug("====>UnSubscribe CallBack====>");
done();
}
function timeout() {
expect().assertFail();
console.debug('ACTS_ParticleAbility_startAbility_0200 timeout');
commonEvent.unsubscribe(subscriber, unSubscribeCallback)
done();
}
id = setTimeout(timeout, START_ABILITY_TIMEOUT);
connId = await featureAbility.connectAbility(
{
bundleName: bundleName,
abilityName: abilityName,
action: "StartAbilityCallback"
},
{
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback,
},
);
console.log('StartConnectNative ConnectAbility connId : ' + connId);
setTimeout(function () {
console.log('StartConnectNative ConnectAbility timeout')
}, TIMEOUT);
}) })
function unSubscribeCallback() {
console.debug("====>UnSubscribe CallBack====>");
done();
}
function timeout() {
expect().assertFail();
console.debug('ACTS_ParticleAbility_startAbility_0200 timeout');
commonEvent.unsubscribe(subscriber, unSubscribeCallback)
done();
}
id = setTimeout(timeout, START_ABILITY_TIMEOUT);
connId = await featureAbility.connectAbility(
{
bundleName: bundleName,
abilityName: abilityName,
action: "StartAbilityCallback"
},
{
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback,
},
);
console.log('StartConnectNative ConnectAbility connId : ' + connId);
setTimeout(function () {
console.log('StartConnectNative ConnectAbility timeout')
}, TIMEOUT);
})
}) })
\ No newline at end of file
...@@ -63,7 +63,7 @@ describe('ActsAnsGetSlotTestCallback', function () { ...@@ -63,7 +63,7 @@ describe('ActsAnsGetSlotTestCallback', function () {
expect(err.code).assertEqual(0); expect(err.code).assertEqual(0);
console.debug("====>getSlotActsAnsGetSlotTestCallback_0100 data====>" + JSON.stringify(data)); console.debug("====>getSlotActsAnsGetSlotTestCallback_0100 data====>" + JSON.stringify(data));
expect(data.type).assertEqual(notification.SlotType.SOCIAL_COMMUNICATION); expect(data.type).assertEqual(notification.SlotType.SOCIAL_COMMUNICATION);
expect(data.level).assertEqual(3); expect(data.level).assertEqual(4);
expect(data.desc).assertEqual(""); expect(data.desc).assertEqual("");
expect(data.badgeFlag).assertEqual(true); expect(data.badgeFlag).assertEqual(true);
expect(data.bypassDnd).assertEqual(false); expect(data.bypassDnd).assertEqual(false);
...@@ -127,7 +127,7 @@ describe('ActsAnsGetSlotTestCallback', function () { ...@@ -127,7 +127,7 @@ describe('ActsAnsGetSlotTestCallback', function () {
expect(err.code).assertEqual(0); expect(err.code).assertEqual(0);
console.debug("====>getSlotActsAnsGetSlotTestCallback_0300 data====>" + JSON.stringify(data)); console.debug("====>getSlotActsAnsGetSlotTestCallback_0300 data====>" + JSON.stringify(data));
expect(data.type).assertEqual(notification.SlotType.CONTENT_INFORMATION); expect(data.type).assertEqual(notification.SlotType.CONTENT_INFORMATION);
expect(data.level).assertEqual(3); expect(data.level).assertEqual(2);
expect(data.desc).assertEqual(""); expect(data.desc).assertEqual("");
expect(data.badgeFlag).assertEqual(true); expect(data.badgeFlag).assertEqual(true);
expect(data.bypassDnd).assertEqual(false); expect(data.bypassDnd).assertEqual(false);
...@@ -161,7 +161,7 @@ describe('ActsAnsGetSlotTestCallback', function () { ...@@ -161,7 +161,7 @@ describe('ActsAnsGetSlotTestCallback', function () {
expect(err.code).assertEqual(0); expect(err.code).assertEqual(0);
console.debug("====>getSlotActsAnsGetSlotTestCallback_0400 data====>" + JSON.stringify(data)); console.debug("====>getSlotActsAnsGetSlotTestCallback_0400 data====>" + JSON.stringify(data));
expect(data.type).assertEqual(notification.SlotType.OTHER_TYPES); expect(data.type).assertEqual(notification.SlotType.OTHER_TYPES);
expect(data.level).assertEqual(3); expect(data.level).assertEqual(1);
expect(data.desc).assertEqual(""); expect(data.desc).assertEqual("");
expect(data.badgeFlag).assertEqual(true); expect(data.badgeFlag).assertEqual(true);
expect(data.bypassDnd).assertEqual(false); expect(data.bypassDnd).assertEqual(false);
...@@ -195,7 +195,7 @@ describe('ActsAnsGetSlotTestCallback', function () { ...@@ -195,7 +195,7 @@ describe('ActsAnsGetSlotTestCallback', function () {
expect(err.code).assertEqual(0); expect(err.code).assertEqual(0);
console.debug("====>getSlotActsAnsGetSlotTestCallback_0500 data====>" + JSON.stringify(data)); console.debug("====>getSlotActsAnsGetSlotTestCallback_0500 data====>" + JSON.stringify(data));
expect(data.type).assertEqual(notification.SlotType.OTHER_TYPES); expect(data.type).assertEqual(notification.SlotType.OTHER_TYPES);
expect(data.level).assertEqual(3); expect(data.level).assertEqual(1);
expect(data.desc).assertEqual(""); expect(data.desc).assertEqual("");
expect(data.badgeFlag).assertEqual(true); expect(data.badgeFlag).assertEqual(true);
expect(data.bypassDnd).assertEqual(false); expect(data.bypassDnd).assertEqual(false);
......
...@@ -32,7 +32,7 @@ describe('ActsAnsGetSlotTestPromise', function () { ...@@ -32,7 +32,7 @@ describe('ActsAnsGetSlotTestPromise', function () {
console.debug("====>getSlotActsAnsGetSlotTestPromise_0100 enter====>"); console.debug("====>getSlotActsAnsGetSlotTestPromise_0100 enter====>");
console.debug("====>getSlotActsAnsGetSlotTestPromise_0100 data====>" + JSON.stringify(data)); console.debug("====>getSlotActsAnsGetSlotTestPromise_0100 data====>" + JSON.stringify(data));
expect(data.type).assertEqual(notification.SlotType.SOCIAL_COMMUNICATION); expect(data.type).assertEqual(notification.SlotType.SOCIAL_COMMUNICATION);
expect(data.level).assertEqual(3); expect(data.level).assertEqual(4);
expect(data.desc).assertEqual(""); expect(data.desc).assertEqual("");
expect(data.badgeFlag).assertEqual(true); expect(data.badgeFlag).assertEqual(true);
expect(data.bypassDnd).assertEqual(false); expect(data.bypassDnd).assertEqual(false);
...@@ -99,7 +99,7 @@ describe('ActsAnsGetSlotTestPromise', function () { ...@@ -99,7 +99,7 @@ describe('ActsAnsGetSlotTestPromise', function () {
console.debug("====>getSlotPromise CONTENT_INFORMATION ActsAnsGetSlotTestPromise_0300 enter====>"); console.debug("====>getSlotPromise CONTENT_INFORMATION ActsAnsGetSlotTestPromise_0300 enter====>");
console.debug("====>getSlotPromise ActsAnsGetSlotTestPromise_0300 data====>" + JSON.stringify(data)); console.debug("====>getSlotPromise ActsAnsGetSlotTestPromise_0300 data====>" + JSON.stringify(data));
expect(data.type).assertEqual(notification.SlotType.CONTENT_INFORMATION); expect(data.type).assertEqual(notification.SlotType.CONTENT_INFORMATION);
expect(data.level).assertEqual(3); expect(data.level).assertEqual(2);
expect(data.desc).assertEqual(""); expect(data.desc).assertEqual("");
expect(data.badgeFlag).assertEqual(true); expect(data.badgeFlag).assertEqual(true);
expect(data.bypassDnd).assertEqual(false); expect(data.bypassDnd).assertEqual(false);
...@@ -133,7 +133,7 @@ describe('ActsAnsGetSlotTestPromise', function () { ...@@ -133,7 +133,7 @@ describe('ActsAnsGetSlotTestPromise', function () {
console.debug("====>getSlotPromise OTHER_TYPES ActsAnsGetSlotTestPromise_0400 enter====>"); console.debug("====>getSlotPromise OTHER_TYPES ActsAnsGetSlotTestPromise_0400 enter====>");
console.debug("====>getSlotPromise ActsAnsGetSlotTestPromise_0400 data====>" + JSON.stringify(data)); console.debug("====>getSlotPromise ActsAnsGetSlotTestPromise_0400 data====>" + JSON.stringify(data));
expect(data.type).assertEqual(notification.SlotType.OTHER_TYPES); expect(data.type).assertEqual(notification.SlotType.OTHER_TYPES);
expect(data.level).assertEqual(3); expect(data.level).assertEqual(1);
expect(data.desc).assertEqual(""); expect(data.desc).assertEqual("");
expect(data.badgeFlag).assertEqual(true); expect(data.badgeFlag).assertEqual(true);
expect(data.bypassDnd).assertEqual(false); expect(data.bypassDnd).assertEqual(false);
...@@ -167,7 +167,7 @@ describe('ActsAnsGetSlotTestPromise', function () { ...@@ -167,7 +167,7 @@ describe('ActsAnsGetSlotTestPromise', function () {
console.debug("====>getSlotPromise UNKNOWN_TYPE ActsAnsGetSlotTestPromise_0500 enter====>"); console.debug("====>getSlotPromise UNKNOWN_TYPE ActsAnsGetSlotTestPromise_0500 enter====>");
console.debug("====>getSlotPromise ActsAnsGetSlotTestPromise_0500 data====>" + JSON.stringify(data)); console.debug("====>getSlotPromise ActsAnsGetSlotTestPromise_0500 data====>" + JSON.stringify(data));
expect(data.type).assertEqual(notification.SlotType.OTHER_TYPES); expect(data.type).assertEqual(notification.SlotType.OTHER_TYPES);
expect(data.level).assertEqual(3); expect(data.level).assertEqual(1);
expect(data.desc).assertEqual(""); expect(data.desc).assertEqual("");
expect(data.badgeFlag).assertEqual(true); expect(data.badgeFlag).assertEqual(true);
expect(data.bypassDnd).assertEqual(false); expect(data.bypassDnd).assertEqual(false);
......
...@@ -32,7 +32,7 @@ describe('ActsAnsRemoveSlotTest', function () { ...@@ -32,7 +32,7 @@ describe('ActsAnsRemoveSlotTest', function () {
console.debug("====>getSlotActsAnsGetSlotTestPromise_0100 enter====>"); console.debug("====>getSlotActsAnsGetSlotTestPromise_0100 enter====>");
console.debug("====>getSlotActsAnsGetSlotTestPromise_0100 data====>" + JSON.stringify(data)); console.debug("====>getSlotActsAnsGetSlotTestPromise_0100 data====>" + JSON.stringify(data));
expect(data.type).assertEqual(notification.SlotType.SOCIAL_COMMUNICATION); expect(data.type).assertEqual(notification.SlotType.SOCIAL_COMMUNICATION);
expect(data.level).assertEqual(3); expect(data.level).assertEqual(4);
expect(data.desc).assertEqual(""); expect(data.desc).assertEqual("");
expect(data.badgeFlag).assertEqual(true); expect(data.badgeFlag).assertEqual(true);
expect(data.bypassDnd).assertEqual(false); expect(data.bypassDnd).assertEqual(false);
......
{ {
"app": { "app": {
"bundleName": "com.neu.actsansactivesubscribertest", "bundleName": "com.example.actsansactivesubscribertest",
"vendor": "example", "vendor": "example",
"version": { "version": {
"code": 1, "code": 1,
...@@ -59,4 +59,4 @@ ...@@ -59,4 +59,4 @@
} }
] ]
} }
} }
\ No newline at end of file
{ {
"app": { "app": {
"bundleName": "com.neu.actsansnotificationtest", "bundleName": "com.example.actsansnotificationtest",
"vendor": "example", "vendor": "example",
"version": { "version": {
"code": 1, "code": 1,
...@@ -59,4 +59,4 @@ ...@@ -59,4 +59,4 @@
} }
] ]
} }
} }
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册