提交 0d7f697f 编写于 作者: U unknown

add user

Signed-off-by: Nunknown <sijunjie@huawei.com>
上级 a6a83776
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsAbilityLifecycleStateNewTest") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsAbilityLifecycleStateNewTest"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/js/default"
}
ohos_resources("hjs_demo_resources") {
sources = [ "./entry/src/main/js/resources" ]
hap_profile = "./entry/src/main/config.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "60000",
"package": "com.amsst.actsabilitylifecyclestatenewtest",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"ActsAbilityLifecycleStateNewTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "com.amsst.actsabilitylifecyclestatenewtest",
"vendor": "amsst",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "com.amsst.actsabilitylifecyclestatenewtest",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "com.amsst.actsabilitylifecyclestatenewtest.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"type": "page",
"launchType": "standard",
"visible": true
}
],
"reqPermissions": [
{
"name": "ohos.permission.INSTALL_BUNDLE",
"reason": "need use ohos.permission.INSTALL_BUNDLE"
},
{
"name":"ohos.permission.GET_BUNDLE_INFO",
"reason":"need use ohos.permission.GET_BUNDLE_INFO"
},
{
"name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
"reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
},
{
"name":"ohos.permission.CHANGE_ABILITY_ENABLED_STATE",
"reason":"need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE"
},
{
"name":"ohos.permission.REMOVE_CACHE_FILES",
"reason":"need use ohos.permission.REMOVE_CACHE_FILES"
},
{
"name":"ohos.permission.LISTEN_BUNDLE_CHANGE",
"reason":"need use ohos.permission.LISTEN_BUNDLE_CHANGE"
},
{
"name":"ohos.permission.MANAGE_LOCAL_ACCOUNTS",
"reason":"need use ohos.permission.MANAGE_LOCAL_ACCOUNTS"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
/*
* 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.
*/
export default {
onCreate() {
console.info('AceApplication onCreate');
},
onDestroy() {
console.info('AceApplication onDestroy');
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
}
}
\ No newline at end of file
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 100px;
}
.titleST {
font-size: 32px;
}
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
<text class="titleST">
StAbility
</text>
</div>
/*
* 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 file from '@system.file'
import app from '@system.app'
import {Core, ExpectExtend, ReportExtend} from 'deccjsunit/index'
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
},
onShow() {
console.info('====onShow finish====<')
const core = Core.getInstance()
const expectExtend = new ExpectExtend({
'id': 'extend'
})
const reportExtend = new ReportExtend(file)
core.addService('expect', expectExtend)
core.addService('report', reportExtend)
core.init()
const configService = core.getDefaultService('config')
configService.setConfig(this)
require('../../../test/List.test')
core.execute()
},
onReady() {
},
}
\ No newline at end of file
{
"string": [
{
"name": "app_name",
"value": "StSeAbClient"
},
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability"
}
]
}
\ 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import featureAbility from '@ohos.ability.featureAbility'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'
describe('ActsGetAbilityStateTest', function () {
let gSetTimeout = 1000
beforeAll(async (done) => {
console.debug('= ACTS_AbeforeAll 1508 ====<begin');
console.debug('= ACTS_AbeforeAll ====<end');
done();
})
beforeEach(async (done) => {
setTimeout(function () {
done();
}, gSetTimeout);
})
afterEach(async (done) => {
setTimeout(function () {
done();
}, gSetTimeout);
})
afterAll((done) => {
console.debug('= ACTS_AafterAll ====<begin');
setTimeout(function () {
console.debug('= ACTS_AafterAll ====<end');
featureAbility.terminateSelf();
done();
}, gSetTimeout);
})
/*
* @tc.number : ACTS_AGetAbilityState_0400
* @tc.name :
* @tc.desc : Get the status of the Ability in the DESTROY state
*/
it('ACTS_AGetAbilityState_0400', 0, async function (done) {
console.debug('====>start====ACTS_AGetAbilityState_0400')
try {
var ability;
var AbilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
console.debug("====>ACTS_onAbilityForegroundCallback====AbilityDelegator=" + AbilityDelegator);
function onAbilityForegroundCallback(){
console.debug("====>ACTS_onAbilityForegroundCallback====");
AbilityDelegator.getCurrentTopAbility((err, data)=>{
console.debug("====>ACTS_AGetCurrentTopAbility err:" +
JSON.stringify(err) + "data:" + JSON.stringify(data));
ability = data;
})
}
function onAbilityDestroyCallback(){
console.debug("====>ACTS_onAbilityDestroyCallback====");
var state = AbilityDelegator.getAbilityState(ability);
console.debug("====>ACTS_AGetAppState_0400 data:" + state);
expect(state==AbilityDelegatorRegistry.AbilityLifecycleState.DESTROY
|| (state!=AbilityDelegatorRegistry.AbilityLifecycleState.BACKGROUND
|| state!=AbilityDelegatorRegistry.AbilityLifecycleState.FOREGROUND
|| state!=AbilityDelegatorRegistry.AbilityLifecycleState.CREATE
|| state!=AbilityDelegatorRegistry.AbilityLifecycleState.UNINITIALIZED
)).assertTrue();
console.debug("====>ACTS_AGetAppState_0400 end====");
done();
}
console.debug("ACTS_====>addAbilityMonitor finish b====");
AbilityDelegator.addAbilityMonitor(
{abilityName: 'com.example.getAbilityState.MainAbility3',
onAbilityForeground:onAbilityForegroundCallback,
onAbilityDestroy:onAbilityDestroyCallback}).then(()=>{
console.debug("ACTS_====>addAbilityMonitor finish e====");
})
featureAbility.startAbility(
{
bundleName: 'com.example.getAbilityState',
abilityName: 'com.example.getAbilityState.MainAbility3',
}, (err,data)=>{
console.debug("ACTS_====>startAbility err:" + JSON.stringify(err));
})
} catch (error) {
console.debug("ACTS_AGetAbilityState_0400 catch (error):" + JSON.stringify(error));
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.
*/
require('./ActsAbilityLifecycleStateNewTest.test.js')
\ No newline at end of file
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* 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
......
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* 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
......
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* 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
......
# 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("ActsKillProcessWithAccountApi7Test") {
hap_name = "ActsKillProcessWithAccountApi7Test"
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/js/default"
}
ohos_resources("hjs_demo_resources") {
sources = [ "./entry/src/main/js/resources" ]
hap_profile = "./entry/src/main/config.json"
}
{
"description": "Configuration for hjsunit Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "60000",
"package": "com.example.myapplication.actsapi7killtest",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"ActsKillProcessWithAccountApi7Test.hap",
"ActsKillProcessWithAccountCloseApi7.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"remount"
]
},
{
"type": "PushKit",
"push": [
"ActsKillProcessWithAccountCloseApi7.hap->/data/ActsKillProcessWithAccountCloseApi7.hap"
]
},
{
"type": "ShellKit",
"run-command": [
"chmod 644 /data/*.hap"
]
}
]
}
{
"app": {
"bundleName": "com.example.myapplication.actsapi7killtest",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "com.example.myapplication.actsapi7killtest",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "com.example.myapplication.actsapi7killtest.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"type": "page",
"launchType": "singleton",
"visible": true
}
],
"reqPermissions": [
{
"name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
"reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
},
{
"name":"ohos.permission.GET_BUNDLE_INFO",
"reason":"need use ohos.permission.GET_BUNDLE_INFO"
},
{
"name":"ohos.permission.CHANGE_ABILITY_ENABLED_STATE",
"reason":"need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE"
},
{
"name":"ohos.permission.REMOVE_CACHE_FILES",
"reason":"need use ohos.permission.REMOVE_CACHE_FILES"
},
{
"name":"ohos.permission.LISTEN_BUNDLE_CHANGE",
"reason":"need use ohos.permission.LISTEN_BUNDLE_CHANGE"
},
{
"name":"ohos.permission.INSTALL_BUNDLE",
"reason":"need use ohos.permission.INSTALL_BUNDLE"
},
{
"name":"ohos.permission.MANAGE_MISSIONS",
"reason":"need use ohos.permission.MANAGE_MISSIONS"
},
{
"name":"ohos.permission.GET_RUNNING_INFO",
"reason":"need use ohos.permission.GET_RUNNING_INFO"
},
{
"name":"ohos.permission.CLEAN_BACKGROUND_PROCESSES",
"reason":"need use ohos.permission.CLEAN_BACKGROUND_PROCESSES"
},
{
"name":"ohos.permission.CLEAN_APPLICATION_DATA",
"reason":"need use ohos.permission.CLEAN_APPLICATION_DATA"
},
{
"name":"ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS",
"reason":"need use ohos.permission.GET_RUNNING_INFO"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
\ 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.
*/
export default {
onCreate() {
console.info('ActsProcessManageJsTest onCreate');
},
onDestroy() {
console.info('ActsProcessManageJsTest onDestroy');
},
onShow() {
console.info('ActsProcessManageJsTest onShow');
},
onHide() {
console.info('ActsProcessManageJsTest onHide');
}
};
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 100px;
}
.btn {
width: 200px;
height: 80px;
}
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
<button class="btn" type="capsule" value="start" onclick="start"></button>
</div>
/*
* 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 { Core, ExpectExtend } from 'deccjsunit/index'
const injectRef = Object.getPrototypeOf(global) || global
injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
export default {
data: {
title: "",
testTime: 0
},
onInit() {
console.info('ActsProcessManageJsTest onInit');
this.title = this.$t('strings.world');
},
onShow() {
console.info('ActsProcessManageJsTest onShow');
console.info('ActsProcessManageJsTest testTime' + this.testTime);
if (this.testTime == 0) {
const core = Core.getInstance()
const expectExtend = new ExpectExtend({
'id': 'extend'
})
core.addService('expect', expectExtend)
core.init()
const configService = core.getDefaultService('config')
this.timeout = 30000;
configService.setConfig(this)
require('../../../test/List.test')
core.execute()
}
this.testTime++;
},
onReady() {
console.info('ActsProcessManageJsTest onReady');
},
onActive() {
console.info('ActsProcessManageJsTest onActive');
},
onInactive() {
console.info('ActsProcessManageJsTest onInactive');
},
onHide() {
console.info('ActsProcessManageJsTest onHide');
},
onDestroy() {
console.info('ActsProcessManageJsTest onDestroy');
},
onBackPress() {
console.info('ActsProcessManageJsTest onBackPress');
},
onNewRequest() {
console.info('ActsProcessManageJsTest onNewRequest');
},
onStartContinuation() {
console.info('ActsProcessManageJsTest onStartContinuation');
},
onSaveData(value) {
console.info('ActsProcessManageJsTest onSaveData:' + JSON.stringify(value));
},
onRestoreData(value) {
console.info('ActsProcessManageJsTest onRestoreData:' + JSON.stringify(value));
},
onCompleteContinuation(code) {
console.info('ActsProcessManageJsTest onCompleteContinuation:' + JSON.stringify(code));
},
onConfigurationUpdated(configuration) {
console.info('ActsProcessManageJsTest onConfigurationUpdated:' + JSON.stringify(configuration));
}
}
{
"string": [
{
"name": "app_name",
"value": "actsparticleabilitytest"
},
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability"
}
]
}
\ 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, 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('ActskillProcessWithaccountTest', function () {
beforeEach(async (done) => {
console.log('======>beforeEach killProcessWithAccountFATest<=======');
await featureAbility.startAbility({
want:
{
bundleName: BUNDLE_NAME,
abilityName: START_ABILITY_NAME
}
}).then(async () => {
console.log("====>end ACTS_KillProcessWithAccountFA 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_KillProcessWithAccountFA_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_KillProcessWithAccountFA_0100', 0, async function (done) {
console.debug("====>ACTS_KillProcessWithAccountFA_0100 start startAbility====>");
var procrssinfo = await appManager.getProcessRunningInfos()
console.log('ACTS_KillProcessWithAccountFA_0100 ==1== getProcessRunningInfos ======> '
+ JSON.stringify(procrssinfo));
var infores = checkRunningProcess(BUNDLE_NAME, procrssinfo)
console.log("====>ACTS_KillProcessWithAccountFA_0100====>infores = " + infores)
expect(infores).assertEqual(true);
await appManager.killProcessWithAccount(BUNDLE_NAME, ACCOUNT_ID).then(async () => {
console.log('ACTS_KillProcessWithAccountFA_0100 killProcess ======> start');
})
setTimeout(async () => {
var copyprocrssinfo = await appManager.getProcessRunningInfos()
console.log('ACTS_KillProcessWithAccountFA_0100 getProcessRunningInfos ======> '
+ JSON.stringify(copyprocrssinfo));
var outcopy = checkRunningProcess(BUNDLE_NAME, copyprocrssinfo)
console.log("====>ACTS_KillProcessWithAccountFA_0100====>outcopy = " + outcopy)
expect(outcopy).assertEqual(false);
done();
}, 3000)
})
/**
* @tc.number: ACTS_KillProcessWithAccountFA_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_KillProcessWithAccountFA_0300', 0, async function (done) {
console.debug("====>ACTS_KillProcessWithAccountFA_0300 start startAbility====>");
var getinfo = await appManager.getProcessRunningInfos()
console.log('ACTS_KillProcessWithAccountFA_0300 getProcessRunningInfos =1= ======> '
+ JSON.stringify(getinfo));
var res = checkRunningProcess(BUNDLE_NAME, getinfo)
console.log("====>ACTS_KillProcessWithAccountFA_0300====>res = " + res)
expect(res).assertEqual(true);
appManager.killProcessWithAccount(NULL_BUNDLE_NAME, ACCOUNT_ID).then(() => {
console.log('ACTS_KillProcessWithAccountFA_0300 ======> ');
})
setTimeout(async () => {
var procrssinfo = await appManager.getProcessRunningInfos()
console.log('ACTS_KillProcessWithAccountFA_0300 ==1== getProcessRunningInfos ======> '
+ JSON.stringify(procrssinfo));
var infores = checkRunningProcess(BUNDLE_NAME, procrssinfo)
console.log("====>ACTS_KillProcessWithAccountFA_0300====>infores = " + infores)
expect(infores).assertEqual(true);
await appManager.killProcessWithAccount(BUNDLE_NAME, ACCOUNT_ID).then(async () => {
console.log('ACTS_KillProcessWithAccountFA_0300 killProcess ======> start');
sleep(500)
var copyprocrssinfo = await appManager.getProcessRunningInfos()
console.log('ACTS_KillProcessWithAccountFA_0300 getProcessRunningInfos ======> '
+ JSON.stringify(copyprocrssinfo));
var outcopy = checkRunningProcess(BUNDLE_NAME, copyprocrssinfo)
console.log("====>ACTS_KillProcessWithAccountFA_0300====> outcopy = " + outcopy)
expect(outcopy).assertEqual(false);
done();
})
}, 1500)
})
/**
* @tc.number: ACTS_KillProcessWithAccountFA_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_KillProcessWithAccountFA_0400', 0, async function (done) {
console.debug("====>ACTS_KillProcessWithAccountFA_0400 start startAbility====>");
var getinfo = await appManager.getProcessRunningInfos()
console.log('ACTS_KillProcessWithAccountFA_0400 getProcessRunningInfos =1= ======> '
+ JSON.stringify(getinfo));
var res = checkRunningProcess(BUNDLE_NAME, getinfo)
console.log("====>ACTS_KillProcessWithAccountFA_0400====>res = " + res)
expect(res).assertEqual(true);
appManager.killProcessWithAccount(BUNDLE_NAME, NULL_ACCOUNT_ID).then(() => {
console.log('ACTS_KillProcessWithAccountFA_0400 killProcess ======> start');
})
setTimeout(async () => {
var procrssinfo = await appManager.getProcessRunningInfos()
console.log('ACTS_KillProcessWithAccountFA_0400 ==1== getProcessRunningInfos ======> '
+ JSON.stringify(procrssinfo));
var infores = checkRunningProcess(BUNDLE_NAME, procrssinfo)
console.log("====>ACTS_KillProcessWithAccountFA_0400====>infores = " + infores)
expect(infores).assertEqual(true);
appManager.killProcessWithAccount(BUNDLE_NAME, ACCOUNT_ID).then(async () => {
console.log('ACTS_KillProcessWithAccountFA_0400 killProcess2 ======> start');
sleep(500)
var copyprocrssinfo = await appManager.getProcessRunningInfos()
console.log('ACTS_KillProcessWithAccountFA_0400 ==2== getProcessRunningInfos ======>'
+ JSON.stringify(copyprocrssinfo));
var out = checkRunningProcess(BUNDLE_NAME, copyprocrssinfo)
console.log("====>ACTS_KillProcessWithAccountFA_0400====>infores = " + out)
expect(out).assertEqual(false);
done();
})
}, 1500)
})
/**
* @tc.number: ACTS_KillProcessWithAccountFA_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_KillProcessWithAccountFA_0500', 0, async function (done) {
console.debug("====>ACTS_KillProcessWithAccountFA_0500 start startAbility====>");
var procrssinfo = await appManager.getProcessRunningInfos()
console.log('ACTS_KillProcessWithAccountFA_0500 ==1== getProcessRunningInfos ======> '
+ JSON.stringify(procrssinfo));
var infores = checkRunningProcess(BUNDLE_NAME, procrssinfo)
console.log("====>ACTS_KillProcessWithAccountFA_0500====>infores = " + infores)
expect(infores).assertEqual(true);
await appManager.killProcessWithAccount(BUNDLE_NAME, ACCOUNT_ID, (async () => {
console.log('ACTS_KillProcessWithAccountFA_0500 killProcess ======> start');
}))
setTimeout(async () => {
var copyprocrssinfo = await appManager.getProcessRunningInfos()
console.log('ACTS_KillProcessWithAccountFA_0500 getProcessRunningInfos ======> '
+ JSON.stringify(copyprocrssinfo));
var outcopy = checkRunningProcess(BUNDLE_NAME, copyprocrssinfo)
console.log("====>ACTS_KillProcessWithAccountFA_0500====>outcopy = " + outcopy)
expect(outcopy).assertEqual(false);
done();
}, 3000)
})
/**
* @tc.number: ACTS_KillProcessWithAccountFA_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_KillProcessWithAccountFA_0700', 0, async function (done) {
console.debug("====>ACTS_KillProcessWithAccountFA_0700 start startAbility====>");
var getinfo = await appManager.getProcessRunningInfos()
console.log('ACTS_KillProcessWithAccountFA_0700 getProcessRunningInfos =1= ======> '
+ JSON.stringify(getinfo));
var res = checkRunningProcess(BUNDLE_NAME, getinfo)
console.log("====>ACTS_KillProcessWithAccountFA_0700====>res = " + res)
expect(res).assertEqual(true);
appManager.killProcessWithAccount(NULL_BUNDLE_NAME, ACCOUNT_ID, (() => {
console.log('ACTS_KillProcessWithAccountFA_0700 killProcess ======> start');
}))
setTimeout(async () => {
var procrssinfo = await appManager.getProcessRunningInfos()
console.log('ACTS_KillProcessWithAccountFA_0700 ==1== getProcessRunningInfos ======> '
+ JSON.stringify(procrssinfo));
var infores = checkRunningProcess(BUNDLE_NAME, procrssinfo)
console.log("====>ACTS_KillProcessWithAccountFA_0700====>infores = " + infores)
expect(infores).assertEqual(true);
await appManager.killProcessWithAccount(BUNDLE_NAME, ACCOUNT_ID).then(async () => {
console.log('ACTS_KillProcessWithAccountFA_0700 killProcess ======> start');
sleep(500)
var copyprocrssinfo = await appManager.getProcessRunningInfos()
console.log('ACTS_KillProcessWithAccountFA_0700 getProcessRunningInfos ======> '
+ JSON.stringify(copyprocrssinfo));
var outcopy = checkRunningProcess(BUNDLE_NAME, copyprocrssinfo)
console.log("====>ACTS_KillProcessWithAccountFA_0700====> outcopy = " + outcopy)
expect(outcopy).assertEqual(false);
done();
})
}, 1500)
})
/**
* @tc.number: ACTS_KillProcessWithAccountFA_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_KillProcessWithAccountFA_0800', 0, async function (done) {
console.debug("====>ACTS_KillProcessWithAccountFA_0800 start startAbility====>");
var getinfo = await appManager.getProcessRunningInfos()
console.log('ACTS_KillProcessWithAccountFA_0800 getProcessRunningInfos =1= ======> '
+ JSON.stringify(getinfo));
var res = checkRunningProcess(BUNDLE_NAME, getinfo)
console.log("====>ACTS_KillProcessWithAccountFA_0800====>res = " + res)
expect(res).assertEqual(true);
appManager.killProcessWithAccount(BUNDLE_NAME, NULL_ACCOUNT_ID, (() => {
console.log('ACTS_KillProcessWithAccountFA_0800 killProcess ======> start');
}))
setTimeout(async () => {
var procrssinfo = await appManager.getProcessRunningInfos()
console.log('ACTS_KillProcessWithAccountFA_0800 ==1== getProcessRunningInfos ======> '
+ JSON.stringify(procrssinfo));
var infores = checkRunningProcess(BUNDLE_NAME, procrssinfo)
console.log("====>ACTS_KillProcessWithAccountFA_0800====>infores = " + infores)
expect(infores).assertEqual(true);
await appManager.killProcessWithAccount(BUNDLE_NAME, ACCOUNT_ID).then(async () => {
console.log('ACTS_KillProcessWithAccountFA_0800 killProcess ======> start');
sleep(500)
var copyprocrssinfo = await appManager.getProcessRunningInfos()
console.log('ACTS_KillProcessWithAccountFA_0800 getProcessRunningInfos ======> '
+ JSON.stringify(copyprocrssinfo));
var outcopy = checkRunningProcess(BUNDLE_NAME, copyprocrssinfo)
console.log("====>ACTS_KillProcessWithAccountFA_0800====> outcopy = " + outcopy)
expect(outcopy).assertEqual(false);
done();
})
}, 1500)
})
})
\ 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.
*/
require('./ActsKillProcessTest.test.js')
\ 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_hap("ActsKillProcessWithAccountCloseApi7") {
hap_name = "ActsKillProcessWithAccountCloseApi7"
hap_profile = "./src/main/config.json"
subsystem_name = XTS_SUITENAME
final_hap_path =
"${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/testcases/${hap_name}.hap"
testonly = true
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./src/main/js/default"
}
ohos_resources("hjs_demo_resources") {
sources = [ "./src/main/js/resources" ]
hap_profile = "./src/main/config.json"
}
{
"app": {
"bundleName": "com.example.actskillprocesswithaccountcloseapi7",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "com.example.actskillprocesswithaccountcloseapi7",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "com.example.actskillprocesswithaccountcloseapi7.MainAbility",
"visible": true,
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"type": "page",
"launchType": "standard"
}
],
"reqPermissions": [
{
"name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
"reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
},
{
"name":"ohos.permission.GET_BUNDLE_INFO",
"reason":"need use ohos.permission.GET_BUNDLE_INFO"
},
{
"name":"ohos.permission.CHANGE_ABILITY_ENABLED_STATE",
"reason":"need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE"
},
{
"name":"ohos.permission.REMOVE_CACHE_FILES",
"reason":"need use ohos.permission.REMOVE_CACHE_FILES"
},
{
"name":"ohos.permission.LISTEN_BUNDLE_CHANGE",
"reason":"need use ohos.permission.LISTEN_BUNDLE_CHANGE"
},
{
"name":"ohos.permission.MANAGE_MISSIONS",
"reason":"need use ohos.permission.MANAGE_MISSIONS"
},
{
"name":"ohos.permission.GET_RUNNING_INFO",
"reason":"need use ohos.permission.GET_RUNNING_INFO"
},
{
"name":"ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS",
"reason":"need use ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS"
},
{
"name":"ohos.permission.CLEAN_BACKGROUND_PROCESSES",
"reason":"need use ohos.permission.CLEAN_BACKGROUND_PROCESSES"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
\ 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.
*/
export default {
onCreate() {
console.info('ProcessManageSystemAppB onCreate');
},
onDestroy() {
console.info('ProcessManageSystemAppB onDestroy');
},
onShow() {
console.info('ProcessManageSystemAppB onShow');
},
onHide() {
console.info('ProcessManageSystemAppB onHide');
}
};
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 100px;
}
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
</div>
/*
* 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 commonEvent from '@ohos.commonevent'
const injectRef = Object.getPrototypeOf(global) || global
injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
export default {
data: {
title: ""
},
onInit() {
console.info('ACTS_ProcessManage SystemAppB onInit');
this.title = "ACTS_ProcessManage SystemAppB";
},
onReady() {
console.info('ACTS_ProcessManage SystemAppB onReady');
},
onActive() {
console.info('ACTS_ProcessManage SystemAppB onActive');
},
onShow() {
console.info('ACTS_ProcessManage SystemAppB onShow');
},
onInactive() {
console.info('ACTS_ProcessManage SystemAppB onInactive');
},
onHide() {
console.info('ACTS_ProcessManage SystemAppB onHide');
},
onDestroy() {
console.info('ACTS_ProcessManage SystemAppB onDestroy');
},
onBackPress() {
console.info('ACTS_ProcessManage SystemAppB onBackPress');
},
onNewRequest() {
console.info('ACTS_ProcessManage SystemAppB onNewRequest');
},
onStartContinuation() {
console.info('ACTS_ProcessManage SystemAppB onStartContinuation');
},
onSaveData(value) {
console.info('ACTS_ProcessManage SystemAppB onSaveData:' + JSON.stringify(value));
},
onRestoreData(value) {
console.info('ACTS_ProcessManage SystemAppB onRestoreData:' + JSON.stringify(value));
},
onCompleteContinuation(code) {
console.info('ACTS_ProcessManage SystemAppB onCompleteContinuation:' + JSON.stringify(code));
},
onConfigurationUpdated(configuration) {
console.info('ACTS_ProcessManage SystemAppB onConfigurationUpdated:' + JSON.stringify(configuration));
}
}
\ No newline at end of file
{
"string": [
{
"name": "app_name",
"value": "particlestartability"
},
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability"
}
]
}
\ 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")
group("ActsKillProcessWithAccountApi7") {
testonly = true
if (is_standard_system) {
deps = [
"ActsKillProcessWithAccountApi7Test:ActsKillProcessWithAccountApi7Test",
"ActsKillProcessWithAccountCloseApi7:ActsKillProcessWithAccountCloseApi7",
]
}
}
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* 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
......
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* 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
......
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* 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
......
......@@ -17,16 +17,20 @@ group("aafwk_standard") {
testonly = true
if (is_standard_system) {
deps = [
"ActsStServiceAbilityClientCaseTest:ActsStServiceAbilityClientCaseTest",
"ActsAbilityLifecycleStateNewTest:ActsAbilityLifecycleStateNewTest",
"ActsDataAbilityJsTest:ActsDataAbilityJsTest",
"ActsKillProcessWithAccountApi7:ActsKillProcessWithAccountApi7",
"ActsStServiceAbilityClientCaseTest:ActsStServiceAbilityClientCaseTest",
"abilitymanager:actsabilitymanagertest",
"actsabilitydistributetest:ActsAbilityDistributeTest",
"actsabilitydistributetest:ActsAbilityDistributeTest",
"actsabilitymanageretstest:ActsAbilityManagerEtsTest",
"amsZipfileUnzipfileST:ActsZlibTest",
"amsabilitymanager/amsMissionSnapshotTest:ActsAmsMissionSnapshotTest",
"amsabilitymanager/amsMissionSnapshotTestSingleton:ActsAmsMissionSnapshotTestSingleton",
"amsabilitymanager/amsMissionSnapshotTestSingletonS:ActsAmsMissionSnapshotTestSingletonS",
"amsdatauriutils:ActsAmsDataUriUtilsTest",
"amsgetabilityprocessinfo:amsgetabilityprocessinfo",
"amsmultiapp/MultiAppPage:ActsAmsMultiPageApp",
"amsmultiapp/MultiAppPageConnectService:ActsAmsMultiPageAppConnectService",
"amsmultiapp/MultiAppPageConnect_Service:ActsAmsMultiAppPageConnectService",
......@@ -45,14 +49,17 @@ group("aafwk_standard") {
"amsmultiapp/amsmultiapptester:ActsAmsMultiAppTester",
"amsmultiapp/amsmultidataabilityclone:ActsAmsMultiDataAbilityClone",
"amsmultiapp/amsmultidataabilityself:ActsAmsMultiDataAbilitySelf",
"amsprocessmanageapi7:amsprocessmanageapi7",
"context:context",
"featureability:featureability",
"formmanager:formmanager",
"lanuageConfigapi7:lanuageConfigapi7",
"serviceability/sceneProject/particlestartability:ParticleStartAbility",
"serviceability/sceneProject/particletestserver:ParticleTestServer",
"serviceability/stserviceabilityserver:amsStServiceAilityServer",
"serviceability/stserviceabilityserversecond:ActsAmsStServiceAilityServerSecondTest",
"setshowonlockscreen:setshowonlockscreen",
"stage:stage",
"want:want",
]
}
......
......@@ -60,7 +60,7 @@ describe('ActsAmsCallBackSixth Scene', function () {
console.info('Acts_Ams_test_12200 clearMissions error.code ' + error.code + ',data [' + info + ']' );
expect(typeof(error.code)).assertEqual("number");
expect(error.code).assertEqual(0);
done();
});
done();
})
})
\ No newline at end of file
......@@ -58,6 +58,7 @@ describe('ActsAmsCallBackSixth Scene', function () {
var info = await missionManager.clearAllMissions().catch(err => {
console.log('Acts_Ams_test_12100 clearAllMission failed: ' + err);
expect(err).assertEqual(0);
done();
});
console.info('Acts_Ams_test_12100 clearAllMissions data [' + info + ']');
done();
......
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsAbilityManagerEtsTest") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_ets_assets",
":hjs_demo_ets_resources",
]
ets2abc = true
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsAbilityManagerEtsTest"
}
ohos_js_assets("hjs_demo_ets_assets") {
source_dir = "./entry/src/main/ets/MainAbility"
}
ohos_resources("hjs_demo_ets_resources") {
sources = [ "./entry/src/main/resources" ]
hap_profile = "./entry/src/main/config.json"
}
{
"description": "Configuration for aceceshi Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "600000",
"package": "com.ohos.acecollaboration",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"ActsAbilityManagerEtsTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "com.ohos.acecollaboration",
"vendor": "ohos",
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 7,
"releaseType": "Release",
"target": 7
}
},
"deviceConfig": {},
"module": {
"package": "com.ohos.acecollaboration",
"name": ".MyApplication",
"mainAbility": "com.ohos.acecollaboration.MainAbility",
"deviceType": [
"phone"
],
"reqPermissions": [
{
"name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
},
{
"name": "ohos.permission.GET_BUNDLE_INFO"
}
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry",
"installationFree": false
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"visible": true,
"srcPath": "MainAbility",
"srcLanguage": "ets",
"name": "com.ohos.acecollaboration.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:entry_MainAbility",
"type": "page",
"launchType": "standard"
},
{
"orientation": "unspecified",
"srcPath": "MainAbility2",
"name": ".MainAbility2",
"srcLanguage": "ets",
"icon": "$media:icon",
"description": "$string:description_mainability2",
"formsEnabled": false,
"label": "$string:entry_MainAbility2",
"type": "page",
"launchType": "standard"
},
{
"srcPath": "ServiceAbility",
"name": ".ServiceAbility",
"icon": "$media:icon",
"srcLanguage": "ets",
"description": "$string:description_serviceability",
"type": "service"
},
{
"srcPath": "ServiceAbility2",
"name": ".ServiceAbility2",
"icon": "$media:icon",
"srcLanguage": "ets",
"description": "$string:description_serviceability2",
"type": "service"
},
{
"srcPath": "ServiceAbility3",
"name": ".ServiceAbility3",
"icon": "$media:icon",
"srcLanguage": "ets",
"description": "$string:description_serviceability3",
"type": "service"
},
{
"srcPath": "ServiceAbility4",
"name": ".ServiceAbility4",
"icon": "$media:icon",
"srcLanguage": "ets",
"description": "$string:description_serviceability4",
"type": "service"
},
{
"srcPath": "ServiceAbility5",
"name": ".ServiceAbility5",
"icon": "$media:icon",
"srcLanguage": "ets",
"description": "$string:description_serviceability5",
"type": "service"
},
{
"srcPath": "ServiceAbility6",
"name": ".ServiceAbility6",
"icon": "$media:icon",
"srcLanguage": "ets",
"description": "$string:description_serviceability6",
"type": "service"
},
{
"srcPath": "ServiceAbility7",
"name": ".ServiceAbility7",
"icon": "$media:icon",
"srcLanguage": "ets",
"description": "$string:description_serviceability7",
"type": "service"
}
],
"js": [
{
"mode": {
"syntax": "ets",
"type": "pageAbility"
},
"pages": [
"pages/index"
],
"name": "MainAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
},
{
"mode": {
"syntax": "ets",
"type": "pageAbility"
},
"pages": [
"pages/index"
],
"name": ".MainAbility2",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
],
"defPermissions": [
{
"name": "com.ohos.acecollaboration.DataAbilityShellProvider.PROVIDER"
}
]
}
}
\ 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.
*/
export default {
onCreate() {
console.info('Application onCreate')
},
onDestroy() {
console.info('Application onDestroy')
},
}
\ 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 file from '@system.file';
import {Core, ExpectExtend, ReportExtend} from "deccjsunit/index.ets";
import testsuite from "../test/List.test.ets";
import featureAbility from "@ohos.ability.featureAbility";
async function startService2() {
var str = {
"want": {
"bundleName": "com.ohos.acecollaboration",
"abilityName": "com.ohos.acecollaboration.ServiceAbility2",
},
};
var data = featureAbility.startAbility(str);
console.info('particleAbility_connectAbility_test_0100 startAbility succeeded: ' + JSON.stringify(data));
}
async function startService3() {
var str = {
"want": {
"bundleName": "com.ohos.acecollaboration",
"abilityName": "com.ohos.acecollaboration.ServiceAbility3",
},
};
var data = featureAbility.startAbility(str);
console.info('particleAbility_connectAbility_test_0200 startAbility succeeded: ' + JSON.stringify(data));
}
async function startService4() {
var str = {
"want": {
"bundleName": "com.ohos.acecollaboration",
"abilityName": "com.ohos.acecollaboration.ServiceAbility4",
},
};
var data = featureAbility.startAbility(str);
console.info('particleAbility_connectAbility_test_0300 startAbility succeeded: ' + JSON.stringify(data));
}
async function startService5() {
var str = {
"want": {
"bundleName": "com.ohos.acecollaboration",
"abilityName": "com.ohos.acecollaboration.ServiceAbility5",
},
};
var data = featureAbility.startAbility(str);
console.info('particleAbility_connectAbility_test_0400 startAbility succeeded: ' + JSON.stringify(data));
}
async function startService6(){
var str = {
"want": {
"bundleName": "com.ohos.acecollaboration",
"abilityName": "com.ohos.acecollaboration.ServiceAbility6",
},
};
var data = featureAbility.startAbility(str);
console.info('particleAbility_connectAbility_test_0500 startAbility succeeded: ' + JSON.stringify(data));
}
async function startService7(){
var str = {
"want": {
"bundleName": "com.ohos.acecollaboration",
"abilityName": "com.ohos.acecollaboration.ServiceAbility7",
},
};
var data = featureAbility.startAbility(str);
console.info('particleAbility_connectAbility_test_0600 startAbility succeeded: ' + JSON.stringify(data));
}
@Entry
@Component
struct MyComponent {
aboutToAppear() {
console.info("start run testcase!!!!")
featureAbility.getWant()
.then((Want) => {
const core = Core.getInstance();
const expectExtend = new ExpectExtend({
'id': 'extend'
});
core.addService('expect', expectExtend);
const reportExtend = new ReportExtend(file);
core.addService('report', reportExtend);
core.init();
core.subscribeEvent('task', reportExtend);
const configService = core.getDefaultService('config');
console.info('parameters---->' + JSON.stringify(Want.parameters));
configService.setConfig(Want.parameters);
testsuite();
core.execute();
console.info('Operation successful. Data: ' + JSON.stringify(Want));
})
.catch((error) => {
console.error('Operation failed. Cause: ' + JSON.stringify(error));
})
}
build() {
Flex({
direction: FlexDirection.Column,
alignItems: ItemAlign.Center,
justifyContent: FlexAlign.Center
}) {
Text('ACE ETS TEST 组件协同')
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button('disconnectAbility_promise')
.fontSize(40)
.height(40)
.margin({ top: 20 })
.fontWeight(FontWeight.Bold)
.onClick(() => {
startService2();
});
Button('disconnectAbility_callback')
.fontSize(40)
.height(40)
.margin({ top: 20 })
.fontWeight(FontWeight.Bold)
.onClick(() => {
startService3();
});
Button('connectotherAbility')
.fontSize(40)
.height(40)
.margin({ top: 20 })
.fontWeight(FontWeight.Bold)
.onClick(() => {
startService4();
});
Button('connectnull')
.fontSize(40)
.height(40)
.margin({ top: 20 })
.fontWeight(FontWeight.Bold)
.onClick(() => {
startService5();
});
Button('connecterror')
.fontSize(40)
.height(40)
.margin({top:20})
.fontWeight(FontWeight.Bold)
.onClick(() => {
startService6();
});
Button('connectAPI8')
.fontSize(40)
.height(40)
.margin({top:20})
.fontWeight(FontWeight.Bold)
.onClick(() => {
startService7();
});
}
.width('100%')
.height('100%')
}
}
/**
* 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 featureAbility from '@ohos.ability.featureAbility'
import {describe, beforeEach, afterEach, it, expect} from "deccjsunit/index.ets";
import Utils from './Utils';
export default function contextJsunit() {
describe('appInfoTest', function () {
beforeEach(async function (done) {
console.info("context before each called");
done()
});
afterEach(async function () {
await Utils.sleep(2000);
console.info("context after each called");
});
/*
* @tc.number: context_getCacheDir_test_0100
* @tc.name: getCacheDir : Obtains the Cache directory on internal storage.
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it("context_getCacheDir_test_0100", 0, async function (done) {
console.log("------------------start context_getCacheDir_test_0100-------------------");
try {
var timeOldStamp = await Utils.getNowTime();
var context = await featureAbility.getContext();
context.getCacheDir().then((data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('context_getCacheDir_test_0100', timeOldStamp, timeNewStamp)
console.log("context_getCacheDir_test_0100: CacheDir is " + data);
})
} catch (error) {
console.log("logMessage context_getCacheDir_test_0100: error = " + error);
expect(error).assertEqual("/data/accounts/account_0/appdata/com.ohos.acecollaboration/cache");
}
var data1 = await context.getCacheDir();
expect(typeof (data1)).assertEqual("string");
expect(data1).assertEqual("/data/accounts/account_0/appdata/com.ohos.acecollaboration/cache");
done();
console.log("------------------end context_getCacheDir_test_0100-------------------");
});
/*
* @tc.number: context_getCacheDir_test_0200
* @tc.name: getCacheDir : Obtains the Cache directory on internal storage.
* @tc.desc: Check the return value of the interface (by AsyncCallback)
* @tc.level 0
*/
it("context_getCacheDir_test_0200", 0, async function (done) {
console.log("------------------start context_getCacheDir_test_0200-------------------");
try {
var timeOldStamp = await Utils.getNowTime();
var context = await featureAbility.getContext();
context.getCacheDir((err, data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('context_getCacheDir_test_0200', timeOldStamp, timeNewStamp)
console.log("context_getCacheDir_test_0200: getCacheDir successful, result = " + data);
});
} catch (error) {
console.log("logMessage context_getCacheDir_test_0200: error = " + error);
expect(error).assertEqual("/data/accounts/account_0/appdata/com.ohos.acecollaboration/cache");
}
var data1 = await context.getCacheDir();
expect(typeof (data1)).assertEqual("string");
expect(data1).assertEqual("/data/accounts/account_0/appdata/com.ohos.acecollaboration/cache");
done();
console.log("------------------end context_getCacheDir_test_0200-------------------");
});
/*
* @tc.number: context_getFilesDir_test_0100
* @tc.name: getFilesDir : Obtains the files directory on internal storage.
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it("context_getFilesDir_test_0100", 0, async function (done) {
console.log("------------------start context_getFilesDir_test_0100-------------------");
try {
var timeOldStamp = await Utils.getNowTime();
var context = await featureAbility.getContext();
context.getFilesDir().then((data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('context_getFilesDir_test_0100', timeOldStamp, timeNewStamp)
console.log("context_getFilesDir_test_0100:FilesDir is " + data);
})
} catch (error) {
console.log("logMessage context_getFilesDir_test_0100: error = " + error);
expect(error).assertEqual("/data/accounts/account_0/appdata/com.ohos.acecollaboration/files");
}
var data1 = await context.getFilesDir();
expect(typeof (data1)).assertEqual("string");
expect(data1).assertEqual("/data/accounts/account_0/appdata/com.ohos.acecollaboration/files");
done();
console.log("------------------end context_getFilesDir_test_0100-------------------");
});
/*
* @tc.number: context_getFilesDir_test_0200
* @tc.name: getFilesDir : Obtains the files directory on internal storage.
* @tc.desc: Check the return value of the interface (by AsyncCallback)
* @tc.level 0
*/
it("context_getFilesDir_test_0200", 0, async function (done) {
console.log("------------------start context_getFilesDir_test_0200-------------------");
try {
var timeOldStamp = await Utils.getNowTime();
var context = await featureAbility.getContext();
context.getFilesDir((err, data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('context_getFilesDir_test_0200', timeOldStamp, timeNewStamp)
console.log("context_getFilesDir_test_0200: getFilesDir successful, result = " + data);
});
} catch (error) {
console.log("logMessage context_getFilesDir_test_0200: error = " + error);
expect(error).assertEqual("/data/accounts/account_0/appdata/com.ohos.acecollaboration/files");
}
var data1 = await context.getFilesDir();
expect(typeof (data1)).assertEqual("string");
expect(data1).assertEqual("/data/accounts/account_0/appdata/com.ohos.acecollaboration/files");
done();
console.log("------------------end context_getFilesDir_test_0200-------------------");
});
/*
* @tc.number: context_getOrCreateDistributedDir_test_0100
* @tc.name: getOrCreateDistributedDir : Obtains the directory of Distributed files.
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it("context_getOrCreateDistributedDir_0100", 0, async function (done) {
console.log("------------------start context_getOrCreateDistributedDir_0100-------------------");
try {
var timeOldStamp = await Utils.getNowTime();
var context = await featureAbility.getContext();
context.getOrCreateDistributedDir().then((data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('context_getOrCreateDistributedDir_0100', timeOldStamp, timeNewStamp);
console.log("context_getOrCreateDistributedDir_0100: DistributedDir is " + data);
})
} catch (error) {
console.log("logMessage context_getOrCreateDistributedDir_0100: error = " + error);
expect(error).assertEqual("/data/storage/el2/distributedfiles/entry");
}
var data1 = await context.getOrCreateDistributedDir();
expect(typeof (data1)).assertEqual("string");
expect(data1).assertEqual("/data/storage/el2/distributedfiles/entry");
done();
console.log("------------------end context_getOrCreateDistributedDir_0100-------------------");
});
/*
* @tc.number: context_getOrCreateDistributedDir_0200
* @tc.name: getOrCreateDistributedDir : Obtains the directory of Distributed files.
* @tc.desc: Check the return value of the interface (by AsyncCallback)
* @tc.level 0
*/
it("context_getOrCreateDistributedDir_0200", 0, async function (done) {
console.log("------------------start context_getOrCreateDistributedDir_0200-------------------");
try {
var timeOldStamp = await Utils.getNowTime();
var context = await featureAbility.getContext();
context.getOrCreateDistributedDir((err, data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('context_getOrCreateDistributedDir_0200', timeOldStamp, timeNewStamp);
console.log("context_getOrCreateDistributedDir_0200: getOrCreateDistributedDir successful, result = " + data);
});
} catch (error) {
console.log("logMessage context_getOrCreateDistributedDir_0200: error = " + error);
expect(error).assertEqual("/data/storage/el2/distributedfiles/entry");
}
var data1 = await context.getOrCreateDistributedDir();
expect(typeof (data1)).assertEqual("string");
expect(data1).assertEqual("/data/storage/el2/distributedfiles/entry");
done();
console.log("------------------end context_getOrCreateDistributedDir_0200-------------------");
});
/*
* @tc.number: context_getAppType_0100
* @tc.name: getAppType : Obtains the type of current application.
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it("context_getAppType_0100", 0, async function (done) {
console.log("------------------start context_getAppType_0100-------------------");
try {
var timeOldStamp = await Utils.getNowTime();
var context = await featureAbility.getContext();
context.getAppType().then((data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('context_getAppType_0100_0100', timeOldStamp, timeNewStamp);
console.log("context_getAppType_0100: AppType is " + data);
})
} catch (error) {
console.log("logMessage context_getAppType_0100: error = " + error);
expect(error).assertEqual("system");
}
var data1 = await context.getAppType();
expect(typeof (data1)).assertEqual("string");
expect(data1).assertEqual("system");
done();
console.log("------------------end context_getAppType_0100-------------------");
});
/*
* @tc.number: context_getAppType_0200
* @tc.name: getAppType : Obtains the type of current application.
* @tc.desc: Check the return value of the interface (by AsyncCallback)
* @tc.level 0
*/
it("context_getAppType_0200", 0, async function (done) {
console.log("------------------start context_getAppType_0200-------------------");
try {
var timeOldStamp = await Utils.getNowTime();
var context = await featureAbility.getContext();
context.getAppType((err, data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('context_getAppType_0200_0100', timeOldStamp, timeNewStamp);
console.log("context_getAppType_0200: getAppType successful, result = " + data);
});
} catch (error) {
console.log("logMessage context_getAppType_0200: error = " + error);
expect(error).assertEqual("system");
}
var data1 = await context.getAppType();
expect(typeof (data1)).assertEqual("string");
expect(data1).assertEqual("system");
done();
console.log("------------------end context_getAppType_0200-------------------");
});
})
}
/**
* 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 addContextAndAbilityJsunit from './addContextAndAbilityJsunit.test.ets';
import getHapModuleInfoJsunit from './getHapModuleInfoJsunit.test.ets';
import getAbilityInfoJsunit from './getAbilityInfoJsunit.test.ets';
import getApplicationContext from './getApplicationContextJsunit.test.ets';
import getAppVersionInfoJsunit from './getAppVersionInfoJsunit.test.ets';
import ContextJsunit from './ContextJsunit.test.ets';
import DataAbilityJsunit from './DataAbility.test.ets';
export default function testsuite() {
ContextJsunit();
DataAbilityJsunit();
addContextAndAbilityJsunit();
getHapModuleInfoJsunit();
getAbilityInfoJsunit();
getApplicationContext();
getAppVersionInfoJsunit();
}
\ 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.
*/
export default class Utils {
static sleep(time) {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve(reject)
}, time)
}).then(() => {
console.info(`sleep ${time} over...`)
})
}
static getNowTime() {
return new Date().getTime();
}
/**
* 接口调用时间
* @param startTime 接口调用开始时间
* @param endTime 接口调用结束时间
*/
static getDurationTime(msg, startTime, endTime) {
console.info(msg + 'Get Interface startTime: ' + startTime);
console.info(msg + 'Get Interface endTime: ' + endTime);
var duration = (endTime - startTime)
console.info(msg + 'Get Interface Duration: ' + duration);
return duration;
}
}
/**
* 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 "deccjsunit/index.ets";
import Utils from './Utils';
import ability_featureAbility from '@ohos.ability.featureAbility';
import abilityManager from "@ohos.app.abilitymanager"
const TAG_TEST_0100 = ' context_isUpdatingConfigurations_test_0100 ';
const TAG_TEST_0200 = ' context_isUpdatingConfigurations_test_0200 ';
const TAG_TEST_0300 = ' context_printDrawnCompleted_test_0100 ';
const TAG_TEST_0400 = ' context_printDrawnCompleted_test_0200 ';
const TAG_TEST_0500 = ' context_getAppMemorySize_test_0100 ';
const TAG_TEST_0600 = ' context_getAppMemorySize_test_0200 ';
const TAG_TEST_0700 = ' context_isRamConstrainedDevice_test_0100 ';
const TAG_TEST_0800 = ' context_isRamConstrainedDevice_test_0200 ';
const TAG_TEST_0900 = ' context_featureAbility_test_0100 ';
const TAG_TEST_0010 = ' context_featureAbility_test_0200 ';
const TAG_TEST_0011 = ' context_featureAbility_test_0300 ';
const TAG_TEST_0012 = ' context_featureAbility_test_0400 ';
export default function addContextAndAbilityJsunit() {
describe('appInfoTest', function () {
/*
* @tc.number: context_isUpdatingConfigurations_test_0100
* @tc.name: isUpdatingConfigurations : Obtains whether the configuration of the current ability is changing.
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it(TAG_TEST_0100, 0, async function (done) {
console.info(TAG_TEST_0100 + 'promise START');
let detailed;
var startTime = await Utils.getNowTime();
var context = ability_featureAbility.getContext();
await context.isUpdatingConfigurations().then((data) => {
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0100, startTime, endTime)
console.info(TAG_TEST_0100 + ' promise data is:' + JSON.stringify(data));
detailed = data;
}).catch((error) => {
console.error(TAG_TEST_0100 + 'promise errors is: ' + JSON.stringify(error));
})
expect(typeof (detailed)).assertEqual("boolean");
expect(detailed).assertEqual(false);
done();
console.log('------------------ ' + TAG_TEST_0100 + ' end -------------------');
});
/*
* @tc.number: context_isUpdatingConfigurations_test_0200
* @tc.name: isUpdatingConfigurations : Obtains whether the configuration of the current ability is changing.
* @tc.desc: Check the return value of the interface (by AsyncCallback)
* @tc.level 0
*/
it(TAG_TEST_0200, 0, async function (done) {
let detailed;
console.info(TAG_TEST_0200 + 'callBack START');
try {
var startTime = await Utils.getNowTime();
var context = ability_featureAbility.getContext();
context.isUpdatingConfigurations((error, data) => {
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0200, startTime, endTime)
detailed = data;
console.info(TAG_TEST_0200 + ' callBack succeeded. data is:' + JSON.stringify(data));
});
} catch (error) {
console.error(TAG_TEST_0200 + 'Operation failed. Cause: ' + JSON.stringify(error));
}
await Utils.sleep(2000)
expect(typeof (detailed)).assertEqual("boolean");
expect(detailed).assertEqual(false);
done();
console.log('------------------ ' + TAG_TEST_0200 + ' end -------------------');
});
/*
* @tc.number: context_printDrawnCompleted_test_0100
* @tc.name: printDrawnCompleted : Inform the system of the time required to complete the drawing of the page
capability.
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it(TAG_TEST_0300, 0, async function (done) {
let detailed;
console.info(TAG_TEST_0300 + 'callBack START');
var startTime = await Utils.getNowTime();
var context = ability_featureAbility.getContext();
await context.printDrawnCompleted().then((data) => {
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0300, startTime, endTime)
console.info(TAG_TEST_0300 + ' promise data is:' + JSON.stringify(data));
detailed = data;
}).catch((error) => {
console.error(TAG_TEST_0300 + 'promise error is: ' + JSON.stringify(error));
});
await Utils.sleep(2000)
expect(detailed).assertEqual(null);
done();
console.log('------------------ ' + TAG_TEST_0300 + ' end -------------------');
})
/*
* @tc.number: context_printDrawnCompleted_test_0200
* @tc.name: printDrawnCompleted : Inform the system of the time required to complete the drawing of the page
capability.
* @tc.desc: Check the return value of the interface (by AsyncCallback)
* @tc.level 0
*/
it(TAG_TEST_0400, 0, async function (done) {
let detailed;
console.info(TAG_TEST_0400 + 'callBack START');
try {
var startTime = await Utils.getNowTime();
var context = ability_featureAbility.getContext();
context.printDrawnCompleted((error, data) => {
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0300, startTime, endTime)
detailed = data;
console.info(TAG_TEST_0400 + ' callBack succeeded. data is:' + JSON.stringify(data));
});
} catch (error) {
console.error(TAG_TEST_0400 + 'Operation failed. Cause: ' + JSON.stringify(error));
}
await Utils.sleep(2000)
expect(detailed).assertEqual(null);
done();
console.log('------------------ ' + TAG_TEST_0400 + ' end -------------------');
})
/*
* @tc.number: context_getAppMemorySize_test_0100
* @tc.name: getAppMemorySize : Obtains the memory size of the application.
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it(TAG_TEST_0500, 0, async function (done) {
console.info(TAG_TEST_0500 + 'promise START');
let detailed;
var startTime = await Utils.getNowTime();
await abilityManager.getAppMemorySize()
.then((data) => {
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0500, startTime, endTime)
console.info(TAG_TEST_0500 + ' promise data is:' + JSON.stringify(data));
detailed = data;
}).catch((error) => {
console.error(TAG_TEST_0500 + 'promise errors is: ' + JSON.stringify(error));
})
await Utils.sleep(2000)
expect(typeof (detailed)).assertEqual("number");
expect(detailed).assertEqual(512);
done();
console.log('------------------ ' + TAG_TEST_0500 + ' end -------------------');
});
/*
* @tc.number: context_getAppMemorySize_test_0200
* @tc.name: getAppMemorySize : Obtains the memory size of the application.
* @tc.desc: Check the return value of the interface (by AsyncCallback)
* @tc.level 0
*/
it(TAG_TEST_0600, 0, async function (done) {
console.info(TAG_TEST_0600 + 'callBack START');
var startTime = await Utils.getNowTime();
abilityManager.getAppMemorySize((error, data) => {
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0500, startTime, endTime)
console.info(TAG_TEST_0600 + ' callBack error is: ' + JSON.stringify(error));
console.info(TAG_TEST_0600 + ' callBack data is:' + JSON.stringify(data));
expect(typeof (data)).assertEqual("number");
expect(data).assertEqual(512);
console.log('------------------ ' + TAG_TEST_0600 + ' end -------------------');
done();
})
});
/*
* @tc.number: context_isRamConstrainedDevice_test_0100
* @tc.name: isRamConstrainedDevice : Obtains whether the current device has low ram.
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it(TAG_TEST_0700, 0, async function (done) {
let detailed;
console.info(TAG_TEST_0700 + 'promise START');
var startTime = await Utils.getNowTime();
await abilityManager.isRamConstrainedDevice().then((data) => {
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0500, startTime, endTime)
console.info(TAG_TEST_0700 + ' promise data is:' + JSON.stringify(data));
detailed = data;
}).catch((error) => {
console.error(TAG_TEST_0700 + 'promise errors is: ' + JSON.stringify(error));
})
await Utils.sleep(1000)
expect(typeof (detailed)).assertEqual("boolean");
expect(detailed).assertEqual(false)
done();
console.log('------------------ ' + TAG_TEST_0700 + ' end -------------------');
});
/*
* @tc.number: context_isRamConstrainedDevice_test_0200
* @tc.name: isRamConstrainedDevice : Obtains whether the current device has low ram.
* @tc.desc: Check the return value of the interface (by AsyncCallback)
* @tc.level 0
*/
it(TAG_TEST_0800, 0, async function (done) {
console.info(TAG_TEST_0800 + 'callBack START');
var startTime = await Utils.getNowTime();
abilityManager.isRamConstrainedDevice((error, data) => {
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0500, startTime, endTime)
console.info(TAG_TEST_0800 + ' callBack error is:' + error);
console.info(TAG_TEST_0800 + ' callBack data is:' + JSON.stringify(data));
expect(typeof (data)).assertEqual("boolean");
expect(data).assertEqual(false);
done();
})
console.log('------------------ ' + TAG_TEST_0800 + ' end -------------------');
});
/*
* @tc.number: context_featureAbility_test_0100
* @tc.name: featureAbility.ErrorCode : featureAbility.ErrorCode
* @tc.desc: Check the featureAbility.ErrorCode.NO_ERROR
* @tc.level 0
*/
it(TAG_TEST_0900, 0, async function (done) {
console.info(TAG_TEST_0900 + ' NO_ERROR START');
var no_error = ability_featureAbility.ErrorCode.NO_ERROR
console.info(TAG_TEST_0900 + ' featureAbility no_error is: ' + no_error);
expect(typeof (no_error)).assertEqual("number");
expect(no_error).assertEqual(0);
done();
console.log('------------------ ' + TAG_TEST_0900 + ' end -------------------');
});
/*
* @tc.number: context_featureAbility_test_0200
* @tc.name: featureAbility.ErrorCode : featureAbility.ErrorCode
* @tc.desc: Check the featureAbility.ErrorCode.INVALID_PARAMETER
* @tc.level 0
*/
it(TAG_TEST_0010, 0, async function (done) {
console.info(TAG_TEST_0010 + ' INVALID_PARAMETER START');
var invalid_parameter = ability_featureAbility.ErrorCode.INVALID_PARAMETER
console.info(TAG_TEST_0010 + ' featureAbility invalid_parameter is: ' + invalid_parameter);
expect(typeof (invalid_parameter)).assertEqual("number");
expect(invalid_parameter).assertEqual(-1);
done();
console.log('------------------ ' + TAG_TEST_0010 + ' end -------------------');
});
/*
* @tc.number: context_featureAbility_test_0300
* @tc.name: featureAbility.ErrorCode : featureAbility.ErrorCode
* @tc.desc: Check the featureAbility.ErrorCode.ABILITY_NOT_FOUND
* @tc.level 0
*/
it(TAG_TEST_0011, 0, async function (done) {
console.info(TAG_TEST_0011 + ' ABILITY_NOT_FOUND START');
var ability_not_found = ability_featureAbility.ErrorCode.ABILITY_NOT_FOUND
console.info(TAG_TEST_0011 + ' featureAbility ability_not_found is: ' + ability_not_found);
expect(typeof (ability_not_found)).assertEqual("number");
expect(ability_not_found).assertEqual(-2);
done();
console.log('------------------ ' + TAG_TEST_0011 + ' end -------------------');
});
/*
* @tc.number: context_featureAbility_test_0400
* @tc.name: featureAbility.ErrorCode : featureAbility.ErrorCode
* @tc.desc: Check the featureAbility.ErrorCode.PERMISSION_DENY
* @tc.level 0
*/
it(TAG_TEST_0012, 0, async function (done) {
console.info(TAG_TEST_0012 + ' PERMISSION_DENY START');
var permission_deny = ability_featureAbility.ErrorCode.PERMISSION_DENY
console.info(TAG_TEST_0012 + ' featureAbility permission_deny is: ' + permission_deny);
expect(typeof (permission_deny)).assertEqual("number");
expect(permission_deny).assertEqual(-3);
done();
console.log('------------------ ' + TAG_TEST_0012 + ' 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 "deccjsunit/index.ets";
import Utils from './Utils';
import ability_featureAbility from '@ohos.ability.featureAbility';
export default function getHapModuleInfoJsunit() {
describe('appInfoTest', function () {
/**
* @tc.number: context_getAbilityInfo_test_0100
* @tc.name: getAbilityInfo:Query the current attributionability details.
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it('context_getAbilityInfo_test_0100', 0, async function (done) {
console.info('[context_getAbilityInfo_test_0100] START');
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
var context = ability_featureAbility.getContext();
await context.getAbilityInfo()
.then((data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('context_getAbilityInfo_test_0100', timeOldStamp, timeNewStamp);
console.info('[context_getAbilityInfo_test_0100] data is:' + JSON.stringify(data));
expect(typeof (data)).assertEqual("object");
}).catch((error) => {
console.error('[context_getAbilityInfo_test_0100] failed:' + JSON.stringify(error));
})
var promise = await context.getAbilityInfo();
console.info('--[context_getAbilityInfo_test_0100] check---');
checkAbilityInfo('context_getAbilityInfo_test_0100', promise);
console.info('[context_getAbilityInfo_test_0100] FINISH');
done();
});
async function startAbility2() {
var str = {
"want": {
"bundleName": "com.ohos.acecollaboration",
"abilityName": "com.ohos.acecollaboration.MainAbility2",
},
};
ability_featureAbility.startAbility(str).then((data) => {
console.info('context_getAbilityInfo_test_0300 startMainAbility2 succeeded: ' + JSON.stringify(data));
}).catch((error) => {
console.error('context_getAbilityInfo_test_0300 startMainAbility2 failed. Cause: ' + JSON.stringify(error));
});
}
/**
* @tc.number: context_getAbilityInfo_test_0200
* @tc.name: getAbilityInfo:Query the current attributionability details.
* @tc.desc: Check the return value of the interface (by AsyncCallback)
* @tc.level 0
*/
it('context_getAbilityInfo_test_0200', 0, async function (done) {
try {
console.info('[context_getAbilityInfo_test_0200] START');
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
var context = ability_featureAbility.getContext();
context.getAbilityInfo((error, data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('context_getAbilityInfo_test_0200', timeOldStamp, timeNewStamp);
console.info('[context_getAbilityInfo_test_0200] data is:' + JSON.stringify(data));
expect(typeof (data)).assertEqual("object");
});
} catch (error) {
console.error('[context_getAbilityInfo_test_0200] failed: ' + JSON.stringify(error));
}
var callback = await context.getAbilityInfo();
console.info('---[context_getAbilityInfo_test_0200] check---');
checkAbilityInfo('context_getAbilityInfo_test_0200', callback);
console.info('[context_getAbilityInfo_test_0200] FINISH');
done();
})
/**
* @tc.number: context_getAbilityInfo_test_0300_1
* @tc.name: getAbilityInfo:Query the current attributionability details.
* @tc.desc: Check the return value of the interface
* @tc.level 0
*/
it('context_getAbilityInfo_test_0300_1', 0, async function (done) {
console.info('[context_getAbilityInfo_test_0300] STARTability');
startAbility2();
done();
});
/**
* @tc.number: context_getAbilityInfo_test_0400
* @tc.name: getAbilityInfo:Query the current attributionability details.
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it('context_getAbilityInfo_test_0400', 0, async function (done) {
console.info('[context_getAbilityInfo_test_0400] START');
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
var context = ability_featureAbility.getContext();
await context.getAbilityInfo()
.then((data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('context_getAbilityInfo_test_0400', timeOldStamp, timeNewStamp);
console.info('[context_getAbilityInfo_test_0400] data is:' + JSON.stringify(data));
expect(typeof (data)).assertEqual("object");
}).catch((error) => {
console.error('[context_getAbilityInfo_test_0400] failed:' + JSON.stringify(error));
})
var promise = await context.getAbilityInfo();
console.info('--[context_getAbilityInfo_test_0400] check---');
checkAbilityInfo('context_getAbilityInfo_test_0400', promise);
console.info('[context_getAbilityInfo_test_0400] FINISH');
done();
});
function checkAbilityInfo(msg, data) {
console.log(msg + "checkAbilityInfo start " + JSON.stringify(data));
console.log(msg + "checkAbilityInfo bundleName : " + data.bundleName);
console.log(msg + "checkAbilityInfo name : " + data.name);
console.log(msg + "checkAbilityInfo label : " + data.label);
console.log(msg + "checkAbilityInfo description : " + data.description);
console.log(msg + "checkAbilityInfo icon : " + data.icon);
console.log(msg + "checkAbilityInfo descriptionId : " + data.descriptionId);
console.log(msg + "checkAbilityInfo iconId : " + data.iconId);
console.log(msg + "checkAbilityInfo moduleName : " + data.moduleName);
console.log(msg + "checkAbilityInfo process : " + data.process);
console.log(msg + "checkAbilityInfo targetAbility : " + data.targetAbility);
console.log(msg + "checkAbilityInfo backgroundModes : " + data.backgroundModes);
console.log(msg + "checkAbilityInfo isVisible : " + data.isVisible);
console.log(msg + "checkAbilityInfo formEnabled : " + data.formEnabled);
console.log(msg + "checkAbilityInfo type : " + data.type)
console.log(msg + "checkAbilityInfo orientation : " + data.orientation);
console.log(msg + "checkAbilityInfo launchMode : " + data.launchMode);
console.log(msg + "checkAbilityInfo permissions length : " + data.permissions.length);
for (var j = 0; j < data.permissions.length; j++) {
console.log(msg + "getAbilityInfo data.permissions[" + j + "] : " + data.permissions[j]);
}
console.log(msg + "checkAbilityInfo deviceTypes length : " + data.deviceTypes.length);
for (var k = 0; k < data.deviceTypes.length; k++) {
console.log(msg + "getAbilityInfo data.deviceTypes[" + k + "] : " + data.deviceTypes[k]);
}
console.log(msg + "checkAbilityInfo deviceCapabilities length : " + data.deviceCapabilities.length);
for (var i = 0; i < data.deviceCapabilities.length; i++) {
console.log(msg + "getAbilityInfo data.deviceCapabilities[" + i + "] : " + data.deviceCapabilities[i]);
}
console.log(msg + "checkAbilityInfo readPermission : " + data.readPermission);
console.log(msg + "checkAbilityInfo writePermission : " + data.writePermission);
console.log(msg + "checkAbilityInfo formEntity : " + data.formEntity);
console.log(msg + "checkAbilityInfo minFormHeight : " + data.minFormHeight);
console.log(msg + "checkAbilityInfo defaultFormHeight : " + data.defaultFormHeight);
console.log(msg + "checkAbilityInfo minFormWidth : " + data.minFormWidth);
console.log(msg + "checkAbilityInfo defaultFormWidth : " + data.defaultFormWidth);
console.log(msg + "checkAbilityInfo uri : " + data.uri);
console.log(msg + "checkAbilityInfo customizeData : " + data.customizeData);
console.log(msg + "checkAbilityInfo labelId : " + data.labelId);
console.log(msg + "checkAbilityInfo subType : " + data.subType);
expect(typeof (data)).assertEqual("object");
expect(typeof (data.bundleName)).assertEqual("string");
expect(typeof (data.name)).assertEqual("string");
expect(typeof (data.label)).assertEqual("string");
expect(typeof (data.description)).assertEqual("string");
expect(typeof (data.icon)).assertEqual("string");
expect(typeof (data.labelId)).assertEqual("number");
expect(typeof (data.descriptionId)).assertEqual("number");
expect(typeof (data.iconId)).assertEqual("number");
expect(typeof (data.moduleName)).assertEqual("string");
expect(typeof (data.process)).assertEqual("string");
expect(typeof (data.targetAbility)).assertEqual("string");
expect(typeof (data.backgroundModes)).assertEqual("number");
expect(typeof (data.isVisible)).assertEqual("boolean");
expect(typeof (data.formEnabled)).assertEqual("boolean");
expect(typeof (data.type)).assertEqual("number");
expect(typeof (data.subType)).assertEqual("number");
expect(typeof (data.orientation)).assertEqual("number");
expect(typeof (data.launchMode)).assertEqual("number");
expect(Array.isArray(data.permissions)).assertEqual(true);
expect(Array.isArray(data.deviceTypes)).assertEqual(true);
expect(Array.isArray(data.deviceCapabilities)).assertEqual(true);
expect(typeof (data.readPermission)).assertEqual("string");
expect(typeof (data.writePermission)).assertEqual("string");
expect(typeof (data.applicationInfo)).assertEqual("object");
expect(typeof (data.formEntity)).assertEqual("number");
expect(typeof (data.minFormHeight)).assertEqual("number");
expect(typeof (data.defaultFormHeight)).assertEqual("number");
expect(typeof (data.minFormWidth)).assertEqual("number");
expect(typeof (data.defaultFormWidth)).assertEqual("number");
expect(typeof (data.uri)).assertEqual("string");
expect(data.bundleName).assertEqual("com.ohos.acecollaboration");
expect(data.name).assertEqual("com.ohos.acecollaboration.MainAbility");
expect(data.label).assertEqual("$string:entry_MainAbility");
expect(data.description).assertEqual("$string:mainability_description");
expect(data.icon).assertEqual("$media:icon");
expect(data.descriptionId > 0).assertTrue();
expect(data.iconId > 0).assertTrue();
expect(data.moduleName).assertEqual("entry");
expect(data.process).assertEqual("");
expect(data.targetAbility).assertEqual("");
expect(data.backgroundModes).assertEqual(0);
expect(data.isVisible).assertEqual(true);
expect(data.formEnabled).assertEqual(false);
expect(data.type).assertEqual(1);
expect(data.orientation).assertEqual(0);
expect(data.launchMode).assertEqual(1);
expect(data.deviceTypes[0]).assertEqual("phone");
expect(data.readPermission).assertEqual("");
expect(data.writePermission).assertEqual("");
checkApplicationInfo(msg, data.applicationInfo);
expect(data.formEntity).assertEqual(0);
expect(data.minFormHeight).assertEqual(0);
expect(data.defaultFormHeight).assertEqual(0);
expect(data.minFormWidth).assertEqual(0);
expect(data.defaultFormWidth).assertEqual(0);
expect(data.uri).assertEqual("");
expect(data.labelId > 0).assertTrue();
expect(data.subType).assertEqual(0);
console.log(msg + "---checkAbilityInfo End--- ");
}
function checkApplicationInfo(msg, info) {
console.log(msg + "checkApplicationInfo start : " + JSON.stringify(info));
console.log(msg + "checkApplicationInfo name : " + info.name);
console.log(msg + "checkApplicationInfo description : " + info.description);
console.log(msg + "checkApplicationInfo descriptionId : " + info.descriptionId);
console.log(msg + "checkApplicationInfo systemApp : " + info.systemApp);
console.log(msg + "checkApplicationInfo enabled : " + info.enabled);
console.log(msg + "checkApplicationInfo label : " + info.label);
console.log(msg + "checkApplicationInfo labelId : " + info.labelId);
console.log(msg + "checkApplicationInfo icon : " + info.icon);
console.log(msg + "checkApplicationInfo iconId : " + info.iconId);
console.log(msg + "checkApplicationInfo process : " + info.process);
console.log(msg + "checkApplicationInfo supportedModes : " + info.supportedModes);
console.log(msg + "checkApplicationInfo moduleSourceDirs length : " + info.moduleSourceDirs.length);
for (var j = 0; j < info.moduleSourceDirs.length; j++) {
console.log(msg + "checkApplicationInfo info.moduleSourceDirs[" + j + "] : " + info.moduleSourceDirs[j]);
}
console.log(msg + "checkApplicationInfo permissions length : " + info.permissions.length);
for (var k = 0; k < info.permissions.length; k++) {
console.log(msg + "checkApplicationInfo info.permissions[" + k + "] : " + info.permissions[k]);
}
console.log(msg + "checkApplicationInfo moduleInfos length : " + info.moduleInfos.length);
for (var i = 0; i < info.moduleInfos.length; i++) {
console.log(msg + "checkApplicationInfo info.moduleInfos[" + i + "].moduleName : "
+ info.moduleInfos[i].moduleName);
console.log(msg + "checkApplicationInfo info.moduleInfos[" + i + "].moduleSourceDir : "
+ info.moduleInfos[i].moduleSourceDir);
}
console.log(msg + "checkApplicationInfo entryDir : " + info.entryDir);
expect(typeof (info)).assertEqual("object");
expect(typeof (info.name)).assertEqual("string");
expect(typeof (info.description)).assertEqual("string");
expect(typeof (info.descriptionId)).assertEqual("number");
expect(typeof (info.systemApp)).assertEqual("boolean");
expect(typeof (info.enabled)).assertEqual("boolean");
expect(typeof (info.label)).assertEqual("string");
expect(typeof (info.labelId)).assertEqual("string");
expect(typeof (info.icon)).assertEqual("string");
expect(typeof (info.iconId)).assertEqual("string");
expect(typeof (info.process)).assertEqual("string");
expect(typeof (info.supportedModes)).assertEqual("number");
expect(Array.isArray(info.moduleSourceDirs)).assertEqual(true);
expect(Array.isArray(info.permissions)).assertEqual(true);
expect(Array.isArray(info.moduleInfos)).assertEqual(true);
expect(typeof (info.entryDir)).assertEqual("string");
expect(info.name).assertEqual("com.ohos.acecollaboration");
expect(info.description).assertEqual("$string:mainability_description");
expect(info.descriptionId > 0).assertTrue();
expect(info.systemApp).assertEqual(true);
expect(info.enabled).assertEqual(true);
expect(info.label).assertEqual("$string:entry_MainAbility");
expect(info.icon).assertEqual("$media:icon");
expect(info.process).assertEqual("");
expect(info.supportedModes).assertEqual(0);
expect(info.entryDir).assertEqual("/data/app/el1/bundle/public/" +
"com.ohos.acecollaboration/com.ohos.acecollaboration");
if (info.moduleSourceDirs.length == 1){
expect(info.moduleInfos[0].moduleName).assertEqual("entry");
expect(info.moduleInfos[0].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" +
"com.ohos.acecollaboration/com.ohos.acecollaboration");
}else if(info.moduleSourceDirs.length == 2) {
if (info.moduleInfos[0].moduleName == "myapplication1") {
expect(info.moduleInfos[0].moduleName).assertEqual("myapplication1");
expect(info.moduleInfos[0].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" +
"com.ohos.acecollaboration/com.example.myapplication1");
expect(info.moduleInfos[1].moduleName).assertEqual("entry");
expect(info.moduleInfos[1].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" +
"com.ohos.acecollaboration/com.ohos.acecollaboration");
}else{
expect(info.moduleInfos[0].moduleName).assertEqual("myapplication2");
expect(info.moduleInfos[0].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" +
"com.ohos.acecollaboration/com.example.myapplication2");
expect(info.moduleInfos[1].moduleName).assertEqual("entry");
expect(info.moduleInfos[1].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" +
"com.ohos.acecollaboration/com.ohos.acecollaboration");
}
}else {
expect(info.moduleInfos[0].moduleName).assertEqual("myapplication1");
expect(info.moduleInfos[0].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" +
"com.ohos.acecollaboration/com.example.myapplication1");
expect(info.moduleInfos[1].moduleName).assertEqual("myapplication2");
expect(info.moduleInfos[1].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" +
"com.ohos.acecollaboration/com.example.myapplication2");
expect(info.moduleInfos[2].moduleName).assertEqual("entry");
expect(info.moduleInfos[2].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" +
"com.ohos.acecollaboration/com.ohos.acecollaboration");
}
console.log(msg + "---checkApplicationInfo 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 "deccjsunit/index.ets";
import Utils from './Utils';
import ability_featureAbility from '@ohos.ability.featureAbility';
export default function getHapModuleInfoJsunit() {
describe('appInfoTest', function () {
/**
* @tc.number: context_getAppVersionInfo_test_0100
* @tc.name: getAppVersionInfo:Gets the version information for the application.
* @tc.desc: Check the return type of the interface (by Promise)
* @tc.level 0
*/
it('context_getAppVersionInfo_test_0100', 0, async function (done) {
console.info('[context_getAppVersionInfo_test_0100] START');
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
var context = ability_featureAbility.getContext();
context.getAppVersionInfo()
.then((data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('context_getAppVersionInfo_test_0100', timeOldStamp, timeNewStamp);
console.info('[context_getAppVersionInfo_test_0100] data is:' + JSON.stringify(data));
expect(typeof (data)).assertEqual("object");
}).catch((error) => {
console.error('[context_getAppVersionInfo_test_0100] failed:' + JSON.stringify(error));
})
var promise = await context.getAppVersionInfo();
console.info('---[context_getAppVersionInfo_test_0100] check---');
checkAppVersionInfo('context_getAppVersionInfo_test_0100', promise);
console.info('[context_getAppVersionInfo_test_0100] FINISH');
done();
});
/**
* @tc.number: context_getAppVersionInfo_test_0200
* @tc.name: getAppVersionInfo:Gets the version information for the application.
* @tc.desc: Check the return type of the interface (by Callback)
* @tc.level 0
*/
it('context_getAppVersionInfo_test_0200', 0, async function (done) {
try {
console.info('[context_getAppVersionInfo_test_0200] START');
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
var context = ability_featureAbility.getContext();
context.getAppVersionInfo((error, data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('context_getAppVersionInfo_test_0200', timeOldStamp, timeNewStamp);
console.info('[context_getAppVersionInfo_test_0200] data is:' + JSON.stringify(data));
expect(typeof (data)).assertEqual("object");
});
}
catch (error) {
console.error('[context_getAppVersionInfo_test_0200] failed: ' + JSON.stringify(error));
}
var callback = await context.getAppVersionInfo();
console.info('---[context_getAppVersionInfo_test_0200] check---');
checkAppVersionInfo('context_getAppVersionInfo_test_0200', callback);
console.info('[context_getAppVersionInfo_test_0200] FINISH');
done();
});
function checkAppVersionInfo(msg, data) {
console.log(msg + "checkAppVersionInfo start : " + JSON.stringify(data));
console.log(msg + "checkAppVersionInfo appName : " + data.appName);
console.log(msg + "checkAppVersionInfo versionCode : " + data.versionCode);
console.log(msg + "checkAppVersionInfo versionName : " + data.versionName);
expect(typeof (data)).assertEqual("object");
expect(typeof (data.appName)).assertEqual("string");
expect(typeof (data.versionCode)).assertEqual("number");
expect(typeof (data.versionName)).assertEqual("string");
expect(data.appName).assertEqual("");
expect(data.versionCode).assertEqual(1000000);
expect(data.versionName).assertEqual("1.0.0");
console.log(msg + "---checkAppVersionInfo 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 "deccjsunit/index.ets";
import Utils from './Utils';
import ability_featureAbility from '@ohos.ability.featureAbility';
export default function getHapModuleInfoJsunit() {
describe('appInfoTest', function () {
/**
* @tc.number: context_getApplicationContext_test_0100
* @tc.name: getApplicationContext:Gets the application context information.
* @tc.desc: Check the return value of the interface
* @tc.level 0
*/
it('context_getApplicationContext_test_0100', 0, async function (done) {
try {
console.info('[context_getApplicationContext_test_0100] START');
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
var context = ability_featureAbility.getContext().getApplicationContext();
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('context_getApplicationContext_test_0100', timeOldStamp, timeNewStamp);
console.info('[context_getApplicationContext_test_0100] data is:' + JSON.stringify(context));
}
catch (error) {
console.error('[context_getApplicationContext_test_0100] failed:' + JSON.stringify(error));
}
expect(typeof (context)).assertEqual("object");
console.info('[context_getApplicationContext_test_0100] FINISH');
done();
});
})
}
\ No newline at end of file
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册