From ad960e569ea57f476a69bb2538ca67161aa6a098 Mon Sep 17 00:00:00 2001 From: zhijianwen Date: Fri, 4 Nov 2022 12:13:50 +0800 Subject: [PATCH] --ActsNotificationManagerRequestTest-- Signed-off-by: zhijianwen --- .../ActsNotificationManagerRequestTest.js | 94 +++++++++++++++++++ .../js/test/ActsNotificationRequestTest.js | 1 - .../src/main/js/test/List.test.js | 7 +- 3 files changed, 99 insertions(+), 3 deletions(-) create mode 100644 notification/ans_standard/actsNotificationRequestTest/src/main/js/test/ActsNotificationManagerRequestTest.js diff --git a/notification/ans_standard/actsNotificationRequestTest/src/main/js/test/ActsNotificationManagerRequestTest.js b/notification/ans_standard/actsNotificationRequestTest/src/main/js/test/ActsNotificationManagerRequestTest.js new file mode 100644 index 000000000..9e4988f1d --- /dev/null +++ b/notification/ans_standard/actsNotificationRequestTest/src/main/js/test/ActsNotificationManagerRequestTest.js @@ -0,0 +1,94 @@ +/* +* Copyright (c) 2022 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 +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import notificationManager from '@ohos.notificationManager' +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' + +export default function ActsNotificationManagerRequestTest() { + describe('SUB_NOTIFICATION_ANS_MANAGER_REQUEST_TEST', function () { + let TAG = 'SUB_NOTIFICATION_ANS_MANAGER_REQUEST_TEST ===>' + console.info(TAG + 'SUB_NOTIFICATION_ANS_MANAGER_REQUEST_TEST START') + + /* + * @tc.number : SUB_NOTIFICATION_ANS_MANAGER_REQUEST_TEST_0100 + * @tc.name : function publish(request: NotificationRequest, callback: AsyncCallback): void + * @tc.desc : publish a notification after requestEnableNotification + */ + it('SUB_NOTIFICATION_ANS_MANAGER_REQUEST_TEST_0100', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_MANAGER_REQUEST_TEST_0100 START`) + let notificationRequest = { + id: 1, + content: { + contentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + } + } + } + try { + notificationManager.publish(notificationRequest, (err, data) => { + if (err) { + console.info(`${TAG} notification publish AsyncCallback err: ${err.code}, errMes: ${err.message}`) + expect(false).assertTrue() + done() + } else { + console.log(`${TAG} notification publish AsyncCallback success: ${data}`) + expect(true).assertTrue() + done() + } + }) + } catch (err) { + console.info(`${TAG} notification publish AsyncCallback errCode: ${err.code}, errMes: ${err.message}`) + expect(false).assertTrue() + done() + } + console.info(`${TAG} SUB_NOTIFICATION_ANS_MANAGER_REQUEST_TEST_0100 END`) + }) + + /* + * @tc.number : SUB_NOTIFICATION_ANS_MANAGER_REQUEST_TEST_0200 + * @tc.name : function publish(request: NotificationRequest): Promise + * @tc.desc : publish a notification after requestEnableNotification + */ + it('SUB_NOTIFICATION_ANS_MANAGER_REQUEST_TEST_0200', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_MANAGER_REQUEST_TEST_0200 START`) + let notificationRequest = { + id: 1, + content: { + contentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + } + } + } + notificationManager.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}, errMes: ${err.message}`) + expect(false).assertTrue() + done() + }) + console.info(`${TAG} SUB_NOTIFICATION_ANS_MANAGER_REQUEST_TEST_0200 END`) + }) + console.info(TAG + 'SUB_NOTIFICATION_ANS_MANAGER_REQUEST_TEST END') + }) + +} diff --git a/notification/ans_standard/actsNotificationRequestTest/src/main/js/test/ActsNotificationRequestTest.js b/notification/ans_standard/actsNotificationRequestTest/src/main/js/test/ActsNotificationRequestTest.js index b3b0089ac..9517588b6 100644 --- a/notification/ans_standard/actsNotificationRequestTest/src/main/js/test/ActsNotificationRequestTest.js +++ b/notification/ans_standard/actsNotificationRequestTest/src/main/js/test/ActsNotificationRequestTest.js @@ -1,4 +1,3 @@ -// @ts-nocheck /* * Copyright (c) 2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/notification/ans_standard/actsNotificationRequestTest/src/main/js/test/List.test.js b/notification/ans_standard/actsNotificationRequestTest/src/main/js/test/List.test.js index 89bcb1b68..551a66e95 100644 --- a/notification/ans_standard/actsNotificationRequestTest/src/main/js/test/List.test.js +++ b/notification/ans_standard/actsNotificationRequestTest/src/main/js/test/List.test.js @@ -13,6 +13,9 @@ * limitations under the License. */ import ActsNotificationRequestTest from './ActsNotificationRequestTest.js' +import ActsNotificationManagerRequestTest from './ActsNotificationManagerRequestTest.js' + export default function testsuite() { - ActsNotificationRequestTest() -} + ActsNotificationRequestTest() + ActsNotificationManagerRequestTest() +} \ No newline at end of file -- GitLab