Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
2a733d04
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看板
提交
2a733d04
编写于
8月 01, 2022
作者:
Z
zhijianwen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
emitter_release
Signed-off-by:
N
zhijianwen
<
zhijianwen@huawei.com
>
上级
4b05c238
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
332 addition
and
313 deletion
+332
-313
notification/ces_standard/subscribeandpublish/emittertest/entry/src/main/js/test/EmitterTest.js
...publish/emittertest/entry/src/main/js/test/EmitterTest.js
+332
-313
未找到文件。
notification/ces_standard/subscribeandpublish/emittertest/entry/src/main/js/test/EmitterTest.js
浏览文件 @
2a733d04
...
@@ -12,31 +12,45 @@
...
@@ -12,31 +12,45 @@
* See the License for the specific language governing permissions and
* See the License for the specific language governing permissions and
* limitations under the License.
* limitations under the License.
*/
*/
import
events_emitter
from
'
@ohos.events.emitter
'
;
import
events_emitter
from
'
@ohos.events.emitter
'
import
notification
from
'
@ohos.notification
'
;
import
notification
from
'
@ohos.notification
'
import
commonEvent
from
'
@ohos.commonEvent
'
;
import
commonEvent
from
'
@ohos.commonEvent
'
import
wantAgent
from
'
@ohos.wantAgent
'
;
import
wantAgent
from
'
@ohos.wantAgent
'
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
;
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
import
bundle
from
'
@ohos.bundle
'
;
import
bundle
from
'
@ohos.bundle
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
,
Assert
}
from
'
deccjsunit/index
'
;
import
account
from
'
@ohos.account.osAccount
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
,
Assert
}
from
'
deccjsunit/index
'
describe
(
'
EmitterTest
'
,
function
()
{
describe
(
'
EmitterTest
'
,
function
()
{
const
TAG
=
'
EmitterTest ===>
'
const
TAG
=
'
EmitterTest ===>
'
console
.
info
(
TAG
+
'
EmitterTest START
'
)
let
userId
async
function
getUserId
()
{
await
account
.
getAccountManager
().
getOsAccountLocalIdFromProcess
().
then
(
account
=>
{
console
.
info
(
"
getOsAccountLocalIdFromProcess userid ==========
"
+
account
)
userId
=
account
}).
catch
(
err
=>
{
console
.
info
(
"
getOsAccountLocalIdFromProcess err ==========
"
+
JSON
.
stringify
(
err
))
})
}
async
function
applyPermission
()
{
async
function
applyPermission
()
{
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
com.example.emittertest
'
,
0
,
100
);
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
com.example.emittertest
'
,
0
,
userId
)
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
let
atManager
=
abilityAccessCtrl
.
createAtManager
()
if
(
atManager
!=
null
)
{
if
(
atManager
!=
null
)
{
let
tokenID
=
appInfo
.
accessTokenId
;
let
tokenID
=
appInfo
.
accessTokenId
console
.
info
(
'
[permission]case accessTokenId is
'
+
tokenID
);
console
.
info
(
'
[permission]case accessTokenId is
'
+
tokenID
)
let
permissionName1
=
'
ohos.permission.NOTIFICATION_CONTROLLER
'
;
let
permissionName1
=
'
ohos.permission.NOTIFICATION_CONTROLLER
'
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName1
).
then
((
result
)
=>
{
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission]case grantUserGrantedPermission success:
'
+
result
);
console
.
info
(
'
[permission]case grantUserGrantedPermission success:
'
+
result
)
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permission]case grantUserGrantedPermission failed:
'
+
err
);
console
.
info
(
'
[permission]case grantUserGrantedPermission failed:
'
+
err
)
});
})
}
else
{
}
else
{
console
.
info
(
'
[permission]case apply permission failed,createAtManager failed
'
);
console
.
info
(
'
[permission]case apply permission failed,createAtManager failed
'
)
}
}
}
}
...
@@ -71,9 +85,9 @@ describe('EmitterTest', function () {
...
@@ -71,9 +85,9 @@ describe('EmitterTest', function () {
key_2
:
'
value_2
'
,
key_2
:
'
value_2
'
,
}
}
}
}
let
subscriber
=
undefined
beforeAll
(
async
function
()
{
beforeAll
(
async
function
()
{
await
getUserId
()
await
applyPermission
();
await
applyPermission
()
await
notification
.
enableNotification
(
bundlel
,
true
,
(
err
)
=>
{
await
notification
.
enableNotification
(
bundlel
,
true
,
(
err
)
=>
{
if
(
err
.
code
)
{
if
(
err
.
code
)
{
console
.
info
(
TAG
+
'
: enableNotification failed! Err.code ===>
'
+
JSON
.
stringify
(
err
.
code
))
console
.
info
(
TAG
+
'
: enableNotification failed! Err.code ===>
'
+
JSON
.
stringify
(
err
.
code
))
...
@@ -83,10 +97,10 @@ describe('EmitterTest', function () {
...
@@ -83,10 +97,10 @@ describe('EmitterTest', function () {
console
.
info
(
TAG
+
'
: enableNotification successd!
'
)
console
.
info
(
TAG
+
'
: enableNotification successd!
'
)
expect
(
true
).
assertTrue
()
expect
(
true
).
assertTrue
()
}
}
});
console
.
info
(
TAG
+
'
beforeAll case
'
);
})
})
afterEach
(
async
function
()
{
console
.
info
(
TAG
+
'
beforeAll case
'
)
})
afterEach
(
async
function
()
{
await
notification
.
cancelAll
((
err
)
=>
{
await
notification
.
cancelAll
((
err
)
=>
{
if
(
err
.
code
)
{
if
(
err
.
code
)
{
console
.
info
(
TAG
+
'
: cancelAll failed! Err.code ===>
'
+
err
.
code
)
console
.
info
(
TAG
+
'
: cancelAll failed! Err.code ===>
'
+
err
.
code
)
...
@@ -98,26 +112,27 @@ describe('EmitterTest', function () {
...
@@ -98,26 +112,27 @@ describe('EmitterTest', function () {
}
}
})
})
})
})
function
EmitterCallback
(
eventData
)
{
function
EmitterCallback
(
eventData
)
{
console
.
info
(
TAG
+
'
eventData.id:
'
+
JSON
.
stringify
(
eventData
.
data
.
id
));
console
.
info
(
TAG
+
'
eventData.id:
'
+
JSON
.
stringify
(
eventData
.
data
.
id
))
console
.
info
(
TAG
+
'
eventData.content:
'
+
JSON
.
stringify
(
eventData
.
data
.
content
));
console
.
info
(
TAG
+
'
eventData.content:
'
+
JSON
.
stringify
(
eventData
.
data
.
content
))
if
(
eventData
.
data
.
id
==
0
)
{
if
(
eventData
.
data
.
id
==
0
)
{
expect
(
eventData
.
data
.
content
).
assertEqual
(
'
message_0
'
);
expect
(
eventData
.
data
.
content
).
assertEqual
(
'
message_0
'
)
}
else
if
(
eventData
.
data
.
id
==
1
)
{
}
else
if
(
eventData
.
data
.
id
==
1
)
{
expect
(
eventData
.
data
.
content
).
assertEqual
(
'
message_1
'
);
expect
(
eventData
.
data
.
content
).
assertEqual
(
'
message_1
'
)
}
else
if
(
eventData
.
data
.
id
==
2
)
{
}
else
if
(
eventData
.
data
.
id
==
2
)
{
expect
(
eventData
.
data
.
content
).
assertEqual
(
'
message_2
'
);
expect
(
eventData
.
data
.
content
).
assertEqual
(
'
message_2
'
)
}
else
if
(
eventData
.
data
.
id
==
3
)
{
}
else
if
(
eventData
.
data
.
id
==
3
)
{
expect
(
eventData
.
data
.
content
).
assertEqual
(
'
message_3
'
);
expect
(
eventData
.
data
.
content
).
assertEqual
(
'
message_3
'
)
}
else
if
(
eventData
.
data
.
id
==
4
)
{
}
else
if
(
eventData
.
data
.
id
==
4
)
{
expect
(
eventData
.
data
.
content
).
assertEqual
(
'
message_4
'
);
expect
(
eventData
.
data
.
content
).
assertEqual
(
'
message_4
'
)
}
else
if
(
eventData
.
data
.
id
==
5
)
{
}
else
if
(
eventData
.
data
.
id
==
5
)
{
expect
(
eventData
.
data
.
content
).
assertEqual
(
'
message_5
'
);
expect
(
eventData
.
data
.
content
).
assertEqual
(
'
message_5
'
)
}
}
}
}
it
(
'
EmitterTest_001
'
,
0
,
async
function
(
done
)
{
it
(
'
EmitterTest_001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
TAG
+
'
EmitterTest_001 start
.
'
)
console
.
info
(
TAG
+
'
EmitterTest_001 START
.
'
)
innerEvent
.
eventId
=
1
innerEvent
.
eventId
=
1
innerEvent
.
priority
=
events_emitter
.
EventPriority
.
IDLE
innerEvent
.
priority
=
events_emitter
.
EventPriority
.
IDLE
...
@@ -134,7 +149,7 @@ describe('EmitterTest', function () {
...
@@ -134,7 +149,7 @@ describe('EmitterTest', function () {
})
})
it
(
'
EmitterTest_002
'
,
0
,
async
function
(
done
)
{
it
(
'
EmitterTest_002
'
,
0
,
async
function
(
done
)
{
console
.
info
(
TAG
+
'
EmitterTest_002 start
.
'
)
console
.
info
(
TAG
+
'
EmitterTest_002 START
.
'
)
innerEvent
.
eventId
=
2
innerEvent
.
eventId
=
2
innerEvent
.
priority
=
events_emitter
.
EventPriority
.
LOW
innerEvent
.
priority
=
events_emitter
.
EventPriority
.
LOW
...
@@ -148,7 +163,7 @@ describe('EmitterTest', function () {
...
@@ -148,7 +163,7 @@ describe('EmitterTest', function () {
})
})
it
(
'
EmitterTest_003
'
,
0
,
async
function
(
done
)
{
it
(
'
EmitterTest_003
'
,
0
,
async
function
(
done
)
{
console
.
info
(
TAG
+
'
EmitterTest_003 start
.
'
)
console
.
info
(
TAG
+
'
EmitterTest_003 START
.
'
)
innerEvent
.
eventId
=
3
innerEvent
.
eventId
=
3
innerEvent
.
priority
=
events_emitter
.
EventPriority
.
HIGH
innerEvent
.
priority
=
events_emitter
.
EventPriority
.
HIGH
...
@@ -162,7 +177,7 @@ describe('EmitterTest', function () {
...
@@ -162,7 +177,7 @@ describe('EmitterTest', function () {
})
})
it
(
'
EmitterTest_004
'
,
0
,
async
function
(
done
)
{
it
(
'
EmitterTest_004
'
,
0
,
async
function
(
done
)
{
console
.
info
(
TAG
+
'
EmitterTest_004 start
.
'
)
console
.
info
(
TAG
+
'
EmitterTest_004 START
.
'
)
innerEvent
.
eventId
=
4
innerEvent
.
eventId
=
4
innerEvent
.
priority
=
events_emitter
.
EventPriority
.
IMMEDIATE
innerEvent
.
priority
=
events_emitter
.
EventPriority
.
IMMEDIATE
...
@@ -177,7 +192,7 @@ describe('EmitterTest', function () {
...
@@ -177,7 +192,7 @@ describe('EmitterTest', function () {
it
(
'
EmitterTest_005
'
,
0
,
async
function
(
done
)
{
it
(
'
EmitterTest_005
'
,
0
,
async
function
(
done
)
{
console
.
info
(
TAG
+
'
EmitterTest_005 start
.
'
)
console
.
info
(
TAG
+
'
EmitterTest_005 START
.
'
)
innerEvent
.
eventId
=
5
innerEvent
.
eventId
=
5
innerEvent
.
priority
=
events_emitter
.
EventPriority
.
IMMEDIATE
innerEvent
.
priority
=
events_emitter
.
EventPriority
.
IMMEDIATE
...
@@ -191,7 +206,8 @@ describe('EmitterTest', function () {
...
@@ -191,7 +206,8 @@ describe('EmitterTest', function () {
done
()
done
()
})
})
it
(
'
wantAgent_trigger_001
'
,
0
,
async
function
(
done
){
it
(
'
wantAgent_trigger_001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
TAG
+
'
wantAgent_trigger_001 START.
'
)
await
wantAgent
.
getWantAgent
(
wantAgentInfo
,
(
err
,
data
)
=>
{
await
wantAgent
.
getWantAgent
(
wantAgentInfo
,
(
err
,
data
)
=>
{
if
(
err
.
code
)
{
if
(
err
.
code
)
{
console
.
info
(
TAG
+
'
: getWant failed! Err.code ===>
'
+
JSON
.
stringify
(
err
.
code
))
console
.
info
(
TAG
+
'
: getWant failed! Err.code ===>
'
+
JSON
.
stringify
(
err
.
code
))
...
@@ -201,7 +217,7 @@ describe('EmitterTest', function () {
...
@@ -201,7 +217,7 @@ describe('EmitterTest', function () {
}
else
{
}
else
{
console
.
info
(
TAG
+
'
: getWant successd!
'
)
console
.
info
(
TAG
+
'
: getWant successd!
'
)
console
.
info
(
TAG
+
'
: wantAgentInfo ===>
'
+
JSON
.
stringify
(
data
))
console
.
info
(
TAG
+
'
: wantAgentInfo ===>
'
+
JSON
.
stringify
(
data
))
expect
(
typeof
(
data
)).
assertEqual
(
'
object
'
)
expect
(
typeof
(
data
)).
assertEqual
(
'
object
'
)
let
triggerInfo
=
{
let
triggerInfo
=
{
code
:
100
,
code
:
100
,
...
@@ -228,8 +244,39 @@ describe('EmitterTest', function () {
...
@@ -228,8 +244,39 @@ describe('EmitterTest', function () {
})
})
})
})
it
(
'
commonEvent_subscriberInfo_001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
TAG
+
'
commonEvent_subscriberInfo_001 START.
'
)
let
CommonEventSubscribeInfo
=
{
events
:
[
'
event
'
],
publisherPermission
:
''
,
publisherDeviceId
:
''
,
userId
:
100
,
priority
:
1000
}
let
CommonEventSubscriber
=
await
commonEvent
.
createSubscriber
(
CommonEventSubscribeInfo
)
if
(
CommonEventSubscriber
==
undefined
)
{
console
.
info
(
TAG
+
'
: createSubscriber failed! Err.message ===>
'
+
JSON
.
stringify
(
CommonEventSubscriber
))
expect
(
false
).
assertTrue
()
}
await
CommonEventSubscriber
.
getSubscribeInfo
((
err
,
CommonEventSubscribeInfo
)
=>
{
if
(
err
.
code
)
{
console
.
info
(
TAG
+
'
: getSubscribeInfo failed! Err.code ===>
'
+
JSON
.
stringify
(
err
.
code
))
console
.
info
(
TAG
+
'
: getSubscribeInfo failed! Err.message ===>
'
+
JSON
.
stringify
(
err
.
message
))
expect
(
false
).
assertTrue
()
done
()
}
else
{
console
.
info
(
TAG
+
'
: getSubscribeInfo successd! CommonEventSubscribeInfo ===>
'
+
JSON
.
stringify
(
CommonEventSubscribeInfo
))
done
()
}
})
})
it
(
'
notification_publish_001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
TAG
+
'
notification_publish_001 START.
'
)
it
(
'
notification_publish_001
'
,
0
,
async
function
(
done
){
await
notification
.
isNotificationEnabled
(
bundlel
,
(
err
,
data
)
=>
{
await
notification
.
isNotificationEnabled
(
bundlel
,
(
err
,
data
)
=>
{
if
(
err
.
code
)
{
if
(
err
.
code
)
{
console
.
info
(
TAG
+
'
: isNotificationEnabled failed! Err.code ===>
'
+
JSON
.
stringify
(
err
.
code
))
console
.
info
(
TAG
+
'
: isNotificationEnabled failed! Err.code ===>
'
+
JSON
.
stringify
(
err
.
code
))
...
@@ -240,19 +287,20 @@ describe('EmitterTest', function () {
...
@@ -240,19 +287,20 @@ describe('EmitterTest', function () {
expect
(
true
).
assertTrue
()
expect
(
true
).
assertTrue
()
}
}
})
})
async
function
SubscribeCallbackData
(
data
)
{
async
function
SubscribeCallbackData
(
data
)
{
console
.
info
(
TAG
+
'
: data ===>
'
+
JSON
.
stringify
(
data
))
console
.
info
(
TAG
+
'
: data ===>
'
+
JSON
.
stringify
(
data
))
console
.
info
(
TAG
+
'
: data.request.content.normal.title ===>
'
+
JSON
.
stringify
(
data
.
request
.
content
.
normal
.
title
))
console
.
info
(
TAG
+
'
: data.request.content.normal.title ===>
'
+
JSON
.
stringify
(
data
.
request
.
content
.
normal
.
title
))
console
.
info
(
TAG
+
'
: data.request.content.normal.text ===>
'
+
JSON
.
stringify
(
data
.
request
.
content
.
normal
.
text
))
console
.
info
(
TAG
+
'
: data.request.content.normal.text ===>
'
+
JSON
.
stringify
(
data
.
request
.
content
.
normal
.
text
))
console
.
info
(
TAG
+
'
: data.request.content.normal.additionalText ===>
'
+
JSON
.
stringify
(
data
.
request
.
content
.
normal
.
additionalText
))
console
.
info
(
TAG
+
'
: data.request.content.normal.additionalText ===>
'
+
JSON
.
stringify
(
data
.
request
.
content
.
normal
.
additionalText
))
console
.
info
(
TAG
+
'
: data.request.actionButtons[0].title ===>
'
+
JSON
.
stringify
(
data
.
request
.
actionButtons
[
0
].
title
))
console
.
info
(
TAG
+
'
: data.request.actionButtons[0].title ===>
'
+
JSON
.
stringify
(
data
.
request
.
actionButtons
[
0
].
title
))
expect
(
data
.
request
.
content
.
normal
.
title
).
assertEqual
(
'
title
'
);
expect
(
data
.
request
.
content
.
normal
.
title
).
assertEqual
(
'
title
'
)
expect
(
data
.
request
.
content
.
normal
.
text
).
assertEqual
(
'
text
'
);
expect
(
data
.
request
.
content
.
normal
.
text
).
assertEqual
(
'
text
'
)
expect
(
data
.
request
.
content
.
normal
.
additionalText
).
assertEqual
(
'
additionalText
'
);
expect
(
data
.
request
.
content
.
normal
.
additionalText
).
assertEqual
(
'
additionalText
'
)
expect
(
data
.
request
.
content
.
normal
.
creatorBundleName
).
assertEqual
(
bundlel
.
bundle
);
expect
(
data
.
request
.
content
.
normal
.
creatorBundleName
).
assertEqual
(
bundlel
.
bundle
)
expect
(
data
.
request
.
content
.
normal
.
creatorPid
!=
undefined
).
assertTrue
()
expect
(
data
.
request
.
content
.
normal
.
creatorPid
!=
undefined
).
assertTrue
()
expect
(
data
.
request
.
content
.
normal
.
creatorUid
!=
undefined
).
assertTrue
()
expect
(
data
.
request
.
content
.
normal
.
creatorUid
!=
undefined
).
assertTrue
()
expect
(
data
.
request
.
actionButtons
[
0
].
title
).
assertEqual
(
'
additionalText
'
);
expect
(
data
.
request
.
actionButtons
[
0
].
title
).
assertEqual
(
'
additionalText
'
)
expect
(
data
.
request
.
actionButtons
[
0
].
extras
.
wantAgentInfo_key_1
).
assertEqual
(
'
wantAgentInfo_key_1
'
)
expect
(
data
.
request
.
actionButtons
[
0
].
extras
.
wantAgentInfo_key_1
).
assertEqual
(
'
wantAgentInfo_key_1
'
)
expect
(
data
.
request
.
actionButtons
[
0
].
extras
.
wantAgentInfo_key_2
).
assertEqual
(
'
wantAgentInfo_key_2
'
)
expect
(
data
.
request
.
actionButtons
[
0
].
extras
.
wantAgentInfo_key_2
).
assertEqual
(
'
wantAgentInfo_key_2
'
)
expect
(
data
.
request
.
actionButtons
[
0
].
userInput
.
inputKey
).
assertEqual
(
'
Please input at this
'
)
expect
(
data
.
request
.
actionButtons
[
0
].
userInput
.
inputKey
).
assertEqual
(
'
Please input at this
'
)
...
@@ -275,7 +323,7 @@ describe('EmitterTest', function () {
...
@@ -275,7 +323,7 @@ describe('EmitterTest', function () {
onConsume
:
SubscribeCallbackData
onConsume
:
SubscribeCallbackData
}
}
await
notification
.
subscribe
(
NotificationSubscriber
,
(
err
)
=>
{
await
notification
.
subscribe
(
NotificationSubscriber
,
(
err
)
=>
{
if
(
err
.
code
)
{
if
(
err
.
code
)
{
console
.
info
(
TAG
+
'
: subscribe failed! Err.code ===>
'
+
JSON
.
stringify
(
err
.
code
))
console
.
info
(
TAG
+
'
: subscribe failed! Err.code ===>
'
+
JSON
.
stringify
(
err
.
code
))
console
.
info
(
TAG
+
'
: subscribe failed! Err.message ===>
'
+
JSON
.
stringify
(
err
.
message
))
console
.
info
(
TAG
+
'
: subscribe failed! Err.message ===>
'
+
JSON
.
stringify
(
err
.
message
))
...
@@ -289,30 +337,29 @@ describe('EmitterTest', function () {
...
@@ -289,30 +337,29 @@ describe('EmitterTest', function () {
let
wantAgentInstance
=
await
wantAgent
.
getWantAgent
(
wantAgentInfo
)
let
wantAgentInstance
=
await
wantAgent
.
getWantAgent
(
wantAgentInfo
)
const
NotificationRequest
=
{
const
NotificationRequest
=
{
content
:
{
content
:
{
contentType
:
notification
.
ContentType
.
NOTIFICATION_CONTENT_BASIC_TEXT
,
contentType
:
notification
.
ContentType
.
NOTIFICATION_CONTENT_BASIC_TEXT
,
normal
:
{
normal
:
{
title
:
'
title
'
,
title
:
'
title
'
,
text
:
'
text
'
,
text
:
'
text
'
,
additionalText
:
'
additionalText
'
additionalText
:
'
additionalText
'
},
},
},
},
actionButtons
:
[
actionButtons
:
[
{
{
title
:
'
activeButton_title
'
,
title
:
'
activeButton_title
'
,
wantAgent
:
wantAgentInstance
,
wantAgent
:
wantAgentInstance
,
extras
:
{
extras
:
{
wantAgentInfo_key_1
:
'
wantAgentInfo_key_1
'
,
wantAgentInfo_key_1
:
'
wantAgentInfo_key_1
'
,
wantAgentInfo_key_2
:
'
wantAgentInfo_key_2
'
,
wantAgentInfo_key_2
:
'
wantAgentInfo_key_2
'
,
},
},
userInput
:
{
userInput
:
{
inputKey
:
'
Please input at this
'
inputKey
:
'
Please input at this
'
}
}
}
}
],
],
}
}
// 发布通知
await
notification
.
publish
(
NotificationRequest
,
(
err
)
=>
{
await
notification
.
publish
(
NotificationRequest
,
(
err
)
=>
{
if
(
err
.
code
)
{
if
(
err
.
code
)
{
console
.
info
(
TAG
+
'
: publish failed! Err.code ===>
'
+
JSON
.
stringify
(
err
.
code
))
console
.
info
(
TAG
+
'
: publish failed! Err.code ===>
'
+
JSON
.
stringify
(
err
.
code
))
...
@@ -325,33 +372,5 @@ describe('EmitterTest', function () {
...
@@ -325,33 +372,5 @@ describe('EmitterTest', function () {
})
})
})
})
})
it
(
'
commonEvent_subscriberInfo_001
'
,
0
,
async
function
(
done
){
let
CommonEventSubscribeInfo
=
{
events
:
[
'
event
'
],
publisherPermission
:
''
,
publisherDeviceId
:
''
,
userId
:
100
,
priority
:
1000
}
let
CommonEventSubscriber
=
await
commonEvent
.
createSubscriber
(
CommonEventSubscribeInfo
)
if
(
CommonEventSubscriber
==
undefined
)
{
console
.
info
(
TAG
+
'
: createSubscriber failed! Err.message ===>
'
+
JSON
.
stringify
(
CommonEventSubscriber
))
expect
(
false
).
assertTrue
()
}
await
CommonEventSubscriber
.
getSubscribeInfo
((
err
,
CommonEventSubscribeInfo
)
=>
{
if
(
err
.
code
)
{
console
.
info
(
TAG
+
'
: getSubscribeInfo failed! Err.code ===>
'
+
JSON
.
stringify
(
err
.
code
))
console
.
info
(
TAG
+
'
: getSubscribeInfo failed! Err.message ===>
'
+
JSON
.
stringify
(
err
.
message
))
expect
(
false
).
assertTrue
()
done
()
}
else
{
console
.
info
(
TAG
+
'
: getSubscribeInfo successd! CommonEventSubscribeInfo ===>
'
+
JSON
.
stringify
(
CommonEventSubscribeInfo
))
done
()
}
})
})
})
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录