diff --git a/notification/ans_standard/BUILD.gn b/notification/ans_standard/BUILD.gn index fcd40e4d0da646401fd60dab35c1ac8b8d619a36..ec2e0717c2d967b9315979ba304e770b5fe32e3b 100644 --- a/notification/ans_standard/BUILD.gn +++ b/notification/ans_standard/BUILD.gn @@ -19,6 +19,7 @@ group("ans_standard") { "actsNotificationDistributedTest:ActsNotificationDistributedTest", "actsNotificationManagerSlotTest:ActsNotificationManagerSlotTest", "actsNotificationPublishTest:ActsNotificationPublishTest", + "actsNotificationSecondaryDirectory:ActsNotificationSecondaryDirectory", "actsNotificationShowTest:ActsNotificationShowTest", "actsNotificationSlotTest:ActsNotificationSlotTest", "actsNotificationWantAgentTest:ActsNotificationWantAgentTest", diff --git a/notification/ans_standard/actsNotificationSecondaryDirectory/AppScope/app.json b/notification/ans_standard/actsNotificationSecondaryDirectory/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..ef5c10cb264e5ac83f1717b3419b99fa60bd59cb --- /dev/null +++ b/notification/ans_standard/actsNotificationSecondaryDirectory/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app": { + "bundleName": "com.example.secondaryDirectory", + "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/actsNotificationSecondaryDirectory/AppScope/resources/base/element/string.json b/notification/ans_standard/actsNotificationSecondaryDirectory/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..0d1f12ea9692aa14d5e6e140d74baa9b04c25352 --- /dev/null +++ b/notification/ans_standard/actsNotificationSecondaryDirectory/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/actsNotificationSecondaryDirectory/AppScope/resources/base/media/app_icon.png b/notification/ans_standard/actsNotificationSecondaryDirectory/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/notification/ans_standard/actsNotificationSecondaryDirectory/AppScope/resources/base/media/app_icon.png differ diff --git a/notification/ans_standard/actsNotificationSecondaryDirectory/BUILD.gn b/notification/ans_standard/actsNotificationSecondaryDirectory/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..9a4c54d5dd7169b27838c3eb676097fb94963fcd --- /dev/null +++ b/notification/ans_standard/actsNotificationSecondaryDirectory/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("ActsNotificationSecondaryDirectory") { + hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" + deps = [ + ":secondarydirectorytest_js_assets", + ":secondarydirectorytest_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsNotificationSecondaryDirectory" + subsystem_name = "ability" + part_name = "ability_runtime" +} + +ohos_app_scope("secondarydirectorytest_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("secondarydirectorytest_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("secondarydirectorytest_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":secondarydirectorytest_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/notification/ans_standard/actsNotificationSecondaryDirectory/Test.json b/notification/ans_standard/actsNotificationSecondaryDirectory/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..d6ce77b2c35aed572e765cc83852c7cc087c41d6 --- /dev/null +++ b/notification/ans_standard/actsNotificationSecondaryDirectory/Test.json @@ -0,0 +1,27 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "180000", + "bundle-name": "com.example.secondaryDirectory", + "module-name": "phone", + "shell-timeout": "600000", + "testcase-timeout": 70000 + }, + "kits": [ + { + "test-file-name": [ + "ActsNotificationSecondaryDirectory.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, + { + "type":"ShellKit", + "run-command":[ + "anm setting -e com.example.secondaryDirectory:0:1" + ], + "cleanup-apps":true + } + ] +} diff --git a/notification/ans_standard/actsNotificationSecondaryDirectory/entry/src/main/ets/Application/AbilityStage.ts b/notification/ans_standard/actsNotificationSecondaryDirectory/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..a590b7d615d839ed6c67eced002d150020e300d5 --- /dev/null +++ b/notification/ans_standard/actsNotificationSecondaryDirectory/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.application.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/actsNotificationSecondaryDirectory/entry/src/main/ets/MainAbility/MainAbility.ts b/notification/ans_standard/actsNotificationSecondaryDirectory/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..83be6c5a2a1cab94029e5a4ed20690d133a08f58 --- /dev/null +++ b/notification/ans_standard/actsNotificationSecondaryDirectory/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.application.Ability' + +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/actsNotificationSecondaryDirectory/entry/src/main/ets/MainAbility/pages/MainAbility_pages.ets b/notification/ans_standard/actsNotificationSecondaryDirectory/entry/src/main/ets/MainAbility/pages/MainAbility_pages.ets new file mode 100644 index 0000000000000000000000000000000000000000..ecf02975d91908f8b1b59f3e668343e8419e23c7 --- /dev/null +++ b/notification/ans_standard/actsNotificationSecondaryDirectory/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/ans_standard/actsNotificationSecondaryDirectory/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/notification/ans_standard/actsNotificationSecondaryDirectory/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..ebb6de4af1541d455222b2452af8af77736ad2d5 --- /dev/null +++ b/notification/ans_standard/actsNotificationSecondaryDirectory/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.secondaryDirectory.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/actsNotificationSecondaryDirectory/entry/src/main/ets/test/List.test.ets b/notification/ans_standard/actsNotificationSecondaryDirectory/entry/src/main/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..329392db5760962ac57a94aff6206a4d8b1805b0 --- /dev/null +++ b/notification/ans_standard/actsNotificationSecondaryDirectory/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 secondaryDirectory from './SecondaryDirectory.test' + +export default function List() { + secondaryDirectory() +} \ No newline at end of file diff --git a/notification/ans_standard/actsNotificationSecondaryDirectory/entry/src/main/ets/test/SecondaryDirectory.test.ets b/notification/ans_standard/actsNotificationSecondaryDirectory/entry/src/main/ets/test/SecondaryDirectory.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..fe934ed4171df69b967193641bc3c616a6b3bede --- /dev/null +++ b/notification/ans_standard/actsNotificationSecondaryDirectory/entry/src/main/ets/test/SecondaryDirectory.test.ets @@ -0,0 +1,487 @@ +/* + * 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 notify from '@ohos.notificationManager' +import WantAgent from '@ohos.wantAgent' +import image from '@ohos.multimedia.image' + +var timeout = 1000; + +export default function secondaryDirectoryTest() { +describe('secondaryDirectoryTest', function () { + let TAG = 'SUB_NOTIFICATION_ANS_SECONDARY_DIRECTORY_TEST ===>' + console.info(TAG + 'SUB_NOTIFICATION_ANS_SECONDARY_DIRECTORY_TEST START') + + /* + * @tc.number: SUB_NOTIFICATION_ANS_SECONDARY_DIRECTORY_TEST_0100 + * @tc.name: NotificationRequest、NotificationContent、NotificationBasicContent + * @tc.desc: use NotificationRequest type + */ + it('SUB_NOTIFICATION_ANS_SECONDARY_DIRECTORY_TEST_0100', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_SECONDARY_DIRECTORY_TEST_0100 START`); + + let basicContent: notify.NotificationBasicContent = { + title: "test_title", + text: "test_text", + additionalText: "test_Publish" + } + let notifyContent: notify.NotificationContent = { + contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: basicContent + } + + let notificationRequest : notify.NotificationRequest = { + content: notifyContent, + id: 1 + } + + console.info(`${TAG} SUB_NOTIFICATION_ANS_SECONDARY_DIRECTORY_TEST_0100 PUBLISH`); + try{ + await notify.publish(notificationRequest, (err) => { + if (err) { + console.info(`${TAG} publish AsyncCallback errCode: ${err.code}, errMes: ${err.message}`) + expect(false).assertTrue() + done() + } else { + console.info(`${TAG} publish AsyncCallback success`) + expect(true).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_SECONDARY_DIRECTORY_TEST_0100 END`); + }); + + /* + * @tc.number: SUB_NOTIFICATION_ANS_SECONDARY_DIRECTORY_TEST_0200 + * @tc.name: NotificationLongTextContent + * @tc.desc: use NotificationLongTextContent type + */ + it('SUB_NOTIFICATION_ANS_SECONDARY_DIRECTORY_TEST_0200', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_SECONDARY_DIRECTORY_TEST_0200 START`); + + let longContentText: notify.NotificationLongTextContent = { + title: "test_title", + text: "test_text", + additionalText: "test_Publish", + longText: "longText123456", + briefText: "briefText123456", + expandedTitle: "expandedTitle123456" + } + + let notifyContent: notify.NotificationContent = { + contentType: notify.ContentType.NOTIFICATION_CONTENT_LONG_TEXT, + longText: longContentText + } + + let notificationRequest : notify.NotificationRequest = { + content: notifyContent, + id: 2, + slotType: notify.SlotType.SERVICE_INFORMATION, + } + + try{ + await notify.publish(notificationRequest, (err) => { + if (err) { + console.info(`${TAG} publish AsyncCallback errCode: ${err.code}, errMes: ${err.message}`) + expect(false).assertTrue() + done() + } else { + console.info(`${TAG} publish AsyncCallback success`) + expect(true).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_SECONDARY_DIRECTORY_TEST_0200 END`); + }); + + /* + * @tc.number: SUB_NOTIFICATION_ANS_SECONDARY_DIRECTORY_TEST_0300 + * @tc.name: NotificationBasicContent + * @tc.desc: use NotificationBasicContent type + */ + it('SUB_NOTIFICATION_ANS_SECONDARY_DIRECTORY_TEST_0300', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_SECONDARY_DIRECTORY_TEST_0300 START`); + + let basicContent: notify.NotificationBasicContent = { + title: "test_title", + text: "test_text", + additionalText: "test_Publish" + } + + let notifyContent: notify.NotificationContent = { + contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: basicContent + } + + let notificationRequest : notify.NotificationRequest = { + content: notifyContent, + id: 3 + } + + console.info(`${TAG} SUB_NOTIFICATION_ANS_SECONDARY_DIRECTORY_TEST_0300 PUBLISH`); + try{ + await notify.publish(notificationRequest, (err) => { + if (err) { + console.info(`${TAG} publish AsyncCallback errCode: ${err.code}, errMes: ${err.message}`) + expect(false).assertTrue() + done() + } else { + console.info(`${TAG} publish AsyncCallback success`) + expect(true).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_SECONDARY_DIRECTORY_TEST_0300 END`); + }); + + /* + * @tc.number: SUB_NOTIFICATION_ANS_SECONDARY_DIRECTORY_TEST_0400 + * @tc.name: NotificationMultiLineContent + * @tc.desc: use NotificationMultiLineContent type + */ + it('SUB_NOTIFICATION_ANS_SECONDARY_DIRECTORY_TEST_0400', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_SECONDARY_DIRECTORY_TEST_0400 START`); + + let multiLineContent: notify.NotificationMultiLineContent = { + title: "test_title", + text: "test_text", + briefText: "notificationMultiLineContent_title", + longTitle: "notificationMultiLineContent_title_12345678999999999", + lines: ["thrive", "democracy", "civilization", "harmonious"] + } + + let notifyContent: notify.NotificationContent = { + contentType: notify.ContentType.NOTIFICATION_CONTENT_MULTILINE, + multiLine: multiLineContent + } + + let notificationRequest : notify.NotificationRequest = { + content: notifyContent, + id: 4 + } + + console.info(`${TAG} SUB_NOTIFICATION_ANS_SECONDARY_DIRECTORY_TEST_0400 PUBLISH`); + try{ + await notify.publish(notificationRequest, (err) => { + if (err) { + console.info(`${TAG} publish AsyncCallback errCode: ${err.code}, errMes: ${err.message}`) + expect(false).assertTrue() + done() + } else { + console.info(`${TAG} publish AsyncCallback success`) + expect(true).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_SECONDARY_DIRECTORY_TEST_0400 END`); + }); + + /* + * @tc.number: SUB_NOTIFICATION_ANS_SECONDARY_DIRECTORY_TEST_0500 + * @tc.name: NotificationActionButton、NotificationUserInput + * @tc.desc: use NotificationActionButton type + */ + it('SUB_NOTIFICATION_ANS_SECONDARY_DIRECTORY_TEST_0500', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_SECONDARY_DIRECTORY_TEST_0500 START`); + + let agentInfo = { + wants: [ + { + bundleName: 'com.example.secondaryDirectory', + abilityName: 'com.example.secondaryDirectory.MainAbility', + action: "usual.event.REMOVAL_WANTAGENT" + } + ], + operationType: WantAgent.OperationType.SEND_COMMON_EVENT, + requestCode: 0, + wantAgentFlags:[WantAgent.WantAgentFlags.ONE_TIME_FLAG] + }; + + let wantAgentData = await WantAgent.getWantAgent(agentInfo); + + let basicContent: notify.NotificationBasicContent = { + title: "test_title", + text: "test_text", + additionalText: "test_Publish" + } + let notifyContent: notify.NotificationContent = { + contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: basicContent + } + + let userInputContent: notify.NotificationUserInput = { + inputKey: 'test_NotificationUserInput', + } + + let actionButton: notify.NotificationActionButton = { + title:"buttonA", + wantAgent: wantAgentData, + userInput: userInputContent + } + + let notificationRequest : notify.NotificationRequest = { + content: notifyContent, + actionButtons: [ + actionButton + ], + id: 5 + } + + console.info(`${TAG} SUB_NOTIFICATION_ANS_SECONDARY_DIRECTORY_TEST_0500 PUBLISH`); + try{ + await notify.publish(notificationRequest, (err) => { + if (err) { + console.info(`${TAG} publish AsyncCallback errCode: ${err.code}, errMes: ${err.message}`) + expect(false).assertTrue() + done() + } else { + console.info(`${TAG} publish AsyncCallback success`) + expect(true).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_SECONDARY_DIRECTORY_TEST_0500 END`); + }); + + /* + * @tc.number: SUB_NOTIFICATION_ANS_SECONDARY_DIRECTORY_TEST_0600 + * @tc.name: NotificationTemplate + * @tc.desc: use NotificationTemplate type + */ + it('SUB_NOTIFICATION_ANS_SECONDARY_DIRECTORY_TEST_0600', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_SECONDARY_DIRECTORY_TEST_0600 START`); + + let basicContent: notify.NotificationBasicContent = { + title: "test_title", + text: "test_text", + additionalText: "test_Publish" + } + let notifyContent: notify.NotificationContent = { + contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: basicContent + } + + let notifyTemplate: notify.NotificationTemplate = { + name: 'downloadTemplate', + data: { + title: 'file', + fileName: 'music.mp4', + progressValue: 45 + } + } + + let notificationRequest : notify.NotificationRequest = { + content: notifyContent, + template: notifyTemplate, + id: 6 + } + + console.info(`${TAG} SUB_NOTIFICATION_ANS_SECONDARY_DIRECTORY_TEST_0600 PUBLISH`); + try{ + await notify.publish(notificationRequest, (err) => { + if (err) { + console.info(`${TAG} publish AsyncCallback errCode: ${err.code}, errMes: ${err.message}`) + expect(false).assertTrue() + done() + } else { + console.info(`${TAG} publish AsyncCallback success`) + expect(true).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_SECONDARY_DIRECTORY_TEST_0600 END`); + }); + + /* + * @tc.number: SUB_NOTIFICATION_ANS_SECONDARY_DIRECTORY_TEST_0700 + * @tc.name: DistributedOptions + * @tc.desc: use DistributedOptions type + */ + it('SUB_NOTIFICATION_ANS_SECONDARY_DIRECTORY_TEST_0700', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_SECONDARY_DIRECTORY_TEST_0700 START`); + + let options: notify.DistributedOptions = { + isDistributed: false, + supportDisplayDevices: ["0"], + supportOperateDevices: ["0"] + } + + let basicContent: notify.NotificationBasicContent = { + title: "test_title", + text: "test_text", + additionalText: "test_Publish" + } + let notifyContent: notify.NotificationContent = { + contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: basicContent + } + + let notificationRequest : notify.NotificationRequest = { + content: notifyContent, + distributedOption: options, + id: 7 + } + + console.info(`${TAG} SUB_NOTIFICATION_ANS_SECONDARY_DIRECTORY_TEST_0700 PUBLISH`); + try{ + await notify.publish(notificationRequest, (err) => { + if (err) { + console.info(`${TAG} publish AsyncCallback errCode: ${err.code}, errMes: ${err.message}`) + expect(false).assertTrue() + done() + } else { + console.info(`${TAG} publish AsyncCallback success`) + expect(true).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_SECONDARY_DIRECTORY_TEST_0700 END`); + }); + + /* + * @tc.number: SUB_NOTIFICATION_ANS_SECONDARY_DIRECTORY_TEST_0800 + * @tc.name: NotificationBasicContent + * @tc.desc: use NotificationBasicContent type + */ + it('SUB_NOTIFICATION_ANS_SECONDARY_DIRECTORY_TEST_0800', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_SECONDARY_DIRECTORY_TEST_0800 START`); + + let picture_opts = { + size: { + height: 25, + width: 2, + }, + alphaType: 0, + scaleMode: 1, + pixelFormat: 4, + editable: true + } + let notification_picture: image.PixelMap = undefined + let picture_buffer = new ArrayBuffer(picture_opts.size.height * picture_opts.size.width * 4) + await image.createPixelMap(picture_buffer, picture_opts, (err, pixelMap)=>{ + console.info(`${TAG} SUB_NOTIFICATION_ANS_SECONDARY_DIRECTORY_TEST_0800 pixelMap: ${pixelMap}`); + + let longContentPicture: notify.NotificationPictureContent = { + title: "test_title", + text: "test_text", + additionalText: "test_Publish", + briefText: "briefText123456", + expandedTitle: "expandedTitle123456", + picture: pixelMap + } + + let notifyContent: notify.NotificationContent = { + contentType: notify.ContentType.NOTIFICATION_CONTENT_PICTURE, + picture: longContentPicture + } + + let notificationRequest : notify.NotificationRequest = { + content: notifyContent, + id: 3 + } + + console.info(`${TAG} SUB_NOTIFICATION_ANS_SECONDARY_DIRECTORY_TEST_0800 PUBLISH`); + try{ + notify.publish(notificationRequest, (err) => { + if (err) { + console.info(`${TAG} publish AsyncCallback errCode: ${err.code}, errMes: ${err.message}`) + expect(false).assertTrue() + done() + } else { + console.info(`${TAG} publish AsyncCallback success`) + expect(true).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_SECONDARY_DIRECTORY_TEST_0800 END`); + }); + + /* + * @tc.number: SUB_NOTIFICATION_ANS_SECONDARY_DIRECTORY_TEST_0900 + * @tc.name: NotificationMultiLineContent + * @tc.desc: use NotificationMultiLineContent type + */ + it('SUB_NOTIFICATION_ANS_SECONDARY_DIRECTORY_TEST_0900', 0, async function (done) { + console.info(`${TAG} SUB_NOTIFICATION_ANS_SECONDARY_DIRECTORY_TEST_0900 START`); + + try{ + await notify.addSlot(notify.SlotType.SOCIAL_COMMUNICATION, (err) => { + console.info(`${TAG} addSlot success`) + if (err) { + console.info(`${TAG} addSlot err: ${err.code}, errMes: ${err.message}`) + expect(false).assertTrue() + done() + } else { + notify.getSlots().then((NotificationSlot) => { + console.info(`${TAG} getSlots success:` + JSON.stringify(NotificationSlot)) + expect(NotificationSlot[0].type).assertEqual(notify.SlotType.SOCIAL_COMMUNICATION) + done() + }).catch((err) => { + console.info(`${TAG} getSlots failed err: + ${err.code}`) + expect(false).assertTrue() + done() + }) + } + }) + } catch (err) { + console.info(`${TAG} addSlot failed err: ${err.code}, errMes: ${err.message}`) + expect(false).assertTrue() + done() + } + console.info(`${TAG} SUB_NOTIFICATION_ANS_SECONDARY_DIRECTORY_TEST_0900 END`); + }); +}) } \ No newline at end of file diff --git a/notification/ans_standard/actsNotificationSecondaryDirectory/entry/src/main/module.json b/notification/ans_standard/actsNotificationSecondaryDirectory/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..e0d14434366d54a0afa28b8ed327a40e1477e44b --- /dev/null +++ b/notification/ans_standard/actsNotificationSecondaryDirectory/entry/src/main/module.json @@ -0,0 +1,39 @@ +{ + "module": { + "name": "phone", + "type": "entry", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:phone_entry_dsc", + "mainElement": "MainAbility", + "deviceTypes": [ + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "uiSyntax": "ets", + "abilities": [ + { + "name": "com.example.secondaryDirectory.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" + ] + } + ] + } + ] + } + } \ No newline at end of file diff --git a/notification/ans_standard/actsNotificationSecondaryDirectory/entry/src/main/resources/base/element/color.json b/notification/ans_standard/actsNotificationSecondaryDirectory/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..1bbc9aa9617e97c45440e1d3d66afc1154837012 --- /dev/null +++ b/notification/ans_standard/actsNotificationSecondaryDirectory/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/actsNotificationSecondaryDirectory/entry/src/main/resources/base/element/string.json b/notification/ans_standard/actsNotificationSecondaryDirectory/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..4af975ee904d5089633c604a63f3f9bcc3885a3f --- /dev/null +++ b/notification/ans_standard/actsNotificationSecondaryDirectory/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/actsNotificationSecondaryDirectory/entry/src/main/resources/base/media/icon.png b/notification/ans_standard/actsNotificationSecondaryDirectory/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/notification/ans_standard/actsNotificationSecondaryDirectory/entry/src/main/resources/base/media/icon.png differ diff --git a/notification/ans_standard/actsNotificationSecondaryDirectory/entry/src/main/resources/base/profile/form_config.json b/notification/ans_standard/actsNotificationSecondaryDirectory/entry/src/main/resources/base/profile/form_config.json new file mode 100644 index 0000000000000000000000000000000000000000..146fbe1c6da88e46886838ba746afb29e69cc190 --- /dev/null +++ b/notification/ans_standard/actsNotificationSecondaryDirectory/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/actsNotificationSecondaryDirectory/entry/src/main/resources/base/profile/main_pages.json b/notification/ans_standard/actsNotificationSecondaryDirectory/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..81691245bb98976d7d8966dd406a9abd5140ef39 --- /dev/null +++ b/notification/ans_standard/actsNotificationSecondaryDirectory/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/actsNotificationSecondaryDirectory/signature/openharmony_sx.p7b b/notification/ans_standard/actsNotificationSecondaryDirectory/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/notification/ans_standard/actsNotificationSecondaryDirectory/signature/openharmony_sx.p7b differ