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

!7975 【包管理子系统】【master】新增overlay用例

Merge pull request !7975 from ry/master
......@@ -26,6 +26,7 @@ group("bundlemanager") {
"actsbmsjsunpermissiontest:ActsBmsJsUnPermissionTest",
"actsbmsmetadatatest:ActsBmsMetaDataTest",
"actsbundlemanageretstest:ActsBundleManagerEtsTest",
"actsbundlemanageroverlaytest:ActsBundleMgrOverlayEtsTest",
"actsbundlemanagerstagetest:ActsBundleMgrStageEtsTest",
"actsbundlemanagertest:ActsBundleManagerTest",
"actsbundlenativetest:ActsBundleNativeTest",
......@@ -52,6 +53,7 @@ group("bundlemanager") {
"sceneProject/bmsmainabilitysecondscene:bmsMainAbilitySecondScene",
"sceneProject/bmsmodulenameone:bmsModuleNameTest1",
"sceneProject/bmsmodulenametwo:bmsModuleNameTest2",
"sceneProject/bmsoverlaydemo:bmsOverlayDemo",
"sceneProject/bmsscenefive:bmsJstest5",
"sceneProject/bmsscenefour:bmsJstest4",
"sceneProject/bmssceneone:bmsJstest1",
......
{
"app":{
"bundleName":"ohos.acts.bundle.overlay.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":9,
"targetAPIVersion":9,
"car":{
"apiCompatibleVersion":9,
"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("ActsBundleMgrOverlayEtsTest") {
hap_profile = "entry/src/main/module.json"
deps = [
":actbmsoverlayetstest_js_assets",
":actbmsoverlayetstest_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsBundleMgrOverlayEtsTest"
subsystem_name = "bundlemanager"
part_name = "bundle_framework"
}
ohos_app_scope("actbmsoverlayetstest_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("actbmsoverlayetstest_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("actbmsoverlayetstest_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":actbmsoverlayetstest_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "180000",
"bundle-name": "ohos.acts.bundle.overlay.test",
"module-name": "testModule",
"shell-timeout": "600000",
"testcase-timeout": 70000
},
"kits": [
{
"test-file-name": [
"ActsBundleMgrOverlayEtsTest.hap",
"bmsOverlayDemo.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command":[
"remount",
"mkdir /data/test/"
]
},
{
"type": "PushKit",
"push": [
"bmsOverlayDemo.hap -> /data/test/bmsOverlayDemo.hap"
]
},
{
"type": "ShellKit",
"teardown-command":[
"bm uninstall -n ohos.acts.bundle.overlay.test",
"rm -rf /data/test/"
]
}
]
}
import AbilityStage from "@ohos.app.ability.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("[Demo] MyAbilityStage onCreate")
globalThis.stageOnCreateRun = 1;
globalThis.stageContext = this.context;
}
}
import FormExtension from '@ohos.app.form.FormExtensionAbility';
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.app.ability.UIAbility'
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, "MainAbility/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) 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 '@ohos.router';
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../../../test/List.test'
@Entry
@Component
struct Index {
aboutToAppear(){
console.info("start run testcase!!!!")
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
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
import FormExtension from '@ohos.app.form.FormExtensionAbility';
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.app.ability.UIAbility'
export default class TestAbility extends Ability {
onCreate(want, launchParam) {
console.log('TestAbility onCreate')
}
onDestroy() {
console.log('TestAbility onDestroy')
}
onWindowStageCreate(windowStage) {
console.log('TestAbility onWindowStageCreate')
windowStage.setUIContent(this.context, 'TestAbility/pages/index', null)
globalThis.abilityContext = this.context;
}
onWindowStageDestroy() {
console.log('TestAbility onWindowStageDestroy')
}
onForeground() {
console.log('TestAbility onForeground')
}
onBackground() {
console.log('TestAbility onBackground')
}
};
\ 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 '@ohos.router';
@Entry
@Component
struct Index {
aboutToAppear() {
console.info('TestAbility index aboutToAppear')
}
@State message: string = 'Hello World'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('next page')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width('35%')
.height('5%')
.onClick(()=>{
})
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
import TestRunner from '@ohos.application.testRunner'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
var abilityDelegator = undefined
var abilityDelegatorArguments = undefined
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s it',
'-s level', '-s testType', '-s size', '-s timeout'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams = `${targetParams} ${key} ${parameters[key]}`
}
}
return targetParams.trim()
}
async function onAbilityCreateCallback() {
console.log("onAbilityCreateCallback");
}
async function addAbilityMonitorCallback(err: any) {
console.info("addAbilityMonitorCallback : " + JSON.stringify(err))
}
export default class OpenHarmonyTestRunner implements TestRunner {
constructor() {
}
onPrepare() {
console.info("OpenHarmonyTestRunner OnPrepare ")
}
async onRun() {
console.log('OpenHarmonyTestRunner onRun run')
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility'
let lMonitor = {
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
var cmd = 'aa start -d 0 -a ohos.acts.bundle.overlay.test.MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters)
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd,
(err: any, d: any) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + d.stdResult);
console.info('executeShellCommand : data : ' + d.exitCode);
})
console.info('OpenHarmonyTestRunner onRun end')
}
};
\ 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 impligetProfileByAbilityEmptyAbilityCalled.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import overlay from '@ohos.bundle.overlay';
import Utils from "./Utils";
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium"
const MODULE_NAME = "testModule";
const MODULE_NAME1 = "test1";
const MODULE_NAME2 = "stage1";
const ERROR_INCOMING_MODULE_NAME_NOT_INSTALL = 17700002;
const ERROR_INCOMING_MODULE_NAME_NOT_OVERLAY = 17700033;
const ERROR_CODE = 401;
export default function getOverlayModuleInfo() {
describe('getOverlayModuleInfo', function () {
/*
* @tc.number: SUB_BMS_APPINFO_OVERLAY_0001
* @tc.name: GetOverlayModuleInfoModuleNameIsNull
* @tc.desc: The query fails when the incoming moduleName is empty
*/
it('GetOverlayModuleInfoModuleNameIsNull', 0, async function (done) {
try {
await overlay.getOverlayModuleInfo("").then(data => {
Utils.info("GetOverlayModuleInfoModuleNameIsNull result" + JSON.stringify(data));
expect().assertFail();
}).catch(err => {
Utils.info("GetOverlayModuleInfoModuleNameIsNull fail" + JSON.stringify(err));
expect(err.code).assertEqual(ERROR_CODE);
});
} catch (e) {
Utils.info("GetOverlayModuleInfoModuleNameIsNull catch" + JSON.stringify(e));
expect(e.code).assertEqual(ERROR_CODE);
}
try {
overlay.getOverlayModuleInfo("", (err,data) => {
Utils.info("GetOverlayModuleInfoModuleNameIsNull result" + JSON.stringify(data));
Utils.info("GetOverlayModuleInfoModuleNameIsNull fail" + JSON.stringify(err));
expect().assertFail();
done();
});
} catch (e) {
Utils.info("GetOverlayModuleInfoModuleNameIsNull callback catch" + JSON.stringify(e));
expect(e.code).assertEqual(ERROR_CODE);
done();
}
})
/*
* @tc.number: SUB_BMS_APPINFO_OVERLAY_0003
* @tc.name: GetOverlayModuleInfoModuleNameNotInstall
* @tc.desc: The query fails when the incoming moduleName is not installed
*/
it('GetOverlayModuleInfoModuleNameNotInstall', 0, async function (done) {
await overlay.getOverlayModuleInfo(MODULE_NAME1).then(data => {
Utils.info("GetOverlayModuleInfoModuleNameNotInstall result" + JSON.stringify(data));
expect().assertFail();
}).catch(err => {
Utils.info("GetOverlayModuleInfoModuleNameNotInstall fail" + JSON.stringify(err));
expect(err.code).assertEqual(ERROR_INCOMING_MODULE_NAME_NOT_INSTALL);
});
overlay.getOverlayModuleInfo(MODULE_NAME1, (err,data) => {
Utils.info("GetOverlayModuleInfoModuleNameNotInstall result" + JSON.stringify(data));
Utils.info("GetOverlayModuleInfoModuleNameNotInstall fail" + JSON.stringify(err));
expect(err.code).assertEqual(ERROR_INCOMING_MODULE_NAME_NOT_INSTALL);
done();
});
})
/*
* @tc.number: SUB_BMS_APPINFO_OVERLAY_0004
* @tc.name: GetOverlayModuleInfoModuleNameNotOverlay
* @tc.desc: Failed to set when the incoming moduleName is not overlay
*/
it('GetOverlayModuleInfoModuleNameNotOverlay', 0, async function (done) {
await overlay.getOverlayModuleInfo(MODULE_NAME).then(data => {
Utils.info("GetOverlayModuleInfoModuleNameNotOverlay result" + JSON.stringify(data));
expect().assertFail();
}).catch(err => {
Utils.info("GetOverlayModuleInfoModuleNameNotOverlay fail" + JSON.stringify(err));
expect(err.code).assertEqual(ERROR_INCOMING_MODULE_NAME_NOT_OVERLAY);
});
overlay.getOverlayModuleInfo(MODULE_NAME, (err,data) => {
Utils.info("GetOverlayModuleInfoModuleNameNotOverlay result" + JSON.stringify(data));
Utils.info("GetOverlayModuleInfoModuleNameNotOverlay fail" + JSON.stringify(err));
expect(err.code).assertEqual(ERROR_INCOMING_MODULE_NAME_NOT_OVERLAY);
done();
});
})
/*
* @tc.number: SUB_BMS_APPINFO_OVERLAY_000X
* @tc.name: GetOverlayModuleInfoModuleNameIsOverlay
* @tc.desc: Query succeeded when the moduleName passed in is overlay
*/
it('GetOverlayModuleInfoModuleNameIsOverlay', 0, async function (done) {
await overlay.getOverlayModuleInfo(MODULE_NAME2).then(data => {
Utils.info("GetOverlayModuleInfoModuleNameIsOverlay result" + JSON.stringify(data));
let overlayModuleInfoTest: overlay.OverlayModuleInfo = data;
expect(typeof (overlayModuleInfoTest.bundleName)).assertEqual('string');
expect(data.bundleName).assertEqual("ohos.acts.bundle.overlay.test");
expect(data.moduleName).assertEqual("stage1");
expect(data.targetModuleName).assertEqual("entry1");
expect(data.priority).assertEqual(1);
expect(data.state).assertEqual(2);
}).catch(err => {
Utils.info("GetOverlayModuleInfoModuleNameIsOverlay fail" + JSON.stringify(err));
expect().assertFail()
});
overlay.getOverlayModuleInfo(MODULE_NAME2, (err,data) => {
// "bundleName":"ohos.acts.bundle.overlay.test","moduleName":"stage1","targetModuleName":"entry1","priority":1,"state":2
Utils.info("GetOverlayModuleInfoModuleNameIsOverlay result" + JSON.stringify(data));
Utils.info("GetOverlayModuleInfoModuleNameIsOverlay fail" + JSON.stringify(err));
expect(data.bundleName).assertEqual("ohos.acts.bundle.overlay.test");
expect(data.moduleName).assertEqual("stage1");
expect(data.targetModuleName).assertEqual("entry1");
expect(data.priority).assertEqual(1);
expect(data.state).assertEqual(2);
expect(err).assertNull();
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 impligetProfileByAbilityEmptyAbilityCalled.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import overlay from '@ohos.bundle.overlay';
import Utils from "./Utils";
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium"
const MODULE_NAME = "testModule";
const MODULE_NAME1 = "test1";
const MODULE_NAME2 = "stage1";
const ERROR_INCOMING_MODULE_NAME_NOT_INSTALL = 17700002;
const ERROR_INCOMING_MODULE_NAME_IS_OVERLAY = 17700034;
const ERROR_CODE = 401;
export default function getTargetOverlayModuleInfos() {
describe('getTargetOverlayModuleInfos', function () {
/*
* @tc.number: SUB_BMS_APPINFO_OVERLAY_0006
* @tc.name: GetTargetOverlayModuleInfosModuleNameIsNull
* @tc.desc: The query fails when the incoming moduleName is empty
*/
it('GetTargetOverlayModuleInfosModuleNameIsNull', 0, async function (done) {
try {
await overlay.getTargetOverlayModuleInfos("").then(data => {
Utils.info("GetTargetOverlayModuleInfosModuleNameIsNull result" + JSON.stringify(data));
expect().assertFail();
}).catch(err => {
Utils.info("GetTargetOverlayModuleInfosModuleNameIsNull fail" + JSON.stringify(err));
expect().assertFail();
});
} catch (e) {
Utils.info("GetTargetOverlayModuleInfosModuleNameIsNull catch" + JSON.stringify(e));
expect(e.code).assertEqual(ERROR_CODE);
}
try {
overlay.getTargetOverlayModuleInfos("", (err,data) => {
Utils.info("GetTargetOverlayModuleInfosModuleNameIsNull result" + JSON.stringify(data));
Utils.info("GetTargetOverlayModuleInfosModuleNameIsNull fail" + JSON.stringify(err));
expect().assertFail();
done();
});
} catch (e) {
Utils.info("SetOverlayEnabledModuleNameIsNull callback catch" + JSON.stringify(e));
expect(e.code).assertEqual(ERROR_CODE);
done();
}
})
/*
* @tc.number: SUB_BMS_APPINFO_OVERLAY_0008
* @tc.name: GetTargetOverlayModuleInfosModuleNameNotInstall
* @tc.desc: The query fails when the incoming moduleName is not installed
*/
it('GetTargetOverlayModuleInfosModuleNameNotInstall', 0, async function (done) {
await overlay.getTargetOverlayModuleInfos(MODULE_NAME1).then(data => {
Utils.info("GetTargetOverlayModuleInfosModuleNameNotInstall result" + JSON.stringify(data));
expect().assertFail();
}).catch(err => {
Utils.info("GetTargetOverlayModuleInfosModuleNameNotInstall fail" + JSON.stringify(err));
expect(err.code).assertEqual(ERROR_INCOMING_MODULE_NAME_NOT_INSTALL);
});
overlay.getTargetOverlayModuleInfos(MODULE_NAME1, (err,data) => {
Utils.info("GetTargetOverlayModuleInfosModuleNameNotInstall result" + JSON.stringify(data));
Utils.info("GetTargetOverlayModuleInfosModuleNameNotInstall fail" + JSON.stringify(err));
expect(err.code).assertEqual(ERROR_INCOMING_MODULE_NAME_NOT_INSTALL);
done();
});
})
/*
* @tc.number: SUB_BMS_APPINFO_OVERLAY_0009
* @tc.name: GetTargetOverlayModuleInfosModuleNameIsOverlay
* @tc.desc: Failed to set when the incoming moduleName is overlay
*/
it('GetTargetOverlayModuleInfosModuleNameIsOverlay', 0, async function (done) {
await overlay.getTargetOverlayModuleInfos(MODULE_NAME2).then(data => {
Utils.info("GetTargetOverlayModuleInfosModuleNameIsOverlay result" + JSON.stringify(data));
expect().assertFail();
}).catch(err => {
Utils.info("GetTargetOverlayModuleInfosModuleNameIsOverlay fail" + JSON.stringify(err));
expect(err.code).assertEqual(ERROR_INCOMING_MODULE_NAME_IS_OVERLAY);
});
overlay.getTargetOverlayModuleInfos(MODULE_NAME2, (err,data) => {
Utils.info("GetTargetOverlayModuleInfosModuleNameIsOverlay result" + JSON.stringify(data));
Utils.info("GetTargetOverlayModuleInfosModuleNameIsOverlay fail" + JSON.stringify(err));
expect(err.code).assertEqual(ERROR_INCOMING_MODULE_NAME_IS_OVERLAY);
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 SetOverlayEnabled from './SetOverlayEnabled.test.ets';
import GetOverlayModuleInfo from './GetOverlayModuleInfo.test.ets';
import GetTargetOverlayModuleInfos from './GetTargetOverlayModuleInfos.test.ets';
export default function testsuite() {
SetOverlayEnabled();
GetOverlayModuleInfo();
GetTargetOverlayModuleInfos();
}
\ 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 impligetProfileByAbilityEmptyAbilityCalled.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import overlay from '@ohos.bundle.overlay';
import Utils from "./Utils";
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium"
const MODULE_NAME = "testModule";
const MODULE_NAME1 = "test1";
const ERROR_INCOMING_MODULE_NAME_NOT_INSTALL = 17700002;
const ERROR_INCOMING_MODULE_NAME_NOT_OVERLAY = 17700033;
const ERROR_CODE = 401;
export default function setOverlayEnabled() {
describe('setOverlayEnabled', function () {
/*
* @tc.number: SUB_BMS_OVERLAY_ENABLED_0001
* @tc.name: SetOverlayEnabledModuleNameIsNull
* @tc.desc: Failed to set when the incoming moduleName is empty
*/
it('SetOverlayEnabledModuleNameIsNull', 0, async function (done) {
try {
await overlay.setOverlayEnabled("", true).then(data => {
console.info("SetOverlayEnabledModuleNameIsNull result1111" + JSON.stringify(data))
Utils.info("SetOverlayEnabledModuleNameIsNull result" + JSON.stringify(data));
expect().assertFail();
}).catch(err => {
Utils.info("SetOverlayEnabledModuleNameIsNull fail" + JSON.stringify(err));
expect(err.code).assertEqual(ERROR_CODE);
});
} catch (e) {
Utils.info("SetOverlayEnabledModuleNameIsNull catch" + JSON.stringify(e));
expect(e.code).assertEqual(ERROR_CODE);
}
try {
overlay.setOverlayEnabled("", true, (err,data) => {
Utils.info("SetOverlayEnabledModuleNameIsNull result" + JSON.stringify(data));
Utils.info("SetOverlayEnabledModuleNameIsNull fail" + JSON.stringify(err));
expect().assertFail();
done();
});
} catch (e) {
Utils.info("SetOverlayEnabledModuleNameIsNull callback catch" + JSON.stringify(e));
expect(e.code).assertEqual(ERROR_CODE);
done();
}
})
/*
* @tc.number: SUB_BMS_OVERLAY_ENABLED_0005
* @tc.name: SetOverlayEnabledModuleNameNotInstall
* @tc.desc: Failed to set when the incoming moduleName is not installed
*/
it('SetOverlayEnabledModuleNameNotInstall', 0, async function (done) {
await overlay.setOverlayEnabled(MODULE_NAME1, true).then(data => {
Utils.info("SetOverlayEnabledModuleNameNotInstall result" + JSON.stringify(data));
expect().assertFail();
}).catch(err => {
Utils.info("SetOverlayEnabledModuleNameNotInstall fail" + JSON.stringify(err));
expect(err.code).assertEqual(ERROR_INCOMING_MODULE_NAME_NOT_INSTALL);
});
overlay.setOverlayEnabled(MODULE_NAME1, true, (err,data) => {
Utils.info("SetOverlayEnabledModuleNameNotInstall result" + JSON.stringify(data));
Utils.info("SetOverlayEnabledModuleNameNotInstall fail" + JSON.stringify(err));
expect(err.code).assertEqual(ERROR_INCOMING_MODULE_NAME_NOT_INSTALL);
done();
});
})
/*
* @tc.number: SUB_BMS_OVERLAY_ENABLED_0006
* @tc.name: SetOverlayEnabledModuleNameIsNotOverlay
* @tc.desc: Failed to set when the incoming moduleName is not overlay
*/
it('SetOverlayEnabledModuleNameIsNotOverlay', 0, async function (done) {
await overlay.setOverlayEnabled(MODULE_NAME, true).then(data => {
Utils.info("SetOverlayEnabledModuleNameIsNotOverlay result" + JSON.stringify(data));
expect().assertFail();
}).catch(err => {
Utils.info("SetOverlayEnabledModuleNameIsNotOverlay fail" + JSON.stringify(err));
expect(err.code).assertEqual(ERROR_INCOMING_MODULE_NAME_NOT_OVERLAY);
});
overlay.setOverlayEnabled(MODULE_NAME, true, (err,data) => {
Utils.info("SetOverlayEnabledModuleNameIsNotOverlay result" + JSON.stringify(data));
Utils.info("SetOverlayEnabledModuleNameIsNotOverlay fail" + JSON.stringify(err));
expect(err.code).assertEqual(ERROR_INCOMING_MODULE_NAME_NOT_OVERLAY);
done();
});
})
})
}
\ 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 hiLog from '@ohos.hilog';
export default class Utils {
static info(str) {
hiLog.info(0 , "BMSTEST" , str);
}
static sleep(time) {
return new Promise((resolve, reject) => {
setTimeout((data) => {
resolve(data)
}, time)
}).then(() => {
console.info(`sleep ${time} over...`)
})
}
}
{
"module": {
"name": "testModule",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:testModule_entry_dsc",
"mainElement": "ohos.acts.bundle.overlay.test.MainAbility",
"deviceTypes": [
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"metadata": [
{
"name": "ArkTSPartialUpdate",
"value": "false"
}
],
"abilities": [
{
"name": "ohos.acts.bundle.overlay.test.MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:testModule_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"launchType": "singleton",
"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.ability.form4",
"value": "",
"resource": "$profile:invalid"
}
]
},
{
"name": "ohos.acts.bundle.overlay.test.MainAbility1",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:testModule_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"launchType": "standard",
"orientation": "landscape",
"skills": []
},
{
"name": "ohos.acts.bundle.overlay.test.MainAbility2",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:testModule_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"launchType": "specified",
"orientation": "landscape_inverted",
"skills": []
},
{
"name": "ohos.acts.bundle.overlay.test.MainAbility3",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:testModule_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"launchType": "specified",
"orientation": "portrait_inverted",
"skills": []
},
{
"name": "ohos.acts.bundle.overlay.test.MainAbility4",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:testModule_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"launchType": "specified",
"orientation": "auto_rotation",
"skills": []
},
{
"name": "ohos.acts.bundle.overlay.test.MainAbility5",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:testModule_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"launchType": "specified",
"orientation": "auto_rotation_landscape",
"skills": []
},
{
"name": "ohos.acts.bundle.overlay.test.MainAbility6",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:testModule_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"launchType": "specified",
"orientation": "auto_rotation_portrait",
"skills": []
},
{
"name": "ohos.acts.bundle.overlay.test.MainAbility7",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:testModule_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"launchType": "specified",
"orientation": "auto_rotation_restricted",
"skills": []
},
{
"name": "ohos.acts.bundle.overlay.test.MainAbility8",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:testModule_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"launchType": "specified",
"orientation": "auto_rotation_landscape_restricted",
"skills": []
},
{
"name": "ohos.acts.bundle.overlay.test.MainAbility9",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:testModule_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"launchType": "specified",
"orientation": "auto_rotation_portrait_restricted",
"skills": []
},
{
"name": "ohos.acts.bundle.overlay.test.MainAbility10",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:testModule_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"launchType": "specified",
"orientation": "locked",
"skills": []
}
],
"extensionAbilities": [
{
"description": "$string:form_description",
"descriptionId": 16777219,
"icon": "$media:icon",
"iconId": 16777225,
"label": "$string:entry_label",
"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": "ohos.extension.form4",
"value": "",
"resource": "$profile:invalid"
}
],
"name": "Form",
"srcEntrance": "./ets/FormAbility/FormAbility.ts",
"type": "form",
"visible": true
},
{
"description": "$string:form_description",
"descriptionId": 16777219,
"icon": "$media:icon",
"iconId": 16777225,
"label": "$string:entry_label",
"name": "Form1",
"srcEntrance": "./ets/FormAbility/FormAbility.ts",
"type": "form",
"visible": true
},
{
"description": "$string:form_description",
"descriptionId": 16777219,
"icon": "$media:icon",
"iconId": 16777225,
"label": "$string:entry_label",
"name": "workScheduler",
"srcEntrance": "./ets/FormAbility/FormAbility.ts",
"type": "workScheduler",
"visible": true
},
{
"description": "$string:form_description",
"descriptionId": 16777219,
"icon": "$media:icon",
"iconId": 16777225,
"label": "$string:entry_label",
"name": "inputMethod",
"srcEntrance": "./ets/FormAbility/FormAbility.ts",
"type": "inputMethod",
"visible": true
},
{
"description": "$string:form_description",
"descriptionId": 16777219,
"icon": "$media:icon",
"iconId": 16777225,
"label": "$string:entry_label",
"name": "accessibility",
"srcEntrance": "./ets/FormAbility/FormAbility.ts",
"type": "accessibility",
"visible": true
},
{
"description": "$string:form_description",
"descriptionId": 16777219,
"icon": "$media:icon",
"iconId": 16777225,
"label": "$string:entry_label",
"name": "fileShare",
"srcEntrance": "./ets/FormAbility/FormAbility.ts",
"type": "fileShare",
"visible": true
},
{
"description": "$string:form_description",
"descriptionId": 16777219,
"icon": "$media:icon",
"iconId": 16777225,
"label": "$string:entry_label",
"name": "staticSubscriber",
"srcEntrance": "./ets/FormAbility/FormAbility.ts",
"type": "staticSubscriber",
"visible": true
},
{
"description": "$string:form_description",
"descriptionId": 16777219,
"icon": "$media:icon",
"iconId": 16777225,
"label": "$string:entry_label",
"name": "wallpaper",
"srcEntrance": "./ets/FormAbility/FormAbility.ts",
"type": "wallpaper",
"visible": true
},
{
"description": "$string:form_description",
"descriptionId": 16777219,
"icon": "$media:icon",
"iconId": 16777225,
"label": "$string:entry_label",
"name": "backup",
"srcEntrance": "./ets/FormAbility/FormAbility.ts",
"type": "backup",
"visible": true
},
{
"description": "$string:form_description",
"descriptionId": 16777219,
"icon": "$media:icon",
"iconId": 16777225,
"label": "$string:entry_label",
"name": "window",
"srcEntrance": "./ets/FormAbility/FormAbility.ts",
"type": "window",
"visible": true
},
{
"description": "$string:form_description",
"descriptionId": 16777219,
"icon": "$media:icon",
"iconId": 16777225,
"label": "$string:entry_label",
"name": "enterpriseAdmin",
"srcEntrance": "./ets/FormAbility/FormAbility.ts",
"type": "enterpriseAdmin",
"visible": true
},
{
"description": "$string:form_description",
"descriptionId": 16777219,
"icon": "$media:icon",
"iconId": 16777225,
"label": "$string:entry_label",
"name": "thumbnail",
"srcEntrance": "./ets/FormAbility/FormAbility.ts",
"type": "thumbnail",
"visible": true
},
{
"description": "$string:form_description",
"descriptionId": 16777219,
"icon": "$media:icon",
"iconId": 16777225,
"label": "$string:entry_label",
"name": "preview",
"srcEntrance": "./ets/FormAbility/FormAbility.ts",
"type": "preview",
"visible": true
}
],
"requestPermissions": [
{
"name": "ohos.permission.GET_BUNDLE_INFO",
"reason": "$string:permission_reason",
"usedScene": {
"abilities": ["MainAbility"],
"when": "always"
}
},
{
"name": "ohos.permission.READ_CALENDAR",
"reason": "$string:permission_reason",
"usedScene": {
"abilities": ["MainAbility"],
"when": "inuse"
}
}
],
"metadata": [
{
"name": "MetaData1",
"value": "MetaDataValue",
"resource": "$profile:shortcuts_config"
}
]
}
}
{
"string": [
{
"name": "testModule_entry_dsc",
"value": "i am an entry for testModule"
},
{
"name": "testModule_entry_main",
"value": "the testModule 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"
},
{
"name": "permission_reason",
"value": "Need permission"
}
]
}
{
"src": [
"MainAbility/pages/index/index",
"MainAbility/pages/second/second"
]
}
\ No newline at end of file
{"src": ["MainAbility/pages/index/index","MainAbility/pages/second/second"]}
\ No newline at end of file
{
"src": [
"MainAbility/pages/index/index",
"MainAbility/pages/second/second"
}
\ No newline at end of file
{
"src": [
"MainAbility/pages/index/index",
"MainAbility/pages/second/second"
]
}
\ No newline at end of file
{
"src": [
"MainAbility/pages/index/index",
"MainAbility/pages/second/second"
]
}
\ No newline at end of file
......@@ -94,6 +94,7 @@ export default function getBundleInfoForSelf() {
await bundle.getBundleInfoForSelf(bundle.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION).then(data => {
console.info("getBundleInfoForSelfApplicationPro" + JSON.stringify(data.appInfo));
checkCommonBundleInfo(data);
expect(bundle.ExtensionAbilityType.PRINT).assertEqual(15);
expect(data.appInfo.bundleType).assertEqual(bundle.BundleType.APP);
expect(data.appInfo.name).assertEqual(BUNDLE_NAME);
expect(data.appInfo.description).assertEqual("$string:description_application");
......
......@@ -19,6 +19,7 @@ import getBundleInfoForSelf from './GetBundleInfoForSelf.test.ets';
import getSecondModuleTest from './GetSecondModule.test.ets';
import isDefaultApplicationTest from './IsDefaultApplication.test.ets';
import PublicApiEightTest from './PublicApiEightTest.test.ets';
import PublicApiNineTest from './PublicApiNineTest.test.ets';
export default function testsuite() {
getProfileByAbility();
......@@ -27,4 +28,5 @@ export default function testsuite() {
getSecondModuleTest();
isDefaultApplicationTest();
PublicApiEightTest();
PublicApiNineTest();
}
\ 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 impligetProfileByAbilityEmptyAbilityCalled.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import bundle from '@ohos.bundle.bundleManager';
import defaultAppMgr from '@ohos.bundle.defaultAppManager';
import util from "./Utils";
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium";
const BUNDLE_NAME = "ohos.acts.bundle.stage.test";
const MODULE_NAME = "testModule";
const METADATA_NAME = "ohos.ability.form";
const METADATA_NAME1 = "ohos.extension.form1";
const ABILITY_NAME = "ohos.acts.bundle.stage.test.MainAbility";
const ABILITY_NAME1 = "Form";
const PROFILE_JSON_STRING = "{\"src\":[\"MainAbility/pages/index/index\",\"MainAbility/pages/second/second\"]}";
export default function PublicApiNineTest() {
describe('PublicApiNineTest', function () {
/*
* @tc.number: SUB_BMS_SYSTEMAPI_RUNNIING_0069
* @tc.name: getBundleInfoForSelfProTest
* @tc.desc: Test getBundleInfoForSelf of API9 in version9 normal project
*/
it('getBundleInfoForSelfProTest', 0, async function (done) {
await bundle.getBundleInfoForSelf(bundle.BundleFlag.GET_BUNDLE_INFO_DEFAULT).then(data => {
util.info("getBundleInfoForSelfPro" + JSON.stringify(data));
expect(data.name).assertEqual(BUNDLE_NAME);
}).catch(err => {
util.info("getBundleInfoForSelf fail" + JSON.stringify(err));
expect(err).assertFail();
})
bundle.getBundleInfoForSelf(bundle.BundleFlag.GET_BUNDLE_INFO_DEFAULT, (err, data) => {
expect(data.name).assertEqual(BUNDLE_NAME);
expect(err).assertEqual(null);
done();
})
});
/*
* @tc.number: SUB_BMS_SYSTEMAPI_RUNNIING_0070
* @tc.name: getProfileByAbilityTest
* @tc.desc: Test getProfileByAbility of API9 in version9 normal project
*/
it('getProfileByAbilityTest', 0, async function (done) {
await bundle.getProfileByAbility(MODULE_NAME, ABILITY_NAME, METADATA_NAME).then(data => {
util.info('getProfileByAbility promise data is: ' + JSON.stringify(data));
expect(data[0]).assertEqual(PROFILE_JSON_STRING);
}).catch(err => {
util.info('getProfileByAbility failed. Cause: ' + JSON.stringify(err));
expect().assertFail();
})
bundle.getProfileByAbility(MODULE_NAME, ABILITY_NAME, METADATA_NAME, (err, data) => {
util.info('getProfileByAbility failed. Cause: ' + JSON.stringify(err));
expect(data[0]).assertEqual(PROFILE_JSON_STRING);
done();
})
});
/*
* @tc.number: SUB_BMS_SYSTEMAPI_RUNNIING_0071
* @tc.name: getProfileByExtensionAbilityTest
* @tc.desc: Test getProfileByExtensionAbility of API9 in version9 normal project
*/
it('getProfileByExtensionAbilityPromise', 0, async function (done) {
await bundle.getProfileByExtensionAbility(MODULE_NAME, ABILITY_NAME1, METADATA_NAME1).then(data => {
util.info('getProfileByExtensionAbility promise data is: ' + JSON.stringify(data));
expect(data[0]).assertEqual(PROFILE_JSON_STRING);
}).catch(err => {
util.info('getProfileByExtensionAbility failed. Cause: ' + JSON.stringify(err));
expect().assertFail();
})
bundle.getProfileByExtensionAbility(MODULE_NAME, ABILITY_NAME1, METADATA_NAME1, (err, data) => {
util.info('getProfileByExtensionAbility failed. Cause: ' + JSON.stringify(err));
expect(data[0]).assertEqual(PROFILE_JSON_STRING);
done();
})
});
/**
* @tc.number: SUB_BMS_SYSTEMAPI_RUNNIING_0072
* @tc.name: isDefaultApplicationTest
* @tc.desc: Test isDefaultApplication of API9 in version9 normal project
*/
it('isDefaultApplication_0100', 0, async function (done) {
await defaultAppMgr.isDefaultApplication(defaultAppMgr.ApplicationType.IMAGE).then(data => {
expect(data).assertFalse()
}).catch(err => {
expect().assertFail();
})
defaultAppMgr.isDefaultApplication(defaultAppMgr.ApplicationType.IMAGE, (err, data) => {
util.info("isDefaultApplication_0100 data--- " + data)
util.info("isDefaultApplication_0100 err--- " + err)
expect(data).assertFalse()
expect(err).assertEqual(null)
done()
})
});
})
}
\ No newline at end of file
{
"app":{
"bundleName":"ohos.acts.bundle.overlay.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":9,
"targetAPIVersion":9,
"car":{
"apiCompatibleVersion":9,
"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_hap_assist_suite("bmsOverlayDemo") {
hap_profile = "entry/src/main/module.json"
hap_name = "bmsOverlayDemo"
subsystem_name = "bundlemanager"
part_name = "bundle_framework"
testonly = true
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "signature/openharmony_sx.p7b"
}
ohos_app_scope("bmsoverlaydemo_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("hjs_demo_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":bmsoverlaydemo_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
import AbilityStage from "@ohos.app.ability.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("[Demo] MyAbilityStage onCreate")
globalThis.stageOnCreateRun = 1;
globalThis.stageContext = this.context;
}
}
import FormExtension from '@ohos.app.form.FormExtensionAbility';
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.app.ability.UIAbility'
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.app.form.FormExtensionAbility';
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) 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": "stage1",
"type": "feature",
"targetModuleName": "entry1",
"targetPriority": 1,
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"metadata": [
{
"name": "ArkTSPartialUpdate",
"value": "false"
}
]
}
}
{
"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,
"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,
"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,
"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,
"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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册