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

!5430 xts元能力createModuleContext新增用例

Merge pull request !5430 from chengxingzhen/master
......@@ -18,6 +18,9 @@ group("context") {
if (is_standard_system) {
deps = [
"actscontexttest:ActsContextTest",
"actscreatemodulecontextassist:ActsCreateModuleContextAssist",
"actscreatemodulecontextassistone:ActsCreateModuleContextAssistOne",
"actscreatemodulecontexttest:ActsCreateModuleContextTest",
"scene/defpermission:DefPermission",
]
}
......
{
"app": {
"bundleName": "com.example.createmodulecontexttest",
"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": "AACommandPrintSyncTest"
}
]
}
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_hap_assist_suite("ActsCreateModuleContextAssist") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":createmodulecontext_js_assets",
":createmodulecontext_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsCreateModuleContextAssist"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("createmodulecontext_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("createmodulecontext_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("createmodulecontext_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":createmodulecontext_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
/*
* 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 AbilityStage from "@ohos.application.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("[Demo] MyAbilityStage onCreate")
}
}
\ 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 Ability from '@ohos.application.Ability'
export default class MainAbility extends Ability {
async onCreate(want, launchParam) {
globalThis.abilityContext = this.context;
console.log('MainAbility onCreate')
}
onDestroy() {
console.log('MainAbility onDestroy')
}
onWindowStageCreate(windowStage) {
console.log('MainAbility onWindowStageCreate')
windowStage.setUIContent(this.context, 'pages/index', null)
}
onWindowStageDestroy() {
console.log('MainAbility onWindowStageDestroy')
}
onForeground() {
console.log('MainAbility onForeground')
}
onBackground() {
console.log('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.
*/
@Entry
@Component
struct Index {
@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
{
"module": {
"name": "feature",
"type": "feature",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:entry_test_desc",
"mainElement": "MainAbility",
"deviceTypes": [
"phone",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:main_pages",
"uiSyntax": "ets",
"abilities": [
{
"name": "MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:MainAbility_desc",
"icon": "$media:icon",
"label": "$string:MainAbility_label",
"visible": true,
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
]
}
]
}
}
\ No newline at end of file
{
"string": [
{
"name": "entry_test_desc",
"value": "description"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
},
{
"name": "app_name",
"value": "AACommandPrintSyncTest"
},
{
"name": "description_application",
"value": "demo for test"
}
]
}
\ No newline at end of file
{
"app": {
"bundleName": "com.example.createmodulecontextassistone",
"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
}
}
}
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_hap_assist_suite("ActsCreateModuleContextAssistOne") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":createmodulecontext_js_assets",
":createmodulecontext_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsCreateModuleContextAssistOne"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("createmodulecontext_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("createmodulecontext_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("createmodulecontext_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":createmodulecontext_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
/*
* 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 AbilityStage from "@ohos.application.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("[Demo] MyAbilityStage onCreate")
}
}
\ 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 Ability from '@ohos.application.Ability'
export default class MainAbility extends Ability {
async onCreate(want, launchParam) {
globalThis.abilityContext = this.context;
console.log('MainAbility onCreate')
}
onDestroy() {
console.log('MainAbility onDestroy')
}
onWindowStageCreate(windowStage) {
console.log('MainAbility onWindowStageCreate')
windowStage.setUIContent(this.context, 'pages/index', null)
}
onWindowStageDestroy() {
console.log('MainAbility onWindowStageDestroy')
}
onForeground() {
console.log('MainAbility onForeground')
}
onBackground() {
console.log('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.
*/
@Entry
@Component
struct Index {
@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
{
"module": {
"name": "entry_assist",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:entry_test_desc",
"mainElement": "MainAbility",
"deviceTypes": [
"phone",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:main_pages",
"uiSyntax": "ets",
"abilities": [
{
"name": "MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:MainAbility_desc",
"icon": "$media:icon",
"label": "$string:MainAbility_label",
"visible": true,
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
]
}
]
}
}
\ No newline at end of file
{
"string": [
{
"name": "entry_test_desc",
"value": "description"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
},
{
"name": "app_name",
"value": "AACommandPrintSyncTest"
},
{
"name": "description_application",
"value": "demo for test"
}
]
}
\ No newline at end of file
{
"app": {
"bundleName": "com.example.createmodulecontexttest",
"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": "AACommandPrintSyncTest"
}
]
}
# 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("ActsCreateModuleContextTest") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":createmodulecontext_js_assets",
":createmodulecontext_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsCreateModuleContextTest"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("createmodulecontext_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("createmodulecontext_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("createmodulecontext_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":createmodulecontext_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for aceceshi Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "600000",
"bundle-name": "com.example.createmodulecontexttest",
"module-name": "entry_test",
"shell-timeout": "600000"
},
"kits": [
{
"test-file-name": [
"ActsCreateModuleContextTest.hap",
"ActsCreateModuleContextAssist.hap",
"ActsCreateModuleContextAssistOne.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
/*
* 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 AbilityStage from "@ohos.application.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("[Demo] MyAbilityStage onCreate")
globalThis.abilityStageContext = this.context
}
}
\ 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 Ability from '@ohos.application.Ability'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../test/List.test'
export default class MainAbility extends Ability {
async onCreate(want, launchParam) {
globalThis.abilityContext = this.context;
console.log('MainAbility onCreate')
let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
let abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
onDestroy() {
console.log('MainAbility onDestroy')
}
onWindowStageCreate(windowStage) {
console.log('MainAbility onWindowStageCreate')
windowStage.setUIContent(this.context, 'pages/index', null)
}
onWindowStageDestroy() {
console.log('MainAbility onWindowStageDestroy')
}
onForeground() {
console.log('MainAbility onForeground')
}
onBackground() {
console.log('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 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',
'-s dryRun'
])
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()
globalThis.abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var MainAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility'
let lMonitor = {
abilityName: MainAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
var cmd = 'aa start -d 0 -a 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 implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@Entry
@Component
struct Index {
@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
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { describe, it, expect } from "@ohos/hypium";
let createModuleContext: any;
let bundleName: any;
export default function actsCreateModuleContextTest() {
describe("CreateModuleContext", function () {
/**
* @tc.number: SUB_AA_CreateModuleContext_0100
* @tc.name: AbilityContext calls createModuleContext, passing in the moduleName of
* the current application hap1
* @tc.desc: Verify that the context of the application can be obtained
* @tc.level: 1
*/
it("SUB_AA_CreateModuleContext_0100", 0, async function (done) {
console.info("SUB_AA_AbilityStage_0100 begin");
createModuleContext =
globalThis.abilityContext.createModuleContext("entry_test");
bundleName = createModuleContext.applicationInfo.name;
expect(bundleName).assertEqual("com.example.createmodulecontexttest");
done();
});
/**
* @tc.number: SUB_AA_CreateModuleContext_0200
* @tc.name: AbilityContext calls createModuleContext, passing in the moduleName of
* the current application hap2
* @tc.desc: Verify that the context of the application can be obtained
* @tc.level: 3
*/
it("SUB_AA_CreateModuleContext_0200", 0, async function (done) {
console.log("SUB_AA_AbilityStage_0100 begin");
createModuleContext =
globalThis.abilityContext.createModuleContext("feature");
bundleName = createModuleContext.applicationInfo.name;
expect(bundleName).assertEqual("com.example.createmodulecontexttest");
done();
});
/**
* @tc.number: SUB_AA_CreateModuleContext_0300
* @tc.name: AbilityContext calls createModuleContext, passing in the moduleName of
* the cross-application hap1
* @tc.desc: Verify that the context of the application can not be obtained
* @tc.level: 3
*/
it("SUB_AA_CreateModuleContext_0300", 0, async function (done) {
console.info("SUB_AA_CreateModuleContext_0300 begin");
createModuleContext =
globalThis.abilityContext.createModuleContext("entry_assist");
expect(createModuleContext).assertUndefined();
done();
});
/**
* @tc.number: SUB_AA_CreateModuleContext_0400
* @tc.name: AbilityContext calls createModuleContext, passing in a non-existing moduleName
* @tc.desc: Verify that the context of the application can not be obtained
* @tc.level: 3
*/
it("SUB_AA_CreateModuleContext_0400", 0, async function (done) {
console.info("SUB_AA_CreateModuleContext_0400 begin");
createModuleContext =
globalThis.abilityContext.createModuleContext("abc");
expect(createModuleContext).assertUndefined();
done();
});
/**
* @tc.number: SUB_AA_CreateModuleContext_0500
* @tc.name: AbilityContext calls createModuleContext, and the incoming moduleName is undefined
* @tc.desc: Verify that the context of the application can not be obtained
* @tc.level: 3
*/
it("SUB_AA_CreateModuleContext_0500", 0, async function (done) {
console.info("SUB_AA_CreateModuleContext_0500 begin");
createModuleContext =
globalThis.abilityContext.createModuleContext(undefined);
expect(createModuleContext).assertUndefined();
done();
});
/**
* @tc.number: SUB_AA_CreateModuleContext_0600
* @tc.name: AbilityStageContext calls createModuleContext, passing in the moduleName of
* the current application hap1
* @tc.desc: Verify that the context of the application can be obtained
* @tc.level: 3
*/
it("SUB_AA_CreateModuleContext_0600", 0, async function (done) {
console.info("SUB_AA_CreateModuleContext_0600 begin");
createModuleContext =
globalThis.abilityStageContext.createModuleContext("entry_test");
bundleName = createModuleContext.applicationInfo.name;
expect(bundleName).assertEqual("com.example.createmodulecontexttest");
done();
});
/**
* @tc.number: SUB_AA_CreateModuleContext_0700
* @tc.name: AbilityStageContext calls createModuleContext, passing in the moduleName of
* the current application hap2
* @tc.desc: Verify that the context of the application can be obtained
* @tc.level: 3
*/
it("SUB_AA_CreateModuleContext_0700", 0, async function (done) {
console.info("SUB_AA_CreateModuleContext_0700 begin");
createModuleContext =
globalThis.abilityStageContext.createModuleContext("feature");
bundleName = createModuleContext.applicationInfo.name;
expect(bundleName).assertEqual("com.example.createmodulecontexttest");
done();
});
/**
* @tc.number: SUB_AA_CreateModuleContext_0800
* @tc.name: AbilityStageContext calls createModuleContext, passing in the moduleName of
* the cross-application hap1
* @tc.desc: Verify that the context of the application can not be obtained
* @tc.level: 3
*/
it("SUB_AA_CreateModuleContext_0800", 0, async function (done) {
console.info("SUB_AA_CreateModuleContext_0800 begin");
createModuleContext =
globalThis.abilityContext.createModuleContext("entry_assist");
expect(createModuleContext).assertUndefined();
done();
});
/**
* @tc.number: SUB_AA_CreateModuleContext_0900
* @tc.name: AbilityStageContext calls createModuleContext, passing in a non-existing moduleName
* @tc.desc: Verify that the context of the application can not be obtained
* @tc.level: 3
*/
it("SUB_AA_CreateModuleContext_0900", 0, async function (done) {
console.info("SUB_AA_CreateModuleContext_0900 begin");
createModuleContext =
globalThis.abilityContext.createModuleContext("createmodue");
expect(createModuleContext).assertUndefined();
done();
});
/**
* @tc.number: SUB_AA_CreateModuleContext_1000
* @tc.name: AbilityStageContext calls createModuleContext, and the incoming moduleName is undefined
* @tc.desc: Verify that the context of the application can not be obtained
* @tc.level: 3
*/
it("SUB_AA_CreateModuleContext_1000", 0, async function (done) {
console.info("SUB_AA_CreateModuleContext_1000 begin");
createModuleContext =
globalThis.abilityStageContext.createModuleContext(undefined);
expect(createModuleContext).assertUndefined();
done();
});
});
}
/*
* 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 actsCreateModuleContextTest from './CreateModuleContext.test'
export default function testsuite() {
actsCreateModuleContextTest()
}
\ No newline at end of file
{
"module": {
"name": "entry_test",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:entry_test_desc",
"mainElement": "MainAbility",
"deviceTypes": [
"phone",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:main_pages",
"uiSyntax": "ets",
"abilities": [
{
"name": "MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:MainAbility_desc",
"icon": "$media:icon",
"label": "$string:MainAbility_label",
"visible": true,
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
]
}
]
}
}
\ No newline at end of file
{
"string": [
{
"name": "entry_test_desc",
"value": "description"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
},
{
"name": "app_name",
"value": "AACommandPrintSyncTest"
},
{
"name": "description_application",
"value": "demo for test"
}
]
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册