Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
573edc8c
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
大约 1 年 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
573edc8c
编写于
9月 05, 2022
作者:
Z
zhijianwen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
name
Signed-off-by:
N
zhijianwen
<
zhijianwen@huawei.com
>
上级
efbd6212
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
266 addition
and
250 deletion
+266
-250
notification/ans_standard/actsnotificationshow/src/main/js/test/ActsNotificationShowTest.js
...ficationshow/src/main/js/test/ActsNotificationShowTest.js
+35
-34
notification/ces_standard/subscribeandpublish/actssubscriberorderedtest/src/main/js/test/ActsSubscriber_test_ordered.js
...deredtest/src/main/js/test/ActsSubscriber_test_ordered.js
+24
-17
notification/ces_standard/subscribeandpublish/actssubscriberunordersystemtest/src/main/js/test/ActsSubscriber_test_unorder.js
...ystemtest/src/main/js/test/ActsSubscriber_test_unorder.js
+28
-26
notification/ces_standard/subscribeandpublish/actssubscriberunordertest/src/main/js/test/ActsSubscriber_test_unorder.js
...ordertest/src/main/js/test/ActsSubscriber_test_unorder.js
+44
-38
notification/ces_standard/subscribeandpublish/emittertest/src/main/js/test/EmitterTest.js
...ibeandpublish/emittertest/src/main/js/test/EmitterTest.js
+135
-135
未找到文件。
notification/ans_standard/actsnotificationshow/src/main/js/test/ActsNotificationShowTest.js
浏览文件 @
573edc8c
...
...
@@ -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
"
);
})
}
notification/ces_standard/subscribeandpublish/actssubscriberorderedtest/src/main/js/test/ActsSubscriber_test_ordered.js
浏览文件 @
573edc8c
...
...
@@ -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`
)
})
}
notification/ces_standard/subscribeandpublish/actssubscriberunordersystemtest/src/main/js/test/ActsSubscriber_test_unorder.js
浏览文件 @
573edc8c
...
...
@@ -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`
)
})
}
notification/ces_standard/subscribeandpublish/actssubscriberunordertest/src/main/js/test/ActsSubscriber_test_unorder.js
浏览文件 @
573edc8c
...
...
@@ -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
(
500
0
)
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`
)
})
}
notification/ces_standard/subscribeandpublish/emittertest/src/main/js/test/EmitterTest.js
浏览文件 @
573edc8c
...
...
@@ -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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录