You need to sign in or sign up before continuing.
未验证 提交 1b278639 编写于 作者: O openharmony_ci 提交者: Gitee

!3269 新增queryExtensionAbilityInfos接口用例+stage模型demo

Merge pull request !3269 from ry/master
......@@ -56,6 +56,7 @@ group("bundlemanager") {
"sceneProject/bmsscenethree:bmsJstest3",
"sceneProject/bmsscenetwo:bmsJstest2",
"sceneProject/bmssecondright:second_right",
"sceneProject/bmsstagedemoone:bmsStageDemo1",
]
}
}
......@@ -19,6 +19,8 @@ const BUNDLE_NAME1 = 'com.example.third1';
const SYSTEM_NAME = 'com.example.system2';
const ABILITIY_NAME8 = 'com.example.system2.MainAbility';
const USERID = 100;
const ACTION_NAME = 'action.system.home';
const ENTITY_NAME = 'entity.system.home';
describe('ActsBmsQueryAbilityByWant', function () {
......@@ -30,8 +32,8 @@ describe('ActsBmsQueryAbilityByWant', function () {
*/
it('bms_queryAbilityByWant_0100', 0, async function (done) {
await bundle.queryAbilityByWant({
action: ['action.system.home'],
entities: ['entity.system.home'],
action: [ACTION_NAME],
entities: [ENTITY_NAME],
bundleName: BUNDLE_NAME1
}, bundle.BundleFlag.GET_ABILITY_INFO_WITH_APPLICATION | bundle.BundleFlag.GET_ABILITY_INFO_SYSTEMAPP_ONLY,
USERID).then(data => {
......@@ -40,8 +42,8 @@ describe('ActsBmsQueryAbilityByWant', function () {
expect(err).assertEqual(1);
});
bundle.queryAbilityByWant({
action: ['action.system.home'],
entities: ['entity.system.home'],
action: [ACTION_NAME],
entities: [ENTITY_NAME],
bundleName: BUNDLE_NAME1
}, bundle.BundleFlag.GET_ABILITY_INFO_WITH_APPLICATION | bundle.BundleFlag.GET_ABILITY_INFO_SYSTEMAPP_ONLY,
USERID, (err, data) => {
......@@ -60,8 +62,8 @@ describe('ActsBmsQueryAbilityByWant', function () {
it('bms_queryAbilityByWant_0200', 0, async function (done) {
await bundle.queryAbilityByWant(
{
action: ['action.system.home'],
entities: ['entity.system.home']
action: [ACTION_NAME],
entities: [ENTITY_NAME]
},
bundle.BundleFlag.GET_ABILITY_INFO_WITH_APPLICATION | bundle.BundleFlag.GET_ABILITY_INFO_SYSTEMAPP_ONLY,
USERID).then(data => {
......@@ -75,8 +77,8 @@ describe('ActsBmsQueryAbilityByWant', function () {
});
bundle.queryAbilityByWant(
{
action: ['action.system.home'],
entities: ['entity.system.home']
action: [ACTION_NAME],
entities: [ENTITY_NAME]
},
bundle.BundleFlag.GET_ABILITY_INFO_WITH_APPLICATION | bundle.BundleFlag.GET_ABILITY_INFO_SYSTEMAPP_ONLY,
USERID, (err, data) => {
......@@ -98,7 +100,7 @@ describe('ActsBmsQueryAbilityByWant', function () {
*/
it('bms_queryAbilityByEntities_0300', 0, async function (done) {
let dataInfos = await bundle.queryAbilityByWant({
action: 'action.system.home',
action: ACTION_NAME,
entities: ["entity.app.music",
"entity.app.email",
"entity.app.contacts",
......@@ -117,7 +119,7 @@ describe('ActsBmsQueryAbilityByWant', function () {
expect(dataInfos.length).assertEqual(1);
cheackAbilityInfos(dataInfos[0]);
bundle.queryAbilityByWant({
action: 'action.system.home',
action: ACTION_NAME,
entities: ["entity.app.music",
"entity.app.email",
"entity.app.contacts",
......
......@@ -23,6 +23,10 @@ const BUNDLE_NAME5 = 'com.example.system1';
const BUNDLE_NAME6 = "com.example.bmsmainabilitysecondscene";
const FIRSTMAINABILITY = 'com.example.bmsmainabilityfirstscene.MainAbility';
const SECONDMAINABILITY = 'com.example.bmsmainabilitysecondscene.MainAbility';
const MODULE_NAME = 'entry';
const ICON_PATH = "$media:icon";
const LABEL = '$string:app_name';
const DEVICE_TYPES = 'phone';
describe('ActsBmsHapModuleTest', function () {
......@@ -40,18 +44,18 @@ describe('ActsBmsHapModuleTest', function () {
if (result.hapModuleInfos.length > 0) {
let hapModuleInfo = result.hapModuleInfos[0];
expect(hapModuleInfo.name).assertEqual(BUNDLE_NAME1);
expect(hapModuleInfo.moduleName).assertEqual('entry');
expect(hapModuleInfo.moduleName).assertEqual(MODULE_NAME);
expect(hapModuleInfo.description).assertEqual('');
expect(hapModuleInfo.descriptionId).assertEqual(0);
expect(hapModuleInfo.iconPath).assertEqual("$media:icon");
expect(hapModuleInfo.iconPath).assertEqual(ICON_PATH);
expect(hapModuleInfo.icon).assertEqual('');
expect(hapModuleInfo.label).assertEqual('$string:app_name');
expect(hapModuleInfo.label).assertEqual(LABEL);
expect(hapModuleInfo.labelId).assertEqual(0);
expect(hapModuleInfo.iconId).assertEqual(0);
expect(hapModuleInfo.backgroundImg).assertEqual("");
expect(hapModuleInfo.supportedModes).assertEqual(0);
expect(hapModuleInfo.reqCapabilities.length).assertEqual(0);
expect(hapModuleInfo.deviceTypes[0]).assertEqual('phone');
expect(hapModuleInfo.deviceTypes[0]).assertEqual(DEVICE_TYPES);
expect(hapModuleInfo.mainAbilityName).assertEqual(FIRSTMAINABILITY);
expect(hapModuleInfo.mainElementName).assertEqual(FIRSTMAINABILITY);
expect(hapModuleInfo.abilityInfo.length).assertLarger(0);
......@@ -79,10 +83,10 @@ describe('ActsBmsHapModuleTest', function () {
let hapModuleInfo1 = result.hapModuleInfos[1];
checkHapMoudleInfos(hapModuleInfo);
checkHapMoudleInfos(hapModuleInfo1);
expect(hapModuleInfo.label).assertEqual('$string:app_name');
expect(hapModuleInfo.label).assertEqual(LABEL);
expect(hapModuleInfo.name).assertEqual(BUNDLE_NAME1);
expect(hapModuleInfo1.name).assertEqual(BUNDLE_NAME6);
expect(hapModuleInfo.moduleName).assertEqual('entry');
expect(hapModuleInfo.moduleName).assertEqual(MODULE_NAME);
expect(hapModuleInfo.mainAbilityName).assertEqual(FIRSTMAINABILITY);
expect(hapModuleInfo.mainElementName).assertEqual(FIRSTMAINABILITY);
expect(hapModuleInfo1.moduleName).assertEqual('bmsmainabilitysecondscene');
......@@ -106,18 +110,18 @@ describe('ActsBmsHapModuleTest', function () {
if (result.hapModuleInfos.length > 0) {
let hapModuleInfo = result.hapModuleInfos[0];
expect(hapModuleInfo.name).assertEqual(BUNDLE_NAME2);
expect(hapModuleInfo.moduleName).assertEqual('entry');
expect(hapModuleInfo.moduleName).assertEqual(MODULE_NAME);
expect(hapModuleInfo.description).assertEqual('');
expect(hapModuleInfo.descriptionId).assertEqual(0);
expect(hapModuleInfo.iconPath).assertEqual("$media:icon");
expect(hapModuleInfo.iconPath).assertEqual(ICON_PATH);
expect(hapModuleInfo.icon).assertEqual('');
expect(hapModuleInfo.label).assertEqual('$string:app_name');
expect(hapModuleInfo.label).assertEqual(LABEL);
expect(hapModuleInfo.labelId).assertEqual(0);
expect(hapModuleInfo.iconId).assertEqual(0);
expect(hapModuleInfo.backgroundImg).assertEqual("");
expect(hapModuleInfo.supportedModes).assertEqual(0);
expect(hapModuleInfo.reqCapabilities.length).assertEqual(0);
expect(hapModuleInfo.deviceTypes[0]).assertEqual('phone');
expect(hapModuleInfo.deviceTypes[0]).assertEqual(DEVICE_TYPES);
expect(hapModuleInfo.mainAbilityName).assertEqual("");
expect(hapModuleInfo.mainElementName).assertEqual("");
expect(hapModuleInfo.abilityInfo.length).assertLarger(0);
......@@ -143,18 +147,18 @@ describe('ActsBmsHapModuleTest', function () {
if (result.hapModuleInfos.length == 1) {
let hapModuleInfo = result.hapModuleInfos[0];
expect(hapModuleInfo.name).assertEqual(BUNDLE_NAME3);
expect(hapModuleInfo.moduleName).assertEqual('entry');
expect(hapModuleInfo.moduleName).assertEqual(MODULE_NAME);
expect(hapModuleInfo.description).assertEqual('');
expect(hapModuleInfo.descriptionId).assertEqual(0);
expect(hapModuleInfo.iconPath).assertEqual("$media:icon");
expect(hapModuleInfo.iconPath).assertEqual(ICON_PATH);
expect(hapModuleInfo.icon).assertEqual('');
expect(hapModuleInfo.label).assertEqual('$string:app_name');
expect(hapModuleInfo.label).assertEqual(LABEL);
expect(hapModuleInfo.labelId).assertEqual(0);
expect(hapModuleInfo.iconId).assertEqual(0);
expect(hapModuleInfo.backgroundImg).assertEqual("");
expect(hapModuleInfo.supportedModes).assertEqual(0);
expect(hapModuleInfo.reqCapabilities.length).assertEqual(0);
expect(hapModuleInfo.deviceTypes[0]).assertEqual('phone');
expect(hapModuleInfo.deviceTypes[0]).assertEqual(DEVICE_TYPES);
expect(hapModuleInfo.mainAbilityName).assertEqual("com.example.third5.AMainAbility");
expect(hapModuleInfo.mainElementName).assertEqual("com.example.third5.AMainAbility");
expect(hapModuleInfo.abilityInfo.length).assertLarger(0);
......@@ -181,18 +185,18 @@ describe('ActsBmsHapModuleTest', function () {
if (data.hapModuleInfos.length == 1) {
let hapModuleInfo = data.hapModuleInfos[0];
expect(hapModuleInfo.name).assertEqual(BUNDLE_NAME5);
expect(hapModuleInfo.moduleName).assertEqual('entry');
expect(hapModuleInfo.moduleName).assertEqual(MODULE_NAME);
expect(hapModuleInfo.description).assertEqual('');
expect(hapModuleInfo.descriptionId).assertEqual(0);
expect(hapModuleInfo.iconPath).assertEqual("$media:icon");
expect(hapModuleInfo.iconPath).assertEqual(ICON_PATH);
expect(hapModuleInfo.icon).assertEqual('');
expect(hapModuleInfo.label).assertEqual('$string:app_name');
expect(hapModuleInfo.label).assertEqual(LABEL);
expect(hapModuleInfo.labelId).assertEqual(0);
expect(hapModuleInfo.iconId).assertEqual(0);
expect(hapModuleInfo.backgroundImg).assertEqual("");
expect(hapModuleInfo.supportedModes).assertEqual(0);
expect(hapModuleInfo.reqCapabilities.length).assertEqual(0);
expect(hapModuleInfo.deviceTypes[0]).assertEqual('phone');
expect(hapModuleInfo.deviceTypes[0]).assertEqual(DEVICE_TYPES);
expect(hapModuleInfo.mainAbilityName).assertEqual("com.example.system1.MainAbility");
expect(hapModuleInfo.mainElementName).assertEqual("com.example.system1.MainAbility");
expect(hapModuleInfo.abilityInfo.length).assertLarger(0);
......@@ -208,14 +212,14 @@ describe('ActsBmsHapModuleTest', function () {
function checkHapMoudleInfos(info) {
expect(info.description).assertEqual('');
expect(info.descriptionId).assertEqual(0);
expect(info.iconPath).assertEqual("$media:icon");
expect(info.iconPath).assertEqual(ICON_PATH);
expect(info.icon).assertEqual('');
expect(info.labelId).assertEqual(0);
expect(info.iconId).assertEqual(0);
expect(info.backgroundImg).assertEqual("");
expect(info.supportedModes).assertEqual(0);
expect(info.reqCapabilities.length).assertEqual(0);
expect(info.deviceTypes[0]).assertEqual('phone');
expect(info.deviceTypes[0]).assertEqual(DEVICE_TYPES);
expect(info.abilityInfo.length).assertLarger(0);
expect(info.colorMode).assertEqual(-1);
expect(info.extensionAbilityInfo.length).assertEqual(0);
......
......@@ -27,7 +27,8 @@
"push":[
"bmsThirdBundleTest1.hap -> /data/bmsThirdBundleTest1.hap ",
"first_right.hap -> /data/test/first_right.hap",
"second_right.hap -> /data/second_right.hap"
"second_right.hap -> /data/second_right.hap",
"bmsStageDemo1.hap -> /data/test/bmsStageDemo1.hap"
]
},
{
......@@ -35,7 +36,8 @@
"run-command": [
"bm install -p /data/bmsThirdBundleTest1.hap",
"bm install -p /data/test/first_right.hap",
"bm install -p /data/second_right.hap"
"bm install -p /data/second_right.hap",
"bm install -p /data/test/bmsStageDemo1.hap"
],
"teardown-command":[
"bm uninstall -n com.example.third1",
......
......@@ -21,8 +21,10 @@ import isAbilityEnableETSUnit from "./IsAbilityEnabledETSUnit.ets";
import isApplicationEnabledETSUnit from "./IsApplicationEnabledETSUnit.ets";
import getAbilityIcon from "./GetAbilityIcon.test.ets";
import getNameForUid from "./GetNameForUid.test.ets";
import queryExtensionAbilityInfos from "./QueryExtensionAbilityInfos.test.ets";
export default function testsuite() {
queryExtensionAbilityInfos();
getAbilityIcon();
getLaunchWantForBundle();
getNameForUid();
......
/**
* 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 bundle from '@ohos.bundle'
import { describe, it, expect } from 'hypium/index';
const BUNDLE_NAME1 = "ohos.acts.bundle.stage";
const BUNDLE_NAME2 = "com.noexit.com";
const ABILITY_NAME1 = "ExtensionAbility1";
const ABILITY_NAME2 = "noexitAbility";
export default function QueryExtensionAbilityInfos() {
describe('QueryExtensionAbilityInfos', function () {
/*
* @tc.number: SUB_BMS_APPINFO_EXTENSION_0001
* @tc.name: test queryExtensionAbilityInfos api
* @tc.desc: test queryExtensionAbilityInfos with invalid userId
*/
it('SUB_BMS_APPINFO_EXTENSION_0001', 0, async function (done) {
await bundle.queryExtensionAbilityInfos(
{
"bundleName": BUNDLE_NAME1,
"abilityName": ABILITY_NAME1
}, bundle.ExtensionAbilityType.FORM, bundle.ExtensionFlag.GET_EXTENSION_INFO_DEFAULT, 1001).then(data => {
expect(data).assertFail();
}).catch(err => {
expect(err).assertEqual(1);
});
bundle.queryExtensionAbilityInfos(
{
"bundleName": BUNDLE_NAME1,
"abilityName": ABILITY_NAME1
}, bundle.ExtensionAbilityType.FORM, bundle.ExtensionFlag.GET_EXTENSION_INFO_DEFAULT, 1001, (err, data) => {
if (err) {
expect(err).assertEqual(1);
done();
return;
}
expect(data).assertFail();
done();
})
})
/*
* @tc.number: SUB_BMS_APPINFO_EXTENSION_0002
* @tc.name: test queryExtensionAbilityInfos api
* @tc.desc: test queryExtensionAbilityInfos get permissions flag
*/
it('SUB_BMS_APPINFO_EXTENSION_0002', 0, async function (done) {
await bundle.queryExtensionAbilityInfos({
"bundleName": BUNDLE_NAME1,
"abilityName": ABILITY_NAME1
}, bundle.ExtensionAbilityType.FORM, bundle.ExtensionFlag.GET_EXTENSION_INFO_WITH_PERMISSION, 100).then(data => {
expect(data[0].bundleName).assertEqual("ohos.acts.bundle.stage");
expect(data[0].moduleName).assertEqual("phone");
expect(data[0].name).assertEqual("ExtensionAbility1");
expect(data[0].labelId).assertLarger(0);
expect(data[0].descriptionId).assertLarger(0);
expect(data[0].iconId).assertEqual(0);
expect(data[0].isVisible).assertFalse();
expect(data[0].extensionAbilityType).assertEqual(0);
expect(data[0].permissions[0]).assertEqual("ohos.permission.GET_BUNDLE_INFO");
expect(data[0].enabled).assertTrue();
expect(data[0].readPermission).assertEqual("");
expect(data[0].writePermission).assertEqual("");
expect(data[0].metadata.length).assertEqual(0);
}).catch(err => {
expect(err).assertEqual(1);
});
bundle.queryExtensionAbilityInfos({
"bundleName": BUNDLE_NAME1,
"abilityName": ABILITY_NAME1
}, bundle.ExtensionAbilityType.FORM, bundle.ExtensionFlag.GET_EXTENSION_INFO_WITH_PERMISSION, 100, (err, data) => {
if (err) {
expect(err).assertEqual(1);
done();
return;
}
expect(data[0].bundleName).assertEqual("ohos.acts.bundle.stage");
expect(data[0].moduleName).assertEqual("phone");
expect(data[0].name).assertEqual("ExtensionAbility1");
expect(data[0].labelId).assertLarger(0);
expect(data[0].descriptionId).assertLarger(0);
expect(data[0].iconId).assertEqual(0);
expect(data[0].isVisible).assertFalse();
expect(data[0].extensionAbilityType).assertEqual(0);
expect(data[0].permissions[0]).assertEqual("ohos.permission.GET_BUNDLE_INFO");
expect(data[0].enabled).assertTrue();
expect(data[0].readPermission).assertEqual("");
expect(data[0].writePermission).assertEqual("");
expect(data[0].metadata.length).assertEqual(0);
done();
})
})
/*
* @tc.number: SUB_BMS_APPINFO_EXTENSION_0003
* @tc.name: test queryExtensionAbilityInfos api
* @tc.desc: test queryExtensionAbilityInfos with default flag
*/
it('SUB_BMS_APPINFO_EXTENSION_0003', 0, async function (done) {
await bundle.queryExtensionAbilityInfos(
{
"bundleName": BUNDLE_NAME1,
"abilityName": ABILITY_NAME1
}, bundle.ExtensionAbilityType.FORM, bundle.ExtensionFlag.GET_EXTENSION_INFO_DEFAULT,
100).then(data => {
expect(data[0].bundleName).assertEqual("ohos.acts.bundle.stage");
expect(data[0].moduleName).assertEqual("phone");
expect(data[0].name).assertEqual("ExtensionAbility1");
expect(data[0].labelId).assertLarger(0);
expect(data[0].descriptionId).assertLarger(0);
expect(data[0].iconId).assertEqual(0);
expect(data[0].isVisible).assertFalse();
expect(data[0].extensionAbilityType).assertEqual(0);
expect(data[0].permissions.length).assertEqual(0);
expect(data[0].enabled).assertTrue();
expect(data[0].readPermission).assertEqual("");
expect(data[0].writePermission).assertEqual("");
expect(data[0].metadata.length).assertEqual(0);
}).catch(err => {
expect(err).assertEqual(1);
});
bundle.queryExtensionAbilityInfos(
{
"bundleName": BUNDLE_NAME1,
"abilityName": ABILITY_NAME1
}, bundle.ExtensionAbilityType.FORM, bundle.ExtensionFlag.GET_EXTENSION_INFO_DEFAULT,
100, (err, data) => {
if (err) {
expect(err).assertEqual(1);
done();
return;
}
expect(data[0].bundleName).assertEqual("ohos.acts.bundle.stage");
expect(data[0].moduleName).assertEqual("phone");
expect(data[0].name).assertEqual("ExtensionAbility1");
expect(data[0].labelId).assertLarger(0);
expect(data[0].descriptionId).assertLarger(0);
expect(data[0].iconId).assertEqual(0);
expect(data[0].isVisible).assertFalse();
expect(data[0].extensionAbilityType).assertEqual(0);
expect(data[0].permissions.length).assertEqual(0);
expect(data[0].enabled).assertTrue();
expect(data[0].readPermission).assertEqual("");
expect(data[0].writePermission).assertEqual("");
expect(data[0].metadata.length).assertEqual(0);
done();
})
})
/*
* @tc.number: SUB_BMS_APPINFO_EXTENSION_0004
* @tc.name: test queryExtensionAbilityInfos api
* @tc.desc: test queryExtensionAbilityInfos with get application flag
*/
it('SUB_BMS_APPINFO_EXTENSION_0004', 0, async function (done) {
await bundle.queryExtensionAbilityInfos({
"bundleName": BUNDLE_NAME1,
"abilityName": ABILITY_NAME1
}, bundle.ExtensionAbilityType.FORM, bundle.ExtensionFlag.GET_EXTENSION_INFO_WITH_APPLICATION,
100).then(data => {
expect(data[0].bundleName).assertEqual("ohos.acts.bundle.stage");
expect(data[0].moduleName).assertEqual("phone");
expect(data[0].name).assertEqual("ExtensionAbility1");
expect(data[0].labelId).assertLarger(0);
expect(data[0].descriptionId).assertLarger(0);
expect(data[0].iconId).assertEqual(0);
expect(data[0].isVisible).assertFalse();
expect(data[0].extensionAbilityType).assertEqual(0);
expect(data[0].permissions.length).assertEqual(0);
expect(data[0].enabled).assertTrue();
expect(data[0].readPermission).assertEqual("");
expect(data[0].writePermission).assertEqual("");
expect(data[0].metadata.length).assertEqual(0);
checkApplication(data);
}).catch(err => {
expect(err).assertFail();
});
bundle.queryExtensionAbilityInfos({
"bundleName": BUNDLE_NAME1,
"abilityName": ABILITY_NAME1
}, bundle.ExtensionAbilityType.FORM, bundle.ExtensionFlag.GET_EXTENSION_INFO_WITH_APPLICATION,
100, (err, data) => {
if (err) {
expect(err).assertFail();
done();
return;
}
expect(data[0].bundleName).assertEqual("ohos.acts.bundle.stage");
expect(data[0].moduleName).assertEqual("phone");
expect(data[0].name).assertEqual("ExtensionAbility1");
expect(data[0].labelId).assertLarger(0);
expect(data[0].descriptionId).assertLarger(0);
expect(data[0].iconId).assertEqual(0);
expect(data[0].isVisible).assertFalse();
expect(data[0].extensionAbilityType).assertEqual(0);
expect(data[0].permissions.length).assertEqual(0);
expect(data[0].enabled).assertTrue();
expect(data[0].readPermission).assertEqual("");
expect(data[0].writePermission).assertEqual("");
expect(data[0].metadata.length).assertEqual(0);
checkApplication(data);
done();
})
})
/*
* @tc.number: SUB_BMS_APPINFO_EXTENSION_0005
* @tc.name: test queryExtensionAbilityInfos api
* @tc.desc: test queryExtensionAbilityInfos with invalid bundleName
*/
it('SUB_BMS_APPINFO_EXTENSION_0005', 0, async function (done) {
await bundle.queryExtensionAbilityInfos(
{
"bundleName": BUNDLE_NAME2,
"abilityName": ABILITY_NAME1
}, bundle.ExtensionAbilityType.FORM, bundle.ExtensionFlag.GET_EXTENSION_INFO_DEFAULT, 100).then(data => {
expect(data).assertFail();
}).catch(err => {
expect(err).assertEqual(1);
});
bundle.queryExtensionAbilityInfos(
{
"bundleName": BUNDLE_NAME2,
"abilityName": ABILITY_NAME1
}, bundle.ExtensionAbilityType.FORM, bundle.ExtensionFlag.GET_EXTENSION_INFO_DEFAULT, 100, (err, data) => {
if (err) {
expect(err).assertEqual(1);
done();
return;
}
expect(data).assertFail();
done();
})
})
/*
* @tc.number: SUB_BMS_APPINFO_EXTENSION_0006
* @tc.name: test queryExtensionAbilityInfos api
* @tc.desc: test queryExtensionAbilityInfos with invalid abilityName
*/
it('SUB_BMS_APPINFO_EXTENSION_0006', 0, async function (done) {
await bundle.queryExtensionAbilityInfos(
{
"bundleName": BUNDLE_NAME1,
"abilityName": ABILITY_NAME2
}, bundle.ExtensionAbilityType.FORM, bundle.ExtensionFlag.GET_EXTENSION_INFO_DEFAULT, 100).then(data => {
expect(data).assertFail();
}).catch(err => {
expect(err).assertEqual(1);
});
bundle.queryExtensionAbilityInfos(
{
"bundleName": BUNDLE_NAME1,
"abilityName": ABILITY_NAME2
}, bundle.ExtensionAbilityType.FORM, bundle.ExtensionFlag.GET_EXTENSION_INFO_DEFAULT, 100, (err, data) => {
if (err) {
expect(err).assertEqual(1);
done();
return;
}
expect(data).assertFail();
done();
})
})
/*
* @tc.number: SUB_BMS_APPINFO_EXTENSION_0007
* @tc.name: test queryExtensionAbilityInfos api
* @tc.desc: test queryExtensionAbilityInfos with invalid param
*/
it('SUB_BMS_APPINFO_EXTENSION_0007', 0, async function (done) {
await bundle.queryExtensionAbilityInfos(
{
"bundleName": BUNDLE_NAME1,
"abilityName": ABILITY_NAME1
}, bundle.ExtensionAbilityType.FORM, null, 100).then(data => {
expect(data).assertFail();
}).catch(err => {
expect(err).assertEqual(1);
});
await bundle.queryExtensionAbilityInfos(
{
"bundleName": BUNDLE_NAME1,
"abilityName": ABILITY_NAME1
}, bundle.ExtensionAbilityType.FORM, bundle.ExtensionFlag.GET_EXTENSION_INFO_DEFAULT, null).then(data => {
expect(data).assertFail();
}).catch(err => {
expect(err).assertEqual(1);
});
bundle.queryExtensionAbilityInfos(
{
"bundleName": BUNDLE_NAME1,
"abilityName": ABILITY_NAME1
}, bundle.ExtensionAbilityType.FORM, null, 100, (err, data) => {
expect(err).assertEqual(1);
expect(data).assertEqual("type mismatch");
done();
})
})
/*
* @tc.number: SUB_BMS_APPINFO_EXTENSION_0008
* @tc.name: test queryExtensionAbilityInfos api
* @tc.desc: test queryExtensionAbilityInfos with get metaData flag and no userId
*/
it('SUB_BMS_APPINFO_EXTENSION_0008', 0, async function (done) {
await bundle.queryExtensionAbilityInfos({
"bundleName": BUNDLE_NAME1,
"abilityName": ABILITY_NAME1
}, bundle.ExtensionAbilityType.FORM, bundle.ExtensionFlag.GET_EXTENSION_INFO_WITH_METADATA).then(data => {
expect(data[0].bundleName).assertEqual("ohos.acts.bundle.stage");
expect(data[0].moduleName).assertEqual("phone");
expect(data[0].name).assertEqual("ExtensionAbility1");
expect(data[0].labelId).assertLarger(0);
expect(data[0].descriptionId).assertLarger(0);
expect(data[0].iconId).assertEqual(0);
expect(data[0].isVisible).assertFalse();
expect(data[0].extensionAbilityType).assertEqual(0);
expect(data[0].permissions.length).assertEqual(0);
expect(data[0].enabled).assertTrue();
expect(data[0].readPermission).assertEqual("");
expect(data[0].writePermission).assertEqual("");
expect(data[0].metadata[0].name).assertEqual("ohos.extension.form");
expect(data[0].metadata[0].value).assertEqual("");
expect(data[0].metadata[0].resource).assertEqual("$profile:form_config");
}).catch(err => {
expect(err).assertFail();
});
bundle.queryExtensionAbilityInfos({
"bundleName": BUNDLE_NAME1,
"abilityName": ABILITY_NAME1
}, bundle.ExtensionAbilityType.FORM, bundle.ExtensionFlag.GET_EXTENSION_INFO_WITH_METADATA, (err, data) => {
if (err) {
expect(err).assertFail();
done();
return;
}
expect(data[0].bundleName).assertEqual("ohos.acts.bundle.stage");
expect(data[0].moduleName).assertEqual("phone");
expect(data[0].name).assertEqual("ExtensionAbility1");
expect(data[0].labelId).assertLarger(0);
expect(data[0].descriptionId).assertLarger(0);
expect(data[0].iconId).assertEqual(0);
expect(data[0].isVisible).assertFalse();
expect(data[0].extensionAbilityType).assertEqual(0);
expect(data[0].permissions.length).assertEqual(0);
expect(data[0].enabled).assertTrue();
expect(data[0].readPermission).assertEqual("");
expect(data[0].writePermission).assertEqual("");
expect(data[0].metadata[0].name).assertEqual("ohos.extension.form");
expect(data[0].metadata[0].value).assertEqual("");
expect(data[0].metadata[0].resource).assertEqual("$profile:form_config");
done();
})
})
function checkApplication(data) {
expect(data[0].applicationInfo.name).assertEqual("ohos.acts.bundle.stage");
expect(data[0].applicationInfo.codePath).assertEqual("/data/app/el1/bundle/public/ohos.acts.bundle.stage");
expect(data[0].applicationInfo.accessTokenId).assertLarger(0);
expect(data[0].applicationInfo.description).assertEqual("$string:description_application");
expect(data[0].applicationInfo.descriptionId).assertLarger(0);
expect(data[0].applicationInfo.icon).assertEqual("$media:icon");
expect(data[0].applicationInfo.iconId).assertLarger(0);
expect(data[0].applicationInfo.label).assertEqual("$string:app_name");
expect(data[0].applicationInfo.labelId).assertLarger(0);
expect(data[0].applicationInfo.systemApp).assertTrue();
expect(data[0].applicationInfo.supportedModes).assertEqual(0);
expect(data[0].applicationInfo.process).assertEqual("");
expect(data[0].applicationInfo.entryDir).assertEqual("/data/app/el1/bundle/public/ohos.acts.bundle.stage/phone");
expect(data[0].applicationInfo.permissions.length).assertEqual(0);
expect(data[0].applicationInfo.moduleSourceDirs[0]).assertEqual("/data/app/el1/bundle/public/ohos.acts.bundle.stage/phone");
expect(data[0].applicationInfo.moduleInfos[0].moduleName).assertEqual("phone");
expect(data[0].applicationInfo.moduleInfos[0].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/ohos.acts.bundle.stage/phone");
expect(JSON.stringify(data[0].applicationInfo.metaData)).assertEqual("{}");
expect(JSON.stringify(data[0].applicationInfo.metadata)).assertEqual("{}");
expect(data[0].applicationInfo.enabled).assertTrue();
expect(data[0].applicationInfo.flags).assertEqual(0);
expect(data[0].applicationInfo.uid).assertLarger(0);
expect(data[0].applicationInfo.entityType).assertEqual("unspecified");
expect(data[0].applicationInfo.removable).assertTrue();
expect(data[0].applicationInfo.fingerprint).assertEqual("");
}
})
}
......@@ -33,7 +33,7 @@ const BUNDLE_NAME = 'com.open.harmony.packagemag';
const BUNDLE_NAME_OTHER = 'com.ohos.acepackage';
const USER_ID_100 = 100;
export default function applicationBundleJsunit() {
export default function getApplicationInfoJsunit() {
describe('appInfoTest', function () {
......
{
"app":{
"bundleName":"ohos.acts.bundle.stage",
"vendor":"huawei",
"versionCode":1000000,
"versionName":"1.0.0",
"debug":false,
"icon":"$media:icon",
"label":"$string:app_name",
"description":"$string:description_application",
"distributedNotificationEnabled":true,
"keepAlive":true,
"singleUser":true,
"minAPIVersion":8,
"targetAPIVersion":8,
"car":{
"apiCompatibleVersion":8,
"singleUser":false
}
}
}
{
"string":[
{
"name":"app_name",
"value":"ohosProject"
}
]
}
\ No newline at end of file
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("bmsStageDemo1") {
hap_profile = "entry/src/main/module.json"
deps = [
":bmsstagedemoone_js_assets",
":bmsstagedemoone_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "bmsStageDemo1"
testonly = true
}
ohos_app_scope("bmsstagedemoone_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("bmsstagedemoone_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("bmsstagedemoone_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":bmsstagedemoone_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
}
import AbilityStage from "@ohos.application.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("[Demo] MyAbilityStage onCreate")
globalThis.stageOnCreateRun = 1;
globalThis.stageContext = this.context;
}
}
import FormExtension from '@ohos.application.FormExtension';
import formBindingData from '@ohos.application.formBindingData';
import formInfo from '@ohos.application.formInfo';
export default class FormAbility extends FormExtension {
onCreate(want) {
// Called to return a FormBindingData object.
let formData = {};
return formBindingData.createFormBindingData(formData);
}
onCastToNormal(formId) {
// Called when the form provider is notified that a temporary form is successfully
// converted to a normal form.
}
onUpdate(formId) {
// Called to notify the form provider to update a specified form.
}
onVisibilityChange(newStatus) {
// Called when the form provider receives form events from the system.
}
onEvent(formId, message) {
// Called when a specified message event defined by the form provider is triggered.
}
onDestroy(formId) {
// Called to notify the form provider that a specified form has been destroyed.
}
onAcquireFormState(want) {
// Called to return a {@link FormState} object.
return formInfo.FormState.READY;
}
};
\ No newline at end of file
import Ability from '@ohos.application.Ability'
export default class MainAbility extends Ability {
onCreate(want,launchParam){
// Ability is creating, initialize resources for this ability
console.log("[Demo] MainAbility onCreate")
globalThis.abilityWant = want;
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("[Demo] MainAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] MainAbility onWindowStageCreate")
globalThis.abilityContext = this.context
windowStage.setUIContent(this.context, "pages/index/index", null)
}
onWindowStageDestroy() {
//Main window is destroyed, release UI related resources
console.log("[Demo] MainAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] MainAbility onForeground")
}
onBackground() {
// Ability has back to background
console.log("[Demo] MainAbility onBackground")
}
};
\ No newline at end of file
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import file from '@system.file';
import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index.ets"
import testsuite from "../../test/List.test.ets"
@Entry
@Component
struct Index {
aboutToAppear(){
console.info("start run testcase!!!!")
const core = Core.getInstance()
const expectExtend = new ExpectExtend({
'id': 'extend'
})
core.addService('expect', expectExtend)
const reportExtend = new ReportExtend(file)
core.addService('report', reportExtend)
core.init()
core.subscribeEvent('task', reportExtend)
const configService = core.getDefaultService('config')
console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters))
globalThis.abilityWant.parameters.timeout = 70000;
configService.setConfig(globalThis.abilityWant.parameters)
testsuite(globalThis.abilityContext)
core.execute()
}
build() {
Flex({ direction:FlexDirection.Column, alignItems:ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('Hello World')
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('next page')
.fontSize(25)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.onClick(() => {
})
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
/*
* Copyright (c) 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 router from '@system.router';
@Entry
@Component
struct Second {
private content: string = "Second Page"
build() {
Flex({ direction: FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text(`${this.content}`)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('back to index')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.onClick(() => {
router.back()
})
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export default function testsuite(context) {
}
\ No newline at end of file
{
"module": {
"name": "phone",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
"phone"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"abilities": [
{
"name": "ohos.acts.bundle.stage.MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"orientation": "portrait",
"visible": true,
"skills": [
{
"actions": [
"action.system.home"
],
"entities":[
"entity.system.home"
]
}
]
}
],
"extensionAbilities": [
{
"name": "FormAbility",
"srcEntrance": "./ets/FormAbility/FormAbility.ts",
"label": "$string:form_FormAbility_label",
"description": "$string:form_FormAbility_desc",
"type": "form",
"metadata": [
{
"name": "ohos.extension.form",
"resource": "$profile:form_config"
}
],
"permissions": ["ohos.permission.GET_BUNDLE_INFO"]
},
{
"name": "ExtensionAbility1",
"srcEntrance": "./ets/FormAbility/FormAbility.ts",
"label": "$string:form_FormAbility_label",
"description": "$string:form_FormAbility_desc",
"type": "form",
"metadata": [
{
"name": "ohos.extension.form",
"resource": "$profile:form_config"
}
],
"permissions": ["ohos.permission.GET_BUNDLE_INFO"]
}
]
}
}
{
"string": [
{
"name": "phone_entry_dsc",
"value": "i am an entry for phone"
},
{
"name": "phone_entry_main",
"value": "the phone entry ability"
},
{
"name": "entry_label",
"value": "ActsContextTest"
},
{
"name": "form_description",
"value": "my form"
},
{
"name": "serviceability_description",
"value": "my whether"
},
{
"name": "description_application",
"value": "demo for test"
},
{
"name": "app_name",
"value": "Demo"
},
{
"name": "form_FormAbility_desc",
"value": "form_description"
},
{
"name": "form_FormAbility_label",
"value": "form_label"
}
]
}
{
"forms": [
{
"isDefault": true,
"src": "./js/widget/pages/index/index",
"scheduledUpdateTime": "10:30",
"defaultDimension": "2*2",
"name": "widget",
"description": "This is a service widget.",
"colorMode": "auto",
"window": {
"designWidth": 720,
"autoDesignWidth": true
},
"formConfigAbility": "ability://xxxxx",
"supportDimensions": [
"2*2"
],
"updateEnabled": true,
"updateDuration": 1
},
{
"isDefault": true,
"src": "./js/widget1/pages/index/index",
"scheduledUpdateTime": "10:30",
"defaultDimension": "2*2",
"name": "widget1",
"description": "This is a service widget.",
"colorMode": "auto",
"window": {
"designWidth": 720,
"autoDesignWidth": true
},
"formConfigAbility": "ability://xxxxx",
"supportDimensions": [
"1*2",
"2*2"
],
"updateEnabled": true,
"updateDuration": 1
},
{
"isDefault": true,
"src": "./js/widget2/pages/index/index",
"scheduledUpdateTime": "10:30",
"defaultDimension": "2*2",
"name": "widget2",
"description": "This is a service widget.",
"colorMode": "auto",
"window": {
"designWidth": 720,
"autoDesignWidth": true
},
"formConfigAbility": "ability://xxxxx",
"supportDimensions": [
"2*2"
],
"updateEnabled": true,
"updateDuration": 1
},
{
"isDefault": true,
"src": "./js/widget3/pages/index/index",
"scheduledUpdateTime": "10:30",
"defaultDimension": "2*2",
"name": "widget3",
"description": "This is a service widget.",
"colorMode": "auto",
"window": {
"designWidth": 720,
"autoDesignWidth": true
},
"formConfigAbility": "ability://xxxxx",
"supportDimensions": [
"2*2"
],
"updateEnabled": true,
"updateDuration": 1
}
]
}
\ No newline at end of file
......@@ -263,7 +263,7 @@ it('ACTS_ZipFile_2300', 0, async function (done) {
done();
})
}).catch(function (err) {
console.info("ACTS_ZipFile_2200 write data to file failed with error:" + err);
console.info("ACTS_ZipFile_2300 write data to file failed with error:" + err);
expect(err).assertFail();
done();
});
......@@ -813,7 +813,7 @@ it('ACTS_ZipFile_3200', 0, async function (done) {
/*
* @tc.number: ACTS_ZipFile_3300
* @tc.name: zipFile
* @tc.desc: COMPRESS_STRATEGY_FILTERED,,
* @tc.desc: COMPRESS_STRATEGY_FIXED,,
*/
it('ACTS_ZipFile_3300', 0, async function (done) {
console.log("==================ACTS_ZipFile_3300 start==================");
......@@ -822,7 +822,7 @@ it('ACTS_ZipFile_3300', 0, async function (done) {
var unzipdir = dir + "/ACTS_ZipFile_3300";
var unzipresultfile = unzipdir + "/ACTS_ZipFile_3300.txt";
var options = {};
options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_FILTERED;
options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_FIXED;
var fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
fileio.write(fd, infos).then(function (number) {
console.info("ACTS_ZipFile_3300 write data to file successfully:" + number);
......@@ -873,7 +873,7 @@ it('ACTS_ZipFile_3300', 0, async function (done) {
/*
* @tc.number: ACTS_ZipFile_3500
* @tc.name: zipFile
* @tc.desc: FLUSH_TYPE_NO_FLUSH,,
* @tc.desc: INPUT_FILE_NOT_EXIST,,
*/
it('ACTS_ZipFile_3500', 0, async function (done) {
console.log("==================ACTS_ZipFile_3500 start==================");
......@@ -905,7 +905,7 @@ it('ACTS_ZipFile_3500', 0, async function (done) {
/*
* @tc.number: ACTS_ZipFile_3600
* @tc.name: zipFile
* @tc.desc: FLUSH_TYPE_NO_FLUSH,,
* @tc.desc: INPUT_FILE_NULL,,
*/
it('ACTS_ZipFile_3600', 0, async function (done) {
console.log("==================ACTS_ZipFile_3600 start==================");
......@@ -936,7 +936,7 @@ it('ACTS_ZipFile_3600', 0, async function (done) {
/*
* @tc.number: ACTS_ZipFile_4500
* @tc.name: zipFile
* @tc.desc: COMPRESS_STRATEGY_FILTERED,,
* @tc.desc: COMPRESS_STRATEGY_FILTERED_CALLBACK,,
*/
it('ACTS_ZipFile_4500', 0, async function (done) {
console.log("==================ACTS_ZipFile_4500 start==================");
......@@ -975,7 +975,7 @@ it('ACTS_ZipFile_4500', 0, async function (done) {
done();
});
}).catch((err) => {
console.log("zipFile fail: " + err);
console.log("ACTS_ZipFile_4500 zipFile fail: " + err);
expect(err).assertFail();
done();
})
......@@ -990,7 +990,7 @@ it('ACTS_ZipFile_4500', 0, async function (done) {
/*
* @tc.number: ACTS_ZipFile_4900
* @tc.name: zipFile
* @tc.desc: COMPRESS_STRATEGY_FILTERED,
* @tc.desc: COMPRESS_STRATEGY_FILTERED_PROMISE,
*/
it('ACTS_ZipFile_4900', 0, async function (done) {
console.log("==================ACTS_ZipFile_4900 start==================");
......@@ -1019,7 +1019,7 @@ it('ACTS_ZipFile_4900', 0, async function (done) {
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
done();
}).catch(err => {
console.log("unzipFile fail: " + err);
console.log("ACTS_ZipFile_4900 err: " + err);
expect(err).assertFail();
done();
})
......@@ -1029,7 +1029,7 @@ it('ACTS_ZipFile_4900', 0, async function (done) {
done();
});
}).catch(err => {
console.log("zipFile fail: " + err);
console.log("ACTS_ZipFile_4900 zipFile fail: " + err);
expect(err).assertFail();
done();
})
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册