未验证 提交 733ada9e 编写于 作者: O openharmony_ci 提交者: Gitee

!8644 add notification XTS test

Merge pull request !8644 from liuyanzhi2020/liu0512
......@@ -60,6 +60,25 @@ export default function ActsNotificationDistributedTest() {
console.info(`${TAG} SUB_NOTIFICATION_ANS_IS_DISTRIBUTED_ENABLED_TEST_0200 END`)
})
/*
* @tc.number : SUB_NOTIFICATION_ANS_IS_DISTRIBUTED_ENABLED_TEST_0300
* @tc.name : function isDistributedEnabled(undefined): Promise<boolean>
* @tc.desc : Obtains whether the device supports distributed notification
*/
it('SUB_NOTIFICATION_ANS_IS_DISTRIBUTED_ENABLED_TEST_0300', 0, async function (done) {
console.info(`${TAG} SUB_NOTIFICATION_ANS_IS_DISTRIBUTED_ENABLED_TEST_0300 START`)
notification.isDistributedEnabled(undefined).then((data) => {
console.info(`${TAG} isDistributedEnabled Promise success: ${data}`)
expect(data).assertFalse()
done()
}).catch((err) => {
console.info(`${TAG} isDistributedEnabled Promise err: ${err.code}`)
expect(false).assertTrue()
done()
})
console.info(`${TAG} SUB_NOTIFICATION_ANS_IS_DISTRIBUTED_ENABLED_TEST_0300 END`)
})
console.info(TAG + 'SUB_NOTIFICATION_IS_DISTRIBUTED_ENABLED_TEST END')
})
......
......@@ -66,6 +66,25 @@ export default function ActsNotificationManagerDistributedTest() {
console.info(`${TAG} SUB_NOTIFICATION_ANS_MANAGER_IS_DISTRIBUTED_ENABLED_TEST_0200 END`)
})
/*
* @tc.number : SUB_NOTIFICATION_ANS_MANAGER_IS_DISTRIBUTED_ENABLED_TEST_0300
* @tc.name : function isDistributedEnabled(undefined): Promise<boolean>
* @tc.desc : Obtains whether the device supports distributed notification
*/
it('SUB_NOTIFICATION_ANS_MANAGER_IS_DISTRIBUTED_ENABLED_TEST_0300', 0, async function (done) {
console.info(`${TAG} SUB_NOTIFICATION_ANS_MANAGER_IS_DISTRIBUTED_ENABLED_TEST_0300 START`)
notificationManager.isDistributedEnabled(undefined).then((data) => {
console.info(`${TAG} isDistributedEnabled Promise success: ${data}`)
expect(data).assertFalse()
done()
}).catch((err) => {
console.info(`${TAG} isDistributedEnabled Promise err: ${err.code}, errMes: ${err.message}`)
expect(false).assertTrue()
done()
})
console.info(`${TAG} SUB_NOTIFICATION_ANS_MANAGER_IS_DISTRIBUTED_ENABLED_TEST_0300 END`)
})
console.info(TAG + 'SUB_NOTIFICATION_IS_DISTRIBUTED_ENABLED_TEST END')
})
......
......@@ -1512,6 +1512,101 @@ export default function ActsNotificationManagerSlotTest() {
console.info(TAG + 'SUB_NOTIFICATION_ANS_MANAGER_SLOT_TEST_4800 END')
})
/*
* @tc.number : SUB_NOTIFICATION_ANS_MANAGER_SLOT_TEST_4900
* @tc.name : addSlot(type: SlotType, undefined): Promise<void>
* @tc.desc : NotificationSlot for other purposes
*/
it('SUB_NOTIFICATION_ANS_MANAGER_SLOT_TEST_4900', 0, async function (done) {
console.info(TAG + 'SUB_NOTIFICATION_ANS_MANAGER_SLOT_TEST_4900 START')
await notificationManager.addSlot(notificationManager.SlotType.OTHER_TYPES, undefined).then(() => {
console.info(`${TAG} addSlot_49 Promise success`)
expect(true).assertTrue()
done()
}).catch((err) => {
console.info(`${TAG} addSlot_49 Promise errCode: ${err.code}, errMes: ${err.message}`)
expect(false).assertTrue()
done()
})
console.info(TAG + 'SUB_NOTIFICATION_ANS_MANAGER_SLOT_TEST_4900 END')
})
/*
* @tc.number : SUB_NOTIFICATION_ANS_MANAGER_SLOT_TEST_5000
* @tc.name : getSlot(SlotType: SlotType, undefined): Promise<NotificationSlot>
* @tc.desc : Get the UNKNOWN_TYPE type slot without add
*/
it('SUB_NOTIFICATION_ANS_MANAGER_SLOT_TEST_5000', 0, async function (done) {
console.info(TAG + 'SUB_NOTIFICATION_ANS_MANAGER_SLOT_TEST_5000 START')
await notificationManager.getSlot(notificationManager.SlotType.UNKNOWN_TYPE, undefined).then((NotificationSlot) => {
console.info(`${TAG} getSlot_50 Promise success: ${NotificationSlot}`)
expect(true).assertTrue()
done()
}).catch((err) => {
console.info(`${TAG} getSlot_50 Promise errCode: ${err.code}, errMes: ${err.message}`)
expect(false).assertTrue()
done()
})
console.info(TAG + 'SUB_NOTIFICATION_ANS_MANAGER_SLOT_TEST_5000 END')
})
/*
* @tc.number : SUB_NOTIFICATION_ANS_MANAGER_SLOT_TEST_5100
* @tc.name : getSlots(undefined): Promise<Array<NotificationSlot>>
* @tc.desc : Get all NotificationSlot without add
*/
it('SUB_NOTIFICATION_ANS_MANAGER_SLOT_TEST_5100', 0, async function (done) {
console.info(TAG + 'SUB_NOTIFICATION_ANS_MANAGER_SLOT_TEST_5100 START')
await notificationManager.getSlots(undefined).then((NotificationSlot) => {
console.info(`${TAG} getSlots_51 Promise success: ${NotificationSlot}`)
expect(true).assertTrue()
done()
}).catch((err) => {
console.info(`${TAG} getSlots_51 Promise err: ${err}, errMes: ${err.message}`)
expect(false).assertTrue()
done()
})
console.info(TAG + 'SUB_NOTIFICATION_ANS_MANAGER_SLOT_TEST_5100 END')
})
/*
* @tc.number : SUB_NOTIFICATION_ANS_MANAGER_SLOT_TEST_5200
* @tc.name : removeSlot(SlotType: SlotType, undefined): Promise<void>
* @tc.desc : Remove the UNKNOWN_TYPE type slot without add
*/
it('SUB_NOTIFICATION_ANS_MANAGER_SLOT_TEST_5200', 0, async function (done) {
console.info(TAG + 'SUB_NOTIFICATION_ANS_MANAGER_SLOT_TEST_5200 START')
await notificationManager.removeSlot(notificationManager.SlotType.UNKNOWN_TYPE, undefined).then(() => {
console.info(`${TAG} removeSlot_52 success`)
expect(true).assertTrue()
done()
}).catch((err) => {
console.info(`${TAG} removeSlot_52 errCode: ${err.code}, errMes: ${err.message}`)
expect(false).assertTrue()
done()
})
console.info(TAG + 'SUB_NOTIFICATION_ANS_MANAGER_SLOT_TEST_5200 END')
})
/*
* @tc.number : SUB_NOTIFICATION_ANS_MANAGER_SLOT_TEST_5300
* @tc.name : removeAllSlots(undefined): Promise<void>
* @tc.desc : Removes all NotificationSlot
*/
it('SUB_NOTIFICATION_ANS_MANAGER_SLOT_TEST_5300', 0, async function (done) {
console.info(TAG + 'SUB_NOTIFICATION_ANS_MANAGER_SLOT_TEST_5300 START')
await notificationManager.removeAllSlots(undefined).then(() => {
console.info(`${TAG} removeAllSlots_53 Promise success`)
expect(true).assertTrue()
done()
}).catch((err) => {
console.info(`${TAG} removeAllSlots_53 Promise err: ${err}, errMes: ${err.message}`)
expect(false).assertTrue()
done()
})
console.info(TAG + 'SUB_NOTIFICATION_ANS_MANAGER_SLOT_TEST_5300 END')
})
/*
* @tc.number : SUB_NOTIFICATION_ANS_MANAGER_SLOT_ENUM_TEST_0100
* @tc.name : Describes NotificationSlot types
......
......@@ -102,6 +102,68 @@ export default function ActsNotificationManagerPublishTest() {
console.info(`${TAG} SUB_NOTIFICATION_ANS_MANAGER_CANCEL_TEST_0300 END`)
})
/*
* @tc.number : SUB_NOTIFICATION_ANS_MANAGER_CANCEL_TEST_0400
* @tc.name : function cancel(id: number, undefined): Promise<void>
* @tc.desc : Cancels a notification with the specified label and ID
*/
it('SUB_NOTIFICATION_ANS_MANAGER_CANCEL_TEST_0400', 0, async function (done) {
console.info(`${TAG} SUB_NOTIFICATION_ANS_MANAGER_CANCEL_TEST_0400 START`)
let id = 1
await notificationManager.cancel(id, undefined).then(() => {
console.info(`${TAG} cancel Promise success`)
expect(false).assertTrue()
done()
}).catch((err) => {
console.info(`${TAG} cancel Promise err: ${err.code}, errMes: ${err.message}`)
expect(true).assertTrue()
done()
})
console.info(`${TAG} SUB_NOTIFICATION_ANS_MANAGER_CANCEL_TEST_0400 END`)
})
/*
* @tc.number : SUB_NOTIFICATION_ANS_MANAGER_CANCEL_TEST_0500
* @tc.name : function cancel(id: number, num: number): Promise<void>
* @tc.desc : Cancels a notification with the specified label and ID
*/
it('SUB_NOTIFICATION_ANS_MANAGER_CANCEL_TEST_0500', 0, async function (done) {
console.info(`${TAG} SUB_NOTIFICATION_ANS_MANAGER_CANCEL_TEST_0500 START`)
let id = 1
let num = 2
await notificationManager.cancel(id, num).then(() => {
console.info(`${TAG} cancel Promise success`)
expect(false).assertTrue()
done()
}).catch((err) => {
console.info(`${TAG} cancel Promise err: ${err.code}, errMes: ${err.message}`)
expect(true).assertTrue()
done()
})
console.info(`${TAG} SUB_NOTIFICATION_ANS_MANAGER_CANCEL_TEST_0500 END`)
})
/*
* @tc.number : SUB_NOTIFICATION_ANS_MANAGER_CANCEL_TEST_0600
* @tc.name : function cancel(id: number, label: string, undefined): Promise<void>
* @tc.desc : Cancels a notification with the specified label and ID
*/
it('SUB_NOTIFICATION_ANS_MANAGER_CANCEL_TEST_0600', 0, async function (done) {
console.info(`${TAG} SUB_NOTIFICATION_ANS_MANAGER_CANCEL_TEST_0600 START`)
let id = 1
let label = "label"
await notificationManager.cancel(id, label, undefined).then(() => {
console.info(`${TAG} cancel Promise success`)
expect(false).assertTrue()
done()
}).catch((err) => {
console.info(`${TAG} cancel Promise err: ${err.code}, errMes: ${err.message}`)
expect(true).assertTrue()
done()
})
console.info(`${TAG} SUB_NOTIFICATION_ANS_MANAGER_CANCEL_TEST_0600 END`)
})
/*
* @tc.number : SUB_NOTIFICATION_ANS_MANAGER_CANCELAll_TEST_0100
* @tc.name : function cancelAll(callback: AsyncCallback<void>): void
......@@ -148,6 +210,25 @@ export default function ActsNotificationManagerPublishTest() {
console.info(`${TAG} SUB_NOTIFICATION_ANS_MANAGER_CANCELAll_TEST_0200 END`)
})
/*
* @tc.number : SUB_NOTIFICATION_ANS_MANAGER_CANCELAll_TEST_0300
* @tc.name : function cancelAll(undefined): Promise<void>
* @tc.desc : Cancels all notifications of the current application
*/
it('SUB_NOTIFICATION_ANS_MANAGER_CANCELAll_TEST_0300', 0, async function (done) {
console.info(`${TAG} SUB_NOTIFICATION_ANS_MANAGER_CANCELAll_TEST_0300 START`)
await notificationManager.cancelAll(undefined).then(() => {
console.info(`${TAG} cancelAll Promise success`)
expect(true).assertTrue()
done()
}).catch((err) => {
console.info(`${TAG} cancelAll Promise err: ${err.code}, errMes: ${err.message}`)
expect(false).assertTrue()
done()
})
console.info(`${TAG} SUB_NOTIFICATION_ANS_MANAGER_CANCELAll_TEST_0300 END`)
})
/*
* @tc.number : SUB_NOTIFICATION_ANS_MANAGER_CANCEL_GROUP_TEST_0100
* @tc.name : function cancelGroup(groupName: string, callback: AsyncCallback<void>): void
......@@ -196,6 +277,46 @@ export default function ActsNotificationManagerPublishTest() {
console.info(`${TAG} SUB_NOTIFICATION_ANS_MANAGER_CANCEL_GROUP_TEST_0200 END`)
})
/*
* @tc.number : SUB_NOTIFICATION_ANS_MANAGER_CANCEL_GROUP_TEST_0300
* @tc.name : function cancelGroup(num: number): Promise<void>
* @tc.desc : Cancel the notification of a specified group for this application
*/
it('SUB_NOTIFICATION_ANS_MANAGER_CANCEL_GROUP_TEST_0300', 0, async function (done) {
console.info(`${TAG} SUB_NOTIFICATION_ANS_MANAGER_CANCEL_GROUP_TEST_0300 START`)
let num = 1
await notificationManager.cancelGroup(num).then(() => {
console.info(`${TAG} cancelGroup Promise success`)
expect(true).assertTrue()
done()
}).catch((err) => {
console.info(`${TAG} cancelGroup Promise err: ${err.code}, errMes: ${err.message}`)
expect(false).assertTrue()
done()
})
console.info(`${TAG} SUB_NOTIFICATION_ANS_MANAGER_CANCEL_GROUP_TEST_0300 END`)
})
/*
* @tc.number : SUB_NOTIFICATION_ANS_MANAGER_CANCEL_GROUP_TEST_0400
* @tc.name : function cancelGroup(groupName: string, undefined): Promise<void>
* @tc.desc : Cancel the notification of a specified group for this application
*/
it('SUB_NOTIFICATION_ANS_MANAGER_CANCEL_GROUP_TEST_0400', 0, async function (done) {
console.info(`${TAG} SUB_NOTIFICATION_ANS_MANAGER_CANCEL_GROUP_TEST_0400 START`)
let groupName = "groupName"
await notificationManager.cancelGroup(groupName, undefined).then(() => {
console.info(`${TAG} cancelGroup Promise success`)
expect(true).assertTrue()
done()
}).catch((err) => {
console.info(`${TAG} cancelGroup Promise err: ${err.code}, errMes: ${err.message}`)
expect(false).assertTrue()
done()
})
console.info(`${TAG} SUB_NOTIFICATION_ANS_MANAGER_CANCEL_GROUP_TEST_0400 END`)
})
/*
* @tc.number : SUB_NOTIFICATION_ANS_MANAGER_REQUEST_ENABLE_TEST_0100
* @tc.name : function requestEnableNotification(callback: AsyncCallback<void>): void
......@@ -242,6 +363,25 @@ export default function ActsNotificationManagerPublishTest() {
console.info(`${TAG} SUB_NOTIFICATION_ANS_MANAGER_REQUEST_ENABLE_TEST_0200 END`)
})
/*
* @tc.number : SUB_NOTIFICATION_ANS_MANAGER_REQUEST_ENABLE_TEST_0300
* @tc.name : function requestEnableNotification(undefined): Promise<void>
* @tc.desc : OperationType.UNKNOWN_TYPE & WantAgentFlags.ONE_TIME_FLAG
*/
it('SUB_NOTIFICATION_ANS_MANAGER_REQUEST_ENABLE_TEST_0300', 0, async function (done) {
console.info(`${TAG} SUB_NOTIFICATION_ANS_MANAGER_REQUEST_ENABLE_TEST_0300 START`)
await notificationManager.requestEnableNotification(undefined).then(() => {
console.info(`${TAG} requestEnableNotification Promise success`)
expect(true).assertTrue()
done()
}).catch((err) => {
console.info(`${TAG} requestEnableNotification Promise err: ${err.code}, errMes: ${err.message}`)
expect(false).assertTrue()
done()
})
console.info(`${TAG} SUB_NOTIFICATION_ANS_MANAGER_REQUEST_ENABLE_TEST_0300 END`)
})
/*
* @tc.number : SUB_NOTIFICATION_ANS_MANAGER_COUNT_TEST_0100
* @tc.name : function getActiveNotificationCount(callback: AsyncCallback<number>): void
......@@ -334,6 +474,43 @@ export default function ActsNotificationManagerPublishTest() {
console.info(`${TAG} SUB_NOTIFICATION_ANS_MANAGER_COUNT_TEST_0400 END`)
})
/*
* @tc.number : SUB_NOTIFICATION_ANS_MANAGER_COUNT_TEST_0500
* @tc.name : function getActiveNotificationCount(undefined): Promise<number>
* @tc.desc : Obtains the number of all active notifications
*/
it('SUB_NOTIFICATION_ANS_MANAGER_COUNT_TEST_0500', 0, async function (done) {
console.info(`${TAG} SUB_NOTIFICATION_ANS_MANAGER_COUNT_TEST_0500 START`)
await notificationManager.getActiveNotificationCount(undefined).then((data) => {
console.info(`${TAG} getActiveNotificationCount Promise success :${JSON.stringify(data)}`)
expect(true).assertTrue()
done()
}).catch((err) => {
console.info(`${TAG} getActiveNotificationCount Promise err: ${err.code}, errMes: ${err.message}`)
expect(false).assertTrue()
done()
})
console.info(`${TAG} SUB_NOTIFICATION_ANS_MANAGER_COUNT_TEST_0500 END`)
})
/*
* @tc.number : SUB_NOTIFICATION_ANS_MANAGER_COUNT_TEST_0600
* @tc.name : function getActiveNotifications(undefined): Promise<Array<NotificationRequest>>
* @tc.desc : Obtains an array of active notifications
*/
it('SUB_NOTIFICATION_ANS_MANAGER_COUNT_TEST_0600', 0, async function (done) {
console.info(`${TAG} SUB_NOTIFICATION_ANS_MANAGER_COUNT_TEST_0600 START`)
await notificationManager.getActiveNotifications(undefined).then((data) => {
console.info(`${TAG} getActiveNotifications Promise success :${JSON.stringify(data)}`)
expect(true).assertTrue()
done()
}).catch((err) => {
console.info(`${TAG} getActiveNotifications Promise err: ${err.code}, errMes: ${err.message}`)
expect(false).assertTrue()
done()
})
console.info(`${TAG} SUB_NOTIFICATION_ANS_MANAGER_COUNT_TEST_0600 END`)
})
/*
* @tc.number : SUB_NOTIFICATION_ANS_MANAGER_SUPPORT_TEST_0100
......@@ -383,6 +560,46 @@ export default function ActsNotificationManagerPublishTest() {
console.info(`${TAG} SUB_NOTIFICATION_ANS_MANAGER_SUPPORT_TEST_0200 END`)
})
/*
* @tc.number : SUB_NOTIFICATION_ANS_MANAGER_SUPPORT_TEST_0300
* @tc.name : function isSupportTemplate(num: number): Promise<boolean>
* @tc.desc : Obtains whether the template is supported by the system
*/
it('SUB_NOTIFICATION_ANS_MANAGER_SUPPORT_TEST_0300', 0, async function (done) {
console.info(`${TAG} SUB_NOTIFICATION_ANS_MANAGER_SUPPORT_TEST_0300 START`)
let num = 1
await notificationManager.isSupportTemplate(num).then((data) => {
console.info(`${TAG} isSupportTemplate Promise success :${JSON.stringify(data)}`)
expect(true).assertTrue()
done()
}).catch((err) => {
console.info(`${TAG} isSupportTemplate Promise err: ${err.code}, errMes: ${err.message}`)
expect(false).assertTrue()
done()
})
console.info(`${TAG} SUB_NOTIFICATION_ANS_MANAGER_SUPPORT_TEST_0300 END`)
})
/*
* @tc.number : SUB_NOTIFICATION_ANS_MANAGER_SUPPORT_TEST_0400
* @tc.name : function isSupportTemplate(templateName: string, undefined): Promise<boolean>
* @tc.desc : Obtains whether the template is supported by the system
*/
it('SUB_NOTIFICATION_ANS_MANAGER_SUPPORT_TEST_0400', 0, async function (done) {
console.info(`${TAG} SUB_NOTIFICATION_ANS_MANAGER_SUPPORT_TEST_0400 START`)
let templateName = 'test_templateName'
await notificationManager.isSupportTemplate(templateName, undefined).then((data) => {
console.info(`${TAG} isSupportTemplate Promise success :${JSON.stringify(data)}`)
expect(true).assertTrue()
done()
}).catch((err) => {
console.info(`${TAG} isSupportTemplate Promise err: ${err.code}, errMes: ${err.message}`)
expect(false).assertTrue()
done()
})
console.info(`${TAG} SUB_NOTIFICATION_ANS_MANAGER_SUPPORT_TEST_0400 END`)
})
console.info(TAG + 'SUB_NOTIFICATION_ANS_MANAGER_Publish_TEST END')
})
......
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
......@@ -503,6 +503,51 @@ export default function ActsNotificationPublishTest() {
console.info(`${TAG} SUB_NOTIFICATION_ANS_PUBLISH_TEST_1200 END`)
})
/*
* @tc.number : SUB_NOTIFICATION_ANS_PUBLISH_TEST_01300
* @tc.name : function publish(request: NotificationRequest, label: string): Promise<void>
* @tc.desc : Publishes a notification
*/
it('SUB_NOTIFICATION_ANS_PUBLISH_TEST_01300', 0, async function (done) {
console.info(`${TAG} SUB_NOTIFICATION_ANS_PUBLISH_TEST_01300 START`)
let label = "label"
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, label).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_01300 END`)
})
/*
* @tc.number : SUB_NOTIFICATION_ANS_CANCEL_TEST_0100
* @tc.name : function cancel(id: number, label: string, callback: AsyncCallback<void>): void
......@@ -569,6 +614,92 @@ export default function ActsNotificationPublishTest() {
console.info(`${TAG} SUB_NOTIFICATION_ANS_CANCEL_TEST_0300 END`)
})
/*
* @tc.number : SUB_NOTIFICATION_ANS_CANCEL_TEST_0400
* @tc.name : function cancel(id: number, label?: string, str: string): Promise<void>;
* @tc.desc : Cancels a notification with the specified label and ID
*/
it('SUB_NOTIFICATION_ANS_CANCEL_TEST_0400', 0, async function (done) {
console.info(`${TAG} SUB_NOTIFICATION_ANS_CANCEL_TEST_0400 START`)
let id = 1
let label = "label"
let str = "str"
await notification.cancel(id, label, str).then(() => {
console.info(`${TAG} cancel Promise success`)
expect(false).assertTrue()
done()
}).catch((err) => {
console.info(`${TAG} cancel Promise err: ${err.code}`)
expect(true).assertTrue()
done()
})
console.info(`${TAG} SUB_NOTIFICATION_ANS_CANCEL_TEST_0400 END`)
})
/*
* @tc.number : SUB_NOTIFICATION_ANS_CANCEL_TEST_0500
* @tc.name : function cancel(id: number, label: number): Promise<void>;
* @tc.desc : Cancels a notification with the specified label and ID
*/
it('SUB_NOTIFICATION_ANS_CANCEL_TEST_0500', 0, async function (done) {
console.info(`${TAG} SUB_NOTIFICATION_ANS_CANCEL_TEST_0500 START`)
let id = 1
let label = 2
await notification.cancel(id, label).then(() => {
console.info(`${TAG} cancel Promise success`)
expect(false).assertTrue()
done()
}).catch((err) => {
console.info(`${TAG} cancel Promise err: ${err.code}`)
expect(true).assertTrue()
done()
})
console.info(`${TAG} SUB_NOTIFICATION_ANS_CANCEL_TEST_0500 END`)
})
/*
* @tc.number : SUB_NOTIFICATION_ANS_CANCEL_TEST_0600
* @tc.name : function cancel(id: number, label: number, callback: AsyncCallback<void>): void
* @tc.desc : Cancels a notification with the specified label and ID
*/
it('SUB_NOTIFICATION_ANS_CANCEL_TEST_0600', 0, async function (done) {
console.info(`${TAG} SUB_NOTIFICATION_ANS_CANCEL_TEST_0600 START`)
let id = 1
let label = 2
await notification.cancel(id, label, (err) => {
if (err.code) {
console.info(`${TAG} cancel AsyncCallback err: ${err.code}`)
expect(true).assertTrue()
done()
} else {
console.info(`${TAG} cancel AsyncCallback success`)
expect(false).assertTrue()
done()
}
})
console.info(`${TAG} SUB_NOTIFICATION_ANS_CANCEL_TEST_0600 END`)
})
/*
* @tc.number : SUB_NOTIFICATION_ANS_CANCEL_TEST_0700
* @tc.name : function cancel(id: number, undefined): Promise<void>;
* @tc.desc : Cancels a notification with the ID
*/
it('SUB_NOTIFICATION_ANS_CANCEL_TEST_0700', 0, async function (done) {
console.info(`${TAG} SUB_NOTIFICATION_ANS_CANCEL_TEST_0700 START`)
let id = 1
await notification.cancel(id, undefined).then(() => {
console.info(`${TAG} cancel Promise success`)
expect(false).assertTrue()
done()
}).catch((err) => {
console.info(`${TAG} cancel Promise err: ${err.code}`)
expect(true).assertTrue()
done()
})
console.info(`${TAG} SUB_NOTIFICATION_ANS_CANCEL_TEST_0700 END`)
})
/*
* @tc.number : SUB_NOTIFICATION_ANS_CANCELAll_TEST_0100
* @tc.name : function cancelAll(callback: AsyncCallback<void>): void
......@@ -609,6 +740,25 @@ export default function ActsNotificationPublishTest() {
console.info(`${TAG} SUB_NOTIFICATION_ANS_CANCELAll_TEST_0200 END`)
})
/*
* @tc.number : SUB_NOTIFICATION_ANS_CANCELAll_TEST_0300
* @tc.name : function cancelAll(undefined): Promise<void>
* @tc.desc : Cancels all notifications of the current application
*/
it('SUB_NOTIFICATION_ANS_CANCELAll_TEST_0300', 0, async function (done) {
console.info(`${TAG} SUB_NOTIFICATION_ANS_CANCELAll_TEST_0300 START`)
await notification.cancelAll(undefined).then(() => {
console.info(`${TAG} cancelAll Promise success`)
expect(true).assertTrue()
done()
}).catch((err) => {
console.info(`${TAG} cancelAll Promise err: ${err.code}`)
expect(false).assertTrue()
done()
})
console.info(`${TAG} SUB_NOTIFICATION_ANS_CANCELAll_TEST_0300 END`)
})
/*
* @tc.number : SUB_NOTIFICATION_ANS_CANCEL_GROUP_TEST_0100
* @tc.name : function cancelGroup(groupName: string, callback: AsyncCallback<void>): void
......@@ -651,6 +801,45 @@ export default function ActsNotificationPublishTest() {
console.info(`${TAG} SUB_NOTIFICATION_ANS_CANCEL_GROUP_TEST_0200 END`)
})
/*
* @tc.number : SUB_NOTIFICATION_ANS_CANCEL_GROUP_TEST_0300
* @tc.name : function cancelGroup(number): Promise<void>
* @tc.desc : Cancel the notification of a specified group for this application
*/
it('SUB_NOTIFICATION_ANS_CANCEL_GROUP_TEST_0300', 0, async function (done) {
console.info(`${TAG} SUB_NOTIFICATION_ANS_CANCEL_GROUP_TEST_0300 START`)
await notification.cancelGroup(2).then(() => {
console.info(`${TAG} cancelGroup Promise success`)
expect(true).assertTrue()
done()
}).catch((err) => {
console.info(`${TAG} cancelGroup Promise err: ${err.code}`)
expect(false).assertTrue()
done()
})
console.info(`${TAG} SUB_NOTIFICATION_ANS_CANCEL_GROUP_TEST_0300 END`)
})
/*
* @tc.number : SUB_NOTIFICATION_ANS_CANCEL_GROUP_TEST_0400
* @tc.name : function cancelGroup(groupName: string, undefined): Promise<void>
* @tc.desc : Cancel the notification of a specified group for this application
*/
it('SUB_NOTIFICATION_ANS_CANCEL_GROUP_TEST_0400', 0, async function (done) {
console.info(`${TAG} SUB_NOTIFICATION_ANS_CANCEL_GROUP_TEST_0400 START`)
let groupName = "groupName"
await notification.cancelGroup(groupName, undefined).then(() => {
console.info(`${TAG} cancelGroup Promise success`)
expect(true).assertTrue()
done()
}).catch((err) => {
console.info(`${TAG} cancelGroup Promise err: ${err.code}`)
expect(false).assertTrue()
done()
})
console.info(`${TAG} SUB_NOTIFICATION_ANS_CANCEL_GROUP_TEST_0400 END`)
})
/*
* @tc.number : SUB_NOTIFICATION_ANS_REQUEST_ENABLE_TEST_0100
* @tc.name : function requestEnableNotification(callback: AsyncCallback<void>): void
......@@ -691,6 +880,25 @@ export default function ActsNotificationPublishTest() {
console.info(`${TAG} SUB_NOTIFICATION_ANS_REQUEST_ENABLE_TEST_0200 END`)
})
/*
* @tc.number : SUB_NOTIFICATION_ANS_REQUEST_ENABLE_TEST_0300
* @tc.name : function requestEnableNotification(undefined): Promise<void>
* @tc.desc : OperationType.UNKNOWN_TYPE & WantAgentFlags.ONE_TIME_FLAG
*/
it('SUB_NOTIFICATION_ANS_REQUEST_ENABLE_TEST_0300', 0, async function (done) {
console.info(`${TAG} SUB_NOTIFICATION_ANS_REQUEST_ENABLE_TEST_0300 START`)
await notification.requestEnableNotification(undefined).then(() => {
console.info(`${TAG} requestEnableNotification Promise success`)
expect(true).assertTrue()
done()
}).catch((err) => {
console.info(`${TAG} requestEnableNotification Promise err: ${err.code}`)
expect(false).assertTrue()
done()
})
console.info(`${TAG} SUB_NOTIFICATION_ANS_REQUEST_ENABLE_TEST_0300 END`)
})
/*
* @tc.number : SUB_NOTIFICATION_ANS_COUNT_TEST_0100
* @tc.name : function getActiveNotificationCount(callback: AsyncCallback<number>): void
......@@ -771,6 +979,43 @@ export default function ActsNotificationPublishTest() {
console.info(`${TAG} SUB_NOTIFICATION_ANS_COUNT_TEST_0400 END`)
})
/*
* @tc.number : SUB_NOTIFICATION_ANS_COUNT_TEST_0500
* @tc.name : function getActiveNotificationCount(undefined): Promise<number>
* @tc.desc : Obtains the number of all active notifications
*/
it('SUB_NOTIFICATION_ANS_COUNT_TEST_0500', 0, async function (done) {
console.info(`${TAG} SUB_NOTIFICATION_ANS_COUNT_TEST_0500 START`)
await notification.getActiveNotificationCount(undefined).then((data) => {
console.info(`${TAG} getActiveNotificationCount Promise success :${JSON.stringify(data)}`)
expect(true).assertTrue()
done()
}).catch((err) => {
console.info(`${TAG} getActiveNotificationCount Promise err: ${err.code}`)
expect(false).assertTrue()
done()
})
console.info(`${TAG} SUB_NOTIFICATION_ANS_COUNT_TEST_0500 END`)
})
/*
* @tc.number : SUB_NOTIFICATION_ANS_COUNT_TEST_0600
* @tc.name : function getActiveNotifications(undefined): Promise<Array<NotificationRequest>>
* @tc.desc : Obtains an array of active notifications
*/
it('SUB_NOTIFICATION_ANS_COUNT_TEST_0600', 0, async function (done) {
console.info(`${TAG} SUB_NOTIFICATION_ANS_COUNT_TEST_0600 START`)
await notification.getActiveNotifications(undefined).then((data) => {
console.info(`${TAG} getActiveNotifications Promise success :${JSON.stringify(data)}`)
expect(true).assertTrue()
done()
}).catch((err) => {
console.info(`${TAG} getActiveNotifications Promise err: ${err.code}`)
expect(false).assertTrue()
done()
})
console.info(`${TAG} SUB_NOTIFICATION_ANS_COUNT_TEST_0600 END`)
})
/*
* @tc.number : SUB_NOTIFICATION_ANS_SUPPORT_TEST_0100
......@@ -814,7 +1059,46 @@ export default function ActsNotificationPublishTest() {
console.info(`${TAG} SUB_NOTIFICATION_ANS_SUPPORT_TEST_0200 END`)
})
console.info(TAG + 'SUB_NOTIFICATION_ANS_Publish_TEST END')
/*
* @tc.number : SUB_NOTIFICATION_ANS_SUPPORT_TEST_0300
* @tc.name : function isSupportTemplate(templateName: number): Promise<boolean>
* @tc.desc : Obtains whether the template is supported by the system
*/
it('SUB_NOTIFICATION_ANS_SUPPORT_TEST_0300', 0, async function (done) {
console.info(`${TAG} SUB_NOTIFICATION_ANS_SUPPORT_TEST_0300 START`)
let templateName = 2
await notification.isSupportTemplate(templateName).then((data) => {
console.info(`${TAG} isSupportTemplate Promise success :${JSON.stringify(data)}`)
expect(true).assertTrue()
done()
}).catch((err) => {
console.info(`${TAG} isSupportTemplate Promise err: ${err.code}`)
expect(false).assertTrue()
done()
})
console.info(`${TAG} SUB_NOTIFICATION_ANS_SUPPORT_TEST_0300 END`)
})
/*
* @tc.number : SUB_NOTIFICATION_ANS_SUPPORT_TEST_0400
* @tc.name : function isSupportTemplate(templateName: string, undefined): Promise<boolean>
* @tc.desc : Obtains whether the template is supported by the system
*/
it('SUB_NOTIFICATION_ANS_SUPPORT_TEST_0400', 0, async function (done) {
console.info(`${TAG} SUB_NOTIFICATION_ANS_SUPPORT_TEST_0400 START`)
let templateName = 'test_templateName'
await notification.isSupportTemplate(templateName, undefined).then((data) => {
console.info(`${TAG} isSupportTemplate Promise success :${JSON.stringify(data)}`)
expect(true).assertTrue()
done()
}).catch((err) => {
console.info(`${TAG} isSupportTemplate Promise err: ${err.code}`)
expect(false).assertTrue()
done()
})
console.info(`${TAG} SUB_NOTIFICATION_ANS_SUPPORT_TEST_0400 END`)
})
console.info(TAG + 'SUB_NOTIFICATION_ANS_Publish_TEST END')
})
}
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
......@@ -1374,6 +1374,101 @@ export default function ActsNotificationSlotTest() {
console.info(TAG + 'SUB_NOTIFICATION_ANS_SLOT_TEST_4800 END')
})
/*
* @tc.number : SUB_NOTIFICATION_ANS_SLOT_TEST_4900
* @tc.name : getSlot(SlotType: SlotType, undefined): Promise<NotificationSlot>
* @tc.desc : Get the OTHER_TYPES type slot without add
*/
it('SUB_NOTIFICATION_ANS_SLOT_TEST_4900', 0, async function (done) {
console.info(TAG + 'SUB_NOTIFICATION_ANS_SLOT_TEST_4900 START')
await notification.getSlot(notification.SlotType.OTHER_TYPES, undefined).then((NotificationSlot) => {
console.info(`${TAG} getSlot_49 Promise success: ${NotificationSlot}`)
expect(true).assertTrue()
done()
}).catch((err) => {
console.info(`${TAG} getSlot_49 Promise err: ${err.code}`)
expect(false).assertTrue()
done()
})
console.info(TAG + 'SUB_NOTIFICATION_ANS_SLOT_TEST_4900 END')
})
/*
* @tc.number : SUB_NOTIFICATION_ANS_SLOT_TEST_5000
* @tc.name : addSlot(type: SlotType, undefined): Promise<void>
* @tc.desc : NotificationSlot of an unknown type
*/
it('SUB_NOTIFICATION_ANS_SLOT_TEST_5000', 0, async function (done) {
console.info(TAG + 'SUB_NOTIFICATION_ANS_SLOT_TEST_5000 START')
await notification.addSlot(notification.SlotType.UNKNOWN_TYPE, undefined).then(() => {
console.info(`${TAG} addSlot_50 Promise success`)
expect(true).assertTrue()
done()
}).catch((err) => {
console.info(`${TAG} addSlot_50 Promise err: ${err.code}`)
expect(false).assertTrue()
done()
})
console.info(TAG + 'SUB_NOTIFICATION_ANS_SLOT_TEST_5000 END')
})
/*
* @tc.number : SUB_NOTIFICATION_ANS_SLOT_TEST_5100
* @tc.name : getSlots(undefined): Promise<Array<NotificationSlot>>
* @tc.desc : Get all NotificationSlot without add
*/
it('SUB_NOTIFICATION_ANS_SLOT_TEST_5100', 0, async function (done) {
console.info(TAG + 'SUB_NOTIFICATION_ANS_SLOT_TEST_5100 START')
await notification.getSlots(undefined).then((NotificationSlot) => {
console.info(`${TAG} getSlots_51 Promise success: ${NotificationSlot}`)
expect(true).assertTrue()
done()
}).catch((err) => {
console.info(`${TAG} getSlots_51 Promise err: ${err.code}`)
expect(false).assertTrue()
done()
})
console.info(TAG + 'SUB_NOTIFICATION_ANS_SLOT_TEST_5100 END')
})
/*
* @tc.number : SUB_NOTIFICATION_ANS_SLOT_TEST_5200
* @tc.name : removeSlot(SlotType: SlotType, undefined): Promise<void>
* @tc.desc : Remove the UNKNOWN_TYPE type slot without add
*/
it('SUB_NOTIFICATION_ANS_SLOT_TEST_5200', 0, async function (done) {
console.info(TAG + 'SUB_NOTIFICATION_ANS_SLOT_TEST_5200 START')
await notification.removeSlot(notification.SlotType.UNKNOWN_TYPE, undefined).then(() => {
console.info(`${TAG} removeSlot_52 success`)
expect(true).assertTrue()
done()
}).catch((err) => {
console.info(`${TAG} removeSlot_52 err: ${err.code}`)
expect(false).assertTrue()
done()
})
console.info(TAG + 'SUB_NOTIFICATION_ANS_SLOT_TEST_5200 END')
})
/*
* @tc.number : SUB_NOTIFICATION_ANS_SLOT_TEST_5300
* @tc.name : removeAllSlots(undefined): Promise<void>
* @tc.desc : Removes all NotificationSlot
*/
it('SUB_NOTIFICATION_ANS_SLOT_TEST_5300', 0, async function (done) {
console.info(TAG + 'SUB_NOTIFICATION_ANS_SLOT_TEST_5300 START')
await notification.removeAllSlots(undefined).then(() => {
console.info(`${TAG} removeAllSlots_53 Promise success`)
expect(true).assertTrue()
done()
}).catch((err) => {
console.info(`${TAG} removeAllSlots_53 Promise err: ${err.code}`)
expect(false).assertTrue()
done()
})
console.info(TAG + 'SUB_NOTIFICATION_ANS_SLOT_TEST_5300 END')
})
/*
* @tc.number : SUB_NOTIFICATION_SLOT_ENUM_TEST_0100
* @tc.name : Describes NotificationSlot types
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册