diff --git a/ability/ability_runtime/BUILD.gn b/ability/ability_runtime/BUILD.gn index b75f96a6819ed73357bf3fe98b0d7d849cdb2469..5b9daed008aa1c92f642532d5e29ecd98e4c2989 100644 --- a/ability/ability_runtime/BUILD.gn +++ b/ability/ability_runtime/BUILD.gn @@ -35,6 +35,7 @@ group("ability_runtime") { "actsstartrunnertest:ActsStartRunnerTest", "actsstserviceabilityclientcase:ActsStServiceAbilityClientCaseTest", "actssupportfunction:actssupportfunction", + "actssystemapitest:ActsSystemAPITest", "actsusers:actsusers", "amscontextualinforquery:amscontextualinforquery", "amsdatauriutils:ActsAmsDataUriUtilsTest", diff --git a/ability/ability_runtime/actssystemapitest/AppScope/app.json b/ability/ability_runtime/actssystemapitest/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..1b07e263bc09fea1c51f0e04588dd42d5aee0c95 --- /dev/null +++ b/ability/ability_runtime/actssystemapitest/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app": { + "bundleName": "com.acts.systemapitest", + "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/ability/ability_runtime/actssystemapitest/AppScope/resources/base/element/string.json b/ability/ability_runtime/actssystemapitest/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..ec48a8748ea2b8c0babde132baba30c5503a0918 --- /dev/null +++ b/ability/ability_runtime/actssystemapitest/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "AbilityStageMonitor" + } + ] +} diff --git a/ability/ability_runtime/actssystemapitest/AppScope/resources/base/media/app_icon.png b/ability/ability_runtime/actssystemapitest/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/actssystemapitest/AppScope/resources/base/media/app_icon.png differ diff --git a/ability/ability_runtime/actssystemapitest/BUILD.gn b/ability/ability_runtime/actssystemapitest/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..db6eaf17dbe1b8ef9cba9c60f9bcc54247a62b33 --- /dev/null +++ b/ability/ability_runtime/actssystemapitest/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("ActsSystemAPITest") { + hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" + deps = [ + ":systemapi_js_assets", + ":systemapi_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsSystemAPITest" + subsystem_name = "ability" + part_name = "ability_runtime" +} + +ohos_app_scope("systemapi_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("systemapi_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("systemapi_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":systemapi_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/ability/ability_runtime/actssystemapitest/Test.json b/ability/ability_runtime/actssystemapitest/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..f77bc7f9e34b99f6d585d00ff4b872aa0d16329c --- /dev/null +++ b/ability/ability_runtime/actssystemapitest/Test.json @@ -0,0 +1,21 @@ +{ + "description": "Configuration for aceceshi Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "600000", + "bundle-name": "com.acts.systemapitest", + "module-name": "entry_test", + "shell-timeout": "600000", + "testcase-timeout": "15000" + }, + "kits": [ + { + "test-file-name": [ + "ActsSystemAPITest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} + diff --git a/ability/ability_runtime/actssystemapitest/entry/src/main/ets/Application/MyAbilityStage.ts b/ability/ability_runtime/actssystemapitest/entry/src/main/ets/Application/MyAbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..8a0fce1233f517b4baa8396228da2b63de8f91e2 --- /dev/null +++ b/ability/ability_runtime/actssystemapitest/entry/src/main/ets/Application/MyAbilityStage.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.info("MyAbilityStageMonitor onCreate"); + globalThis.abilityStageContext = this.context; + } +} \ No newline at end of file diff --git a/ability/ability_runtime/actssystemapitest/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/actssystemapitest/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..05cf527b8846a58dbb391a778f51ae9939ebc53e --- /dev/null +++ b/ability/ability_runtime/actssystemapitest/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,60 @@ +/* + * 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' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from '../test/List.test' + +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("ActsSystemAPITest MainAbility onCreate"); + globalThis.abilityWant = want; + globalThis.abilityContext = this.context; + let abilityDelegator: any; + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); + let abilityDelegatorArguments: any; + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments(); + console.info('start run testcase!!!'); + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite); + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("ActsSystemAPITest MainAbility onDestroy"); + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("ActsSystemAPITest MainAbility onWindowStageCreate"); + windowStage.setUIContent(this.context, "pages/index/index", null); + console.log("ActsSystemAPITest MainAbility onWindowStageCreate finish"); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("ActsSystemAPITest MainAbility onWindowStageDestroy"); + } + + onForeground() { + // Ability has brought to foreground + console.log("ActsSystemAPITest MainAbility onForeground"); + } + + onBackground() { + // Ability has back to background + console.log("ActsSystemAPITest MainAbility onBackground"); + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/actssystemapitest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/ability/ability_runtime/actssystemapitest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..5e01ca05951b9353c9d8bfa787c7c876a3651f3f --- /dev/null +++ b/ability/ability_runtime/actssystemapitest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,75 @@ +/* +* 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' + +let abilityDelegator = undefined +let 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() + globalThis.abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + let testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility' + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + let cmd = 'aa start -d 0 -a MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + 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/ability/ability_runtime/actssystemapitest/entry/src/main/ets/pages/index/index.ets b/ability/ability_runtime/actssystemapitest/entry/src/main/ets/pages/index/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..43fab984f04e6394fbaad746e09ea1735b49f605 --- /dev/null +++ b/ability/ability_runtime/actssystemapitest/entry/src/main/ets/pages/index/index.ets @@ -0,0 +1,44 @@ +/* + * 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. + */ + + +@Entry +@Component +struct Index { + aboutToAppear(){ + } + + build() { + Flex({ direction:FlexDirection.Column, alignItems:ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('MainAbility Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/actssystemapitest/entry/src/main/ets/test/AbilityContext.test.ets b/ability/ability_runtime/actssystemapitest/entry/src/main/ets/test/AbilityContext.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..4aef6e4f7982c9d929737d447ed46311fc8b2bdf --- /dev/null +++ b/ability/ability_runtime/actssystemapitest/entry/src/main/ets/test/AbilityContext.test.ets @@ -0,0 +1,486 @@ +/* + * 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, it, expect } from '@ohos/hypium' +import image from '@ohos.multimedia.image' + +let ERROR_CODE = 202; +let context; +export default function abilityContextTest() { + describe('abilityContextTest', function () { + beforeAll(function () { + context = globalThis.abilityContext; + }) + + /** + * @tc.number: System_API_Test_AbilityContext_0100 + * @tc.name: callback form startAbilityWithAccount system interface interception test + * @tc.desc: Test third-party applications calling startAbilityWithAccount will be blocked + * @tc.level 3 + */ + it('System_API_Test_AbilityContext_0100', 0, function (done) { + let TAG = 'System_API_Test_AbilityContext_0100'; + let want = { + abilityName: "aaa", + bundleName: "bbb" + } + let account = 110; + context.startAbilityWithAccount(want, account, (error) => { + if (error.code) { + console.log(TAG + " error: " + error.code + ", " + error.message); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } + }) + }) + + /** + * @tc.number: System_API_Test_AbilityContext_0200 + * @tc.name: Multi-parameter startAbilityWithAccount system interface interception test in the form of callback + * @tc.desc: Test third-party applications calling startAbilityWithAccount will be blocked + * @tc.level 3 + */ + it('System_API_Test_AbilityContext_0200', 0, function (done) { + let TAG = 'System_API_Test_AbilityContext_0200'; + let want = { + abilityName: "aaa", + bundleName: "bbb" + } + let account = 110; + let options = { + windowMode: 0 + }; + context.startAbilityWithAccount(want, account, options, (error) => { + if (error.code) { + console.log(TAG + " error: " + error.code + ", " + error.message); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } + }) + }) + + /** + * @tc.number: System_API_Test_AbilityContext_0300 + * @tc.name: The promise form startAbilityWithAccount system interface interception test + * @tc.desc: Test third-party applications calling startAbilityWithAccount will be blocked + * @tc.level 3 + */ + it('System_API_Test_AbilityContext_0300', 0, function (done) { + let TAG = 'System_API_Test_AbilityContext_0300'; + let want = { + abilityName: "aaa", + bundleName: "bbb" + } + let account = 110; + context.startAbilityWithAccount(want, account) + .then(() => { }) + .catch(error => { + console.log(TAG + " error: " + error.code + ", " + error.message); + expect(error.code).assertEqual(ERROR_CODE); + done(); + }) + }) + + /** + * @tc.number: System_API_Test_AbilityContext_0400 + * @tc.name: Multiple input arguments in the form of promise, startAbilityWithAccount system interface interception test + * @tc.desc: Test third-party applications calling startAbilityWithAccount will be blocked + * @tc.level 3 + */ + it('System_API_Test_AbilityContext_0400', 0, function (done) { + let TAG = 'System_API_Test_AbilityContext_0400'; + let want = { + abilityName: "aaa", + bundleName: "bbb" + } + let account = 110; + let options = { + windowMode: 0 + }; + context.startAbilityWithAccount(want, account, options) + .then(() => { }) + .catch(error => { + console.log(TAG + " error: " + error.code + ", " + error.message); + expect(error.code).assertEqual(ERROR_CODE); + done(); + }) + }) + + /** + * @tc.number: System_API_Test_AbilityContext_0500 + * @tc.name: callback form startAbilityForResultWithAccount system interface interception test + * @tc.desc: Test the third-party application call startAbilityForResultWithAccount will be blocked + * @tc.level 3 + */ + it('System_API_Test_AbilityContext_0500', 0, function (done) { + let TAG = 'System_API_Test_AbilityContext_0500'; + let want = { + abilityName: "aaa", + bundleName: "bbb" + } + let account = 110; + try { + context.startAbilityForResultWithAccount(want, account, (error) => { + + }) + } catch (error) { + console.log(TAG + " error: " + error.code + ", " + error.message); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } + }) + + /** + * @tc.number: System_API_Test_AbilityContext_0600 + * @tc.name: Multi-parameter startAbilityForResultWithAccount system interface interception test in the form of callback + * @tc.desc: Test the third-party application call startAbilityForResultWithAccount will be blocked + * @tc.level 3 + */ + it('System_API_Test_AbilityContext_0600', 0, function (done) { + let TAG = 'System_API_Test_AbilityContext_0600'; + let want = { + abilityName: "aaa", + bundleName: "bbb" + } + let account = 110; + let options = { + windowMode: 0 + }; + try { + context.startAbilityForResultWithAccount(want, account, options, (error) => { + + }) + } catch (error) { + console.log(TAG + " error: " + error.code + ", " + error.message); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } + }) + + /** + * @tc.number: System_API_Test_AbilityContext_0700 + * @tc.name: promise form startAbilityForResultWithAccount system interface interception test + * @tc.desc: Test the third-party application call startAbilityForResultWithAccount will be blocked + * @tc.level 3 + */ + it('System_API_Test_AbilityContext_0700', 0, function (done) { + let TAG = 'System_API_Test_AbilityContext_0700'; + let want = { + abilityName: "aaa", + bundleName: "bbb" + } + let account = 110; + try { + context.startAbilityForResultWithAccount(want, account) + .then(() => { }) + .catch(error => { + + }) + } catch (error) { + console.log(TAG + " error: " + error.code + ", " + error.message); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } + }) + + /** + * @tc.number: System_API_Test_AbilityContext_0800 + * @tc.name: Multi-parameter startAbilityForResultWithAccount system interface interception test in the form of promise + * @tc.desc: Test the third-party application call startAbilityForResultWithAccount will be blocked + * @tc.level 3 + */ + it('System_API_Test_AbilityContext_0800', 0, function (done) { + let TAG = 'System_API_Test_AbilityContext_0800'; + let want = { + abilityName: "aaa", + bundleName: "bbb" + } + let account = 110; + let options = { + windowMode: 0 + }; + try { + context.startAbilityForResultWithAccount(want, account, options) + .then(() => { }) + .catch(error => { + + }) + } catch (error) { + console.log(TAG + " error: " + error.code + ", " + error.message); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } + }) + + /** + * @tc.number: System_API_Test_AbilityContext_0900 + * @tc.name: callback form startServiceExtensionAbility system interface interception test + * @tc.desc: Test the third-party application call startServiceExtensionAbility will be blocked + * @tc.level 3 + */ + it('System_API_Test_AbilityContext_0900', 0, function (done) { + let TAG = 'System_API_Test_AbilityContext_0900'; + let want = { + abilityName: "aaa", + bundleName: "bbb" + } + context.startServiceExtensionAbility(want, (error) => { + if (error.code) { + console.log(TAG + " error: " + error.code + ", " + error.message); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } + }) + }) + + /** + * @tc.number: System_API_Test_AbilityContext_1000 + * @tc.name: promise form startServiceExtensionAbility system interface interception test + * @tc.desc: Test the third-party application call startServiceExtensionAbility will be blocked + * @tc.level 3 + */ + it('System_API_Test_AbilityContext_1000', 0, function (done) { + let TAG = 'System_API_Test_AbilityContext_1000'; + let want = { + abilityName: "aaa", + bundleName: "bbb" + } + context.startServiceExtensionAbility(want) + .then(() => { }) + .catch(error => { + console.log(TAG + " error: " + error.code + ", " + error.message); + expect(error.code).assertEqual(ERROR_CODE); + done(); + }) + }) + + /** + * @tc.number: System_API_Test_AbilityContext_1100 + * @tc.name: callback form startServiceExtensionAbilityWithAccount system interface interception test + * @tc.desc: Test the third-party application call startServiceExtensionAbilityWithAccount will be blocked + * @tc.level 3 + */ + it('System_API_Test_AbilityContext_1100', 0, function (done) { + let TAG = 'System_API_Test_AbilityContext_1100'; + let want = { + abilityName: "aaa", + bundleName: "bbb" + } + let account = 110; + context.startServiceExtensionAbilityWithAccount(want, account, (error) => { + if (error.code) { + console.log(TAG + " error: " + error.code + ", " + error.message); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } + }) + }) + + /** + * @tc.number: System_API_Test_AbilityContext_1200 + * @tc.name: promise form startServiceExtensionAbilityWithAccount system interface interception test + * @tc.desc: Test the third-party application call startServiceExtensionAbilityWithAccount will be blocked + * @tc.level 3 + */ + it('System_API_Test_AbilityContext_1200', 0, function (done) { + let TAG = 'System_API_Test_AbilityContext_1200'; + let want = { + abilityName: "aaa", + bundleName: "bbb" + } + let account = 110; + context.startServiceExtensionAbilityWithAccount(want, account) + .then(() => { }) + .catch(error => { + console.log(TAG + " error: " + error.code + ", " + error.message); + expect(error.code).assertEqual(ERROR_CODE); + done(); + }) + }) + + /** + * @tc.number: System_API_Test_AbilityContext_1300 + * @tc.name: callback form stopServiceExtensionAbility system interface interception test + * @tc.desc: Test the third-party application call stopServiceExtensionAbility will be blocked + * @tc.level 3 + */ + it('System_API_Test_AbilityContext_1300', 0, function (done) { + let TAG = 'System_API_Test_AbilityContext_1300'; + let want = { + abilityName: "aaa", + bundleName: "bbb" + } + context.stopServiceExtensionAbility(want, (error) => { + if (error.code) { + console.log(TAG + " error: " + error.code + ", " + error.message); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } + }) + }) + + /** + * @tc.number: System_API_Test_AbilityContext_1400 + * @tc.name: promise form stopServiceExtensionAbility system interface interception test + * @tc.desc: Test the third-party application call stopServiceExtensionAbility will be blocked + * @tc.level 3 + */ + it('System_API_Test_AbilityContext_1400', 0, function (done) { + let TAG = 'System_API_Test_AbilityContext_1400'; + let want = { + abilityName: "aaa", + bundleName: "bbb" + } + context.stopServiceExtensionAbility(want) + .then(() => { }) + .catch(error => { + console.log(TAG + " error: " + error.code + ", " + error.message); + expect(error.code).assertEqual(ERROR_CODE); + done(); + }) + }) + + /** + * @tc.number: System_API_Test_AbilityContext_1500 + * @tc.name: calback form stopServiceExtensionAbilityWithAccount system interface interception test + * @tc.desc: Test the third-party application call stopServiceExtensionAbilityWithAccount will be blocked + * @tc.level 3 + */ + it('System_API_Test_AbilityContext_1500', 0, function (done) { + let TAG = 'System_API_Test_AbilityContext_1500'; + let want = { + abilityName: "aaa", + bundleName: "bbb" + } + let account = 110; + context.stopServiceExtensionAbilityWithAccount(want, account, (error) => { + if (error.code) { + console.log(TAG + " error: " + error.code + ", " + error.message); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } + }) + }) + + /** + * @tc.number: System_API_Test_AbilityContext_1600 + * @tc.name: promise form stopServiceExtensionAbilityWithAccount system interface interception test + * @tc.desc: Test the third-party application call stopServiceExtensionAbilityWithAccount will be blocked + * @tc.level 3 + */ + it('System_API_Test_AbilityContext_1600', 0, function (done) { + let TAG = 'System_API_Test_AbilityContext_1600'; + let want = { + abilityName: "aaa", + bundleName: "bbb" + } + let account = 110; + context.stopServiceExtensionAbilityWithAccount(want, account) + .then(() => { + expect().assertFail(); + done(); + }) + .catch(error => { + console.log(TAG + " error: " + error.code + ", " + error.message); + expect(error.code).assertEqual(ERROR_CODE); + done(); + }) + }) + + /** + * @tc.number: System_API_Test_AbilityContext_1700 + * @tc.name: promise form connectServiceExtensionAbilityWithAccount system interface interception test + * @tc.desc: Test the third-party application call connectServiceExtensionAbilityWithAccount will be blocked + * @tc.level 3 + */ + it('System_API_Test_AbilityContext_1700', 0, function (done) { + let TAG = 'System_API_Test_AbilityContext_1700'; + let want = { + abilityName: "aaa", + bundleName: "bbb" + } + let accountId = 110; + let options = { + onConnect(elementName, remote) { console.log('----------- onConnect -----------') }, + onDisconnect(elementName) { console.log('----------- onDisconnect -----------') }, + onFailed(code) { + console.log(TAG + " error: " + code); + expect(code).assertEqual(ERROR_CODE); + done(); + } + } + + try { + context.connectServiceExtensionAbilityWithAccount(want, accountId, options); + } catch (paramError) { + console.log('error.code: ' + JSON.stringify(paramError.code) + + ' error.message: ' + JSON.stringify(paramError.message)); + } + }) + + /** + * @tc.number: System_API_Test_AbilityContext_1800 + * @tc.name: callback form setMissionIcon system interface interception test + * @tc.desc: Test the third-party application call setMissionIcon will be blocked + * @tc.level 3 + */ + it('System_API_Test_AbilityContext_1800', 0, async function (done) { + let TAG = 'System_API_Test_AbilityContext_1800'; + + const color = new ArrayBuffer(96); + let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }; + image.createPixelMap(color, opts).then((pixelmap) => { + console.log(TAG + ' Succeeded in creating pixelmap.'); + context.setMissionIcon(pixelmap, (error) => { + console.log(TAG + ' ---------- setMissionIcon fail, err: -----------', error); + if (error.code) { + console.log(TAG + " error: " + error.code + ", " + error.message); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } + }) + }).catch(error => { + console.log(TAG + ' Failed to create pixelmap.'); + }) + }) + + /** + * @tc.number: System_API_Test_AbilityContext_1900 + * @tc.name: promise form setMissionIcon system interface interception test + * @tc.desc: Test the third-party application call setMissionIcon will be blocked + * @tc.level 3 + */ + it('System_API_Test_AbilityContext_1900', 0, function (done) { + let TAG = 'System_API_Test_AbilityContext_1900'; + const color = new ArrayBuffer(96); + let bufferArr = new Uint8Array(color); + let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }; + image.createPixelMap(color, opts).then((pixelmap) => { + console.log(TAG + ' Succeeded in creating pixelmap.'); + context.setMissionIcon(pixelmap) + .then(() => { + console.log('-------------- setMissionIcon success -------------'); + }) + .catch((error) => { + console.log(TAG + " error: " + error.code + ", " + error.message); + expect(error.code).assertEqual(ERROR_CODE); + done(); + }); + }).catch(error => { + console.log(TAG + ' Failed to create pixelmap.'); + }) + }) + }) +} \ No newline at end of file diff --git a/ability/ability_runtime/actssystemapitest/entry/src/main/ets/test/AbilityManager.test.ets b/ability/ability_runtime/actssystemapitest/entry/src/main/ets/test/AbilityManager.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..b977417975d9d9f7b6ed9672526a056ebd53bd7c --- /dev/null +++ b/ability/ability_runtime/actssystemapitest/entry/src/main/ets/test/AbilityManager.test.ets @@ -0,0 +1,175 @@ +/* + * 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, it, expect } from '@ohos/hypium' +import abilityManager from "@ohos.app.ability.abilityManager" + +let ERROR_CODE = 202; +export default function abilityManagerTest() { + describe('abilityManagerTest', function () { + + /** + * @tc.number: System_API_Test_Ability_Manager_0100 + * @tc.name: callback form updateConfiguration system interface interception test + * @tc.desc: Test the third-party application call updateConfiguration will be blocked + * @tc.level 3 + */ + it('System_API_Test_Ability_Manager_0100', 0, function (done) { + let TAG = 'System_API_Test_Ability_Manager_0100'; + let configInit = { + language: 'english' + } + abilityManager.updateConfiguration(configInit, (err) => { + console.log(TAG + " err.code: " + err.code); + expect(err.code).assertEqual(ERROR_CODE); + done(); + }); + }) + + /** + * @tc.number: System_API_Test_Ability_Manager_0200 + * @tc.name: promise form updateConfiguration system interface interception test + * @tc.desc: Test the third-party application call updateConfiguration will be blocked + * @tc.level 3 + */ + it('System_API_Test_Ability_Manager_0200', 0, function (done) { + let TAG = 'System_API_Test_Ability_Manager_0200'; + let configInit = { + language: 'english' + } + abilityManager.updateConfiguration(configInit) + .then(err => { + console.log(TAG + ` err->${JSON.stringify(err)}`); + expect().assertFail(); + done(); + }) + .catch(err => { + console.log(TAG + " err.code: " + err.code); + expect(err.code).assertEqual(ERROR_CODE); + done(); + }) + }) + + /** + * @tc.number: System_API_Test_Ability_Manager_0300 + * @tc.name: callback form getAbilityRunningInfos system interface interception test + * @tc.desc: Test the third-party application call getAbilityRunningInfos will be blocked + * @tc.level 3 + */ + it('System_API_Test_Ability_Manager_0300', 0, function (done) { + let TAG = 'System_API_Test_Ability_Manager_0300'; + abilityManager.getAbilityRunningInfos((err) => { + console.log(TAG + " err.code: " + err.code); + expect(err.code).assertEqual(ERROR_CODE); + done(); + }); + }) + + /** + * @tc.number: System_API_Test_Ability_Manager_0400 + * @tc.name: promise form getAbilityRunningInfos system interface interception test + * @tc.desc: Test the third-party application call getAbilityRunningInfos will be blocked + * @tc.level 3 + */ + it('System_API_Test_Ability_Manager_0400', 0, function (done) { + let TAG = 'System_API_Test_Ability_Manager_0400'; + abilityManager.getAbilityRunningInfos() + .then(err => { + console.log(TAG + ` err->${JSON.stringify(err)}`); + expect().assertFail(); + done(); + }) + .catch(err => { + console.log(TAG + " err.code: " + err.code); + expect(err.code).assertEqual(ERROR_CODE); + done(); + }) + }) + + /** + * @tc.number: System_API_Test_Ability_Manager_0500 + * @tc.name: callback form getExtensionRunningInfos system interface interception test + * @tc.desc: Test the third-party application call getExtensionRunningInfos will be blocked + * @tc.level 3 + */ + it('System_API_Test_Ability_Manager_0500', 0, function (done) { + let TAG = 'System_API_Test_Ability_Manager_0500'; + let upperLimit = 10; + abilityManager.getExtensionRunningInfos(upperLimit, (err) => { + console.log(TAG + " err.code: " + err.code); + expect(err.code).assertEqual(ERROR_CODE); + done(); + }); + }) + + /** + * @tc.number: System_API_Test_Ability_Manager_0600 + * @tc.name: promise form getExtensionRunningInfos system interface interception test + * @tc.desc: Test the third-party application call getExtensionRunningInfos will be blocked + * @tc.level 3 + */ + it('System_API_Test_Ability_Manager_0600', 0, function (done) { + let TAG = 'System_API_Test_Ability_Manager_0600'; + let upperLimit = 10; + abilityManager.getExtensionRunningInfos(upperLimit) + .then(err => { + console.log(TAG + ` err->${JSON.stringify(err)}`); + expect().assertFail(); + done(); + }) + .catch(err => { + console.log(TAG + " err.code: " + err.code); + expect(err.code).assertEqual(ERROR_CODE); + done(); + }) + }) + + /** + * @tc.number: System_API_Test_Ability_Manager_0700 + * @tc.name: callback form getTopAbility system interface interception test + * @tc.desc: Test the third-party application call getTopAbility will be blocked + * @tc.level 3 + */ + it('System_API_Test_Ability_Manager_0700', 0, function (done) { + let TAG = 'System_API_Test_Ability_Manager_0700'; + try { + abilityManager.getTopAbility((data) => { + + }); + } catch (error) { + console.log(TAG + " err.code: " + error.code); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } + }) + + /** + * @tc.number: System_API_Test_Ability_Manager_0800 + * @tc.name: promise form getTopAbility system interface interception test + * @tc.desc: Test the third-party application call getTopAbility will be blocked + * @tc.level 3 + */ + it('System_API_Test_Ability_Manager_0800', 0, function (done) { + let TAG = 'System_API_Test_Ability_Manager_0800'; + try { + abilityManager.getTopAbility().then().catch(); + } catch (error) { + console.log(TAG + " err.code: " + error.code); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } + }) + }) +} \ No newline at end of file diff --git a/ability/ability_runtime/actssystemapitest/entry/src/main/ets/test/AppManager.test.ets b/ability/ability_runtime/actssystemapitest/entry/src/main/ets/test/AppManager.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..525265325b9f7a9626754d95c4a7bf400f93ee5a --- /dev/null +++ b/ability/ability_runtime/actssystemapitest/entry/src/main/ets/test/AppManager.test.ets @@ -0,0 +1,246 @@ +/* + * 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, it, expect } from '@ohos/hypium' +import appManager from "@ohos.app.ability.appManager" + +let ERROR_CODE = 202; +export default function appManagerTest() { + describe('appManagerTest', function () { + + /** + * @tc.number: System_API_Test_App_Manager_0100 + * @tc.name: appManager.on system interface interception test + * @tc.desc: Test the third-party application call appManager.on will be blocked + * @tc.level 3 + */ + it('System_API_Test_App_Manager_0100',0, function (done) { + let TAG = 'System_API_Test_App_Manager_0100'; + let applicationStateObserver = { + onForegroundApplicationChanged(appStateData) { + console.log(TAG + '------------ onForegroundApplicationChanged -----------', appStateData); + }, + onAbilityStateChanged(abilityStateData) { + console.log(TAG + '------------ onAbilityStateChanged -----------', abilityStateData); + }, + onProcessCreated(processData) { + console.log(TAG + '------------ onProcessCreated -----------', processData); + }, + onProcessDied(processData) { + console.log(TAG + '------------ onProcessDied -----------', processData); + }, + onProcessStateChanged(processData) { + console.log(TAG + '------------ onProcessStateChanged -----------', processData); + } + } + try { + const observerCode = appManager.on("applicationState", applicationStateObserver); + console.log('-------- observerCode: ---------', observerCode); + } catch (err) { + console.log(TAG + " err.code: " + err.code); + expect(err.code).assertEqual(ERROR_CODE); + done(); + } + }) + + /** + * @tc.number: System_API_Test_App_Manager_0200 + * @tc.name: Multi-parameter appManager.on system interface interception test + * @tc.desc: Test the third-party application call appManager.on will be blocked + * @tc.level 3 + */ + it('System_API_Test_App_Manager_0200',0, function (done) { + let TAG = 'System_API_Test_App_Manager_0200'; + let applicationStateObserver = { + onForegroundApplicationChanged(appStateData) { + console.log(TAG + '------------ onForegroundApplicationChanged -----------', appStateData); + }, + onAbilityStateChanged(abilityStateData) { + console.log(TAG + '------------ onAbilityStateChanged -----------', abilityStateData); + }, + onProcessCreated(processData) { + console.log(TAG + '------------ onProcessCreated -----------', processData); + }, + onProcessDied(processData) { + console.log(TAG + '------------ onProcessDied -----------', processData); + }, + onProcessStateChanged(processData) { + console.log(TAG + '------------ onProcessStateChanged -----------', processData); + } + } + let bundleNameList = ['bundleName1', 'bundleName2']; + try { + const observerCode = appManager.on("applicationState", applicationStateObserver, bundleNameList); + console.log('-------- observerCode: ---------', observerCode); + } catch (err) { + console.log(TAG + " err.code: " + err.code); + expect(err.code).assertEqual(ERROR_CODE); + done(); + } + }) + + /** + * @tc.number: System_API_Test_App_Manager_0300 + * @tc.name: callback form getForegroundApplications system interface interception test + * @tc.desc: Test the third-party application call getForegroundApplications will be blocked + * @tc.level 3 + */ + it('System_API_Test_App_Manager_0300',0, function (done) { + let TAG = 'System_API_Test_App_Manager_0300'; + appManager.getForegroundApplications((err) => { + console.log(TAG + " err.code: " + err.code); + expect(err.code).assertEqual(ERROR_CODE); + done(); + }); + }) + + /** + * @tc.number: System_API_Test_App_Manager_0400 + * @tc.name: promise form getForegroundApplications system interface interception test + * @tc.desc: Test the third-party application call getForegroundApplications will be blocked + * @tc.level 3 + */ + it('System_API_Test_App_Manager_0400',0, function (done) { + let TAG = 'System_API_Test_App_Manager_0400'; + appManager.getForegroundApplications() + .then(err => { + console.log(TAG + ` err->${JSON.stringify(err)}`); + expect().assertFail(); + done(); + }) + .catch(err => { + console.log(TAG + " err.code: " + err.code); + expect(err.code).assertEqual(ERROR_CODE); + done(); + }) + }) + + /** + * @tc.number: System_API_Test_App_Manager_0500 + * @tc.name: callback form killProcessWithAccount system interface interception test + * @tc.desc: Test the third-party application call killProcessWithAccount will be blocked + * @tc.level 3 + */ + it('System_API_Test_App_Manager_0500',0, function (done) { + let TAG = 'System_API_Test_App_Manager_0500'; + let bundleName = "com.ohos.application"; + let accountId = 100; + appManager.killProcessWithAccount(bundleName, accountId, (err) => { + console.log(TAG + " err.code: " + err.code); + expect(err.code).assertEqual(ERROR_CODE); + done(); + }); + }) + + /** + * @tc.number: System_API_Test_App_Manager_0600 + * @tc.name: promise form killProcessWithAccount system interface interception test + * @tc.desc: Test the third-party application call killProcessWithAccount will be blocked + * @tc.level 3 + */ + it('System_API_Test_App_Manager_0600',0, function (done) { + let TAG = 'System_API_Test_App_Manager_0600'; + let bundleName = "com.ohos.application"; + let accountId = 100; + appManager.killProcessWithAccount(bundleName, accountId) + .then(err => { + console.log(TAG + ` err->${JSON.stringify(err)}`); + expect().assertFail(); + done(); + }) + .catch(err => { + console.log(TAG + " err.code: " + err.code); + expect(err.code).assertEqual(ERROR_CODE); + done(); + }) + }) + + /** + * @tc.number: System_API_Test_App_Manager_0700 + * @tc.name: callback form killProcessesByBundleName system interface interception test + * @tc.desc: Test the third-party application call killProcessesByBundleName will be blocked + * @tc.level 3 + */ + it('System_API_Test_App_Manager_0700',0, function (done) { + let TAG = 'System_API_Test_App_Manager_0700'; + let bundleName = "com.ohos.application"; + appManager.killProcessesByBundleName(bundleName, (err) => { + console.log(TAG + " err.code: " + err.code); + expect(err.code).assertEqual(ERROR_CODE); + done(); + }); + }) + + /** + * @tc.number: System_API_Test_App_Manager_0800 + * @tc.name: promise form killProcessesByBundleName system interface interception test + * @tc.desc: Test the third-party application call killProcessesByBundleName will be blocked + * @tc.level 3 + */ + it('System_API_Test_App_Manager_0800',0, function (done) { + let TAG = 'System_API_Test_App_Manager_0800'; + let bundleName = "com.ohos.application"; + appManager.killProcessesByBundleName(bundleName) + .then(err => { + console.log(TAG + ` err->${JSON.stringify(err)}`); + expect().assertFail(); + done(); + }) + .catch(err => { + console.log(TAG + " err.code: " + err.code); + expect(err.code).assertEqual(ERROR_CODE); + done(); + }) + }) + + /** + * @tc.number: System_API_Test_App_Manager_0900 + * @tc.name: callback form clearUpApplicationData system interface interception test + * @tc.desc: Test the third-party application call clearUpApplicationData will be blocked + * @tc.level 3 + */ + it('System_API_Test_App_Manager_0900',0, function (done) { + let TAG = 'System_API_Test_App_Manager_0900'; + let bundleName = "com.ohos.application"; + appManager.clearUpApplicationData(bundleName, (err) => { + console.log(TAG + " err.code: " + err.code); + expect(err.code).assertEqual(ERROR_CODE); + done(); + }); + }) + + /** + * @tc.number: System_API_Test_App_Manager_1000 + * @tc.name: promise form clearUpApplicationData system interface interception test + * @tc.desc: Test the third-party application call clearUpApplicationData will be blocked + * @tc.level 3 + */ + it('System_API_Test_App_Manager_1000',0, function (done) { + let TAG = 'System_API_Test_App_Manager_1000'; + let bundleName = "com.ohos.application"; + appManager.clearUpApplicationData(bundleName) + .then(err => { + console.log(TAG + ` err->${JSON.stringify(err)}`); + expect().assertFail(); + done(); + }) + .catch(err => { + console.log(TAG + " err.code: " + err.code); + expect(err.code).assertEqual(ERROR_CODE); + done(); + }) + }) + }) +} \ No newline at end of file diff --git a/ability/ability_runtime/actssystemapitest/entry/src/main/ets/test/Context.test.ets b/ability/ability_runtime/actssystemapitest/entry/src/main/ets/test/Context.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..5ae9d81615dba2bd372a7ca7254f0ac55f15ecce --- /dev/null +++ b/ability/ability_runtime/actssystemapitest/entry/src/main/ets/test/Context.test.ets @@ -0,0 +1,64 @@ +/* + * 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, it, expect } from '@ohos/hypium' + +let ERROR_CODE = 202; +let context; +export default function contextTest() { + describe('contextTest', function () { + beforeAll(function () { + context = globalThis.abilityContext; + }) + + /** + * @tc.number: System_API_Test_Context_0100 + * @tc.name: callback form createBundleContext system interface interception test + * @tc.desc: Test the third-party application call createBundleContext will be blocked + * @tc.level 3 + */ + it('System_API_Test_Context_0100',0, function (done) { + let TAG = 'System_API_Test_Context_0100'; + console.log(`${TAG} context : ${context}`); + try { + let bundleName = "aaa"; + context.createBundleContext(bundleName); + } catch (error) { + console.log(TAG + " error: " + error.code + ", " + error.message); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } + }) + + /** + * @tc.number: System_API_Test_Context_0200 + * @tc.name: promise form createBundleContext system interface interception test + * @tc.desc: Test the third-party application call createBundleContext will be blocked + * @tc.level 3 + */ + it('System_API_Test_Context_0200',0, function (done) { + let TAG = 'System_API_Test_Context_0200'; + try { + let bundleName = "aaa"; + let moduleName = "aaa"; + context.createModuleContext(bundleName, moduleName); + } catch (error) { + console.log(TAG + " error: " + error.code + ", " + error.message); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } + }) + }) +} \ No newline at end of file diff --git a/ability/ability_runtime/actssystemapitest/entry/src/main/ets/test/FormHost.test.ets b/ability/ability_runtime/actssystemapitest/entry/src/main/ets/test/FormHost.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..85f21a189c18e65c773f9aa2ed417bf81f1f6818 --- /dev/null +++ b/ability/ability_runtime/actssystemapitest/entry/src/main/ets/test/FormHost.test.ets @@ -0,0 +1,997 @@ +/* + * 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, it, expect } from '@ohos/hypium' +import formHost from '@ohos.app.form.formHost' + +let ERROR_CODE = 16500101; +export default function formHostTest() { + describe('formHostTest', function () { + + /** + * @tc.number: System_API_Test_Form_Host_0100 + * @tc.name: callback form deleteForm system interface interception test + * @tc.desc: Test the third-party application call deleteForm will be blocked + * @tc.level 3 + */ + it('System_API_Test_Form_Host_0100',0, async function (done) { + let TAG = 'System_API_Test_Form_Host_0100'; + console.log(TAG + ' formHost deleteForm BEGIN'); + try { + let formId = "12400633174999288"; + formHost.deleteForm(formId, (error, data) => { + if (error) { + console.log(TAG + ' formHost deleteForm, error:' + JSON.stringify(error.code)); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } else { + console.log(TAG + ' formHost deleteForm success'); + } + }); + } catch (error) { + console.log(`catch err->${JSON.stringify(error)}`); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } + }) + + /** + * @tc.number: System_API_Test_Form_Host_0200 + * @tc.name: promise form deleteForm system interface interception test + * @tc.desc: Test the third-party application call deleteForm will be blocked + * @tc.level 3 + */ + it('System_API_Test_Form_Host_0200',0, async function (done) { + let TAG = 'System_API_Test_Form_Host_0200'; + try { + let formId = "12400633174999288"; + formHost.deleteForm(formId) + .then(() => { + expect().assertFail(); + done(); + }) + .catch((error) => { + console.log(TAG + ' formHost deleteForm, error:' + JSON.stringify(error)); + expect(error.code).assertEqual(ERROR_CODE); + done(); + }) + } catch (error) { + console.log(`catch err->${JSON.stringify(error)}`); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } + }) + + + + /** + * @tc.number: System_API_Test_Form_Host_0300 + * @tc.name: callback form deleteForm system interface interception test + * @tc.desc: Test the third-party application call deleteForm will be blocked + * @tc.level 3 + */ + it('System_API_Test_Form_Host_0300',0, async function (done) { + let TAG = 'System_API_Test_Form_Host_0300'; + try { + let formId = "12400633174999288"; + formHost.releaseForm(formId, (error, data) => { + if (error) { + console.log(TAG + ' formHost releaseForm, error:' + JSON.stringify(error)); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } else { + console.log(TAG + ' formHost releaseForm success'); + } + }); + } catch (error) { + console.log(`catch err->${JSON.stringify(error)}`); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } + }) + + /** + * @tc.number: System_API_Test_Form_Host_0400 + * @tc.name: Multi-parameter releaseForm system interface interception test in the form of callback + * @tc.desc: Test the third-party application call releaseForm will be blocked + * @tc.level 3 + */ + it('System_API_Test_Form_Host_0400',0, async function (done) { + let TAG = 'System_API_Test_Form_Host_0400'; + try { + let formId = "12400633174999288"; + formHost.releaseForm(formId, false, (error, data) => { + if (error) { + console.log(TAG + ' formHost releaseForm, error:' + JSON.stringify(error)); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } else { + console.log(TAG + ' formHost releaseForm success'); + } + }); + } catch (error) { + console.log(`catch err->${JSON.stringify(error)}`); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } + }) + + /** + * @tc.number: System_API_Test_Form_Host_0500 + * @tc.name: promise form releaseForm system interface interception test + * @tc.desc: Test the third-party application call releaseForm will be blocked + * @tc.level 3 + */ + it('System_API_Test_Form_Host_0500',0, async function (done) { + let TAG = 'System_API_Test_Form_Host_0500'; + try { + let formId = "12400633174999288"; + formHost.releaseForm(formId) + .then(() => { + expect().assertFail(); + done(); + }) + .catch((error) => { + console.log(TAG + ' formHost releaseForm, error:' + JSON.stringify(error)); + expect(error.code).assertEqual(ERROR_CODE); + done(); + }) + } catch (error) { + console.log(`catch err->${JSON.stringify(error)}`); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } + }) + + /** + * @tc.number: System_API_Test_Form_Host_0600 + * @tc.name: callback form requestForm system interface interception test + * @tc.desc: Test the third-party application call requestForm will be blocked + * @tc.level 3 + */ + it('System_API_Test_Form_Host_0600',0, async function (done) { + let TAG = 'System_API_Test_Form_Host_0600'; + try { + let formId = "12400633174999288"; + formHost.requestForm(formId, (error, data) => { + if (error) { + console.log(TAG + ' formHost requestForm, error:' + JSON.stringify(error)); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } else { + console.log(TAG + ' formHost requestForm success'); + } + }); + } catch (error) { + console.log(`catch err->${JSON.stringify(error)}`); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } + }) + + /** + * @tc.number: System_API_Test_Form_Host_0700 + * @tc.name: promise form requestForm system interface interception test + * @tc.desc: Test the third-party application call requestForm will be blocked + * @tc.level 3 + */ + it('System_API_Test_Form_Host_0700',0, async function (done) { + let TAG = 'System_API_Test_Form_Host_0700'; + try { + let formId = "12400633174999288"; + formHost.requestForm(formId) + .then(() => { + expect().assertFail(); + done(); + }) + .catch((error) => { + console.log(TAG + ' formHost requestForm, error:' + JSON.stringify(error)); + expect(error.code).assertEqual(ERROR_CODE); + done(); + }) + } catch (error) { + console.log(`catch err->${JSON.stringify(error)}`); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } + }) + + /** + * @tc.number: System_API_Test_Form_Host_0800 + * @tc.name: callback form castToNormalForm system interface interception test + * @tc.desc: Test the third-party application call castToNormalForm will be blocked + * @tc.level 3 + */ + it('System_API_Test_Form_Host_0800',0, async function (done) { + let TAG = 'System_API_Test_Form_Host_0800'; + try { + let formId = "12400633174999288"; + formHost.castToNormalForm(formId, (error, data) => { + if (error) { + console.log(TAG + ' formHost castToNormalForm, error:' + JSON.stringify(error)); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } else { + console.log(TAG + ' formHost castToNormalForm success'); + } + }); + } catch (error) { + console.log(`catch err->${JSON.stringify(error)}`); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } + }) + + /** + * @tc.number: System_API_Test_Form_Host_0900 + * @tc.name: promise form castToNormalForm system interface interception test + * @tc.desc: Test the third-party application call castToNormalForm will be blocked + * @tc.level 3 + */ + it('System_API_Test_Form_Host_0900',0, async function (done) { + let TAG = 'System_API_Test_Form_Host_0900'; + try { + let formId = "12400633174999288"; + formHost.castToNormalForm(formId) + .then(() => { + expect().assertFail(); + done(); + }) + .catch((error) => { + console.log(TAG + ' formHost castToNormalForm, error:' + JSON.stringify(error)); + expect(error.code).assertEqual(ERROR_CODE); + done(); + }) + } catch (error) { + console.log(`catch err->${JSON.stringify(error)}`); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } + }) + + /** + * @tc.number: System_API_Test_Form_Host_1000 + * @tc.name: callback form notifyVisibleForms system interface interception test + * @tc.desc: Test the third-party application call notifyVisibleForms will be blocked + * @tc.level 3 + */ + it('System_API_Test_Form_Host_1000',0, async function (done) { + let TAG = 'System_API_Test_Form_Host_1000'; + try { + let formId = "12400633174999288"; + formHost.notifyVisibleForms([formId], (error, data) => { + if (error) { + console.log(TAG + ' formHost castToNormalForm, error:' + JSON.stringify(error)); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } else { + console.log(TAG + ' formHost castToNormalForm success'); + } + }); + } catch (error) { + console.log(`catch err->${JSON.stringify(error)}`); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } + }) + + /** + * @tc.number: System_API_Test_Form_Host_1100 + * @tc.name: promise form notifyVisibleForms system interface interception test + * @tc.desc: Test the third-party application call notifyVisibleForms will be blocked + * @tc.level 3 + */ + it('System_API_Test_Form_Host_1100',0, async function (done) { + let TAG = 'System_API_Test_Form_Host_1100'; + try { + let formId = "12400633174999288"; + formHost.notifyVisibleForms([formId]) + .then(() => { + expect().assertFail(); + done(); + }) + .catch((error) => { + console.log(TAG + ' formHost castToNormalForm, error:' + JSON.stringify(error)); + expect(error.code).assertEqual(ERROR_CODE); + done(); + }) + } catch (error) { + console.log(`catch err->${JSON.stringify(error)}`); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } + }) + + /** + * @tc.number: System_API_Test_Form_Host_1200 + * @tc.name: callback form notifyInvisibleForms system interface interception test + * @tc.desc: Test the third-party application call notifyInvisibleForms will be blocked + * @tc.level 3 + */ + it('System_API_Test_Form_Host_1200',0, async function (done) { + let TAG = 'System_API_Test_Form_Host_1200'; + try { + let formId = "12400633174999288"; + formHost.notifyInvisibleForms([formId], (error, data) => { + if (error) { + console.log(TAG + ' formHost notifyInvisibleForms, error:' + JSON.stringify(error)); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } else { + console.log(TAG + ' formHost notifyInvisibleForms success'); + } + }); + } catch (error) { + console.log(`catch err->${JSON.stringify(error)}`); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } + }) + + /** + * @tc.number: System_API_Test_Form_Host_1300 + * @tc.name: promise form notifyInvisibleForms system interface interception test + * @tc.desc: Test the third-party application call notifyInvisibleForms will be blocked + * @tc.level 3 + */ + it('System_API_Test_Form_Host_1300',0, async function (done) { + let TAG = 'System_API_Test_Form_Host_1300'; + try { + let formId = "12400633174999288"; + formHost.notifyInvisibleForms([formId]) + .then(() => { + expect().assertFail(); + done(); + }) + .catch((error) => { + console.log(TAG + ' formHost notifyInvisibleForms, error:' + JSON.stringify(error)); + expect(error.code).assertEqual(ERROR_CODE); + done(); + }) + } catch (error) { + console.log(`catch err->${JSON.stringify(error)}`); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } + }) + + /** + * @tc.number: System_API_Test_Form_Host_1400 + * @tc.name: callback form enableFormsUpdate system interface interception test + * @tc.desc: Test the third-party application call enableFormsUpdate will be blocked + * @tc.level 3 + */ + it('System_API_Test_Form_Host_1400',0, async function (done) { + let TAG = 'System_API_Test_Form_Host_1400'; + try { + let formId = "12400633174999288"; + formHost.enableFormsUpdate([formId], (error, data) => { + if (error) { + console.log(TAG + ' formHost enableFormsUpdate, error:' + JSON.stringify(error)); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } else { + console.log(TAG + ' formHost enableFormsUpdate success'); + } + }); + } catch (error) { + console.log(`catch err->${JSON.stringify(error)}`); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } + }) + + /** + * @tc.number: System_API_Test_Form_Host_1500 + * @tc.name: promise form enableFormsUpdate system interface interception test + * @tc.desc: Test the third-party application call enableFormsUpdate will be blocked + * @tc.level 3 + */ + it('System_API_Test_Form_Host_1500',0, async function (done) { + let TAG = 'System_API_Test_Form_Host_1500'; + try { + let formId = "12400633174999288"; + formHost.enableFormsUpdate([formId]) + .then(() => { + expect().assertFail(); + done(); + }) + .catch((error) => { + console.log(TAG + ' formHost enableFormsUpdate, error:' + JSON.stringify(error)); + expect(error.code).assertEqual(ERROR_CODE); + done(); + }) + } catch (error) { + console.log(`catch err->${JSON.stringify(error)}`); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } + }) + + /** + * @tc.number: System_API_Test_Form_Host_1600 + * @tc.name: callback form disableFormsUpdate system interface interception test + * @tc.desc: Test the third-party application call disableFormsUpdate will be blocked + * @tc.level 3 + */ + it('System_API_Test_Form_Host_1600',0, async function (done) { + let TAG = 'System_API_Test_Form_Host_1600'; + try { + let formId = "12400633174999288"; + formHost.disableFormsUpdate([formId], (error, data) => { + if (error) { + console.log(TAG + ' formHost disableFormsUpdate, error:' + JSON.stringify(error)); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } else { + console.log(TAG + ' formHost disableFormsUpdate success'); + } + }); + } catch (error) { + console.log(`catch err->${JSON.stringify(error)}`); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } + }) + + /** + * @tc.number: System_API_Test_Form_Host_1700 + * @tc.name: promise form disableFormsUpdate system interface interception test + * @tc.desc: Test the third-party application call disableFormsUpdate will be blocked + * @tc.level 3 + */ + it('System_API_Test_Form_Host_1700',0, async function (done) { + let TAG = 'System_API_Test_Form_Host_1700'; + try { + let formId = "12400633174999288"; + formHost.disableFormsUpdate([formId]) + .then(() => { + expect().assertFail(); + done(); + }) + .catch((error) => { + console.log(TAG + ' formHost disableFormsUpdate, error:' + JSON.stringify(error)); + expect(error.code).assertEqual(ERROR_CODE); + done(); + }) + } catch (error) { + console.log(`catch err->${JSON.stringify(error)}`); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } + }) + + /** + * @tc.number: System_API_Test_Form_Host_1800 + * @tc.name: callback form isSystemReady system interface interception test + * @tc.desc: Test the third-party application call isSystemReady will be blocked + * @tc.level 3 + */ + it('System_API_Test_Form_Host_1800',0, async function (done) { + let TAG = 'System_API_Test_Form_Host_1800'; + try { + formHost.isSystemReady((data) => { + + }) + } catch (error) { + console.log(TAG + ` catch err->${JSON.stringify(error)}`); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } + }) + + /** + * @tc.number: System_API_Test_Form_Host_1900 + * @tc.name: promise form isSystemReady system interface interception test + * @tc.desc: Test the third-party application call isSystemReady will be blocked + * @tc.level 3 + */ + it('System_API_Test_Form_Host_1900',0, async function (done) { + let TAG = 'System_API_Test_Form_Host_1900'; + try { + formHost.isSystemReady() + .then(() => { + expect().assertFail(); + done(); + }) + .catch((error) => { + console.log(TAG + ` promise catch err->${JSON.stringify(error)}`); + }) + } catch (error) { + console.log(TAG + ` catch err->${JSON.stringify(error)}`); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } + }) + + /** + * @tc.number: System_API_Test_Form_Host_2000 + * @tc.name: callback form getAllFormsInfo system interface interception test + * @tc.desc: Test the third-party application call getAllFormsInfo will be blocked + * @tc.level 3 + */ + it('System_API_Test_Form_Host_2000',0, async function (done) { + let TAG = 'System_API_Test_Form_Host_2000'; + try { + formHost.getAllFormsInfo((error, data) => { + console.log(TAG + ' formHost getAllFormsInfo, error:' + JSON.stringify(error)); + expect(error.code).assertEqual(ERROR_CODE); + done(); + }) + } catch (error) { + console.log(TAG + ` catch err->${JSON.stringify(error)}`); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } + }) + + /** + * @tc.number: System_API_Test_Form_Host_2100 + * @tc.name: promise form getAllFormsInfo system interface interception test + * @tc.desc: Test the third-party application call getAllFormsInfo will be blocked + * @tc.level 3 + */ + it('System_API_Test_Form_Host_2100',0, async function (done) { + let TAG = 'System_API_Test_Form_Host_2100'; + try { + formHost.getAllFormsInfo() + .then(() => { + expect().assertFail(); + done(); + }) + .catch((error) => { + console.log(TAG + ' formHost getAllFormsInfo, error:' + JSON.stringify(error)); + expect(error.code).assertEqual(ERROR_CODE); + done(); + }) + } catch (error) { + console.log(TAG + ` catch err->${JSON.stringify(error)}`); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } + }) + + + /** + * @tc.number: System_API_Test_Form_Host_2200 + * @tc.name: callback form getFormsInfo system interface interception test + * @tc.desc: Test the third-party application call getFormsInfo will be blocked + * @tc.level 3 + */ + it('System_API_Test_Form_Host_2200',0, async function (done) { + let TAG = 'System_API_Test_Form_Host_2200'; + try { + let bundleName = "bundleName"; + formHost.getFormsInfo(bundleName, (error, data) => { + if (error) { + console.log(TAG + ' formHost getFormsInfo, error:' + JSON.stringify(error)); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } else { + console.log(TAG + ' formHost getFormsInfo success'); + } + }); + } catch (error) { + console.log(`catch err->${JSON.stringify(error)}`); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } + }) + + /** + * @tc.number: System_API_Test_Form_Host_2300 + * @tc.name: Multiple input in the form of callback getFormsInfo system interface interception test + * @tc.desc: Test the third-party application call getFormsInfo will be blocked + * @tc.level 3 + */ + it('System_API_Test_Form_Host_2300',0, async function (done) { + let TAG = 'System_API_Test_Form_Host_2300'; + try { + let bundleName = "bundleName"; + let moduleName = "moduleName"; + formHost.getFormsInfo(bundleName, moduleName, (error, data) => { + if (error) { + console.log(TAG + ' formHost getFormsInfo, error:' + JSON.stringify(error)); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } else { + console.log(TAG + ' formHost getFormsInfo success'); + } + }); + } catch (error) { + console.log(`catch err->${JSON.stringify(error)}`); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } + }) + + /** + * @tc.number: System_API_Test_Form_Host_2400 + * @tc.name: promise form getFormsInfo system interface interception test + * @tc.desc: Test the third-party application call getFormsInfo will be blocked + * @tc.level 3 + */ + it('System_API_Test_Form_Host_2400',0, async function (done) { + let TAG = 'System_API_Test_Form_Host_2400'; + try { + let bundleName = "bundleName"; + formHost.getFormsInfo(bundleName) + .then(() => { + expect().assertFail(); + done(); + }) + .catch((error) => { + console.log(TAG + ' formHost getFormsInfo, error:' + JSON.stringify(error)); + expect(error.code).assertEqual(ERROR_CODE); + done(); + }) + } catch (error) { + console.log(`catch err->${JSON.stringify(error)}`); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } + }) + + /** + * @tc.number: System_API_Test_Form_Host_2500 + * @tc.name: callback form deleteInvalidForms system interface interception test + * @tc.desc: Test the third-party application call deleteInvalidForms will be blocked + * @tc.level 3 + */ + it('System_API_Test_Form_Host_2500',0, async function (done) { + let TAG = 'System_API_Test_Form_Host_2500'; + try { + let formId = "12400633174999288"; + formHost.deleteInvalidForms([formId], (error, data) => { + if (error) { + console.log(TAG + ' formHost deleteInvalidForms, error:' + JSON.stringify(error)); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } else { + console.log(TAG + ' formHost deleteInvalidForms success'); + } + }); + } catch (error) { + console.log(`catch err->${JSON.stringify(error)}`); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } + }) + + /** + * @tc.number: System_API_Test_Form_Host_2600 + * @tc.name: promise form deleteInvalidForms system interface interception test + * @tc.desc: Test the third-party application call deleteInvalidForms will be blocked + * @tc.level 3 + */ + it('System_API_Test_Form_Host_2600',0, async function (done) { + let TAG = 'System_API_Test_Form_Host_2600'; + try { + let formId = "12400633174999288"; + formHost.deleteInvalidForms([formId]) + .then(() => { + expect().assertFail(); + done(); + }) + .catch((error) => { + console.log(TAG + ' formHost deleteInvalidForms, error:' + JSON.stringify(error)); + expect(error.code).assertEqual(ERROR_CODE); + done(); + }) + } catch (error) { + console.log(`catch err->${JSON.stringify(error)}`); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } + }) + + /** + * @tc.number: System_API_Test_Form_Host_2700 + * @tc.name: callback form acquireFormState system interface interception test + * @tc.desc: Test the third-party application call acquireFormState will be blocked + * @tc.level 3 + */ + it('System_API_Test_Form_Host_2700',0, async function (done) { + let TAG = 'System_API_Test_Form_Host_2700'; + try { + let want = { + abilityName: "aaa", + bundleName: "bbb" + }; + formHost.acquireFormState(want, (error, data) => { + if (error) { + console.log(TAG + ' formHost acquireFormState, error:' + JSON.stringify(error)); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } else { + console.log(TAG + ' formHost acquireFormState success'); + } + }); + } catch (error) { + console.log(`catch err->${JSON.stringify(error)}`); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } + }) + + /** + * @tc.number: System_API_Test_Form_Host_2800 + * @tc.name: promise form acquireFormState system interface interception test + * @tc.desc: Test the third-party application call deleteForm will be blocked + * @tc.level 3 + */ + it('System_API_Test_Form_Host_2800',0, async function (done) { + let TAG = 'System_API_Test_Form_Host_2800'; + try { + let want = { + abilityName: "aaa", + bundleName: "bbb" + }; + formHost.acquireFormState(want) + .then(() => { + expect().assertFail(); + done(); + }) + .catch((error) => { + console.log(TAG + ' formHost acquireFormState, error:' + JSON.stringify(error)); + expect(error.code).assertEqual(ERROR_CODE); + done(); + }) + } catch (error) { + console.log(`catch err->${JSON.stringify(error)}`); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } + }) + + /** + * @tc.number: System_API_Test_Form_Host_2900 + * @tc.name: callback form on system interface interception test + * @tc.desc: Test the third-party application call on will be blocked + * @tc.level 3 + */ + it('System_API_Test_Form_Host_2900',0, async function (done) { + let TAG = 'System_API_Test_Form_Host_2900'; + try { + formHost.on("formUninstall", (data) => { + console.log(TAG + ` data->${JSON.stringify(data)}`); + expect().assertFail(); + done(); + }) + } catch (error) { + console.log(TAG + ` catch err->${JSON.stringify(error)}`); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } + }) + + /** + * @tc.number: System_API_Test_Form_Host_3000 + * @tc.name: callback form off system interface interception test + * @tc.desc: Test the third-party application call off will be blocked + * @tc.level 3 + */ + it('System_API_Test_Form_Host_3000',0, async function (done) { + let TAG = 'System_API_Test_Form_Host_3000'; + try { + formHost.off("formUninstall", (data) => { + console.log(TAG + ` data->${JSON.stringify(data)}`); + expect().assertFail(); + done(); + }) + } catch (error) { + console.log(TAG + ` catch err->${JSON.stringify(error)}`); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } + }) + + /** + * @tc.number: System_API_Test_Form_Host_3100 + * @tc.name: callback form notifyFormsVisible system interface interception test + * @tc.desc: Test the third-party application call notifyFormsVisible will be blocked + * @tc.level 3 + */ + it('System_API_Test_Form_Host_3100',0, async function (done) { + let TAG = 'System_API_Test_Form_Host_3100'; + try { + let formId = "12400633174999288"; + formHost.notifyFormsVisible([formId], false, (error, data) => { + if (error) { + console.log(TAG + ' formHost notifyFormsVisible, error:' + JSON.stringify(error)); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } else { + console.log(TAG + ' formHost notifyFormsVisible success'); + } + }); + } catch (error) { + console.log(`catch err->${JSON.stringify(error)}`); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } + }) + + /** + * @tc.number: System_API_Test_Form_Host_3200 + * @tc.name: promise form notifyFormsVisible system interface interception test + * @tc.desc: Test the third-party application call notifyFormsVisible will be blocked + * @tc.level 3 + */ + it('System_API_Test_Form_Host_3200',0, async function (done) { + let TAG = 'System_API_Test_Form_Host_3200'; + try { + let formId = "12400633174999288"; + formHost.notifyFormsVisible([formId], false) + .then(() => { + + }) + .catch((error) => { + console.log(TAG + ' formHost notifyFormsVisible, error:' + JSON.stringify(error)); + expect(error.code).assertEqual(ERROR_CODE); + done(); + }) + } catch (error) { + console.log(`catch err->${JSON.stringify(error)}`); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } + }) + + /** + * @tc.number: System_API_Test_Form_Host_3300 + * @tc.name: callback form notifyFormsEnableUpdate system interface interception test + * @tc.desc: Test the third-party application call notifyFormsEnableUpdate will be blocked + * @tc.level 3 + */ + it('System_API_Test_Form_Host_3300',0, async function (done) { + let TAG = 'System_API_Test_Form_Host_3300'; + try { + let formId = "12400633174999288"; + formHost.notifyFormsEnableUpdate([formId], false, (error, data) => { + if (error) { + console.log(TAG + ' formHost notifyFormsEnableUpdate, error:' + JSON.stringify(error)); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } else { + console.log(TAG + ' formHost notifyFormsEnableUpdate success'); + } + }); + } catch (error) { + console.log(`catch err->${JSON.stringify(error)}`); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } + }) + + /** + * @tc.number: System_API_Test_Form_Host_3400 + * @tc.name: promise form notifyFormsEnableUpdate system interface interception test + * @tc.desc: Test the third-party application call notifyFormsEnableUpdate will be blocked + * @tc.level 3 + */ + it('System_API_Test_Form_Host_3400',0, async function (done) { + let TAG = 'System_API_Test_Form_Host_3400'; + let formId = "12400633174999288"; + formHost.notifyFormsEnableUpdate([formId], false) + .then(() => { + }) + .catch((error) => { + console.log(TAG + ' formHost notifyFormsEnableUpdate, error:' + JSON.stringify(error)); + expect(error.code).assertEqual(ERROR_CODE); + done(); + }) + }) + + /** + * @tc.number: System_API_Test_Form_Host_3500 + * @tc.name: callback form shareForm system interface interception test + * @tc.desc: Test the third-party application call shareForm will be blocked + * @tc.level 3 + */ + it('System_API_Test_Form_Host_3500',0, async function (done) { + let TAG = 'System_API_Test_Form_Host_3500'; + try { + let formId = "1337079774"; + formHost.shareForm(formId, null, (error, data) => { + if (error) { + console.log(TAG + ' formHost shareForm, error:' + JSON.stringify(error)); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } else { + console.log(TAG + ' formHost shareForm success'); + } + }); + } catch (error) { + console.log(TAG + ` catch err->${JSON.stringify(error)}`); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } + }) + + /** + * @tc.number: System_API_Test_Form_Host_3600 + * @tc.name: promise form shareForm system interface interception test + * @tc.desc: Test the third-party application call shareForm will be blocked + * @tc.level 3 + */ + it('System_API_Test_Form_Host_3600',0, async function (done) { + let TAG = 'System_API_Test_Form_Host_3600'; + let formId = "12400633174999288"; + formHost.shareForm(formId, null) + .then(() => { + expect().assertFail(); + done(); + }) + .catch((error) => { + console.log(TAG + ' formHost shareForm, error:' + JSON.stringify(error)); + expect(error.code).assertEqual(ERROR_CODE); + done(); + }) + }) + + /** + * @tc.number: System_API_Test_Form_Host_3700 + * @tc.name: callback form notifyFormsPrivacyProtected system interface interception test + * @tc.desc: Test the third-party application call notifyFormsPrivacyProtected will be blocked + * @tc.level 3 + */ + it('System_API_Test_Form_Host_3700',0, async function (done) { + let TAG = 'System_API_Test_Form_Host_3700'; + try { + let formId = "12400633174999288"; + formHost.notifyFormsPrivacyProtected([formId], false, (error, data) => { + if (error) { + console.log(TAG + ' formHost notifyFormsPrivacyProtected, error:' + JSON.stringify(error)); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } else { + console.log(TAG + ' formHost notifyFormsPrivacyProtected success'); + } + }); + } catch (error) { + console.log(`catch err->${JSON.stringify(error)}`); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } + }) + + /** + * @tc.number: System_API_Test_Form_Host_3800 + * @tc.name: promise form notifyFormsPrivacyProtected system interface interception test + * @tc.desc: Test the third-party application call notifyFormsPrivacyProtected will be blocked + * @tc.level 3 + */ + it('System_API_Test_Form_Host_3800',0, async function (done) { + let TAG = 'System_API_Test_Form_Host_3800'; + try { + let formId = "12400633174999288"; + formHost.notifyFormsPrivacyProtected([formId], false) + .then(() => { + + }) + .catch((error) => { + console.log(TAG + ' formHost notifyFormsPrivacyProtected, error:' + JSON.stringify(error)); + expect(error.code).assertEqual(ERROR_CODE); + done(); + }) + } catch (error) { + console.log(`catch err->${JSON.stringify(error)}`); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } + }) + }) +} \ No newline at end of file diff --git a/ability/ability_runtime/actssystemapitest/entry/src/main/ets/test/FormProvider.test.ets b/ability/ability_runtime/actssystemapitest/entry/src/main/ets/test/FormProvider.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..a5596b75dfa69cad9e96f6bdbfb57e1faaac67b3 --- /dev/null +++ b/ability/ability_runtime/actssystemapitest/entry/src/main/ets/test/FormProvider.test.ets @@ -0,0 +1,167 @@ +/* + * 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, it, expect } from '@ohos/hypium' +import formProvider from '@ohos.app.form.formProvider' +import formBindingData from '@ohos.app.form.formBindingData' + +let ERROR_CODE = 16500101; +export default function formProviderTest() { + describe('formProviderTest', function () { + + /** + * @tc.number: System_API_Test_Form_Provider_0100 + * @tc.name: Multi-parameter requestPublishForm system interface interception test in the form of callback + * @tc.desc: Test the third-party application call requestPublishForm will be blocked + * @tc.level 3 + */ + it('System_API_Test_Form_Provider_0100',0, async function (done) { + let TAG = 'System_API_Test_Form_Provider_0100'; + let want = { + abilityName: "FormAbility", + parameters: { + "ohos.extra.param.key.form_dimension": 2, + "ohos.extra.param.key.form_name": "widget", + "ohos.extra.param.key.module_name": "entry" + } + }; + try { + let obj = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"}); + formProvider.requestPublishForm(want, obj, (error, data) => { + if (error) { + console.log(TAG + ' formProvider requestPublishForm, error: ' + JSON.stringify(error)); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } else { + console.log('formProvider requestPublishForm, form ID is: ' + JSON.stringify(data)); + } + }); + } catch (error) { + console.log(TAG + ` catch err->${JSON.stringify(error)}`); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } + }) + + /** + * @tc.number: System_API_Test_Form_Provider_0200 + * @tc.name: Multi-parameter requestPublishForm system interface interception test in the form of promise + * @tc.desc: Test the third-party application call requestPublishForm will be blocked + * @tc.level 3 + */ + it('System_API_Test_Form_Provider_0200',0, async function (done) { + let TAG = 'System_API_Test_Form_Provider_0200'; + let want = { + abilityName: "FormAbility", + parameters: { + "ohos.extra.param.key.form_dimension": 2, + "ohos.extra.param.key.form_name": "widget", + "ohos.extra.param.key.module_name": "entry" + } + }; + try { + let obj = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"}); + formProvider.requestPublishForm(want, obj).then((data) => { + console.log(TAG + ' formProvider requestPublishForm success, form ID is :' + JSON.stringify(data)); + }).catch((error) => { + console.log(TAG + ' formProvider requestPublishForm, error: ' + JSON.stringify(error)); + expect(error.code).assertEqual(ERROR_CODE); + done(); + }); + } catch (error) { + console.log(TAG + ` catch err->${JSON.stringify(error)}`); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } + }) + + /** + * @tc.number: System_API_Test_Form_Provider_0300 + * @tc.name: promise form requestPublishForm system interface interception test + * @tc.desc: Test the third-party application call requestPublishForm will be blocked + * @tc.level 3 + */ + it('System_API_Test_Form_Provider_0300',0, async function (done) { + let TAG = 'System_API_Test_Form_Provider_0300'; + let want = { + abilityName: "FormAbility", + parameters: { + "ohos.extra.param.key.form_dimension": 2, + "ohos.extra.param.key.form_name": "widget", + "ohos.extra.param.key.module_name": "entry" + } + }; + try { + formProvider.requestPublishForm(want).then((data) => { + console.log(TAG + ' formProvider requestPublishForm success, form ID is :' + JSON.stringify(data)); + }).catch((error) => { + console.log(TAG + ' formProvider requestPublishForm, error: ' + JSON.stringify(error)); + expect(error.code).assertEqual(ERROR_CODE); + done(); + }); + } catch (error) { + console.log(TAG + ` catch err->${JSON.stringify(error)}`); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } + }) + + /** + * @tc.number: System_API_Test_Form_Provider_0400 + * @tc.name: callback form isRequestPublishFormSupported system interface interception test + * @tc.desc: Test the third-party application call isRequestPublishFormSupported will be blocked + * @tc.level 3 + */ + it('System_API_Test_Form_Provider_0400',0, async function (done) { + let TAG = 'System_API_Test_Form_Provider_0400'; + try { + formProvider.isRequestPublishFormSupported((error, data) => { + if (error) { + console.log(TAG + ' formProvider isRequestPublishFormSupported, error: ' + JSON.stringify(error)); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } + }); + } catch (error) { + console.log(TAG + ` catch err->${JSON.stringify(error)}`); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } + }) + + /** + * @tc.number: System_API_Test_Form_Provider_0500 + * @tc.name: promise form isRequestPublishFormSupported system interface interception test + * @tc.desc: Test the third-party application call isRequestPublishFormSupported will be blocked + * @tc.level 3 + */ + it('System_API_Test_Form_Provider_0500',0, async function (done) { + let TAG = 'System_API_Test_Form_Provider_0500'; + try { + formProvider.isRequestPublishFormSupported().then((data) => { + console.log(TAG + ' formProvider isRequestPublishFormSupported success'); + }).catch((error) => { + console.log(TAG + ' formProvider isRequestPublishFormSupported, error: ' + JSON.stringify(error)); + expect(error.code).assertEqual(ERROR_CODE); + done(); + }); + } catch (error) { + console.log(TAG + ` catch err->${JSON.stringify(error)}`); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } + }) + }) +} \ No newline at end of file diff --git a/ability/ability_runtime/actssystemapitest/entry/src/main/ets/test/List.test.ets b/ability/ability_runtime/actssystemapitest/entry/src/main/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..62990200d0e592337d2e49c82e31eaaa05cc69d7 --- /dev/null +++ b/ability/ability_runtime/actssystemapitest/entry/src/main/ets/test/List.test.ets @@ -0,0 +1,34 @@ +/* +* 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 abilityManagerTest from './AbilityManager.test' +import appManagerTest from './AppManager.test' +import missionManagerTest from './MissionManager.test' +import wantAgentTest from './WantAgent.test' +import formHostTest from './FormHost.test' +import formProviderTest from './FormProvider.test' +import abilityContextTest from './AbilityContext.test' +import contextTest from './Context.test' + +export default function testsuite() { + abilityManagerTest(); + appManagerTest(); + missionManagerTest(); + wantAgentTest(); + formHostTest(); + formProviderTest(); + abilityContextTest(); + contextTest(); +} \ No newline at end of file diff --git a/ability/ability_runtime/actssystemapitest/entry/src/main/ets/test/MissionManager.test.ets b/ability/ability_runtime/actssystemapitest/entry/src/main/ets/test/MissionManager.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..d719c540767c052b85982418375fcc745ba21324 --- /dev/null +++ b/ability/ability_runtime/actssystemapitest/entry/src/main/ets/test/MissionManager.test.ets @@ -0,0 +1,436 @@ +/* + * 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, it, expect } from '@ohos/hypium' +import missionManager from "@ohos.app.ability.missionManager" + +let ERROR_CODE = 202; +export default function missionManagerTest() { + describe('missionManagerTest', function () { + + /** + * @tc.number: System_API_Test_Mission_Manager_0100 + * @tc.name: missionManager.on system interface interception test + * @tc.desc: Test the third-party application call missionManager.on will be blocked + * @tc.level 3 + */ + it('System_API_Test_Mission_Manager_0100', 0, function (done) { + let TAG = 'System_API_Test_Mission_Manager_0100'; + let listener = { + onMissionCreated: function (mission) { console.log("--------onMissionCreated-------") }, + onMissionDestroyed: function (mission) { console.log("--------onMissionDestroyed-------") }, + onMissionSnapshotChanged: function (mission) { console.log("--------onMissionSnapshotChanged-------") }, + onMissionLabelUpdated: function (mission) { console.log("--------onMissionLabelUpdated-------") }, + onMissionMovedToFront: function (mission) { console.log("--------onMissionMovedToFront-------") }, + onMissionIconUpdated: function (mission, icon) { console.log("--------onMissionIconUpdated-------") }, + onMissionClosed: function (mission) { console.log("--------onMissionClosed-------") } + }; + try { + const observerCode = missionManager.on("mission", listener); + console.log('-------- observerCode: ---------', observerCode); + } catch (err) { + console.log(TAG + " err.code: " + err.code); + expect(err.code).assertEqual(ERROR_CODE); + done(); + } + }) + + /** + * @tc.number: System_API_Test_Mission_Manager_0200 + * @tc.name: callback form getMissionInfo system interface interception test + * @tc.desc: Test the third-party application call getMissionInfo will be blocked + * @tc.level 3 + */ + it('System_API_Test_Mission_Manager_0200', 0, function (done) { + let TAG = 'System_API_Test_Mission_Manager_0200'; + let deviceId = "deviceId"; + let missionId = 0; + missionManager.getMissionInfo(deviceId, missionId, (err) => { + console.log(TAG + " err.code: " + err.code); + expect(err.code).assertEqual(ERROR_CODE); + done(); + }); + }) + + /** + * @tc.number: System_API_Test_Mission_Manager_0300 + * @tc.name: promise form getMissionInfo system interface interception test + * @tc.desc: Test the third-party application call getMissionInfo will be blocked + * @tc.level 3 + */ + it('System_API_Test_Mission_Manager_0300', 0, function (done) { + let TAG = 'System_API_Test_Mission_Manager_0300'; + let deviceId = "deviceId"; + let missionId = 0; + missionManager.getMissionInfo(deviceId, missionId) + .then(err => { + console.log(TAG + ` err->${JSON.stringify(err)}`); + expect().assertFail(); + done(); + }) + .catch(err => { + console.log(TAG + " err.code: " + err.code); + expect(err.code).assertEqual(ERROR_CODE); + done(); + }) + }) + + /** + * @tc.number: System_API_Test_Mission_Manager_0400 + * @tc.name: callback form getMissionInfos system interface interception test + * @tc.desc: Test the third-party application call getMissionInfos will be blocked + * @tc.level 3 + */ + it('System_API_Test_Mission_Manager_0400', 0, function (done) { + let TAG = 'System_API_Test_Mission_Manager_0400'; + let deviceId = "deviceId"; + let numMax = 10; + missionManager.getMissionInfos(deviceId, numMax, (err) => { + console.log(TAG + " err.code: " + err.code); + expect(err.code).assertEqual(ERROR_CODE); + done(); + }); + }) + + /** + * @tc.number: System_API_Test_Mission_Manager_0500 + * @tc.name: promise form getMissionInfos system interface interception test + * @tc.desc: Test the third-party application call getMissionInfos will be blocked + * @tc.level 3 + */ + it('System_API_Test_Mission_Manager_0500', 0, function (done) { + let TAG = 'System_API_Test_Mission_Manager_0500'; + let deviceId = "deviceId"; + let numMax = 10; + missionManager.getMissionInfos(deviceId, numMax) + .then(err => { + console.log(TAG + ` err->${JSON.stringify(err)}`); + expect().assertFail(); + done(); + }) + .catch(err => { + console.log(TAG + " err.code: " + err.code); + expect(err.code).assertEqual(ERROR_CODE); + done(); + }) + }) + + /** + * @tc.number: System_API_Test_Mission_Manager_0600 + * @tc.name: callback form getMissionSnapShot system interface interception test + * @tc.desc: Test the third-party application call getMissionSnapShot will be blocked + * @tc.level 3 + */ + it('System_API_Test_Mission_Manager_0600', 0, function (done) { + let TAG = 'System_API_Test_Mission_Manager_0600'; + let deviceId = "deviceId"; + let missionId = 0; + missionManager.getMissionSnapShot(deviceId, missionId, (err) => { + console.log(TAG + " err.code: " + err.code); + expect(err.code).assertEqual(ERROR_CODE); + done(); + }); + }) + + /** + * @tc.number: System_API_Test_Mission_Manager_0700 + * @tc.name: promise form isRequestPublishFormSupported system interface interception test + * @tc.desc: Test the third-party application call isRequestPublishFormSupported will be blocked + * @tc.level 3 + */ + it('System_API_Test_Mission_Manager_0700', 0, function (done) { + let TAG = 'System_API_Test_Mission_Manager_0700'; + let deviceId = "deviceId"; + let missionId = 0; + missionManager.getMissionSnapShot(deviceId, missionId) + .then(err => { + console.log(TAG + ` err->${JSON.stringify(err)}`); + expect().assertFail(); + done(); + }) + .catch(err => { + console.log(TAG + " err.code: " + err.code); + expect(err.code).assertEqual(ERROR_CODE); + done(); + }) + }) + + /** + * @tc.number: System_API_Test_Mission_Manager_0800 + * @tc.name: promise form getLowResolutionMissionSnapShot system interface interception test + * @tc.desc: Test the third-party application call getLowResolutionMissionSnapShot will be blocked + * @tc.level 3 + */ + it('System_API_Test_Mission_Manager_0800', 0, function (done) { + let TAG = 'System_API_Test_Mission_Manager_0800'; + let deviceId = "deviceId"; + let missionId = 0; + missionManager.getLowResolutionMissionSnapShot(deviceId, missionId, (err) => { + console.log(TAG + " err.code: " + err.code); + expect(err.code).assertEqual(ERROR_CODE); + done(); + }); + }) + + /** + * @tc.number: System_API_Test_Mission_Manager_0900 + * @tc.name: promise form getLowResolutionMissionSnapShot system interface interception test + * @tc.desc: Test the third-party application call getLowResolutionMissionSnapShot will be blocked + * @tc.level 3 + */ + it('System_API_Test_Mission_Manager_0900', 0, function (done) { + let TAG = 'System_API_Test_Mission_Manager_0900'; + let deviceId = "deviceId"; + let missionId = 0; + missionManager.getLowResolutionMissionSnapShot(deviceId, missionId) + .then(err => { + console.log(TAG + ` err->${JSON.stringify(err)}`); + expect().assertFail(); + done(); + }) + .catch(err => { + console.log(TAG + " err.code: " + err.code); + expect(err.code).assertEqual(ERROR_CODE); + done(); + }) + }) + + /** + * @tc.number: System_API_Test_Mission_Manager_1000 + * @tc.name: callback form lockMission system interface interception test + * @tc.desc: Test the third-party application call lockMission will be blocked + * @tc.level 3 + */ + it('System_API_Test_Mission_Manager_1000', 0, function (done) { + let TAG = 'System_API_Test_Mission_Manager_1000'; + let missionId = 0; + missionManager.lockMission(missionId, (err) => { + console.log(TAG + " err.code: " + err.code); + expect(err.code).assertEqual(ERROR_CODE); + done(); + }); + }) + + /** + * @tc.number: System_API_Test_Mission_Manager_1100 + * @tc.name: promise form lockMission system interface interception test + * @tc.desc: Test the third-party application call lockMission will be blocked + * @tc.level 3 + */ + it('System_API_Test_Mission_Manager_1100', 0, function (done) { + let TAG = 'System_API_Test_Mission_Manager_1100'; + let missionId = 0; + missionManager.lockMission(missionId) + .then(err => { + console.log(TAG + ` err->${JSON.stringify(err)}`); + expect().assertFail(); + done(); + }) + .catch(err => { + console.log(TAG + " err.code: " + err.code); + expect(err.code).assertEqual(ERROR_CODE); + done(); + }) + }) + + /** + * @tc.number: System_API_Test_Mission_Manager_1200 + * @tc.name: callback form unlockMission system interface interception test + * @tc.desc: Test the third-party application call unlockMission will be blocked + * @tc.level 3 + */ + it('System_API_Test_Mission_Manager_1200', 0, function (done) { + let TAG = 'System_API_Test_Mission_Manager_1200'; + let missionId = 0; + missionManager.unlockMission(missionId, (err) => { + console.log(TAG + " err.code: " + err.code); + expect(err.code).assertEqual(ERROR_CODE); + done(); + }); + }) + + /** + * @tc.number: System_API_Test_Mission_Manager_1300 + * @tc.name: promise form unlockMission system interface interception test + * @tc.desc: Test the third-party application call unlockMission will be blocked + * @tc.level 3 + */ + it('System_API_Test_Mission_Manager_1300', 0, function (done) { + let TAG = 'System_API_Test_Mission_Manager_1300'; + let missionId = 0; + missionManager.unlockMission(missionId) + .then(err => { + console.log(TAG + ` err->${JSON.stringify(err)}`); + expect().assertFail(); + done(); + }) + .catch(err => { + console.log(TAG + " err.code: " + err.code); + expect(err.code).assertEqual(ERROR_CODE); + done(); + }) + }) + + /** + * @tc.number: System_API_Test_Mission_Manager_1400 + * @tc.name: callback form clearMission system interface interception test + * @tc.desc: Test the third-party application call clearMission will be blocked + * @tc.level 3 + */ + it('System_API_Test_Mission_Manager_1400', 0, function (done) { + let TAG = 'System_API_Test_Mission_Manager_1400'; + let missionId = 0; + missionManager.clearMission(missionId, (err) => { + console.log(TAG + " err.code: " + err.code); + expect(err.code).assertEqual(ERROR_CODE); + done(); + }); + }) + + /** + * @tc.number: System_API_Test_Mission_Manager_1500 + * @tc.name: promise form clearMission system interface interception test + * @tc.desc: Test the third-party application call clearMission will be blocked + * @tc.level 3 + */ + it('System_API_Test_Mission_Manager_1500', 0, function (done) { + let TAG = 'System_API_Test_Mission_Manager_1500'; + let missionId = 0; + missionManager.clearMission(missionId) + .then(err => { + console.log(TAG + ` err->${JSON.stringify(err)}`); + expect().assertFail(); + done(); + }) + .catch(err => { + console.log(TAG + " err.code: " + err.code); + expect(err.code).assertEqual(ERROR_CODE); + done(); + }) + }) + + /** + * @tc.number: System_API_Test_Mission_Manager_1600 + * @tc.name: callback form clearAllMissions system interface interception test + * @tc.desc: Test the third-party application call clearAllMissions will be blocked + * @tc.level 3 + */ + it('System_API_Test_Mission_Manager_1600', 0, function (done) { + let TAG = 'System_API_Test_Mission_Manager_1600'; + missionManager.clearAllMissions((err) => { + console.log(TAG + " err.code: " + err.code); + expect(err.code).assertEqual(ERROR_CODE); + done(); + }); + }) + + /** + * @tc.number: System_API_Test_Mission_Manager_1700 + * @tc.name: promise form clearAllMissions system interface interception test + * @tc.desc: Test the third-party application call clearAllMissions will be blocked + * @tc.level 3 + */ + it('System_API_Test_Mission_Manager_1700', 0, function (done) { + let TAG = 'System_API_Test_Mission_Manager_1700'; + missionManager.clearAllMissions() + .then(err => { + console.log(TAG + ` err->${JSON.stringify(err)}`); + expect().assertFail(); + done(); + }) + .catch(err => { + console.log(TAG + " err.code: " + err.code); + expect(err.code).assertEqual(ERROR_CODE); + done(); + }) + }) + + /** + * @tc.number: System_API_Test_Mission_Manager_1800 + * @tc.name: callback form moveMissionToFront system interface interception test + * @tc.desc: Test the third-party application call moveMissionToFront will be blocked + * @tc.level 3 + */ + it('System_API_Test_Mission_Manager_1800', 0, function (done) { + let TAG = 'System_API_Test_Mission_Manager_1800'; + let missionId = 0; + missionManager.moveMissionToFront(missionId, (err) => { + console.log(TAG + " err.code: " + err.code); + expect(err.code).assertEqual(ERROR_CODE); + done(); + }); + }) + + /** + * @tc.number: System_API_Test_Mission_Manager_1900 + * @tc.name: promise form moveMissionToFront system interface interception test + * @tc.desc: Test the third-party application call moveMissionToFront will be blocked + * @tc.level 3 + */ + it('System_API_Test_Mission_Manager_1900', 0, function (done) { + let TAG = 'System_API_Test_Mission_Manager_1900'; + let missionId = 0; + missionManager.moveMissionToFront(missionId) + .then(err => { + console.log(TAG + ` err->${JSON.stringify(err)}`); + expect().assertFail(); + done(); + }) + .catch(err => { + console.log(TAG + " err.code: " + err.code); + expect(err.code).assertEqual(ERROR_CODE); + done(); + }) + }) + + /** + * @tc.number: System_API_Test_Mission_Manager_2000 + * @tc.name: Multi-parameter moveMissionToFront system interface interception test in the form of callback + * @tc.desc: Test the third-party application call moveMissionToFront will be blocked + * @tc.level 3 + */ + it('System_API_Test_Mission_Manager_2000', 0, function (done) { + let TAG = 'System_API_Test_Mission_Manager_2000'; + let missionId = 0; + missionManager.moveMissionToFront(missionId, { windowMode: 101 }, (err) => { + console.log(TAG + " err.code: " + err.code); + expect(err.code).assertEqual(ERROR_CODE); + done(); + }); + }) + + /** + * @tc.number: System_API_Test_Mission_Manager_2100 + * @tc.name: Multi-parameter moveMissionToFront system interface interception test in the form of promise + * @tc.desc: Test the third-party application call moveMissionToFront will be blocked + * @tc.level 3 + */ + it('System_API_Test_Mission_Manager_2100', 0, function (done) { + let TAG = 'System_API_Test_Mission_Manager_2100'; + let missionId = 0; + missionManager.moveMissionToFront(missionId, { windowMode: 101 }) + .then(err => { + console.log(TAG + ` err->${JSON.stringify(err)}`); + expect().assertFail(); + done(); + }) + .catch(err => { + console.log(TAG + " err.code: " + err.code); + expect(err.code).assertEqual(ERROR_CODE); + done(); + }) + }) + }) +} \ No newline at end of file diff --git a/ability/ability_runtime/actssystemapitest/entry/src/main/ets/test/WantAgent.test.ets b/ability/ability_runtime/actssystemapitest/entry/src/main/ets/test/WantAgent.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..83647d8feba3a7143738326334f6b25beaa2a505 --- /dev/null +++ b/ability/ability_runtime/actssystemapitest/entry/src/main/ets/test/WantAgent.test.ets @@ -0,0 +1,62 @@ +/* + * 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, it, expect } from '@ohos/hypium' +import WantAgent from '@ohos.app.ability.wantAgent' + +let ERROR_CODE = 202; + +export default function wantAgentTest() { + describe('wantAgentTest', function () { + + /** + * @tc.number: SUB_AA_OpenHarmony_Context_0100 + * @tc.name: callback form getWant system interface interception test + * @tc.desc: Test the third-party application call getWant will be blocked + * @tc.level 3 + */ + it('System_API_Test_WantAgent_Manager_0100',0, async function (done) { + let TAG = 'System_API_Test_WantAgent_Manager_0100'; + let wantAgent; + try { + WantAgent.getWant(wantAgent, (error, data) => { + console.info(TAG + " ==========================>getWantCallback=======================>"); + }) + } catch (error) { + console.info(TAG + ` getWantCallback err: + ${error.code} + ${error.message}`); + expect(error.code).assertEqual(ERROR_CODE); + done(); + } + }) + + /** + * @tc.number: SUB_AA_OpenHarmony_Context_0100 + * @tc.name: promise form getWant system interface interception test + * @tc.desc: Test the third-party application call getWant will be blocked + * @tc.level 3 + */ + it('System_API_Test_QuickFix_Manager_0200',0, async function (done) { + let TAG = 'System_API_Test_QuickFix_Manager_0200'; + let wantAgent; + try { + WantAgent.getWant(wantAgent).then().catch(); + } catch (error) { + console.info(TAG + ` getWantCallback err: + ${error.code} + ${error.message}`) + expect(error.code).assertEqual(ERROR_CODE); + done(); + } + }) + }) +} \ No newline at end of file diff --git a/ability/ability_runtime/actssystemapitest/entry/src/main/module.json b/ability/ability_runtime/actssystemapitest/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..f737641a3b1559e7c64a66f1efb68309f23df16a --- /dev/null +++ b/ability/ability_runtime/actssystemapitest/entry/src/main/module.json @@ -0,0 +1,27 @@ +{ + "module": { + "name": "entry_test", + "type": "entry", + "srcEntrance": "./ets/Application/MyAbilityStage.ts", + "description": "$string:entry_test_desc", + "mainElement": "MainAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "uiSyntax": "ets", + "abilities": [ + { + "name": "MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:MainAbility_desc", + "icon": "$media:icon", + "label": "$string:MainAbility_label", + "visible": true + } + ] + } +} \ No newline at end of file diff --git a/ability/ability_runtime/actssystemapitest/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/actssystemapitest/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..8c06d7f3a854bcb392d0d857b8b9d9a739252a17 --- /dev/null +++ b/ability/ability_runtime/actssystemapitest/entry/src/main/resources/base/element/string.json @@ -0,0 +1,24 @@ +{ + "string": [ + { + "name": "entry_test_desc", + "value": "description" + }, + { + "name": "app_name", + "value": "ActsSystemAPITest" + }, + { + "name": "description_application", + "value": "demo for test" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "entry_MainAbility" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/actssystemapitest/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/actssystemapitest/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/actssystemapitest/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/actssystemapitest/entry/src/main/resources/base/profile/main_pages.json b/ability/ability_runtime/actssystemapitest/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..821ecf2358ec52ffa8b0812267be3793be71896a --- /dev/null +++ b/ability/ability_runtime/actssystemapitest/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/index/index" + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/actssystemapitest/signature/openharmony_sx.p7b b/ability/ability_runtime/actssystemapitest/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..043f3c9efb6ea23f40e43179e85e5587c5168d44 Binary files /dev/null and b/ability/ability_runtime/actssystemapitest/signature/openharmony_sx.p7b differ