提交 a54c8539 编写于 作者: K kirl.liu

Fix codex

Signed-off-by: Nkirl.liu <kirl.liu@huawei.com>
上级 48e5eaf4
/*
* 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, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index"
import appManager from '@ohos.application.AppManager';
import featureAbility from '@ohos.ability.featureAbility'
const ACCOUNT_ID = 100;
const NULL_ACCOUNT_ID = 102;
const BUNDLE_NAME = 'com.example.actskillprocesswithaccountcloseapi7';
const NULL_BUNDLE_NAME = 'com.aaa.bbb';
const START_ABILITY_NAME = 'com.example.actskillprocesswithaccountcloseapi7.MainAbility';
describe('ActsAbilityTest', function () {
beforeEach(async (done) => {
console.log('======>beforeEach killProcessWithAccountTest<=======');
await featureAbility.startAbility({
want:
{
bundleName: BUNDLE_NAME,
abilityName: START_ABILITY_NAME
}
}).then(async () => {
console.log("====>end ACTS_KillProcessWithAccount startability ====>success!")
done();
})
})
function sleep(time) {
let delta;
if (typeof time != 'number' || time <= 0) {
delta = 100;
} else {
delta = Math.round(time);
}
for (let start = Date.now(); Date.now() - start <= delta;);
}
function checkRunningProcess(name, dataInfo) {
for (let i = 0, len = dataInfo.length; i < len; i++) {
if (dataInfo[i].processName == name) {
return true;
}
}
return false;
}
/**
* @tc.number: ACTS_KillProcessWithAccount_0100
* @tc.name: Provide the system interface of the specified user management application.
* @tc.desc: Validates the ability to stop the specified process for the specified user.
*/
it('ACTS_KillProcessWithAccount_0100', 0, async function (done) {
console.debug("====>ACTS_KillProcessWithAccount_0100 start startAbility====>");
var procrssinfo = await appManager.getProcessRunningInfos()
console.log('ACTS_KillProcessWithAccount_0100 ==1== getProcessRunningInfos ======> '
+ JSON.stringify(procrssinfo));
var infores = checkRunningProcess(BUNDLE_NAME, procrssinfo)
console.log("====>ACTS_KillProcessWithAccount_0100====>infores = " + infores)
expect(infores).assertEqual(true);
await appManager.killProcessWithAccount(BUNDLE_NAME, ACCOUNT_ID).then(async () => {
console.log('ACTS_KillProcessWithAccount_0100 killProcess ======> start');
})
setTimeout(async () => {
var copyprocrssinfo = await appManager.getProcessRunningInfos()
console.log('ACTS_KillProcessWithAccount_0100 getProcessRunningInfos ======> '
+ JSON.stringify(copyprocrssinfo));
var outcopy = checkRunningProcess(BUNDLE_NAME, copyprocrssinfo)
console.log("====>ACTS_KillProcessWithAccount_0100====>outcopy = " + outcopy)
expect(outcopy).assertEqual(false);
done();
}, 3000)
})
/**
* @tc.number: ACTS_KillProcessWithAccount_0300
* @tc.name: Provide the system interface of the specified user management application.
* @tc.desc: Authentication cannot stop the specified process for the specified user.
*/
it('ACTS_KillProcessWithAccount_0300', 0, async function (done) {
console.debug("====>ACTS_KillProcessWithAccount_0300 start startAbility====>");
var getinfo = await appManager.getProcessRunningInfos()
console.log('ACTS_KillProcessWithAccount_0300 getProcessRunningInfos =1= ======> '
+ JSON.stringify(getinfo));
var res = checkRunningProcess(BUNDLE_NAME, getinfo)
console.log("====>ACTS_KillProcessWithAccount_0300====>res = " + res)
expect(res).assertEqual(true);
appManager.killProcessWithAccount(NULL_BUNDLE_NAME, ACCOUNT_ID).then(() => {
console.log('ACTS_KillProcessWithAccount_0300 ======> ');
})
setTimeout(async () => {
var procrssinfo = await appManager.getProcessRunningInfos()
console.log('ACTS_KillProcessWithAccount_0300 ==1== getProcessRunningInfos ======> '
+ JSON.stringify(procrssinfo));
var infores = checkRunningProcess(BUNDLE_NAME, procrssinfo)
console.log("====>ACTS_KillProcessWithAccount_0300====>infores = " + infores)
expect(infores).assertEqual(true);
await appManager.killProcessWithAccount(BUNDLE_NAME, ACCOUNT_ID).then(async () => {
console.log('ACTS_KillProcessWithAccount_0300 killProcess ======> start');
sleep(500)
var copyprocrssinfo = await appManager.getProcessRunningInfos()
console.log('ACTS_KillProcessWithAccount_0300 getProcessRunningInfos ======> '
+ JSON.stringify(copyprocrssinfo));
var outcopy = checkRunningProcess(BUNDLE_NAME, copyprocrssinfo)
console.log("====>ACTS_KillProcessWithAccount_0300====> outcopy = " + outcopy)
expect(outcopy).assertEqual(false);
done();
})
}, 1500)
})
/**
* @tc.number: ACTS_KillProcessWithAccount_0400
* @tc.name: Provide the system interface of the specified user management application.
* @tc.desc: Authentication cannot stop the specified process for the specified user.
*/
it('ACTS_KillProcessWithAccount_0400', 0, async function (done) {
console.debug("====>ACTS_KillProcessWithAccount_0400 start startAbility====>");
var getinfo = await appManager.getProcessRunningInfos()
console.log('ACTS_KillProcessWithAccount_0400 getProcessRunningInfos =1= ======> '
+ JSON.stringify(getinfo));
var res = checkRunningProcess(BUNDLE_NAME, getinfo)
console.log("====>ACTS_KillProcessWithAccount_0400====>res = " + res)
expect(res).assertEqual(true);
appManager.killProcessWithAccount(BUNDLE_NAME, NULL_ACCOUNT_ID).then(() => {
console.log('ACTS_KillProcessWithAccount_0400 killProcess ======> start');
})
setTimeout(async () => {
var procrssinfo = await appManager.getProcessRunningInfos()
console.log('ACTS_KillProcessWithAccount_0400 ==1== getProcessRunningInfos ======> '
+ JSON.stringify(procrssinfo));
var infores = checkRunningProcess(BUNDLE_NAME, procrssinfo)
console.log("====>ACTS_KillProcessWithAccount_0400====>infores = " + infores)
expect(infores).assertEqual(true);
appManager.killProcessWithAccount(BUNDLE_NAME, ACCOUNT_ID).then(async () => {
console.log('ACTS_KillProcessWithAccount_0400 killProcess2 ======> start');
sleep(500)
var copyprocrssinfo = await appManager.getProcessRunningInfos()
console.log('ACTS_KillProcessWithAccount_0400 ==2== getProcessRunningInfos ======>'
+ JSON.stringify(copyprocrssinfo));
var out = checkRunningProcess(BUNDLE_NAME, copyprocrssinfo)
console.log("====>ACTS_KillProcessWithAccount_0400====>infores = " + out)
expect(out).assertEqual(false);
done();
})
}, 1500)
})
/**
* @tc.number: ACTS_KillProcessWithAccount_0500
* @tc.name: Provide the system interface of the specified user management application.
* @tc.desc: Validates the ability to stop the specified process for the specified user.
*/
it('ACTS_KillProcessWithAccount_0500', 0, async function (done) {
console.debug("====>ACTS_KillProcessWithAccount_0500 start startAbility====>");
var procrssinfo = await appManager.getProcessRunningInfos()
console.log('ACTS_KillProcessWithAccount_0500 ==1== getProcessRunningInfos ======> '
+ JSON.stringify(procrssinfo));
var infores = checkRunningProcess(BUNDLE_NAME, procrssinfo)
console.log("====>ACTS_KillProcessWithAccount_0500====>infores = " + infores)
expect(infores).assertEqual(true);
await appManager.killProcessWithAccount(BUNDLE_NAME, ACCOUNT_ID, (async () => {
console.log('ACTS_KillProcessWithAccount_0500 killProcess ======> start');
}))
setTimeout(async () => {
var copyprocrssinfo = await appManager.getProcessRunningInfos()
console.log('ACTS_KillProcessWithAccount_0500 getProcessRunningInfos ======> '
+ JSON.stringify(copyprocrssinfo));
var outcopy = checkRunningProcess(BUNDLE_NAME, copyprocrssinfo)
console.log("====>ACTS_KillProcessWithAccount_0500====>outcopy = " + outcopy)
expect(outcopy).assertEqual(false);
done();
}, 3000)
})
/**
* @tc.number: ACTS_KillProcessWithAccount_0700
* @tc.name: Provide the system interface of the specified user management application.
* @tc.desc: Authentication cannot stop the specified process for the specified user.
*/
it('ACTS_KillProcessWithAccount_0700', 0, async function (done) {
console.debug("====>ACTS_KillProcessWithAccount_0700 start startAbility====>");
var getinfo = await appManager.getProcessRunningInfos()
console.log('ACTS_KillProcessWithAccount_0700 getProcessRunningInfos =1= ======> '
+ JSON.stringify(getinfo));
var res = checkRunningProcess(BUNDLE_NAME, getinfo)
console.log("====>ACTS_KillProcessWithAccount_0700====>res = " + res)
expect(res).assertEqual(true);
appManager.killProcessWithAccount(NULL_BUNDLE_NAME, ACCOUNT_ID, (() => {
console.log('ACTS_KillProcessWithAccount_0700 killProcess ======> start');
}))
setTimeout(async () => {
var procrssinfo = await appManager.getProcessRunningInfos()
console.log('ACTS_KillProcessWithAccount_0700 ==1== getProcessRunningInfos ======> '
+ JSON.stringify(procrssinfo));
var infores = checkRunningProcess(BUNDLE_NAME, procrssinfo)
console.log("====>ACTS_KillProcessWithAccount_0700====>infores = " + infores)
expect(infores).assertEqual(true);
await appManager.killProcessWithAccount(BUNDLE_NAME, ACCOUNT_ID).then(async () => {
console.log('ACTS_KillProcessWithAccount_0700 killProcess ======> start');
sleep(500)
var copyprocrssinfo = await appManager.getProcessRunningInfos()
console.log('ACTS_KillProcessWithAccount_0700 getProcessRunningInfos ======> '
+ JSON.stringify(copyprocrssinfo));
var outcopy = checkRunningProcess(BUNDLE_NAME, copyprocrssinfo)
console.log("====>ACTS_KillProcessWithAccount_0700====> outcopy = " + outcopy)
expect(outcopy).assertEqual(false);
done();
})
}, 1500)
})
/**
* @tc.number: ACTS_KillProcessWithAccount_0800
* @tc.name: Provide the system interface of the specified user management application.
* @tc.desc: Authentication cannot stop the specified process for the specified user.
*/
it('ACTS_KillProcessWithAccount_0800', 0, async function (done) {
console.debug("====>ACTS_KillProcessWithAccount_0800 start startAbility====>");
var getinfo = await appManager.getProcessRunningInfos()
console.log('ACTS_KillProcessWithAccount_0800 getProcessRunningInfos =1= ======> '
+ JSON.stringify(getinfo));
var res = checkRunningProcess(BUNDLE_NAME, getinfo)
console.log("====>ACTS_KillProcessWithAccount_0800====>res = " + res)
expect(res).assertEqual(true);
appManager.killProcessWithAccount(BUNDLE_NAME, NULL_ACCOUNT_ID, (() => {
console.log('ACTS_KillProcessWithAccount_0800 killProcess ======> start');
}))
setTimeout(async () => {
var procrssinfo = await appManager.getProcessRunningInfos()
console.log('ACTS_KillProcessWithAccount_0800 ==1== getProcessRunningInfos ======> '
+ JSON.stringify(procrssinfo));
var infores = checkRunningProcess(BUNDLE_NAME, procrssinfo)
console.log("====>ACTS_KillProcessWithAccount_0800====>infores = " + infores)
expect(infores).assertEqual(true);
await appManager.killProcessWithAccount(BUNDLE_NAME, ACCOUNT_ID).then(async () => {
console.log('ACTS_KillProcessWithAccount_0800 killProcess ======> start');
sleep(500)
var copyprocrssinfo = await appManager.getProcessRunningInfos()
console.log('ACTS_KillProcessWithAccount_0800 getProcessRunningInfos ======> '
+ JSON.stringify(copyprocrssinfo));
var outcopy = checkRunningProcess(BUNDLE_NAME, copyprocrssinfo)
console.log("====>ACTS_KillProcessWithAccount_0800====> outcopy = " + outcopy)
expect(outcopy).assertEqual(false);
done();
})
}, 1500)
})
})
\ 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, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index"
import commonEvent from '@ohos.commonevent'
import bundle from '@ohos.bundle'
import missionManager from '@ohos.application.missionManager'
import abilityManager from '@ohos.application.abilityManager'
import featureAbility from '@ohos.ability.featureability'
var subscriberInfoMultiInstance = {
events: ["UpdateLanguageFinish"]
};
const BUNDLE_PATHS = [['/data/test/ActslanguageconfigAppATest.hap']];
const BUNDLE_NAMES = ['com.example.actslanguageconfigappatest'];
const BUNDLE_COUNT = 1;
const START_ABILITY_TIMEOUT = 5000;
const MAX_MISSION_NUM = 1024;
async function startAbilityProcess(parameters) {
let bundleName;
let abilityName;
let idx = parameters.nextStep;
switch (parameters.step[idx]) {
case "StartA1":
bundleName = "com.example.actslanguageconfigappatest";
abilityName = "com.example.actslanguageconfigappatest.MainAbility";
break;
default:
break;
}
parameters.nextStep = ++idx;
await featureAbility.startAbility({
want: {
bundleName: bundleName,
abilityName: abilityName,
parameters: parameters
}
})
}
function getMissionId() {
return new Promise(async (resolve, reject) => {
var missionId = -1;
var missionInfos = await missionManager.getMissionInfos('', MAX_MISSION_NUM);
for (let i = 0; i < missionInfos.length; i++) {
console.log('getMissionId result: ' + i + '= ' + JSON.stringify(missionInfos[i]))
if ((missionInfos[i].want.abilityName == "com.example.languageconfigtestapi7.MainAbility") &&
(missionInfos[i].runningState == 0)) {
missionId = missionInfos[i].missionId;
break;
}
}
console.log('======>Acts_getMissionId resolve missionId<=======' + missionId);
resolve(missionId);
})
}
describe('ActsAbilityTest', function () {
beforeEach(async (done) => {
console.log('======>Acts_beforeEach ininin<=======');
let installer = await bundle.getBundleInstaller();
var count = 0;
for (let i = 0; i < BUNDLE_COUNT; i++) {
installer.install(BUNDLE_PATHS[i], {
userId: 100,
installFlag: 1,
isKeepData: false
}, (err, data) => {
count++;
console.log('======>Acts_beforeEach install finish <=======' + err.code);
console.log('======>Acts_beforeEach install finish <=======' + data.status);
console.log('======>Acts_beforeEach install finish <=======' + data.statusMessage);
if (count == BUNDLE_COUNT) {
setTimeout(() => {
done();
}, 1000)
}
})
}
})
/*
* @tc.number: AMS_UpdateConfiguration_0100
* @tc.name: Connects a service ability, which is used to start a cloned page ability.
* @tc.desc: Check the event data of executor page ability publishes
*/
it('AMS_UpdateConfiguration_0100', 0, async function (done) {
console.log('Acts_AMS_UpdateConfiguration_0100====<begin');
var subscriber;
var id;
var configDefault = {
language: "zh-Hans"
};
var configChange = {
language: "en"
};
await abilityManager.updateConfiguration(configDefault);
function subscribeCallBack(err, data) {
console.debug("====>Acts_Subscribe CallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("UpdateLanguageFinish");
clearTimeout(id);
console.log('Acts_AMS_UpdateConfiguration_0100 start set lang');
commonEvent.unsubscribe(subscriber, unSubscribeCallback);
}
commonEvent.createSubscriber(subscriberInfoMultiInstance).then(async (data) => {
console.debug("Acts_====>Create Subscriber====>");
subscriber = data;
commonEvent.subscribe(subscriber, subscribeCallBack);
})
function unSubscribeCallback() {
setTimeout( function () {
console.debug("Acts_====>UnSubscribe CallBack====>");
done();
}, 2000);
}
function timeout() {
expect().assertFail();
console.log('Acts_StartLanguageConfigTester timeout');
commonEvent.unsubscribe(subscriber, unSubscribeCallback);
}
id = setTimeout(timeout, START_ABILITY_TIMEOUT);
console.log('Acts_Start LanguageConfigTester AMS_UpdateConfiguration_0100 timer id : ' + id);
console.log('Acts_LanguageConfigTester AMS_UpdateConfiguration_0100 start Ability');
startAbilityProcess({
startId: 0,
stepNum: 1,
nextStep: 0,
step: ["StartA1"]
});
})
})
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册