Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
437f9f95
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看板
未验证
提交
437f9f95
编写于
9月 02, 2023
作者:
O
openharmony_ci
提交者:
Gitee
9月 02, 2023
浏览文件
操作
浏览文件
下载
差异文件
!9999 add ces sync api xts
Merge pull request !9999 from zhuhan/0830
上级
5ff205e9
7f216fc5
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
140 addition
and
0 deletion
+140
-0
notification/ces_standard/actsCommonEventManagerTest/src/main/js/test/ActsCommonEventManagerSubscribeTest.js
...t/src/main/js/test/ActsCommonEventManagerSubscribeTest.js
+140
-0
未找到文件。
notification/ces_standard/actsCommonEventManagerTest/src/main/js/test/ActsCommonEventManagerSubscribeTest.js
浏览文件 @
437f9f95
...
...
@@ -209,6 +209,146 @@ export default function ActsCommonEventManagerSubscribeTest() {
console
.
info
(
`
${
TAG
}
SUB_NOTIFICATION_CES_SUBSCRIBE_MANAGER_TEST_1000 END`
)
})
it
(
'
SUB_NOTIFICATION_CES_SUBSCRIBE_MANAGER_TEST_1100
'
,
0
,
async
function
(
done
)
{
console
.
info
(
`
${
TAG
}
SUB_NOTIFICATION_CES_SUBSCRIBE_MANAGER_TEST_1100 START`
)
let
options
=
{
code
:
0
,
data
:
"
initial data
"
,
isOrdered
:
true
,
isSticky
:
false
,
}
let
subscribeInfo
=
{
events
:
[
"
eventname
"
],
priority
:
100
};
function
SubscribeCB
(
err
,
data
)
{
if
(
err
)
{
expect
(
false
).
assertTrue
()
done
()
}
else
{
let
code1
=
subscriber
.
getCodeSync
();
expect
(
code1
).
assertEqual
(
0
);
console
.
info
(
`getCodeSync before setCodeSync, code is
${
code1
}
`
)
subscriber
.
setCodeSync
(
1
);
let
code2
=
subscriber
.
getCodeSync
();
console
.
info
(
`getCodeSync after setCodeSync, code is
${
code2
}
`
)
expect
(
code2
).
assertEqual
(
1
);
let
data
=
subscriber
.
getDataSync
();
expect
(
data
).
assertEqual
(
"
initial data
"
);
console
.
info
(
`getDataSync before setDataSync, data is
${
data
}
`
)
subscriber
.
setDataSync
(
"
data change
"
);
let
data2
=
subscriber
.
getDataSync
();
expect
(
data2
).
assertEqual
(
"
data change
"
);
console
.
info
(
`getDataSync after setDataSync, data is
${
data2
}
`
)
subscriber
.
setCodeAndDataSync
(
2
,
"
setCodeAndDataSync
"
)
let
code3
=
subscriber
.
getCodeSync
()
expect
(
code3
).
assertEqual
(
2
);
console
.
info
(
`getCodeSync after setCodeAndDataSync, code is
${
code3
}
`
)
let
data3
=
subscriber
.
getDataSync
();
expect
(
data3
).
assertEqual
(
"
setCodeAndDataSync
"
);
console
.
info
(
`getDataSync after setCodeAndDataSync, data is
${
data3
}
`
)
let
isorder
=
subscriber
.
isOrderedCommonEventSync
();
expect
(
isorder
).
assertEqual
(
true
)
console
.
info
(
`isOrderedCommonEventSync, isorder is
${
isorder
}
`
)
let
isSticky
=
subscriber
.
isStickyCommonEventSync
();
expect
(
isSticky
).
assertEqual
(
false
)
console
.
info
(
`isStickyCommonEventSync, isStickyCommonEventSync is
${
isSticky
}
`
)
subscriber
.
abortCommonEventSync
();
let
isaborted
=
subscriber
.
getAbortCommonEventSync
();
expect
(
isaborted
).
assertEqual
(
true
)
console
.
info
(
`getAbortCommonEventSync isaborted
${
isaborted
}
`
)
subscriber
.
clearAbortCommonEventSync
()
done
()
}
}
let
subscriber
=
commonEventManager
.
createSubscriberSync
(
subscribeInfo
)
commonEventManager
.
subscribe
(
subscriber
,
SubscribeCB
)
function
publishCB
(
err
)
{
if
(
err
)
{
console
.
error
(
`publish failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
)
expect
(
false
).
assertTrue
()
done
()
}
else
{
console
.
info
(
`publish success`
)
}
}
try
{
setTimeout
(()
=>
{
commonEventManager
.
publish
(
"
eventname
"
,
options
,
publishCB
);
},
1000
);
}
catch
(
err
)
{
console
.
error
(
`publish failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
)
}
})
it
(
'
SUB_NOTIFICATION_CES_SUBSCRIBE_MANAGER_TEST_1200
'
,
0
,
async
function
(
done
)
{
console
.
info
(
`
${
TAG
}
SUB_NOTIFICATION_CES_SUBSCRIBE_MANAGER_TEST_1200 START`
)
let
options
=
{
code
:
0
,
data
:
"
initial data
"
,
}
let
subscribeInfo
=
{
events
:
[
"
eventname2
"
],
priority
:
100
};
function
SubscribeCB
(
err
,
data
)
{
if
(
err
)
{
console
.
error
(
`subscribe failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
)
expect
(
false
).
assertTrue
()
done
()
}
else
{
let
info
=
subscriber
.
getSubscribeInfoSync
();
expect
(
info
.
priority
).
assertEqual
(
100
)
expect
(
info
.
userId
).
assertEqual
(
-
3
)
done
()
}
}
let
subscriber
=
commonEventManager
.
createSubscriberSync
(
subscribeInfo
)
commonEventManager
.
subscribe
(
subscriber
,
SubscribeCB
)
function
publishCB
(
err
)
{
if
(
err
)
{
console
.
error
(
`publish failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
)
expect
(
false
).
assertTrue
()
done
()
}
else
{
console
.
info
(
`publish success`
)
}
}
try
{
setTimeout
(()
=>
{
commonEventManager
.
publish
(
"
eventname2
"
,
options
,
publishCB
);
},
1000
);
}
catch
(
err
)
{
console
.
error
(
`publish failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
)
expect
(
false
).
assertTrue
()
done
()
}
console
.
info
(
`
${
TAG
}
SUB_NOTIFICATION_CES_SUBSCRIBE_MANAGER_TEST_1200 END`
)
})
console
.
info
(
`
${
TAG
}
SUB_NOTIFICATION_CES_SUBSCRIBE_MANAGER_TEST END`
)
})
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录