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

!5379 【XTS】【事件通知子系统】 XTS 用例名称修改_master

Merge pull request !5379 from zhijianwen/master
......@@ -16,17 +16,17 @@ import notification from '@system.notification'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
export default function ActsNotificationShowTest() {
describe('ActsNotificationShowTest', function () {
const TAG = 'ActsNotificationShowTest ===> '
console.info(TAG + "ActsNotificationShowTest START")
describe('SUB_NOTIFICATION_SHOW_TEST', function () {
const TAG = 'SUB_NOTIFICATION_SHOW_TEST ===> '
console.info(TAG + "SUB_NOTIFICATION_SHOW_TEST START")
/*
* @tc.number: ActsNotificationShowTest_0100
* @tc.number: SUB_NOTIFICATION_SHOW_TEST_0100
* @tc.name: show()
* @tc.desc: verify the function of show
*/
it('ActsNotificationShowTest_0100', 0, async function (done) {
console.info(TAG + 'ActsNotificationShowTest_0100 START ')
it('SUB_NOTIFICATION_SHOW_TEST_0100', 0, async function (done) {
console.info(TAG + 'SUB_NOTIFICATION_SHOW_TEST_0100 START ')
let ShowNotificationOptions = {
contentTitle: 'Title1',
contentText: 'This is a notification 001'
......@@ -40,12 +40,12 @@ export default function ActsNotificationShowTest() {
})
/*
* @tc.number: ActsNotificationShowTest_0200
* @tc.number: SUB_NOTIFICATION_SHOW_TEST_0200
* @tc.name: show()
* @tc.desc: verify the function of show
*/
it('ActsNotificationShowTest_0200', 0, async function (done) {
console.info(TAG + 'ActsNotificationShowTest_0200 START ')
it('SUB_NOTIFICATION_SHOW_TEST_0200', 0, async function (done) {
console.info(TAG + 'SUB_NOTIFICATION_SHOW_TEST_0200 START ')
let ShowNotificationOptions = {
contentTitle: 123,
contentText: 'This is a notification 002'
......@@ -58,12 +58,12 @@ export default function ActsNotificationShowTest() {
})
/*
* @tc.number: ActsNotificationShowTest_0300
* @tc.number: SUB_NOTIFICATION_SHOW_TEST_0300
* @tc.name: show()
* @tc.desc: verify the function of show
*/
it('ActsNotificationShowTest_0300', 0, async function (done) {
console.info(TAG + 'ActsNotificationShowTest_0300 START ')
it('SUB_NOTIFICATION_SHOW_TEST_0300', 0, async function (done) {
console.info(TAG + 'SUB_NOTIFICATION_SHOW_TEST_0300 START ')
let ShowNotificationOptions = {}
notification.show(ShowNotificationOptions)
expect(ShowNotificationOptions.contentTitle).assertEqual(undefined)
......@@ -71,12 +71,12 @@ export default function ActsNotificationShowTest() {
})
/*
* @tc.number: ActsNotificationShowTest_0400
* @tc.number: SUB_NOTIFICATION_SHOW_TEST_0400
* @tc.name: show()
* @tc.desc: verify the function of show
*/
it('ActsNotificationShowTest_0400', 0, async function (done) {
console.info(TAG + 'ActsNotificationShowTest_0400 START ')
it('SUB_NOTIFICATION_SHOW_TEST_0400', 0, async function (done) {
console.info(TAG + 'SUB_NOTIFICATION_SHOW_TEST_0400 START ')
let ActionResult = {
bundleName: 'com.example.notification',
abilityName: 'com.example.notification.MainAbility',
......@@ -102,12 +102,12 @@ export default function ActsNotificationShowTest() {
})
/*
* @tc.number: ActsNotificationShowTest_0500
* @tc.number: SUB_NOTIFICATION_SHOW_TEST_0500
* @tc.name: show()
* @tc.desc: verify the function of show
*/
it('ActsNotificationShowTest_0500', 0, async function (done) {
console.info(TAG + 'ActsNotificationShowTest_0500 START ')
it('SUB_NOTIFICATION_SHOW_TEST_0500', 0, async function (done) {
console.info(TAG + 'SUB_NOTIFICATION_SHOW_TEST_0500 START ')
let ActionResult = {
bundleName: 'com.example.notification',
abilityName: 'com.example.notification.MainAbility',
......@@ -133,12 +133,12 @@ export default function ActsNotificationShowTest() {
})
/*
* @tc.number: ActsNotificationShowTest_0600
* @tc.number: SUB_NOTIFICATION_SHOW_TEST_0600
* @tc.name: show()
* @tc.desc: verify the function of show
*/
it('ActsNotificationShowTest_0600', 0, async function (done) {
console.info(TAG + 'ActsNotificationShowTest_0600 START ')
it('SUB_NOTIFICATION_SHOW_TEST_0600', 0, async function (done) {
console.info(TAG + 'SUB_NOTIFICATION_SHOW_TEST_0600 START ')
let ActionResult = {
bundleName: '',
abilityName: 'com.example.notification.MainAbility',
......@@ -163,12 +163,12 @@ export default function ActsNotificationShowTest() {
})
/*
* @tc.number: ActsNotificationShowTest_0700
* @tc.number: SUB_NOTIFICATION_SHOW_TEST_0700
* @tc.name: show()
* @tc.desc: verify the function of show
*/
it('ActsNotificationShowTest_0700', 0, async function (done) {
console.info(TAG + 'ActsNotificationShowTest_0700 START ')
it('SUB_NOTIFICATION_SHOW_TEST_0700', 0, async function (done) {
console.info(TAG + 'SUB_NOTIFICATION_SHOW_TEST_0700 START ')
let ActionResult = {
bundleName: 'com.example.notification',
abilityName: '',
......@@ -193,12 +193,12 @@ export default function ActsNotificationShowTest() {
})
/*
* @tc.number: ActsNotificationShowTest_0800
* @tc.number: SUB_NOTIFICATION_SHOW_TEST_0800
* @tc.name: show()
* @tc.desc: verify the function of show
*/
it('ActsNotificationShowTest_0800', 0, async function (done) {
console.info(TAG + 'ActsNotificationShowTest_0800 START ')
it('SUB_NOTIFICATION_SHOW_TEST_0800', 0, async function (done) {
console.info(TAG + 'SUB_NOTIFICATION_SHOW_TEST_0800 START ')
let ActionResult = {
bundleName: 'com.example.notification',
abilityName: 'com.example.notification.MainAbility',
......@@ -223,12 +223,12 @@ export default function ActsNotificationShowTest() {
})
/*
* @tc.number: ActsNotificationShowTest_0900
* @tc.number: SUB_NOTIFICATION_SHOW_TEST_0900
* @tc.name: show()
* @tc.desc: verify the function of show
*/
it('ActsNotificationShowTest_0900', 0, async function (done) {
console.info(TAG + 'ActsNotificationShowTest_0900 START ')
it('SUB_NOTIFICATION_SHOW_TEST_0900', 0, async function (done) {
console.info(TAG + 'SUB_NOTIFICATION_SHOW_TEST_0900 START ')
let ActionResult = {
bundleName: 'com.example.notification',
abilityName: 'com.example.notification.MainAbility',
......@@ -251,12 +251,12 @@ export default function ActsNotificationShowTest() {
})
/*
* @tc.number: ActsNotificationShowTest_1000
* @tc.number: SUB_NOTIFICATION_SHOW_TEST_1000
* @tc.name: show()
* @tc.desc: verify the function of show
*/
it('ActsNotificationShowTest_1000', 0, async function (done) {
console.info(TAG + 'ActsNotificationShowTest_1000 START ')
it('SUB_NOTIFICATION_SHOW_TEST_1000', 0, async function (done) {
console.info(TAG + 'SUB_NOTIFICATION_SHOW_TEST_1000 START ')
let ActionResult = {
bundleName: 'com.example.notification',
abilityName: 'com.example.notification.MainAbility',
......@@ -278,8 +278,9 @@ export default function ActsNotificationShowTest() {
done()
})
console.info(TAG + "ActsNotificationShowTest END");
console.info(TAG + "SUB_NOTIFICATION_SHOW_TEST END");
})
}
......@@ -16,8 +16,9 @@ import Subscriber from '@ohos.commonEvent'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'
export default function ActsSubscriberTestOrder() {
describe('ActsSubscriberTestOrder', function () {
console.info('===========ActsSubscriberTestOrder start====================>');
describe('SUB_NOTIFICATION_CES_SUBSCRIBER_ORDER_TEST', function () {
let TAG = 'SUB_NOTIFICATION_CES_SUBSCRIBER_ORDER_TEST ===>'
console.info(`${TAG} SUB_NOTIFICATION_CES_SUBSCRIBER_ORDER_TEST START`)
let num2 = 0;
let order = false;
let commonEventSubscriber0100;
......@@ -40,12 +41,12 @@ describe('ActsSubscriberTestOrder', function () {
}
/*
* @tc.number : ActsSubscriberTestOrder_0100
* @tc.number : SUB_NOTIFICATION_CES_SUBSCRIBER_ORDER_TEST_0100
* @tc.name : verify subscribe and publish : Check subscribe same event and publish common ordered event
* @tc.desc : Check the subscriber can receive event "publish_event0100" type of the interface (by Promise)
*/
it('ActsSubscriberTestOrder_0100', 0, async function (done) {
console.info('===============ActsSubscriberTestOrder_0100===============>');
it('SUB_NOTIFICATION_CES_SUBSCRIBER_ORDER_TEST_0100', 0, async function (done) {
console.info(`${TAG} SUB_NOTIFICATION_CES_SUBSCRIBER_ORDER_TEST_0100 START`)
let commonEventSubscribeInfo1 = {
events: ['publish_event0100'],
......@@ -148,16 +149,17 @@ describe('ActsSubscriberTestOrder', function () {
}, 100);
});
})
console.info(`${TAG} SUB_NOTIFICATION_CES_SUBSCRIBER_ORDER_TEST_0100 END`)
})
/*
* @tc.number : ActsSubscriberTestOrder_0200
* @tc.number : SUB_NOTIFICATION_CES_SUBSCRIBER_ORDER_TEST_0200
* @tc.name : verify subscribe and publish : Check subscribe different event
* and twice publish common ordered event and check unsubscribe event
* @tc.desc : Check the subscriber can receive event "publish_event0200" type of the interface (by Promise)
*/
it ('ActsSubscriberTestOrder_0200', 0, async function (done) {
console.info('===============ActsSubscriberTestOrder_0200===============>');
it ('SUB_NOTIFICATION_CES_SUBSCRIBER_ORDER_TEST_0200', 0, async function (done) {
console.info(`${TAG} SUB_NOTIFICATION_CES_SUBSCRIBER_ORDER_TEST_0200 START`)
let commonEventSubscribeInfo1 = {
events: ['publish_event0200',
......@@ -253,16 +255,17 @@ describe('ActsSubscriberTestOrder', function () {
}, 100);
});
})
console.info(`${TAG} SUB_NOTIFICATION_CES_SUBSCRIBER_ORDER_TEST_0200 END`)
})
/*
* @tc.number : ActsSubscriberTestOrder_0300
* @tc.number : SUB_NOTIFICATION_CES_SUBSCRIBER_ORDER_TEST_0300
* @tc.name : verify subscribe and publish : Check subscribe different events
* and some publish common ordered events
* @tc.desc : Check the subscriber can receive event "publish_event0301" type of the interface (by Promise)
*/
it ('ActsSubscriberTestOrder_0300', 0, async function (done) {
console.info('===============ActsSubscriberTestOrder_0300===============>');
it ('SUB_NOTIFICATION_CES_SUBSCRIBER_ORDER_TEST_0300', 0, async function (done) {
console.info(`${TAG} SUB_NOTIFICATION_CES_SUBSCRIBER_ORDER_TEST_0300 START`)
let commonEventSubscribeInfo1 = {
events: ['publish_event0301'],
......@@ -361,16 +364,17 @@ describe('ActsSubscriberTestOrder', function () {
}
});
})
console.info(`${TAG} SUB_NOTIFICATION_CES_SUBSCRIBER_ORDER_TEST_0300 END`)
})
/*
* @tc.number : ActsSubscriberTestOrder_0400
* @tc.number : SUB_NOTIFICATION_CES_SUBSCRIBER_ORDER_TEST_0400
* @tc.name : verify subscribe and publish : Check subscribe same events
* and publish common ordered events and check abort event
* @tc.desc : Check the subscriber can receive event "publish_eventOrder0400" type of the interface by promise
*/
it ('ActsSubscriberTestOrder_0400', 0, async function (done) {
console.info('===============ActsSubscriberTestOrder_0400===============>');
it ('SUB_NOTIFICATION_CES_SUBSCRIBER_ORDER_TEST_0400', 0, async function (done) {
console.info(`${TAG} SUB_NOTIFICATION_CES_SUBSCRIBER_ORDER_TEST_0400 START`)
let commonEventSubscribeInfo1 = {
events: ['publish_eventOrder0400'],
......@@ -444,15 +448,16 @@ describe('ActsSubscriberTestOrder', function () {
}, 100);
})
})
console.info(`${TAG} SUB_NOTIFICATION_CES_SUBSCRIBER_ORDER_TEST_0400 END`)
})
/*
* @tc.number : ActsSubscriberTestOrder_0500
* @tc.number : SUB_NOTIFICATION_CES_SUBSCRIBER_ORDER_TEST_0500
* @tc.name : verify subscribe and publish : Check subscriber same events
* @tc.desc : Check the subscriber can receive event "publish_event0500" type of the interface (by promise)
*/
it ('ActsSubscriberTestOrder_0500', 0, async function (done) {
console.info('===============ActsSubscriberTestOrder_0500===============>');
it ('SUB_NOTIFICATION_CES_SUBSCRIBER_ORDER_TEST_0500', 0, async function (done) {
console.info(`${TAG} SUB_NOTIFICATION_CES_SUBSCRIBER_ORDER_TEST_0500 START`)
let commonEventSubscribeInfo1 = {
events: ['publish_event0500'],
......@@ -531,6 +536,8 @@ describe('ActsSubscriberTestOrder', function () {
}, 100);
})
})
console.info(`${TAG} SUB_NOTIFICATION_CES_SUBSCRIBER_ORDER_TEST_0400 END`)
})
console.info(`${TAG} SUB_NOTIFICATION_CES_SUBSCRIBER_ORDER_TEST END`)
})
}
......@@ -16,11 +16,12 @@ import commonEvent from '@ohos.commonEvent'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
export default function ActsSubscriberTestUnorderSystem() {
describe('ActsSubscriberTestUnorderSystem', async function (done) {
let TAG = 'Subscriber_Unorder_System ===>'
it('Subscriber_Unorder_System_001', 0, async function (done) {
console.info(TAG + 'Subscriber_Unorder_System_001 START')
const CommonEventSubscriberInfo = {
describe('SUB_NOTIFICATION_CES_SUBSCRIBER_UNORDER_SYSTEM_TEST', async function () {
let TAG = 'SUB_NOTIFICATION_CES_SUBSCRIBER_UNORDER_SYSTEM_TEST ===>'
console.info(`${TAG} SUB_NOTIFICATION_CES_SUBSCRIBER_UNORDER_SYSTEM_TEST START`)
it('SUB_NOTIFICATION_CES_SUBSCRIBER_UNORDER_SYSTEM_TEST_0100', 0, async function (done) {
console.info(`${TAG} SUB_NOTIFICATION_CES_SUBSCRIBER_UNORDER_SYSTEM_TEST START`)
let CommonEventSubscriberInfo = {
events: [
commonEvent.Support.COMMON_EVENT_SHUTDOWN,
commonEvent.Support.COMMON_EVENT_BATTERY_CHANGED,
......@@ -158,7 +159,7 @@ export default function ActsSubscriberTestUnorderSystem() {
commonEvent.Support.COMMON_EVENT_NFC_ACTION_RF_FIELD_ON_DETECTED,
commonEvent.Support.COMMON_EVENT_NFC_ACTION_RF_FIELD_OFF_DETECTED,
commonEvent.Support.COMMON_EVENT_USER_ADDED,
//commonEvent.Support.COMMON_EVENT_USER_REMOVED,
// commonEvent.Support.COMMON_EVENT_USER_REMOVED,
commonEvent.Support.COMMON_EVENT_ABILITY_ADDED,
commonEvent.Support.COMMON_EVENT_ABILITY_REMOVED,
commonEvent.Support.COMMON_EVENT_ABILITY_UPDATED,
......@@ -178,41 +179,42 @@ export default function ActsSubscriberTestUnorderSystem() {
commonEvent.Support.COMMON_EVENT_SPN_INFO_CHANGED
]
}
let CommonEventSubscriber = await commonEvent.createSubscriber(CommonEventSubscriberInfo)
if (CommonEventSubscriber == undefined) {
console.info(TAG + ': createSubscriber failed! Err.Info ===> ' + JSON.stringify(CommonEventSubscriber))
let CommonEventSubscriber
commonEvent.createSubscriber(CommonEventSubscriberInfo).then((data) => {
console.info(`${TAG} createSubscriber success : ${CommonEventSubscriberInfo}`)
CommonEventSubscriber = data
expect(true).assertTrue()
commonEvent.subscribe(CommonEventSubscriber, (err, CommonEventData) => {
if (err.code) {
console.info(`${TAG} subscribe err : ${err.code}`)
expect(false).assertTrue()
done()
} else {
console.info(`${TAG} subscribe success : ${CommonEventData}`)
expect(true).assertTrue()
}
})
}).catch((err) => {
console.info(`${TAG} createSubscriber err ${err}`)
expect(false).assertTrue()
done()
} else {
console.info(TAG + ': createSubscriber successed! Subscriber.Info ===> ' + JSON.stringify(CommonEventSubscriber))
expect(true).assertTrue()
}
await commonEvent.subscribe(CommonEventSubscriber, (err, CommonEventData) => {
if (err.code) {
console.info(TAG + ': subscribe failed! Err.Info ===> ' + JSON.stringify(err.code))
expect(false).assertTrue()
done()
} else {
console.info(TAG + ': subscribe successed! CommonEventData.Info ===> ' + JSON.stringify(CommonEventData))
expect(true).assertTrue()
}
})
for (let i = 0; i < CommonEventSubscriberInfo.events.length; i++) {
await commonEvent.publish(CommonEventSubscriberInfo.events[i], (err) => {
if (err.code) {
console.info(TAG + ': publish failed! event.Info ===> ' + JSON.stringify(CommonEventSubscriberInfo.events[i]))
console.info(`${TAG} publish err : ${err.code}`)
expect(false).assertTrue()
done()
} else {
console.info(TAG + ': publish successed! event.Info ===> ' + JSON.stringify(CommonEventSubscriberInfo.events[i]))
console.info(`${TAG} publish success : ${CommonEventSubscriberInfo.events[i]}`)
expect(true).assertTrue()
done()
}
})
}
})
console.info(`${TAG} SUB_NOTIFICATION_CES_SUBSCRIBER_UNORDER_SYSTEM_TEST END`)
})
}
......@@ -16,9 +16,9 @@ import commonEvent from '@ohos.commonEvent';
import {describe,beforeAll,beforeEach,afterEach,afterAll,it,expect,} from "@ohos/hypium";
export default function ActsSubscriberTestUnorder() {
describe('ActsSubscriberTestUnorder', function () {
let TAG = 'ActsSubscriberTestUnorder ===>';
describe('SUB_NOTIFICATION_CES_SUBSCRIBER_UNORDER_TEST', function () {
let TAG = 'SUB_NOTIFICATION_CES_SUBSCRIBER_UNORDER_TEST ===>';
console.info(`${TAG} SUB_NOTIFICATION_CES_SUBSCRIBER_UNORDER_TEST START`)
let CommonEventSubscriberInfo = {
events: ['event'],
......@@ -32,12 +32,12 @@ export default function ActsSubscriberTestUnorder() {
return new Promise(resolve => setTimeout(resolve, ms));
}
/*
* @tc.number : ActsSubscriberTestUnorder_0100
* @tc.number : SUB_NOTIFICATION_CES_SUBSCRIBER_UNORDER_TEST_0100
* @tc.name : check
* @tc.desc : getSubscribeInfo(callback: AsyncCallback<CommonEventSubscribeInfo>): void
*/
it('ActsSubscriberTestUnorder_0100', 0, async function (done) {
console.info(TAG + 'ActsSubscriberTestUnorder_0100 START ')
it('SUB_NOTIFICATION_CES_SUBSCRIBER_UNORDER_TEST_0100', 0, async function (done) {
console.info(`${TAG} SUB_NOTIFICATION_CES_SUBSCRIBER_UNORDER_TEST_0100 START`)
let CommonEventSubscriber = await commonEvent.createSubscriber(CommonEventSubscriberInfo)
if (CommonEventSubscriber == undefined) {
console.info(TAG + ': createSubscriber failed! Err.Info ===> ' + JSON.stringify(CommonEventSubscriber))
......@@ -64,15 +64,16 @@ export default function ActsSubscriberTestUnorder() {
done()
}
})
console.info(`${TAG} SUB_NOTIFICATION_CES_SUBSCRIBER_UNORDER_TEST_0100 END`)
})
/*
* @tc.number : ActsSubscriberTestUnorder_0200
* @tc.number : SUB_NOTIFICATION_CES_SUBSCRIBER_UNORDER_TEST_0200
* @tc.name : check
* @tc.desc : getSubscribeInfo(): Promise<CommonEventSubscribeInfo>
*/
it('ActsSubscriberTestUnorder_0200', 0, async function (done) {
console.info(TAG + 'ActsSubscriberTestUnorder_0200 START ')
it('SUB_NOTIFICATION_CES_SUBSCRIBER_UNORDER_TEST_0200', 0, async function (done) {
console.info(`${TAG} SUB_NOTIFICATION_CES_SUBSCRIBER_UNORDER_TEST_0200 START`)
let CommonEventSubscriber = await commonEvent.createSubscriber(CommonEventSubscriberInfo)
if (CommonEventSubscriber == undefined) {
console.info(TAG + ': createSubscriber failed! Err.Info ===> ' + JSON.stringify(CommonEventSubscriber))
......@@ -96,16 +97,16 @@ export default function ActsSubscriberTestUnorder() {
console.info(TAG + ': getSubscribeInfo promise failed! event.Info ===> ' + JSON.stringify(err.code))
expect(false).assertTrue()
})
console.info(`${TAG} SUB_NOTIFICATION_CES_SUBSCRIBER_UNORDER_TEST_0200 END`)
})
/*
* @tc.number : ActsgetSubscribeInfoTest_0300
* @tc.number : SUB_NOTIFICATION_CES_SUBSCRIBER_UNORDER_TEST_0300
* @tc.name : Check the subscriber can receive event "@#¥#3243adsafdf_" type of the interface
* @tc.desc : getSubscribeInfo(callback: AsyncCallback<CommonEventSubscribeInfo>): void
*/
it('ActsgetSubscribeInfoTest_0300', 0, async function (done) {
console.info(TAG + 'ActsgetSubscribeInfoTest_0100 START ')
it('SUB_NOTIFICATION_CES_SUBSCRIBER_UNORDER_TEST_0300', 0, async function (done) {
console.info(`${TAG} SUB_NOTIFICATION_CES_SUBSCRIBER_UNORDER_TEST_0300 START`)
CommonEventSubscriberInfo.events[0] = '@#¥#3243adsafdf_'
let CommonEventSubscriber = await commonEvent.createSubscriber(CommonEventSubscriberInfo)
if (CommonEventSubscriber == undefined) {
......@@ -133,15 +134,16 @@ export default function ActsSubscriberTestUnorder() {
done()
}
})
console.info(`${TAG} SUB_NOTIFICATION_CES_SUBSCRIBER_UNORDER_TEST_0300 END`)
})
/*
* @tc.number : ActsgetSubscribeInfoTest_0400
* @tc.number : SUB_NOTIFICATION_CES_SUBSCRIBER_UNORDER_TEST_0400
* @tc.name : Check the subscriber can receive event "@#¥#3243adsafdf_" type of the interface (by Promise)
* @tc.desc : getSubscribeInfo(callback: AsyncCallback<CommonEventSubscribeInfo>): void
*/
it('ActsSubscriberTestUnorder_0400', 0, async function (done) {
console.info(TAG + 'ActsSubscriberTestUnorder_0400 START ')
it('SUB_NOTIFICATION_CES_SUBSCRIBER_UNORDER_TEST_0400', 0, async function (done) {
console.info(`${TAG} SUB_NOTIFICATION_CES_SUBSCRIBER_UNORDER_TEST_0400 START`)
CommonEventSubscriberInfo.events[0] = '@#¥#3243adsafdf_'
let CommonEventSubscriber = await commonEvent.createSubscriber(CommonEventSubscriberInfo)
if (CommonEventSubscriber == undefined) {
......@@ -166,16 +168,16 @@ export default function ActsSubscriberTestUnorder() {
console.info(TAG + ': getSubscribeInfo promise failed! event.Info ===> ' + JSON.stringify(err.code))
expect(false).assertTrue()
})
console.info(`${TAG} SUB_NOTIFICATION_CES_SUBSCRIBER_UNORDER_TEST_0400 END`)
})
/*
* @tc.number : ActsSubscriberTestUnorder_0500
* @tc.number : SUB_NOTIFICATION_CES_SUBSCRIBER_UNORDER_TEST_0500
* @tc.name : check
* @tc.desc : isOrderedCommonEvent(callback: AsyncCallback<boolean>): void
*/
it('ActsSubscriberTestUnorder_0500', 0, async function (done) {
console.info(TAG + 'ActsSubscriberTestUnorder_0500 START ')
it('SUB_NOTIFICATION_CES_SUBSCRIBER_UNORDER_TEST_0500', 0, async function (done) {
console.info(`${TAG} SUB_NOTIFICATION_CES_SUBSCRIBER_UNORDER_TEST_0500 START`)
CommonEventSubscriberInfo.events[0] = 'publish_event_0500'
CommonEventSubscriberInfo.publisherDeviceId = 'PublishDeviceId_0500'
CommonEventSubscriberInfo.priority = 10
......@@ -238,16 +240,17 @@ export default function ActsSubscriberTestUnorder() {
}
})
await sleep(5000);
await sleep(5000)
console.info(`${TAG} SUB_NOTIFICATION_CES_SUBSCRIBER_UNORDER_TEST_0500 END`)
})
/*
* @tc.number : ActsSubscriberTestUnorder_0600
* @tc.number : SUB_NOTIFICATION_CES_SUBSCRIBER_UNORDER_TEST_0600
* @tc.name : check
* @tc.desc : isOrderedCommonEvent(): Promise<boolean>
*/
it('ActsSubscriberTestUnorder_0600', 0, async function (done) {
console.info(TAG + 'ActsSubscriberTestUnorder_0600 START ')
it('SUB_NOTIFICATION_CES_SUBSCRIBER_UNORDER_TEST_0600', 0, async function (done) {
console.info(`${TAG} SUB_NOTIFICATION_CES_SUBSCRIBER_UNORDER_TEST_0600 START`)
CommonEventSubscriberInfo.events[0] = 'publish_event_0600'
CommonEventSubscriberInfo.publisherDeviceId = 'PublishDeviceId_0600'
CommonEventSubscriberInfo.priority = 10
......@@ -310,17 +313,17 @@ export default function ActsSubscriberTestUnorder() {
}
})
await sleep(500)
await sleep(5000)
console.info(`${TAG} SUB_NOTIFICATION_CES_SUBSCRIBER_UNORDER_TEST_0600 END`)
})
/*
* @tc.number : ActsSubscriberTestUnorder_0700
* @tc.number : SUB_NOTIFICATION_CES_SUBSCRIBER_UNORDER_TEST_0700
* @tc.name : check
* @tc.desc : iisStickyCommonEvent(callback: AsyncCallback<boolean>): void
*/
it('ActsSubscriberTestUnorder_0700', 0, async function (done) {
console.info(TAG + 'ActsSubscriberTestUnorder_0700 START ')
it('SUB_NOTIFICATION_CES_SUBSCRIBER_UNORDER_TEST_0700', 0, async function (done) {
console.info(`${TAG} SUB_NOTIFICATION_CES_SUBSCRIBER_UNORDER_TEST_0700 START`)
CommonEventSubscriberInfo.events[0] = 'publish_event_0700'
CommonEventSubscriberInfo.publisherDeviceId = 'PublishDeviceId_0700'
CommonEventSubscriberInfo.priority = 10
......@@ -383,16 +386,17 @@ export default function ActsSubscriberTestUnorder() {
}
})
await sleep(5000);
await sleep(5000)
console.info(`${TAG} SUB_NOTIFICATION_CES_SUBSCRIBER_UNORDER_TEST_0700 END`)
})
/*
* @tc.number : ActsSubscriberTestUnorder_0800
* @tc.number : SUB_NOTIFICATION_CES_SUBSCRIBER_UNORDER_TEST_0800
* @tc.name : check
* @tc.desc : isStickyCommonEvent(): Promise<boolean>
*/
it('ActsSubscriberTestUnorder_0800', 0, async function (done) {
console.info(TAG + 'ActsSubscriberTestUnorder_0800 START ')
it('SUB_NOTIFICATION_CES_SUBSCRIBER_UNORDER_TEST_0800', 0, async function (done) {
console.info(`${TAG} SUB_NOTIFICATION_CES_SUBSCRIBER_UNORDER_TEST_0800 START`)
CommonEventSubscriberInfo.events[0] = 'publish_event_0800'
CommonEventSubscriberInfo.publisherDeviceId = 'PublishDeviceId_0800'
CommonEventSubscriberInfo.priority = 10
......@@ -452,17 +456,17 @@ export default function ActsSubscriberTestUnorder() {
done()
}
})
await sleep(500)
await sleep(5000)
console.info(`${TAG} SUB_NOTIFICATION_CES_SUBSCRIBER_UNORDER_TEST_0800 END`)
})
/*
* @tc.number : ActsSubscriberTestUnorder_0900
* @tc.number : SUB_NOTIFICATION_CES_SUBSCRIBER_UNORDER_TEST_0900
* @tc.name : check properties
* @tc.desc : CommonEventPublishData
*/
it('ActsSubscriberTestUnorder_0900', 0, async function (done) {
console.info(TAG + 'ActsSubscriberTestUnorder_0900 START ')
it('SUB_NOTIFICATION_CES_SUBSCRIBER_UNORDER_TEST_0900', 0, async function (done) {
console.info(`${TAG} SUB_NOTIFICATION_CES_SUBSCRIBER_UNORDER_TEST_0900 START`)
CommonEventSubscriberInfo.events[0] = 'publish_event_0900'
CommonEventSubscriberInfo.publisherDeviceId = 'PublishDeviceId_0900'
CommonEventSubscriberInfo.priority = 10
......@@ -511,6 +515,8 @@ export default function ActsSubscriberTestUnorder() {
})
await sleep(5000)
console.info(`${TAG} SUB_NOTIFICATION_CES_SUBSCRIBER_UNORDER_TEST_0900 END`)
})
console.info(`${TAG} SUB_NOTIFICATION_CES_SUBSCRIBER_UNORDER_TEST END`)
})
}
......@@ -16,139 +16,139 @@ import emitter from '@ohos.events.emitter'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'
export default function EmitterTest() {
describe('EmitterTest', function () {
const TAG = 'EmitterTest ===> '
console.info(TAG + 'EmitterTest START')
let innerEvent = {
eventId: undefined,
priority: undefined
}
let eventData = {
data: {
'id': undefined,
'content': undefined
}
}
function EmitterCallback(eventData) {
console.info(TAG + 'eventData.id: ' + JSON.stringify(eventData.data.id));
console.info(TAG + 'eventData.content: ' + JSON.stringify(eventData.data.content));
if (eventData.data.id == 0) {
expect(eventData.data.content).assertEqual('message_0');
} else if (eventData.data.id == 1) {
expect(eventData.data.content).assertEqual('message_1');
} else if (eventData.data.id == 2) {
expect(eventData.data.content).assertEqual('message_2');
} else if (eventData.data.id == 3) {
expect(eventData.data.content).assertEqual('message_3');
} else if (eventData.data.id == 4) {
expect(eventData.data.content).assertEqual('message_4');
} else if (eventData.data.id == 5) {
expect(eventData.data.content).assertEqual('message_5');
}
}
/*
* @tc.number : EmitterTest_0100
* @tc.name : verify on : on(event: InnerEvent, callback: Callback<EventData>): void
* @tc.desc : emitter.EventPriority.IDLE
*/
it('EmitterTest_0100', 0, async function (done) {
console.info(TAG + 'EmitterTest_0100 START')
innerEvent.eventId = 1
innerEvent.priority = emitter.EventPriority.IDLE
eventData.data.id = 0
eventData.data.content = 'message_0'
emitter.on(innerEvent, EmitterCallback)
emitter.emit(innerEvent, eventData)
eventData.data.id = 1
eventData.data.content = 'message_1'
emitter.emit(innerEvent, eventData)
console.info(TAG + 'EmitterTest_0100 END')
done()
})
/*
* @tc.number : EmitterTest_0200
* @tc.name : verify on : once(event: InnerEvent, callback: Callback<EventData>): void
* @tc.desc : emitter.EventPriority.LOW
*/
it('EmitterTest_0200', 0, async function (done) {
console.info(TAG + 'EmitterTest_0200 START')
innerEvent.eventId = 2
innerEvent.priority = emitter.EventPriority.LOW
eventData.data.id = 2
eventData.data.content = 'message_2'
emitter.once(innerEvent, EmitterCallback)
emitter.emit(innerEvent, eventData)
console.info(TAG + 'EmitterTest_0200 END')
done()
})
/*
* @tc.number : EmitterTest_0300
* @tc.name : verify on : emit(event: InnerEvent, data?: EventData): void
* @tc.desc : emitter.EventPriority.HIGH
*/
it('EmitterTest_0300', 0, async function (done) {
console.info(TAG + 'EmitterTest_0300 START')
innerEvent.eventId = 3
innerEvent.priority = emitter.EventPriority.HIGH
eventData.data.id = 3
eventData.data.content = 'message_3'
emitter.once(innerEvent, EmitterCallback)
emitter.emit(innerEvent, eventData)
console.info(TAG + 'EmitterTest_0300 END')
done()
})
/*
* @tc.number : EmitterTest_0400
* @tc.name : verify on : emit(event: InnerEvent, data?: EventData): void
* @tc.desc : emitter.EventPriority.IMMEDIATE
*/
it('EmitterTest_0400', 0, async function (done) {
console.info(TAG + 'EmitterTest_0400 START')
innerEvent.eventId = 4
innerEvent.priority = emitter.EventPriority.IMMEDIATE
eventData.data.id = 4
eventData.data.content = 'message_4'
emitter.once(innerEvent, EmitterCallback)
emitter.emit(innerEvent, eventData)
console.info(TAG + 'EmitterTest_0400 END')
done()
})
/*
* @tc.number : EmitterTest_0500
* @tc.name : verify on : off(eventId: number): void
* @tc.desc : emitter.EventPriority.IMMEDIATE
*/
it('EmitterTest_0500', 0, async function (done) {
console.info(TAG + 'EmitterTest_0500 START')
innerEvent.eventId = 5
innerEvent.priority = emitter.EventPriority.IMMEDIATE
eventData.data.id = 5
eventData.data.content = 'message_5'
emitter.once(innerEvent, EmitterCallback)
emitter.emit(innerEvent, eventData)
emitter.off(5)
console.info(TAG + 'EmitterTest_0500 END')
done()
})
console.info(TAG + 'EmitterTest END')
})
describe('SUB_NOTIFICATION_CES_EMITTER_TEST', function () {
const TAG = 'SUB_NOTIFICATION_CES_EMITTER_TEST ===> '
console.info(`${TAG} SUB_NOTIFICATION_CES_EMITTER_TEST START`)
let innerEvent = {
eventId: undefined,
priority: undefined
}
let eventData = {
data: {
'id': undefined,
'content': undefined
}
}
function EmitterCallback(eventData) {
console.info(TAG + 'eventData.id: ' + JSON.stringify(eventData.data.id));
console.info(TAG + 'eventData.content: ' + JSON.stringify(eventData.data.content));
if (eventData.data.id == 0) {
expect(eventData.data.content).assertEqual('message_0');
} else if (eventData.data.id == 1) {
expect(eventData.data.content).assertEqual('message_1');
} else if (eventData.data.id == 2) {
expect(eventData.data.content).assertEqual('message_2');
} else if (eventData.data.id == 3) {
expect(eventData.data.content).assertEqual('message_3');
} else if (eventData.data.id == 4) {
expect(eventData.data.content).assertEqual('message_4');
} else if (eventData.data.id == 5) {
expect(eventData.data.content).assertEqual('message_5');
}
}
/*
* @tc.number : SUB_NOTIFICATION_CES_EMITTER_TEST_0100
* @tc.name : verify on : on(event: InnerEvent, callback: Callback<EventData>): void
* @tc.desc : emitter.EventPriority.IDLE
*/
it('SUB_NOTIFICATION_CES_EMITTER_TEST_0100', 0, async function (done) {
console.info(`${TAG} SUB_NOTIFICATION_CES_EMITTER_TEST_0100 START`)
innerEvent.eventId = 1
innerEvent.priority = emitter.EventPriority.IDLE
eventData.data.id = 0
eventData.data.content = 'message_0'
emitter.on(innerEvent, EmitterCallback)
emitter.emit(innerEvent, eventData)
eventData.data.id = 1
eventData.data.content = 'message_1'
emitter.emit(innerEvent, eventData)
console.info(`${TAG} SUB_NOTIFICATION_CES_EMITTER_TEST_0100 END`)
done()
})
/*
* @tc.number : SUB_NOTIFICATION_CES_EMITTER_TEST_0200
* @tc.name : verify on : once(event: InnerEvent, callback: Callback<EventData>): void
* @tc.desc : emitter.EventPriority.LOW
*/
it('SUB_NOTIFICATION_CES_EMITTER_TEST_0200', 0, async function (done) {
console.info(`${TAG} SUB_NOTIFICATION_CES_EMITTER_TEST_0200 START`)
innerEvent.eventId = 2
innerEvent.priority = emitter.EventPriority.LOW
eventData.data.id = 2
eventData.data.content = 'message_2'
emitter.once(innerEvent, EmitterCallback)
emitter.emit(innerEvent, eventData)
console.info(`${TAG} SUB_NOTIFICATION_CES_EMITTER_TEST_0200 END`)
done()
})
/*
* @tc.number : SUB_NOTIFICATION_CES_EMITTER_TEST_0300
* @tc.name : verify on : emit(event: InnerEvent, data?: EventData): void
* @tc.desc : emitter.EventPriority.HIGH
*/
it('SUB_NOTIFICATION_CES_EMITTER_TEST_0300', 0, async function (done) {
console.info(`${TAG} SUB_NOTIFICATION_CES_EMITTER_TEST_0300 START`)
innerEvent.eventId = 3
innerEvent.priority = emitter.EventPriority.HIGH
eventData.data.id = 3
eventData.data.content = 'message_3'
emitter.once(innerEvent, EmitterCallback)
emitter.emit(innerEvent, eventData)
console.info(`${TAG} SUB_NOTIFICATION_CES_EMITTER_TEST_0300 END`)
done()
})
/*
* @tc.number : SUB_NOTIFICATION_CES_EMITTER_TEST_0400
* @tc.name : verify on : emit(event: InnerEvent, data?: EventData): void
* @tc.desc : emitter.EventPriority.IMMEDIATE
*/
it('SUB_NOTIFICATION_CES_EMITTER_TEST_0400', 0, async function (done) {
console.info(`${TAG} SUB_NOTIFICATION_CES_EMITTER_TEST_0400 START`)
innerEvent.eventId = 4
innerEvent.priority = emitter.EventPriority.IMMEDIATE
eventData.data.id = 4
eventData.data.content = 'message_4'
emitter.once(innerEvent, EmitterCallback)
emitter.emit(innerEvent, eventData)
console.info(`${TAG} SUB_NOTIFICATION_CES_EMITTER_TEST_0400 END`)
done()
})
/*
* @tc.number : SUB_NOTIFICATION_CES_EMITTER_TEST_0500
* @tc.name : verify on : off(eventId: number): void
* @tc.desc : emitter.EventPriority.IMMEDIATE
*/
it('SUB_NOTIFICATION_CES_EMITTER_TEST_0500', 0, async function (done) {
console.info(`${TAG} SUB_NOTIFICATION_CES_EMITTER_TEST_0500 START`)
innerEvent.eventId = 5
innerEvent.priority = emitter.EventPriority.IMMEDIATE
eventData.data.id = 5
eventData.data.content = 'message_5'
emitter.once(innerEvent, EmitterCallback)
emitter.emit(innerEvent, eventData)
emitter.off(5)
console.info(`${TAG} SUB_NOTIFICATION_CES_EMITTER_TEST_0500 END`)
done()
})
console.info(`${TAG} SUB_NOTIFICATION_CES_EMITTER_TEST END`)
})
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册