Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
06fa1eb6
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,发现更多精彩内容 >>
提交
06fa1eb6
编写于
10月 24, 2022
作者:
Z
zhijianwen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
--PUBLISH_TEST--
Signed-off-by:
N
zhijianwen
<
zhijianwen@huawei.com
>
上级
24293b7f
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
482 addition
and
1 deletion
+482
-1
notification/ans_standard/actsNotificationPublishTest/Test.json
...cation/ans_standard/actsNotificationPublishTest/Test.json
+1
-1
notification/ans_standard/actsNotificationPublishTest/src/main/js/test/ActsNotificationPublishTest.js
...blishTest/src/main/js/test/ActsNotificationPublishTest.js
+481
-0
未找到文件。
notification/ans_standard/actsNotificationPublishTest/Test.json
浏览文件 @
06fa1eb6
...
...
@@ -18,7 +18,7 @@
{
"type"
:
"ShellKit"
,
"run-command"
:[
"anm setting -e com.example.actsnotificationpublish:0:
true
"
"anm setting -e com.example.actsnotificationpublish:0:
1
"
],
"cleanup-apps"
:
true
}
...
...
notification/ans_standard/actsNotificationPublishTest/src/main/js/test/ActsNotificationPublishTest.js
浏览文件 @
06fa1eb6
...
...
@@ -15,12 +15,493 @@
import
notification
from
'
@ohos.notification
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
import
image
from
'
@ohos.multimedia.image
'
import
wantAgent
from
'
@ohos.wantAgent
'
export
default
function
ActsNotificationPublishTest
()
{
describe
(
'
SUB_NOTIFICATION_ANS_Publish_TEST
'
,
function
()
{
let
TAG
=
'
SUB_NOTIFICATION_ANS_Publish_TEST ===>
'
console
.
info
(
TAG
+
'
SUB_NOTIFICATION_ANS_Publish_TEST START
'
)
let
wantAgentData
=
{}
let
picture_opts
=
{
size
:
{
height
:
25
,
width
:
2
},
pixelFormat
:
4
,
editable
:
true
,
alphaType
:
0
,
scaleMode
:
1
}
let
picture_buffer
=
new
ArrayBuffer
(
picture_opts
.
size
.
height
*
picture_opts
.
size
.
width
*
4
)
let
notification_picture
=
undefined
image
.
createPixelMap
(
picture_buffer
,
picture_opts
,
(
err
,
pixelMap
)
=>
{
if
(
err
)
{
console
.
info
(
`
${
TAG
}
createPixelMap err:
${
err
}
`
)
}
else
{
if
(
notification_picture
==
undefined
)
{
console
.
info
(
`
${
TAG
}
createPixelMap err:
${
err
}
`
)
return
}
}
})
// wantAgent
let
WantAgentInfo
=
{
wants
:
[
{
deviceId
:
"
deviceId
"
,
bundleName
:
"
com.example.actsnotificationSecondDirectory
"
,
abilityName
:
"
com.example.actsnotificationSecondDirectory.MainAbility
"
,
action
:
"
action1
"
,
entities
:
[
"
entity1
"
],
type
:
"
MIMETYPE
"
,
uri
:
"
key={true,true,false}
"
,
parameters
:
{
mykey0
:
2222
,
mykey1
:
[
1
,
2
,
3
],
mykey2
:
"
[1, 2, 3]
"
,
mykey3
:
"
ssssssssssssssssssssssssss
"
,
mykey4
:
[
false
,
true
,
false
],
mykey5
:
[
"
qqqqq
"
,
"
wwwwww
"
,
"
aaaaaaaaaaaaaaaaa
"
],
mykey6
:
true
,
}
}
],
operationType
:
wantAgent
.
OperationType
.
START_ABILITIES
,
requestCode
:
0
,
wantAgentFlags
:
[
wantAgent
.
WantAgentFlags
.
UPDATE_PRESENT_FLAG
]
}
wantAgent
.
getWantAgent
(
WantAgentInfo
,
(
err
,
data
)
=>
{
if
(
err
.
code
)
{
console
.
info
(
`
${
TAG
}
getWantAgent AsyncCallback err:
${
err
.
code
}
`
)
}
else
{
console
.
info
(
`
${
TAG
}
getWantAgent AsyncCallback success:
${
JSON
.
stringify
(
data
)}
`
)
wantAgentData
=
data
}
})
afterEach
(
async
function
(
done
)
{
console
.
info
(
`
${
TAG
}
afterEach START`
)
await
notification
.
cancelAll
((
err
)
=>
{
if
(
err
.
code
)
{
console
.
info
(
`
${
TAG
}
cancelAll notification err:
${
err
.
code
}
`
)
expect
(
false
).
assertTrue
()
done
()
}
else
{
console
.
info
(
`
${
TAG
}
cancelAll notification success`
)
expect
(
true
).
assertTrue
()
done
()
}
})
console
.
info
(
`
${
TAG
}
afterEach END`
)
})
/*
* @tc.number : SUB_NOTIFICATION_ANS_PUBLISH_TEST_0100
* @tc.name : function publish(request: NotificationRequest, callback: AsyncCallback<void>): void
* @tc.desc : Publishes a notification
*/
it
(
'
SUB_NOTIFICATION_ANS_PUBLISH_TEST_0100
'
,
0
,
async
function
(
done
)
{
console
.
info
(
`
${
TAG
}
SUB_NOTIFICATION_ANS_PUBLISH_TEST_0100 START`
)
let
notificationRequest
=
{
content
:
{
contentType
:
notification
.
ContentType
.
NOTIFICATION_CONTENT_BASIC_TEXT
,
id
:
1
,
normal
:
{
title
:
'
testTitle
'
,
text
:
'
testText
'
,
additionalText
:
'
testAdditionalText
'
},
},
slotType
:
notification
.
SlotType
.
SOCIAL_COMMUNICATION
,
isOngoing
:
true
,
isUnremovable
:
true
,
deliveryTime
:
0
,
tapDismissed
:
true
,
autoDeletedTime
:
500
,
wantAgent
:
wantAgentData
,
extraInfo
:
{
'
testKey
'
:
'
testValue
'
},
}
notification
.
publish
(
notificationRequest
,
(
err
,
data
)
=>
{
if
(
err
.
code
)
{
console
.
info
(
`
${
TAG
}
notification publish AsyncCallback err:
${
err
.
code
}
`
)
expect
(
false
).
assertTrue
()
done
()
}
else
{
console
.
log
(
`
${
TAG
}
notification publish AsyncCallback success:
${
data
}
`
)
expect
(
true
).
assertTrue
()
done
()
}
})
console
.
info
(
`
${
TAG
}
SUB_NOTIFICATION_ANS_PUBLISH_TEST_0100 END`
)
})
/*
* @tc.number : SUB_NOTIFICATION_ANS_PUBLISH_TEST_0200
* @tc.name : function publish(request: NotificationRequest): Promise<void>
* @tc.desc : Publishes a notification
*/
it
(
'
SUB_NOTIFICATION_ANS_PUBLISH_TEST_0200
'
,
0
,
async
function
(
done
)
{
console
.
info
(
`
${
TAG
}
SUB_NOTIFICATION_ANS_PUBLISH_TEST_0100 START`
)
let
notificationRequest
=
{
content
:
{
contentType
:
notification
.
ContentType
.
NOTIFICATION_CONTENT_BASIC_TEXT
,
id
:
1
,
normal
:
{
title
:
'
testTitle
'
,
text
:
'
testText
'
,
additionalText
:
'
testAdditionalText
'
},
},
slotType
:
notification
.
SlotType
.
SOCIAL_COMMUNICATION
,
isOngoing
:
true
,
isUnremovable
:
true
,
deliveryTime
:
0
,
tapDismissed
:
true
,
autoDeletedTime
:
500
,
wantAgent
:
wantAgentData
,
extraInfo
:
{
'
testKey
'
:
'
testValue
'
},
}
notification
.
publish
(
notificationRequest
).
then
(
data
=>
{
console
.
log
(
`
${
TAG
}
notification publish AsyncCallback success:
${
data
}
`
)
expect
(
true
).
assertTrue
()
done
()
}).
catch
(
err
=>
{
console
.
info
(
`
${
TAG
}
notification publish AsyncCallback err:
${
err
.
code
}
`
)
expect
(
false
).
assertTrue
()
done
()
})
console
.
info
(
`
${
TAG
}
SUB_NOTIFICATION_ANS_PUBLISH_TEST_0200 END`
)
})
/*
* @tc.number : SUB_NOTIFICATION_ANS_PUBLISH_TEST_0500
* @tc.name : function publish(request: NotificationRequest, callback: AsyncCallback<void>): void
* @tc.desc : Publishes a notification
*/
it
(
'
SUB_NOTIFICATION_ANS_PUBLISH_TEST_0500
'
,
0
,
async
function
(
done
)
{
console
.
info
(
`
${
TAG
}
SUB_NOTIFICATION_ANS_PUBLISH_TEST_0100 START`
)
let
notificationRequest
=
{
content
:
{
contentType
:
notification
.
ContentType
.
NOTIFICATION_CONTENT_LONG_TEXT
,
id
:
1
,
normal
:
{
title
:
'
testTitle
'
,
text
:
'
testText
'
,
additionalText
:
'
testAdditionalText
'
},
longText
:
{
title
:
'
testLongTextTitle
'
,
text
:
'
testLongTextText
'
,
additionalText
:
'
testLongTextAdditionalText
'
,
longText
:
'
testLongTextLongText
'
,
briefText
:
'
testLongTextBriefText
'
,
expandedTitle
:
'
testLongTextExpandedTitle
'
},
},
slotType
:
notification
.
SlotType
.
CONTENT_INFORMATION
,
isOngoing
:
true
,
isUnremovable
:
true
,
deliveryTime
:
0
,
tapDismissed
:
true
,
autoDeletedTime
:
500
,
wantAgent
:
wantAgentData
,
extraInfo
:
{
'
testKey
'
:
'
testValue
'
},
}
notification
.
publish
(
notificationRequest
,
(
err
,
data
)
=>
{
if
(
err
.
code
)
{
console
.
info
(
`
${
TAG
}
notification publish AsyncCallback err:
${
err
.
code
}
`
)
expect
(
false
).
assertTrue
()
done
()
}
else
{
console
.
log
(
`
${
TAG
}
notification publish AsyncCallback success:
${
data
}
`
)
expect
(
true
).
assertTrue
()
done
()
}
})
console
.
info
(
`
${
TAG
}
SUB_NOTIFICATION_ANS_PUBLISH_TEST_0500 END`
)
})
/*
* @tc.number : SUB_NOTIFICATION_ANS_PUBLISH_TEST_0600
* @tc.name : function publish(request: NotificationRequest): Promise<void>
* @tc.desc : Publishes a notification
*/
it
(
'
SUB_NOTIFICATION_ANS_PUBLISH_TEST_0600
'
,
0
,
async
function
(
done
)
{
console
.
info
(
`
${
TAG
}
SUB_NOTIFICATION_ANS_PUBLISH_TEST_0100 START`
)
let
notificationRequest
=
{
content
:
{
contentType
:
notification
.
ContentType
.
NOTIFICATION_CONTENT_LONG_TEXT
,
id
:
1
,
normal
:
{
title
:
'
testTitle
'
,
text
:
'
testText
'
,
additionalText
:
'
testAdditionalText
'
},
longText
:
{
title
:
'
testLongTextTitle
'
,
text
:
'
testLongTextText
'
,
additionalText
:
'
testLongTextAdditionalText
'
,
longText
:
'
testLongTextLongText
'
,
briefText
:
'
testLongTextBriefText
'
,
expandedTitle
:
'
testLongTextExpandedTitle
'
},
},
slotType
:
notification
.
SlotType
.
CONTENT_INFORMATION
,
isOngoing
:
true
,
isUnremovable
:
true
,
deliveryTime
:
0
,
tapDismissed
:
true
,
autoDeletedTime
:
500
,
wantAgent
:
wantAgentData
,
extraInfo
:
{
'
testKey
'
:
'
testValue
'
},
}
notification
.
publish
(
notificationRequest
).
then
(
data
=>
{
console
.
log
(
`
${
TAG
}
notification publish AsyncCallback success:
${
data
}
`
)
expect
(
true
).
assertTrue
()
done
()
}).
catch
(
err
=>
{
console
.
info
(
`
${
TAG
}
notification publish AsyncCallback err:
${
err
.
code
}
`
)
expect
(
false
).
assertTrue
()
done
()
})
console
.
info
(
`
${
TAG
}
SUB_NOTIFICATION_ANS_PUBLISH_TEST_0600 END`
)
})
/*
* @tc.number : SUB_NOTIFICATION_ANS_PUBLISH_TEST_0700
* @tc.name : function publish(request: NotificationRequest, callback: AsyncCallback<void>): void
* @tc.desc : Publishes a notification
*/
it
(
'
SUB_NOTIFICATION_ANS_PUBLISH_TEST_0700
'
,
0
,
async
function
(
done
)
{
console
.
info
(
`
${
TAG
}
SUB_NOTIFICATION_ANS_PUBLISH_TEST_0100 START`
)
let
notificationRequest
=
{
content
:
{
contentType
:
notification
.
ContentType
.
NOTIFICATION_CONTENT_MULTILINE
,
id
:
1
,
normal
:
{
title
:
'
testTitle
'
,
text
:
'
testText
'
,
additionalText
:
'
testAdditionalText
'
},
multiLine
:
{
title
:
'
testMultiLineTitle
'
,
text
:
'
testMultiLineText
'
,
additionalText
:
'
testMultiLineAdditionalText
'
,
longTitle
:
'
testMultiLineLongText
'
,
briefText
:
'
testMultiLineBriefText
'
,
lines
:
[
'
firstLine
'
,
'
secondLine
'
,
'
thirdLine
'
]
},
},
slotType
:
notification
.
SlotType
.
OTHER_TYPES
,
isOngoing
:
true
,
isUnremovable
:
true
,
deliveryTime
:
0
,
tapDismissed
:
true
,
autoDeletedTime
:
500
,
wantAgent
:
wantAgentData
,
extraInfo
:
{
'
testKey
'
:
'
testValue
'
},
}
notification
.
publish
(
notificationRequest
,
(
err
,
data
)
=>
{
if
(
err
.
code
)
{
console
.
info
(
`
${
TAG
}
notification publish AsyncCallback err:
${
err
.
code
}
`
)
expect
(
false
).
assertTrue
()
done
()
}
else
{
console
.
log
(
`
${
TAG
}
notification publish AsyncCallback success:
${
data
}
`
)
expect
(
true
).
assertTrue
()
done
()
}
})
console
.
info
(
`
${
TAG
}
SUB_NOTIFICATION_ANS_PUBLISH_TEST_0700 END`
)
})
/*
* @tc.number : SUB_NOTIFICATION_ANS_PUBLISH_TEST_0800
* @tc.name : function publish(request: NotificationRequest): Promise<void>
* @tc.desc : Publishes a notification
*/
it
(
'
SUB_NOTIFICATION_ANS_PUBLISH_TEST_0800
'
,
0
,
async
function
(
done
)
{
console
.
info
(
`
${
TAG
}
SUB_NOTIFICATION_ANS_PUBLISH_TEST_0100 START`
)
let
notificationRequest
=
{
content
:
{
contentType
:
notification
.
ContentType
.
NOTIFICATION_CONTENT_MULTILINE
,
id
:
1
,
normal
:
{
title
:
'
testTitle
'
,
text
:
'
testText
'
,
additionalText
:
'
testAdditionalText
'
},
multiLine
:
{
title
:
'
testMultiLineTitle
'
,
text
:
'
testMultiLineText
'
,
additionalText
:
'
testMultiLineAdditionalText
'
,
longTitle
:
'
testMultiLineLongText
'
,
briefText
:
'
testMultiLineBriefText
'
,
lines
:
[
'
firstLine
'
,
'
secondLine
'
,
'
thirdLine
'
]
},
},
slotType
:
notification
.
SlotType
.
OTHER_TYPES
,
isOngoing
:
false
,
isUnremovable
:
false
,
deliveryTime
:
0
,
tapDismissed
:
false
,
autoDeletedTime
:
500
,
wantAgent
:
wantAgentData
,
extraInfo
:
{
'
testKey
'
:
'
testValue
'
},
}
notification
.
publish
(
notificationRequest
).
then
(
data
=>
{
console
.
log
(
`
${
TAG
}
notification publish AsyncCallback success:
${
data
}
`
)
expect
(
true
).
assertTrue
()
done
()
}).
catch
(
err
=>
{
console
.
info
(
`
${
TAG
}
notification publish AsyncCallback err:
${
err
.
code
}
`
)
expect
(
false
).
assertTrue
()
done
()
})
console
.
info
(
`
${
TAG
}
SUB_NOTIFICATION_ANS_PUBLISH_TEST_0800 END`
)
})
/*
* @tc.number : SUB_NOTIFICATION_ANS_PUBLISH_TEST_1100
* @tc.name : function publish(request: NotificationRequest, callback: AsyncCallback<void>): void
* @tc.desc : Publishes a notification
*/
it
(
'
SUB_NOTIFICATION_ANS_PUBLISH_TEST_1100
'
,
0
,
async
function
(
done
)
{
console
.
info
(
`
${
TAG
}
SUB_NOTIFICATION_ANS_PUBLISH_TEST_0100 START`
)
let
notificationRequest
=
{
content
:
{
contentType
:
notification
.
ContentType
.
NOTIFICATION_CONTENT_BASIC_TEXT
,
id
:
1
,
normal
:
{
title
:
'
testTitle
'
,
text
:
'
testText
'
,
additionalText
:
'
testAdditionalText
'
},
},
color
:
255
,
colorEnabled
:
true
,
isAlertOnce
:
true
,
isStopwatch
:
true
,
isCountDown
:
true
,
isFloatingIcon
:
true
,
label
:
'
notificationPublishTestLabel
'
,
badgeIconStyle
:
6
,
showDeliveryTime
:
true
,
actionButtons
:
[
{
title
:
'
actionButtonsTitle
'
,
wantAgent
:
wantAgentData
,
extras
:
{
'
testActionButtonKey
'
:
'
testActionButtonValue
'
,
},
userInput
:
{
inputKey
:
'
testInputKey
'
}
}
],
}
notification
.
publish
(
notificationRequest
,
(
err
,
data
)
=>
{
if
(
err
.
code
)
{
console
.
info
(
`
${
TAG
}
notification publish AsyncCallback err:
${
err
.
code
}
`
)
expect
(
false
).
assertTrue
()
done
()
}
else
{
console
.
log
(
`
${
TAG
}
notification publish AsyncCallback success:
${
data
}
`
)
expect
(
true
).
assertTrue
()
done
()
}
})
console
.
info
(
`
${
TAG
}
SUB_NOTIFICATION_ANS_PUBLISH_TEST_1100 END`
)
})
/*
* @tc.number : SUB_NOTIFICATION_ANS_PUBLISH_TEST_1200
* @tc.name : function publish(request: NotificationRequest): Promise<void>
* @tc.desc : Publishes a notification
*/
it
(
'
SUB_NOTIFICATION_ANS_PUBLISH_TEST_1200
'
,
0
,
async
function
(
done
)
{
console
.
info
(
`
${
TAG
}
SUB_NOTIFICATION_ANS_PUBLISH_TEST_0100 START`
)
let
notificationRequest
=
{
content
:
{
contentType
:
notification
.
ContentType
.
NOTIFICATION_CONTENT_BASIC_TEXT
,
id
:
1
,
normal
:
{
title
:
'
testTitle
'
,
text
:
'
testText
'
,
additionalText
:
'
testAdditionalText
'
},
},
color
:
255
,
colorEnabled
:
true
,
isAlertOnce
:
true
,
isStopwatch
:
true
,
isCountDown
:
true
,
isFloatingIcon
:
true
,
label
:
'
notificationPublishTestLabel
'
,
badgeIconStyle
:
6
,
showDeliveryTime
:
true
,
actionButtons
:
[
{
title
:
'
actionButtonsTitle
'
,
wantAgent
:
wantAgentData
,
extras
:
{
'
testActionButtonKey
'
:
'
testActionButtonValue
'
,
},
userInput
:
{
inputKey
:
'
testInputKey
'
}
}
],
}
notification
.
publish
(
notificationRequest
).
then
(
data
=>
{
console
.
log
(
`
${
TAG
}
notification publish AsyncCallback success:
${
data
}
`
)
expect
(
true
).
assertTrue
()
done
()
}).
catch
(
err
=>
{
console
.
info
(
`
${
TAG
}
notification publish AsyncCallback err:
${
err
.
code
}
`
)
expect
(
false
).
assertTrue
()
done
()
})
console
.
info
(
`
${
TAG
}
SUB_NOTIFICATION_ANS_PUBLISH_TEST_1200 END`
)
})
/*
* @tc.number : SUB_NOTIFICATION_ANS_CANCEL_TEST_0100
* @tc.name : function cancel(id: number, label: string, callback: AsyncCallback<void>): void
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录