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

!3016 修改格式,新增用例,删除系统api

Merge pull request !3016 from ry/master
...@@ -18,6 +18,7 @@ group("bundlemanager") { ...@@ -18,6 +18,7 @@ group("bundlemanager") {
if (is_standard_system) { if (is_standard_system) {
deps = [ deps = [
"actsbmsaccesstokentest:ActsBmsAccessTokenTest", "actsbmsaccesstokentest:ActsBmsAccessTokenTest",
"actsbmsetsunpermissiontest:ActsBmsEtsUnPermissionTest",
"actsbmsgetinfostest:ActsBmsGetInfosTest", "actsbmsgetinfostest:ActsBmsGetInfosTest",
"actsbmshapmoduletest:ActsBmsHapModuleTest", "actsbmshapmoduletest:ActsBmsHapModuleTest",
"actsbmsjstest:ActsBmsJsTest", "actsbmsjstest:ActsBmsJsTest",
......
# 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("ActsBmsEtsUnPermissionTest") {
hap_profile = "./entry/src/main/config.json"
deps = [
":bms_ets_assets",
":bms_ets_resources",
]
ets2abc = true
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsBmsEtsUnPermissionTest"
}
ohos_js_assets("bms_ets_assets") {
source_dir = "./entry/src/main/ets/MainAbility"
}
ohos_resources("bms_ets_resources") {
sources = [ "./entry/src/main/resources" ]
hap_profile = "./entry/src/main/config.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "120000",
"package": "com.example.actsbmsetsunpermissiontest",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"ActsBmsEtsUnPermissionTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "com.example.actsbmsetsunpermissiontest",
"vendor": "example",
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 7,
"releaseType": "Release",
"target": 7
}
},
"deviceConfig": {},
"module": {
"package": "com.example.actsbmsetsunpermissiontest",
"name": ".MyApplication",
"mainAbility": ".MainAbility",
"srcPath": "MainAbility",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry",
"installationFree": false
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"orientation": "unspecified",
"visible": true,
"srcPath": "MainAbility",
"name": ".MainAbility",
"srcLanguage": "ets",
"icon": "$media:icon",
"description": "$string:description_mainability",
"formsEnabled": false,
"label": "$string:entry_MainAbility",
"type": "page",
"launchType": "standard"
}
],
"js": [
{
"mode": {
"syntax": "ets",
"type": "pageAbility"
},
"pages": [
"pages/index"
],
"name": ".MainAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
\ 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) 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 {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index.ets"
import testsuite from "../test/List.test.ets"
import featureAbility from "@ohos.ability.featureAbility"
@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')
const timeout=10000
configService.setConfig(timeout)
console.info('parameters---->' + JSON.stringify(Want.parameters))
configService.setConfig(Want.parameters)
testsuite()
core.execute()
console.info('Operation successful. Data: ' + JSON.stringify(Want));
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('ccc World')
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
.height('100%')
}
}
/*
* 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.ets"
import bundle from '@ohos.bundle'
const DEFAULT_FLAG = bundle.BundleFlag.GET_BUNDLE_DEFAULT;
const INVALID_CODE = 1;
const LAUNCHER_BUNDLE_NAME = "com.ohos.launcher";
const SELF_BUNDLENAME = "com.example.actsbmsetsunpermissiontest";
const SELF_ABILITYNAME = "com.example.actsbmsetsunpermissiontest.MainAbility";
export default function actsBmsJsUnPermissionTest() {
describe('actsBmsJsUnPermissionTest', function () {
/**
* @tc.number getApplicationInfos_1300
* @tc.name getApplicationInfos_1300
* @tc.desc test getAllApplicationInfo
*/
it('getApplicationInfos_1300', 0, async function (done) {
await bundle.getAllApplicationInfo(DEFAULT_FLAG).then(data => {
expect().assertFail();
done();
}).catch(err => {
expect(err).assertEqual(INVALID_CODE);
done();
});
bundle.getAllApplicationInfo(DEFAULT_FLAG, (err, data) => {
expect(err).assertEqual(INVALID_CODE);
expect(data).assertEqual(undefined);
done();
});
});
/**
* @tc.number getBundleInfo_2000
* @tc.name getBundleInfo_2000
* @tc.desc test getBundleInfo
*/
it('getBundleInfo_2000', 0, async function (done) {
await bundle.getBundleInfo(LAUNCHER_BUNDLE_NAME, DEFAULT_FLAG, { userId: 100 }).then(data => {
expect().assertFail();
done();
}).catch(err => {
expect(err).assertEqual(INVALID_CODE);
done();
});
bundle.getBundleInfo(LAUNCHER_BUNDLE_NAME, DEFAULT_FLAG, { userId: 100 }, (err, data) => {
expect(err).assertEqual(INVALID_CODE);
expect(data).assertEqual(undefined);
done();
});
});
/**
* @tc.number getApplicationInfo_1800
* @tc.name getApplicationInfo_1800
* @tc.desc test getApplicationInfo
*/
it('getApplicationInfo_1800', 0, async function (done) {
await bundle.getApplicationInfo(LAUNCHER_BUNDLE_NAME, DEFAULT_FLAG).then(data => {
expect().assertFail();
done();
}).catch(err => {
expect(err).assertEqual(INVALID_CODE);
done();
});
bundle.getApplicationInfo(LAUNCHER_BUNDLE_NAME, DEFAULT_FLAG, (err, data) => {
expect(err).assertEqual(INVALID_CODE);
expect(data).assertEqual(undefined);
done();
});
});
/*
* @tc.number: getAbilityInfo_100
* @tc.name: test getAbilityInfo
* @tc.desc: test getAbilityInfo
*/
it('getAbilityInfo_200', 0, async function (done) {
await bundle.getAbilityInfo(SELF_BUNDLENAME, SELF_ABILITYNAME).then(res => {
console.info('actwsBundleManager getAbilityInfo promise success res:' + JSON.stringify(res));
for (const item in res) {
const a = res[item];
console.info(item + ":" + JSON.stringify(a));
};
checkAbilityInfo(res);
}).catch(err => {
expect(err).assertFail();
});
bundle.getAbilityInfo(SELF_BUNDLENAME, SELF_ABILITYNAME, (err, res) => {
if (err) {
expect(err).assertFail();
done();
return;
}
console.info('actwsBundleManager getAbilityInfo callback success res:' + JSON.stringify(res));
for (const item in res) {
const a = res[item];
console.info(item + ":" + JSON.stringify(a));
};
checkAbilityInfo(res);
done();
});
});
async function checkAbilityInfo(data) {
console.info("checkAbilityInfo start !!!");
expect(data.bundleName).assertEqual("com.example.actsbmsetsunpermissiontest");
expect(data.name).assertEqual("com.example.actsbmsetsunpermissiontest.MainAbility");
expect(data.label).assertEqual("$string:entry_MainAbility");
expect(data.description).assertEqual("$string:description_mainability");
expect(data.icon).assertEqual("$media:icon");
expect(data.srcPath).assertEqual("MainAbility");
expect(data.srcLanguage).assertEqual("ets");
expect(data.isVisible).assertEqual(true);
expect(data.deviceTypes[0]).assertEqual("phone");
expect(data.process).assertEqual("");
expect(data.uri).assertEqual("");
expect(data.moduleName).assertEqual("entry");
expect(data.type).assertEqual(1);
expect(data.orientation).assertEqual(0);
expect(data.launchMode).assertEqual(1);
expect(data.backgroundModes).assertEqual(0);
expect(data.descriptionId).assertLarger(0);
expect(data.formEnabled).assertEqual(false);
expect(data.iconId).assertLarger(0);
except(data.labelId).assertLarger(0);
expect(data.subType).assertEqual(0);
except(data.enabled).assertEqual(true);
expect(data.readPermission).assertEqual("");
expect(data.writePermission).assertEqual("");
expect(data.targetAbility).assertEqual("");
expect(data.theme).assertEqual("");
expect(data.metaData).assertEqual([]);
expect(data.metadata).assertEqual([]);
checkApplicationInfo(data.applicationInfo);
console.log("---checkAbilityInfo_other End--- ");
}
async function checkApplicationInfo(info) {
console.info("checkApplicationInfo start !!!");
expect(info.name).assertEqual("com.example.actsbmsetsunpermissiontest");
expect(info.codePath).assertEqual("/data/app/el1/bundle/public/com.example.actsbmsetsunpermissiontest");
expect(info.accessTokenId > 0).assertTrue();
expect(info.description).assertEqual("$string:description_mainability");
expect(info.descriptionId > 0).assertTrue();
expect(info.icon).assertEqual("$media:icon");
expect(info.iconId > 0).assertTrue();
expect(info.label).assertEqual("$string:entry_MainAbility");
expect(info.labelId > 0).assertTrue();
expect(info.systemApp).assertEqual(true);
expect(info.entryDir).assertEqual("/data/app/el1/bundle/public/com.example.actsbmsetsunpermissiontest/com.example.actsbmsetsunpermissiontest");
expect(info.supportedModes).assertEqual(0);
expect(info.process).assertEqual("");
expect(info.moduleSourceDirs[0]).assertEqual("/data/app/el1/bundle/public/com.example.actsbmsetsunpermissiontest/com.example.actsbmsetsunpermissiontest");
expect(info.metaData).expect({});
expect(info.metadata).expect({});
expect(info.enabled).expect(true);
expect(info.flags).expect(0);
expect(info.uid).assertLarger(0);
expect(info.entityType).assertEqual("unspecified");
expect(info.removable).assertEqual(true);
console.info("checkApplicationInfo end !!!");
}
})
}
/*
* 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 actsBmsEtsUnPermissionTest from './ActsBmsEtsUnPermissionTest.test.ets';
export default function testsuite() {
actsBmsEtsUnPermissionTest();
}
\ No newline at end of file
{
"string": [
{
"name": "entry_MainAbility",
"value": "entry_MainAbility"
},
{
"name": "description_mainability",
"value": "ETS_Empty Ability"
}
]
}
\ No newline at end of file
...@@ -98,6 +98,7 @@ describe('ActsBmsHapModuleTest', function () { ...@@ -98,6 +98,7 @@ describe('ActsBmsHapModuleTest', function () {
let hapModuleInfo1 = result.hapModuleInfos[1]; let hapModuleInfo1 = result.hapModuleInfos[1];
checkHapMoudleInfos(hapModuleInfo); checkHapMoudleInfos(hapModuleInfo);
checkHapMoudleInfos(hapModuleInfo1); checkHapMoudleInfos(hapModuleInfo1);
expect(hapModuleInfo.label).assertEqual('$string:app_name');
expect(hapModuleInfo.name).assertEqual(BUNDLE_NAME1); expect(hapModuleInfo.name).assertEqual(BUNDLE_NAME1);
expect(hapModuleInfo1.name).assertEqual(BUNDLE_NAME6); expect(hapModuleInfo1.name).assertEqual(BUNDLE_NAME6);
expect(hapModuleInfo.moduleName).assertEqual('entry'); expect(hapModuleInfo.moduleName).assertEqual('entry');
...@@ -288,7 +289,6 @@ describe('ActsBmsHapModuleTest', function () { ...@@ -288,7 +289,6 @@ describe('ActsBmsHapModuleTest', function () {
expect(info.descriptionId).assertEqual(0); expect(info.descriptionId).assertEqual(0);
expect(info.iconPath).assertEqual("$media:icon"); expect(info.iconPath).assertEqual("$media:icon");
expect(info.icon).assertEqual(''); expect(info.icon).assertEqual('');
expect(info.label).assertEqual('$string:app_name');
expect(info.labelId).assertEqual(0); expect(info.labelId).assertEqual(0);
expect(info.iconId).assertEqual(0); expect(info.iconId).assertEqual(0);
expect(info.backgroundImg).assertEqual(""); expect(info.backgroundImg).assertEqual("");
......
...@@ -33,7 +33,18 @@ ...@@ -33,7 +33,18 @@
{ {
"type": "ShellKit", "type": "ShellKit",
"run-command": [ "run-command": [
"chmod 644 /data/test/*.hap" "chmod 644 /data/test/*.hap",
"bm install -p /data/test/bmsThirdBundleTest2.hap",
"bm install -p /data/test/bmsThirdBundleTest5.hap",
"bm install -p /data/test/bmsThirdBundleJs.hap",
"bm install -p /data/test/bmsThirdBundleC.hap"
],
"teardown-command":[
"bm uninstall -n com.example.third2",
"bm uninstall -n com.example.third5",
"bm uninstall -n com.example.js",
"bm uninstall -n com.example.c",
"rm -rf /data/test/"
] ]
} }
] ]
......
/*
* 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 pkg from '@system.package'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'
const NUM_TWO = 2;
const ERR_CODE = 202;
const ERR_MERSSAGE = 'value is not an available number';
describe('ActsBmsHasInstalldTest', function () {
/**
* @tc.number hasInstalled_0100
* @tc.name Package::hasInstalled
* @tc.desc Test hasInstalled interface.
*/
it('hasInstalled_0100', 0, async function (done) {
pkg.hasInstalled({
bundleName: 'com.ohos.launcher',
success: function success(data) {
console.info('hasInstalled success function in');
expect(data.result).assertTrue();
done();
},
fail: function fail(data, code) {
console.info('hasInstalled fail function in');
expect().assertFail();
done();
},
complete: function complete() {
console.info('hasInstalled complete function in');
expect().assertFail();
done();
}
});
});
/**
* @tc.number hasInstalled_0200
* @tc.name Package::hasInstalled
* @tc.desc Test hasInstalled interface.
*/
it('hasInstalled_0200', 0, async function (done) {
pkg.hasInstalled({
bundleName: 'wrongName',
success: function success(data) {
console.info('hasInstalled success function in');
expect(data.result).assertFalse();
done();
},
fail: function fail(data, code) {
console.info('hasInstalled fail function in');
expect().assertFail();
done();
},
complete: function complete() {
console.info('hasInstalled complete function in');
expect().assertFail();
done();
}
});
});
/**
* @tc.number hasInstalled_0300
* @tc.name Package::hasInstalled
* @tc.desc Test hasInstalled interface.
*/
it('hasInstalled_0300', 0, async function (done) {
pkg.hasInstalled({
bundleName: 'wrongName',
success: function success(data) {
console.info('hasInstalled success function in');
expect(data.result).assertFalse();
done();
}
});
});
/**
* @tc.number hasInstalled_0400
* @tc.name Package::hasInstalled
* @tc.desc Test hasInstalled interface.
*/
it('hasInstalled_0400', 0, async function (done) {
let flag = 0;
pkg.hasInstalled({
bundleName: NUM_TWO,
success: function success(data) {
console.info('hasInstalled success function in');
expect().assertFail();
done();
},
fail: function fail(data, code) {
flag += 2;
console.info('hasInstalled fail function in');
expect(data).assertEqual(ERR_MERSSAGE);
expect(code).assertEqual(ERR_CODE);
},
complete: function complete() {
flag += 3;
console.info('hasInstalled complete function in');
expect(flag).assertEqual(5)
done();
}
});
});
})
\ No newline at end of file
...@@ -18,9 +18,6 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from ...@@ -18,9 +18,6 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from
const NUM_TWO = 2; const NUM_TWO = 2;
const NUM_FOUR = 4; const NUM_FOUR = 4;
const ERR_CODE = 202;
const ERR_MERSSAGE = 'value is not an available number';
const BUNDLE_NAME1 = 'com.ohos.launcher';
const BUNDLE_NAME2 = 'com.example.third2'; const BUNDLE_NAME2 = 'com.example.third2';
const BUNDLE_NAME3 = 'com.example.third5'; const BUNDLE_NAME3 = 'com.example.third5';
const BUNDLE_NAME4 = 'com.example.js'; const BUNDLE_NAME4 = 'com.example.js';
...@@ -33,15 +30,6 @@ const ABILITIY_NAME5 = '.MainAbility'; ...@@ -33,15 +30,6 @@ const ABILITIY_NAME5 = '.MainAbility';
const ABILITIY_NAME6 = "com.example.third2.MainAbilityA"; const ABILITIY_NAME6 = "com.example.third2.MainAbilityA";
const ABILITIY_NAME7 = "com.example.third5.MainAbilityA"; const ABILITIY_NAME7 = "com.example.third5.MainAbilityA";
const ABILITIY_NAME8 = "com.example.third5.MainAbilityB"; const ABILITIY_NAME8 = "com.example.third5.MainAbilityB";
const BUNDLE_PATH1 = ['/data/test/bmsThirdBundleTest2.hap'];
const BUNDLE_PATH2 = ['/data/test/bmsThirdBundleTest5.hap'];
const BUNDLE_PATH3 = ['/data/test/bmsThirdBundleJs.hap'];
const BUNDLE_PATH4 = ['/data/test/bmsThirdBundleC.hap'];
let installParam = {
userId: 100,
installFlag: 1,
isKeepData: false
};
describe('ActsBmsJsTest', function () { describe('ActsBmsJsTest', function () {
...@@ -52,54 +40,47 @@ describe('ActsBmsJsTest', function () { ...@@ -52,54 +40,47 @@ describe('ActsBmsJsTest', function () {
* 2.check the ability name by the interface of getBundleInfo * 2.check the ability name by the interface of getBundleInfo
*/ */
it('bms_getJsAbility_0100', 0, async function (done) { it('bms_getJsAbility_0100', 0, async function (done) {
let installer = await bundle.getBundleInstaller(); let result = await bundle.getBundleInfo(BUNDLE_NAME2, bundle.BundleFlag.GET_BUNDLE_WITH_ABILITIES);
installer.install(BUNDLE_PATH1, installParam, onReceiveInstallEvent); expect(result.abilityInfos.length).assertEqual(NUM_TWO);
async function onReceiveInstallEvent(err, data) { if (result.abilityInfos.length == NUM_TWO) {
checkInstallOrUninstall(err, data); console.info("getBundleIno result" + JSON.stringify(result));
let result = await bundle.getBundleInfo(BUNDLE_NAME2, bundle.BundleFlag.GET_BUNDLE_WITH_ABILITIES); let abilityInfo1 = result.abilityInfos[0];
expect(result.abilityInfos.length).assertEqual(NUM_TWO); let abilityInfo2 = result.abilityInfos[1];
if (result.abilityInfos.length == NUM_TWO) { expect(abilityInfo1.name).assertEqual(ABILITIY_NAME1);
let abilityInfo1 = result.abilityInfos[0]; expect(abilityInfo2.name).assertEqual(ABILITIY_NAME6);
let abilityInfo2 = result.abilityInfos[1]; expect(abilityInfo1.srcLanguage).assertEqual('js');
expect(abilityInfo1.name).assertEqual(ABILITIY_NAME1); expect(abilityInfo1.srcPath).assertEqual('');
expect(abilityInfo2.name).assertEqual(ABILITIY_NAME6); expect(abilityInfo1.label).assertEqual("$string:app_name");
expect(abilityInfo1.srcLanguage).assertEqual('js'); expect(abilityInfo1.description).assertEqual("$string:mainability_description");
expect(abilityInfo1.srcPath).assertEqual(''); expect(abilityInfo1.icon).assertEqual("$media:icon");
expect(abilityInfo1.label).assertEqual("$string:app_name"); expect(abilityInfo1.isVisible).assertEqual(true);
expect(abilityInfo1.description).assertEqual("$string:mainability_description"); expect(abilityInfo1.permissions.length).assertEqual(0);
expect(abilityInfo1.icon).assertEqual("$media:icon"); expect(abilityInfo1.deviceTypes[0]).assertEqual('phone');
expect(abilityInfo1.isVisible).assertEqual(true); expect(abilityInfo1.process).assertEqual("");
expect(abilityInfo1.permissions.length).assertEqual(0); expect(abilityInfo1.uri).assertEqual("");
expect(abilityInfo1.deviceTypes[0]).assertEqual('phone'); expect(abilityInfo1.bundleName).assertEqual(BUNDLE_NAME2);
expect(abilityInfo1.process).assertEqual(""); expect(abilityInfo1.moduleName).assertEqual("entry");
expect(abilityInfo1.uri).assertEqual(""); expect(Object.keys(abilityInfo1.applicationInfo).length).assertLarger(0);
expect(abilityInfo1.bundleName).assertEqual(BUNDLE_NAME2); expect(abilityInfo1.type).assertEqual(1);
expect(abilityInfo1.moduleName).assertEqual("entry"); expect(abilityInfo2.type).assertEqual(2);
expect(Object.keys(abilityInfo1.applicationInfo).length).assertLarger(0); expect(abilityInfo1.orientation).assertEqual(0);
expect(abilityInfo1.type).assertEqual(1); expect(abilityInfo1.launchMode).assertEqual(1);
expect(abilityInfo2.type).assertEqual(2); expect(abilityInfo1.backgroundModes).assertEqual(0);
expect(abilityInfo1.orientation).assertEqual(0); expect(abilityInfo2.backgroundModes).assertEqual(510);
expect(abilityInfo1.launchMode).assertEqual(1); expect(abilityInfo1.descriptionId).assertLarger(0);
expect(abilityInfo1.backgroundModes).assertEqual(0); expect(abilityInfo1.formEnabled).assertEqual(false);
expect(abilityInfo2.backgroundModes).assertEqual(510); expect(abilityInfo1.iconId).assertLarger(0);
expect(abilityInfo1.descriptionId).assertLarger(0); expect(abilityInfo1.labelId).assertLarger(0);
expect(abilityInfo1.formEnabled).assertEqual(false); expect(abilityInfo1.subType).assertEqual(0);
expect(abilityInfo1.iconId).assertLarger(0); expect(abilityInfo1.readPermission).assertEqual("");
expect(abilityInfo1.labelId).assertLarger(0); expect(abilityInfo1.writePermission).assertEqual("");
expect(abilityInfo1.subType).assertEqual(0); expect(abilityInfo1.targetAbility).assertEqual("");
expect(abilityInfo1.readPermission).assertEqual(""); expect(abilityInfo1.theme).assertEqual("");
expect(abilityInfo1.writePermission).assertEqual(""); expect(abilityInfo1.metaData.length).assertEqual(0);
expect(abilityInfo1.targetAbility).assertEqual(""); expect(abilityInfo1.metadata.length).assertEqual(0);
expect(abilityInfo1.theme).assertEqual(""); expect(abilityInfo1.enabled).assertEqual(true);
expect(abilityInfo1.metaData.length).assertEqual(0);
expect(abilityInfo1.metadata.length).assertEqual(0);
expect(abilityInfo1.enabled).assertEqual(true);
}
installer.uninstall(BUNDLE_NAME2, installParam, (err, data) => {
checkInstallOrUninstall(err, data);
done();
});
} }
done();
}); });
/* /*
...@@ -109,35 +90,28 @@ describe('ActsBmsJsTest', function () { ...@@ -109,35 +90,28 @@ describe('ActsBmsJsTest', function () {
* 2.check the ability name by the interface of getBundleInfo * 2.check the ability name by the interface of getBundleInfo
*/ */
it('bms_getJsAbility_0200', 0, async function (done) { it('bms_getJsAbility_0200', 0, async function (done) {
let installer = await bundle.getBundleInstaller(); let result = await bundle.getBundleInfo(BUNDLE_NAME3, bundle.BundleFlag.GET_BUNDLE_WITH_ABILITIES);
installer.install(BUNDLE_PATH2, installParam, onReceiveInstallEvent); expect(result.abilityInfos.length).assertEqual(NUM_FOUR);
async function onReceiveInstallEvent(err, data) { if (result.abilityInfos.length == NUM_FOUR) {
checkInstallOrUninstall(err, data); console.info("getBundleIno result" + JSON.stringify(result));
let result = await bundle.getBundleInfo(BUNDLE_NAME3, bundle.BundleFlag.GET_BUNDLE_WITH_ABILITIES); let abilityInfo1 = result.abilityInfos[0];
expect(result.abilityInfos.length).assertEqual(NUM_FOUR); let abilityInfo2 = result.abilityInfos[1];
if (result.abilityInfos.length == NUM_FOUR) { let abilityInfo3 = result.abilityInfos[2];
let abilityInfo1 = result.abilityInfos[0]; let abilityInfo4 = result.abilityInfos[3];
let abilityInfo2 = result.abilityInfos[1]; checkAbilityInfos(abilityInfo1);
let abilityInfo3 = result.abilityInfos[2]; expect(abilityInfo2.metaData.length).assertEqual(1);
let abilityInfo4 = result.abilityInfos[3]; expect(abilityInfo2.metaData[0].name).assertEqual("Data5B");
checkAbilityInfos(abilityInfo1); expect(abilityInfo2.metaData[0].value).assertEqual("float");
expect(abilityInfo2.metaData.length).assertEqual(1); expect(abilityInfo2.metaData[0].extra).assertEqual("$string:mainability_description");
expect(abilityInfo2.metaData[0].name).assertEqual("Data5B"); expect(abilityInfo2.name).assertEqual(ABILITIY_NAME3);
expect(abilityInfo2.metaData[0].value).assertEqual("float"); expect(abilityInfo3.name).assertEqual(ABILITIY_NAME7);
expect(abilityInfo2.metaData[0].extra).assertEqual("$string:mainability_description"); expect(abilityInfo4.name).assertEqual(ABILITIY_NAME8);
expect(abilityInfo2.name).assertEqual(ABILITIY_NAME3); expect(abilityInfo3.type).assertEqual(2);
expect(abilityInfo3.name).assertEqual(ABILITIY_NAME7); expect(abilityInfo4.type).assertEqual(2);
expect(abilityInfo4.name).assertEqual(ABILITIY_NAME8); expect(abilityInfo3.backgroundModes).assertEqual(511);
expect(abilityInfo3.type).assertEqual(2); expect(abilityInfo4.backgroundModes).assertEqual(129);
expect(abilityInfo4.type).assertEqual(2);
expect(abilityInfo3.backgroundModes).assertEqual(511);
expect(abilityInfo4.backgroundModes).assertEqual(129);
}
installer.uninstall(BUNDLE_NAME3, installParam, (err, data) => {
checkInstallOrUninstall(err, data);
done();
});
} }
done();
}); });
/* /*
...@@ -147,50 +121,43 @@ describe('ActsBmsJsTest', function () { ...@@ -147,50 +121,43 @@ describe('ActsBmsJsTest', function () {
* 2.check the ability name by the interface of getBundleInfo * 2.check the ability name by the interface of getBundleInfo
*/ */
it('bms_getJsAbility_0300', 0, async function (done) { it('bms_getJsAbility_0300', 0, async function (done) {
let installer = await bundle.getBundleInstaller(); let result = await bundle.getBundleInfo(BUNDLE_NAME4, bundle.BundleFlag.GET_BUNDLE_WITH_ABILITIES);
installer.install(BUNDLE_PATH3, installParam, onReceiveInstallEvent); expect(result.abilityInfos.length).assertEqual(1);
async function onReceiveInstallEvent(err, data) { if (result.abilityInfos.length == 1) {
checkInstallOrUninstall(err, data); console.info("getBundleIno result" + JSON.stringify(result));
let result = await bundle.getBundleInfo(BUNDLE_NAME4, bundle.BundleFlag.GET_BUNDLE_WITH_ABILITIES); let abilityInfo1 = result.abilityInfos[0];
expect(result.abilityInfos.length).assertEqual(1); expect(abilityInfo1.name).assertEqual(ABILITIY_NAME4);
if (result.abilityInfos.length == 1) { expect(abilityInfo1.srcLanguage).assertEqual('js');
let abilityInfo1 = result.abilityInfos[0]; expect(abilityInfo1.srcPath).assertEqual('default');
expect(abilityInfo1.name).assertEqual(ABILITIY_NAME4); expect(abilityInfo1.label).assertEqual("$string:app_name");
expect(abilityInfo1.srcLanguage).assertEqual('js'); expect(abilityInfo1.description).assertEqual("$string:mainability_description");
expect(abilityInfo1.srcPath).assertEqual('default'); expect(abilityInfo1.icon).assertEqual("$media:icon");
expect(abilityInfo1.label).assertEqual("$string:app_name"); expect(abilityInfo1.isVisible).assertEqual(true);
expect(abilityInfo1.description).assertEqual("$string:mainability_description"); expect(abilityInfo1.permissions.length).assertEqual(0);
expect(abilityInfo1.icon).assertEqual("$media:icon"); expect(abilityInfo1.deviceTypes[0]).assertEqual('phone');
expect(abilityInfo1.isVisible).assertEqual(true); expect(abilityInfo1.process).assertEqual("");
expect(abilityInfo1.permissions.length).assertEqual(0); expect(abilityInfo1.uri).assertEqual("");
expect(abilityInfo1.deviceTypes[0]).assertEqual('phone'); expect(abilityInfo1.bundleName).assertEqual(BUNDLE_NAME4);
expect(abilityInfo1.process).assertEqual(""); expect(abilityInfo1.moduleName).assertEqual("entry");
expect(abilityInfo1.uri).assertEqual(""); expect(Object.keys(abilityInfo1.applicationInfo).length).assertLarger(0);
expect(abilityInfo1.bundleName).assertEqual(BUNDLE_NAME4); expect(abilityInfo1.type).assertEqual(1);
expect(abilityInfo1.moduleName).assertEqual("entry"); expect(abilityInfo1.orientation).assertEqual(0);
expect(Object.keys(abilityInfo1.applicationInfo).length).assertLarger(0); expect(abilityInfo1.launchMode).assertEqual(1);
expect(abilityInfo1.type).assertEqual(1); expect(abilityInfo1.backgroundModes).assertEqual(0);
expect(abilityInfo1.orientation).assertEqual(0); expect(abilityInfo1.descriptionId).assertLarger(0);
expect(abilityInfo1.launchMode).assertEqual(1); expect(abilityInfo1.formEnabled).assertEqual(false);
expect(abilityInfo1.backgroundModes).assertEqual(0); expect(abilityInfo1.iconId).assertLarger(0);
expect(abilityInfo1.descriptionId).assertLarger(0); expect(abilityInfo1.labelId).assertLarger(0);
expect(abilityInfo1.formEnabled).assertEqual(false); expect(abilityInfo1.subType).assertEqual(0);
expect(abilityInfo1.iconId).assertLarger(0); expect(abilityInfo1.readPermission).assertEqual("");
expect(abilityInfo1.labelId).assertLarger(0); expect(abilityInfo1.writePermission).assertEqual("");
expect(abilityInfo1.subType).assertEqual(0); expect(abilityInfo1.targetAbility).assertEqual("");
expect(abilityInfo1.readPermission).assertEqual(""); expect(abilityInfo1.theme).assertEqual("");
expect(abilityInfo1.writePermission).assertEqual(""); expect(abilityInfo1.metaData.length).assertEqual(0);
expect(abilityInfo1.targetAbility).assertEqual(""); expect(abilityInfo1.metadata.length).assertEqual(0);
expect(abilityInfo1.theme).assertEqual(""); expect(abilityInfo1.enabled).assertEqual(true);
expect(abilityInfo1.metaData.length).assertEqual(0);
expect(abilityInfo1.metadata.length).assertEqual(0);
expect(abilityInfo1.enabled).assertEqual(true);
}
installer.uninstall(BUNDLE_NAME4, installParam, (err, data) => {
checkInstallOrUninstall(err, data);
done();
});
} }
done();
}); });
/* /*
...@@ -200,173 +167,42 @@ describe('ActsBmsJsTest', function () { ...@@ -200,173 +167,42 @@ describe('ActsBmsJsTest', function () {
* 2.check the ability name by the interface of getBundleInfo * 2.check the ability name by the interface of getBundleInfo
*/ */
it('bms_getJsAbility_0400', 0, async function (done) { it('bms_getJsAbility_0400', 0, async function (done) {
let installer = await bundle.getBundleInstaller(); let result = await bundle.getBundleInfo(BUNDLE_NAME5, bundle.BundleFlag.GET_BUNDLE_WITH_ABILITIES);
installer.install(BUNDLE_PATH4, installParam, onReceiveInstallEvent); expect(result.abilityInfos.length).assertEqual(1);
async function onReceiveInstallEvent(err, data) { if (result.abilityInfos.length == 1) {
checkInstallOrUninstall(err, data); console.info("getBundleIno result" + JSON.stringify(result));
let result = await bundle.getBundleInfo(BUNDLE_NAME5, bundle.BundleFlag.GET_BUNDLE_WITH_ABILITIES); let abilityInfo1 = result.abilityInfos[0];
expect(result.abilityInfos.length).assertEqual(1); expect(abilityInfo1.name).assertEqual(ABILITIY_NAME5);
if (result.abilityInfos.length == 1) { expect(abilityInfo1.srcLanguage).assertEqual('c++');
let abilityInfo1 = result.abilityInfos[0]; expect(abilityInfo1.srcPath).assertEqual('default/c++/');
expect(abilityInfo1.name).assertEqual(ABILITIY_NAME5); expect(abilityInfo1.label).assertEqual("$string:app_name");
expect(abilityInfo1.srcLanguage).assertEqual('c++'); expect(abilityInfo1.description).assertEqual("$string:mainability_description");
expect(abilityInfo1.srcPath).assertEqual('default/c++/'); expect(abilityInfo1.icon).assertEqual("$media:icon");
expect(abilityInfo1.label).assertEqual("$string:app_name"); expect(abilityInfo1.isVisible).assertEqual(true);
expect(abilityInfo1.description).assertEqual("$string:mainability_description"); expect(abilityInfo1.permissions.length).assertEqual(0);
expect(abilityInfo1.icon).assertEqual("$media:icon"); expect(abilityInfo1.deviceTypes[0]).assertEqual('phone');
expect(abilityInfo1.isVisible).assertEqual(true); expect(abilityInfo1.process).assertEqual("");
expect(abilityInfo1.permissions.length).assertEqual(0); expect(abilityInfo1.uri).assertEqual("");
expect(abilityInfo1.deviceTypes[0]).assertEqual('phone'); expect(abilityInfo1.bundleName).assertEqual(BUNDLE_NAME5);
expect(abilityInfo1.process).assertEqual(""); expect(abilityInfo1.moduleName).assertEqual("entry");
expect(abilityInfo1.uri).assertEqual(""); expect(Object.keys(abilityInfo1.applicationInfo).length).assertLarger(0);
expect(abilityInfo1.bundleName).assertEqual(BUNDLE_NAME5); expect(abilityInfo1.type).assertEqual(1);
expect(abilityInfo1.moduleName).assertEqual("entry"); expect(abilityInfo1.orientation).assertEqual(0);
expect(Object.keys(abilityInfo1.applicationInfo).length).assertLarger(0); expect(abilityInfo1.launchMode).assertEqual(1);
expect(abilityInfo1.type).assertEqual(1); expect(abilityInfo1.backgroundModes).assertEqual(0);
expect(abilityInfo1.orientation).assertEqual(0); expect(abilityInfo1.descriptionId).assertLarger(0);
expect(abilityInfo1.launchMode).assertEqual(1); expect(abilityInfo1.formEnabled).assertEqual(false);
expect(abilityInfo1.backgroundModes).assertEqual(0); expect(abilityInfo1.iconId).assertLarger(0);
expect(abilityInfo1.descriptionId).assertLarger(0); expect(abilityInfo1.labelId).assertLarger(0);
expect(abilityInfo1.formEnabled).assertEqual(false); expect(abilityInfo1.subType).assertEqual(0);
expect(abilityInfo1.iconId).assertLarger(0); expect(abilityInfo1.readPermission).assertEqual("");
expect(abilityInfo1.labelId).assertLarger(0); expect(abilityInfo1.writePermission).assertEqual("");
expect(abilityInfo1.subType).assertEqual(0); expect(abilityInfo1.targetAbility).assertEqual("");
expect(abilityInfo1.readPermission).assertEqual(""); expect(abilityInfo1.theme).assertEqual("");
expect(abilityInfo1.writePermission).assertEqual(""); expect(abilityInfo1.metaData.length).assertEqual(0);
expect(abilityInfo1.targetAbility).assertEqual(""); expect(abilityInfo1.metadata.length).assertEqual(0);
expect(abilityInfo1.theme).assertEqual(""); expect(abilityInfo1.enabled).assertEqual(true);
expect(abilityInfo1.metaData.length).assertEqual(0);
expect(abilityInfo1.metadata.length).assertEqual(0);
expect(abilityInfo1.enabled).assertEqual(true);
}
installer.uninstall(BUNDLE_NAME5, installParam, (err, data) => {
checkInstallOrUninstall(err, data);
done();
});
} }
});
/**
* @tc.number getNameForUid_0100
* @tc.name BUNDLE::getBundleInfo
* @tc.desc Test getBundleInfo interfaces with hap.
*/
it('getNameForUid_0100', 0, async function (done) {
await bundle.getBundleInfo(BUNDLE_NAME1).then(dataInfo => {
bundle.getNameForUid(dataInfo.uid).then(data => {
expect(data).assertEqual(BUNDLE_NAME1)
done();
})
})
.catch(err => {
console.info("getNameForUid fail:" + JSON.stringify(err))
expect(err).assertFail()
done();
});
});
/**
* @tc.number getNameForUid_0200
* @tc.name BUNDLE::getBundleInfo
* @tc.desc Test getBundleInfo interfaces with hap.
*/
it('getNameForUid_0200', 0, async function (done) {
let dataInfo = await bundle.getBundleInfo(BUNDLE_NAME1);
let data = await bundle.getNameForUid(dataInfo.uid);
expect(data).assertEqual(BUNDLE_NAME1);
done();
});
/**
* @tc.number hasInstalled_0100
* @tc.name Package::hasInstalled
* @tc.desc Test hasInstalled interface.
*/
it('hasInstalled_0100', 0, async function (done) {
pkg.hasInstalled({
bundleName: 'com.ohos.launcher',
success: function success(data) {
console.info('hasInstalled success function in');
expect(data.result).assertTrue();
},
fail: function fail(data, code) {
console.info('hasInstalled fail function in');
expect().assertFail();
},
complete: function complete() {
console.info('hasInstalled complete function in');
expect().assertFail();
}
});
done();
});
/**
* @tc.number hasInstalled_0200
* @tc.name Package::hasInstalled
* @tc.desc Test hasInstalled interface.
*/
it('hasInstalled_0200', 0, async function (done) {
pkg.hasInstalled({
bundleName: 'wrongName',
success: function success(data) {
console.info('hasInstalled success function in');
expect(data.result).assertFalse();
},
fail: function fail(data, code) {
console.info('hasInstalled fail function in');
expect().assertFail();
},
complete: function complete() {
console.info('hasInstalled complete function in');
expect().assertFail();
}
});
done();
});
/**
* @tc.number hasInstalled_0300
* @tc.name Package::hasInstalled
* @tc.desc Test hasInstalled interface.
*/
it('hasInstalled_0300', 0, async function (done) {
pkg.hasInstalled({
bundleName: 'wrongName',
success: function success(data) {
console.info('hasInstalled success function in');
expect(data.result).assertFalse();
}
});
done();
});
/**
* @tc.number hasInstalled_0400
* @tc.name Package::hasInstalled
* @tc.desc Test hasInstalled interface.
*/
it('hasInstalled_0400', 0, async function (done) {
let flag = false;
pkg.hasInstalled({
bundleName: NUM_TWO,
success: function success(data) {
console.info('hasInstalled success function in');
expect().assertFail();
},
fail: function fail(data, code) {
console.info('hasInstalled fail function in');
expect(flag).assertFalse();
flag = true;
expect(data).assertEqual(ERR_MERSSAGE);
expect(code).assertEqual(ERR_CODE);
},
complete: function complete() {
console.info('hasInstalled complete function in');
expect(flag).assertTrue();
flag = true;
}
});
done(); done();
}); });
...@@ -404,10 +240,4 @@ describe('ActsBmsJsTest', function () { ...@@ -404,10 +240,4 @@ describe('ActsBmsJsTest', function () {
expect(info.metaData[0].extra).assertEqual("$string:mainability_description"); expect(info.metaData[0].extra).assertEqual("$string:mainability_description");
expect(info.enabled).assertEqual(true); expect(info.enabled).assertEqual(true);
} }
function checkInstallOrUninstall(err, data) {
expect(err.code).assertEqual(0);
expect(data.status).assertEqual(0);
expect(data.statusMessage).assertEqual('SUCCESS');
}
}) })
\ No newline at end of file
...@@ -12,4 +12,6 @@ ...@@ -12,4 +12,6 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
require('./ActsBmsJsTest.test.js')
\ No newline at end of file require('./ActsBmsJsTest.test.js')
require('./ActsBmsHasInstalldTest.test.js')
\ No newline at end of file
...@@ -14,58 +14,16 @@ ...@@ -14,58 +14,16 @@
*/ */
import bundle from '@ohos.bundle' import bundle from '@ohos.bundle'
import innerBundleManager from '@ohos.bundle.innerBundleManager'
import { describe, it, expect } from 'deccjsunit/index' import { describe, it, expect } from 'deccjsunit/index'
const STATUS_INSTALL_PERMISSION_DENIED = 0X44;
const STATUS_UNINSTALL_PERMISSION_DENIED = 0X45;
const LAUNCHER_BUNDLE_NAME = 'com.ohos.launcher'; const LAUNCHER_BUNDLE_NAME = 'com.ohos.launcher';
const LAUNCHER_MAIN_ABILITY = 'com.ohos.launcher.MainAbility'; const LAUNCHER_MAIN_ABILITY = 'com.ohos.launcher.MainAbility';
const DEFAULT_FLAG = 0; const DEFAULT_FLAG = bundle.BundleFlag.GET_BUNDLE_DEFAULT;
const DEFAULT_USER_ID = 100; const DEFAULT_USER_ID = 100;
const INVALID_CODE = 1; const INVALID_CODE = 1;
const BUNDLE_PATH = ['/data/test/bmsJstest1.hap'];
const BUNDLE_NAME1 = 'com.example.myapplication1';
let installParam = {
userId: 100,
installFlag: 1,
isKeepData: false
};
describe('ActsBmsJsUnPermissionTest', function () { describe('ActsBmsJsUnPermissionTest', function () {
/*
* @tc.number: bms_JsInstallPermissionTest_0100
* @tc.name: test js install
* @tc.desc: test js install
*/
it('bms_JsInstallPermissionTest_0100', 0, async function (done) {
let installer = await bundle.getBundleInstaller();
installer.install(BUNDLE_PATH, installParam, OnReceiveInstallEvent);
async function OnReceiveInstallEvent(err, data) {
expect(err.code).assertEqual(-1);
expect(data.status).assertEqual(STATUS_INSTALL_PERMISSION_DENIED);
expect(data.statusMessage).assertEqual("STATUS_INSTALL_PERMISSION_DENIED");
done();
}
});
/*
* @tc.number: bms_JsUnInstallPermissionTest_0100
* @tc.name: test js uninstall
* @tc.desc: test js uninstall
*/
it('bms_JsUnInstallPermissionTest_0100', 0, async function (done) {
let installer = await bundle.getBundleInstaller();
installer.uninstall(BUNDLE_NAME1, installParam, OnReceiveUnInstallEvent);
async function OnReceiveUnInstallEvent(err, data) {
expect(err.code).assertEqual(-1);
expect(data.status).assertEqual(STATUS_UNINSTALL_PERMISSION_DENIED);
expect(data.statusMessage).assertEqual("STATUS_UNINSTALL_PERMISSION_DENIED");
done();
}
});
/* /*
* @tc.number: getApplicationInfoTest_100 * @tc.number: getApplicationInfoTest_100
* @tc.name: test getApplicationInfo * @tc.name: test getApplicationInfo
...@@ -79,6 +37,11 @@ describe('ActsBmsJsUnPermissionTest', function () { ...@@ -79,6 +37,11 @@ describe('ActsBmsJsUnPermissionTest', function () {
expect(err).assertEqual(INVALID_CODE); expect(err).assertEqual(INVALID_CODE);
done(); done();
}); });
bundle.getApplicationInfo(LAUNCHER_BUNDLE_NAME, DEFAULT_FLAG, DEFAULT_USER_ID, (err, data) => {
expect(err).assertEqual(INVALID_CODE);
expect(data).assertEqual(undefined);
done();
});
}); });
/* /*
...@@ -94,6 +57,11 @@ describe('ActsBmsJsUnPermissionTest', function () { ...@@ -94,6 +57,11 @@ describe('ActsBmsJsUnPermissionTest', function () {
expect(err).assertEqual(INVALID_CODE); expect(err).assertEqual(INVALID_CODE);
done(); done();
}); });
bundle.getAllApplicationInfo(DEFAULT_FLAG, DEFAULT_USER_ID, (err, data) => {
expect(err).assertEqual(INVALID_CODE);
expect(data).assertEqual(undefined);
done();
});
}); });
/* /*
...@@ -109,6 +77,11 @@ describe('ActsBmsJsUnPermissionTest', function () { ...@@ -109,6 +77,11 @@ describe('ActsBmsJsUnPermissionTest', function () {
expect(err).assertEqual(INVALID_CODE); expect(err).assertEqual(INVALID_CODE);
done(); done();
}); });
bundle.getBundleInfo(LAUNCHER_BUNDLE_NAME, DEFAULT_USER_ID, (err, data) => {
expect(err).assertEqual(INVALID_CODE);
expect(data).assertEqual(undefined);
done();
});
}); });
/* /*
...@@ -124,6 +97,11 @@ describe('ActsBmsJsUnPermissionTest', function () { ...@@ -124,6 +97,11 @@ describe('ActsBmsJsUnPermissionTest', function () {
expect(err).assertEqual(INVALID_CODE); expect(err).assertEqual(INVALID_CODE);
done(); done();
}); });
bundle.getAllBundleInfo(DEFAULT_FLAG, (err, data) => {
expect(err).assertEqual(INVALID_CODE);
expect(data).assertEqual(undefined);
done();
});
}); });
/* /*
...@@ -142,6 +120,15 @@ describe('ActsBmsJsUnPermissionTest', function () { ...@@ -142,6 +120,15 @@ describe('ActsBmsJsUnPermissionTest', function () {
expect(err).assertEqual(INVALID_CODE); expect(err).assertEqual(INVALID_CODE);
done(); done();
}); });
bundle.queryAbilityByWant({
bundleName: LAUNCHER_BUNDLE_NAME,
abilityName: LAUNCHER_MAIN_ABILITY
}, DEFAULT_FLAG, DEFAULT_USER_ID, (err, data) => {
console.info("data ===================:" + data);
expect(err).assertEqual(INVALID_CODE);
expect(data).assertEqual("QueryAbilityInfos failed");
done();
});
}); });
/* /*
...@@ -157,6 +144,11 @@ describe('ActsBmsJsUnPermissionTest', function () { ...@@ -157,6 +144,11 @@ describe('ActsBmsJsUnPermissionTest', function () {
expect(err).assertEqual(INVALID_CODE); expect(err).assertEqual(INVALID_CODE);
done(); done();
}); });
bundle.getLaunchWantForBundle(LAUNCHER_BUNDLE_NAME, (err, data) => {
expect(err).assertEqual(INVALID_CODE);
expect(data).assertEqual(undefined);
done();
});
}); });
/* /*
...@@ -194,56 +186,11 @@ describe('ActsBmsJsUnPermissionTest', function () { ...@@ -194,56 +186,11 @@ describe('ActsBmsJsUnPermissionTest', function () {
}); });
/* /*
* @tc.number: getLauncherAbilityInfosTest_100 * @tc.number: getAbilityLabelTest_100
* @tc.name: test getLauncherAbilityInfos * @tc.name: getAbilityLabel : Gets the specified ability label
* @tc.desc: test getLauncherAbilityInfos * @tc.desc: Check the return value of the interface
*/ * @tc.level 0
it('getLauncherAbilityInfosTest_100', 0, async function (done) { */
await innerBundleManager.getLauncherAbilityInfos(LAUNCHER_BUNDLE_NAME, DEFAULT_USER_ID).then(data => {
expect().assertFail();
done();
}).catch(err => {
expect(err).assertEqual(INVALID_CODE);
done();
});
});
/*
* @tc.number: getAllLauncherAbilityInfosTest_100
* @tc.name: test getAllLauncherAbilityInfos
* @tc.desc: test getAllLauncherAbilityInfos
*/
it('getAllLauncherAbilityInfosTest_100', 0, async function (done) {
await innerBundleManager.getAllLauncherAbilityInfos(DEFAULT_USER_ID).then(data => {
expect().assertFail();
done();
}).catch(err => {
expect(err).assertEqual(INVALID_CODE);
done();
});
});
/*
* @tc.number: getShortcutInfosTest_100
* @tc.name: test getShortcutInfos
* @tc.desc: test getShortcutInfos
*/
it('getShortcutInfosTest_100', 0, async function (done) {
await innerBundleManager.getShortcutInfos(LAUNCHER_BUNDLE_NAME).then(data => {
expect().assertFail();
done();
}).catch(err => {
expect(err).assertEqual(INVALID_CODE);
done();
});
});
/*
* @tc.number: getAbilityLabelTest_100
* @tc.name: getAbilityLabel : Gets the specified ability label
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it('getAbilityLabelTest_100', 0, async function (done) { it('getAbilityLabelTest_100', 0, async function (done) {
await bundle.getAbilityLabel(LAUNCHER_BUNDLE_NAME, LAUNCHER_MAIN_ABILITY) await bundle.getAbilityLabel(LAUNCHER_BUNDLE_NAME, LAUNCHER_MAIN_ABILITY)
.then((data) => { .then((data) => {
...@@ -254,6 +201,11 @@ describe('ActsBmsJsUnPermissionTest', function () { ...@@ -254,6 +201,11 @@ describe('ActsBmsJsUnPermissionTest', function () {
expect(error).assertEqual(INVALID_CODE); expect(error).assertEqual(INVALID_CODE);
done(); done();
}); });
bundle.getAbilityLabel(LAUNCHER_BUNDLE_NAME, LAUNCHER_MAIN_ABILITY, (err, data) => {
expect(err).assertEqual(INVALID_CODE);
expect(data).assertEqual(undefined);
done();
});
}); });
/* /*
...@@ -269,5 +221,10 @@ describe('ActsBmsJsUnPermissionTest', function () { ...@@ -269,5 +221,10 @@ describe('ActsBmsJsUnPermissionTest', function () {
expect(err).assertEqual(INVALID_CODE); expect(err).assertEqual(INVALID_CODE);
done(); done();
}); });
bundle.getAbilityInfo(LAUNCHER_BUNDLE_NAME, LAUNCHER_MAIN_ABILITY, (err, data) => {
expect(err).assertEqual(INVALID_CODE);
expect(data).assertEqual(undefined);
done();
});
}); });
}) })
...@@ -13,6 +13,33 @@ ...@@ -13,6 +13,33 @@
], ],
"type": "AppInstallKit", "type": "AppInstallKit",
"cleanup-apps": true "cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"remount",
"mkdir /data/test/"
]
},
{
"type": "PushKit",
"push":[
"bmsThirdBundleTest1.hap -> /data/bmsThirdBundleTest1.hap ",
"first_right.hap -> /data/test/first_right.hap",
"second_right.hap -> /data/second_right.hap"
]
},
{
"type": "ShellKit",
"run-command": [
"bm install -p /data/bmsThirdBundleTest1.hap",
"bm install -p /data/test/first_right.hap",
"bm install -p /data/second_right.hap"
],
"teardown-command":[
"bm uninstall -n com.example.third1",
"bm uninstall -n com.example.l3jsdemo"
]
} }
] ]
} }
...@@ -29,6 +29,9 @@ ...@@ -29,6 +29,9 @@
}, },
{ {
"name": "ohos.permission.CHANGE_ABILITY_ENABLED_STATE" "name": "ohos.permission.CHANGE_ABILITY_ENABLED_STATE"
},
{
"name": "ohos.permission.INSTALL_BUNDLE"
} }
], ],
"distro": { "distro": {
......
/*
* 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 bundle from '@ohos.bundle'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'
const BUNDLE_NAME = "com.ohos.callui"
const ABILITIY_NAME = "com.ohos.callui.MainAbility"
export default function getAbilityIcon() {
describe('ActsBmsGetAbilityIconTest', function () {
/*
* @tc.number: bms_getAbilityIcon_0100
* @tc.name: test getAbilityIcon`
* @tc.desc: get the abilityIcon
*/
it('bms_getAbilityIcon_0100', 0, async function (done) {
bundle.getAbilityIcon(BUNDLE_NAME, ABILITIY_NAME).then(pixelmap => {
console.log('bms_getAbilityIcon_0100 success: ' + pixelmap);
expect(pixelmap !== null).assertTrue();
done();
})
.catch(err => {
console.info("getAbilityIcon fail:" + JSON.stringify(err))
expect(err).assertFail();
done();
});
});
/*
* @tc.number: bms_getAbilityIcon_0200
* @tc.name: test getAbilityIcon
* @tc.desc: get the abilityIcon
*/
it('bms_getAbilityIcon_0200', 0, async function (done) {
bundle.getAbilityIcon(BUNDLE_NAME, ABILITIY_NAME, (err, pixelmap) => {
expect(err).assertEqual(0);
expect(pixelmap !== null).assertTrue();
done();
});
});
});
}
\ No newline at end of file
...@@ -12,203 +12,198 @@ ...@@ -12,203 +12,198 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import {describe, it, expect} from 'deccjsunit/index.ets'; import { describe, it, expect } from 'deccjsunit/index.ets';
import Utils from './Utils'; import Utils from './Utils';
import Bundle from '@ohos.bundle'; import Bundle from '@ohos.bundle';
const BUNDLE_NAME = 'com.open.harmony.packagemag' const BUNDLE_NAME = 'com.open.harmony.packagemag';
const ABILITY_NAME = 'com.open.harmony.packagemag.MainAbility' const ABILITY_NAME = 'com.open.harmony.packagemag.MainAbility';
const SERVICE_ABILITY_NAME = 'com.open.harmony.packagemag.ServiceAbility' const SERVICE_ABILITY_NAME = 'com.open.harmony.packagemag.ServiceAbility';
const OTHER_BUNDLE_NAME = 'com.ohos.acepackage';
const OTHER_ABILITY_NAME = 'com.ohos.acepackage.MainAbility';
const BUNDLE_NAME_ERROR = 'com.ohos.acepackage.error';
const ABILITY_NAME_ERROR = 'com.ohos.acepackage.error.MainAbility';
const OTHER_BUNDLE_NAME = 'com.ohos.acepackage' export default function getAbilityLabelJsUnit() {
const OTHER_ABILITY_NAME = 'com.ohos.acepackage.MainAbility'
const BUNDLE_NAME_ERROR = 'com.ohos.acepackage.error' describe('context_getAbilityLabel_test', function () {
const ABILITY_NAME_ERROR = 'com.ohos.acepackage.error.MainAbility'
export default function getAbilityLabelJsUnit() { /*
* @tc.number: context_getAbilityLabel_test_0100
* @tc.name: getAbilityLabel : Gets the specified ability label
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it('context_getAbilityLabel_test_0100', 0, async function (done) {
let mData;
let timeOldStamp = await Utils.getNowTime();
await Bundle.getAbilityLabel(BUNDLE_NAME, ABILITY_NAME).then((data) => {
let timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_getAbilityLabel_test_0100]', timeOldStamp, timeNewStamp);
mData = data;
console.info('[context_getAbilityLabel_test_0100] promise data is: ' + JSON.stringify(data));
}).catch((error) => {
console.info('[context_getAbilityLabel_test_0100] promise error is: ' + error);
expect(error).assertFail();
});
getAbilityLabelSuccess('[context_getAbilityLabel_test_0100]', mData);
done();
});
describe('context_getAbilityLabel_test', function () { /*
/* * @tc.number: context_getAbilityLabel_test_0200
* @tc.number: context_getAbilityLabel_test_0100 * @tc.name: getAbilityLabel : Gets the specified ability label
* @tc.name: getAbilityLabel : Gets the specified ability label * @tc.desc: Check the return value of the interface (by callback)
* @tc.desc: Check the return value of the interface (by promise) * @tc.level 0
* @tc.level 0 */
*/ it('context_getAbilityLabel_test_0200', 0, async function (done) {
it('context_getAbilityLabel_test_0100', 0, async function (done) { let timeOldStamp = await Utils.getNowTime();
let mData; let mData;
var timeOldStamp = await Utils.getNowTime(); Bundle.getAbilityLabel(BUNDLE_NAME, ABILITY_NAME, (error, data) => {
await Bundle.getAbilityLabel(BUNDLE_NAME, ABILITY_NAME) if (error) {
.then((data) => { console.error('[context_getAbilityLabel_test_0200]Operation failed. Cause: ' + JSON.stringify(error));
var timeNewStamp = Utils.getNowTime(); expect(error).assertFail();
Utils.getDurationTime('[context_getAbilityLabel_test_0100]', timeOldStamp, timeNewStamp); }
mData = data; let timeNewStamp = Utils.getNowTime();
console.info('[context_getAbilityLabel_test_0100] promise data is: ' + JSON.stringify(data)); Utils.getDurationTime('[context_getAbilityLabel_test_0200]', timeOldStamp, timeNewStamp);
}) mData = data;
.catch((error) => { console.info('[context_getAbilityLabel_test_0200] callBack error: ' + error);
console.info('[context_getAbilityLabel_test_0100] promise error is: ' + error); console.info('[context_getAbilityLabel_test_0200] callBack data is:' + JSON.stringify(data));
expect(error).assertFail(); });
await Utils.sleep(2000);
getAbilityLabelSuccess('[context_getAbilityLabel_test_0200]', mData);
done();
}); });
getAbilityLabelSuccess('[context_getAbilityLabel_test_0100]', mData);
done();
});
/* /*
* @tc.number: context_getAbilityLabel_test_0200 * @tc.number: context_getAbilityLabel_test_0300
* @tc.name: getAbilityLabel : Gets the specified ability label * @tc.name: getAbilityLabel : Gets the specified ability label
* @tc.desc: Check the return value of the interface (by callbac) * @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0 * @tc.level 0
*/ */
it('context_getAbilityLabel_test_0200', 0, async function (done) { it('context_getAbilityLabel_test_0300', 0, async function (done) {
var timeOldStamp = await Utils.getNowTime(); let timeOldStamp = await Utils.getNowTime();
let mData; let mError;
Bundle.getAbilityLabel(BUNDLE_NAME, ABILITY_NAME, (error, data) => { await Bundle.getAbilityLabel(BUNDLE_NAME_ERROR, ABILITY_NAME_ERROR).then((data) => {
if(error){ let timeNewStamp = Utils.getNowTime();
console.error('[context_getAbilityLabel_test_0200]Operation failed. Cause: ' + JSON.stringify(error)); Utils.getDurationTime('[context_getAbilityLabel_test_0300]', timeOldStamp, timeNewStamp);
expect(error).assertFail(); console.info('[context_getAbilityLabel_test_0300] promise data is: ' + JSON.stringify(data));
} }).catch((error) => {
var timeNewStamp = Utils.getNowTime(); let timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_getAbilityLabel_test_0200]', timeOldStamp, timeNewStamp); mError = error;
mData = data; Utils.getDurationTime('[context_getAbilityLabel_test_0300]', timeOldStamp, timeNewStamp);
console.info('[context_getAbilityLabel_test_0200] callBack error: ' + error); console.info('[context_getAbilityLabel_test_0300] promise error is: ' + error);
console.info('[context_getAbilityLabel_test_0200] callBack data is:' + JSON.stringify(data)); expect(mError).assertEqual(1);
}); });
await Utils.sleep(2000); await Utils.sleep(2000);
getAbilityLabelSuccess('[context_getAbilityLabel_test_0200]', mData); getAbilityLabelFailure('[context_getAbilityLabel_test_0300]', mError);
done(); done();
}); });
/* /*
* @tc.number: context_getAbilityLabel_test_0300 * @tc.number: context_getAbilityLabel_test_0400
* @tc.name: getAbilityLabel : Gets the specified ability label * @tc.name: getAbilityLabel : Gets the specified ability label
* @tc.desc: Check the return value of the interface (by promise) * @tc.desc: Check the return value of the interface (by callback)
* @tc.level 0 * @tc.level 0
*/ */
it('context_getAbilityLabel_test_0300', 0, async function (done) { it('context_getAbilityLabel_test_0400', 0, async function (done) {
var timeOldStamp = await Utils.getNowTime(); let timeOldStamp = await Utils.getNowTime();
let mError; let mError;
await Bundle.getAbilityLabel(BUNDLE_NAME_ERROR, ABILITY_NAME_ERROR) Bundle.getAbilityLabel(BUNDLE_NAME_ERROR, ABILITY_NAME_ERROR, (error, data) => {
.then((data) => { if (error !== null) {
var timeNewStamp = Utils.getNowTime(); console.info('[context_getAbilityLabel_test_0400] callBack error: ' + error);
Utils.getDurationTime('[context_getAbilityLabel_test_0300]', timeOldStamp, timeNewStamp); expect(error).assertEqual(1);
console.info('[context_getAbilityLabel_test_0300] promise data is: ' + JSON.stringify(data)); }
}) let timeNewStamp = Utils.getNowTime();
.catch((error) => { Utils.getDurationTime('[context_getAbilityLabel_test_0400]', timeOldStamp, timeNewStamp);
var timeNewStamp = Utils.getNowTime(); mError = error;
mError = error; console.info('[context_getAbilityLabel_test_0400] callBack data is:' + JSON.stringify(data));
Utils.getDurationTime('[context_getAbilityLabel_test_0300]', timeOldStamp, timeNewStamp); });
console.info('[context_getAbilityLabel_test_0300] promise error is: ' + error); await Utils.sleep(2000);
expect(mError).assertEqual(1); getAbilityLabelFailure('[context_getAbilityLabel_test_0400]', mError);
done();
}); });
await Utils.sleep(2000);
getAbilityLabelFailure('[context_getAbilityLabel_test_0300]', mError);
done();
});
/* /*
* @tc.number: context_getAbilityLabel_test_0400 * @tc.number: context_getAbilityLabel_test_0500
* @tc.name: getAbilityLabel : Gets the specified ability label * @tc.name: getAbilityLabel : Gets the specified ability label
* @tc.desc: Check the return value of the interface (by callback) * @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0 * @tc.level 0
*/ */
it('context_getAbilityLabel_test_0400', 0, async function (done) { it('context_getAbilityLabel_test_0500', 0, async function (done) {
var timeOldStamp = await Utils.getNowTime(); let mData;
let mError; let mError = null;
Bundle.getAbilityLabel(BUNDLE_NAME_ERROR, ABILITY_NAME_ERROR, (error, data) => { let timeOldStamp = await Utils.getNowTime();
if(error !== null){ await Bundle.getAbilityLabel(OTHER_BUNDLE_NAME, OTHER_ABILITY_NAME).then((data) => {
console.info('[context_getAbilityLabel_test_0400] callBack error: ' + error); let timeNewStamp = Utils.getNowTime();
expect(error).assertEqual(1); Utils.getDurationTime('[context_getAbilityLabel_test_0500]', timeOldStamp, timeNewStamp);
} mData = data;
var timeNewStamp = Utils.getNowTime(); expect(mData).assertFail();
Utils.getDurationTime('[context_getAbilityLabel_test_0400]', timeOldStamp, timeNewStamp); console.info('[context_getAbilityLabel_test_0500] promise data is: ' + JSON.stringify(data));
mError = error; }).catch((error) => {
console.info('[context_getAbilityLabel_test_0400] callBack data is:' + JSON.stringify(data)); mError = error;
}); console.info('[context_getAbilityLabel_test_0500] promise error is: ' + error);
await Utils.sleep(2000); getAbilityLabelFailure('[context_getAbilityLabel_test_0500]', mError);
getAbilityLabelFailure('[context_getAbilityLabel_test_0400]', mError); });
done(); done();
}); });
/* /*
* @tc.number: context_getAbilityLabel_test_0500 * @tc.number: context_getAbilityLabel_test_0600
* @tc.name: getAbilityLabel : Gets the specified ability label * @tc.name: getAbilityLabel : Gets the specified ability label
* @tc.desc: Check the return value of the interface (by promise) * @tc.desc: Check the return value of the interface (by callback)
* @tc.level 0 * @tc.level 0
*/ */
it('context_getAbilityLabel_test_0500', 0, async function (done) { it('context_getAbilityLabel_test_0600', 0, async function (done) {
let mData; let timeOldStamp = await Utils.getNowTime();
let mError = null; Bundle.getAbilityLabel(OTHER_BUNDLE_NAME, OTHER_ABILITY_NAME, (error, data) => {
var timeOldStamp = await Utils.getNowTime(); let timeNewStamp = Utils.getNowTime();
await Bundle.getAbilityLabel(OTHER_BUNDLE_NAME, OTHER_ABILITY_NAME) Utils.getDurationTime('[context_getAbilityLabel_test_0600]', timeOldStamp, timeNewStamp);
.then((data) => { console.info('[context_getAbilityLabel_test_0600] callBack error: ' + error);
var timeNewStamp = Utils.getNowTime(); getAbilityLabelFailure('[context_getAbilityLabel_test_0600]', error);
Utils.getDurationTime('[context_getAbilityLabel_test_0500]', timeOldStamp, timeNewStamp); expect(data).assertEqual(undefined);
mData = data; });
expect(mData).assertFail(); done();
console.info('[context_getAbilityLabel_test_0500] promise data is: ' + JSON.stringify(data));
})
.catch((error) => {
mError = error;
console.info('[context_getAbilityLabel_test_0500] promise error is: ' + error);
getAbilityLabelFailure('[context_getAbilityLabel_test_0500]', mError);
}); });
done();
});
/*
* @tc.number: context_getAbilityLabel_test_0600
* @tc.name: getAbilityLabel : Gets the specified ability label
* @tc.desc: Check the return value of the interface (by callback)
* @tc.level 0
*/
it('context_getAbilityLabel_test_0600', 0, async function (done) {
var timeOldStamp = await Utils.getNowTime();
Bundle.getAbilityLabel(OTHER_BUNDLE_NAME, OTHER_ABILITY_NAME, (error, data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_getAbilityLabel_test_0600]', timeOldStamp, timeNewStamp);
console.info('[context_getAbilityLabel_test_0600] callBack error: ' + error);
getAbilityLabelFailure('[context_getAbilityLabel_test_0600]', error);
expect(data).assertEqual(undefined);
});
done();
});
/*
* @tc.number: context_getAbilityLabel_test_0700
* @tc.name: getAbilityLabel : Gets the specified ability label
* @tc.desc: Check the return value of the interface (by callback)
* @tc.level 0
*/
it('context_getAbilityLabel_test_0700', 0, async function (done) {
let timeOldStamp = await Utils.getNowTime();
let mError;
Bundle.getAbilityLabel(BUNDLE_NAME, SERVICE_ABILITY_NAME, (error, data) => {
let timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_getAbilityLabel_test_0700]', timeOldStamp, timeNewStamp);
mError = error;
if (mError !== null) {
console.info('[context_getAbilityLabel_test_0600] callBack error: ' + error);
}
console.info('[context_getAbilityLabel_test_0700] callBack data is:' + JSON.stringify(data));
});
await Utils.sleep(2000);
getAbilityLabelFailure('[context_getAbilityLabel_test_0700]', mError);
done();
});
function getAbilityLabelSuccess(msg, data) {
console.log(msg + ' start ' + JSON.stringify(data));
console.log(msg + ' result ' + data);
expect(typeof (data)).assertEqual('string');
expect(data).assertEqual("entry_MainAbility");
}
/* function getAbilityLabelFailure(msg, error) {
* @tc.number: context_getAbilityLabel_test_0700 console.log(msg + ' Failure ');
* @tc.name: getAbilityLabel : Gets the specified ability label console.log(msg + ' error ' + JSON.stringify(error));
* @tc.desc: Check the return value of the interface (by callback) expect(typeof (error)).assertEqual('number');
* @tc.level 0 expect(error).assertEqual(1)
*/
it('context_getAbilityLabel_test_0700', 0, async function (done) {
var timeOldStamp = await Utils.getNowTime();
let mError;
Bundle.getAbilityLabel(BUNDLE_NAME, SERVICE_ABILITY_NAME, (error, data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_getAbilityLabel_test_0700]', timeOldStamp, timeNewStamp);
mError = error;
if(mError !== null){
console.info('[context_getAbilityLabel_test_0600] callBack error: ' + error);
} }
console.info('[context_getAbilityLabel_test_0700] callBack data is:' + JSON.stringify(data));
});
await Utils.sleep(2000);
getAbilityLabelFailure('[context_getAbilityLabel_test_0700]', mError);
done();
});
function getAbilityLabelSuccess(msg, data) { })
console.log(msg + ' start ' + JSON.stringify(data));
console.log(msg + ' result ' + data);
expect(typeof (data)).assertEqual('string');
expect(data).assertEqual("entry_MainAbility");
}
function getAbilityLabelFailure(msg, error) {
console.log(msg + ' Failure ');
console.log(msg + ' error ' + JSON.stringify(error));
expect(typeof (error)).assertEqual('number');
expect(error).assertEqual(1)
}
})
} }
\ 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 expect 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 bundleMgr from '@ohos.bundle';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index';
const NAME1 = "com.example.third1";
const NAME2 = "com.example.l3jsdemo";
const NAME3 = "com.notexist.com";
const ABILITYNAME1 = "com.example.third1.MainAbility";
const ABILITYNAME2 = "com.example.l3jsdemo.MainAbility";
export default function getLaunchWantForBundle() {
describe('GetLaunchWantForBundleTest', function () {
/*
* @tc.number: SUB_BMS_APPINFO_QUERY_0069
* @tc.name: testGetLaunchWantForBundle.
* @tc.desc: Test getLaunchWantForBundle api by promise and callback.
* @tc.author renyi 00559040
* @tc.size MediumTest
* @tc.type Function
* @tc.level Level 1
*/
it('testGetLaunchWantForBundle', 0, async function (done) {
await bundleMgr.getLaunchWantForBundle(NAME1).then(res => {
expect(res.bundleName).assertEqual(NAME1);
expect(res.abilityName).assertEqual(ABILITYNAME1);
expect(res.deviceId).assertEqual('');
expect(res.action).assertEqual('action.system.home');
expect(res.entities[0]).assertEqual('entity.system.home');
}).catch(err => {
expect(err).assertFail();
});
bundleMgr.getLaunchWantForBundle(NAME1, (err, res) => {
expect(err).assertEqual(0);
expect(res.bundleName).assertEqual(NAME1);
expect(res.abilityName).assertEqual(ABILITYNAME1);
expect(res.deviceId).assertEqual('');
expect(res.action).assertEqual('action.system.home');
expect(res.entities[0]).assertEqual('entity.system.home');
done();
});
});
/*
* @tc.number: SUB_BMS_APPINFO_QUERY_0012
* @tc.name: testGetLaunchWantForBundleWithManyHaps.
* @tc.desc: Test getLaunchWantForBundle api by promise and callback.
* @tc.author renyi 00559040
* @tc.size MediumTest
* @tc.type Function
* @tc.level Level 1
*/
it('testGetLaunchWantForBundleWithManyHaps', 0, async function (done) {
await bundleMgr.getLaunchWantForBundle(NAME2).then(res => {
expect(res.bundleName).assertEqual(NAME2);
expect(res.abilityName).assertEqual(ABILITYNAME2);
expect(res.deviceId).assertEqual('');
expect(res.action).assertEqual('action.system.home');
expect(res.entities[0]).assertEqual('entity.system.home');
}).catch(err => {
expect(err).assertFail();
});
bundleMgr.getLaunchWantForBundle(NAME2, (err, res) => {
expect(err).assertEqual(0);
expect(res.bundleName).assertEqual(NAME2);
expect(res.abilityName).assertEqual(ABILITYNAME2);
expect(res.deviceId).assertEqual('');
expect(res.action).assertEqual('action.system.home');
expect(res.entities[0]).assertEqual('entity.system.home');
done();
});
});
/*
* @tc.number: SUB_BMS_APPINFO_QUERY_0013
* @tc.name: testGetLaunchWantForBundleWithNotExist.
* @tc.desc: Test getLaunchWantForBundle api by promise and callback.
* @tc.author renyi 00559040
* @tc.size MediumTest
* @tc.type Function
* @tc.level Level 2
*/
it('testGetLaunchWantForBundleWithNotExist', 0, async function (done) {
await bundleMgr.getLaunchWantForBundle(NAME3).then(res => {
expect().assertFail();
}).catch(err => {
expect(err).assertEqual(1);
});
bundleMgr.getLaunchWantForBundle(NAME3, (err, res) => {
if (err) {
expect(err).assertEqual(1);
done();
return;
}
expect().assertFail();
done();
});
});
/*
* @tc.number: SUB_BMS_APPINFO_QUERY_0014
* @tc.name: testGetLaunchWantForBundleWithInvalidParam.
* @tc.desc: Test getLaunchWantForBundle api by promise and callback.
* @tc.author renyi 00559040
* @tc.size MediumTest
* @tc.type Function
* @tc.level Level 3
*/
it('testGetLaunchWantForBundleWithInvalidParam', 0, async function (done) {
await bundleMgr.getLaunchWantForBundle(null).then(res => {
expect().assertFail();
}).catch(err => {
expect(err).assertEqual(1);
});
bundleMgr.getLaunchWantForBundle(null, (err, res) => {
if (err) {
expect(err).assertEqual(1);
done();
return;
}
expect().assertFail();
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 bundle from '@ohos.bundle'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'
const BUNDLE_NAME1 = 'com.ohos.launcher';
const BUNDLE_NAME2 = 'com.open.harmony.packagemag';
export default function getNameForUid() {
describe('ActsBmsgetNameForUidTest', function () {
/**
* @tc.number getNameForUid_0100
* @tc.name BUNDLE::getBundleInfo
* @tc.desc Test getBundleInfo interfaces with other hap.
*/
it('getNameForUid_0100', 0, async function (done) {
let dataInfo = await bundle.getBundleInfo(BUNDLE_NAME1);
await bundle.getNameForUid(dataInfo.uid).then(data => {
expect(data).assertEqual(BUNDLE_NAME1);
}).catch(err => {
console.info("getNameForUid fail:" + JSON.stringify(err));
expect(err).assertFail();
});
bundle.getNameForUid(dataInfo.uid, (err, data) => {
console.info("getNameForUid result:" + JSON.stringify(data));
expect(data).assertEqual(BUNDLE_NAME1);
expect(err).assertEqual(0);
done();
});
});
/**
* @tc.number getNameForUid_0200
* @tc.name BUNDLE::getBundleInfo
* @tc.desc Test getBundleInfo interfaces with hap.
*/
it('getNameForUid_0200', 0, async function (done) {
let dataInfo = await bundle.getBundleInfo(BUNDLE_NAME2);
await bundle.getNameForUid(dataInfo.uid).then(data => {
expect(data).assertEqual(BUNDLE_NAME2);
}).catch(err => {
console.info("getNameForUid fail:" + JSON.stringify(err));
expect(err).assertFail();
});
bundle.getNameForUid(dataInfo.uid, (err, data) => {
console.info("getNameForUid result:" + JSON.stringify(data));
expect(data).assertEqual(BUNDLE_NAME2);
expect(err).assertEqual(0);
done();
});
});
/**
* @tc.number getNameForUid_0300
* @tc.name BUNDLE::getBundleInfo
* @tc.desc Test getBundleInfo interfaces with notexist hap.
*/
it('getNameForUid_0300', 0, async function (done) {
await bundle.getNameForUid(123456).then(data => {
expect(data).assertFail();
}).catch(err => {
console.info("getNameForUid fail:" + JSON.stringify(err));
expect(err).assertEqual(1);
});
bundle.getNameForUid(123456, (err, data) => {
console.info("getNameForUid result:" + JSON.stringify(data));
expect(err).assertEqual(1);
done()
});
});
/**
* @tc.number getNameForUid_0400
* @tc.name BUNDLE::getBundleInfo
* @tc.desc Test getBundleInfo interfaces with error param.
*/
it('getNameForUid_0400', 0, async function (done) {
await bundle.getNameForUid(undefined).then(data => {
expect(data).assertFail();
}).catch(err => {
console.info("getNameForUid fail:" + JSON.stringify(err));
expect(err).assertEqual(2);
});
bundle.getNameForUid(undefined, (err, data) => {
console.info("getNameForUid result:" + JSON.stringify(data));
expect(err).assertEqual(2);
done()
});
});
});
}
\ No newline at end of file
...@@ -13,295 +13,338 @@ ...@@ -13,295 +13,338 @@
* limitations under the License. * limitations under the License.
*/ */
import {describe, it, expect} from 'deccjsunit/index.ets'; import { describe, it, expect } from 'deccjsunit/index.ets';
import Utils from './Utils'; import Utils from './Utils';
import bundleManager from '@ohos.bundle'; import bundleManager from '@ohos.bundle';
const BUNDLE_NAME1 = 'com.open.harmony.packagemag';
const BUNDLE_NAME_OTHER = 'com.ohos.acecollaboration';
const BUNDLE_NAME2 = 'com.harmony.packagemag';
const BUNDLE_NAME3 = "";
const BUNDLE_NAME4 = 'com.example.third1';
const ABILITY_NAME1 = 'com.open.harmony.packagemag.MainAbility';
const ABILITY_NAME_OTHER = 'com.ohos.acecollaboration.MainAbility';
const ABILITY_NAME2 = 'com.harmony.packagemag1.MainAbility';
const ABILITY_NAME3 = 'com.example.third1.MainAbility';
export default function GetabilityInfo() { export default function GetabilityInfo() {
describe('GetabilityInfo', function () {
let bundleName = "com.open.harmony.packagemag";
let abilityName = "com.open.harmony.packagemag.MainAbility";
let bundleName_other = "com.ohos.acecollaboration"; describe('GetabilityInfo', function () {
let abilityName_other = "com.ohos.acecollaboration.MainAbility";
let bundleName1 = "com.harmony.packagemag"; /*
let abilityName1 = "com.harmony.packagemag1.MainAbility"; * @tc.number: bundle_GetabilityInfo_test_0100
* @tc.name: getAbilityInfo : The basic ability is enhanced to obtain the specified Ability information
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it('bundle_GetabilityInfo_test_0100', 0, async function (done) {
let mData;
let timeOldStamp = await Utils.getNowTime();
await bundleManager.getAbilityInfo(BUNDLE_NAME1, ABILITY_NAME1).then((data) => {
let timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('bundle_GetabilityInfo_test_0100', timeOldStamp, timeNewStamp)
console.info('[bundle_GetabilityInfo_test_0100] getApplicationInfo promise data is: ' + JSON.stringify(data));
for (const item in data) {
const a = data[item];
console.info(item + ":" + JSON.stringify(a));
};
expect(typeof (data)).assertEqual("object");
mData = data;
checkAbilityInfo(mData);
done();
}).catch((error) => {
console.error('[bundle_GetabilityInfo_test_0100]Operation failed. Cause: ' + JSON.stringify(error));
expect(error).assertFail();
done();
});
});
/* /*
* @tc.number: bundle_GetabilityInfo_test_0100 * @tc.number: bundle_GetabilityInfo_test_0200
* @tc.name: getAbilityInfo : The basic ability is enhanced to obtain the specified Ability information * @tc.name: getAbilityInfo : The basic ability is enhanced to obtain the specified Ability information
* @tc.desc: Check the return value of the interface (by promise) * @tc.desc: Check the return value of the interface (by callback)
* @tc.level 0 * @tc.level 0
*/ */
it('bundle_GetabilityInfo_test_0100', 0, async function (done) { it('bundle_GetabilityInfo_test_0200', 0, async function (done) {
let mData; let mData;
var timeOldStamp = await Utils.getNowTime(); let timeOldStamp = await Utils.getNowTime();
await bundleManager.getAbilityInfo(bundleName, abilityName) bundleManager.getAbilityInfo(BUNDLE_NAME1, ABILITY_NAME1, (err, data) => {
.then((data) => { let timeNewStamp = Utils.getNowTime();
var timeNewStamp = Utils.getNowTime(); Utils.getDurationTime('bundle_GetabilityInfo_test_0200', timeOldStamp, timeNewStamp);
Utils.getDurationTime('bundle_GetabilityInfo_test_0100', timeOldStamp, timeNewStamp) if (err) {
console.info('[bundle_GetabilityInfo_test_0100] getApplicationInfo promise data is: ' + JSON.stringify(data)); console.error('[bundle_GetabilityInfo_test_0200]Operation failed. Cause: ' + JSON.stringify(err));
expect(typeof (data)).assertEqual("object"); expect(err).assertFail();
mData = data; }
}).catch((error) => { console.info('[bundle_GetabilityInfo_test_0200] getApplicationInfo callback data is: ' + JSON.stringify(data));
console.error('[bundle_GetabilityInfo_test_0100]Operation failed. Cause: ' + JSON.stringify(error)); mData = data;
expect(error).assertFail(); Utils.sleep(2000);
}) checkAbilityInfo(mData);
checkAbilityInfo(mData); done();
done(); });
}); });
/*
* @tc.number: testgetAbilityInfoOtherBundle
* @tc.name: getAbilityInfo : The basic ability is enhanced to obtain the specified Ability information
* @tc.desc: Check the return value of the interface (by callback)
* @tc.level 0
*/
it('testgetAbilityInfoOtherBundle', 0, async function (done) {
await bundleManager.getAbilityInfo(BUNDLE_NAME4, ABILITY_NAME3).then(res => {
checkAbilityInfo_other(res);
console.info('actwsBundleManager getAbilityInfo promise success res:' + JSON.stringify(res));
for (const item in res) {
const a = res[item];
console.info(item + ":" + JSON.stringify(a));
};
}).catch(err => {
console.info('actwsBundleManager getAbilityInfo promise err:' + JSON.stringify(err));
expect().assertFail();
});
bundleManager.getAbilityInfo(BUNDLE_NAME4, ABILITY_NAME3, (err, res) => {
if (err) {
console.info('actwsBundleManager getAbilityInfo callback err:' + JSON.stringify(err));
expect().assertFail();
done();
return;
}
checkAbilityInfo_other(res);
console.info('actwsBundleManager getAbilityInfo callback success res:' + JSON.stringify(res));
for (const item in res) {
const a = res[item];
console.info(item + ":" + JSON.stringify(a));
};
done();
});
});
/*
* @tc.number: bundle_GetabilityInfo_test_0200
* @tc.name: getAbilityInfo : The basic ability is enhanced to obtain the specified Ability information
* @tc.desc: Check the return value of the interface (by callback)
* @tc.level 0
*/
it('bundle_GetabilityInfo_test_0200', 0, async function (done) {
let mData;
var timeOldStamp = await Utils.getNowTime();
await bundleManager.getAbilityInfo(bundleName, abilityName, (err, data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('bundle_GetabilityInfo_test_0200', timeOldStamp, timeNewStamp)
if (err) {
console.error('[bundle_GetabilityInfo_test_0200]Operation failed. Cause: ' + JSON.stringify(err));
expect(err).assertFail();
}
console.info('[bundle_GetabilityInfo_test_0200] getApplicationInfo callback data is: ' + JSON.stringify(data));
mData = data;
})
await Utils.sleep(2000);
checkAbilityInfo(mData);
done();
});
/* /*
* @tc.number: bundle_GetabilityInfo_test_0300 * @tc.number: bundle_GetabilityInfo_test_0300
* @tc.name: getAbilityInfo : The basic ability is enhanced to obtain the specified Ability information * @tc.name: getAbilityInfo : The basic ability is enhanced to obtain the specified Ability information
* @tc.desc: Check the return value of the interface (by promise) * @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0 * @tc.level 0
*/ */
it('bundle_GetabilityInfo_test_0300', 0, async function (done) { it('bundle_GetabilityInfo_test_0300', 0, async function (done) {
var timeOldStamp = await Utils.getNowTime(); let timeOldStamp = await Utils.getNowTime();
await bundleManager.getAbilityInfo(bundleName_other, abilityName_other) await bundleManager.getAbilityInfo(BUNDLE_NAME_OTHER, ABILITY_NAME_OTHER).then((data) => {
.then((data) => { let timeNewStamp = Utils.getNowTime();
var timeNewStamp = Utils.getNowTime(); Utils.getDurationTime('bundle_GetabilityInfo_test_0300', timeOldStamp, timeNewStamp);
Utils.getDurationTime('bundle_GetabilityInfo_test_0300',timeOldStamp,timeNewStamp) expect(data).assertFail();
expect(data).assertFail(); }).catch((error) => {
}).catch((error) => { console.error('[bundle_GetabilityInfo_test_0300]Operation failed. Cause: ' + JSON.stringify(error));
console.error('[bundle_GetabilityInfo_test_0300]Operation failed. Cause: ' + JSON.stringify(error)); expect(error).assertEqual(1);
expect(error).assertEqual(1); });
done();
}); });
done();
});
/* /*
* @tc.number: bundle_GetabilityInfo_test_0400 * @tc.number: bundle_GetabilityInfo_test_0400
* @tc.name: getAbilityInfo : The basic ability is enhanced to obtain the specified Ability information * @tc.name: getAbilityInfo : The basic ability is enhanced to obtain the specified Ability information
* @tc.desc: Check the return value of the interface (by promise) * @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0 * @tc.level 0
*/ */
it('bundle_GetabilityInfo_test_0400', 0, async function (done) { it('bundle_GetabilityInfo_test_0400', 0, async function (done) {
let error1; let error1;
var timeOldStamp = await Utils.getNowTime(); let timeOldStamp = await Utils.getNowTime();
bundleManager.getAbilityInfo(bundleName1, abilityName) await bundleManager.getAbilityInfo(BUNDLE_NAME2, ABILITY_NAME1).then((data) => {
.then((data) => { let timeNewStamp = Utils.getNowTime();
var timeNewStamp = Utils.getNowTime(); Utils.getDurationTime('bundle_GetabilityInfo_test_0400', timeOldStamp, timeNewStamp);
Utils.getDurationTime('bundle_GetabilityInfo_test_0400', timeOldStamp, timeNewStamp) console.info('[bundle_GetabilityInfo_test_0400] getApplicationInfo data is: ' + JSON.stringify(data));
console.info('[bundle_GetabilityInfo_test_0400] getApplicationInfo data is: ' + JSON.stringify(data)); expect(typeof (data)).assertEqual("object");
expect(typeof (data)).assertEqual("object"); }).catch((error) => {
}).catch((error) => { console.error('[bundle_GetabilityInfo_test_0400]Operation failed. Cause: ' + JSON.stringify(error));
console.error('[bundle_GetabilityInfo_test_0400]Operation failed. Cause: ' + JSON.stringify(error)); error1 = error;
error1 = error; });
}) await Utils.sleep(1000);
await Utils.sleep(1000); await expect(error1).assertEqual(1);
await expect(error1).assertEqual(1); done();
done(); });
});
/* /*
* @tc.number: bundle_GetabilityInfo_test_0500 * @tc.number: bundle_GetabilityInfo_test_0500
* @tc.name: getAbilityInfo : The basic ability is enhanced to obtain the specified Ability information * @tc.name: getAbilityInfo : The basic ability is enhanced to obtain the specified Ability information
* @tc.desc: Check the return value of the interface (by callback) * @tc.desc: Check the return value of the interface (by callback)
* @tc.level 0 * @tc.level 0
*/ */
it('bundle_GetabilityInfo_test_0500', 0, async function (done) { it('bundle_GetabilityInfo_test_0500', 0, async function (done) {
let error let error
await bundleManager.getAbilityInfo(bundleName, abilityName1).then((data) => { await bundleManager.getAbilityInfo(BUNDLE_NAME1, ABILITY_NAME2).then((data) => {
console.info('[bundle_GetabilityInfo_test_0500] START' + JSON.stringify(data)); console.info('[bundle_GetabilityInfo_test_0500] START' + JSON.stringify(data));
}).catch((err) => { }).catch((err) => {
console.info('[bundle_GetabilityInfo_test_0500] err = ' + JSON.stringify(err)); console.info('[bundle_GetabilityInfo_test_0500] err = ' + JSON.stringify(err));
error = err error = err;
}) })
expect(error).assertEqual(1); expect(error).assertEqual(1);
done(); done();
console.info('[bundle_GetabilityInfo_test_0500] END'); console.info('[bundle_GetabilityInfo_test_0500] END');
}); });
/* /*
* @tc.number: bundle_GetabilityInfo_test_0600 * @tc.number: bundle_GetabilityInfo_test_0600
* @tc.name: getAbilityInfo : The basic ability is enhanced to obtain the specified Ability information * @tc.name: getAbilityInfo : The basic ability is enhanced to obtain the specified Ability information
* @tc.desc: Check the return value of the interface (by promise) * @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0 * @tc.level 0
*/ */
let bundleName2 = ""; it('bundle_GetabilityInfo_test_0600', 0, async function (done) {
it('bundle_GetabilityInfo_test_0600', 0, async function (done) { let error1;
let error1; let timeOldStamp = await Utils.getNowTime();
var timeOldStamp = await Utils.getNowTime(); await bundleManager.getAbilityInfo(BUNDLE_NAME3, ABILITY_NAME1).then((data) => {
bundleManager.getAbilityInfo(bundleName2, abilityName) let timeNewStamp = Utils.getNowTime();
.then((data) => { Utils.getDurationTime('bundle_GetabilityInfo_test_0600', timeOldStamp, timeNewStamp);
var timeNewStamp = Utils.getNowTime(); console.info('[bundle_GetabilityInfo_test_0600] getApplicationInfo data promise is: ' + JSON.stringify(data));
Utils.getDurationTime('bundle_GetabilityInfo_test_0600', timeOldStamp, timeNewStamp) expect(typeof (data)).assertEqual("object");
console.info('[bundle_GetabilityInfo_test_0600] getApplicationInfo data promise is: ' + JSON.stringify(data)); }).catch((error) => {
expect(typeof (data)).assertEqual("object"); console.error('[bundle_GetabilityInfo_test_0600]Operation failed. Cause: ' + JSON.stringify(error));
}).catch((error) => { error1 = error;
console.error('[bundle_GetabilityInfo_test_0600]Operation failed. Cause: ' + JSON.stringify(error)); })
error1 = error; await Utils.sleep(1000);
}) await expect(error1).assertEqual(1);
await Utils.sleep(1000); done();
await expect(error1).assertEqual(1); });
done();
});
/** /*
* 打印AbilityInfo属性信息 * @tc.number: testgetAbilityInfoOtherBundle
* @param data * @tc.name: getAbilityInfo : The basic ability is enhanced to obtain the specified Ability information
*/ * @tc.desc: Check the return value of the interface (by callback)
function checkAbilityInfo(data) { * @tc.level 0
expect(typeof (data.bundleName)).assertEqual("string"); */
expect(data.bundleName).assertEqual("com.open.harmony.packagemag") it('testgetAbilityInfoUndefined', 0, async function (done) {
expect(typeof (data.name)).assertEqual("string"); await bundleManager.getAbilityInfo(undefined, undefined).then(res => {
expect(data.name).assertEqual("com.open.harmony.packagemag.MainAbility"); console.info('actwsBundleManager getAbilityInfo promise success res:' + JSON.stringify(res));
expect(data.label).assertEqual("$string:entry_MainAbility"); expect().assertFail();
expect(typeof (data.label)).assertEqual("string"); }).catch(err => {
expect(data.description).assertEqual("$string:mainability_description"); expect(err).assertEqual(2);
expect(typeof (data.description)).assertEqual("string"); });
expect(data.icon).assertEqual("$media:icon"); bundleManager.getAbilityInfo(null, null, (err, res) => {
expect(typeof (data.icon)).assertEqual("string"); if (err) {
expect(data.srcPath).assertEqual("MainAbility"); expect(err).assertEqual(2);
expect(typeof (data.srcPath)).assertEqual("string"); done();
expect(data.srcLanguage).assertEqual("ets"); return;
expect(typeof (data.srcLanguage)).assertEqual("string"); }
expect(data.isVisible).assertEqual(true); console.info('actwsBundleManager getAbilityInfo callback success res:' + JSON.stringify(res));
expect(Array.isArray(data.permissions)).assertEqual(true); expect().assertFail();
expect(Array.isArray(data.deviceCapabilities)).assertEqual(true); done();
expect(data.deviceTypes[0]).assertEqual("phone"); });
expect(typeof (data.process)).assertEqual("string"); });
expect(data.process).assertEqual("");
expect(typeof (data.uri)).assertEqual("string");
expect(data.uri).assertEqual("");
expect(data.moduleName).assertEqual("entry");
expect(typeof (data.moduleName)).assertEqual("string");
expect(typeof (data.applicationInfo)).assertEqual("object");
checkApplicationInfo(data.applicationInfo);
console.log("---checkAbilityInfo End--- ");
}
/** function checkAbilityInfo(data) {
* 打印ApplicationInfo属性信息 expect(typeof (data.bundleName)).assertEqual("string");
* @param data expect(data.bundleName).assertEqual("com.open.harmony.packagemag");
*/ expect(typeof (data.name)).assertEqual("string");
function checkApplicationInfo(info) { expect(data.name).assertEqual("com.open.harmony.packagemag.MainAbility");
expect(typeof (info)).assertEqual("object") expect(data.label).assertEqual("$string:entry_MainAbility");
expect(typeof (info.name)).assertEqual("string") expect(typeof (data.label)).assertEqual("string");
expect(info.name).assertEqual("com.open.harmony.packagemag"); expect(data.description).assertEqual("$string:mainability_description");
expect(typeof (info.codePath)).assertEqual("string") expect(typeof (data.description)).assertEqual("string");
expect(info.codePath).assertEqual("/data/app/el1/bundle/public/com.open.harmony.packagemag"); expect(data.icon).assertEqual("$media:icon");
expect(typeof (info.accessTokenId)).assertEqual("number") expect(typeof (data.icon)).assertEqual("string");
expect(info.accessTokenId > 0).assertTrue() expect(data.srcPath).assertEqual("MainAbility");
expect(typeof (info.description)).assertEqual("string") expect(typeof (data.srcPath)).assertEqual("string");
expect(info.description).assertEqual("$string:mainability_description") expect(data.srcLanguage).assertEqual("ets");
expect(typeof (info.descriptionId)).assertEqual("number") expect(typeof (data.srcLanguage)).assertEqual("string");
expect(info.descriptionId > 0).assertTrue() expect(data.isVisible).assertEqual(true);
expect(typeof (info.icon)).assertEqual("string") expect(Array.isArray(data.permissions)).assertEqual(true);
expect(info.icon).assertEqual("$media:icon") expect(Array.isArray(data.deviceCapabilities)).assertEqual(true);
expect(typeof (info.iconId)).assertEqual("number") expect(data.deviceTypes[0]).assertEqual("phone");
expect(info.iconId > 0).assertTrue() expect(typeof (data.process)).assertEqual("string");
expect(typeof (info.label)).assertEqual("string") expect(data.process).assertEqual("");
expect(info.label).assertEqual("$string:entry_MainAbility") expect(typeof (data.uri)).assertEqual("string");
expect(typeof (info.labelId)).assertEqual("number") expect(data.uri).assertEqual("");
expect(info.labelId > 0).assertTrue() expect(data.moduleName).assertEqual("entry");
expect(info.systemApp).assertEqual(true) expect(typeof (data.moduleName)).assertEqual("string");
expect(typeof (info.entryDir)).assertEqual("string") expect(typeof (data.applicationInfo)).assertEqual("object");
expect(info.entryDir).assertEqual("/data/app/el1/bundle/public/com.open.harmony.packagemag/com.open.harmony.packagemag"); checkApplicationInfo(data.applicationInfo);
expect(typeof (info.supportedModes)).assertEqual("number") console.log("---checkAbilityInfo End--- ");
expect(info.supportedModes).assertEqual(0) }
expect(typeof (info.process)).assertEqual("string")
expect(info.process).assertEqual("")
expect(Array.isArray(info.moduleSourceDirs)).assertEqual(true);
expect(info.moduleSourceDirs[0]).assertEqual("/data/app/el1/bundle/public/com.open.harmony.packagemag/com.open.harmony.packagemag");
expect(Array.isArray(info.permissions)).assertEqual(true);
}
/** function checkApplicationInfo(info) {
* 打印ApplicationInfo属性信息 expect(typeof (info)).assertEqual("object");
* @param data expect(typeof (info.name)).assertEqual("string");
*/ expect(info.name).assertEqual("com.open.harmony.packagemag");
function checkAbilityInfo_other(data) { expect(typeof (info.codePath)).assertEqual("string");
expect(typeof (data.bundleName)).assertEqual("string"); expect(info.codePath).assertEqual("/data/app/el1/bundle/public/com.open.harmony.packagemag");
expect(data.bundleName).assertEqual("com.ohos.acecollaboration"); expect(typeof (info.accessTokenId)).assertEqual("number");
expect(typeof (data.name)).assertEqual("string"); expect(info.accessTokenId > 0).assertTrue();
expect(data.name).assertEqual("com.ohos.acecollaboration.MainAbility"); expect(typeof (info.description)).assertEqual("string");
expect(data.label).assertEqual("$string:entry_MainAbility"); expect(info.description).assertEqual("$string:mainability_description");
expect(typeof (data.label)).assertEqual("string"); expect(typeof (info.descriptionId)).assertEqual("number");
expect(data.description).assertEqual("$string:mainability_description"); expect(info.descriptionId > 0).assertTrue();
expect(typeof (data.description)).assertEqual("string"); expect(typeof (info.icon)).assertEqual("string");
expect(data.icon).assertEqual("$media:icon"); expect(info.icon).assertEqual("$media:icon");
expect(typeof (data.icon)).assertEqual("string"); expect(typeof (info.iconId)).assertEqual("number");
expect(data.srcPath).assertEqual("MainAbility"); expect(info.iconId > 0).assertTrue();
expect(typeof (data.srcPath)).assertEqual("string"); expect(typeof (info.label)).assertEqual("string");
expect(data.srcLanguage).assertEqual("ets"); expect(info.label).assertEqual("$string:entry_MainAbility");
expect(typeof (data.srcLanguage)).assertEqual("string"); expect(typeof (info.labelId)).assertEqual("number");
expect(data.isVisible).assertEqual(true); expect(info.labelId > 0).assertTrue();
expect(Array.isArray(data.permissions)).assertEqual(true); expect(info.systemApp).assertEqual(true);
expect(Array.isArray(data.deviceCapabilities)).assertEqual(true); expect(typeof (info.entryDir)).assertEqual("string");
expect(data.deviceTypes[0]).assertEqual("phone"); expect(info.entryDir).assertEqual("/data/app/el1/bundle/public/com.open.harmony.packagemag/com.open.harmony.packagemag");
expect(typeof (data.process)).assertEqual("string"); expect(typeof (info.supportedModes)).assertEqual("number");
expect(data.process).assertEqual(""); expect(info.supportedModes).assertEqual(0);
expect(typeof (data.uri)).assertEqual("string"); expect(typeof (info.process)).assertEqual("string");
expect(data.uri).assertEqual(""); expect(info.process).assertEqual("");
expect(data.moduleName).assertEqual("entry"); expect(Array.isArray(info.moduleSourceDirs)).assertEqual(true);
expect(typeof (data.moduleName)).assertEqual("string"); expect(info.moduleSourceDirs[0]).assertEqual("/data/app/el1/bundle/public/com.open.harmony.packagemag/com.open.harmony.packagemag");
expect(typeof (data.applicationInfo)).assertEqual("object"); expect(Array.isArray(info.permissions)).assertEqual(true);
checkApplicationInfo_other(data.applicationInfo); }
console.log("---checkAbilityInfo_other End--- ");
} async function checkAbilityInfo_other(data) {
expect(data.bundleName).assertEqual("com.example.third1");
expect(data.name).assertEqual("com.example.third1.MainAbility");
expect(data.label).assertEqual("$string:app_name");
expect(data.description).assertEqual("$string:mainability_description");
expect(data.icon).assertEqual("$media:icon");
expect(data.srcPath).assertEqual("");
expect(data.srcLanguage).assertEqual("js");
expect(data.isVisible).assertEqual(true);
expect(data.deviceTypes[0]).assertEqual("phone");
expect(data.process).assertEqual("");
expect(data.uri).assertEqual("");
expect(data.moduleName).assertEqual("entry");
expect(data.type).assertEqual(1);
expect(data.orientation).assertEqual(0);
expect(data.launchMode).assertEqual(1);
expect(data.backgroundModes).assertEqual(0);
expect(data.descriptionId).assertLarger(0);
expect(data.formEnabled).assertEqual(false);
expect(data.iconId).assertLarger(0);
except(data.labelId).assertLarger(0);
expect(data.subType).assertEqual(0);
except(data.enabled).assertEqual(true);
expect(data.readPermission).assertEqual("");
expect(data.writePermission).assertEqual("");
expect(data.targetAbility).assertEqual("");
expect(data.theme).assertEqual("");
expect(data.metaData).assertEqual([]);
expect(data.metadata).assertEqual([]);
checkApplicationInfo_other(data.applicationInfo);
console.log("---checkAbilityInfo_other End--- ");
}
/** async function checkApplicationInfo_other(info) {
* 打印ApplicationInfo属性信息 expect(info.name).assertEqual("com.example.third1");
* @param data expect(info.codePath).assertEqual("/data/app/el1/bundle/public/com.example.third1");
*/ expect(info.accessTokenId > 0).assertTrue();
function checkApplicationInfo_other(info) { expect(info.description).assertEqual("$string:mainability_description");
expect(typeof (info)).assertEqual("object") expect(info.descriptionId > 0).assertTrue();
expect(typeof (info.name)).assertEqual("string") expect(info.icon).assertEqual("$media:icon");
expect(info.name).assertEqual("com.ohos.acecollaboration"); expect(info.iconId > 0).assertTrue();
expect(typeof (info.codePath)).assertEqual("string") expect(info.label).assertEqual("$string:app_name");
expect(info.codePath).assertEqual("/data/app/el1/bundle/public/com.ohos.acecollaboration"); expect(info.labelId > 0).assertTrue();
expect(typeof (info.accessTokenId)).assertEqual("number") expect(info.systemApp).assertEqual(true);
expect(info.accessTokenId > 0).assertTrue() expect(info.entryDir).assertEqual("/data/app/el1/bundle/public/com.ohos.acecollaboration/com.ohos.acecollaboration");
expect(typeof (info.description)).assertEqual("string") expect(info.supportedModes).assertEqual(0);
expect(info.description).assertEqual("$string:mainability_description") expect(info.process).assertEqual("");
expect(typeof (info.descriptionId)).assertEqual("number") expect(info.moduleSourceDirs[0]).assertEqual("/data/app/el1/bundle/public/com.ohos.acecollaboration/com.ohos.acecollaboration");
expect(info.descriptionId > 0).assertTrue() expect(info.metaData).expect({});
expect(typeof (info.icon)).assertEqual("string") expect(info.metadata).expect({});
expect(info.icon).assertEqual("$media:icon") expect(info.enabled).expect(true);
expect(typeof (info.iconId)).assertEqual("number") expect(info.flags).expect(0);
expect(info.iconId > 0).assertTrue() expect(info.uid).assertLarger(0);
expect(typeof (info.label)).assertEqual("string") expect(info.entityType).assertEqual("unspecified");
expect(info.label).assertEqual("$string:entry_MainAbility") expect(info.removable).assertEqual(true);
expect(typeof (info.labelId)).assertEqual("number") }
expect(info.labelId > 0).assertTrue() });
expect(info.systemApp).assertEqual(true)
expect(typeof (info.entryDir)).assertEqual("string")
expect(info.entryDir).assertEqual("/data/app/el1/bundle/public/com.ohos.acecollaboration/com.ohos.acecollaboration");
expect(typeof (info.supportedModes)).assertEqual("number")
expect(info.supportedModes).assertEqual(0)
expect(typeof (info.process)).assertEqual("string")
expect(info.process).assertEqual("")
expect(Array.isArray(info.moduleSourceDirs)).assertEqual(true);
expect(info.moduleSourceDirs[0]).assertEqual("/data/app/el1/bundle/public/com.ohos.acecollaboration/com.ohos.acecollaboration");
expect(Array.isArray(info.permissions)).assertEqual(true);
}
});
} }
\ No newline at end of file
...@@ -12,274 +12,259 @@ ...@@ -12,274 +12,259 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import {describe, it, expect} from 'deccjsunit/index.ets'; import { describe, it, expect } from 'deccjsunit/index.ets';
import Utils from './Utils'; import Utils from './Utils';
import Bundle from '@ohos.bundle'; import Bundle from '@ohos.bundle';
const BUNDLE_NAME = 'com.open.harmony.packagemag' const BUNDLE_NAME = 'com.open.harmony.packagemag';
const ABILITY_NAME = 'com.open.harmony.packagemag.MainAbility' const BUNDLE_NAME_ERROR = 'com.ohos.acepackage.error';
const ABILITY_NAME = 'com.open.harmony.packagemag.MainAbility';
const ABILITY_NAME_ERROR = 'com.ohos.acepackage.error.MainAbility';
const ABILITY = { const ABILITY = {
bundleName: BUNDLE_NAME, bundleName: BUNDLE_NAME,
name: ABILITY_NAME name: ABILITY_NAME
} }
const BUNDLE_NAME_ERROR = 'com.ohos.acepackage.error'
const ABILITY_NAME_ERROR = 'com.ohos.acepackage.error.MainAbility'
const ABILITY_ERROR = { const ABILITY_ERROR = {
bundleName: BUNDLE_NAME_ERROR, bundleName: BUNDLE_NAME_ERROR,
name: ABILITY_NAME_ERROR name: ABILITY_NAME_ERROR
} }
export default function isAbilityEnabledETSUnit() { export default function isAbilityEnabledETSUnit() {
describe('context_isAbilityEnabled_test', function () {
/*
* @tc.number: context_isAbilityEnabled_test_0100
* @tc.name: isAbilityEnabled : Get whether to enable a specified ability
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it('context_isAbilityEnabled_test_0100', 0, async function (done) {
var timeOldStamp = await Utils.getNowTime();
let mData;
await Bundle.isAbilityEnabled(ABILITY)
.then((data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_isAbilityEnabled_test_0100]', timeOldStamp, timeNewStamp);
mData = data;
console.info('[context_isAbilityEnabled_test_0100] promise data is: ' + JSON.stringify(data));
})
.catch((error) => {
console.info('[context_isAbilityEnabled_test_0100] promise error is: ' + error);
expect(error).assertFail();
});
getAbilityEnabledSuccess('[context_isAbilityEnabled_test_0100]', mData);
done();
});
/* describe('context_isAbilityEnabled_test', function () {
* @tc.number: context_isAbilityEnabled_test_0200
* @tc.name: isAbilityEnabled : Get whether to enable a specified ability
* @tc.desc: Check the return value of the interface (by callback)
* @tc.level 0
*/
it('context_isAbilityEnabled_test_0200', 0, async function (done) {
var timeOldStamp = await Utils.getNowTime();
let mData;
Bundle.isAbilityEnabled(ABILITY, (error, data) => {
if(error){
console.error('[context_isAbilityEnabled_test_0200]Operation failed. Cause: ' + JSON.stringify(error));
expect(error).assertFail();
}
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_isAbilityEnabled_test_0200]', timeOldStamp, timeNewStamp);
mData = data;
console.info('[context_isAbilityEnabled_test_0200] callBack error: ' + error);
console.info('[context_isAbilityEnabled_test_0200] callBack data is:' + JSON.stringify(data));
});
await Utils.sleep(2000);
getAbilityEnabledSuccess('[context_isAbilityEnabled_test_0200]', mData);
done();
});
/* /*
* @tc.number: context_isAbilityEnabled_test_0300 * @tc.number: context_isAbilityEnabled_test_0100
* @tc.name: isAbilityEnabled : Get whether to enable a specified ability * @tc.name: isAbilityEnabled : Get whether to enable a specified ability
* @tc.desc: Check the return value of the interface (by promise) * @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0 * @tc.level 0
*/ */
it('context_isAbilityEnabled_test_0300', 0, async function (done) { it('context_isAbilityEnabled_test_0100', 0, async function (done) {
var timeOldStamp = await Utils.getNowTime(); let timeOldStamp = await Utils.getNowTime();
let mData; let mData;
await Bundle.isAbilityEnabled(ABILITY_ERROR) await Bundle.isAbilityEnabled(ABILITY).then((data) => {
.then((data) => { let timeNewStamp = Utils.getNowTime();
var timeNewStamp = Utils.getNowTime(); Utils.getDurationTime('[context_isAbilityEnabled_test_0100]', timeOldStamp, timeNewStamp);
Utils.getDurationTime('[context_isAbilityEnabled_test_0300]', timeOldStamp, timeNewStamp); mData = data;
mData = data; console.info('[context_isAbilityEnabled_test_0100] promise data is: ' + JSON.stringify(data));
console.info('[context_isAbilityEnabled_test_0300] promise data is: ' + JSON.stringify(data)); }).catch((error) => {
}) console.info('[context_isAbilityEnabled_test_0100] promise error is: ' + error);
.catch((error) => { expect(error).assertFail();
var timeNewStamp = Utils.getNowTime(); });
Utils.getDurationTime('[context_isAbilityEnabled_test_0300]', timeOldStamp, timeNewStamp); getAbilityEnabledSuccess('[context_isAbilityEnabled_test_0100]', mData);
console.info('[context_isAbilityEnabled_test_0300] promise error is: ' + error); done();
expect(error).assertFail();
}); });
getAbilityEnabledFalse('[context_isAbilityEnabled_test_0300]', mData);
done();
});
/*
* @tc.number: context_isAbilityEnabled_test_0400
* @tc.name: isAbilityEnabled : Get whether to enable a specified ability
* @tc.desc: Check the return value of the interface (by callback)
* @tc.level 0
*/
it('context_isAbilityEnabled_test_0400', 0, async function (done) {
var timeOldStamp = await Utils.getNowTime();
let mData;
Bundle.isAbilityEnabled(ABILITY_ERROR, (error, data) => {
if(error){
console.error('[context_isAbilityEnabled_test_0400]Operation failed. Cause: ' + JSON.stringify(error));
expect(error).assertFail();
}
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_isAbilityEnabled_test_0300]', timeOldStamp, timeNewStamp);
mData = data;
console.info('[context_isAbilityEnabled_test_0400] callBack error: ' + error);
console.info('[context_isAbilityEnabled_test_0400] callBack data is:' + JSON.stringify(data));
});
await Utils.sleep(2000);
console.info('[context_isAbilityEnabled_test_0400] Failure ');
getAbilityEnabledFalse('[context_isAbilityEnabled_test_0300]', mData);
done();
});
/*
* @tc.number: context_isAbilityEnabled_test_0200
* @tc.name: isAbilityEnabled : Get whether to enable a specified ability
* @tc.desc: Check the return value of the interface (by callback)
* @tc.level 0
*/
it('context_isAbilityEnabled_test_0200', 0, async function (done) {
let timeOldStamp = await Utils.getNowTime();
let mData;
Bundle.isAbilityEnabled(ABILITY, (error, data) => {
if (error) {
console.error('[context_isAbilityEnabled_test_0200]Operation failed. Cause: ' + JSON.stringify(error));
expect(error).assertFail();
}
let timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_isAbilityEnabled_test_0200]', timeOldStamp, timeNewStamp);
mData = data;
console.info('[context_isAbilityEnabled_test_0200] callBack error: ' + error);
console.info('[context_isAbilityEnabled_test_0200] callBack data is:' + JSON.stringify(data));
});
await Utils.sleep(2000);
getAbilityEnabledSuccess('[context_isAbilityEnabled_test_0200]', mData);
done();
});
/* /*
* @tc.number: context_isAbilityEnabled_test_0500 * @tc.number: context_isAbilityEnabled_test_0300
* @tc.name: isAbilityEnabled : Get whether to enable a specified ability * @tc.name: isAbilityEnabled : Get whether to enable a specified ability
* @tc.desc: Check the return value of the interface (by promise) * @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0 * @tc.level 0
*/ */
it('context_isAbilityEnabled_test_0500', 0, async function (done) { it('context_isAbilityEnabled_test_0300', 0, async function (done) {
await Bundle.setAbilityEnabled(ABILITY, true) let timeOldStamp = await Utils.getNowTime();
.then((data) => { let mData;
console.info('[context_isAbilityEnabled_test_0500] set enable true data is: ' + JSON.stringify(data)); await Bundle.isAbilityEnabled(ABILITY_ERROR).then((data) => {
}).catch((error) => { let timeNewStamp = Utils.getNowTime();
console.info('[context_isAbilityEnabled_test_0500] set enable true error is: ' + error); Utils.getDurationTime('[context_isAbilityEnabled_test_0300]', timeOldStamp, timeNewStamp);
expect(error).assertFail(); mData = data;
}) console.info('[context_isAbilityEnabled_test_0300] promise data is: ' + JSON.stringify(data));
}).catch((error) => {
let timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_isAbilityEnabled_test_0300]', timeOldStamp, timeNewStamp);
console.info('[context_isAbilityEnabled_test_0300] promise error is: ' + error);
expect(error).assertFail();
});
getAbilityEnabledFalse('[context_isAbilityEnabled_test_0300]', mData);
done();
});
var timeOldStamp = await Utils.getNowTime(); /*
let mData; * @tc.number: context_isAbilityEnabled_test_0400
await Bundle.isAbilityEnabled(ABILITY) * @tc.name: isAbilityEnabled : Get whether to enable a specified ability
.then((data) => { * @tc.desc: Check the return value of the interface (by callback)
var timeNewStamp = Utils.getNowTime(); * @tc.level 0
Utils.getDurationTime('[context_isAbilityEnabled_test_0500]', timeOldStamp, timeNewStamp); */
mData = data; it('context_isAbilityEnabled_test_0400', 0, async function (done) {
console.info('[context_isAbilityEnabled_test_0500] promise data is: ' + JSON.stringify(data)); let timeOldStamp = await Utils.getNowTime();
}) let mData;
.catch((error) => { Bundle.isAbilityEnabled(ABILITY_ERROR, (error, data) => {
console.info('[context_isAbilityEnabled_test_0500] promise error is: ' + error); if (error) {
expect(error).assertFail(); console.error('[context_isAbilityEnabled_test_0400]Operation failed. Cause: ' + JSON.stringify(error));
expect(error).assertFail();
}
let timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_isAbilityEnabled_test_0300]', timeOldStamp, timeNewStamp);
mData = data;
console.info('[context_isAbilityEnabled_test_0400] callBack error: ' + error);
console.info('[context_isAbilityEnabled_test_0400] callBack data is:' + JSON.stringify(data));
});
await Utils.sleep(2000);
console.info('[context_isAbilityEnabled_test_0400] Failure ');
getAbilityEnabledFalse('[context_isAbilityEnabled_test_0300]', mData);
done();
}); });
getAbilityEnabledTrue('[context_isAbilityEnabled_test_0500]', mData);
done();
});
/*
* @tc.number: context_isAbilityEnabled_test_0600
* @tc.name: isAbilityEnabled : Get whether to enable a specified ability
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it('context_isAbilityEnabled_test_0600', 0, async function (done) {
await Bundle.setAbilityEnabled(ABILITY, false)
.then((data) => {
console.info('[context_isAbilityEnabled_test_0600] set enable false data is: ' + JSON.stringify(data));
}).catch((error) => {
console.info('[context_isAbilityEnabled_test_0600] set enable false error is: ' + error);
expect(error).assertFail();
})
var timeOldStamp = await Utils.getNowTime(); /*
let mData; * @tc.number: context_isAbilityEnabled_test_0500
await Bundle.isAbilityEnabled(ABILITY) * @tc.name: isAbilityEnabled : Get whether to enable a specified ability
.then((data) => { * @tc.desc: Check the return value of the interface (by promise)
var timeNewStamp = Utils.getNowTime(); * @tc.level 0
Utils.getDurationTime('[context_isAbilityEnabled_test_0600]', timeOldStamp, timeNewStamp); */
mData = data; it('context_isAbilityEnabled_test_0500', 0, async function (done) {
console.info('[context_isAbilityEnabled_test_0600] promise data is: ' + JSON.stringify(data)); await Bundle.setAbilityEnabled(ABILITY, true).then((data) => {
}) console.info('[context_isAbilityEnabled_test_0500] set enable true data is: ' + JSON.stringify(data));
.catch((error) => { }).catch((error) => {
console.info('[context_isAbilityEnabled_test_0600] promise error is: ' + error); console.info('[context_isAbilityEnabled_test_0500] set enable true error is: ' + error);
expect(error).assertFail(); expect(error).assertFail();
})
let timeOldStamp = await Utils.getNowTime();
let mData;
await Bundle.isAbilityEnabled(ABILITY).then((data) => {
let timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_isAbilityEnabled_test_0500]', timeOldStamp, timeNewStamp);
mData = data;
console.info('[context_isAbilityEnabled_test_0500] promise data is: ' + JSON.stringify(data));
}).catch((error) => {
console.info('[context_isAbilityEnabled_test_0500] promise error is: ' + error);
expect(error).assertFail();
});
getAbilityEnabledTrue('[context_isAbilityEnabled_test_0500]', mData);
done();
}); });
getAbilityEnabledFalse('[context_isAbilityEnabled_test_0600]', mData);
done();
});
/* /*
* @tc.number: context_isAbilityEnabled_test_0700 * @tc.number: context_isAbilityEnabled_test_0600
* @tc.name: isAbilityEnabled : Get whether to enable a specified ability * @tc.name: isAbilityEnabled : Get whether to enable a specified ability
* @tc.desc: Check the return value of the interface (by callback) * @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0 * @tc.level 0
*/ */
it('context_isAbilityEnabled_test_0700', 0, async function (done) { it('context_isAbilityEnabled_test_0600', 0, async function (done) {
await Bundle.setAbilityEnabled(ABILITY, true) await Bundle.setAbilityEnabled(ABILITY, false).then((data) => {
.then((data) => { console.info('[context_isAbilityEnabled_test_0600] set enable false data is: ' + JSON.stringify(data));
console.info('[context_isAbilityEnabled_test_0700] set enable true data is: ' + JSON.stringify(data)); }).catch((error) => {
}).catch((error) => { console.info('[context_isAbilityEnabled_test_0600] set enable false error is: ' + error);
console.info('[context_isAbilityEnabled_test_0700] set enable true error is: ' + error); expect(error).assertFail();
expect(error).assertFail(); })
}) let timeOldStamp = await Utils.getNowTime();
let mData;
await Bundle.isAbilityEnabled(ABILITY).then((data) => {
let timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_isAbilityEnabled_test_0600]', timeOldStamp, timeNewStamp);
mData = data;
console.info('[context_isAbilityEnabled_test_0600] promise data is: ' + JSON.stringify(data));
}).catch((error) => {
console.info('[context_isAbilityEnabled_test_0600] promise error is: ' + error);
expect(error).assertFail();
});
getAbilityEnabledFalse('[context_isAbilityEnabled_test_0600]', mData);
done();
});
var timeOldStamp = await Utils.getNowTime(); /*
let mData; * @tc.number: context_isAbilityEnabled_test_0700
Bundle.isAbilityEnabled(ABILITY, (error, data) => { * @tc.name: isAbilityEnabled : Get whether to enable a specified ability
if(error){ * @tc.desc: Check the return value of the interface (by callback)
console.error('[context_isAbilityEnabled_test_0700]Operation failed. Cause: ' + JSON.stringify(error)); * @tc.level 0
expect(error).assertFail(); */
} it('context_isAbilityEnabled_test_0700', 0, async function (done) {
var timeNewStamp = Utils.getNowTime(); await Bundle.setAbilityEnabled(ABILITY, true).then((data) => {
Utils.getDurationTime('[context_isAbilityEnabled_test_0700]', timeOldStamp, timeNewStamp); console.info('[context_isAbilityEnabled_test_0700] set enable true data is: ' + JSON.stringify(data));
mData = data; }).catch((error) => {
console.info('[context_isAbilityEnabled_test_0700] callBack error: ' + error); console.info('[context_isAbilityEnabled_test_0700] set enable true error is: ' + error);
console.info('[context_isAbilityEnabled_test_0700] callBack data is:' + JSON.stringify(data)); expect(error).assertFail();
}); })
await Utils.sleep(2000); let timeOldStamp = await Utils.getNowTime();
getAbilityEnabledTrue('[context_isAbilityEnabled_test_0700]', mData); let mData;
done(); Bundle.isAbilityEnabled(ABILITY, (error, data) => {
}); if (error) {
console.error('[context_isAbilityEnabled_test_0700]Operation failed. Cause: ' + JSON.stringify(error));
expect(error).assertFail();
}
let timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_isAbilityEnabled_test_0700]', timeOldStamp, timeNewStamp);
mData = data;
console.info('[context_isAbilityEnabled_test_0700] callBack error: ' + error);
console.info('[context_isAbilityEnabled_test_0700] callBack data is:' + JSON.stringify(data));
});
await Utils.sleep(2000);
getAbilityEnabledTrue('[context_isAbilityEnabled_test_0700]', mData);
done();
});
/* /*
* @tc.number: context_isAbilityEnabled_test_0800 * @tc.number: context_isAbilityEnabled_test_0800
* @tc.name: isAbilityEnabled : Get whether to enable a specified ability * @tc.name: isAbilityEnabled : Get whether to enable a specified ability
* @tc.desc: Check the return value of the interface (by callback) * @tc.desc: Check the return value of the interface (by callback)
* @tc.level 0 * @tc.level 0
*/ */
it('context_isAbilityEnabled_test_0800', 0, async function (done) { it('context_isAbilityEnabled_test_0800', 0, async function (done) {
await Bundle.setAbilityEnabled(ABILITY, false) await Bundle.setAbilityEnabled(ABILITY, false).then((data) => {
.then((data) => { console.info('[context_isAbilityEnabled_test_0800] set enable false data is: ' + JSON.stringify(data));
console.info('[context_isAbilityEnabled_test_0800] set enable false data is: ' + JSON.stringify(data)); }).catch((error) => {
}).catch((error) => { console.info('[context_isAbilityEnabled_test_0800] set enable false error is: ' + error);
console.info('[context_isAbilityEnabled_test_0800] set enable false error is: ' + error); expect(error).assertFail();
expect(error).assertFail(); })
}) let timeOldStamp = await Utils.getNowTime();
let mData;
Bundle.isAbilityEnabled(ABILITY, (error, data) => {
if (error) {
console.error('[context_isAbilityEnabled_test_0800]Operation failed. Cause: ' + JSON.stringify(error));
expect(error).assertFail();
}
let timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_isAbilityEnabled_test_0800]', timeOldStamp, timeNewStamp);
mData = data;
console.info('[context_isAbilityEnabled_test_0800] callBack error: ' + error);
console.info('[context_isAbilityEnabled_test_0800] callBack data is:' + JSON.stringify(data));
});
await Utils.sleep(2000);
getAbilityEnabledFalse('[context_isAbilityEnabled_test_0800]', mData);
done();
});
var timeOldStamp = await Utils.getNowTime(); function getAbilityEnabledSuccess(msg, data) {
let mData; console.log(msg + ' start ' + JSON.stringify(data));
Bundle.isAbilityEnabled(ABILITY, (error, data) => { console.log(msg + ' data : ' + data);
if(error){ expect(typeof (data)).assertEqual('boolean')
console.error('[context_isAbilityEnabled_test_0800]Operation failed. Cause: ' + JSON.stringify(error));
expect(error).assertFail();
} }
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_isAbilityEnabled_test_0800]', timeOldStamp, timeNewStamp);
mData = data;
console.info('[context_isAbilityEnabled_test_0800] callBack error: ' + error);
console.info('[context_isAbilityEnabled_test_0800] callBack data is:' + JSON.stringify(data));
});
await Utils.sleep(2000);
getAbilityEnabledFalse('[context_isAbilityEnabled_test_0800]', mData);
done();
});
function getAbilityEnabledTrue(msg, data) {
getAbilityEnabledSuccess(msg, data);
expect(data).assertEqual(true);
}
function getAbilityEnabledSuccess(msg, data) { function getAbilityEnabledFalse(msg, data) {
console.log(msg + ' start ' + JSON.stringify(data)); getAbilityEnabledSuccess(msg, data);
console.log(msg + ' data : ' + data); expect(data).assertEqual(false);
expect(typeof (data)).assertEqual('boolean') }
}
function getAbilityEnabledTrue(msg, data) {
getAbilityEnabledSuccess(msg, data);
expect(data).assertEqual(true);
}
function getAbilityEnabledFalse(msg, data) { })
getAbilityEnabledSuccess(msg, data);
expect(data).assertEqual(false);
}
})
} }
\ No newline at end of file
...@@ -12,197 +12,191 @@ ...@@ -12,197 +12,191 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import {describe, it, expect} from 'deccjsunit/index.ets'; import { describe, it, expect } from 'deccjsunit/index.ets';
import Utils from './Utils'; import Utils from './Utils';
import Bundle from '@ohos.bundle'; import Bundle from '@ohos.bundle';
const BUNDLE_NAME = 'com.open.harmony.packagemag' const BUNDLE_NAME = 'com.open.harmony.packagemag'
const BUNDLE_NAME_ERROR = 'com.ohos.acepackage.error' const BUNDLE_NAME_ERROR = 'com.ohos.acepackage.error'
export default function IsApplicationEnabledETSUnit() { export default function IsApplicationEnabledETSUnit() {
describe('context_isApplicationEnabled_test', function () {
/*
* @tc.number: context_isApplicationEnabled_test_0100
* @tc.name: isApplicationEnabled : Get whether to enable a specified application
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it('context_isApplicationEnabled_test_0100', 0, async function (done) {
var timeOldStamp = await Utils.getNowTime();
let mData;
await Bundle.isApplicationEnabled(BUNDLE_NAME)
.then((data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_isApplicationEnabled_test_0100]', timeOldStamp, timeNewStamp);
mData = data;
console.info('[context_isApplicationEnabled_test_0100] promise data is: ' + JSON.stringify(data));
})
.catch((error) => {
console.info('[context_isApplicationEnabled_test_0100] promise error is: ' + error);
expect(error).assertFail();
});
getApplicationEnabledSuccess('[context_isApplicationEnabled_test_0100]', mData);
done();
});
/* describe('context_isApplicationEnabled_test', function () {
* @tc.number: context_isApplicationEnabled_test_0200
* @tc.name: isApplicationEnabled : Get whether to enable a specified application
* @tc.desc: Check the return value of the interface (by callback)
* @tc.level 0
*/
it('context_isApplicationEnabled_test_0200', 0, async function (done) {
var timeOldStamp = await Utils.getNowTime();
let mData;
Bundle.isApplicationEnabled(BUNDLE_NAME, (error, data) => {
if(error){
console.error('[context_isApplicationEnabled_test_0200]Operation failed. Cause: ' + JSON.stringify(error));
expect(error).assertFail();
}
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_isApplicationEnabled_test_0200]', timeOldStamp, timeNewStamp);
mData = data;
console.info('[context_isApplicationEnabled_test_0200] callBack error: ' + error);
console.info('[context_isApplicationEnabled_test_0200] callBack data is:' + JSON.stringify(data));
});
await Utils.sleep(2000);
getApplicationEnabledSuccess('[context_isApplicationEnabled_test_0200]', mData);
done();
});
/* /*
* @tc.number: context_isApplicationEnabled_test_0300 * @tc.number: context_isApplicationEnabled_test_0100
* @tc.name: isApplicationEnabled : Get whether to enable a specified application * @tc.name: isApplicationEnabled : Get whether to enable a specified application
* @tc.desc: Check the return value of the interface (by promise) * @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0 * @tc.level 0
*/ */
it('context_isApplicationEnabled_test_0300', 0, async function (done) { it('context_isApplicationEnabled_test_0100', 0, async function (done) {
var timeOldStamp = await Utils.getNowTime(); let timeOldStamp = await Utils.getNowTime();
let mData; let mData;
await Bundle.isApplicationEnabled(BUNDLE_NAME_ERROR) await Bundle.isApplicationEnabled(BUNDLE_NAME).then((data) => {
.then((data) => { let timeNewStamp = Utils.getNowTime();
var timeNewStamp = Utils.getNowTime(); Utils.getDurationTime('[context_isApplicationEnabled_test_0100]', timeOldStamp, timeNewStamp);
Utils.getDurationTime('[context_isApplicationEnabled_test_0300]', timeOldStamp, timeNewStamp); mData = data;
mData = data; console.info('[context_isApplicationEnabled_test_0100] promise data is: ' + JSON.stringify(data));
console.info('[context_isApplicationEnabled_test_0300] promise data is: ' + JSON.stringify(data)); }).catch((error) => {
}) console.info('[context_isApplicationEnabled_test_0100] promise error is: ' + error);
.catch((error) => { expect(error).assertFail();
var timeNewStamp = Utils.getNowTime(); });
Utils.getDurationTime('[context_isApplicationEnabled_test_0300]', timeOldStamp, timeNewStamp); getApplicationEnabledSuccess('[context_isApplicationEnabled_test_0100]', mData);
console.info('[context_isApplicationEnabled_test_0300] promise error is: ' + error); done();
expect(error).assertFail();
}); });
getApplicationEnabledFalse('[context_isApplicationEnabled_test_0300]', mData);
done();
});
/* /*
* @tc.number: context_isApplicationEnabled_test_0400 * @tc.number: context_isApplicationEnabled_test_0200
* @tc.name: isApplicationEnabled : Get whether to enable a specified application * @tc.name: isApplicationEnabled : Get whether to enable a specified application
* @tc.desc: Check the return value of the interface (by callback) * @tc.desc: Check the return value of the interface (by callback)
* @tc.level 0 * @tc.level 0
*/ */
it('context_isApplicationEnabled_test_0400', 0, async function (done) { it('context_isApplicationEnabled_test_0200', 0, async function (done) {
var timeOldStamp = await Utils.getNowTime(); let timeOldStamp = await Utils.getNowTime();
let mData; let mData;
Bundle.isApplicationEnabled(BUNDLE_NAME_ERROR, (error, data) => { Bundle.isApplicationEnabled(BUNDLE_NAME, (error, data) => {
if(error){ if (error) {
console.error('[context_isApplicationEnabled_test_0400]Operation failed. Cause: ' + JSON.stringify(error)); console.error('[context_isApplicationEnabled_test_0200]Operation failed. Cause: ' + JSON.stringify(error));
expect(error).assertFail(); expect(error).assertFail();
} }
var timeNewStamp = Utils.getNowTime(); let timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_isApplicationEnabled_test_0400]', timeOldStamp, timeNewStamp); Utils.getDurationTime('[context_isApplicationEnabled_test_0200]', timeOldStamp, timeNewStamp);
mData = data; mData = data;
console.info('[context_isApplicationEnabled_test_0400] callBack error: ' + error); console.info('[context_isApplicationEnabled_test_0200] callBack error: ' + error);
console.info('[context_isApplicationEnabled_test_0400] callBack data is:' + JSON.stringify(data)); console.info('[context_isApplicationEnabled_test_0200] callBack data is:' + JSON.stringify(data));
}); });
await Utils.sleep(2000); await Utils.sleep(2000);
getApplicationEnabledFalse('[context_isApplicationEnabled_test_0300]', mData); getApplicationEnabledSuccess('[context_isApplicationEnabled_test_0200]', mData);
console.info('[context_isApplicationEnabled_test_0400] Failure '); done();
done(); });
});
/* /*
* @tc.number: context_isApplicationEnabled_test_0500 * @tc.number: context_isApplicationEnabled_test_0300
* @tc.name: isApplicationEnabled : Get whether to enable a specified application * @tc.name: isApplicationEnabled : Get whether to enable a specified application
* @tc.desc: Check the return value of the interface (by promise) * @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0 * @tc.level 0
*/ */
it('context_isApplicationEnabled_test_0500', 0, async function (done) { it('context_isApplicationEnabled_test_0300', 0, async function (done) {
await Bundle.setApplicationEnabled(BUNDLE_NAME, true) let timeOldStamp = await Utils.getNowTime();
.then((data) => { let mData;
console.info('[context_isApplicationEnabled_test_0500] set enable true data is: ' + JSON.stringify(data)); await Bundle.isApplicationEnabled(BUNDLE_NAME_ERROR).then((data) => {
}).catch((error) => { let timeNewStamp = Utils.getNowTime();
console.info('[context_isApplicationEnabled_test_0500] set enable true error is: ' + error); Utils.getDurationTime('[context_isApplicationEnabled_test_0300]', timeOldStamp, timeNewStamp);
expect(error).assertFail(); mData = data;
console.info('[context_isApplicationEnabled_test_0300] promise data is: ' + JSON.stringify(data));
}).catch((error) => {
let timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_isApplicationEnabled_test_0300]', timeOldStamp, timeNewStamp);
console.info('[context_isApplicationEnabled_test_0300] promise error is: ' + error);
expect(error).assertFail();
});
getApplicationEnabledFalse('[context_isApplicationEnabled_test_0300]', mData);
done();
}); });
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime(); /*
let mData; * @tc.number: context_isApplicationEnabled_test_0400
await Bundle.isApplicationEnabled(BUNDLE_NAME) * @tc.name: isApplicationEnabled : Get whether to enable a specified application
.then((data) => { * @tc.desc: Check the return value of the interface (by callback)
var timeNewStamp = Utils.getNowTime(); * @tc.level 0
Utils.getDurationTime('[context_isApplicationEnabled_test_0500]', timeOldStamp, timeNewStamp); */
mData = data; it('context_isApplicationEnabled_test_0400', 0, async function (done) {
console.info('[context_isApplicationEnabled_test_0500] promise data is: ' + JSON.stringify(data)); let timeOldStamp = await Utils.getNowTime();
}) let mData;
.catch((error) => { Bundle.isApplicationEnabled(BUNDLE_NAME_ERROR, (error, data) => {
console.info('[context_isApplicationEnabled_test_0500] promise error is: ' + error); if (error) {
expect(error).assertFail(); console.error('[context_isApplicationEnabled_test_0400]Operation failed. Cause: ' + JSON.stringify(error));
expect(error).assertFail();
}
let timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_isApplicationEnabled_test_0400]', timeOldStamp, timeNewStamp);
mData = data;
console.info('[context_isApplicationEnabled_test_0400] callBack error: ' + error);
console.info('[context_isApplicationEnabled_test_0400] callBack data is:' + JSON.stringify(data));
});
await Utils.sleep(2000);
getApplicationEnabledFalse('[context_isApplicationEnabled_test_0300]', mData);
console.info('[context_isApplicationEnabled_test_0400] Failure ');
done();
}); });
getApplicationEnabledTrue('[context_isApplicationEnabled_test_0500]', mData);
done();
});
/* /*
* @tc.number: context_isApplicationEnabled_test_0600 * @tc.number: context_isApplicationEnabled_test_0500
* @tc.name: isApplicationEnabled : Get whether to enable a specified application * @tc.name: isApplicationEnabled : Get whether to enable a specified application
* @tc.desc: Check the return value of the interface (by callback) * @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0 * @tc.level 0
*/ */
it('context_isApplicationEnabled_test_0600', 0, async function (done) { it('context_isApplicationEnabled_test_0500', 0, async function (done) {
await Bundle.setApplicationEnabled(BUNDLE_NAME, false) await Bundle.setApplicationEnabled(BUNDLE_NAME, true).then((data) => {
.then((data) => { console.info('[context_isApplicationEnabled_test_0500] set enable true data is: ' + JSON.stringify(data));
console.info('[context_isApplicationEnabled_test_0600] set enable false data is: ' + JSON.stringify(data)); }).catch((error) => {
}).catch((error) => { console.info('[context_isApplicationEnabled_test_0500] set enable true error is: ' + error);
console.info('[context_isApplicationEnabled_test_0600] set enable false error is: ' + error); expect(error).assertFail();
expect(error).assertFail(); });
await Utils.sleep(1000);
let timeOldStamp = await Utils.getNowTime();
let mData;
await Bundle.isApplicationEnabled(BUNDLE_NAME).then((data) => {
let timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_isApplicationEnabled_test_0500]', timeOldStamp, timeNewStamp);
mData = data;
console.info('[context_isApplicationEnabled_test_0500] promise data is: ' + JSON.stringify(data));
}).catch((error) => {
console.info('[context_isApplicationEnabled_test_0500] promise error is: ' + error);
expect(error).assertFail();
});
getApplicationEnabledTrue('[context_isApplicationEnabled_test_0500]', mData);
done();
}); });
await Utils.sleep(1000); /*
var timeOldStamp = await Utils.getNowTime(); * @tc.number: context_isApplicationEnabled_test_0600
let mData; * @tc.name: isApplicationEnabled : Get whether to enable a specified application
Bundle.isApplicationEnabled(BUNDLE_NAME, (error, data) => { * @tc.desc: Check the return value of the interface (by callback)
if(error){ * @tc.level 0
console.error('[context_isApplicationEnabled_test_0600]Operation failed. Cause: ' + JSON.stringify(error)); */
expect(error).assertFail(); it('context_isApplicationEnabled_test_0600', 0, async function (done) {
await Bundle.setApplicationEnabled(BUNDLE_NAME, false).then((data) => {
console.info('[context_isApplicationEnabled_test_0600] set enable false data is: ' + JSON.stringify(data));
}).catch((error) => {
console.info('[context_isApplicationEnabled_test_0600] set enable false error is: ' + error);
expect(error).assertFail();
});
await Utils.sleep(1000);
let timeOldStamp = await Utils.getNowTime();
let mData;
Bundle.isApplicationEnabled(BUNDLE_NAME, (error, data) => {
if (error) {
console.error('[context_isApplicationEnabled_test_0600]Operation failed. Cause: ' + JSON.stringify(error));
expect(error).assertFail();
}
let timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_isApplicationEnabled_test_0600]', timeOldStamp, timeNewStamp);
mData = data;
console.info('[context_isApplicationEnabled_test_0600] callBack error: ' + error);
console.info('[context_isApplicationEnabled_test_0600] callBack data is:' + JSON.stringify(data));
});
await Utils.sleep(2000);
getApplicationEnabledFalse('[context_isApplicationEnabled_test_0600]', mData);
done();
});
function getApplicationEnabledSuccess(msg, data) {
console.log(msg + ' start ' + JSON.stringify(data));
console.log(msg + ' data : ' + data);
expect(typeof (data)).assertEqual('boolean')
} }
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_isApplicationEnabled_test_0600]', timeOldStamp, timeNewStamp);
mData = data;
console.info('[context_isApplicationEnabled_test_0600] callBack error: ' + error);
console.info('[context_isApplicationEnabled_test_0600] callBack data is:' + JSON.stringify(data));
});
await Utils.sleep(2000);
getApplicationEnabledFalse('[context_isApplicationEnabled_test_0600]', mData);
done();
});
function getApplicationEnabledSuccess(msg, data) { function getApplicationEnabledTrue(msg, data) {
console.log(msg + ' start ' + JSON.stringify(data)); getApplicationEnabledSuccess(msg, data);
console.log(msg + ' data : ' + data); expect(data).assertEqual(true);
expect(typeof (data)).assertEqual('boolean') }
}
function getApplicationEnabledFalse(msg, data) {
getApplicationEnabledSuccess(msg, data);
expect(data).assertEqual(false);
}
function getApplicationEnabledTrue(msg, data) { })
getApplicationEnabledSuccess(msg, data);
expect(data).assertEqual(true);
}
function getApplicationEnabledFalse(msg, data) {
getApplicationEnabledSuccess(msg, data);
expect(data).assertEqual(false);
}
})
} }
\ No newline at end of file
...@@ -12,14 +12,20 @@ ...@@ -12,14 +12,20 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import getLaunchWantForBundle from './GetLaunchWantForBundle.test.ets';
import getabilityInfo from './GetabilityInfo.test.ets'; import getabilityInfo from './GetabilityInfo.test.ets';
import getApplicationInfoJsunit from './getApplicationInfoJsunit.test.ets'; import getApplicationInfoJsunit from './getApplicationInfoJsunit.test.ets';
import getAllAppInfoJsunit from './getAllApplicationInfoJsunit.test.ets'; import getAllAppInfoJsunit from './getAllApplicationInfoJsunit.test.ets';
import getAbilityLabelJsUnit from "./GetAbilityLabelJsUnit.test.ets"; import getAbilityLabelJsUnit from "./GetAbilityLabelJsUnit.test.ets";
import isAbilityEnableETSUnit from "./IsAbilityEnabledETSUnit.ets"; import isAbilityEnableETSUnit from "./IsAbilityEnabledETSUnit.ets";
import isApplicationEnabledETSUnit from "./IsApplicationEnabledETSUnit.ets"; import isApplicationEnabledETSUnit from "./IsApplicationEnabledETSUnit.ets";
import getAbilityIcon from "./GetAbilityIcon.test.ets";
import getNameForUid from "./GetNameForUid.test.ets";
export default function testsuite() { export default function testsuite() {
getAbilityIcon();
getLaunchWantForBundle();
getNameForUid();
//RM.007 //RM.007
getApplicationInfoJsunit(); getApplicationInfoJsunit();
getAllAppInfoJsunit(); getAllAppInfoJsunit();
......
...@@ -15,114 +15,115 @@ ...@@ -15,114 +15,115 @@
*/ */
export default class Utils { export default class Utils {
static rect_left; static rect_left;
static rect_top; static rect_top;
static rect_right; static rect_right;
static rect_bottom; static rect_bottom;
static rect_value; static rect_value;
static sleep(time) { static sleep(time) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
setTimeout(() => { setTimeout(() => {
resolve() resolve()
}, time) }, time)
}).then(() => { }).then(() => {
console.info(`sleep ${time} over...`) console.info(`sleep ${time} over...`)
}) })
}
static getComponentRect(key) {
let strJson = getInspectorByKey(key);
let obj = JSON.parse(strJson);
console.info("[getInspectorByKey] current component obj is: " + JSON.stringify(obj));
let rectInfo = JSON.parse('[' + obj.$rect + ']')
console.info("[getInspectorByKey] rectInfo is: " + rectInfo);
this.rect_left = JSON.parse('[' + rectInfo[0] + ']')[0]
this.rect_top = JSON.parse('[' + rectInfo[0] + ']')[1]
this.rect_right = JSON.parse('[' + rectInfo[1] + ']')[0]
this.rect_bottom = JSON.parse('[' + rectInfo[1] + ']')[1]
return this.rect_value = {
"left": this.rect_left, "top": this.rect_top, "right": this.rect_right, "bottom": this.rect_bottom
} }
}
static async swipe(downX, downY, upX, upY, steps) {
console.info('start to swipe')
this.drags(downX, downY, upX, upY, steps, false)
}
static async drag(downX, downY, upX, upY, steps) {
console.info('start to drag')
this.drags(downX, downY, upX, upY, steps, true)
}
static async drags(downX, downY, upX, upY, steps, drag) { static getComponentRect(key) {
var xStep; let strJson = getInspectorByKey(key);
var yStep; let obj = JSON.parse(strJson);
var swipeSteps; console.info("[getInspectorByKey] current component obj is: " + JSON.stringify(obj));
var ret; let rectInfo = JSON.parse('[' + obj.$rect + ']')
xStep = 0; console.info("[getInspectorByKey] rectInfo is: " + rectInfo);
yStep = 0; this.rect_left = JSON.parse('[' + rectInfo[0] + ']')[0]
ret = false; this.rect_top = JSON.parse('[' + rectInfo[0] + ']')[1]
swipeSteps = steps; this.rect_right = JSON.parse('[' + rectInfo[1] + ']')[0]
if (swipeSteps == 0) { this.rect_bottom = JSON.parse('[' + rectInfo[1] + ']')[1]
swipeSteps = 1; return this.rect_value = {
"left": this.rect_left, "top": this.rect_top, "right": this.rect_right, "bottom": this.rect_bottom
}
} }
xStep = (upX - downX) / swipeSteps;
yStep = (upY - downY) / swipeSteps; static async swipe(downX, downY, upX, upY, steps) {
console.info('move step is: ' + 'xStep: ' + xStep + ' yStep: ' + yStep) console.info('start to swipe')
var downPonit: TouchObject = { this.drags(downX, downY, upX, upY, steps, false)
id: 1,
x: downX,
y: downY,
type: TouchType.Down,
}
console.info('down touch started: ' + JSON.stringify(downPonit))
sendTouchEvent(downPonit);
console.info('start to move')
if (drag) {
await this.sleep(500)
} }
for (var i = 1;i <= swipeSteps; i++) {
var movePoint: TouchObject = { static async drag(downX, downY, upX, upY, steps) {
id: 1, console.info('start to drag')
x: downX + (xStep * i), this.drags(downX, downY, upX, upY, steps, true)
y: downY + (yStep * i),
type: TouchType.Move
}
console.info('move touch started: ' + JSON.stringify(movePoint))
ret = sendTouchEvent(movePoint)
if (ret == false) {
break;
}
await this.sleep(5)
} }
console.info('start to up')
if (drag) { static async drags(downX, downY, upX, upY, steps, drag) {
await this.sleep(100) let xStep;
let yStep;
let swipeSteps;
let ret;
xStep = 0;
yStep = 0;
ret = false;
swipeSteps = steps;
if (swipeSteps == 0) {
swipeSteps = 1;
}
xStep = (upX - downX) / swipeSteps;
yStep = (upY - downY) / swipeSteps;
console.info('move step is: ' + 'xStep: ' + xStep + ' yStep: ' + yStep)
let downPonit: TouchObject = {
id: 1,
x: downX,
y: downY,
type: TouchType.Down,
}
console.info('down touch started: ' + JSON.stringify(downPonit))
sendTouchEvent(downPonit);
console.info('start to move')
if (drag) {
await this.sleep(500)
}
for (let i = 1;i <= swipeSteps; i++) {
let movePoint: TouchObject = {
id: 1,
x: downX + (xStep * i),
y: downY + (yStep * i),
type: TouchType.Move
}
console.info('move touch started: ' + JSON.stringify(movePoint))
ret = sendTouchEvent(movePoint)
if (ret == false) {
break;
}
await this.sleep(5)
}
console.info('start to up')
if (drag) {
await this.sleep(100)
}
let upPoint: TouchObject = {
id: 1,
x: upX,
y: upY,
type: TouchType.Up,
}
console.info('up touch started: ' + JSON.stringify(upPoint))
sendTouchEvent(upPoint)
await this.sleep(500)
} }
var upPoint: TouchObject = {
id: 1, static getNowTime() {
x: upX, return new Date().getTime();
y: upY,
type: TouchType.Up,
} }
console.info('up touch started: ' + JSON.stringify(upPoint))
sendTouchEvent(upPoint)
await this.sleep(500)
}
static getNowTime() { static getDurationTime(log,startTime, endTime) {
return new Date().getTime(); console.info("Get Interface startTime: " + startTime);
} console.info("Get Interface endTime: " + endTime);
let duration = (endTime - startTime);
console.info("Get Interface duration: " + duration);
return duration;
}
static getDurationTime(log,startTime, endTime) {
console.info("Get Interface startTime: " + startTime);
console.info("Get Interface endTime: " + endTime);
var duration = (endTime - startTime);
console.info("Get Interface duration: " + duration);
return duration;
}
} }
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import {describe, it, expect} from 'deccjsunit/index.ets'; import { describe, it, expect } from 'deccjsunit/index.ets';
import Utils from './Utils'; import Utils from './Utils';
import Bundle from '@ohos.bundle'; import Bundle from '@ohos.bundle';
...@@ -29,315 +29,303 @@ const TAG_TEST_0500_002 = ' bundle_getAllApplicationInfo_test_0500_0010 '; ...@@ -29,315 +29,303 @@ const TAG_TEST_0500_002 = ' bundle_getAllApplicationInfo_test_0500_0010 ';
const USER_ID_100 = 100; const USER_ID_100 = 100;
export default function applicationBundleJsunit() { export default function applicationBundleJsunit() {
describe('appInfoTest', function () {
/** describe('appInfoTest', function () {
* @tc.number: bundle_getApplicationInfo_test_0100_001
* @tc.name: getApplicationInfo : Obtains based on a given bundle name. /**
* @tc.desc: Check the return value of the interface (by promise) * @tc.number: bundle_getApplicationInfo_test_0100_001
* @tc.level 0 * @tc.name: getApplicationInfo : Obtains based on a given bundle name.
*/ * @tc.desc: Check the return value of the interface (by promise)
it(TAG_TEST_0100_001, 0, async function (done) { * @tc.level 0
var startTime = await Utils.getNowTime(); */
let data = await Bundle.getAllApplicationInfo(Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, USER_ID_100) it(TAG_TEST_0100_001, 0, async function (done) {
.catch((error) => { let startTime = await Utils.getNowTime();
console.info(TAG_TEST_0100_001 + 'UserId promise error is: ' + error); let data = await Bundle.getAllApplicationInfo(
expect(error).assertFail(); Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, USER_ID_100).catch((error) => {
console.info(TAG_TEST_0100_001 + 'UserId promise error is: ' + error);
expect(error).assertFail();
});
let endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0100_001, startTime, endTime);
console.info(TAG_TEST_0100_001 + ' UserId promise data is: ' + JSON.stringify(data));
expectData(TAG_TEST_0100_001, data)
getApplicationInfoSuccess(TAG_TEST_0100_001, data);
done();
}); });
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0100_001, startTime, endTime);
console.info(TAG_TEST_0100_001 + ' UserId promise data is: ' + JSON.stringify(data));
expectData(TAG_TEST_0100_001, data)
getApplicationInfoSuccess(TAG_TEST_0100_001, data);
done();
});
/** /**
* @tc.number: bundle_getApplicationInfo_test_0100_002 * @tc.number: bundle_getApplicationInfo_test_0100_002
* @tc.name: getApplicationInfo : Obtains based on a given bundle name. * @tc.name: getApplicationInfo : Obtains based on a given bundle name.
* @tc.desc: Check the return value of the interface (by promise) * @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0 * @tc.level 0
*/ */
it(TAG_TEST_0100_002, 0, async function (done) { it(TAG_TEST_0100_002, 0, async function (done) {
var startTime = await Utils.getNowTime(); let startTime = await Utils.getNowTime();
let data = await Bundle.getAllApplicationInfo(Bundle.BundleFlag.GET_ALL_APPLICATION_INFO, USER_ID_100) let data = await Bundle.getAllApplicationInfo(
.catch((error) => { Bundle.BundleFlag.GET_ALL_APPLICATION_INFO, USER_ID_100).catch((error) => {
console.info(TAG_TEST_0100_002 + 'UserId promise error is: ' + error); console.info(TAG_TEST_0100_002 + 'UserId promise error is: ' + error);
expect(error).assertFail(); expect(error).assertFail();
});
let endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0100_002, startTime, endTime);
console.info(TAG_TEST_0100_002 + ' UserId promise data is: ' + JSON.stringify(data));
expectData(TAG_TEST_0100_002, data)
getApplicationInfoSuccess(TAG_TEST_0100_002, data);
done();
}); });
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0100_002, startTime, endTime);
console.info(TAG_TEST_0100_002 + ' UserId promise data is: ' + JSON.stringify(data));
expectData(TAG_TEST_0100_002, data)
getApplicationInfoSuccess(TAG_TEST_0100_002, data);
done();
});
/** /**
* @tc.number: bundle_getApplicationInfo_test_0100_003 * @tc.number: bundle_getApplicationInfo_test_0100_003
* @tc.name: getApplicationInfo : Obtains based on a given bundle name. * @tc.name: getApplicationInfo : Obtains based on a given bundle name.
* @tc.desc: Check the return value of the interface (by promise) * @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0 * @tc.level 0
*/ */
it(TAG_TEST_0100_003, 0, async function (done) { it(TAG_TEST_0100_003, 0, async function (done) {
var startTime = await Utils.getNowTime(); let startTime = await Utils.getNowTime();
let data = await Bundle.getAllApplicationInfo(Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_DISABLE, USER_ID_100) let data = await Bundle.getAllApplicationInfo(
.catch((error) => { Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_DISABLE, USER_ID_100).catch((error) => {
console.info(TAG_TEST_0100_003 + 'UserId promise error is: ' + error); console.info(TAG_TEST_0100_003 + 'UserId promise error is: ' + error);
expect(error).assertFail(); expect(error).assertFail();
});
let endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0100_003, startTime, endTime);
console.info(TAG_TEST_0100_003 + ' UserId promise data is: ' + JSON.stringify(data));
expectData(TAG_TEST_0100_003, data)
getApplicationInfoSuccess(TAG_TEST_0100_003, data);
done();
}); });
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0100_003, startTime, endTime);
console.info(TAG_TEST_0100_003 + ' UserId promise data is: ' + JSON.stringify(data));
expectData(TAG_TEST_0100_003, data)
getApplicationInfoSuccess(TAG_TEST_0100_003, data);
done();
});
/** /**
* @tc.number: bundle_getApplicationInfo_test_0200_004 * @tc.number: bundle_getApplicationInfo_test_0200_004
* @tc.name: getApplicationInfo : Obtains based on a given bundle name. * @tc.name: getApplicationInfo : Obtains based on a given bundle name.
* @tc.desc: Check the return value of the interface (by promise) * @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0 * @tc.level 0
*/ */
it(TAG_TEST_0200_001, 0, async function (done) { it(TAG_TEST_0200_001, 0, async function (done) {
var startTime = await Utils.getNowTime(); let startTime = await Utils.getNowTime();
let data = await Bundle.getAllApplicationInfo(Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION) let data = await Bundle.getAllApplicationInfo(
.catch((error) => { Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION).catch((error) => {
console.info(TAG_TEST_0200_001 + 'onUserId promise error is: ' + error); console.info(TAG_TEST_0200_001 + 'onUserId promise error is: ' + error);
expect(error).assertFail(); expect(error).assertFail();
});
let endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0200_001, startTime, endTime);
console.info(TAG_TEST_0200_001 + ' onUserId promise data is: ' + JSON.stringify(data));
expectData(TAG_TEST_0200_001, data)
getApplicationInfoSuccess(TAG_TEST_0200_001, data);
done();
}); });
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0200_001, startTime, endTime);
console.info(TAG_TEST_0200_001 + ' onUserId promise data is: ' + JSON.stringify(data));
expectData(TAG_TEST_0200_001, data)
getApplicationInfoSuccess(TAG_TEST_0200_001, data);
done();
});
/** /**
* @tc.number: bundle_getApplicationInfo_test_0200_005 * @tc.number: bundle_getApplicationInfo_test_0200_005
* @tc.name: getApplicationInfo : Obtains based on a given bundle name. * @tc.name: getApplicationInfo : Obtains based on a given bundle name.
* @tc.desc: Check the return value of the interface (by promise) * @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0 * @tc.level 0
*/ */
it(TAG_TEST_0200_002, 0, async function (done) { it(TAG_TEST_0200_002, 0, async function (done) {
var startTime = await Utils.getNowTime(); let startTime = await Utils.getNowTime();
let data = await Bundle.getAllApplicationInfo(Bundle.BundleFlag.GET_ALL_APPLICATION_INFO) let data = await Bundle.getAllApplicationInfo(
.catch((error) => { Bundle.BundleFlag.GET_ALL_APPLICATION_INFO).catch((error) => {
console.info(TAG_TEST_0200_002 + 'onUserId promise error is: ' + error); console.info(TAG_TEST_0200_002 + 'onUserId promise error is: ' + error);
expect(error).assertFail(); expect(error).assertFail();
});
let endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0200_002, startTime, endTime);
console.info(TAG_TEST_0200_002 + ' onUserId promise data is: ' + JSON.stringify(data));
expectData(TAG_TEST_0200_002, data)
getApplicationInfoSuccess(TAG_TEST_0200_002, data);
done();
}); });
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0200_002, startTime, endTime);
console.info(TAG_TEST_0200_002 + ' onUserId promise data is: ' + JSON.stringify(data));
expectData(TAG_TEST_0200_002, data)
getApplicationInfoSuccess(TAG_TEST_0200_002, data);
done();
});
/** /**
* @tc.number: bundle_getApplicationInfo_test_0200_006 * @tc.number: bundle_getApplicationInfo_test_0200_006
* @tc.name: getApplicationInfo : Obtains based on a given bundle name. * @tc.name: getApplicationInfo : Obtains based on a given bundle name.
* @tc.desc: Check the return value of the interface (by promise) * @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0 * @tc.level 0
*/ */
it(TAG_TEST_0200_003, 0, async function (done) { it(TAG_TEST_0200_003, 0, async function (done) {
var startTime = await Utils.getNowTime(); let startTime = await Utils.getNowTime();
let data = await Bundle.getAllApplicationInfo(Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_DISABLE) let data = await Bundle.getAllApplicationInfo(
.catch((error) => { Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_DISABLE).catch((error) => {
console.info(TAG_TEST_0200_003 + 'onUserId promise error is: ' + error); console.info(TAG_TEST_0200_003 + 'onUserId promise error is: ' + error);
expect(error).assertFail(); expect(error).assertFail();
});
let endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0200_003, startTime, endTime);
console.info(TAG_TEST_0200_003 + ' onUserId promise data is: ' + JSON.stringify(data));
expectData(TAG_TEST_0200_003, data)
getApplicationInfoSuccess(TAG_TEST_0200_003, data);
done();
}); });
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0200_003, startTime, endTime);
console.info(TAG_TEST_0200_003 + ' onUserId promise data is: ' + JSON.stringify(data));
expectData(TAG_TEST_0200_003, data)
getApplicationInfoSuccess(TAG_TEST_0200_003, data);
done();
});
/** /**
* @tc.number: bundle_getApplicationInfo_test_0300_007 * @tc.number: bundle_getApplicationInfo_test_0300_007
* @tc.name: getApplicationInfo : Obtains based on a given bundle name. * @tc.name: getApplicationInfo : Obtains based on a given bundle name.
* @tc.desc: Check the return value of the interface (by callBack) * @tc.desc: Check the return value of the interface (by callBack)
* @tc.level 0 * @tc.level 0
*/ */
it(TAG_TEST_0300_001, 0, async function (done) { it(TAG_TEST_0300_001, 0, async function (done) {
let datas; let datas;
var startTime = await Utils.getNowTime(); let startTime = await Utils.getNowTime();
Bundle.getAllApplicationInfo(Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, USER_ID_100, Bundle.getAllApplicationInfo(
(error, data) => { Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, USER_ID_100, (error, data) => {
var endTime = Utils.getNowTime(); let endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0300_001, startTime, endTime); Utils.getDurationTime(TAG_TEST_0300_001, startTime, endTime);
if(error){ if (error) {
expect(error).assertFail(); expect(error).assertFail();
console.info(TAG_TEST_0300_001 + 'UserId callBack error: ' + error); console.info(TAG_TEST_0300_001 + 'UserId callBack error: ' + error);
} }
console.info(TAG_TEST_0300_001 + 'UserId callBack error: ' + error); console.info(TAG_TEST_0300_001 + 'UserId callBack error: ' + error);
console.info(TAG_TEST_0300_001 + 'UserId callBack data is:' + JSON.stringify(data)); console.info(TAG_TEST_0300_001 + 'UserId callBack data is:' + JSON.stringify(data));
datas = data; datas = data;
});
await Utils.sleep(2000);
console.info(TAG_TEST_0300_001 + 'UserId callBack datas is:' + JSON.stringify(datas));
expectData(TAG_TEST_0300_001, datas)
getApplicationInfoSuccess(TAG_TEST_0300_001, datas);
done();
}); });
await Utils.sleep(2000);
console.info(TAG_TEST_0300_001 + 'UserId callBack datas is:' + JSON.stringify(datas));
expectData(TAG_TEST_0300_001, datas)
getApplicationInfoSuccess(TAG_TEST_0300_001, datas);
done();
});
/** /**
* @tc.number: bundle_getApplicationInfo_test_0400_008 * @tc.number: bundle_getApplicationInfo_test_0400_008
* @tc.name: getApplicationInfo : Obtains based on a given bundle name. * @tc.name: getApplicationInfo : Obtains based on a given bundle name.
* @tc.desc: Check the return value of the interface (by callBack) * @tc.desc: Check the return value of the interface (by callBack)
* @tc.level 0 * @tc.level 0
*/ */
it(TAG_TEST_0400_001, 0, async function (done) { it(TAG_TEST_0400_001, 0, async function (done) {
let datas; let datas;
var startTime = await Utils.getNowTime(); let startTime = await Utils.getNowTime();
Bundle.getAllApplicationInfo(Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, (error, data) => { Bundle.getAllApplicationInfo(Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, (error, data) => {
var endTime = Utils.getNowTime(); let endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0400_001, startTime, endTime); Utils.getDurationTime(TAG_TEST_0400_001, startTime, endTime);
if(error){ if (error) {
expect(error).assertFail(); expect(error).assertFail();
console.info(TAG_TEST_0400_001 + 'UserId callBack error: ' + error); console.info(TAG_TEST_0400_001 + 'UserId callBack error: ' + error);
} }
console.info(TAG_TEST_0400_001 + 'noUserId callBack error: ' + error); console.info(TAG_TEST_0400_001 + 'noUserId callBack error: ' + error);
console.info(TAG_TEST_0400_001 + 'noUserId callBack data is:' + JSON.stringify(data)); console.info(TAG_TEST_0400_001 + 'noUserId callBack data is:' + JSON.stringify(data));
datas = data; datas = data;
}); });
await Utils.sleep(2000); await Utils.sleep(2000);
console.info(TAG_TEST_0400_001 + 'noUserId callBack datas is:' + JSON.stringify(datas)); console.info(TAG_TEST_0400_001 + 'noUserId callBack datas is:' + JSON.stringify(datas));
expectData(TAG_TEST_0400_001, datas) expectData(TAG_TEST_0400_001, datas)
getApplicationInfoSuccess(TAG_TEST_0400_001, datas); getApplicationInfoSuccess(TAG_TEST_0400_001, datas);
done(); done();
});
/**
* @tc.number: bundle_getApplicationInfo_test_0500_009
* @tc.name: getApplicationInfo : Obtains based on a given bundle name.
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it(TAG_TEST_0500_001, 0, async function (done) {
let errors;
var startTime = await Utils.getNowTime();
await Bundle.getAllApplicationInfo('0')
.then((data) => {
console.info(TAG_TEST_0500_001 + 'noUserId promise data is: ' + data);
expect(data).assertFail();
})
.catch((error) => {
console.info(TAG_TEST_0500_001 + 'noUserId promise error is: ' + error);
errors = error;
expect(errors).assertEqual(1);
}); });
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0500_001, startTime, endTime);
done();
});
/** /**
* @tc.number: bundle_getApplicationInfo_test_0500_0010 * @tc.number: bundle_getApplicationInfo_test_0500_009
* @tc.name: getApplicationInfo : Obtains based on a given bundle name. * @tc.name: getApplicationInfo : Obtains based on a given bundle name.
* @tc.desc: Check the return value of the interface (by promise) * @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0 * @tc.level 0
*/ */
it(TAG_TEST_0500_002, 0, async function (done) { it(TAG_TEST_0500_001, 0, async function (done) {
let errors; let errors;
var startTime = await Utils.getNowTime(); let startTime = await Utils.getNowTime();
await Bundle.getAllApplicationInfo('0', USER_ID_100) await Bundle.getAllApplicationInfo('Bundle.BundleFlag.GET_BUNDLE_DEFAULT').then((data) => {
.then((data) => { console.info(TAG_TEST_0500_001 + 'noUserId promise data is: ' + data);
console.info(TAG_TEST_0500_002 + 'noUserId promise data is: ' + data); expect(data).assertFail();
expect(data).assertFail(); }).catch((error) => {
}) console.info(TAG_TEST_0500_001 + 'noUserId promise error is: ' + error);
.catch((error) => { errors = error;
console.info(TAG_TEST_0500_002 + 'UserId promise error is: ' + error); expect(errors).assertEqual(1);
errors = error; });
expect(errors).assertEqual(1); let endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0500_001, startTime, endTime);
done();
}); });
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0500_002, startTime, endTime);
done();
});
/**
* @tc.number: bundle_getApplicationInfo_test_0500_0010
* @tc.name: getApplicationInfo : Obtains based on a given bundle name.
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it(TAG_TEST_0500_002, 0, async function (done) {
let errors;
let startTime = await Utils.getNowTime();
await Bundle.getAllApplicationInfo('Bundle.BundleFlag.GET_BUNDLE_DEFAULT', USER_ID_100).then((data) => {
console.info(TAG_TEST_0500_002 + 'noUserId promise data is: ' + data);
expect(data).assertFail();
}).catch((error) => {
console.info(TAG_TEST_0500_002 + 'UserId promise error is: ' + error);
errors = error;
expect(errors).assertEqual(1);
});
let endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0500_002, startTime, endTime);
done();
});
/** function expectData(msg, data) {
* expect属性 console.info(msg + 'commonTest data length [' + data.length + ']');
* @param msg log信息 for (let i = 0; i < data.length; i++) {
* @param data 数据源 expect(typeof (data)).assertEqual('object');
*/ expect(typeof (data[i].name)).assertEqual('string');
function expectData(msg, data) { expect(typeof (data[i].codePath)).assertEqual('string');
console.info(msg + 'commonTest data length [' + data.length + ']'); expect(typeof (data[i].accessTokenId)).assertEqual('number');
for (var i = 0; i < data.length; i++) { expect(typeof (data[i].description)).assertEqual('string');
expect(typeof (data)).assertEqual('object'); expect(typeof (data[i].descriptionId)).assertEqual('number');
expect(typeof (data[i].name)).assertEqual('string'); expect(typeof (data[i].icon)).assertEqual('string');
expect(typeof (data[i].codePath)).assertEqual('string'); expect(typeof (data[i].iconId)).assertEqual('number');
expect(typeof (data[i].accessTokenId)).assertEqual('number'); expect(typeof (data[i].label)).assertEqual('string');
expect(typeof (data[i].description)).assertEqual('string'); expect(typeof (data[i].labelId)).assertEqual('number');
expect(typeof (data[i].descriptionId)).assertEqual('number'); expect(typeof (data[i].systemApp)).assertEqual('boolean')
expect(typeof (data[i].icon)).assertEqual('string'); expect(typeof (data[i].supportedModes)).assertEqual('number');
expect(typeof (data[i].iconId)).assertEqual('number'); expect(typeof (data[i].process)).assertEqual('string');
expect(typeof (data[i].label)).assertEqual('string'); expect(typeof (data[i].metaData)).assertEqual('object');
expect(typeof (data[i].labelId)).assertEqual('number'); expect(typeof (data[i].metadata)).assertEqual('object');
expect(typeof (data[i].systemApp)).assertEqual('boolean') expect(typeof (data[i].enabled)).assertEqual('boolean');
expect(typeof (data[i].supportedModes)).assertEqual('number'); expect(typeof (data[i].flags)).assertEqual('number');
expect(typeof (data[i].process)).assertEqual('string'); expect(typeof (data[i].uid)).assertEqual('number');
expect(typeof (data[i].entryDir)).assertEqual('string'); expect(typeof (data[i].entityType)).assertEqual('string');
expect(typeof (data[i].metaData)).assertEqual('object'); expect(typeof (data[i].removable)).assertEqual('boolean');
expect(typeof (data[i].metadata)).assertEqual('object'); expect(Array.isArray(data[i].permissions)).assertEqual(true);
expect(typeof (data[i].enabled)).assertEqual('boolean'); expect(Array.isArray(data[i].moduleSourceDirs)).assertEqual(true);
expect(typeof (data[i].flags)).assertEqual('number'); expect(Array.isArray(data[i].moduleInfos)).assertEqual(true);
expect(typeof (data[i].uid)).assertEqual('number'); }
expect(typeof (data[i].entityType)).assertEqual('string'); }
expect(typeof (data[i].removable)).assertEqual('boolean');
expect(Array.isArray(data[i].permissions)).assertEqual(true);
expect(Array.isArray(data[i].moduleSourceDirs)).assertEqual(true);
expect(Array.isArray(data[i].moduleInfos)).assertEqual(true);
}
}
/** function getApplicationInfoSuccess(msg, data) {
* expect指定数据属性值 console.info(msg + 'getApplicationInfoSuccess data length [' + data.length + ']');
* @param msg log信息 for (let i = 0; i < data.length; i++) {
* @param data 数据源 if (data[i].name === 'com.open.harmony.packagemag' || i === 0 && data[i].name === '') {
*/ console.info(msg + JSON.stringify(data[i]));
function getApplicationInfoSuccess(msg, data) { expect(data[i].name).assertEqual('com.open.harmony.packagemag');
console.info(msg + 'getApplicationInfoSuccess data length [' + data.length + ']'); expect(data[i].codePath).assertEqual('/data/app/el1/bundle/public/com.open.harmony.packagemag');
for (var i = 0; i < data.length; i++) { expect(data[i].description).assertEqual('$string:mainability_description');
if (data[i].name === 'com.open.harmony.packagemag' || i === 0 && data[i].name === '') { if (data[i].descriptionId !== 0) {
console.info(msg + JSON.stringify(data[i])); expect(data[i].descriptionId > 0).assertEqual(true);
expect(data[i].name).assertEqual('com.open.harmony.packagemag'); }
expect(data[i].codePath).assertEqual('/data/app/el1/bundle/public/com.open.harmony.packagemag'); expect(data[i].icon).assertEqual('$media:icon');
expect(data[i].description).assertEqual('$string:mainability_description'); expect(data[i].iconId > 0).assertEqual(true);
if (data[i].descriptionId !== 0) { expect(data[i].label).assertEqual('$string:entry_MainAbility');
expect(data[i].descriptionId > 0).assertEqual(true); expect(data[i].accessTokenId > 0).assertEqual(true);
} if (data[i].label !== 0) {
expect(data[i].icon).assertEqual('$media:icon'); expect(data[i].labelId > 0).assertEqual(true);
expect(data[i].iconId > 0).assertEqual(true); };
expect(data[i].label).assertEqual('$string:entry_MainAbility'); if (data[i].uid !== 0) {
expect(data[i].accessTokenId > 0).assertEqual(true); expect(data[i].uid > 0).assertEqual(true);
if (data[i].label !== 0) { };
expect(data[i].labelId > 0).assertEqual(true); expect(data[i].systemApp).assertEqual(true);
}; expect(data[i].supportedModes).assertEqual(0);
if (data[i].uid !== 0) { expect(data[i].process).assertEqual("");
expect(data[i].uid > 0).assertEqual(true); expect(data[i].entryDir).assertEqual('/data/app/el1/bundle/public/com.open.harmony.packagemag' +
}; '/com.open.harmony.packagemag');
expect(data[i].systemApp).assertEqual(true); expect(data[i].enabled).assertEqual(true);
expect(data[i].supportedModes).assertEqual(0); expect(data[i].flags).assertEqual(0);
expect(data[i].process).assertEqual(""); expect(data[i].entityType).assertEqual('unspecified');
expect(data[i].entryDir).assertEqual('/data/app/el1/bundle/public/com.open.harmony.packagemag' + expect(data[i].removable).assertEqual(true);
'/com.open.harmony.packagemag'); expect(data[i].moduleInfos[0].moduleName).assertEqual('entry');
expect(data[i].enabled).assertEqual(true); expect(data[i].moduleInfos[0].moduleSourceDir).assertEqual('/data/app/el1/bundle/public/' +
expect(data[i].flags).assertEqual(0); 'com.open.harmony.packagemag/com.open.harmony.packagemag');
expect(data[i].entityType).assertEqual('unspecified'); expect(data[i].moduleSourceDirs[0]).assertEqual('/data/app/el1/bundle/public/' +
expect(data[i].removable).assertEqual(true); 'com.open.harmony.packagemag/com.open.harmony.packagemag');
expect(data[i].moduleInfos[0].moduleName).assertEqual('entry'); }
expect(data[i].moduleInfos[0].moduleSourceDir).assertEqual('/data/app/el1/bundle/public/' + }
'com.open.harmony.packagemag/com.open.harmony.packagemag');
expect(data[i].moduleSourceDirs[0]).assertEqual('/data/app/el1/bundle/public/' +
'com.open.harmony.packagemag/com.open.harmony.packagemag');
} }
}
} });
});
} }
\ No newline at end of file
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import {describe, it, expect} from 'deccjsunit/index.ets'; import { describe, it, expect } from 'deccjsunit/index.ets';
import Utils from './Utils'; import Utils from './Utils';
import Bundle from '@ohos.bundle'; import Bundle from '@ohos.bundle';
...@@ -33,413 +33,389 @@ const BUNDLE_NAME = 'com.open.harmony.packagemag'; ...@@ -33,413 +33,389 @@ const BUNDLE_NAME = 'com.open.harmony.packagemag';
const BUNDLE_NAME_OTHER = 'com.ohos.acepackage'; const BUNDLE_NAME_OTHER = 'com.ohos.acepackage';
const USER_ID_100 = 100; const USER_ID_100 = 100;
export default function applicationBundleJsunit() { export default function applicationBundleJsunit() {
describe('appInfoTest', function () {
/** describe('appInfoTest', function () {
* @tc.number: bundle_getApplicationInfo_test_0100_001
* @tc.name: getApplicationInfo : Obtains based on a given bundle name. /**
* @tc.desc: Check the return value of the interface (by promise) * @tc.number: bundle_getApplicationInfo_test_0100_001
* @tc.level 0 * @tc.name: getApplicationInfo : Obtains based on a given bundle name.
*/ * @tc.desc: Check the return value of the interface (by promise)
it(TAG_TEST_0100_001, 0, async function (done) { * @tc.level 0
var startTime = await Utils.getNowTime(); */
let data = await Bundle.getApplicationInfo(BUNDLE_NAME, Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, it(TAG_TEST_0100_001, 0, async function (done) {
USER_ID_100) let startTime = await Utils.getNowTime();
.catch((error) => { let data = await Bundle.getApplicationInfo(BUNDLE_NAME,
console.info(TAG_TEST_0100_001 + 'UserId promise error is: ' + error); Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, USER_ID_100).catch((error) => {
expect(error).assertFail(); console.info(TAG_TEST_0100_001 + 'UserId promise error is: ' + error);
expect(error).assertFail();
});
let endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0100_001, startTime, endTime);
console.info(TAG_TEST_0100_001 + ' UserId promise data is: ' + JSON.stringify(data));
expectData(TAG_TEST_0100_001, data);
getApplicationInfoSuccess(TAG_TEST_0100_001, data);
done();
}); });
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0100_001, startTime, endTime);
console.info(TAG_TEST_0100_001 + ' UserId promise data is: ' + JSON.stringify(data));
expectData(TAG_TEST_0100_001, data);
getApplicationInfoSuccess(TAG_TEST_0100_001, data);
done();
});
/** /**
* @tc.number: bundle_getApplicationInfo_test_0100_002 * @tc.number: bundle_getApplicationInfo_test_0100_002
* @tc.name: getApplicationInfo : Obtains based on a given bundle name. * @tc.name: getApplicationInfo : Obtains based on a given bundle name.
* @tc.desc: Check the return value of the interface (by promise) * @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0 * @tc.level 0
*/ */
it(TAG_TEST_0100_002, 0, async function (done) { it(TAG_TEST_0100_002, 0, async function (done) {
var startTime = await Utils.getNowTime(); let startTime = await Utils.getNowTime();
let data = await Bundle.getApplicationInfo(BUNDLE_NAME, Bundle.BundleFlag.GET_ALL_APPLICATION_INFO, USER_ID_100) let data = await Bundle.getApplicationInfo(BUNDLE_NAME,
.catch((error) => { Bundle.BundleFlag.GET_ALL_APPLICATION_INFO, USER_ID_100).catch((error) => {
console.info(TAG_TEST_0100_002 + 'UserId promise error is: ' + error); console.info(TAG_TEST_0100_002 + 'UserId promise error is: ' + error);
expect(error).assertFail(); expect(error).assertFail();
});
let endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0100_002, startTime, endTime);
console.info(TAG_TEST_0100_002 + ' UserId promise data is: ' + JSON.stringify(data));
expectData(TAG_TEST_0100_002, data);
getApplicationInfoSuccess_plus(TAG_TEST_0100_002, data);
done();
}); });
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0100_002, startTime, endTime);
console.info(TAG_TEST_0100_002 + ' UserId promise data is: ' + JSON.stringify(data));
expectData(TAG_TEST_0100_002, data);
getApplicationInfoSuccess_plus(TAG_TEST_0100_002, data);
done();
});
/** /**
* @tc.number: bundle_getApplicationInfo_test_0100_003 * @tc.number: bundle_getApplicationInfo_test_0100_003
* @tc.name: getApplicationInfo : Obtains based on a given bundle name. * @tc.name: getApplicationInfo : Obtains based on a given bundle name.
* @tc.desc: Check the return value of the interface (by promise) * @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0 * @tc.level 0
*/ */
it(TAG_TEST_0100_003, 0, async function (done) { it(TAG_TEST_0100_003, 0, async function (done) {
var startTime = await Utils.getNowTime(); let startTime = await Utils.getNowTime();
let data = await Bundle.getApplicationInfo(BUNDLE_NAME, Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_DISABLE, let data = await Bundle.getApplicationInfo(BUNDLE_NAME,
USER_ID_100) Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_DISABLE, USER_ID_100).catch((error) => {
.catch((error) => { console.info(TAG_TEST_0100_003 + 'UserId promise error is: ' + error);
console.info(TAG_TEST_0100_003 + 'UserId promise error is: ' + error); expect(error).assertFail();
expect(error).assertFail(); });
let endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0100_003, startTime, endTime);
console.info(TAG_TEST_0100_003 + ' UserId promise data is: ' + JSON.stringify(data));
expectData(TAG_TEST_0100_003, data);
getApplicationInfoSuccess_plus(TAG_TEST_0100_003, data);
done();
}); });
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0100_003, startTime, endTime);
console.info(TAG_TEST_0100_003 + ' UserId promise data is: ' + JSON.stringify(data));
expectData(TAG_TEST_0100_003, data);
getApplicationInfoSuccess_plus(TAG_TEST_0100_003, data);
done();
});
/** /**
* @tc.number: bundle_getApplicationInfo_test_0200_004 * @tc.number: bundle_getApplicationInfo_test_0200_001
* @tc.name: getApplicationInfo : Obtains based on a given bundle name. * @tc.name: getApplicationInfo : Obtains based on a given bundle name.
* @tc.desc: Check the return value of the interface (by promise) * @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0 * @tc.level 0
*/ */
it(TAG_TEST_0200_001, 0, async function (done) { it(TAG_TEST_0200_001, 0, async function (done) {
var startTime = await Utils.getNowTime(); let startTime = await Utils.getNowTime();
let data = await Bundle.getApplicationInfo(BUNDLE_NAME, Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION) let data = await Bundle.getApplicationInfo(BUNDLE_NAME,
.catch((error) => { Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION).catch((error) => {
console.info(TAG_TEST_0200_001 + 'onUserId promise error is: ' + error); console.info(TAG_TEST_0200_001 + 'onUserId promise error is: ' + error);
expect(error).assertFail(); expect(error).assertFail();
});
let endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0200_001, startTime, endTime);
console.info(TAG_TEST_0200_001 + ' onUserId promise data is: ' + JSON.stringify(data));
expectData(TAG_TEST_0200_001, data);
getApplicationInfoSuccess(TAG_TEST_0200_001, data);
done();
}); });
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0200_001, startTime, endTime);
console.info(TAG_TEST_0200_001 + ' onUserId promise data is: ' + JSON.stringify(data));
expectData(TAG_TEST_0200_001, data);
getApplicationInfoSuccess(TAG_TEST_0200_001, data);
done();
});
/** /**
* @tc.number: bundle_getApplicationInfo_test_0200_005 * @tc.number: bundle_getApplicationInfo_test_0200_002
* @tc.name: getApplicationInfo : Obtains based on a given bundle name. * @tc.name: getApplicationInfo : Obtains based on a given bundle name.
* @tc.desc: Check the return value of the interface (by promise) * @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0 * @tc.level 0
*/ */
it(TAG_TEST_0200_002, 0, async function (done) { it(TAG_TEST_0200_002, 0, async function (done) {
var startTime = await Utils.getNowTime(); let startTime = await Utils.getNowTime();
let data = await Bundle.getApplicationInfo(BUNDLE_NAME, Bundle.BundleFlag.GET_ALL_APPLICATION_INFO) let data = await Bundle.getApplicationInfo(BUNDLE_NAME,
.catch((error) => { Bundle.BundleFlag.GET_ALL_APPLICATION_INFO).catch((error) => {
console.info(TAG_TEST_0200_002 + 'onUserId promise error is: ' + error); console.info(TAG_TEST_0200_002 + 'onUserId promise error is: ' + error);
expect(error).assertFail(); expect(error).assertFail();
});
let endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0200_002, startTime, endTime);
console.info(TAG_TEST_0200_002 + ' onUserId promise data is: ' + JSON.stringify(data));
expectData(TAG_TEST_0200_002, data);
getApplicationInfoSuccess_plus(TAG_TEST_0200_002, data);
done();
}); });
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0200_002, startTime, endTime);
console.info(TAG_TEST_0200_002 + ' onUserId promise data is: ' + JSON.stringify(data));
expectData(TAG_TEST_0200_002, data);
getApplicationInfoSuccess_plus(TAG_TEST_0200_002, data);
done();
});
/** /**
* @tc.number: bundle_getApplicationInfo_test_0200_006 * @tc.number: bundle_getApplicationInfo_test_0200_003
* @tc.name: getApplicationInfo : Obtains based on a given bundle name. * @tc.name: getApplicationInfo : Obtains based on a given bundle name.
* @tc.desc: Check the return value of the interface (by promise) * @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0 * @tc.level 0
*/ */
it(TAG_TEST_0200_003, 0, async function (done) { it(TAG_TEST_0200_003, 0, async function (done) {
var startTime = await Utils.getNowTime(); let startTime = await Utils.getNowTime();
let data = await Bundle.getApplicationInfo(BUNDLE_NAME, Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_DISABLE) let data = await Bundle.getApplicationInfo(BUNDLE_NAME,
.catch((error) => { Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_DISABLE).catch((error) => {
console.info(TAG_TEST_0200_003 + 'onUserId promise error is: ' + error); console.info(TAG_TEST_0200_003 + 'onUserId promise error is: ' + error);
expect(error).assertFail(); expect(error).assertFail();
});
let endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0200_003, startTime, endTime);
console.info(TAG_TEST_0200_003 + ' onUserId promise data is: ' + JSON.stringify(data));
expectData(TAG_TEST_0200_003, data);
getApplicationInfoSuccess_plus(TAG_TEST_0200_003, data);
done();
}); });
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0200_003, startTime, endTime);
console.info(TAG_TEST_0200_003 + ' onUserId promise data is: ' + JSON.stringify(data));
expectData(TAG_TEST_0200_003, data);
getApplicationInfoSuccess_plus(TAG_TEST_0200_003, data);
done();
});
/** /**
* @tc.number: bundle_getApplicationInfo_test_0300_007 * @tc.number: bundle_getApplicationInfo_test_0300_001
* @tc.name: getApplicationInfo : Obtains based on a given bundle name. * @tc.name: getApplicationInfo : Obtains based on a given bundle name.
* @tc.desc: Check the return value of the interface (by callBack) * @tc.desc: Check the return value of the interface (by callBack)
* @tc.level 0 * @tc.level 0
*/ */
it(TAG_TEST_0300_001, 0, async function (done) { it(TAG_TEST_0300_001, 0, async function (done) {
let errors; let errors;
let datas; let datas;
var startTime = await Utils.getNowTime(); let startTime = await Utils.getNowTime();
Bundle.getApplicationInfo(BUNDLE_NAME, Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, Bundle.getApplicationInfo(BUNDLE_NAME,
USER_ID_100, (error, data) => { Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, USER_ID_100, (error, data) => {
var endTime = Utils.getNowTime(); let endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0300_001, startTime, endTime); Utils.getDurationTime(TAG_TEST_0300_001, startTime, endTime);
errors = error; errors = error;
if(errors){ if (errors) {
expect(errors).assertFail(); expect(errors).assertFail();
console.info(TAG_TEST_0300_001 + 'UserId callBack error: ' + error); console.info(TAG_TEST_0300_001 + 'UserId callBack error: ' + error);
} }
console.info(TAG_TEST_0300_001 + 'UserId callBack data is:' + JSON.stringify(data)); console.info(TAG_TEST_0300_001 + 'UserId callBack data is:' + JSON.stringify(data));
datas = data; datas = data;
});
await Utils.sleep(2000);
console.info(TAG_TEST_0300_001 + 'UserId callBack data is: ' + JSON.stringify(datas));
expectData(TAG_TEST_0300_001, datas);
getApplicationInfoSuccess(TAG_TEST_0300_001, datas);
done();
}); });
await Utils.sleep(2000);
console.info(TAG_TEST_0300_001 + 'UserId callBack data is: ' + JSON.stringify(datas));
expectData(TAG_TEST_0300_001, datas);
getApplicationInfoSuccess(TAG_TEST_0300_001, datas);
done();
});
/** /**
* @tc.number: bundle_getApplicationInfo_test_0400_008 * @tc.number: bundle_getApplicationInfo_test_0400_001
* @tc.name: getApplicationInfo : Obtains based on a given bundle name. * @tc.name: getApplicationInfo : Obtains based on a given bundle name.
* @tc.desc: Check the return value of the interface (by callBack) * @tc.desc: Check the return value of the interface (by callBack)
* @tc.level 0 * @tc.level 0
*/ */
it(TAG_TEST_0400_001, 0, async function (done) { it(TAG_TEST_0400_001, 0, async function (done) {
let errors; let errors;
let datas; let datas;
var startTime = await Utils.getNowTime(); let startTime = await Utils.getNowTime();
Bundle.getApplicationInfo(BUNDLE_NAME, Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, (error, data) => { Bundle.getApplicationInfo(BUNDLE_NAME,
var endTime = Utils.getNowTime(); Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, (error, data) => {
errors = error; let endTime = Utils.getNowTime();
if(errors){ errors = error;
expect(errors).assertFail(); if (errors) {
console.info(TAG_TEST_0400_001 + 'UserId callBack error: ' + error); expect(errors).assertFail();
} console.info(TAG_TEST_0400_001 + 'UserId callBack error: ' + error);
Utils.getDurationTime(TAG_TEST_0400_001, startTime, endTime); }
console.info(TAG_TEST_0400_001 + 'noUserId callBack data is:' + JSON.stringify(data)); Utils.getDurationTime(TAG_TEST_0400_001, startTime, endTime);
datas = data; console.info(TAG_TEST_0400_001 + 'noUserId callBack data is:' + JSON.stringify(data));
}); datas = data;
await Utils.sleep(2000); });
console.info(TAG_TEST_0400_001 + 'noUserId callBack data is: ' + JSON.stringify(datas)); await Utils.sleep(2000);
expectData(TAG_TEST_0400_001, datas); console.info(TAG_TEST_0400_001 + 'noUserId callBack data is: ' + JSON.stringify(datas));
getApplicationInfoSuccess(TAG_TEST_0400_001, datas); expectData(TAG_TEST_0400_001, datas);
done(); getApplicationInfoSuccess(TAG_TEST_0400_001, datas);
}); done();
});
/** /**
* @tc.number: bundle_getApplicationInfo_test_0500_009 * @tc.number: bundle_getApplicationInfo_test_0500_001
* @tc.name: getApplicationInfo : Obtains based on a given bundle name. * @tc.name: getApplicationInfo : Obtains based on a given bundle name.
* @tc.desc: Check the return value of the interface (by promise) * @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0 * @tc.level 0
*/ */
it(TAG_TEST_0500_001, 0, async function (done) { it(TAG_TEST_0500_001, 0, async function (done) {
var startTime = await Utils.getNowTime(); let startTime = await Utils.getNowTime();
await Bundle.getApplicationInfo('', 0) await Bundle.getApplicationInfo('', Bundle.BundleFlag.GET_BUNDLE_DEFAULT).then((data) => {
.then((data) => { console.info(TAG_TEST_0500_001 + 'noUserId promise data is: ' + data);
console.info(TAG_TEST_0500_001 + 'noUserId promise data is: ' + data); expect(data).assertFail();
expect(data).assertFail(); }).catch((error) => {
}) console.info(TAG_TEST_0500_001 + 'noUserId promise error is: ' + error);
.catch((error) => { expect(error).assertEqual(1);
console.info(TAG_TEST_0500_001 + 'noUserId promise error is: ' + error); });
expect(error).assertEqual(1); let endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0500_001, startTime, endTime);
done();
}); });
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0500_001, startTime, endTime);
done();
});
/** /**
* @tc.number: bundle_getApplicationInfo_test_0500_0010 * @tc.number: bundle_getApplicationInfo_test_0500_002
* @tc.name: getApplicationInfo : Obtains based on a given bundle name. * @tc.name: getApplicationInfo : Obtains based on a given bundle name.
* @tc.desc: Check the return value of the interface (by promise) * @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0 * @tc.level 0
*/ */
it(TAG_TEST_0500_002, 0, async function (done) { it(TAG_TEST_0500_002, 0, async function (done) {
var startTime = await Utils.getNowTime(); let startTime = await Utils.getNowTime();
await Bundle.getApplicationInfo('', '0', USER_ID_100) await Bundle.getApplicationInfo('', 'Bundle.BundleFlag.GET_BUNDLE_DEFAULT', USER_ID_100).then((data) => {
.then((data) => { console.info(TAG_TEST_0500_002 + 'UserId promise data is: ' + data);
console.info(TAG_TEST_0500_002 + 'UserId promise data is: ' + data); expect(data).assertFail();
expect(data).assertFail(); }).catch((error) => {
}) console.info(TAG_TEST_0500_002 + 'UserId promise error is: ' + error);
.catch((error) => { expect(error).assertEqual(1);
console.info(TAG_TEST_0500_002 + 'UserId promise error is: ' + error); });
expect(error).assertEqual(1); let endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0500_002, startTime, endTime);
done();
}); });
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0500_002, startTime, endTime);
done();
});
/** /**
* @tc.number: bundle_getApplicationInfo_test_0600_0011 * @tc.number: bundle_getApplicationInfo_test_0600_001
* @tc.name: getApplicationInfo : Obtains based on a given bundle name. * @tc.name: getApplicationInfo : Obtains based on a given bundle name.
* @tc.desc: Check the return value of the interface (by promise) * @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0 * @tc.level 0
*/ */
it(TAG_TEST_0600_001, 0, async function (done) { it(TAG_TEST_0600_001, 0, async function (done) {
let errors let errors
var startTime = await Utils.getNowTime(); let startTime = await Utils.getNowTime();
await Bundle.getApplicationInfo(BUNDLE_NAME_OTHER, await Bundle.getApplicationInfo(BUNDLE_NAME_OTHER,
Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION) Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION).then((data) => {
.then((data) => { console.info(TAG_TEST_0600_001 + 'other bundleName noUserId promise data is: ' + data);
console.info(TAG_TEST_0600_001 + 'other bundleName noUserId promise data is: ' + data); expect(data).assertFail();
expect(data).assertFail(); }).catch((error) => {
}) console.info(TAG_TEST_0600_001 + 'other bundleName noUserId promise error is: ' + error);
.catch((error) => { errors = error
console.info(TAG_TEST_0600_001 + 'other bundleName noUserId promise error is: ' + error); expect(errors).assertEqual(1);
errors = error });
expect(errors).assertEqual(1); let endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0600_001, startTime, endTime);
done();
}); });
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0600_001, startTime, endTime);
done();
});
/** /**
* @tc.number: bundle_getApplicationInfo_test_0600_0012 * @tc.number: bundle_getApplicationInfo_test_0600_002
* @tc.name: getApplicationInfo : Obtains based on a given bundle name. * @tc.name: getApplicationInfo : Obtains based on a given bundle name.
* @tc.desc: Check the return value of the interface (by promise) * @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0 * @tc.level 0
*/ */
it(TAG_TEST_0600_002, 0, async function (done) { it(TAG_TEST_0600_002, 0, async function (done) {
var startTime = await Utils.getNowTime(); let startTime = await Utils.getNowTime();
let errors let errors
await Bundle.getApplicationInfo(BUNDLE_NAME_OTHER, Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, await Bundle.getApplicationInfo(BUNDLE_NAME_OTHER,
USER_ID_100) Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, USER_ID_100).then((data) => {
.then((data) => { console.info(TAG_TEST_0600_002 + 'other bundleName UserId promise data is: ' + data);
console.info(TAG_TEST_0600_002 + 'other bundleName UserId promise data is: ' + data); expect(data).assertFail();
expect(data).assertFail(); }).catch((error) => {
}) console.info(TAG_TEST_0600_002 + 'other bundleName UserId promise error is: ' + error);
.catch((error) => { errors = error
console.info(TAG_TEST_0600_002 + 'other bundleName UserId promise error is: ' + error); expect(errors).assertEqual(1);
errors = error });
expect(errors).assertEqual(1); let endTime = Utils.getNowTime();
}); Utils.getDurationTime(TAG_TEST_0600_002, startTime, endTime);
var endTime = Utils.getNowTime(); done();
Utils.getDurationTime(TAG_TEST_0600_002, startTime, endTime); });
done();
});
/** /**
* @tc.number: bundle_getApplicationInfo_test_0500_009 * @tc.number: bundle_getApplicationInfo_test_0600_003
* @tc.name: getApplicationInfo : Obtains based on a given bundle name. * @tc.name: getApplicationInfo : Obtains based on a given bundle name.
* @tc.desc: Check the return value of the interface (by promise) * @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0 * @tc.level 0
*/ */
it(TAG_TEST_0600_003, 0, async function (done) { it(TAG_TEST_0600_003, 0, async function (done) {
var startTime = await Utils.getNowTime(); let startTime = await Utils.getNowTime();
await Bundle.getApplicationInfo(BUNDLE_NAME, 0) await Bundle.getApplicationInfo(BUNDLE_NAME, Bundle.BundleFlag.GET_BUNDLE_DEFAULT).then((data) => {
.then((data) => { let endTime = Utils.getNowTime();
var endTime = Utils.getNowTime(); Utils.getDurationTime(TAG_TEST_0600_003, startTime, endTime);
Utils.getDurationTime(TAG_TEST_0600_003, startTime, endTime); console.info(TAG_TEST_0600_003 + 'noUserId promise data is: ' + data);
console.info(TAG_TEST_0600_003 + 'noUserId promise data is: ' + data); expect(typeof (data)).assertEqual("object");
expect(typeof (data)).assertEqual("object"); expectData(TAG_TEST_0600_003, data);
expectData(TAG_TEST_0600_003, data); getApplicationInfoSuccess_plus(TAG_TEST_0600_003, data);
getApplicationInfoSuccess_plus(TAG_TEST_0600_003, data); }).catch((error) => {
}) console.info(TAG_TEST_0600_003 + 'noUserId promise error is: ' + error);
.catch((error) => { expect(error).assertFail();
console.info(TAG_TEST_0600_003 + 'noUserId promise error is: ' + error); });
expect(error).assertFail(); done();
}); });
done();
});
function expectData(msg, data) {
expect(typeof (data)).assertEqual('object');
expect(typeof (data.name)).assertEqual('string');
expect(typeof (data.codePath)).assertEqual('string');
expect(typeof (data.accessTokenId)).assertEqual('number');
expect(typeof (data.description)).assertEqual('string');
expect(typeof (data.descriptionId)).assertEqual('number');
expect(typeof (data.icon)).assertEqual('string');
expect(typeof (data.iconId)).assertEqual('number');
expect(typeof (data.label)).assertEqual('string');
expect(typeof (data.labelId)).assertEqual('number');
expect(typeof (data.systemApp)).assertEqual('boolean')
expect(typeof (data.supportedModes)).assertEqual('number');
expect(typeof (data.process)).assertEqual('string');
expect(typeof (data.entryDir)).assertEqual('string');
expect(typeof (data.metaData)).assertEqual('object');
expect(typeof (data.metadata)).assertEqual('object');
expect(typeof (data.enabled)).assertEqual('boolean');
expect(typeof (data.flags)).assertEqual('number');
expect(typeof (data.uid)).assertEqual('number');
expect(typeof (data.entityType)).assertEqual('string');
expect(typeof (data.removable)).assertEqual('boolean');
expect(Array.isArray(data.permissions)).assertEqual(true);
expect(Array.isArray(data.moduleSourceDirs)).assertEqual(true);
expect(Array.isArray(data.moduleInfos)).assertEqual(true);
}
function getApplicationInfoSuccess(msg, data) {
expect(data.name).assertEqual('com.open.harmony.packagemag');
expect(data.codePath).assertEqual('/data/app/el1/bundle/public/com.open.harmony.packagemag');
expect(data.accessTokenId > 0).assertEqual(true);
expect(data.description).assertEqual('$string:mainability_description');
expect(data.descriptionId > 0).assertEqual(true);
expect(data.icon).assertEqual('$media:icon');
expect(data.iconId > 0).assertEqual(true);
expect(data.uid > 0).assertEqual(true);
expect(data.label).assertEqual('$string:entry_MainAbility');
expect(data.labelId > 0).assertEqual(true);
expect(data.systemApp).assertEqual(true);
expect(data.supportedModes).assertEqual(0);
expect(data.flags).assertEqual(0);
expect(data.process).assertEqual("");
expect(data.entryDir).assertEqual('/data/app/el1/bundle/public/com.open.harmony.packagemag' +
'/com.open.harmony.packagemag');
expect(data.enabled).assertEqual(true);
expect(data.entityType).assertEqual('unspecified');
expect(data.removable).assertEqual(true);
expect(data.moduleInfos[0].moduleName).assertEqual('entry');
expect(data.moduleInfos[0].moduleSourceDir).assertEqual('/data/app/el1/bundle/public/' +
'com.open.harmony.packagemag/com.open.harmony.packagemag');
expect(data.moduleSourceDirs[0]).assertEqual('/data/app/el1/bundle/public/' +
'com.open.harmony.packagemag/com.open.harmony.packagemag');
expect(data.permissions[0]).assertEqual("ohos.permission.CHANGE_ABILITY_ENABLED_STATE");
expect(data.permissions[1]).assertEqual("ohos.permission.GET_BUNDLE_INFO");
expect(data.permissions[2]).assertEqual("ohos.permission.GET_BUNDLE_INFO_PRIVILEGED");
console.log(msg + ' end ' + JSON.stringify(data));
}
/** function getApplicationInfoSuccess_plus(msg, data) {
* expect属性 expect(data.name).assertEqual('com.open.harmony.packagemag');
* @param msg log信息 expect(data.codePath).assertEqual('/data/app/el1/bundle/public/com.open.harmony.packagemag');
* @param data 数据源 expect(data.accessTokenId > 0).assertEqual(true);
*/ expect(data.description).assertEqual('$string:mainability_description');
function expectData(msg, data) { expect(data.descriptionId > 0).assertEqual(true);
expect(typeof (data)).assertEqual('object'); expect(data.icon).assertEqual('$media:icon');
expect(typeof (data.name)).assertEqual('string'); expect(data.iconId > 0).assertEqual(true);
expect(typeof (data.codePath)).assertEqual('string'); expect(data.uid > 0).assertEqual(true);
expect(typeof (data.accessTokenId)).assertEqual('number'); expect(data.label).assertEqual('$string:entry_MainAbility');
expect(typeof (data.description)).assertEqual('string'); expect(data.labelId > 0).assertEqual(true);
expect(typeof (data.descriptionId)).assertEqual('number'); expect(data.systemApp).assertEqual(true);
expect(typeof (data.icon)).assertEqual('string'); expect(data.supportedModes).assertEqual(0);
expect(typeof (data.iconId)).assertEqual('number'); expect(data.flags).assertEqual(0);
expect(typeof (data.label)).assertEqual('string'); expect(data.process).assertEqual("");
expect(typeof (data.labelId)).assertEqual('number'); expect(data.entryDir).assertEqual('/data/app/el1/bundle/public/com.open.harmony.packagemag' +
expect(typeof (data.systemApp)).assertEqual('boolean') '/com.open.harmony.packagemag');
expect(typeof (data.supportedModes)).assertEqual('number'); expect(data.enabled).assertEqual(true);
expect(typeof (data.process)).assertEqual('string'); expect(data.entityType).assertEqual('unspecified');
expect(typeof (data.entryDir)).assertEqual('string'); expect(data.removable).assertEqual(true);
expect(typeof (data.metaData)).assertEqual('object'); expect(data.moduleInfos[0].moduleName).assertEqual('entry');
expect(typeof (data.metadata)).assertEqual('object'); expect(data.moduleInfos[0].moduleSourceDir).assertEqual('/data/app/el1/bundle/public/' +
expect(typeof (data.enabled)).assertEqual('boolean'); 'com.open.harmony.packagemag/com.open.harmony.packagemag');
expect(typeof (data.flags)).assertEqual('number'); expect(data.moduleSourceDirs[0]).assertEqual('/data/app/el1/bundle/public/' +
expect(typeof (data.uid)).assertEqual('number'); 'com.open.harmony.packagemag/com.open.harmony.packagemag');
expect(typeof (data.entityType)).assertEqual('string'); console.log(msg + ' end ' + JSON.stringify(data));
expect(typeof (data.removable)).assertEqual('boolean'); }
expect(Array.isArray(data.permissions)).assertEqual(true);
expect(Array.isArray(data.moduleSourceDirs)).assertEqual(true);
expect(Array.isArray(data.moduleInfos)).assertEqual(true);
}
/** });
* expect属性值
* @param msg log信息
* @param data 数据源
*/
function getApplicationInfoSuccess(msg, data) {
expect(data.name).assertEqual('com.open.harmony.packagemag');
expect(data.codePath).assertEqual('/data/app/el1/bundle/public/com.open.harmony.packagemag');
expect(data.accessTokenId > 0).assertEqual(true);
expect(data.description).assertEqual('$string:mainability_description');
expect(data.descriptionId > 0).assertEqual(true);
expect(data.icon).assertEqual('$media:icon');
expect(data.iconId > 0).assertEqual(true);
expect(data.uid > 0).assertEqual(true);
expect(data.label).assertEqual('$string:entry_MainAbility');
expect(data.labelId > 0).assertEqual(true);
expect(data.systemApp).assertEqual(true);
expect(data.supportedModes).assertEqual(0);
expect(data.flags).assertEqual(0);
expect(data.process).assertEqual("");
expect(data.entryDir).assertEqual('/data/app/el1/bundle/public/com.open.harmony.packagemag' +
'/com.open.harmony.packagemag');
expect(data.enabled).assertEqual(true);
expect(data.entityType).assertEqual('unspecified');
expect(data.removable).assertEqual(true);
expect(data.moduleInfos[0].moduleName).assertEqual('entry');
expect(data.moduleInfos[0].moduleSourceDir).assertEqual('/data/app/el1/bundle/public/' +
'com.open.harmony.packagemag/com.open.harmony.packagemag');
expect(data.moduleSourceDirs[0]).assertEqual('/data/app/el1/bundle/public/' +
'com.open.harmony.packagemag/com.open.harmony.packagemag');
expect(data.permissions[0]).assertEqual("ohos.permission.CHANGE_ABILITY_ENABLED_STATE");
expect(data.permissions[1]).assertEqual("ohos.permission.GET_BUNDLE_INFO");
expect(data.permissions[2]).assertEqual("ohos.permission.GET_BUNDLE_INFO_PRIVILEGED");
console.log(msg + ' end ' + JSON.stringify(data));
}
/**
* expect属性值
* @param msg log信息
* @param data 数据源
*/
function getApplicationInfoSuccess_plus(msg, data) {
expect(data.name).assertEqual('com.open.harmony.packagemag');
expect(data.codePath).assertEqual('/data/app/el1/bundle/public/com.open.harmony.packagemag');
expect(data.accessTokenId > 0).assertEqual(true);
expect(data.description).assertEqual('$string:mainability_description');
expect(data.descriptionId > 0).assertEqual(true);
expect(data.icon).assertEqual('$media:icon');
expect(data.iconId > 0).assertEqual(true);
expect(data.uid > 0).assertEqual(true);
expect(data.label).assertEqual('$string:entry_MainAbility');
expect(data.labelId > 0).assertEqual(true);
expect(data.systemApp).assertEqual(true);
expect(data.supportedModes).assertEqual(0);
expect(data.flags).assertEqual(0);
expect(data.process).assertEqual("");
expect(data.entryDir).assertEqual('/data/app/el1/bundle/public/com.open.harmony.packagemag' +
'/com.open.harmony.packagemag');
expect(data.enabled).assertEqual(true);
expect(data.entityType).assertEqual('unspecified');
expect(data.removable).assertEqual(true);
expect(data.moduleInfos[0].moduleName).assertEqual('entry');
expect(data.moduleInfos[0].moduleSourceDir).assertEqual('/data/app/el1/bundle/public/' +
'com.open.harmony.packagemag/com.open.harmony.packagemag');
expect(data.moduleSourceDirs[0]).assertEqual('/data/app/el1/bundle/public/' +
'com.open.harmony.packagemag/com.open.harmony.packagemag');
console.log(msg + ' end ' + JSON.stringify(data));
}
});
} }
\ No newline at end of file
...@@ -1901,7 +1901,6 @@ describe('ActsBundleManagerTest', function () { ...@@ -1901,7 +1901,6 @@ describe('ActsBundleManagerTest', function () {
expect(datainfo.versionName.length).assertLarger(0) expect(datainfo.versionName.length).assertLarger(0)
expect(datainfo.uid).assertLarger(2099) expect(datainfo.uid).assertLarger(2099)
expect(datainfo.appInfo.name).assertEqual(LAUNCHER) expect(datainfo.appInfo.name).assertEqual(LAUNCHER)
expect(datainfo.appInfo.description).assertEqual(DESCRIPTION)
expect(datainfo.appInfo.systemApp).assertEqual(true) expect(datainfo.appInfo.systemApp).assertEqual(true)
expect(datainfo.appInfo.supportedModes).assertEqual(0) expect(datainfo.appInfo.supportedModes).assertEqual(0)
expect(datainfo.appInfo.moduleInfos.length).assertLarger(0) expect(datainfo.appInfo.moduleInfos.length).assertLarger(0)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册