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

!7908 xts-monthly-API覆盖

Merge pull request !7908 from chengxingzhen/monthly_20221018
......@@ -30,6 +30,7 @@ group("ability_runtime") {
"actsdataabilityaccessdatasharetest:dataabilityaccessdatashare",
"actsfwkdataaccessortest:dataability",
"actsqueryfunctiontest:actsqueryfunctiontest",
"actsrequestdialogtest:actsrequestdialogtest",
"actsserviceabilityclienttest:serviceability",
"actsshellcommandfunctionalitytest:actsshellcommandfunctionalitytest",
"actssingleton:actssingleton",
......
# 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("//test/xts/tools/build/suite.gni")
group("actsrequestdialogtest") {
testonly = true
if (is_standard_system) {
deps = [ "actsrequestdialog:ActsRequestDialogTest" ]
}
}
{
"app":{
"bundleName":"com.acts.example.requestdialog",
"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":"ohosProject"
}
]
}
\ 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsRequestDialogTest") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":actsrequestdialog_js_assets",
":actsrequestrecent_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsRequestDialogTest"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("actsrequestdialog_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("actsrequestdialog_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("actsrequestrecent_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":actsrequestdialog_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "180000",
"bundle-name": "com.acts.example.requestdialog",
"module-name": "phone",
"shell-timeout": "600000",
"testcase-timeout": 70000
},
"kits": [
{
"test-file-name": [
"ActsRequestDialogTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"remount",
"mkdir /data/test"
]
},
{
"type": "PushKit",
"push": [
"ActsRequestDialogTest.hap->/data/test/ActsRequestDialogTest.hap"
]
},
{
"type": "ShellKit",
"run-command": [
"chmod 644 /data/test/*.hap"
]
}
]
}
\ 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 AbilityStage from "@ohos.app.ability.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("MyAbilityStage onCreate");
globalThis.stageContext = this.context;
}
}
/*
* 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 Ability from '@ohos.app.ability.UIAbility'
export default class MainAbility extends Ability {
onCreate(want,launchParam){
// Ability is creating, initialize resources for this ability
console.log("MainAbility onCreate");
globalThis.abilityWant = want;
globalThis.abilityContext = this.context;
globalThis.applicationContext = this.context.getApplicationContext();
globalThis.requestDialogSuccess = false;
globalThis.validRequestInfo = false;
globalThis.validRequestCallback = false;
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("MainAbility onDestroy");
globalThis.applicationContext.killAllProcesses().then((data)=>{
console.log(`MainAbility getRunningProcessInformation data ${JSON.stringify(data)}`);
}).catch((err)=>{
console.log(`MainAbility getRunningProcessInformation err ${JSON.stringify(err)}`);
})
globalThis.applicationContext.killAllProcesses((err, data)=>{
console.log(`MainAbility getRunningProcessInformation data ${JSON.stringify(data)}
err: ${JSON.stringify(err)}`);
})
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("MainAbility onWindowStageCreate");
windowStage.setUIContent(this.context, "MainAbility/pages/index/index", null)
}
onWindowStageDestroy() {
//Main window is destroyed, release UI related resources
console.log("MainAbility onWindowStageDestroy");
}
onForeground() {
// Ability has brought to foreground
console.log("MainAbility onForeground");
}
onBackground() {
// Ability has back to background
console.log("MainAbility onBackground");
}
};
\ 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 router from '@ohos.router';
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../../../test/List.test'
var testTime = 0;
@Entry
@Component
struct Index {
aboutToAppear(){
console.info("start run testcase!!!!")
if(testTime++==0){
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
}
build() {
Flex({ direction:FlexDirection.Column, alignItems:ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('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 router from '@system.router';
@Entry
@Component
struct Second {
private content: string = "Second Page"
build() {
Flex({ direction: FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text(`${this.content}`)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('back to index')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.onClick(() => {
router.back()
})
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Ability from '@ohos.app.ability.UIAbility'
import commonEvent from '@ohos.commonEvent'
import dialogRequest from '@ohos.app.ability.dialogRequest'
async function publishEvent() {
var event = 'ACTS_REQUEST_DIALOG_EVENT1';
var commonEventPublishData = {
parameters: {
instanceCount: 1,
}
};
commonEvent.publish(event, commonEventPublishData, () => {
console.log('============>publish event success.==========>>')
});
}
export default class MainAbility2 extends Ability {
onCreate(want, launchParam) {
// Ability is creating, initialize resources for this ability
console.log("MainAbility2 onCreate");
globalThis.abilityWant2 = want;
globalThis.requestDialogSuccess = true;
try {
let requestInfo = dialogRequest.getRequestInfo(want);
if (requestInfo) {
globalThis.validRequestInfo = true;
console.log("MainAbility2 requestInfo is valid");
} else {
console.log("MainAbility2 requestInfo is invalid");
}
let requestCallback = dialogRequest.getRequestCallback(want);
if (requestCallback) {
console.log("MainAbility2 requestCallback is valid");
globalThis.validRequestCallback = true;
let resultCode = {
result : dialogRequest.ResultCode.RESULT_CANCEL,
};
let resultCode2 ={
result : dialogRequest.ResultCode.RESULT_OK,
};
console.log(`resultCjode2 is ${JSON.stringify(resultCode2)}`);
requestCallback.setRequestResult(resultCode);
} else {
console.log("MainAbility2 requestCallback is invalid");
}
publishEvent();
} catch {
console.log("MainAbility2 testRequest fail");
}
console.log("AbilityMultiInstanceAppA abilityWant = " + JSON.stringify( globalThis.abilityWant2));
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("MainAbility2 onDestroy");
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("MainAbility2 onWindowStageCreate")
globalThis.abilityContext2 = this.context;
windowStage.setUIContent(this.context, "MainAbility/pages/second/second", null);
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("MainAbility onWindowStageDestroy");
}
onForeground() {
// Ability has brought to foreground
console.log("MainAbility onForeground");
}
onBackground() {
// Ability has back to background
console.log("MainAbility onBackground");
}
};
/*
* 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 Ability from '@ohos.app.ability.UIAbility'
export default class TestAbility extends Ability {
onCreate(want, launchParam) {
console.log('TestAbility onCreate');
}
onDestroy() {
console.log('TestAbility onDestroy');
}
onWindowStageCreate(windowStage) {
console.log('TestAbility onWindowStageCreate');
windowStage.loadContent("TestAbility/pages/index", (err, data) => {
if (err.code) {
console.error('Failed to load the content. Cause:' + JSON.stringify(err));
return;
}
console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data))
});
globalThis.abilityContext = this.context;
}
onWindowStageDestroy() {
console.log('TestAbility onWindowStageDestroy');
}
onForeground() {
console.log('TestAbility onForeground');
}
onBackground() {
console.log('TestAbility onBackground');
}
};
\ 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 router from '@ohos.router';
@Entry
@Component
struct Index {
aboutToAppear() {
console.info('TestAbility index aboutToAppear')
}
@State message: string = 'Hello World'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('next page')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width('35%')
.height('5%')
.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 TestRunner from '@ohos.application.testRunner'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
var abilityDelegator = undefined;
var abilityDelegatorArguments = undefined;
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s it',
'-s level', '-s testType', '-s size', '-s timeout',
'-s dryRun'
]);
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams = `${targetParams} ${key} ${parameters[key]}`;
}
}
return targetParams.trim();
}
async function onAbilityCreateCallback() {
console.log("onAbilityCreateCallback");
}
async function addAbilityMonitorCallback(err: any) {
console.info("addAbilityMonitorCallback : " + JSON.stringify(err));
}
export default class OpenHarmonyTestRunner implements TestRunner {
constructor() {
}
onPrepare() {
console.info("OpenHarmonyTestRunner OnPrepare ");
}
async onRun() {
console.log('OpenHarmonyTestRunner onRun run')
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments();
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
var testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility';
let lMonitor = {
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback);
var cmd = 'aa start -d 0 -a com.acts.example.requestdialog.MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName;
cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters);
var debug = abilityDelegatorArguments.parameters["-D"];
if (debug == 'true')
{
cmd += ' -D'
}
console.info('cmd : '+cmd);
abilityDelegator.executeShellCommand(cmd,
(err: any, d: any) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + d.stdResult);
console.info('executeShellCommand : data : ' + d.exitCode);
})
console.info('OpenHarmonyTestRunner onRun end');
}
};
\ No newline at end of file
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { describe, it, expect } from "@ohos/hypium"
import commonEvent from '@ohos.commonEvent'
var subscriberInfo = {
events: ["ACTS_REQUEST_DIALOG_EVENT1", "ACTS_REQUEST_DIALOG_EVENT2"]
};
const CASE_TIMEOUT = 3000;
console.info("====>in Ability.test====>");
export default function abilityTest() {
describe('ActsRequestDialogTest', function () {
console.info("====>in ActsRequestDialogTest====>");
function sleep(time) {
return new Promise((resolve) => setTimeout(resolve, time));
}
/*
* @tc.number: ACTS_requestDialog_0100
* @tc.name: Start Recent Ability with no permission.
* @tc.desc: reguest dialog service
*/
it('ACTS_requestDialog_0100', 0, async function (done) {
console.log('ACTS_requestDialog_0100====<begin');
var subscriber;
let id;
let resultCode;
async function subscribeCallBack(err, data) {
console.info("====>ACTS_requestDialog_0100 Subscribe CallBack data:====>" + JSON.stringify(data));
async function processInfoCheck(data) {
console.info('====> ACTS_requestDialog_0100 processInfoCheck=====>');
expect(globalThis.requestDialogSuccess).assertTrue();
expect(globalThis.validRequestInfo).assertTrue();
expect(globalThis.validRequestCallback).assertTrue();
commonEvent.unsubscribe(subscriber, unSubscribeCallback);
done();
}
if (data.event == "ACTS_REQUEST_DIALOG_EVENT1") {
console.info('====> ACTS_startRecent_0100 ACTS_StartAbility_CommonEvent1 success=====>');
await sleep(500);
processInfoCheck(data);
}
}
commonEvent.createSubscriber(subscriberInfo).then(async (data) => {
console.info("====>ACTS_requestDialog_0100 Create Subscriber====>");
subscriber = data;
commonEvent.subscribe(subscriber, subscribeCallBack);
try {
await globalThis.abilityContext.requestDialogService(
{
bundleName: 'com.acts.example.requestdialog',
abilityName: 'com.acts.example.requestdialog.MainAbility2',
}).then((data) => {
console.info("====>ACTS_requestDialog_0100 request end + data:" + JSON.stringify(data));
resultCode = data.result;
})
} catch (paramError) {
console.info("====>ACTS_requestDialog_0100 requestDialogSerivce paramError====>");
}
})
function unSubscribeCallback() {
console.info("====>UnSubscribe0100 CallBack====>");
}
function timeout() {
console.log('ACTS_requestDialog_0100 timeout.');
done();
}
id = setTimeout(timeout, CASE_TIMEOUT);
console.log('Start ACTS_requestDialog_0100 timer id : ' + id);
})
})
}
\ 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 abilityTest from './Ability.test.ets'
export default function testsuite() {
abilityTest()
}
\ No newline at end of file
{
"module": {
"name": "phone",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"abilities": [
{
"name": "com.acts.example.requestdialog.MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"skills": [
{
"actions": [
"action.system.home"
],
"entities": [
"entity.system.home"
]
}
]
},
{
"name": "com.acts.example.requestdialog.MainAbility2",
"srcEntrance": "./ets/MainAbility2/MainAbility2.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"launchType":"standard",
"orientation": "portrait"
}
]
}
}
\ No newline at end of file
{
"string": [
{
"name": "phone_entry_dsc",
"value": "i am an entry for phone"
},
{
"name": "phone_entry_main",
"value": "the phone entry ability"
},
{
"name": "entry_label",
"value": "ActsContextTest"
},
{
"name": "form_description",
"value": "my form"
},
{
"name": "serviceability_description",
"value": "my whether"
},
{
"name": "description_application",
"value": "demo for test"
},
{
"name": "app_name",
"value": "Demo"
}
]
}
{
"src": [
"MainAbility/pages/index/index",
"MainAbility/pages/second/second"
]
}
\ No newline at end of file
......@@ -12,16 +12,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import { describe, afterEach, it, expect } from '@ohos/hypium'
import formProvider from '@ohos.application.formProvider';
import FormInfo from '@ohos.application.formInfo';
import formInfoNew from '@ohos.app.form.formInfo';
import formError from '@ohos.application.formError';
import formHost from '@ohos.application.formHost';
import errorManager from '@ohos.app.ability.errorManager';
import abilityConstant from '@ohos.app.ability.AbilityConstant'
import appManager from '@ohos.application.appManager'
import appManagerNew from '@ohos.app.ability.appManager'
import commonEvent from '@ohos.commonEvent';
import ability from '@ohos.ability.ability';
......@@ -29,12 +26,11 @@ import abilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry
import common from '@ohos.app.ability.common';
import contextConstant from "@ohos.app.ability.contextConstant"
var EXTENSION_INFO_ERR = 16000001
var INNER_ERROR = 16000050
var CROSS_USER_DENY = 201
var INVALID_PARAM = 401
var trueInfo;
var array = new Array();
let EXTENSION_INFO_ERR = 16000001;
let INNER_ERROR = 16000050;
let CROSS_USER_DENY = 201;
let array = new Array();
let TAG = '';
function sleep(time) {
return new Promise((resolve)=>setTimeout(resolve,time));
}
......@@ -517,62 +513,6 @@ export default function ApiCoverTest() {
done()
});
/*
* @tc.number SUB_AA_Test_ProcessInformation_0100
* @tc.name Test getRunningProcessInformation in appManager.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_Test_ProcessInformation_0100', 0, async function (done) {
let ProcessInformation:appManagerNew.ProcessInformation;
let process;
appManagerNew.getRunningProcessInformation().then((ProcessInformations)=>{
console.info("SUB_AA_Test_ProcessInformation_0100:" + JSON.stringify(ProcessInformations));
for(let i = 0; i < ProcessInformations.length; i++){
console.info("SUB_AA_Test_ProcessInformation_0100:" + JSON.stringify(ProcessInformations[i]));
expect(ProcessInformations[i].pid).assertLarger(0)
expect(ProcessInformations[i].uid).assertLarger(0)
if(ProcessInformations[i].processName == "com.example.apicoverhaptest"){
process = ProcessInformations[i]
}
}
expect(process.bundleNames[0]).assertEqual("com.example.apicoverhaptest")
done()
}).catch((error)=>{
console.info("SUB_AA_Test_ProcessInformation_0100:" + JSON.stringify(error));
expect().assertFail()
done()
})
});
/*
* @tc.number SUB_AA_Test_ProcessInformation_0200
* @tc.name Test getRunningProcessInformation by callback in appManager.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_Test_ProcessInformation_0200', 0, async function (done) {
let process;
appManagerNew.getRunningProcessInformation((error, ProcessInformations)=>{
if (error) {
console.info("SUB_AA_Test_ProcessInformation_0200:" + JSON.stringify(error));
expect().assertFail()
done()
}
console.info("SUB_AA_Test_ProcessInformation_0200:" + JSON.stringify(ProcessInformations));
for(let i = 0; i < ProcessInformations.length; i++){
console.info("SUB_AA_Test_ProcessInformation_0200:" + JSON.stringify(ProcessInformations[i]));
expect(ProcessInformations[i].pid).assertLarger(0)
expect(ProcessInformations[i].uid).assertLarger(0)
if(ProcessInformations[i].processName == "com.example.apicoverhaptest"){
process = ProcessInformations[i]
}
}
expect(process.bundleNames[0]).assertEqual("com.example.apicoverhaptest")
done()
})
});
/*
* @tc.number SUB_AA_FMS_AbilityStage_0100
* @tc.name Start AbilityStage and get config.
......@@ -717,5 +657,115 @@ export default function ApiCoverTest() {
done()
})
})
/*
* @tc.number SUB_AA_AbilityAppManager_0100
* @tc.name The form of a promise getRunningProcessInformation
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_AbilityAppManager_0100', 0, async function (done) {
TAG = 'SUB_AA_AbilityAppManager_0100';
await appManagerNew.getRunningProcessInformation().then((data)=>{
console.log(`${TAG} getRunningProcessInformation data ${JSON.stringify(data.length)}`);
for (let i = 0; i < data.length; i++) {
console.log(`${TAG} getRunningProcessInformation${i} : JSON.stringify(data[i])`);
expect(typeof (data[i].pid)).assertEqual("number");
expect(data[i].pid).assertLarger(0);
expect(typeof (data[i].uid)).assertEqual("number");
expect(data[i].uid).assertLarger(0);
expect(typeof (data[i].processName)).assertEqual("string");
expect(data[i].processName.length).assertLarger(0);
expect(Array.isArray(data[i].bundleNames)).assertEqual(true);
expect(data[i].bundleNames.length).assertLarger(0);
}
done();
}).catch((err)=>{
console.log(`${TAG} getRunningProcessInformation err ${JSON.stringify(err)}`);
expect().assertFail();
done();
})
})
/*
* @tc.number SUB_AA_AbilityAppManager_0200
* @tc.name The form of a callback getRunningProcessInformation
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_AbilityAppManager_0200', 0, async function (done) {
TAG = 'SUB_AA_AbilityAppManager_0100';
appManagerNew.getRunningProcessInformation((err, data) => {
console.log(`${TAG} getRunningProcessInformation data ${JSON.stringify(data.length)}
err: ${JSON.stringify(err)}`);
for (let i = 0; i < data.length; i++) {
console.log(`${TAG} getRunningProcessInformation${i} : JSON.stringify(data[i])`);
expect(typeof (data[i].pid)).assertEqual("number");
expect(data[i].pid).assertLarger(0);
expect(typeof (data[i].uid)).assertEqual("number");
expect(data[i].uid).assertLarger(0);
expect(typeof (data[i].processName)).assertEqual("string");
expect(data[i].processName.length).assertLarger(0);
expect(Array.isArray(data[i].bundleNames)).assertEqual(true);
expect(data[i].bundleNames.length).assertLarger(0);
}
done();
})
})
/*
* @tc.number SUB_AA_ApplicationContext_0100
* @tc.name The form of a promise getRunningProcessInformation
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_ApplicationContext_0100', 0, async function (done) {
TAG = 'SUB_AA_ApplicationContext_0100';
await globalThis.applicationContext.getRunningProcessInformation().then((data)=>{
console.log(`${TAG} getRunningProcessInformation data ${JSON.stringify(data.length)}`);
for (let i = 0; i < data.length; i++) {
console.log(`${TAG} getRunningProcessInformation${i} : JSON.stringify(data[i])`);
expect(typeof (data[i].pid)).assertEqual("number");
expect(data[i].pid).assertLarger(0);
expect(typeof (data[i].uid)).assertEqual("number");
expect(data[i].uid).assertLarger(0);
expect(typeof (data[i].processName)).assertEqual("string");
expect(data[i].processName.length).assertLarger(0);
expect(Array.isArray(data[i].bundleNames)).assertEqual(true);
expect(data[i].bundleNames.length).assertLarger(0);
}
done();
}).catch((err)=>{
console.log(`${TAG} getRunningProcessInformation err ${JSON.stringify(err)}`);
expect().assertFail();
done();
})
})
/*
* @tc.number SUB_AA_ApplicationContext_0200
* @tc.name The form of a callback getRunningProcessInformation
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_ApplicationContext_0200', 0, async function (done) {
TAG = 'SUB_AA_ApplicationContext_0200';
globalThis.applicationContext.getRunningProcessInformation((err, data) => {
console.log(`${TAG} getRunningProcessInformation data ${JSON.stringify(data.length)}
err: ${JSON.stringify(err)}`);
for (let i = 0; i < data.length; i++) {
console.log(`${TAG} getRunningProcessInformation${i} : JSON.stringify(data[i])`);
expect(typeof (data[i].pid)).assertEqual("number");
expect(data[i].pid).assertLarger(0);
expect(typeof (data[i].uid)).assertEqual("number");
expect(data[i].uid).assertLarger(0);
expect(typeof (data[i].processName)).assertEqual("string");
expect(data[i].processName.length).assertLarger(0);
expect(Array.isArray(data[i].bundleNames)).assertEqual(true);
expect(data[i].bundleNames.length).assertLarger(0);
}
done();
})
})
})
}
......@@ -14,6 +14,7 @@
*/
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import wantAgent from '@ohos.app.ability.wantAgent';
import wantConstant from '@ohos.app.ability.wantConstant'
var TAG
export default function wantAgentCoverTest() {
......@@ -60,6 +61,8 @@ export default function wantAgentCoverTest() {
});
setTimeout(() => {
expect(wantConstant.Params.ABILITY_BACK_TO_OTHER_MISSION_STACK)
.assertEqual('ability.params.backToOtherMissionStack');
expect(status).assertTrue();
expect(code1).assertEqual(2);
done()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册