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

!4514 【XTS】【事件通知子系统】补充属性_master

Merge pull request !4514 from 郅建文/master
...@@ -19,14 +19,14 @@ var time = 1000 ...@@ -19,14 +19,14 @@ var time = 1000
var WantAgent; var WantAgent;
export default function ActsAnsWantAgentOneProTest() { export default function ActsAnsWantAgentOneProTest() {
describe('ActsAnsWantAgentOneProTest', function () { describe('ActsAnsWantAgentOneProTest', function () {
console.info('----ActsWantAgentTest----'); console.info("----ActsWantAgentTest----");
/* /*
* @tc.number: ACTS_SetWant_0200 * @tc.number: ACTS_SetWant_0200
* @tc.name: getWantAgent(OperationType.START_ABILITY) * @tc.name: getWantAgent(OperationType.START_ABILITY)
* @tc.desc: verify the function of getWantAgent(OperationType.START_ABILITY) * @tc.desc: verify the function of getWantAgent(OperationType.START_ABILITY)
*/ */
it('ACTS_SetWant_0200', 0, async function (done) { it("ACTS_SetWant_0200", 0, async function (done) {
var agentInfo = { var agentInfo = {
wants: [ wants: [
{ {
...@@ -36,8 +36,7 @@ describe('ActsAnsWantAgentOneProTest', function () { ...@@ -36,8 +36,7 @@ describe('ActsAnsWantAgentOneProTest', function () {
entities: ["entity1"], entities: ["entity1"],
type: "MIMETYPE", type: "MIMETYPE",
uri: "key={true,true,false}", uri: "key={true,true,false}",
parameters: parameters: {
{
mykey0: 2222, mykey0: 2222,
mykey1: [1, 2, 3], mykey1: [1, 2, 3],
mykey2: "[1, 2, 3]", mykey2: "[1, 2, 3]",
...@@ -45,44 +44,104 @@ describe('ActsAnsWantAgentOneProTest', function () { ...@@ -45,44 +44,104 @@ describe('ActsAnsWantAgentOneProTest', function () {
mykey4: [false, true, false], mykey4: [false, true, false],
mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"], mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"],
mykey6: true, mykey6: true,
},
},
],
operationType: wantAgent.OperationType.START_ABILITY,
requestCode: 0,
wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG],
};
console.info("----getWantAgent before----");
wantAgent.getWantAgent(agentInfo).then((data) => {
WantAgent = data;
console.info("----getWantAgent success!----");
console.info(JSON.stringify(data));
expect(typeof data).assertEqual("object");
var triggerInfo = {
code: 0,
};
wantAgent.trigger(WantAgent, triggerInfo, (err, data) => {
if (err.code == 0) {
console.info("----trigger success!----");
console.info("== trigger data " + JSON.stringify(data));
} else {
console.info("----trigger failed!----");
console.info("== trigger data " + JSON.stringify(data));
} }
done();
});
done();
});
setTimeout(function () {
console.debug("====>time out ACTS_SetWant_0200====>");
}, time);
console.info("----getWantAgent after----");
});
/*
* @tc.number: ACTS_SetWant_0300
* @tc.name: getWantAgent(OperationType.START_ABILITY)
* @tc.desc: verify the function of getWantAgent(OperationType.START_ABILITY)
*/
it("ACTS_SetWant_0300", 0, async function (done) {
var agentInfo = {
wants: [
{
bundleName: "com.example.WantAgentTest1",
abilityName: "com.example.WantAgentTest1.MainAbility",
action: "action1",
entities: ["entity1"],
type: "MIMETYPE",
uri: "key={true,true,false}",
parameters: {
mykey0: 2222,
mykey1: [1, 2, 3],
mykey2: "[1, 2, 3]",
mykey3: "ssssssssssssssssssssssssss",
mykey4: [false, true, false],
mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"],
mykey6: true,
},
}, },
], ],
operationType: wantAgent.OperationType.START_ABILITY, operationType: wantAgent.OperationType.START_ABILITY,
requestCode: 0, requestCode: 0,
wantAgentFlags:[wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG] wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG],
extraInfo: {
key1:'test_extraInfo'
} }
console.info('----getWantAgent before----'); };
wantAgent.getWantAgent(agentInfo).then( console.info("----getWantAgent before----");
(data) => { wantAgent.getWantAgent(agentInfo).then((data) => {
WantAgent = data; WantAgent = data;
console.info('----getWantAgent success!----'); console.info("----getWantAgent success!----");
console.info(JSON.stringify(data)); console.info(JSON.stringify(data));
expect(typeof(data)).assertEqual("object"); expect(typeof data).assertEqual("object");
var triggerInfo = { var triggerInfo = {
code:0 code: 0,
want:WantAgent,
permission:'',
extraInfo: {
key1:'test_triggerInfo'
} }
wantAgent.trigger(WantAgent, triggerInfo, };
(err, data) => { wantAgent.trigger(WantAgent, triggerInfo, (err, data) => {
if (err.code == 0) { if (err.code == 0) {
console.info('----trigger success!----'); console.info("----trigger success!----");
console.info('== trigger data ' + JSON.stringify(data) ); console.info("== trigger data " + JSON.stringify(data));
} else { } else {
console.info('----trigger failed!----'); console.info("----trigger failed!----");
console.info('== trigger data ' + JSON.stringify(data) ); console.info("== trigger data " + JSON.stringify(data));
} }
done(); done();
} });
);
done(); done();
});
} setTimeout(function () {
);
setTimeout(function(){
console.debug("====>time out ACTS_SetWant_0200====>"); console.debug("====>time out ACTS_SetWant_0200====>");
}, time); }, time);
console.info('----getWantAgent after----'); console.info("----getWantAgent after----");
}) });
}) })
} }
...@@ -334,6 +334,7 @@ describe("ActsSubscriberTestUnorder", async function (done) { ...@@ -334,6 +334,7 @@ describe("ActsSubscriberTestUnorder", async function (done) {
console.info("===============ActsSubscriberTestUnorder_0700==========================>"); console.info("===============ActsSubscriberTestUnorder_0700==========================>");
let commonEventSubscribeInfo = { let commonEventSubscribeInfo = {
events: ["publish_event0700"], events: ["publish_event0700"],
userId:100
}; };
let commonEventPublishData = { let commonEventPublishData = {
...@@ -357,6 +358,7 @@ describe("ActsSubscriberTestUnorder", async function (done) { ...@@ -357,6 +358,7 @@ describe("ActsSubscriberTestUnorder", async function (done) {
Subscriber.createSubscriber(commonEventSubscribeInfo).then((data) => { Subscriber.createSubscriber(commonEventSubscribeInfo).then((data) => {
console.info("===============ActsSubscriberTestUnorder_0700=========createSubscriber promise"); console.info("===============ActsSubscriberTestUnorder_0700=========createSubscriber promise");
expect(commonEventSubscribeInfo.userId).assertEqual(100)
commonEventSubscriber007 = data; commonEventSubscriber007 = data;
data.getSubscribeInfo().then(() => { data.getSubscribeInfo().then(() => {
console.info("===============ActsSubscriberTestUnorder_0700=========getSubscribeInfo promise"); console.info("===============ActsSubscriberTestUnorder_0700=========getSubscribeInfo promise");
......
...@@ -16,7 +16,7 @@ import emitter from '@ohos.events.emitter' ...@@ -16,7 +16,7 @@ import emitter from '@ohos.events.emitter'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'
export default function EmitterTest() { export default function EmitterTest() {
describe('EmitterTest', function () { describe('EmitterTest', function () {
console.info("===========EmitterTest start====================>"); console.info("===========EmitterTest start====================>");
var eventData = { var eventData = {
...@@ -107,5 +107,49 @@ describe('EmitterTest', function () { ...@@ -107,5 +107,49 @@ describe('EmitterTest', function () {
done(); done();
}) })
}) /*
* @tc.number : EmitterEmitTest_0100
* @tc.name : verify off : Check subscribe same off common ordered event
* @tc.desc : Check the subscriber can receive event "EmitterOffTest" type of the interface (by Promise)
*/
it('EmitterEmitTest_0100', 0, async function (done){
console.info("===========EmitterEmitTest_0100====================>");
var eventData2 = {
data: {
"content": "c",
"id": 2,
}};
var innerEventHigh = {
eventId: 3,
priority: emitter.EventPriority.HIGH
};
emitter.once(InnerEventLow, callback01);
emitter.emit(innerEventHigh, eventData2);
expect(emitter.EventPriority.HIGH).assertEqual(1)
done();
})
/*
* @tc.number : EmitterEmitTest_0200
* @tc.name : verify off : emitter.EventPriority.IDLE
* @tc.desc : emitter.EventPriority.IDLE
*/
it('EmitterEmitTest_0200', 0, async function (done){
console.info("===========EmitterEmitTest_0100====================>");
var eventData3 = {
data: {
"content": "d",
"id": 3,
}};
var innerEventIdle = {
eventId: 4,
priority: emitter.EventPriority.IDLE
};
emitter.once(innerEventIdle, callback01);
emitter.emit(InnerEventImmediate, eventData3);
expect(emitter.EventPriority.IDLE).assertEqual(3)
done();
})
})
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册