未验证 提交 46343b88 编写于 作者: O openharmony_ci 提交者: Gitee

!7225 xts-系统API鉴权新增用例

Merge pull request !7225 from chengxingzhen/master
......@@ -35,6 +35,7 @@ group("ability_runtime") {
"actsstartrunnertest:ActsStartRunnerTest",
"actsstserviceabilityclientcase:ActsStServiceAbilityClientCaseTest",
"actssupportfunction:actssupportfunction",
"actssystemapitest:ActsSystemAPITest",
"actsusers:actsusers",
"amscontextualinforquery:amscontextualinforquery",
"amsdatauriutils:ActsAmsDataUriUtilsTest",
......
{
"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
}
}
}
{
"string": [
{
"name": "app_name",
"value": "AbilityStageMonitor"
}
]
}
# 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"
}
{
"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
}
]
}
/*
* 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
/*
* 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
/*
* 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
/*
* 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
/*
* 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
/*
* 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
/*
* 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
/*
* 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
/*
* 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
/*
* 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
/*
* 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
/*
* 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
{
"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
{
"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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册