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

!3871 增加测试用例

Merge pull request !3871 from shilei91/master
......@@ -25,6 +25,7 @@ group("bundlemanager") {
"actsbmsjstest:ActsBmsJsTest",
"actsbmsjsunpermissiontest:ActsBmsJsUnPermissionTest",
"actsbmsmetadatatest:ActsBmsMetaDataTest",
"actsbmsstageetstest:ActBmsStageEtsTest",
"actsbundlemanageretstest:ActsBundleManagerEtsTest",
"actsbundlemanagertest:ActsBundleManagerTest",
"sceneProject/bmsaccesstokenfive:bmsAccessTokenTest5",
......
{
"app":{
"bundleName":"ohos.acts.bundle.stage.test",
"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) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActBmsStageEtsTest") {
hap_profile = "entry/src/main/module.json"
deps = [
":actbmsstageetstest_js_assets",
":actbmsstageetstest_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActBmsStageEtsTest"
}
ohos_app_scope("actbmsstageetstest_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("actbmsstageetstest_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("actbmsstageetstest_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":actbmsstageetstest_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "180000",
"package": "ohos.acts.bundle.stage.test",
"shell-timeout": "600000"
},
"kits": [
{
"test-file-name": [
"ActBmsStageEtsTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"teardown-command":[
"bm uninstall -n ohos.acts.bundle.stage.test"
]
}
]
}
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
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
/*
* 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"
@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) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import router from '@system.router';
@Entry
@Component
struct Second {
private content: string = "Second Page"
build() {
Flex({ direction: FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text(`${this.content}`)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('back to index')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.onClick(() => {
router.back()
})
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
/**
* Copyright (c) 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, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index"
const MODULE_NAME = "phone"
const MODULE_NAME_TEST = "phone1"
const ABILITY_NAME = "ohos.acts.bundle.stage.test.MainAbility"
const ABILITY_NAME1 = "ohos.acts.bundle.stage.test.MainAbility1"
const ABILITY_NAME_TEST = "ohos.acts.bundle.stage.test.MainAbilityTest"
const METADATA_NAME = "ohos.ability.form"
const METADATA_NAME1 = "ohos.ability.form1"
const METADATA_NAME2 = "ohos.ability.form2"
const METADATA_NAME3 = "ohos.ability.form3"
const METADATA_NAME_TEST = "ohos.test.form"
const PROFILE_JSON_STRING = "{\"src\":[\"pages/index/index\",\"pages/second/second\"]}"
export default function getProfileByAbility() {
describe('getProfileByAbility', function () {
/*
* @tc.number: getProfileByAbility_0400
* @tc.name: getProfileByAbility : The profile is obtained by specified ability
* @tc.desc: Check the invalid moduleName (by promise)
* @tc.level 0
*/
it('getProfileByAbility_0400', 0, async function (done) {
await bundle.getProfileByAbility(MODULE_NAME_TEST, ABILITY_NAME, METADATA_NAME).then(data => {
console.info("getProfileByAbility_0400 success" + JSON.stringify(data))
expect(data).assertFail()
done()
}).catch(err => {
console.info("getProfileByAbility_0400 failed" + JSON.stringify(err))
expect(err).assertEqual(1)
done()
})
})
/*
* @tc.number: getProfileByAbility_0500
* @tc.name: getProfileByAbility : The profile is obtained by specified ability
* @tc.desc: Check the invalid moduleName (by promise)
* @tc.level 0
*/
it('getProfileByAbility_0500', 0, async function (done) {
await bundle.getProfileByAbility('', ABILITY_NAME, METADATA_NAME).then(data => {
console.info("getProfileByAbility_0500 success" + JSON.stringify(data))
expect(data).assertFail()
done()
}).catch(err => {
console.info("getProfileByAbility_0500 failed" + JSON.stringify(err))
expect(err).assertEqual(1)
done()
})
})
/*
* @tc.number: getProfileByAbility_0600
* @tc.name: getProfileByAbility : The profile is obtained by specified ability
* @tc.desc: Check the invalid moduleName (by callback)
* @tc.level 0
*/
it('getProfileByAbility_0600', 0, async function (done) {
bundle.getProfileByAbility(MODULE_NAME_TEST, ABILITY_NAME, METADATA_NAME, (err, data) => {
if (err) {
console.error('[getProfileByAbility_0600]Operation failed. Cause: ' + JSON.stringify(err));
expect(err).assertEqual(1);
}
console.info('[getProfileByAbility_0600] getApplicationInfo callback data is: ' + JSON.stringify(data));
expect(typeof data).assertEqual("string");
expect(data).assertEqual("GetProfile failed");
done();
});
})
/*
* @tc.number: getProfileByAbility_0700
* @tc.name: getProfileByAbility : The profile is obtained by specified ability
* @tc.desc: Check the invalid moduleName (by callback)
* @tc.level 0
*/
it('getProfileByAbility_0700', 0, async function (done) {
bundle.getProfileByAbility('', ABILITY_NAME, METADATA_NAME, (err, data) => {
if (err) {
console.error('[getProfileByAbility_0700]Operation failed. Cause: ' + JSON.stringify(err));
expect(err).assertEqual(1);
}
console.info('[getProfileByAbility_0700] getApplicationInfo callback data is: ' + JSON.stringify(data));
expect(typeof data).assertEqual("string");
expect(data).assertEqual("GetProfile failed");
done();
});
})
/*
* @tc.number: getProfileByAbility_0800
* @tc.name: getProfileByAbility : The profile is obtained by specified ability
* @tc.desc: Check the invalid abilityName (by promise)
* @tc.level 0
*/
it('getProfileByAbility_0800', 0, async function (done) {
await bundle.getProfileByAbility(MODULE_NAME, ABILITY_NAME_TEST, METADATA_NAME).then(data => {
console.info("getProfileByAbility_0800 success" + JSON.stringify(data))
expect(data).assertFail()
done()
}).catch(err => {
console.info("getProfileByAbility_0800 failed" + JSON.stringify(err))
expect(err).assertEqual(1)
done()
})
})
/*
* @tc.number: getProfileByAbility_0900
* @tc.name: getProfileByAbility : The profile is obtained by specified ability
* @tc.desc: Check the invalid abilityName (by promise)
* @tc.level 0
*/
it('getProfileByAbility_0900', 0, async function (done) {
await bundle.getProfileByAbility(MODULE_NAME, '', METADATA_NAME).then(data => {
console.info("getProfileByAbility_0900 success" + JSON.stringify(data))
expect(data).assertFail()
done()
}).catch(err => {
console.info("getProfileByAbility_0900 failed" + JSON.stringify(err))
expect(err).assertEqual(1)
done()
})
})
/*
* @tc.number: getProfileByAbility_1000
* @tc.name: getProfileByAbility : The profile is obtained by specified ability
* @tc.desc: Check the invalid abilityName (by callback)
* @tc.level 0
*/
it('getProfileByAbility_1000', 0, async function (done) {
bundle.getProfileByAbility(MODULE_NAME, ABILITY_NAME_TEST, METADATA_NAME, (err, data) => {
if (err) {
console.error('[getProfileByAbility_1000]Operation failed. Cause: ' + JSON.stringify(err));
expect(err).assertEqual(1);
}
console.info('[getProfileByAbility_1000] getApplicationInfo callback data is: ' + JSON.stringify(data));
expect(typeof data).assertEqual("string");
expect(data).assertEqual("GetProfile failed");
done();
});
})
/*
* @tc.number: getProfileByAbility_1100
* @tc.name: getProfileByAbility : The profile is obtained by specified ability
* @tc.desc: Check the invalid abilityName (by callback)
* @tc.level 0
*/
it('getProfileByAbility_1100', 0, async function (done) {
bundle.getProfileByAbility(MODULE_NAME, '', METADATA_NAME, (err, data) => {
if (err) {
console.error('[getProfileByAbility_1100]Operation failed. Cause: ' + JSON.stringify(err));
expect(err).assertEqual(1);
}
console.info('[getProfileByAbility_1100] getApplicationInfo callback data is: ' + JSON.stringify(data));
expect(typeof data).assertEqual("string");
expect(data).assertEqual("GetProfile failed");
done();
});
})
/*
* @tc.number: getProfileByAbility_1200
* @tc.name: getProfileByAbility : The profile is obtained by specified ability
* @tc.desc: Check the valid metadataName (by callback)
* @tc.level 0
*/
it('getProfileByAbility_1200', 0, async function (done) {
bundle.getProfileByAbility(MODULE_NAME, ABILITY_NAME, METADATA_NAME, (err, data) => {
if (err) {
console.error('[getProfileByAbility_1200]Operation failed. Cause: ' + JSON.stringify(err));
expect(err).assertEqual(1);
}
console.info('[getProfileByAbility_1200] getApplicationInfo callback data is: ' + JSON.stringify(data));
expect(Array.isArray(data)).assertTrue();
expect(typeof data[0]).assertEqual("string");
expect(data[0]).assertEqual(PROFILE_JSON_STRING);
done();
});
})
/*
* @tc.number: getProfileByAbility_1300
* @tc.name: getProfileByAbility : The profile is obtained by specified ability
* @tc.desc: Check the invalid metadataName (by callback)
* @tc.level 0
*/
it('getProfileByAbility_1300', 0, async function (done) {
bundle.getProfileByAbility(MODULE_NAME, ABILITY_NAME, METADATA_NAME_TEST, (err, data) => {
if (err) {
console.error('[getProfileByAbility_1300]Operation failed. Cause: ' + JSON.stringify(err));
expect(err).assertEqual(1);
}
console.info('[getProfileByAbility_1300] getApplicationInfo callback data is: ' + JSON.stringify(data));
expect(typeof data).assertEqual("string");
expect(data).assertEqual("GetProfile failed");
done();
});
})
/*
* @tc.number: getProfileByAbility_1400
* @tc.name: getProfileByAbility : The profile is obtained by specified ability
* @tc.desc: Check the empty metadataName (by callback)
* @tc.level 0
*/
it('getProfileByAbility_1400', 0, async function (done) {
bundle.getProfileByAbility(MODULE_NAME, ABILITY_NAME, '', (err, data) => {
if (err) {
console.error('[getProfileByAbility_1400]Operation failed. Cause: ' + JSON.stringify(err));
expect(err).assertEqual(1);
}
console.info('[getProfileByAbility_1400] getApplicationInfo callback data is: ' + JSON.stringify(data));
expect(Array.isArray(data)).assertTrue();
expect(typeof data[0]).assertEqual("string");
expect(data[0]).assertEqual(PROFILE_JSON_STRING);
expect(typeof data[1]).assertEqual("string");
expect(data[1]).assertEqual(PROFILE_JSON_STRING);
done();
});
})
/*
* @tc.number: getProfileByAbility_1500
* @tc.name: getProfileByAbility : The profile is obtained by specified ability
* @tc.desc: Check the valid metadataName (by promise)
* @tc.level 0
*/
it('getProfileByAbility_1500', 0, async function (done) {
await bundle.getProfileByAbility(MODULE_NAME, ABILITY_NAME, METADATA_NAME).then(data => {
console.info('[getProfileByAbility_1500] getApplicationInfo callback data is: ' + JSON.stringify(data));
expect(Array.isArray(data)).assertTrue();
expect(typeof data[0]).assertEqual("string");
expect(data[0]).assertEqual(PROFILE_JSON_STRING);
done();
}).catch(err => {
console.error('[getProfileByAbility_1500]Operation failed. Cause: ' + JSON.stringify(err));
expect(err).assertEqual(1);
done();
})
})
/*
* @tc.number: getProfileByAbility_1600
* @tc.name: getProfileByAbility : The profile is obtained by specified ability
* @tc.desc: Check the invalid metadataName (by promise)
* @tc.level 0
*/
it('getProfileByAbility_1600', 0, async function (done) {
await bundle.getProfileByAbility(MODULE_NAME, ABILITY_NAME, METADATA_NAME_TEST).then(data => {
console.info('[getProfileByAbility_1600] getApplicationInfo callback data is: ' + JSON.stringify(data));
expect(data).assertFail()
done()
}).catch(err => {
console.error('[getProfileByAbility_1600]Operation failed. Cause: ' + JSON.stringify(err));
expect(err).assertEqual(1);
done();
})
})
/*
* @tc.number: getProfileByAbility_1700
* @tc.name: getProfileByAbility : The profile is obtained by specified ability
* @tc.desc: Check the empty metadataName (by promise)
* @tc.level 0
*/
it('getProfileByAbility_1700', 0, async function (done) {
await bundle.getProfileByAbility(MODULE_NAME, ABILITY_NAME, '').then(data => {
console.info('[getProfileByAbility_1700] getApplicationInfo callback data is: ' + JSON.stringify(data));
expect(Array.isArray(data)).assertTrue();
expect(typeof data[0]).assertEqual("string");
expect(data[0]).assertEqual(PROFILE_JSON_STRING);
expect(typeof data[1]).assertEqual("string");
expect(data[1]).assertEqual(PROFILE_JSON_STRING);
done();
}).catch(err => {
console.error('[getProfileByAbility_1700]Operation failed. Cause: ' + JSON.stringify(err));
expect(err).assertEqual(1);
done();
})
})
/*
* @tc.number: getProfileByAbility_1800
* @tc.name: getProfileByAbility : The profile is obtained by specified ability
* @tc.desc: without metadataName (by promise)
* @tc.level 0
*/
it('getProfileByAbility_1800', 0, async function (done) {
await bundle.getProfileByAbility(MODULE_NAME, ABILITY_NAME).then(data => {
console.info('[getProfileByAbility_1800] getApplicationInfo callback data is: ' + JSON.stringify(data));
expect(Array.isArray(data)).assertTrue();
expect(typeof data[0]).assertEqual("string");
expect(data[0]).assertEqual(PROFILE_JSON_STRING);
expect(typeof data[1]).assertEqual("string");
expect(data[1]).assertEqual(PROFILE_JSON_STRING);
done();
}).catch(err => {
console.error('[getProfileByAbility_1800]Operation failed. Cause: ' + JSON.stringify(err));
expect(err).assertEqual(1);
done();
})
})
/*
* @tc.number: getProfileByAbility_1900
* @tc.name: getProfileByAbility : The profile is obtained by specified ability
* @tc.desc: no profile configured under the ability (by promise)
* @tc.level 0
*/
it('getProfileByAbility_1900', 0, async function (done) {
await bundle.getProfileByAbility(MODULE_NAME, ABILITY_NAME1).then(data => {
console.info('[getProfileByAbility_1900] getApplicationInfo callback data is: ' + JSON.stringify(data));
expect(data).assertFail()
done();
}).catch(err => {
console.error('[getProfileByAbility_1900]Operation failed. Cause: ' + JSON.stringify(err));
expect(err).assertEqual(1);
done();
})
})
/*
* @tc.number: getProfileByAbility_2000
* @tc.name: getProfileByAbility : The profile is obtained by specified ability
* @tc.desc: resource has no prefix '$profile:' (by promise)
* @tc.level 0
*/
it('getProfileByAbility_2000', 0, async function (done) {
await bundle.getProfileByAbility(MODULE_NAME, ABILITY_NAME, METADATA_NAME2).then(data => {
console.info('[getProfileByAbility_2000] getApplicationInfo callback data is: ' + JSON.stringify(data));
expect(data).assertFail()
done();
}).catch(err => {
console.error('[getProfileByAbility_2000]Operation failed. Cause: ' + JSON.stringify(err));
expect(err).assertEqual(1);
done();
})
})
/*
* @tc.number: getProfileByAbility_2100
* @tc.name: getProfileByAbility : The profile is obtained by specified ability
* @tc.desc: resource has no prefix '$profile:' (by callback)
* @tc.level 0
*/
it('getProfileByAbility_2100', 0, async function (done) {
bundle.getProfileByAbility(MODULE_NAME, ABILITY_NAME, METADATA_NAME2, (err, data) => {
if (err) {
console.error('[getProfileByAbility_2100]Operation failed. Cause: ' + JSON.stringify(err));
expect(err).assertEqual(1);
}
console.info('[getProfileByAbility_2100] getApplicationInfo callback data is: ' + JSON.stringify(data));
expect(typeof data).assertEqual("string");
expect(data).assertEqual("GetProfile failed");
done();
});
})
/*
* @tc.number: getProfileByAbility_2200
* @tc.name: getProfileByAbility : The profile is obtained by specified ability
* @tc.desc: profile is not json-format (by promise)
* @tc.level 0
*/
it('getProfileByAbility_2200', 0, async function (done) {
await bundle.getProfileByAbility(MODULE_NAME, ABILITY_NAME, METADATA_NAME3).then(data => {
console.info('[getProfileByAbility_2200] getApplicationInfo callback data is: ' + JSON.stringify(data));
expect(data).assertFail()
done();
}).catch(err => {
console.error('[getProfileByAbility_2200]Operation failed. Cause: ' + JSON.stringify(err));
expect(err).assertEqual(1);
done();
})
})
/*
* @tc.number: getProfileByAbility_2300
* @tc.name: getProfileByAbility : The profile is obtained by specified ability
* @tc.desc: profile is not json-format (by callback)
* @tc.level 0
*/
it('getProfileByAbility_2300', 0, async function (done) {
bundle.getProfileByAbility(MODULE_NAME, ABILITY_NAME, METADATA_NAME3, (err, data) => {
if (err) {
console.error('[getProfileByAbility_2300]Operation failed. Cause: ' + JSON.stringify(err));
expect(err).assertEqual(1);
}
console.info('[getProfileByAbility_2300] getApplicationInfo callback data is: ' + JSON.stringify(data));
expect(typeof data).assertEqual("string");
expect(data).assertEqual("GetProfile failed");
done();
});
})
})
}
\ No newline at end of file
/**
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import bundle from '@ohos.bundle';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index"
const MODULE_NAME = "phone"
const MODULE_NAME_TEST = "phone1"
const ABILITY_NAME = "Form"
const ABILITY_NAME1 = "Form1"
const ABILITY_NAME_TEST = "FromTest"
const METADATA_NAME = "ohos.extension.form"
const METADATA_NAME1 = "ohos.extension.form1"
const METADATA_NAME2 = "ohos.extension.form2"
const METADATA_NAME3 = "ohos.extension.form3"
const METADATA_NAME_TEST = "ohos.test.form"
const PROFILE_JSON_STRING = "{\"src\":[\"pages/index/index\",\"pages/second/second\"]}"
export default function getProfileByExtensionAbility() {
describe('getProfileByExtensionAbility', function () {
/*
* @tc.number: getProfileByExtensionAbility_0400
* @tc.name: getProfileByExtensionAbility : The profile is obtained by specified ability
* @tc.desc: Check the invalid moduleName (by promise)
* @tc.level 0
*/
it('getProfileByExtensionAbility_0400', 0, async function (done) {
await bundle.getProfileByExtensionAbility(MODULE_NAME_TEST, ABILITY_NAME, METADATA_NAME).then(data => {
console.info("getProfileByExtensionAbility_0400 success" + JSON.stringify(data))
expect(data).assertFail()
done()
}).catch(err => {
console.info("getProfileByExtensionAbility_0400 failed" + JSON.stringify(err))
expect(err).assertEqual(1)
done()
})
})
/*
* @tc.number: getProfileByExtensionAbility_0500
* @tc.name: getProfileByExtensionAbility : The profile is obtained by specified ability
* @tc.desc: Check the invalid moduleName (by promise)
* @tc.level 0
*/
it('getProfileByExtensionAbility_0500', 0, async function (done) {
await bundle.getProfileByExtensionAbility('', ABILITY_NAME, METADATA_NAME).then(data => {
console.info("getProfileByExtensionAbility_0500 success" + JSON.stringify(data))
expect(data).assertFail()
done()
}).catch(err => {
console.info("getProfileByExtensionAbility_0500 failed" + JSON.stringify(err))
expect(err).assertEqual(1)
done()
})
})
/*
* @tc.number: getProfileByExtensionAbility_0600
* @tc.name: getProfileByExtensionAbility : The profile is obtained by specified ability
* @tc.desc: Check the invalid moduleName (by callback)
* @tc.level 0
*/
it('getProfileByExtensionAbility_0600', 0, async function (done) {
bundle.getProfileByExtensionAbility(MODULE_NAME_TEST, ABILITY_NAME, METADATA_NAME, (err, data) => {
if (err) {
console.error('[getProfileByExtensionAbility_0600]Operation failed. Cause: ' + JSON.stringify(err));
expect(err).assertEqual(1);
}
console.info('[getProfileByExtensionAbility_0600] getApplicationInfo callback data is: ' + JSON.stringify(data));
expect(typeof data).assertEqual("string");
expect(data).assertEqual("GetProfile failed");
done();
});
})
/*
* @tc.number: getProfileByExtensionAbility_0700
* @tc.name: getProfileByExtensionAbility : The profile is obtained by specified ability
* @tc.desc: Check the invalid moduleName (by callback)
* @tc.level 0
*/
it('getProfileByExtensionAbility_0700', 0, async function (done) {
bundle.getProfileByExtensionAbility('', ABILITY_NAME, METADATA_NAME, (err, data) => {
if (err) {
console.error('[getProfileByExtensionAbility_0700]Operation failed. Cause: ' + JSON.stringify(err));
expect(err).assertEqual(1);
}
console.info('[getProfileByExtensionAbility_0700] getApplicationInfo callback data is: ' + JSON.stringify(data));
expect(typeof data).assertEqual("string");
expect(data).assertEqual("GetProfile failed");
done();
});
})
/*
* @tc.number: getProfileByExtensionAbility_0800
* @tc.name: getProfileByExtensionAbility : The profile is obtained by specified ability
* @tc.desc: Check the invalid abilityName (by promise)
* @tc.level 0
*/
it('getProfileByExtensionAbility_0800', 0, async function (done) {
await bundle.getProfileByExtensionAbility(MODULE_NAME, ABILITY_NAME_TEST, METADATA_NAME).then(data => {
console.info("getProfileByExtensionAbility_0800 success" + JSON.stringify(data))
expect(data).assertFail()
done()
}).catch(err => {
console.info("getProfileByExtensionAbility_0800 failed" + JSON.stringify(err))
expect(err).assertEqual(1)
done()
})
})
/*
* @tc.number: getProfileByExtensionAbility_0900
* @tc.name: getProfileByExtensionAbility : The profile is obtained by specified ability
* @tc.desc: Check the invalid abilityName (by promise)
* @tc.level 0
*/
it('getProfileByExtensionAbility_0900', 0, async function (done) {
await bundle.getProfileByExtensionAbility(MODULE_NAME, '', METADATA_NAME).then(data => {
console.info("getProfileByExtensionAbility_0900 success" + JSON.stringify(data))
expect(data).assertFail()
done()
}).catch(err => {
console.info("getProfileByExtensionAbility_0900 failed" + JSON.stringify(err))
expect(err).assertEqual(1)
done()
})
})
/*
* @tc.number: getProfileByExtensionAbility_1000
* @tc.name: getProfileByExtensionAbility : The profile is obtained by specified ability
* @tc.desc: Check the invalid abilityName (by callback)
* @tc.level 0
*/
it('getProfileByExtensionAbility_1000', 0, async function (done) {
bundle.getProfileByExtensionAbility(MODULE_NAME, ABILITY_NAME_TEST, METADATA_NAME, (err, data) => {
if (err) {
console.error('[getProfileByExtensionAbility_1000]Operation failed. Cause: ' + JSON.stringify(err));
expect(err).assertEqual(1);
}
console.info('[getProfileByExtensionAbility_1000] getApplicationInfo callback data is: ' + JSON.stringify(data));
expect(typeof data).assertEqual("string");
expect(data).assertEqual("GetProfile failed");
done();
});
})
/*
* @tc.number: getProfileByExtensionAbility_1100
* @tc.name: getProfileByExtensionAbility : The profile is obtained by specified ability
* @tc.desc: Check the invalid abilityName (by callback)
* @tc.level 0
*/
it('getProfileByExtensionAbility_1100', 0, async function (done) {
bundle.getProfileByExtensionAbility(MODULE_NAME, '', METADATA_NAME, (err, data) => {
if (err) {
console.error('[getProfileByExtensionAbility_1100]Operation failed. Cause: ' + JSON.stringify(err));
expect(err).assertEqual(1);
}
console.info('[getProfileByExtensionAbility_1100] getApplicationInfo callback data is: ' + JSON.stringify(data));
expect(typeof data).assertEqual("string");
expect(data).assertEqual("GetProfile failed");
done();
});
})
/*
* @tc.number: getProfileByExtensionAbility_1200
* @tc.name: getProfileByExtensionAbility : The profile is obtained by specified ability
* @tc.desc: Check the valid metadataName (by callback)
* @tc.level 0
*/
it('getProfileByExtensionAbility_1200', 0, async function (done) {
bundle.getProfileByExtensionAbility(MODULE_NAME, ABILITY_NAME, METADATA_NAME, (err, data) => {
if (err) {
console.error('[getProfileByExtensionAbility_1200]Operation failed. Cause: ' + JSON.stringify(err));
expect(err).assertEqual(1);
}
console.info('[getProfileByExtensionAbility_1200] getApplicationInfo callback data is: ' + JSON.stringify(data));
expect(Array.isArray(data)).assertTrue();
expect(typeof data[0]).assertEqual("string");
expect(data[0]).assertEqual(PROFILE_JSON_STRING);
done();
});
})
/*
* @tc.number: getProfileByExtensionAbility_1300
* @tc.name: getProfileByExtensionAbility : The profile is obtained by specified ability
* @tc.desc: Check the invalid metadataName (by callback)
* @tc.level 0
*/
it('getProfileByExtensionAbility_1300', 0, async function (done) {
bundle.getProfileByExtensionAbility(MODULE_NAME, ABILITY_NAME, METADATA_NAME_TEST, (err, data) => {
if (err) {
console.error('[getProfileByExtensionAbility_1300]Operation failed. Cause: ' + JSON.stringify(err));
expect(err).assertEqual(1);
}
console.info('[getProfileByExtensionAbility_1300] getApplicationInfo callback data is: ' + JSON.stringify(data));
expect(typeof data).assertEqual("string");
expect(data).assertEqual("GetProfile failed");
done();
});
})
/*
* @tc.number: getProfileByExtensionAbility_1400
* @tc.name: getProfileByExtensionAbility : The profile is obtained by specified ability
* @tc.desc: Check the empty metadataName (by callback)
* @tc.level 0
*/
it('getProfileByExtensionAbility_1400', 0, async function (done) {
bundle.getProfileByExtensionAbility(MODULE_NAME, ABILITY_NAME, '', (err, data) => {
if (err) {
console.error('[getProfileByExtensionAbility_1400]Operation failed. Cause: ' + JSON.stringify(err));
expect(err).assertEqual(1);
}
console.info('[getProfileByExtensionAbility_1400] getApplicationInfo callback data is: ' + JSON.stringify(data));
expect(Array.isArray(data)).assertTrue();
expect(typeof data[0]).assertEqual("string");
expect(data[0]).assertEqual(PROFILE_JSON_STRING);
expect(typeof data[1]).assertEqual("string");
expect(data[1]).assertEqual(PROFILE_JSON_STRING);
done();
});
})
/*
* @tc.number: getProfileByExtensionAbility_1500
* @tc.name: getProfileByExtensionAbility : The profile is obtained by specified ability
* @tc.desc: Check the valid metadataName (by promise)
* @tc.level 0
*/
it('getProfileByExtensionAbility_1500', 0, async function (done) {
await bundle.getProfileByExtensionAbility(MODULE_NAME, ABILITY_NAME, METADATA_NAME).then(data => {
console.info('[getProfileByExtensionAbility_1500] getApplicationInfo callback data is: ' + JSON.stringify(data));
expect(Array.isArray(data)).assertTrue();
expect(typeof data[0]).assertEqual("string");
expect(data[0]).assertEqual(PROFILE_JSON_STRING);
done();
}).catch(err => {
console.error('[getProfileByExtensionAbility_1500]Operation failed. Cause: ' + JSON.stringify(err));
expect(err).assertEqual(1);
done();
})
})
/*
* @tc.number: getProfileByExtensionAbility_1600
* @tc.name: getProfileByExtensionAbility : The profile is obtained by specified ability
* @tc.desc: Check the invalid metadataName (by promise)
* @tc.level 0
*/
it('getProfileByExtensionAbility_1600', 0, async function (done) {
await bundle.getProfileByExtensionAbility(MODULE_NAME, ABILITY_NAME, METADATA_NAME_TEST).then(data => {
console.info('[getProfileByExtensionAbility_1600] getApplicationInfo callback data is: ' + JSON.stringify(data));
expect(data).assertFail()
done()
}).catch(err => {
console.error('[getProfileByExtensionAbility_1600]Operation failed. Cause: ' + JSON.stringify(err));
expect(err).assertEqual(1);
done();
})
})
/*
* @tc.number: getProfileByExtensionAbility_1700
* @tc.name: getProfileByExtensionAbility : The profile is obtained by specified ability
* @tc.desc: Check the empty metadataName (by promise)
* @tc.level 0
*/
it('getProfileByExtensionAbility_1700', 0, async function (done) {
await bundle.getProfileByExtensionAbility(MODULE_NAME, ABILITY_NAME, '').then(data => {
console.info('[getProfileByExtensionAbility_1700] getApplicationInfo callback data is: ' + JSON.stringify(data));
expect(Array.isArray(data)).assertTrue();
expect(typeof data[0]).assertEqual("string");
expect(data[0]).assertEqual(PROFILE_JSON_STRING);
expect(typeof data[1]).assertEqual("string");
expect(data[1]).assertEqual(PROFILE_JSON_STRING);
done();
}).catch(err => {
console.error('[getProfileByExtensionAbility_1700]Operation failed. Cause: ' + JSON.stringify(err));
expect(err).assertEqual(1);
done();
})
})
/*
* @tc.number: getProfileByExtensionAbility_1800
* @tc.name: getProfileByExtensionAbility : The profile is obtained by specified ability
* @tc.desc: without metadataName (by promise)
* @tc.level 0
*/
it('getProfileByExtensionAbility_1800', 0, async function (done) {
await bundle.getProfileByExtensionAbility(MODULE_NAME, ABILITY_NAME).then(data => {
console.info('[getProfileByExtensionAbility_1800] getApplicationInfo callback data is: ' + JSON.stringify(data));
expect(Array.isArray(data)).assertTrue();
expect(typeof data[0]).assertEqual("string");
expect(data[0]).assertEqual(PROFILE_JSON_STRING);
expect(typeof data[1]).assertEqual("string");
expect(data[1]).assertEqual(PROFILE_JSON_STRING);
done();
}).catch(err => {
console.error('[getProfileByExtensionAbility_1800]Operation failed. Cause: ' + JSON.stringify(err));
expect(err).assertEqual(1);
done();
})
})
/*
* @tc.number: getProfileByExtensionAbility_1900
* @tc.name: getProfileByExtensionAbility : The profile is obtained by specified ability
* @tc.desc: no profile configured under the ability (by promise)
* @tc.level 0
*/
it('getProfileByExtensionAbility_1900', 0, async function (done) {
await bundle.getProfileByExtensionAbility(MODULE_NAME, ABILITY_NAME1).then(data => {
console.info('[getProfileByExtensionAbility_1900] getApplicationInfo callback data is: ' + JSON.stringify(data));
expect(data).assertFail()
done();
}).catch(err => {
console.error('[getProfileByExtensionAbility_1900]Operation failed. Cause: ' + JSON.stringify(err));
expect(err).assertEqual(1);
done();
})
})
/*
* @tc.number: getProfileByExtensionAbility_2000
* @tc.name: getProfileByExtensionAbility : The profile is obtained by specified ability
* @tc.desc: resource has no prefix '$profile:' (by promise)
* @tc.level 0
*/
it('getProfileByExtensionAbility_2000', 0, async function (done) {
await bundle.getProfileByExtensionAbility(MODULE_NAME, ABILITY_NAME, METADATA_NAME2).then(data => {
console.info('[getProfileByExtensionAbility_2000] getApplicationInfo callback data is: ' + JSON.stringify(data));
expect(data).assertFail()
done();
}).catch(err => {
console.error('[getProfileByExtensionAbility_2000]Operation failed. Cause: ' + JSON.stringify(err));
expect(err).assertEqual(1);
done();
})
})
/*
* @tc.number: getProfileByExtensionAbility_2100
* @tc.name: getProfileByExtensionAbility : The profile is obtained by specified ability
* @tc.desc: resource has no prefix '$profile:' (by callback)
* @tc.level 0
*/
it('getProfileByExtensionAbility_2100', 0, async function (done) {
bundle.getProfileByExtensionAbility(MODULE_NAME, ABILITY_NAME, METADATA_NAME2, (err, data) => {
if (err) {
console.error('[getProfileByExtensionAbility_2100]Operation failed. Cause: ' + JSON.stringify(err));
expect(err).assertEqual(1);
}
console.info('[getProfileByExtensionAbility_2100] getApplicationInfo callback data is: ' + JSON.stringify(data));
expect(typeof data).assertEqual("string");
expect(data).assertEqual("GetProfile failed");
done();
});
})
/*
* @tc.number: getProfileByExtensionAbility_2200
* @tc.name: getProfileByExtensionAbility : The profile is obtained by specified ability
* @tc.desc: profile is not json-format (by promise)
* @tc.level 0
*/
it('getProfileByExtensionAbility_2200', 0, async function (done) {
await bundle.getProfileByExtensionAbility(MODULE_NAME, ABILITY_NAME, METADATA_NAME3).then(data => {
console.info('[getProfileByExtensionAbility_2200] getApplicationInfo callback data is: ' + JSON.stringify(data));
expect(data).assertFail()
done();
}).catch(err => {
console.error('[getProfileByExtensionAbility_2200]Operation failed. Cause: ' + JSON.stringify(err));
expect(err).assertEqual(1);
done();
})
})
/*
* @tc.number: getProfileByExtensionAbility_2300
* @tc.name: getProfileByExtensionAbility : The profile is obtained by specified ability
* @tc.desc: profile is not json-format (by callback)
* @tc.level 0
*/
it('getProfileByExtensionAbility_2300', 0, async function (done) {
bundle.getProfileByExtensionAbility(MODULE_NAME, ABILITY_NAME, METADATA_NAME3, (err, data) => {
if (err) {
console.error('[getProfileByExtensionAbility_2300]Operation failed. Cause: ' + JSON.stringify(err));
expect(err).assertEqual(1);
}
console.info('[getProfileByExtensionAbility_2300] getApplicationInfo callback data is: ' + JSON.stringify(data));
expect(typeof data).assertEqual("string");
expect(data).assertEqual("GetProfile failed");
done();
});
})
})
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import getProfileByAbility from './GetProfileByAbility.test.ets';
import getProfileByExtensionAbility from './GetProfileByExtensionAbility.test.ets';
export default function testsuite(context) {
getProfileByAbility();
getProfileByExtensionAbility();
}
\ 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.test.MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"skills": [
{
"actions": [
"action.system.home"
],
"entities":[
"entity.system.home"
]
}
],
"metadata": [
{
"name": "ohos.ability.form",
"value": "",
"resource": "$profile:shortcuts_config"
},
{
"name": "ohos.ability.form1",
"value": "",
"resource": "$profile:form_config"
},
{
"name": "ohos.ability.form2",
"value": "",
"resource": "@profile:form_config"
},
{
"name": "ohos.ability.form3",
"value": "",
"resource": "$profile:form_config1"
}
]
},
{
"name": "ohos.acts.bundle.stage.test.MainAbility1",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"skills": []
}
],
"extensionAbilities": [
{
"description": "$string:form_description",
"descriptionId": 16777219,
"icon": "$media:icon",
"iconId": 16777225,
"metadata": [
{
"name": "ohos.extension.form",
"value": "",
"resource": "$profile:shortcuts_config"
},
{
"name": "ohos.extension.form1",
"value": "",
"resource": "$profile:form_config"
},
{
"name": "ohos.extension.form2",
"value": "",
"resource": "@profile:form_config"
},
{
"name": "ohos.extension.form3",
"value": "",
"resource": "$profile:form_config1"
}
],
"name": "Form",
"srcEntrance": "./ets/FormAbility/FormAbility.ts",
"type": "form",
"visible": true
},
{
"description": "$string:form_description",
"descriptionId": 16777219,
"icon": "$media:icon",
"iconId": 16777225,
"name": "Form1",
"srcEntrance": "./ets/FormAbility/FormAbility.ts",
"type": "form",
"visible": true
}
]
}
}
{
"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"
}
]
}
{
"src": [
"pages/index/index",
"pages/second/second"
]
}
\ No newline at end of file
{"forms" :[{"colorMode" : "auto","defaultDimension" : "2*2","description" : "$string:16777219","formConfigAbility" : "ability://xxxxx","formVisibleNotify" : false,"isDefault" : true,"name" : "Form_Js","scheduledUpdateTime" : "10:30","src" : "pages/card/index","supportDimensions" :["2*2"],"updateDuration" : 1,"updateEnabled" : true,"window" :{"autoDesignWidth" : true,"designWidth" : 720}}]}
\ No newline at end of file
{
"src": [
"pages/index/index",
"pages/second/second"
]
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册