diff --git a/notification/ans_standard/BUILD.gn b/notification/ans_standard/BUILD.gn index 894b5bc2ab0d2073a9b48d36836ff997a9823b0f..604db8d45a8bf5cd6fc1b16d5505d37dccd079be 100644 --- a/notification/ans_standard/BUILD.gn +++ b/notification/ans_standard/BUILD.gn @@ -24,6 +24,7 @@ group("ans_standard") { "actsNotificationSecondaryDirectoryTest:ActsNotificationSecondaryDirectoryTest", "actsNotificationShowTest:ActsNotificationShowTest", "actsNotificationSlotTest:ActsNotificationSlotTest", + "actsNotificationSystemAPITest:ActsNotificationSystemAPITest", "actsNotificationWantAgentTest:ActsNotificationWantAgentTest", ] } diff --git a/notification/ans_standard/actsNotificationSystemAPITest/AppScope/app.json b/notification/ans_standard/actsNotificationSystemAPITest/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..7d34d5a5d488607637aabf8a4496f67d71eccd3b --- /dev/null +++ b/notification/ans_standard/actsNotificationSystemAPITest/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app": { + "bundleName": "com.example.systemAPI", + "vendor": "huawei", + "versionCode": 1000000, + "versionName": "1.0.0", + "debug": false, + "icon": "$media:icon", + "label": "$string:app_name", + "description": "$string:description_application", + "distributedNotificationEnabled": true, + "keepAlive": true, + "singleUser": true, + "minAPIVersion": 9, + "targetAPIVersion": 9, + "car": { + "apiCompatibleVersion": 9, + "singleUser": false + } + } +} diff --git a/notification/ans_standard/actsNotificationSystemAPITest/AppScope/resources/base/element/string.json b/notification/ans_standard/actsNotificationSystemAPITest/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..0d1f12ea9692aa14d5e6e140d74baa9b04c25352 --- /dev/null +++ b/notification/ans_standard/actsNotificationSystemAPITest/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string":[ + { + "name":"app_name", + "value":"LifecycleTest" + } + ] +} \ No newline at end of file diff --git a/notification/ans_standard/actsNotificationSystemAPITest/AppScope/resources/base/media/app_icon.png b/notification/ans_standard/actsNotificationSystemAPITest/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/notification/ans_standard/actsNotificationSystemAPITest/AppScope/resources/base/media/app_icon.png differ diff --git a/notification/ans_standard/actsNotificationSystemAPITest/BUILD.gn b/notification/ans_standard/actsNotificationSystemAPITest/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..c5bd466e68c171609fbf01eb708443780af7166d --- /dev/null +++ b/notification/ans_standard/actsNotificationSystemAPITest/BUILD.gn @@ -0,0 +1,43 @@ +# Copyright (c) 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 +# +# 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ActsNotificationSystemAPITest") { + hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" + deps = [ + ":systemapitest_js_assets", + ":systemapitest_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsNotificationSystemAPITest" + subsystem_name = "ability" + part_name = "ability_runtime" +} + +ohos_app_scope("systemapitest_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("systemapitest_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("systemapitest_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":systemapitest_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/notification/ans_standard/actsNotificationSystemAPITest/Test.json b/notification/ans_standard/actsNotificationSystemAPITest/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..0153e2529f7f5557a5ce38a849da6bfa9ead7fc4 --- /dev/null +++ b/notification/ans_standard/actsNotificationSystemAPITest/Test.json @@ -0,0 +1,27 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "180000", + "bundle-name": "com.example.systemAPI", + "module-name": "phone", + "shell-timeout": "600000", + "testcase-timeout": 70000 + }, + "kits": [ + { + "test-file-name": [ + "ActsNotificationSystemAPITest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, + { + "type":"ShellKit", + "run-command":[ + "anm setting -e com.example.systemAPI:0:1" + ], + "cleanup-apps":true + } + ] +} diff --git a/notification/ans_standard/actsNotificationSystemAPITest/entry/src/main/ets/Application/AbilityStage.ts b/notification/ans_standard/actsNotificationSystemAPITest/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..308e590c00c7ce4bc6ad3fedf2af7dd74356dc68 --- /dev/null +++ b/notification/ans_standard/actsNotificationSystemAPITest/entry/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,23 @@ +/* + * Copyright (c) 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 + * + * 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 AbilityStage from "@ohos.app.ability.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("[Demo] MyAbilityStage onCreate") + globalThis.stageContext = this.context; + } +} \ No newline at end of file diff --git a/notification/ans_standard/actsNotificationSystemAPITest/entry/src/main/ets/MainAbility/MainAbility.ts b/notification/ans_standard/actsNotificationSystemAPITest/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..3d394176330a9cc8c42bf2aa3569dd936e15c5ae --- /dev/null +++ b/notification/ans_standard/actsNotificationSystemAPITest/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 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 + * + * 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 Ability from '@ohos.app.ability.UIAbility' + +export default class MainAbility extends Ability { + + onCreate(want, launchParam) { + console.log("[Demo] MainAbility onCreate") + globalThis.abilityWant = want; + globalThis.applicationContext = this.context.getApplicationContext(); + } + + onDestroy() { + console.log("[Demo] MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("[Demo] MainAbility onWindowStageCreate") + globalThis.abilityContext = this.context; + windowStage.setUIContent(this.context, "MainAbility/pages/MainAbility_pages", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("[Demo] MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("[Demo] MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("[Demo] MainAbility onBackground") + } +}; diff --git a/notification/ans_standard/actsNotificationSystemAPITest/entry/src/main/ets/MainAbility/pages/MainAbility_pages.ets b/notification/ans_standard/actsNotificationSystemAPITest/entry/src/main/ets/MainAbility/pages/MainAbility_pages.ets new file mode 100644 index 0000000000000000000000000000000000000000..04e81577e55c00db79128beb6078e787f37b8ef0 --- /dev/null +++ b/notification/ans_standard/actsNotificationSystemAPITest/entry/src/main/ets/MainAbility/pages/MainAbility_pages.ets @@ -0,0 +1,47 @@ +// @ts-nocheck +/* + * Copyright (c) 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 + * + * 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 router from '@ohos.router'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../test/List.test' + +@Entry +@Component +struct Index { + @State message: string = 'MainAbility' + + aboutToAppear() { + console.info("start run testcase!!!!") + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + } + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/notification/ans_standard/actsNotificationSystemAPITest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/notification/ans_standard/actsNotificationSystemAPITest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..f8505da65f160dc5da0b5237da8c169d0236291e --- /dev/null +++ b/notification/ans_standard/actsNotificationSystemAPITest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,78 @@ +/* + * Copyright (c) 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 + * + * 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 TestRunner from '@ohos.application.testRunner' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s it', + '-s level', '-s testType', '-s size', '-s timeout', + '-s dryRun' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams = `${targetParams} ${key} ${parameters[key]}` + } + } + return targetParams.trim() +} + +async function onAbilityCreateCallback() { + console.log("onAbilityCreateCallback"); +} + +async function addAbilityMonitorCallback(err: any) { + console.info("addAbilityMonitorCallback : " + JSON.stringify(err)) +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + console.info("OpenHarmonyTestRunner OnPrepare ") + } + + async onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility' + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a com.example.systemAPI.MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + var debug = abilityDelegatorArguments.parameters["-D"] + if (debug == 'true') + { + cmd += ' -D' + } + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + d.stdResult); + console.info('executeShellCommand : data : ' + d.exitCode); + }) + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/notification/ans_standard/actsNotificationSystemAPITest/entry/src/main/ets/test/ActsNotificationSystemAPITest.test.ets b/notification/ans_standard/actsNotificationSystemAPITest/entry/src/main/ets/test/ActsNotificationSystemAPITest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..59991a8695fffd5891c11987d1fee99bb184a247 --- /dev/null +++ b/notification/ans_standard/actsNotificationSystemAPITest/entry/src/main/ets/test/ActsNotificationSystemAPITest.test.ets @@ -0,0 +1,1005 @@ +/* + * Copyright (c) 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 + * + * 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' +import notificationManager from '@ohos.notificationManager' +import notificationSubscribe from '@ohos.notificationSubscribe'; + +export default function ActsNotificationSystemAPITest() { +describe('SUB_NOTIFICATION_ANS_SYSTEM_API_TEST', function () { + let TAG = 'SUB_NOTIFICATION_ANS_SYSTEM_API_TEST ===>' + console.info(TAG + 'SUB_NOTIFICATION_ANS_SYSTEM_API_TEST START') + + /* + * @tc.number: SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_0100 + * @tc.name: publish + * @tc.desc: test function publish takes userId + */ + it('SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_0100', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_0100 START`); + + let notificationRequest : notificationManager.NotificationRequest = { + id: 1, + content: { + contentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_Publish" + } + } + } + + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_0100 PUBLISH`); + try{ + notificationManager.publish(notificationRequest, 0, (err) => { + if (err) { + console.info(`${TAG} publish AsyncCallback errCode: ${err.code}, errMes: ${err.message}`) + expect(err.code).assertEqual(202); + done() + } else { + console.info(`${TAG} publish AsyncCallback success`) + expect(false).assertTrue() + done() + } + }); + } catch (err) { + console.info(`${TAG} publish AsyncCallback errCode: ${err.code}, errMes: ${err.message}`) + expect(false).assertTrue() + done() + } + + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_0100 END`); + }); + + /* + * @tc.number: SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_0200 + * @tc.name: publishAsBundle + * @tc.desc: test function publishAsBundle + */ + it('SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_0200', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_0200 START`); + + let notificationRequest : notificationManager.NotificationRequest = { + id: 1, + content: { + contentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_Publish" + } + } + } + + notificationManager.publishAsBundle(notificationRequest, "example.bundleName", 0, (err) => { + if (err) { + console.info(`${TAG} publishAsBundle AsyncCallback errCode: ${err.code}, errMes: ${err.message}`) + expect(err.code).assertEqual(202); + done() + } else { + console.info(`${TAG} publishAsBundle AsyncCallback success`) + expect(false).assertTrue() + done() + } + }); + + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_0200 END`); + }); + + /* + * @tc.number: SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_0300 + * @tc.name: cancelAsBundle + * @tc.desc: test function cancelAsBundle + */ + it('SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_0300', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_0300 START`); + + notificationManager.cancelAsBundle(1, "example.bundleName", 0, (err) => { + if (err) { + console.info(`${TAG} cancelAsBundle AsyncCallback errCode: ${err.code}, errMes: ${err.message}`) + expect(err.code).assertEqual(202); + done() + } else { + console.info(`${TAG} cancelAsBundle AsyncCallback success`) + expect(false).assertTrue() + done() + } + }); + + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_0300 END`); + }); + + /* + * @tc.number: SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_0400 + * @tc.name: addSlot + * @tc.desc: test function addSlot + */ + it('SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_0400', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_0400 START`); + + let slot : notificationManager.NotificationSlot = { + type: notificationManager.SlotType.SOCIAL_COMMUNICATION, + level: notificationManager.SlotLevel.LEVEL_HIGH, + desc: 'xts test' + } + notificationManager.addSlot(slot, (err) => { + if (err) { + console.info(`${TAG} addSlot AsyncCallback errCode: ${err.code}, errMes: ${err.message}`) + expect(err.code).assertEqual(202); + done() + } else { + console.info(`${TAG} addSlot AsyncCallback success`) + expect(false).assertTrue() + done() + } + }); + + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_0400 END`); + }); + + /* + * @tc.number: SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_0500 + * @tc.name: setNotificationEnable + * @tc.desc: test function setNotificationEnable + */ + it('SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_0500', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_0500 START`); + + let bundleOpt : notificationManager.BundleOption = { + bundle: "example.bundleName", + uid: 0 + } + notificationManager.setNotificationEnable(bundleOpt, true, (err) => { + if (err) { + console.info(`${TAG} setNotificationEnable AsyncCallback errCode: ${err.code}, errMes: ${err.message}`) + expect(err.code).assertEqual(202); + done() + } else { + console.info(`${TAG} setNotificationEnable AsyncCallback success`) + expect(false).assertTrue() + done() + } + }); + + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_0500 END`); + }); + + /* + * @tc.number: SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_0600 + * @tc.name: isNotificationEnabled + * @tc.desc: test function isNotificationEnabled + */ + it('SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_0600', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_0600 START`); + + let bundleOpt : notificationManager.BundleOption = { + bundle: "example.bundleName", + uid: 0 + } + notificationManager.isNotificationEnabled(bundleOpt, (err, data) => { + if (err) { + console.info(`${TAG} isNotificationEnabled AsyncCallback errCode: ${err.code}, errMes: ${err.message}`) + expect(err.code).assertEqual(202); + done() + } else { + console.info(`${TAG} isNotificationEnabled AsyncCallback success`) + expect(false).assertTrue() + done() + } + }); + + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_0600 END`); + }); + + /* + * @tc.number: SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_0700 + * @tc.name: isNotificationEnabled + * @tc.desc: test function isNotificationEnabled no parameter + */ + it('SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_0700', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_0700 START`); + + notificationManager.isNotificationEnabled((err, data) => { + if (err) { + console.info(`${TAG} isNotificationEnabled AsyncCallback errCode: ${err.code}, errMes: ${err.message}`) + expect(err.code).assertEqual(202); + done() + } else { + console.info(`${TAG} isNotificationEnabled AsyncCallback success`) + expect(false).assertTrue() + done() + } + }); + + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_0700 END`); + }); + + /* + * @tc.number: SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_0800 + * @tc.name: isNotificationEnabled + * @tc.desc: test function isNotificationEnabled take userId + */ + it('SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_0800', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_0800 START`); + + notificationManager.isNotificationEnabled(0, (err, data) => { + if (err) { + console.info(`${TAG} isNotificationEnabled AsyncCallback errCode: ${err.code}, errMes: ${err.message}`) + expect(err.code).assertEqual(202); + done() + } else { + console.info(`${TAG} isNotificationEnabled AsyncCallback success`) + expect(false).assertTrue() + done() + } + }); + + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_0800 END`); + }); + + /* + * @tc.number: SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_0900 + * @tc.name: displayBadge + * @tc.desc: test function displayBadge + */ + it('SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_0900', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_0900 START`); + + let bundleOpt : notificationManager.BundleOption = { + bundle: "example.bundleName", + uid: 0 + } + notificationManager.displayBadge(bundleOpt, true, (err) => { + if (err) { + console.info(`${TAG} displayBadge AsyncCallback errCode: ${err.code}, errMes: ${err.message}`) + expect(err.code).assertEqual(202); + done() + } else { + console.info(`${TAG} displayBadge AsyncCallback success`) + expect(false).assertTrue() + done() + } + }); + + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_0900 END`); + }); + + /* + * @tc.number: SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_1000 + * @tc.name: isBadgeDisplayed + * @tc.desc: test function isBadgeDisplayed + */ + it('SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_1000', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_1000 START`); + + let bundleOpt : notificationManager.BundleOption = { + bundle: "example.bundleName", + uid: 0 + } + notificationManager.isBadgeDisplayed(bundleOpt, (err, data) => { + if (err) { + console.info(`${TAG} isBadgeDisplayed AsyncCallback errCode: ${err.code}, errMes: ${err.message}`) + expect(err.code).assertEqual(202); + done() + } else { + console.info(`${TAG} isBadgeDisplayed AsyncCallback success`) + expect(false).assertTrue() + done() + } + }); + + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_1000 END`); + }); + + /* + * @tc.number: SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_1100 + * @tc.name: setSlotByBundle + * @tc.desc: test function setSlotByBundle + */ + it('SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_1100', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_1100 START`); + + let bundleOpt : notificationManager.BundleOption = { + bundle: "example.bundleName", + uid: 0 + } + let slot : notificationManager.NotificationSlot = { + type: notificationManager.SlotType.SOCIAL_COMMUNICATION, + level: notificationManager.SlotLevel.LEVEL_HIGH, + desc: 'xts test' + } + + notificationManager.setSlotByBundle(bundleOpt, slot, (err) => { + if (err) { + console.info(`${TAG} setSlotByBundle AsyncCallback errCode: ${err.code}, errMes: ${err.message}`) + expect(err.code).assertEqual(202); + done() + } else { + console.info(`${TAG} setSlotByBundle AsyncCallback success`) + expect(false).assertTrue() + done() + } + }); + + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_1100 END`); + }); + + /* + * @tc.number: SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_1200 + * @tc.name: getSlotsByBundle + * @tc.desc: test function getSlotsByBundle + */ + it('SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_1200', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_1200 START`); + + let bundleOpt : notificationManager.BundleOption = { + bundle: "example.bundleName", + uid: 0 + } + + notificationManager.getSlotsByBundle(bundleOpt, (err, data) => { + if (err) { + console.info(`${TAG} getSlotsByBundle AsyncCallback errCode: ${err.code}, errMes: ${err.message}`) + expect(err.code).assertEqual(202); + done() + } else { + console.info(`${TAG} getSlotsByBundle AsyncCallback success`) + expect(false).assertTrue() + done() + } + }); + + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_1200 END`); + }); + + /* + * @tc.number: SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_1300 + * @tc.name: getSlotNumByBundle + * @tc.desc: test function getSlotNumByBundle + */ + it('SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_1300', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_1300 START`); + + let bundleOpt : notificationManager.BundleOption = { + bundle: "example.bundleName", + uid: 0 + } + + notificationManager.getSlotNumByBundle(bundleOpt, (err, data) => { + if (err) { + console.info(`${TAG} getSlotNumByBundle AsyncCallback errCode: ${err.code}, errMes: ${err.message}`) + expect(err.code).assertEqual(202); + done() + } else { + console.info(`${TAG} getSlotNumByBundle AsyncCallback success`) + expect(false).assertTrue() + done() + } + }); + + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_1300 END`); + }); + + /* + * @tc.number: SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_1400 + * @tc.name: getAllActiveNotifications + * @tc.desc: test function getAllActiveNotifications + */ + it('SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_1400', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_1400 START`); + + notificationManager.getAllActiveNotifications((err, data) => { + if (err) { + console.info(`${TAG} getAllActiveNotifications AsyncCallback errCode: ${err.code}, errMes: ${err.message}`) + expect(err.code).assertEqual(202); + done() + } else { + console.info(`${TAG} getAllActiveNotifications AsyncCallback success`) + expect(false).assertTrue() + done() + } + }); + + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_1400 END`); + }); + + /* + * @tc.number: SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_1500 + * @tc.name: removeGroupByBundle + * @tc.desc: test function removeGroupByBundle + */ + it('SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_1500', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_1500 START`); + + let bundleOpt : notificationManager.BundleOption = { + bundle: "example.bundleName", + uid: 0 + } + notificationManager.removeGroupByBundle(bundleOpt, "groupName", (err) => { + if (err) { + console.info(`${TAG} removeGroupByBundle AsyncCallback errCode: ${err.code}, errMes: ${err.message}`) + expect(err.code).assertEqual(202); + done() + } else { + console.info(`${TAG} removeGroupByBundle AsyncCallback success`) + expect(false).assertTrue() + done() + } + }); + + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_1500 END`); + }); + + /* + * @tc.number: SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_1600 + * @tc.name: setDoNotDisturbDate + * @tc.desc: test function setDoNotDisturbDate + */ + it('SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_1600', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_1600 START`); + + let date : notificationManager.DoNotDisturbDate = { + type: notificationManager.DoNotDisturbType.TYPE_ONCE, + begin: new Date(2023, 2, 24, 15, 53), + end: new Date(2024, 2, 24, 15, 53) + } + notificationManager.setDoNotDisturbDate(date, (err) => { + if (err) { + console.info(`${TAG} setDoNotDisturbDate AsyncCallback errCode: ${err.code}, errMes: ${err.message}`) + expect(err.code).assertEqual(202); + done() + } else { + console.info(`${TAG} setDoNotDisturbDate AsyncCallback success`) + expect(false).assertTrue() + done() + } + }); + + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_1600 END`); + }); + + /* + * @tc.number: SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_1700 + * @tc.name: setDoNotDisturbDate + * @tc.desc: test function setDoNotDisturbDate take userId + */ + it('SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_1700', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_1700 START`); + + let date : notificationManager.DoNotDisturbDate = { + type: notificationManager.DoNotDisturbType.TYPE_ONCE, + begin: new Date(2023, 2, 24, 15, 53), + end: new Date(2024, 2, 24, 15, 53) + } + notificationManager.setDoNotDisturbDate(date, 0, (err) => { + if (err) { + console.info(`${TAG} setDoNotDisturbDate AsyncCallback errCode: ${err.code}, errMes: ${err.message}`) + expect(err.code).assertEqual(202); + done() + } else { + console.info(`${TAG} setDoNotDisturbDate AsyncCallback success`) + expect(false).assertTrue() + done() + } + }); + + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_1700 END`); + }); + + /* + * @tc.number: SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_1800 + * @tc.name: getDoNotDisturbDate + * @tc.desc: test function getDoNotDisturbDate + */ + it('SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_1800', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_1800 START`); + + notificationManager.getDoNotDisturbDate((err, data) => { + if (err) { + console.info(`${TAG} getDoNotDisturbDate AsyncCallback errCode: ${err.code}, errMes: ${err.message}`) + expect(err.code).assertEqual(202); + done() + } else { + console.info(`${TAG} getDoNotDisturbDate AsyncCallback success`) + expect(false).assertTrue() + done() + } + }); + + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_1800 END`); + }); + + /* + * @tc.number: SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_1900 + * @tc.name: getDoNotDisturbDate + * @tc.desc: test function getDoNotDisturbDate take userId + */ + it('SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_1900', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_1900 START`); + + notificationManager.getDoNotDisturbDate(0, (err, data) => { + if (err) { + console.info(`${TAG} getDoNotDisturbDate AsyncCallback errCode: ${err.code}, errMes: ${err.message}`) + expect(err.code).assertEqual(202); + done() + } else { + console.info(`${TAG} getDoNotDisturbDate AsyncCallback success`) + expect(false).assertTrue() + done() + } + }); + + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_1900 END`); + }); + + /* + * @tc.number: SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_2000 + * @tc.name: isSupportDoNotDisturbMode + * @tc.desc: test function isSupportDoNotDisturbMode + */ + it('SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_2000', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_2000 START`); + + notificationManager.isSupportDoNotDisturbMode((err, data) => { + if (err) { + console.info(`${TAG} isSupportDoNotDisturbMode AsyncCallback errCode: ${err.code}, errMes: ${err.message}`) + expect(err.code).assertEqual(202); + done() + } else { + console.info(`${TAG} isSupportDoNotDisturbMode AsyncCallback success`) + expect(false).assertTrue() + done() + } + }); + + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_2000 END`); + }); + + /* + * @tc.number: SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_2100 + * @tc.name: setDistributedEnable + * @tc.desc: test function setDistributedEnable + */ + it('SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_2100', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_2100 START`); + + notificationManager.setDistributedEnable(true, (err) => { + if (err) { + console.info(`${TAG} setDistributedEnable AsyncCallback errCode: ${err.code}, errMes: ${err.message}`) + expect(err.code).assertEqual(202); + done() + } else { + console.info(`${TAG} setDistributedEnable AsyncCallback success`) + expect(false).assertTrue() + done() + } + }); + + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_2100 END`); + }); + + /* + * @tc.number: SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_2200 + * @tc.name: setDistributedEnableByBundle + * @tc.desc: test function setDistributedEnableByBundle + */ + it('SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_2200', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_2200 START`); + + let bundleOpt : notificationManager.BundleOption = { + bundle: "example.bundleName", + uid: 0 + } + notificationManager.setDistributedEnableByBundle(bundleOpt, true, (err) => { + if (err) { + console.info(`${TAG} setDistributedEnableByBundle AsyncCallback errCode: ${err.code}, errMes: ${err.message}`) + expect(err.code).assertEqual(202); + done() + } else { + console.info(`${TAG} setDistributedEnableByBundle AsyncCallback success`) + expect(false).assertTrue() + done() + } + }); + + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_2200 END`); + }); + + /* + * @tc.number: SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_2300 + * @tc.name: isDistributedEnabledByBundle + * @tc.desc: test function isDistributedEnabledByBundle + */ + it('SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_2300', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_2300 START`); + + let bundleOpt : notificationManager.BundleOption = { + bundle: "example.bundleName", + uid: 0 + } + notificationManager.isDistributedEnabledByBundle(bundleOpt, (err, data) => { + if (err) { + console.info(`${TAG} isDistributedEnabledByBundle AsyncCallback errCode: ${err.code}, errMes: ${err.message}`) + expect(err.code).assertEqual(202); + done() + } else { + console.info(`${TAG} isDistributedEnabledByBundle AsyncCallback success`) + expect(false).assertTrue() + done() + } + }); + + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_2300 END`); + }); + + /* + * @tc.number: SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_2400 + * @tc.name: getDeviceRemindType + * @tc.desc: test function getDeviceRemindType + */ + it('SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_2400', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_2400 START`); + + notificationManager.getDeviceRemindType((err, data) => { + if (err) { + console.info(`${TAG} getDeviceRemindType AsyncCallback errCode: ${err.code}, errMes: ${err.message}`) + expect(err.code).assertEqual(202); + done() + } else { + console.info(`${TAG} getDeviceRemindType AsyncCallback success`) + expect(false).assertTrue() + done() + } + }); + + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_2400 END`); + }); + + /* + * @tc.number: SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_2500 + * @tc.name: setNotificationEnableSlot + * @tc.desc: test function setNotificationEnableSlot + */ + it('SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_2500', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_2500 START`); + + let bundleOpt : notificationManager.BundleOption = { + bundle: "example.bundleName", + uid: 0 + } + let type = notificationManager.SlotType.SOCIAL_COMMUNICATION; + notificationManager.setNotificationEnableSlot(bundleOpt, type, true, (err) => { + if (err) { + console.info(`${TAG} setNotificationEnableSlot AsyncCallback errCode: ${err.code}, errMes: ${err.message}`) + expect(err.code).assertEqual(202); + done() + } else { + console.info(`${TAG} setNotificationEnableSlot AsyncCallback success`) + expect(false).assertTrue() + done() + } + }); + + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_2500 END`); + }); + + /* + * @tc.number: SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_2600 + * @tc.name: isNotificationSlotEnabled + * @tc.desc: test function isNotificationSlotEnabled + */ + it('SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_2600', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_2600 START`); + + let bundleOpt : notificationManager.BundleOption = { + bundle: "example.bundleName", + uid: 0 + } + let type = notificationManager.SlotType.SOCIAL_COMMUNICATION; + notificationManager.isNotificationSlotEnabled(bundleOpt, type, (err, data) => { + if (err) { + console.info(`${TAG} isNotificationSlotEnabled AsyncCallback errCode: ${err.code}, errMes: ${err.message}`) + expect(err.code).assertEqual(202); + done() + } else { + console.info(`${TAG} isNotificationSlotEnabled AsyncCallback success`) + expect(false).assertTrue() + done() + } + }); + + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_2600 END`); + }); + + /* + * @tc.number: SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_2700 + * @tc.name: setSyncNotificationEnabledWithoutApp + * @tc.desc: test function setSyncNotificationEnabledWithoutApp + */ + it('SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_2700', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_2700 START`); + + notificationManager.setSyncNotificationEnabledWithoutApp(0, true, (err) => { + if (err) { + console.info(`${TAG} setSyncNotificationEnabledWithoutApp AsyncCallback errCode: ${err.code}, errMes: ${err.message}`) + expect(err.code).assertEqual(202); + done() + } else { + console.info(`${TAG} setSyncNotificationEnabledWithoutApp AsyncCallback success`) + expect(false).assertTrue() + done() + } + }); + + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_2700 END`); + }); + + /* + * @tc.number: SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_2800 + * @tc.name: getSyncNotificationEnabledWithoutApp + * @tc.desc: test function getSyncNotificationEnabledWithoutApp + */ + it('SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_2800', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_2800 START`); + + notificationManager.getSyncNotificationEnabledWithoutApp(0, (err, data) => { + if (err) { + console.info(`${TAG} getSyncNotificationEnabledWithoutApp AsyncCallback errCode: ${err.code}, errMes: ${err.message}`) + expect(err.code).assertEqual(202); + done() + } else { + console.info(`${TAG} getSyncNotificationEnabledWithoutApp AsyncCallback success`) + expect(false).assertTrue() + done() + } + }); + + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_2800 END`); + }); + + let subscriber = { + onConsume: function (data) { + let req = data.request; + console.info(`${TAG} onConsume request id: ${req.id}`) + } + }; + + /* + * @tc.number: SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_2900 + * @tc.name: subscribe + * @tc.desc: test function subscribe + */ + it('SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_2900', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_2900 START`); + + notificationSubscribe.subscribe(subscriber, (err) => { + if (err) { + console.info(`${TAG} subscribe AsyncCallback errCode: ${err.code}, errMes: ${err.message}`) + expect(err.code).assertEqual(202); + done() + } else { + console.info(`${TAG} subscribe AsyncCallback success`) + expect(false).assertTrue() + done() + } + }); + + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_2900 END`); + }); + + /* + * @tc.number: SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_3000 + * @tc.name: subscribe + * @tc.desc: test function subscribe take NotificationSubscribeInfo + */ + it('SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_3000', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_3000 START`); + + let subscribeInfo : notificationSubscribe.NotificationSubscribeInfo = { + bundleNames: ["example.bundleName"], + userId: 0 + } + notificationSubscribe.subscribe(subscriber, subscribeInfo, (err) => { + if (err) { + console.info(`${TAG} subscribe AsyncCallback errCode: ${err.code}, errMes: ${err.message}`) + expect(err.code).assertEqual(202); + done() + } else { + console.info(`${TAG} subscribe AsyncCallback success`) + expect(false).assertTrue() + done() + } + }); + + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_3000 END`); + }); + + /* + * @tc.number: SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_3100 + * @tc.name: subscribe + * @tc.desc: test function subscribe take NotificationSubscribeInfo + */ + it('SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_3100', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_3100 START`); + + let subscribeInfo : notificationSubscribe.NotificationSubscribeInfo = { + bundleNames: ["example.bundleName"], + userId: 0 + } + + await notificationSubscribe.subscribe(subscriber, subscribeInfo).then(() => { + console.info(`${TAG} subscribe AsyncCallback success`) + expect(false).assertTrue() + done() + }).catch((err) => { + console.info(`${TAG} subscribe AsyncCallback errCode: ${err.code}, errMes: ${err.message}`) + expect(err.code).assertEqual(202); + done() + }); + + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_3100 END`); + }); + + /* + * @tc.number: SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_3200 + * @tc.name: unsubscribe + * @tc.desc: test function unsubscribe + */ + it('SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_3200', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_3200 START`); + + notificationSubscribe.unsubscribe(subscriber, (err) => { + if (err) { + console.info(`${TAG} unsubscribe AsyncCallback errCode: ${err.code}, errMes: ${err.message}`) + expect(err.code).assertEqual(202); + done() + } else { + console.info(`${TAG} unsubscribe AsyncCallback success`) + expect(false).assertTrue() + done() + } + }); + + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_3200 END`); + }); + + /* + * @tc.number: SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_3300 + * @tc.name: remove + * @tc.desc: test function remove + */ + it('SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_3300', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_3300 START`); + + let bundleOpt : notificationSubscribe.BundleOption = { + bundle: "example.bundleName", + uid: 0 + } + let key : notificationSubscribe.NotificationKey = { + id: 0, + label: 'test' + } + notificationSubscribe.remove(bundleOpt, key, notificationSubscribe.RemoveReason.CLICK_REASON_REMOVE, (err) => { + if (err) { + console.info(`${TAG} remove AsyncCallback errCode: ${err.code}, errMes: ${err.message}`) + expect(err.code).assertEqual(202); + done() + } else { + console.info(`${TAG} remove AsyncCallback success`) + expect(false).assertTrue() + done() + } + }); + + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_3300 END`); + }); + + /* + * @tc.number: SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_3400 + * @tc.name: remove + * @tc.desc: test function remove + */ + it('SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_3400', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_3400 START`); + + notificationSubscribe.remove("device_0_1", notificationSubscribe.RemoveReason.CLICK_REASON_REMOVE, (err) => { + if (err) { + console.info(`${TAG} remove AsyncCallback errCode: ${err.code}, errMes: ${err.message}`) + expect(err.code).assertEqual(202); + done() + } else { + console.info(`${TAG} remove AsyncCallback success`) + expect(false).assertTrue() + done() + } + }); + + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_3400 END`); + }); + + /* + * @tc.number: SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_3500 + * @tc.name: removeAll + * @tc.desc: test function removeAll take bundle + */ + it('SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_3500', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_3500 START`); + + let bundleOpt : notificationSubscribe.BundleOption = { + bundle: "example.bundleName", + uid: 0 + } + notificationSubscribe.removeAll(bundleOpt, (err) => { + if (err) { + console.info(`${TAG} removeAll AsyncCallback errCode: ${err.code}, errMes: ${err.message}`) + expect(err.code).assertEqual(202); + done() + } else { + console.info(`${TAG} removeAll AsyncCallback success`) + expect(false).assertTrue() + done() + } + }); + + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_3500 END`); + }); + + /* + * @tc.number: SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_3600 + * @tc.name: removeAll + * @tc.desc: test function removeAll + */ + it('SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_3600', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_3600 START`); + + notificationSubscribe.removeAll((err) => { + if (err) { + console.info(`${TAG} removeAll AsyncCallback errCode: ${err.code}, errMes: ${err.message}`) + expect(err.code).assertEqual(202); + done() + } else { + console.info(`${TAG} removeAll AsyncCallback success`) + expect(false).assertTrue() + done() + } + }); + + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_3600 END`); + }); + + /* + * @tc.number: SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_3700 + * @tc.name: removeAll + * @tc.desc: test function removeAll take userId + */ + it('SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_3700', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_3700 START`); + + notificationSubscribe.removeAll(0, (err) => { + if (err) { + console.info(`${TAG} removeAll AsyncCallback errCode: ${err.code}, errMes: ${err.message}`) + expect(err.code).assertEqual(202); + done() + } else { + console.info(`${TAG} removeAll AsyncCallback success`) + expect(false).assertTrue() + done() + } + }); + + console.info(`${TAG} SUB_NOTIFICATION_ANS_SYSTEM_API_TEST_3700 END`); + }); + +}) } \ No newline at end of file diff --git a/notification/ans_standard/actsNotificationSystemAPITest/entry/src/main/ets/test/List.test.ets b/notification/ans_standard/actsNotificationSystemAPITest/entry/src/main/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..7824ef3ef57dac0be3bb621db1538ad8daa7d1b6 --- /dev/null +++ b/notification/ans_standard/actsNotificationSystemAPITest/entry/src/main/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 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 + * + * 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 ActsNotificationSystemAPITest from './ActsNotificationSystemAPITest.test' + +export default function List() { + ActsNotificationSystemAPITest() +} \ No newline at end of file diff --git a/notification/ans_standard/actsNotificationSystemAPITest/entry/src/main/module.json b/notification/ans_standard/actsNotificationSystemAPITest/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..132c6adc5fc18d0a2309bfe08d5cbaecc35d253f --- /dev/null +++ b/notification/ans_standard/actsNotificationSystemAPITest/entry/src/main/module.json @@ -0,0 +1,47 @@ +{ + "module": { + "name": "phone", + "type": "entry", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:phone_entry_dsc", + "mainElement": "MainAbility", + "deviceTypes": [ + "tablet", + "default", + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], + "abilities": [ + { + "name": "com.example.systemAPI.MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:white", + "visible": true, + "orientation": "portrait", + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ] + } + } diff --git a/notification/ans_standard/actsNotificationSystemAPITest/entry/src/main/resources/base/element/color.json b/notification/ans_standard/actsNotificationSystemAPITest/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..1bbc9aa9617e97c45440e1d3d66afc1154837012 --- /dev/null +++ b/notification/ans_standard/actsNotificationSystemAPITest/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "white", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/notification/ans_standard/actsNotificationSystemAPITest/entry/src/main/resources/base/element/string.json b/notification/ans_standard/actsNotificationSystemAPITest/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..4af975ee904d5089633c604a63f3f9bcc3885a3f --- /dev/null +++ b/notification/ans_standard/actsNotificationSystemAPITest/entry/src/main/resources/base/element/string.json @@ -0,0 +1,36 @@ +{ + "string": [ + { + "name": "phone_entry_dsc", + "value": "i am an entry for phone" + }, + { + "name": "phone_entry_main", + "value": "the phone entry ability" + }, + { + "name": "entry_label", + "value": "ActsLifecycleMultihapTest" + }, + { + "name": "form_description", + "value": "my form" + }, + { + "name": "description_application", + "value": "demo for test" + }, + { + "name": "entry_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + } + ] +} diff --git a/notification/ans_standard/actsNotificationSystemAPITest/entry/src/main/resources/base/media/icon.png b/notification/ans_standard/actsNotificationSystemAPITest/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/notification/ans_standard/actsNotificationSystemAPITest/entry/src/main/resources/base/media/icon.png differ diff --git a/notification/ans_standard/actsNotificationSystemAPITest/entry/src/main/resources/base/profile/form_config.json b/notification/ans_standard/actsNotificationSystemAPITest/entry/src/main/resources/base/profile/form_config.json new file mode 100644 index 0000000000000000000000000000000000000000..146fbe1c6da88e46886838ba746afb29e69cc190 --- /dev/null +++ b/notification/ans_standard/actsNotificationSystemAPITest/entry/src/main/resources/base/profile/form_config.json @@ -0,0 +1,23 @@ +{ + "forms": [ + { + "isDefault": true, + "src": "./js/widget/pages/index/index", + "scheduledUpdateTime": "10:30", + "defaultDimension": "2*2", + "name": "widget", + "description": "This is a service widget.", + "colorMode": "auto", + "window": { + "designWidth": 720, + "autoDesignWidth": true + }, + "formConfigAbility": "ability://xxxxx", + "supportDimensions": [ + "2*2" + ], + "updateEnabled": true, + "updateDuration": 1 + } + ] +} \ No newline at end of file diff --git a/notification/ans_standard/actsNotificationSystemAPITest/entry/src/main/resources/base/profile/main_pages.json b/notification/ans_standard/actsNotificationSystemAPITest/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..81691245bb98976d7d8966dd406a9abd5140ef39 --- /dev/null +++ b/notification/ans_standard/actsNotificationSystemAPITest/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "MainAbility/pages/MainAbility_pages" + ] +} \ No newline at end of file diff --git a/notification/ans_standard/actsNotificationSystemAPITest/signature/openharmony_sx.p7b b/notification/ans_standard/actsNotificationSystemAPITest/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..e7b446ca607cf1f079c68a591655a5a84fd7eec2 Binary files /dev/null and b/notification/ans_standard/actsNotificationSystemAPITest/signature/openharmony_sx.p7b differ diff --git a/notification/ces_standard/BUILD.gn b/notification/ces_standard/BUILD.gn index 9951871275841051ae0c85a9d3dbd22b6ac4daa8..4f1895455d83c10d579f4828eeb10e1bb4c9aaea 100644 --- a/notification/ces_standard/BUILD.gn +++ b/notification/ces_standard/BUILD.gn @@ -20,6 +20,7 @@ group("ces_standard") { "actsCommonEventManagerSupportTest:ActsCommonEventManagerSupportTest", "actsCommonEventManagerTest:ActsCommonEventManagerTest", "actsCommonEventSupportTest:ActsCommonEventSupportTest", + "actsCommonEventSystemAPITest:ActsCommonEventSystemAPITest", "subscribeandpublish:SubscribeAndPublish", ] } diff --git a/notification/ces_standard/actsCommonEventSystemAPITest/AppScope/app.json b/notification/ces_standard/actsCommonEventSystemAPITest/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..7d34d5a5d488607637aabf8a4496f67d71eccd3b --- /dev/null +++ b/notification/ces_standard/actsCommonEventSystemAPITest/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app": { + "bundleName": "com.example.systemAPI", + "vendor": "huawei", + "versionCode": 1000000, + "versionName": "1.0.0", + "debug": false, + "icon": "$media:icon", + "label": "$string:app_name", + "description": "$string:description_application", + "distributedNotificationEnabled": true, + "keepAlive": true, + "singleUser": true, + "minAPIVersion": 9, + "targetAPIVersion": 9, + "car": { + "apiCompatibleVersion": 9, + "singleUser": false + } + } +} diff --git a/notification/ces_standard/actsCommonEventSystemAPITest/AppScope/resources/base/element/string.json b/notification/ces_standard/actsCommonEventSystemAPITest/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..0d1f12ea9692aa14d5e6e140d74baa9b04c25352 --- /dev/null +++ b/notification/ces_standard/actsCommonEventSystemAPITest/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string":[ + { + "name":"app_name", + "value":"LifecycleTest" + } + ] +} \ No newline at end of file diff --git a/notification/ces_standard/actsCommonEventSystemAPITest/AppScope/resources/base/media/app_icon.png b/notification/ces_standard/actsCommonEventSystemAPITest/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/notification/ces_standard/actsCommonEventSystemAPITest/AppScope/resources/base/media/app_icon.png differ diff --git a/notification/ces_standard/actsCommonEventSystemAPITest/BUILD.gn b/notification/ces_standard/actsCommonEventSystemAPITest/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..179cd8366d28167fe4a58f6a6d43b0dd1848a28a --- /dev/null +++ b/notification/ces_standard/actsCommonEventSystemAPITest/BUILD.gn @@ -0,0 +1,43 @@ +# Copyright (c) 2021 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ActsCommonEventSystemAPITest") { + hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" + deps = [ + ":systemapitest_js_assets", + ":systemapitest_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsCommonEventSystemAPITest" + subsystem_name = "ability" + part_name = "ability_runtime" +} + +ohos_app_scope("systemapitest_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("systemapitest_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("systemapitest_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":systemapitest_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/notification/ces_standard/actsCommonEventSystemAPITest/Test.json b/notification/ces_standard/actsCommonEventSystemAPITest/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..1c62d9b2bce42c54321999e0710037d74c907f62 --- /dev/null +++ b/notification/ces_standard/actsCommonEventSystemAPITest/Test.json @@ -0,0 +1,27 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "180000", + "bundle-name": "com.example.systemAPI", + "module-name": "phone", + "shell-timeout": "600000", + "testcase-timeout": 70000 + }, + "kits": [ + { + "test-file-name": [ + "ActsCommonEventSystemAPITest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, + { + "type":"ShellKit", + "run-command":[ + "anm setting -e com.example.systemAPI:0:1" + ], + "cleanup-apps":true + } + ] +} diff --git a/notification/ces_standard/actsCommonEventSystemAPITest/entry/src/main/ets/Application/AbilityStage.ts b/notification/ces_standard/actsCommonEventSystemAPITest/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..7e917ee0f146b706fc264dfaac71ac33f8c513a0 --- /dev/null +++ b/notification/ces_standard/actsCommonEventSystemAPITest/entry/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2021 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 AbilityStage from "@ohos.app.ability.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("[Demo] MyAbilityStage onCreate") + globalThis.stageContext = this.context; + } +} \ No newline at end of file diff --git a/notification/ces_standard/actsCommonEventSystemAPITest/entry/src/main/ets/MainAbility/MainAbility.ts b/notification/ces_standard/actsCommonEventSystemAPITest/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..881e90c13c2404e167090ce55019ad24f8b4cc2b --- /dev/null +++ b/notification/ces_standard/actsCommonEventSystemAPITest/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2021 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 Ability from '@ohos.app.ability.UIAbility' + +export default class MainAbility extends Ability { + + onCreate(want, launchParam) { + console.log("[Demo] MainAbility onCreate") + globalThis.abilityWant = want; + globalThis.applicationContext = this.context.getApplicationContext(); + } + + onDestroy() { + console.log("[Demo] MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("[Demo] MainAbility onWindowStageCreate") + globalThis.abilityContext = this.context; + windowStage.setUIContent(this.context, "MainAbility/pages/MainAbility_pages", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("[Demo] MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("[Demo] MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("[Demo] MainAbility onBackground") + } +}; diff --git a/notification/ces_standard/actsCommonEventSystemAPITest/entry/src/main/ets/MainAbility/pages/MainAbility_pages.ets b/notification/ces_standard/actsCommonEventSystemAPITest/entry/src/main/ets/MainAbility/pages/MainAbility_pages.ets new file mode 100644 index 0000000000000000000000000000000000000000..ecf02975d91908f8b1b59f3e668343e8419e23c7 --- /dev/null +++ b/notification/ces_standard/actsCommonEventSystemAPITest/entry/src/main/ets/MainAbility/pages/MainAbility_pages.ets @@ -0,0 +1,47 @@ +// @ts-nocheck +/* + * Copyright (c) 2021 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 router from '@ohos.router'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../test/List.test' + +@Entry +@Component +struct Index { + @State message: string = 'MainAbility' + + aboutToAppear() { + console.info("start run testcase!!!!") + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + } + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/notification/ces_standard/actsCommonEventSystemAPITest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/notification/ces_standard/actsCommonEventSystemAPITest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..ced6d9c55dba5e6abe686473b1aba02d08ff4d0e --- /dev/null +++ b/notification/ces_standard/actsCommonEventSystemAPITest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,78 @@ +/* + * 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 TestRunner from '@ohos.application.testRunner' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s it', + '-s level', '-s testType', '-s size', '-s timeout', + '-s dryRun' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams = `${targetParams} ${key} ${parameters[key]}` + } + } + return targetParams.trim() +} + +async function onAbilityCreateCallback() { + console.log("onAbilityCreateCallback"); +} + +async function addAbilityMonitorCallback(err: any) { + console.info("addAbilityMonitorCallback : " + JSON.stringify(err)) +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + console.info("OpenHarmonyTestRunner OnPrepare ") + } + + async onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility' + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a com.example.systemAPI.MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + var debug = abilityDelegatorArguments.parameters["-D"] + if (debug == 'true') + { + cmd += ' -D' + } + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + d.stdResult); + console.info('executeShellCommand : data : ' + d.exitCode); + }) + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/notification/ces_standard/actsCommonEventSystemAPITest/entry/src/main/ets/test/ActsCommonEventSystemAPITest.test.ets b/notification/ces_standard/actsCommonEventSystemAPITest/entry/src/main/ets/test/ActsCommonEventSystemAPITest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..1f1a7502ab0535bcec5e84e36aedae6965d7adbe --- /dev/null +++ b/notification/ces_standard/actsCommonEventSystemAPITest/entry/src/main/ets/test/ActsCommonEventSystemAPITest.test.ets @@ -0,0 +1,73 @@ +/* + * 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' +import commonEventManager from '@ohos.commonEventManager' + +export default function ActsCommonEventSystemAPITest() { +describe('SUB_NOTIFICATION_CES_SYSTEM_API_TEST', function () { + let TAG = 'SUB_NOTIFICATION_CES_SYSTEM_API_TEST ===>' + console.info(TAG + 'SUB_NOTIFICATION_CES_SYSTEM_API_TEST START') + + /* + * @tc.number: SUB_NOTIFICATION_CES_SYSTEM_API_TEST_0100 + * @tc.name: publishAsUser + * @tc.desc: test function publishAsBundle + */ + it('SUB_NOTIFICATION_CES_SYSTEM_API_TEST_0100', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_CES_SYSTEM_API_TEST_0100 START`); + + commonEventManager.publishAsUser("event.test", 0, (err) => { + if (err) { + console.info(`${TAG} publishAsUser AsyncCallback errCode: ${err.code}, errMes: ${err.message}`) + expect(err.code).assertEqual(202); + done() + } else { + console.info(`${TAG} publishAsUser AsyncCallback success`) + expect(false).assertTrue() + done() + } + }); + + console.info(`${TAG} SUB_NOTIFICATION_CES_SYSTEM_API_TEST_0100 END`); + }); + + /* + * @tc.number: SUB_NOTIFICATION_CES_SYSTEM_API_TEST_0200 + * @tc.name: publishAsUser + * @tc.desc: test function publishAsUser + */ + it('SUB_NOTIFICATION_CES_SYSTEM_API_TEST_0200', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_CES_SYSTEM_API_TEST_0200 START`); + + let publishData = { + bundleNames: "example.bundleName", + code: 1 + } + + commonEventManager.publishAsUser("event.test", 0, publishData, (err) => { + if (err) { + console.info(`${TAG} publishAsUser AsyncCallback errCode: ${err.code}, errMes: ${err.message}`) + expect(err.code).assertEqual(202); + done() + } else { + console.info(`${TAG} publishAsUser AsyncCallback success`) + expect(false).assertTrue() + done() + } + }); + + console.info(`${TAG} SUB_NOTIFICATION_CES_SYSTEM_API_TEST_0200 END`); + }); +}) } \ No newline at end of file diff --git a/notification/ces_standard/actsCommonEventSystemAPITest/entry/src/main/ets/test/List.test.ets b/notification/ces_standard/actsCommonEventSystemAPITest/entry/src/main/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..5e4b902db264a8e8830bb0e4e63fbcdcebf30ca2 --- /dev/null +++ b/notification/ces_standard/actsCommonEventSystemAPITest/entry/src/main/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2021 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 ActsCommonEventSystemAPITest from './ActsCommonEventSystemAPITest.test' + +export default function List() { + ActsCommonEventSystemAPITest() +} \ No newline at end of file diff --git a/notification/ces_standard/actsCommonEventSystemAPITest/entry/src/main/module.json b/notification/ces_standard/actsCommonEventSystemAPITest/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..132c6adc5fc18d0a2309bfe08d5cbaecc35d253f --- /dev/null +++ b/notification/ces_standard/actsCommonEventSystemAPITest/entry/src/main/module.json @@ -0,0 +1,47 @@ +{ + "module": { + "name": "phone", + "type": "entry", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:phone_entry_dsc", + "mainElement": "MainAbility", + "deviceTypes": [ + "tablet", + "default", + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], + "abilities": [ + { + "name": "com.example.systemAPI.MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:white", + "visible": true, + "orientation": "portrait", + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ] + } + } diff --git a/notification/ces_standard/actsCommonEventSystemAPITest/entry/src/main/resources/base/element/color.json b/notification/ces_standard/actsCommonEventSystemAPITest/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..1bbc9aa9617e97c45440e1d3d66afc1154837012 --- /dev/null +++ b/notification/ces_standard/actsCommonEventSystemAPITest/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "white", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/notification/ces_standard/actsCommonEventSystemAPITest/entry/src/main/resources/base/element/string.json b/notification/ces_standard/actsCommonEventSystemAPITest/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..4af975ee904d5089633c604a63f3f9bcc3885a3f --- /dev/null +++ b/notification/ces_standard/actsCommonEventSystemAPITest/entry/src/main/resources/base/element/string.json @@ -0,0 +1,36 @@ +{ + "string": [ + { + "name": "phone_entry_dsc", + "value": "i am an entry for phone" + }, + { + "name": "phone_entry_main", + "value": "the phone entry ability" + }, + { + "name": "entry_label", + "value": "ActsLifecycleMultihapTest" + }, + { + "name": "form_description", + "value": "my form" + }, + { + "name": "description_application", + "value": "demo for test" + }, + { + "name": "entry_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + } + ] +} diff --git a/notification/ces_standard/actsCommonEventSystemAPITest/entry/src/main/resources/base/media/icon.png b/notification/ces_standard/actsCommonEventSystemAPITest/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/notification/ces_standard/actsCommonEventSystemAPITest/entry/src/main/resources/base/media/icon.png differ diff --git a/notification/ces_standard/actsCommonEventSystemAPITest/entry/src/main/resources/base/profile/form_config.json b/notification/ces_standard/actsCommonEventSystemAPITest/entry/src/main/resources/base/profile/form_config.json new file mode 100644 index 0000000000000000000000000000000000000000..146fbe1c6da88e46886838ba746afb29e69cc190 --- /dev/null +++ b/notification/ces_standard/actsCommonEventSystemAPITest/entry/src/main/resources/base/profile/form_config.json @@ -0,0 +1,23 @@ +{ + "forms": [ + { + "isDefault": true, + "src": "./js/widget/pages/index/index", + "scheduledUpdateTime": "10:30", + "defaultDimension": "2*2", + "name": "widget", + "description": "This is a service widget.", + "colorMode": "auto", + "window": { + "designWidth": 720, + "autoDesignWidth": true + }, + "formConfigAbility": "ability://xxxxx", + "supportDimensions": [ + "2*2" + ], + "updateEnabled": true, + "updateDuration": 1 + } + ] +} \ No newline at end of file diff --git a/notification/ces_standard/actsCommonEventSystemAPITest/entry/src/main/resources/base/profile/main_pages.json b/notification/ces_standard/actsCommonEventSystemAPITest/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..81691245bb98976d7d8966dd406a9abd5140ef39 --- /dev/null +++ b/notification/ces_standard/actsCommonEventSystemAPITest/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "MainAbility/pages/MainAbility_pages" + ] +} \ No newline at end of file diff --git a/notification/ces_standard/actsCommonEventSystemAPITest/signature/openharmony_sx.p7b b/notification/ces_standard/actsCommonEventSystemAPITest/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..e7b446ca607cf1f079c68a591655a5a84fd7eec2 Binary files /dev/null and b/notification/ces_standard/actsCommonEventSystemAPITest/signature/openharmony_sx.p7b differ