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

!6438 xts-元能力新增context相关用例

Merge pull request !6438 from chengxingzhen/master
...@@ -60,7 +60,7 @@ ...@@ -60,7 +60,7 @@
"launchType": "singleton" "launchType": "singleton"
} }
], ],
"reqPermissions": [ "requestPermissions": [
{ {
"name":"ohos.permission.START_ABILITIES_FROM_BACKGROUND", "name":"ohos.permission.START_ABILITIES_FROM_BACKGROUND",
"reason":"need use ohos.permission.START_ABILITIES_FROM_BACKGROUND" "reason":"need use ohos.permission.START_ABILITIES_FROM_BACKGROUND"
......
...@@ -21,6 +21,7 @@ group("context") { ...@@ -21,6 +21,7 @@ group("context") {
"actscreatemodulecontextassist:ActsCreateModuleContextAssist", "actscreatemodulecontextassist:ActsCreateModuleContextAssist",
"actscreatemodulecontextassistone:ActsCreateModuleContextAssistOne", "actscreatemodulecontextassistone:ActsCreateModuleContextAssistOne",
"actscreatemodulecontexttest:ActsCreateModuleContextTest", "actscreatemodulecontexttest:ActsCreateModuleContextTest",
"actsstagecontext:actsstagecontext",
"scene/defpermission:DefPermission", "scene/defpermission:DefPermission",
] ]
} }
......
# 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")
group("actsstagecontext") {
testonly = true
if (is_standard_system) {
deps = [
"actsstagecontextassistone:ActsStageContextAssistOne",
"actsstagecontextassisttwo:ActsStageContextAssistTwo",
"actsstagecontextpropertiestest:ActsStageContextPropertiesTest",
]
}
}
{
"app": {
"bundleName": "com.example.stagecontextpropertiestest",
"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
}
}
}
\ 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_hap_assist_suite("ActsStageContextAssistOne") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":stagecontextassistone_js_assets",
":stagecontextassistone_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsStageContextAssistOne"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("stagecontextassistone_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("stagecontextassistone_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("stagecontextassistone_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":stagecontextassistone_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.info("ActsStageContextAssistOne StageAbility onCreate")
globalThis.abilityStageContextA = 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 commonEvent from '@ohos.commonEvent'
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
console.info('ActsStageContextAssistOne MainAbility3 onCreate')
}
onDestroy() {
console.info('ActsStageContextAssistOne MainAbility3 onDestroy')
}
onWindowStageCreate(windowStage) {
console.info('ActsStageContextAssistOne MainAbility3 onWindowStageCreate')
windowStage.setUIContent(this.context, 'pages/index', null)
}
onWindowStageDestroy() {
console.info('ActsStageContextAssistOne MainAbility3 onWindowStageDestroy')
}
onForeground() {
console.info('ActsStageContextAssistOne MainAbility3 onForeground')
globalThis.abilityContextA = this.context
commonEvent.publish("StartMainAbility3_CommonEvent_ContextOne", () => {
console.log("Publish StartMainAbility3_CommonEvent_ContextOne callback")
})
}
onBackground() {
console.info('ActsStageContextAssistOne MainAbility3 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 {
aboutToAppear() {
console.info('MainAbility index aboutToAppear')
console.info('start run testcase!!!')
}
@State message: string = 'MainAbility3 Hello'
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_assistone",
"type": "feature",
"srcEntrance": "./ets/Application/MyAbilityStage.ts",
"description": "$string:entry_test_desc",
"mainElement": "MainAbility3",
"deviceTypes": [
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:main_pages",
"uiSyntax": "ets",
"abilities": [
{
"name": "MainAbility3",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:MainAbility_desc",
"icon": "$media:icon",
"label": "$string:MainAbility_label",
"launchType": "specified",
"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": "feature_MainAbility"
},
{
"name": "app_name",
"value": "ActsStageContextAssistOne"
},
{
"name": "description_application",
"value": "demo for test"
}
]
}
\ No newline at end of file
{
"app": {
"bundleName": "com.example.actsstagecontextassisttwo",
"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("ActsStageContextAssistTwo") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":stagecontextassisttwo_js_assets",
":stagecontextassisttwo_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsStageContextAssistTwo"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("stagecontextassisttwo_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("stagecontextassisttwo_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("stagecontextassisttwo_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":stagecontextassisttwo_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"
import commonEvent from '@ohos.commonEvent'
function sleep(delay) {
let start = new Date().getTime();
while (true) {
if (new Date().getTime() - start > delay) {
break;
}
}
}
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.info("ActsStageContextAssistTwo AbilityStage onCreate")
globalThis.abilityStageContextB = this.context
}
onAcceptWant(want) {
console.log("ActsStageContextAssistTwo onAcceptWant called want:" + JSON.stringify(want));
async function publishContext() {
let stageContextJson = {
'cacheDir': globalThis.abilityStageContextB.cacheDir, 'tempDir': globalThis.abilityStageContextB.tempDir,
'filesDir': globalThis.abilityStageContextB.filesDir, 'distributedFilesDir': globalThis.abilityStageContextB.distributedFilesDir,
'databaseDir': globalThis.abilityStageContextB.databaseDir, 'preferencesDir': globalThis.abilityStageContextB.preferencesDir,
'bundleCodeDir': globalThis.abilityStageContextB.bundleCodeDir
};
let stageAppContext = globalThis.abilityStageContextB.getApplicationContext()
let stageAppContextJson = {
'cacheDir': stageAppContext.cacheDir, 'tempDir': stageAppContext.tempDir, 'filesDir': stageAppContext.filesDir,
'distributedFilesDir': stageAppContext.distributedFilesDir, 'databaseDir': stageAppContext.databaseDir,
'preferencesDir': stageAppContext.preferencesDir, 'bundleCodeDir': stageAppContext.bundleCodeDir
};
let bundleContext = globalThis.abilityStageContextB.createBundleContext("com.example.actsstagecontextassisttwo");
let result = await bundleContext.resourceManager.getString(16777219)
let appBundleContext = stageAppContext.createBundleContext("com.example.actsstagecontextassisttwo");
let result1 = await appBundleContext.resourceManager.getString(16777219)
console.log("ActsStageContextAssistTwo getLabel " + JSON.stringify(result1))
let stageBundleContextJson = {
'cacheDir': bundleContext.cacheDir, 'tempDir': bundleContext.tempDir, 'filesDir': bundleContext.filesDir,
'distributedFilesDir': bundleContext.distributedFilesDir, 'databaseDir': bundleContext.databaseDir,
'preferencesDir': bundleContext.preferencesDir, 'bundleCodeDir': bundleContext.bundleCodeDir
};
let stageAppBundleContextJson = {
'cacheDir': appBundleContext.cacheDir, 'tempDir': appBundleContext.tempDir, 'filesDir': appBundleContext.filesDir,
'distributedFilesDir': appBundleContext.distributedFilesDir, 'databaseDir': appBundleContext.databaseDir,
'preferencesDir': appBundleContext.preferencesDir, 'bundleCodeDir': appBundleContext.bundleCodeDir
};
let commonEventData = {
parameters: {
abilityStageContextAssistOne: stageContextJson,
abilityStageAppContextAssistOne: stageAppContextJson,
abilityStageLabel: result,
abilityStageAppLabel: result1,
abilityStageBundleContxtAssistOne: stageBundleContextJson,
abilityStageAppBundleContextAssistOne: stageAppBundleContextJson
}
}
commonEvent.publish("AssistContextTwo_StageAbilityA_Start_CommonEvent", commonEventData, () => {
console.log("Publish AssistContextTwo_StageAbilityA_Start_CommonEvent callback")
})
}
publishContext()
sleep(500)
let abilityId = want.parameters.startId.toString();
return abilityId;
}
}
\ 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 commonEvent from '@ohos.commonEvent'
import bundle from '@ohos.bundle';
import dataAbility from '@ohos.data.dataAbility';
export default class MainAbility extends Ability {
onCreate(want: any, launchParam: any) {
console.info('ActsStageContextAssistTwo MainAbility4 onCreate')
}
onDestroy() {
console.info('MainAbilityMonitor onDestroy')
}
onWindowStageCreate(windowStage) {
console.info('ActsStageContextAssistTwo MainAbility4 onWindowStageCreate')
windowStage.setUIContent(this.context, 'MainAbility/pages/index', null)
}
onWindowStageDestroy() {
console.info('ActsStageContextAssistTwo MainAbility4 onWindowStageDestroy')
}
async onForeground() {
console.info('ActsStageContextAssistTwo MainAbility4 onForeground')
let contextJson = {
'cacheDir': this.context.cacheDir, 'tempDir': this.context.tempDir, 'filesDir': this.context.filesDir,
'distributedFilesDir': this.context.distributedFilesDir, 'databaseDir': this.context.databaseDir,
'preferencesDir': this.context.preferencesDir, 'bundleCodeDir': this.context.bundleCodeDir
};
let abilityAppContext = this.context.getApplicationContext()
let appContextJson = {
'cacheDir': abilityAppContext.cacheDir, 'tempDir': abilityAppContext.tempDir, 'filesDir': abilityAppContext.filesDir,
'distributedFilesDir': abilityAppContext.distributedFilesDir, 'databaseDir': abilityAppContext.databaseDir,
'preferencesDir': abilityAppContext.preferencesDir, 'bundleCodeDir': abilityAppContext.bundleCodeDir
};
let bundleContext = this.context.createBundleContext("com.example.actsstagecontextassisttwo")
let bundleAppContext = abilityAppContext.createBundleContext("com.example.actsstagecontextassisttwo")
let result = await bundleContext.resourceManager.getString(16777219)
let bundleContextJson = {
'cacheDir': bundleContext.cacheDir, 'tempDir': bundleContext.tempDir, 'filesDir': bundleContext.filesDir,
'distributedFilesDir': bundleContext.distributedFilesDir, 'databaseDir': bundleContext.databaseDir,
'preferencesDir': bundleContext.preferencesDir, 'bundleCodeDir': bundleContext.bundleCodeDir
};
let appBundleContextJson = {
'cacheDir': bundleAppContext.cacheDir, 'tempDir': bundleAppContext.tempDir, 'filesDir': bundleAppContext.filesDir,
'distributedFilesDir': bundleAppContext.distributedFilesDir, 'databaseDir': bundleAppContext.databaseDir,
'preferencesDir': bundleAppContext.preferencesDir, 'bundleCodeDir': bundleAppContext.bundleCodeDir
};
let errCode;
try {
this.context.createBundleContext("com.example.stagecontextpropertiestest")
} catch (error) {
console.log("ActsStageContextAssistTwo createBundleContext is error:" + JSON.stringify(error))
errCode = error.code
}
let commonEventData = {
parameters: {
abilityContextAssistTwo: contextJson,
abilityAppContextAssistTwo: appContextJson,
abilityLabel: result,
abilityBundleContextAssistTwo: bundleContextJson,
abilityAppBundleContextAssistTwo: appBundleContextJson,
abilityBundleContextTest: errCode
}
}
commonEvent.publish("StartMainAbility4_CommonEvent_ContextOne", commonEventData, () => {
console.log("Publish StartMainAbility4_CommonEvent_ContextOne callback")
})
}
onBackground() {
console.info('ActsStageContextAssistTwo MainAbility4 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 {
aboutToAppear() {
console.info('MainAbility index aboutToAppear')
console.info('start run testcase!!!')
}
@State message: string = 'MainAbility4 Hello'
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_assisttow",
"type": "entry",
"srcEntrance": "./ets/Application/MyAbilityStage.ts",
"description": "$string:entry_test_desc",
"mainElement": "MainAbility4",
"deviceTypes": [
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:main_pages",
"uiSyntax": "ets",
"abilities": [
{
"name": "MainAbility4",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:MainAbility_desc",
"icon": "$media:icon",
"label": "$string:MainAbility_label",
"visible": true,
"launchType": "specified",
"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": "entry_MainAbility"
},
{
"name": "app_name",
"value": "ActsStageContextAssistTwo"
},
{
"name": "description_application",
"value": "demo for test"
}
]
}
\ No newline at end of file
{
"app": {
"bundleName": "com.example.stagecontextpropertiestest",
"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_js_hap_suite("ActsStageContextPropertiesTest") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":stagecontextproperties_js_assets",
":stagecontextproperties_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsStageContextPropertiesTest"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("stagecontextproperties_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("stagecontextproperties_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("stagecontextproperties_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":stagecontextproperties_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for aceceshi Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "600000",
"bundle-name": "com.example.stagecontextpropertiestest",
"module-name": "entry_test",
"shell-timeout": "600000",
"testcase-timeout": "15000"
},
"kits": [
{
"test-file-name": [
"ActsStageContextPropertiesTest.hap",
"ActsStageContextAssistOne.hap",
"ActsStageContextAssistTwo.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.info("MyAbilityStageMonitor 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 {
onCreate(want, launchParam) {
// Ability is creating, initialize resources for this ability
console.log("ActsStageContextPropertiesTest MainAbility onCreate")
globalThis.abilityWant = want;
globalThis.abilityContext = this.context
let abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
let abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("ActsStageContextPropertiesTest MainAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("ActsStageContextPropertiesTest MainAbility onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/index/index", null)
console.log("ActsStageContextPropertiesTest MainAbility onWindowStageCreate finish")
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("ActsStageContextPropertiesTest MainAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("ActsStageContextPropertiesTest MainAbility onForeground")
}
onBackground() {
// Ability has back to background
console.log("ActsStageContextPropertiesTest 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 Ability from '@ohos.application.Ability'
import commonEvent from '@ohos.commonEvent'
export default class MainAbility2 extends Ability {
onCreate(want,launchParam){
// Ability is creating, initialize resources for this ability
console.log("ActsStageContextPropertiesTest MainAbility2 onCreate")
globalThis.abilityWant = want;
globalThis.abilityContext2 = this.context
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("ActsStageContextPropertiesTest MainAbility2 onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("ActsStageContextPropertiesTest MainAbility2 onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/secone/second ", null)
console.log("ActsStageContextPropertiesTest MainAbility2 onWindowStageCreate finish")
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("ActsStageContextPropertiesTest MainAbility2 onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("ActsStageContextPropertiesTest MainAbility2 onForeground")
}
onBackground() {
// Ability has back to background
console.log("ActsStageContextPropertiesTest MainAbility2 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'
let abilityDelegator = undefined
let 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()
let testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility'
let lMonitor = {
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
let 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 {
aboutToAppear(){
}
build() {
Flex({ direction:FlexDirection.Column, alignItems:ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('MainAbility 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 = "SecondMainAbility 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 stageContextPropertiesTest from './StageContextProperties.test'
export default function testsuite() {
stageContextPropertiesTest(globalThis.abilityContext)
}
\ 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, afterEach, beforeAll } from '@ohos/hypium'
import commonEvent from '@ohos.commonEvent'
let Subscriber;
let TAG;
let subscriberInfo_AbilityContext = {
events: ["StartMainAbility3_CommonEvent_ContextOne", "StartMainAbility4_CommonEvent_ContextOne",
"AssistContextTwo_StageAbilityA_Start_CommonEvent"],
};
export default function stageContextPropertiesTest(abilityContext) {
describe('ActsStageContextPropertiesTest', function () {
beforeAll(async (done) => {
console.log("ActsStageContextPropertiesTest afterAll called");
await abilityContext.startAbility({
bundleName: "com.example.stagecontextpropertiestest",
abilityName: "MainAbility2"
}).then((data) => {
console.log('ActsStageContextPropertiesTest - startMainAbility2: ' + JSON.stringify(data));
}).catch((err) => {
console.log("ActsStageContextPropertiesTest - startMainAbility2 failed: "
+ JSON.stringify(err));
done()
})
setTimeout(function () {
console.log("ActsStageContextPropertiesTest afterAll end");
done();
}, 3000);
})
afterEach(async (done) => {
console.log("ActsStageContextPropertiesTest afterEach called");
let wantInfo = {
bundleName: "com.example.stagecontextpropertiestest",
abilityName: "MainAbility"
}
await abilityContext.startAbility(wantInfo).then((data) => {
console.log("ActsStageContextPropertiesTest startMainAbility data : " + JSON.stringify(data));
}).catch((err) => {
console.log("ActsStageContextPropertiesTest startMainAbility err : " + JSON.stringify(err));
})
setTimeout(function () {
console.log("ActsStageContextPropertiesTest afterEach end");
done();
}, 1500);
})
/**
* @tc.number: SUB_AA_OpenHarmony_Context_0100
* @tc.name: Check that context paths of different Ability in the same hap are the same.
* @tc.desc: Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_Context_0100', 0, async function (done) {
TAG = "SUB_AA_OpenHarmony_Context_0100"
console.log(TAG + "--- start");
checkAbilityContextDir();
checkContextDirEqualA(abilityContext, globalThis.abilityContext2);
done()
console.log(TAG + "--- end");
});
/**
* @tc.number: SUB_AA_OpenHarmony_Context_0200
* @tc.name: Check that context paths of different Ability in the same hap are the same.
* @tc.desc: Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_Context_0200', 0, async function (done) {
TAG = "SUB_AA_OpenHarmony_Context_0200"
console.log(TAG + "--- start");
checkApplicationContextDir(abilityContext.getApplicationContext());
checkApplicationContextDir(globalThis.abilityStageContext.getApplicationContext());
checkApplicationContextDir(globalThis.abilityContext2.getApplicationContext());
checkContextDirEqualA(abilityContext.getApplicationContext(),
globalThis.abilityContext2.getApplicationContext())
checkContextDirEqualA(abilityContext.getApplicationContext(),
globalThis.abilityStageContext.getApplicationContext())
done()
});
/**
* @tc.number: SUB_AA_OpenHarmony_Context_0300
* @tc.name: Check that context paths of different Ability in the different hap are the same.
* @tc.desc: Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_Context_0300', 0, async function (done) {
TAG = "SUB_AA_OpenHarmony_Context_0300"
console.log(TAG + " --- start");
checkAbilityContextDir();
function SubscribeCallBack(err, data) {
console.log(TAG + " Subscribe CallBack data: " + JSON.stringify(data)
+ "err: " + JSON.stringify(err));
checkContextDirEqualB(abilityContext, globalThis.abilityContextA)
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
}
await commonEvent.createSubscriber(subscriberInfo_AbilityContext).then(async (data) => {
console.log(TAG + " Create Subscriber");
Subscriber = data;
await commonEvent.subscribe(Subscriber, SubscribeCallBack);
})
function UnSubscribeCallback() {
console.log(TAG + " UnSubscribe CallBack");
done();
}
await abilityContext.startAbility({
bundleName: "com.example.stagecontextpropertiestest",
abilityName: "MainAbility3",
}).then((data) => {
console.log(TAG + ' - startAbility: ' + JSON.stringify(data));
}).catch((err) => {
console.log(TAG + " - start failed" + JSON.stringify(err));
expect.assertFail()
done()
})
});
/**
* @tc.number: SUB_AA_OpenHarmony_Context_0400
* @tc.name: Check that ApplicationContext paths of different Ability in the different hap are the same.
* @tc.desc: Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_Context_0400', 0, async function (done) {
TAG = "SUB_AA_OpenHarmony_Context_0400"
console.log(TAG + " --- start");
checkAbilityStageContextDir();
function SubscribeCallBack(err, data) {
console.log(TAG + " Subscribe CallBack data: " + JSON.stringify(data)
+ "err: " + JSON.stringify(err));
checkContextDirEqualB(globalThis.abilityStageContext, globalThis.abilityStageContextA)
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
}
await commonEvent.createSubscriber(subscriberInfo_AbilityContext).then(async (data) => {
console.log(TAG + " Create Subscriber");
Subscriber = data;
await commonEvent.subscribe(Subscriber, SubscribeCallBack);
})
function UnSubscribeCallback() {
console.log(TAG + " UnSubscribe CallBack");
done();
}
await abilityContext.startAbility({
bundleName: "com.example.stagecontextpropertiestest",
abilityName: "MainAbility3",
}).then((data) => {
console.log(TAG + ' - startAbility: ' + JSON.stringify(data));
}).catch((err) => {
console.log(TAG + " - start failed" + JSON.stringify(err));
expect.assertFail()
done()
})
});
/**
* @tc.number: SUB_AA_OpenHarmony_Context_0500
* @tc.name: Check that ApplicationContext paths of different Ability in the different hap are the same.
* @tc.desc: Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_Context_0500', 0, async function (done) {
TAG = "SUB_AA_OpenHarmony_Context_0500"
console.log(TAG + " --- start");
checkApplicationContextDir(abilityContext.getApplicationContext());
function SubscribeCallBack(err, data) {
console.log(TAG + " Subscribe CallBack data: " + JSON.stringify(data)
+ "err: " + JSON.stringify(err));
checkContextDirEqualA(abilityContext.getApplicationContext(),
globalThis.abilityContextA.getApplicationContext())
checkContextDirEqualA(abilityContext.getApplicationContext(),
globalThis.abilityStageContextA.getApplicationContext())
checkContextDirEqualA(abilityContext.getApplicationContext(),
globalThis.abilityStageContext.getApplicationContext())
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
}
await commonEvent.createSubscriber(subscriberInfo_AbilityContext).then(async (data) => {
console.log(TAG + " Create Subscriber");
Subscriber = data;
await commonEvent.subscribe(Subscriber, SubscribeCallBack);
})
function UnSubscribeCallback() {
console.log(TAG + " UnSubscribe CallBack");
done();
}
await abilityContext.startAbility({
bundleName: "com.example.stagecontextpropertiestest",
abilityName: "MainAbility3",
}).then((data) => {
console.log(TAG + ' - startAbility: ' + JSON.stringify(data));
}).catch((err) => {
console.log(TAG + " - start failed" + JSON.stringify(err));
expect.assertFail()
done()
})
});
/**
* @tc.number: SUB_AA_OpenHarmony_Context_0600
* @tc.name: Check that context paths of different Ability in the different hap are the same.
* @tc.desc: Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_Context_0600', 0, async function (done) {
TAG = "SUB_AA_OpenHarmony_Context_0600"
console.log(TAG + " --- start");
checkAbilityContextDir();
function SubscribeCallBack(err, data) {
console.log(TAG + " Subscribe CallBack data: " + JSON.stringify(data)
+ "err: " + JSON.stringify(err));
if (data.event == "StartMainAbility4_CommonEvent_ContextOne") {
checkContextDirEqualC(abilityContext, data.parameters.abilityContextAssistTwo)
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
}
}
await commonEvent.createSubscriber(subscriberInfo_AbilityContext).then(async (data) => {
console.log(TAG + " Create Subscriber");
Subscriber = data;
await commonEvent.subscribe(Subscriber, SubscribeCallBack);
})
function UnSubscribeCallback() {
console.log(TAG + " UnSubscribe CallBack");
done();
}
await abilityContext.startAbility({
bundleName: "com.example.actsstagecontextassisttwo",
abilityName: "MainAbility4",
parameters: {
startId: 1,
}
}).then((data) => {
console.log(TAG + ' - startAbility: ' + JSON.stringify(data));
}).catch((err) => {
console.log(TAG + " - start failed" + JSON.stringify(err));
expect.assertFail()
done()
})
});
/**
* @tc.number: SUB_AA_OpenHarmony_Context_0700
* @tc.name: Check that context paths of different Ability in the different hap are the same.
* @tc.desc: Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_Context_0700', 0, async function (done) {
TAG = "SUB_AA_OpenHarmony_Context_0700"
console.log(TAG + " --- start");
checkAbilityStageContextDir();
function SubscribeCallBack(err, data) {
console.log(TAG + " Subscribe CallBack data: " + JSON.stringify(data)
+ "err: " + JSON.stringify(err));
if (data.event == "AssistContextTwo_StageAbilityA_Start_CommonEvent") {
checkContextDirEqualC(abilityContext, data.parameters.abilityStageContextAssistOne)
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
}
}
await commonEvent.createSubscriber(subscriberInfo_AbilityContext).then(async (data) => {
console.log(TAG + " Create Subscriber");
Subscriber = data;
await commonEvent.subscribe(Subscriber, SubscribeCallBack);
})
function UnSubscribeCallback() {
console.log(TAG + " UnSubscribe CallBack");
done();
}
await abilityContext.startAbility({
bundleName: "com.example.actsstagecontextassisttwo",
abilityName: "MainAbility4",
parameters: {
startId: 2,
}
}).then((data) => {
console.log(TAG + ' - startAbility: ' + JSON.stringify(data));
}).catch((err) => {
console.log(TAG + " - start failed" + JSON.stringify(err));
expect.assertFail()
done()
})
});
/**
* @tc.number: SUB_AA_OpenHarmony_Context_0800
* @tc.name: Check that ApplicationContext paths of different Ability in the different hap are the same.
* @tc.desc: Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_Context_0800', 0, async function (done) {
TAG = "SUB_AA_OpenHarmony_Context_0800"
console.log(TAG + " --- start");
let num = 0;
let abilityAppContext;
let abilityStageAppContext;
checkApplicationContextDir(abilityContext.getApplicationContext());
function SubscribeCallBack(err, data) {
console.log(TAG + " Subscribe CallBack data: " + JSON.stringify(data)
+ "err: " + JSON.stringify(err));
if (data.event == 'AssistContextTwo_StageAbilityA_Start_CommonEvent') {
console.log(TAG + " AssistContextTwo_StageAbilityA_Start_CommonEvent")
num++;
abilityStageAppContext = data.parameters.abilityStageAppContextAssistOne
}
if (data.event == 'StartMainAbility4_CommonEvent_ContextOne') {
console.log(TAG + " StartMainAbility4_CommonEvent_ContextOne")
num++;
abilityAppContext = data.parameters.abilityAppContextAssistTwo
}
if (num == 2) {
console.log(TAG + " start expect");
checkContextDirEqualA(abilityContext.getApplicationContext(), abilityAppContext)
checkContextDirEqualA(abilityContext.getApplicationContext(), abilityStageAppContext)
checkContextDirEqualA(abilityContext.getApplicationContext(),
globalThis.abilityStageContext.getApplicationContext())
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
}
}
await commonEvent.createSubscriber(subscriberInfo_AbilityContext).then(async (data) => {
console.log(TAG + " Create Subscriber");
Subscriber = data;
await commonEvent.subscribe(Subscriber, SubscribeCallBack);
})
function UnSubscribeCallback() {
console.log(TAG + " UnSubscribe CallBack");
done();
}
await abilityContext.startAbility({
bundleName: "com.example.actsstagecontextassisttwo",
abilityName: "MainAbility4",
parameters: {
startId: 3,
}
}).then((data) => {
console.log(TAG + ' - startAbility: ' + JSON.stringify(data));
}).catch((err) => {
console.log(TAG + " - start failed" + JSON.stringify(err));
expect.assertFail()
done()
})
});
/**
* @tc.number: SUB_AA_OpenHarmony_Context_0900
* @tc.name: Check that label paths of different Ability in the different hap are the same.
* @tc.desc: Function test
* @tc.level 0
*/
it('SUB_AA_OpenHarmony_Context_0900', 0, async function (done) {
TAG = "SUB_AA_OpenHarmony_Context_0900"
console.log(TAG + " --- start");
let result = await abilityContext.resourceManager.getString(16777219);
console.log(TAG + " : result = " + JSON.stringify(result));
expect(result).assertEqual("feature_MainAbility");
done();
});
/**
* @tc.number: SUB_AA_OpenHarmony_Context_1000
* @tc.name: Check that label paths of different Ability in the different hap are the same.
* @tc.desc: Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_Context_1000', 0, async function (done) {
TAG = "SUB_AA_OpenHarmony_Context_1000"
console.log(TAG + " --- start");
let result = await globalThis.abilityStageContext.resourceManager.getString(16777219);
console.log(TAG + " : result = " + JSON.stringify(result));
expect(result).assertEqual("feature_MainAbility");
done();
});
/**
* @tc.number: SUB_AA_OpenHarmony_Context_1100
* @tc.name: Check that label paths of different Ability in the different hap are the same.
* @tc.desc: Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_Context_1100', 0, async function (done) {
TAG = "SUB_AA_OpenHarmony_Context_1100"
console.log(TAG + " --- start");
let result = await globalThis.abilityStageContext.getApplicationContext()
.resourceManager.getString(16777219);
console.log(TAG + " : result = " + JSON.stringify(result));
expect(result).assertEqual("feature_MainAbility");
done();
});
/**
* @tc.number: SUB_AA_OpenHarmony_Context_1200
* @tc.name: Check that label paths of different Ability in the different hap are the same.
* @tc.desc: Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_Context_1200', 0, async function (done) {
TAG = "SUB_AA_OpenHarmony_Context_1200"
console.log(TAG + " --- start");
async function SubscribeCallBack(err, data) {
console.log(TAG + " Subscribe CallBack data: " + JSON.stringify(data)
+ "err: " + JSON.stringify(err));
let result = await globalThis.abilityContextA.resourceManager.getString(16777219);
console.log(TAG + " : result = " + JSON.stringify(result));
expect(result).assertEqual("feature_MainAbility");
checkContextDirEqualB(abilityContext, globalThis.abilityContextA)
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
}
await commonEvent.createSubscriber(subscriberInfo_AbilityContext).then(async (data) => {
console.log(TAG + " Create Subscriber");
Subscriber = data;
await commonEvent.subscribe(Subscriber, SubscribeCallBack);
})
function UnSubscribeCallback() {
console.log(TAG + " UnSubscribe CallBack");
done();
}
await abilityContext.startAbility({
bundleName: "com.example.stagecontextpropertiestest",
abilityName: "MainAbility3",
}).then((data) => {
console.log(TAG + ' - startAbility: ' + JSON.stringify(data));
}).catch((err) => {
console.log(TAG + " - start failed" + JSON.stringify(err));
expect.assertFail()
done()
})
});
/**
* @tc.number: SUB_AA_OpenHarmony_Context_1300
* @tc.name: Call createBundleContext through context and pass in the wrong package
* @tc.desc: Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_Context_1300', 0, async function (done) {
TAG = "SUB_AA_OpenHarmony_Context_1300"
console.log(TAG + " --- start");
try {
abilityContext.createBundleContext(" ");
expect.assertFail()
} catch (error) {
console.log(TAG + " createBundleContext = " + JSON.stringify(error));
done()
}
});
/**
* @tc.number: SUB_AA_OpenHarmony_Context_1400
* @tc.name: The resource obtained through getString is the same as config.json in the label resources are the same
* @tc.desc: Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_Context_1400', 0, async function (done) {
TAG = "SUB_AA_OpenHarmony_Context_1400"
console.log(TAG + " --- start");
let bundleContext = abilityContext.createBundleContext("com.example.stagecontextpropertiestest");
let result = await bundleContext.resourceManager.getString(16777219);
console.log(TAG + " : result = " + JSON.stringify(result));
expect(result).assertEqual("feature_MainAbility");
done();
});
/**
* @tc.number: SUB_AA_OpenHarmony_Context_1500
* @tc.name: The resource obtained through getString is the same as config.json in the label resources are the same
* @tc.desc: Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_Context_1500', 0, async function (done) {
TAG = "SUB_AA_OpenHarmony_Context_1500"
console.log(TAG + " --- start");
function SubscribeCallBack(err, data) {
console.log(TAG + " Subscribe CallBack data: " + JSON.stringify(data)
+ "err: " + JSON.stringify(err));
if (data.event == 'StartMainAbility4_CommonEvent_ContextOne') {
expect(data.parameters.abilityLabel).assertEqual("entry_MainAbility");
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
}
}
await commonEvent.createSubscriber(subscriberInfo_AbilityContext).then(async (data) => {
console.log(TAG + " Create Subscriber");
Subscriber = data;
await commonEvent.subscribe(Subscriber, SubscribeCallBack);
})
function UnSubscribeCallback() {
console.log(TAG + " UnSubscribe CallBack");
done();
}
await abilityContext.startAbility({
bundleName: "com.example.actsstagecontextassisttwo",
abilityName: "MainAbility4",
parameters: {
startId: 4,
}
}).then((data) => {
console.log(TAG + ' - startAbility: ' + JSON.stringify(data));
}).catch((err) => {
console.log(TAG + " - start failed" + JSON.stringify(err));
expect.assertFail()
done()
})
});
/**
* @tc.number: SUB_AA_OpenHarmony_Context_1600
* @tc.name: The resource obtained through getString is the same as config.json in the label resources are the same
* @tc.desc: Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_Context_1600', 0, async function (done) {
TAG = "SUB_AA_OpenHarmony_Context_1600"
console.log(TAG + " --- start");
function SubscribeCallBack(err, data) {
console.log(TAG + " Subscribe CallBack data: " + JSON.stringify(data)
+ "err: " + JSON.stringify(err));
if (data.event == 'AssistContextTwo_StageAbilityA_Start_CommonEvent') {
expect(data.parameters.abilityStageLabel).assertEqual("entry_MainAbility");
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
}
}
await commonEvent.createSubscriber(subscriberInfo_AbilityContext).then(async (data) => {
console.log(TAG + " Create Subscriber");
Subscriber = data;
await commonEvent.subscribe(Subscriber, SubscribeCallBack);
})
function UnSubscribeCallback() {
console.log(TAG + " UnSubscribe CallBack");
done();
}
await abilityContext.startAbility({
bundleName: "com.example.actsstagecontextassisttwo",
abilityName: "MainAbility4",
parameters: {
startId: 5,
}
}).then((data) => {
console.log(TAG + ' - startAbility: ' + JSON.stringify(data));
}).catch((err) => {
console.log(TAG + " - start failed" + JSON.stringify(err));
expect.assertFail()
done()
})
});
/**
* @tc.number: SUB_AA_OpenHarmony_Context_1700
* @tc.name: The resource obtained through getString is the same as config.json in the label resources are the same
* @tc.desc: Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_Context_1700', 0, async function (done) {
TAG = "SUB_AA_OpenHarmony_Context_1700"
console.log(TAG + " --- start");
function SubscribeCallBack(err, data) {
console.log(TAG + " Subscribe CallBack data: " + JSON.stringify(data)
+ "err: " + JSON.stringify(err));
if (data.event == 'AssistContextTwo_StageAbilityA_Start_CommonEvent') {
expect(data.parameters.abilityStageAppLabel).assertEqual("entry_MainAbility");
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
}
}
await commonEvent.createSubscriber(subscriberInfo_AbilityContext).then(async (data) => {
console.log(TAG + " Create Subscriber");
Subscriber = data;
await commonEvent.subscribe(Subscriber, SubscribeCallBack);
})
function UnSubscribeCallback() {
console.log(TAG + " UnSubscribe CallBack");
done();
}
await abilityContext.startAbility({
bundleName: "com.example.actsstagecontextassisttwo",
abilityName: "MainAbility4",
parameters: {
startId: 6,
}
}).then((data) => {
console.log(TAG + ' - startAbility: ' + JSON.stringify(data));
}).catch((err) => {
console.log(TAG + " - start failed" + JSON.stringify(err));
expect.assertFail()
done()
})
});
/**
* @tc.number: SUB_AA_OpenHarmony_Context_1800
* @tc.name: Check that context paths of different Ability in the same hap are the same.
* @tc.desc: Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_Context_1800', 0, async function (done) {
TAG = "SUB_AA_OpenHarmony_Context_1800"
console.log(TAG + " --- start");
let abilityBundleContext1 = abilityContext.createBundleContext("com.example.stagecontextpropertiestest");
let abilityBundleContext2 = globalThis.abilityContext2
.createBundleContext("com.example.stagecontextpropertiestest");
checkBundleContextDir(abilityBundleContext1);
checkContextDirEqualA(abilityBundleContext1, abilityBundleContext2);
console.log(TAG + " --- end");
done()
});
/**
* @tc.number: SUB_AA_OpenHarmony_Context_1900
* @tc.name: Check that ApplicationContext paths of different Ability in the same hap are the same.
* @tc.desc: Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_Context_1900', 0, async function (done) {
TAG = "SUB_AA_OpenHarmony_Context_1800"
console.log(TAG + " --- start");
let abilityBundleContext1 = abilityContext.createBundleContext("com.example.stagecontextpropertiestest");
let abilityBundleContext2 = globalThis.abilityContext2
.createBundleContext("com.example.stagecontextpropertiestest");
let abilityStageBundleContext2 = globalThis.abilityStageContext
.createBundleContext("com.example.stagecontextpropertiestest");
checkBundleContextDir(abilityBundleContext1);
checkContextDirEqualA(abilityBundleContext1, abilityBundleContext2);
checkContextDirEqualA(abilityBundleContext1, abilityStageBundleContext2);
console.log(TAG + " --- end");
done()
});
/**
* @tc.number: SUB_AA_OpenHarmony_Context_2000
* @tc.name: Check that ApplicationContext paths of different Ability in the different hap are the same.
* @tc.desc: Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_Context_2000', 0, async function (done) {
TAG = "SUB_AA_OpenHarmony_Context_2000"
console.log(TAG + " --- start");
let abilityBundleContext1 = abilityContext.createBundleContext("com.example.stagecontextpropertiestest");
checkBundleContextDir(abilityBundleContext1);
function SubscribeCallBack(err, data) {
console.log(TAG + " Subscribe CallBack data: " + JSON.stringify(data)
+ "err: " + JSON.stringify(err));
let abilityBundleContext2 = globalThis.abilityContextA.createBundleContext(
"com.example.stagecontextpropertiestest");
checkContextDirEqualA(abilityBundleContext1, abilityBundleContext2);
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
}
await commonEvent.createSubscriber(subscriberInfo_AbilityContext).then(async (data) => {
console.log(TAG + " Create Subscriber");
Subscriber = data;
await commonEvent.subscribe(Subscriber, SubscribeCallBack);
})
function UnSubscribeCallback() {
console.log(TAG + " UnSubscribe CallBack");
done();
}
await abilityContext.startAbility({
bundleName: "com.example.stagecontextpropertiestest",
abilityName: "MainAbility3",
}).then((data) => {
console.log(TAG + ' - startAbility: ' + JSON.stringify(data));
}).catch((err) => {
console.log(TAG + " - start failed" + JSON.stringify(err));
expect.assertFail()
done()
})
});
/**
* @tc.number: SUB_AA_OpenHarmony_Context_2100
* @tc.name: Check that ApplicationContext paths of different Ability in the different hap are the same.
* @tc.desc: Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_Context_2100', 0, async function (done) {
TAG = "SUB_AA_OpenHarmony_Context_2100"
console.log(TAG + " --- start");
let abilityStageBundleContext1 = globalThis.abilityStageContext.createBundleContext(
"com.example.stagecontextpropertiestest");
checkBundleContextDir(abilityStageBundleContext1);
function SubscribeCallBack(err, data) {
console.log(TAG + " Subscribe CallBack data: " + JSON.stringify(data)
+ "err: " + JSON.stringify(err));
let abilityBundleContext2 = globalThis.abilityStageContextA.createBundleContext(
"com.example.stagecontextpropertiestest");
checkContextDirEqualA(abilityStageBundleContext1, abilityBundleContext2);
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
}
await commonEvent.createSubscriber(subscriberInfo_AbilityContext).then(async (data) => {
console.log(TAG + " Create Subscriber");
Subscriber = data;
await commonEvent.subscribe(Subscriber, SubscribeCallBack);
})
function UnSubscribeCallback() {
console.log(TAG + " UnSubscribe CallBack");
done();
}
await abilityContext.startAbility({
bundleName: "com.example.stagecontextpropertiestest",
abilityName: "MainAbility3",
}).then((data) => {
console.log(TAG + ' - startAbility: ' + JSON.stringify(data));
}).catch((err) => {
console.log(TAG + " - start failed" + JSON.stringify(err));
expect.assertFail()
done()
})
});
/**
* @tc.number: SUB_AA_OpenHarmony_Context_2200
* @tc.name: Check that ApplicationContext paths of different Ability in the different hap are the same.
* @tc.desc: Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_Context_2200', 0, async function (done) {
TAG = "SUB_AA_OpenHarmony_Context_2200"
console.log(TAG + " --- start");
let abilityBundleContext1 = abilityContext.getApplicationContext()
.createBundleContext("com.example.stagecontextpropertiestest")
let abilityStageBundleContext1 = globalThis.abilityStageContext.getApplicationContext()
.createBundleContext(
"com.example.stagecontextpropertiestest");
checkBundleContextDir(abilityBundleContext1);
function SubscribeCallBack(err, data) {
console.log(TAG + " Subscribe CallBack data: " + JSON.stringify(data)
+ "err: " + JSON.stringify(err));
let abilityBundleContext2 = abilityContext.getApplicationContext()
.createBundleContext("com.example.stagecontextpropertiestest")
let abilityStageBundleContext2 = globalThis.abilityStageContext.getApplicationContext()
.createBundleContext(
"com.example.stagecontextpropertiestest");
checkContextDirEqualA(abilityBundleContext1, abilityStageBundleContext1);
checkContextDirEqualA(abilityBundleContext2, abilityStageBundleContext2);
checkContextDirEqualA(abilityBundleContext1, abilityStageBundleContext2);
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
}
await commonEvent.createSubscriber(subscriberInfo_AbilityContext).then(async (data) => {
console.log(TAG + " Create Subscriber");
Subscriber = data;
await commonEvent.subscribe(Subscriber, SubscribeCallBack);
})
function UnSubscribeCallback() {
console.log(TAG + " UnSubscribe CallBack");
done();
}
await abilityContext.startAbility({
bundleName: "com.example.stagecontextpropertiestest",
abilityName: "MainAbility3",
}).then((data) => {
console.log(TAG + ' - startAbility: ' + JSON.stringify(data));
}).catch((err) => {
console.log(TAG + " - start failed" + JSON.stringify(err));
expect.assertFail()
done()
})
});
/**
* @tc.number: SUB_AA_OpenHarmony_Context_2300
* @tc.name: Check that Context paths of different Ability in the different hap are the same.
* @tc.desc: Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_Context_2300', 0, async function (done) {
TAG = "SUB_AA_OpenHarmony_Context_2300"
console.log(TAG + " --- start");
let abilityBundleContext1 = abilityContext.createBundleContext("com.example.stagecontextpropertiestest");
checkBundleContextDir(abilityBundleContext1);
function SubscribeCallBack(err, data) {
console.log(TAG + " Subscribe CallBack data: " + JSON.stringify(data)
+ "err: " + JSON.stringify(err));
if (data.event == 'StartMainAbility4_CommonEvent_ContextOne') {
checkAssistHapBundleContextDir(data.parameters.abilityBundleContextAssistTwo)
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
}
}
await commonEvent.createSubscriber(subscriberInfo_AbilityContext).then(async (data) => {
console.log(TAG + " Create Subscriber");
Subscriber = data;
await commonEvent.subscribe(Subscriber, SubscribeCallBack);
})
function UnSubscribeCallback() {
console.log(TAG + " UnSubscribe CallBack");
done();
}
await abilityContext.startAbility({
bundleName: "com.example.actsstagecontextassisttwo",
abilityName: "MainAbility4",
parameters: {
startId: 7,
}
}).then((data) => {
console.log(TAG + ' - startAbility: ' + JSON.stringify(data));
}).catch((err) => {
console.log(TAG + " - start failed" + JSON.stringify(err));
expect.assertFail()
done()
})
});
/**
* @tc.number: SUB_AA_OpenHarmony_Context_2400
* @tc.name: Check that Context paths of different Ability in the different hap are the same.
* @tc.desc: Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_Context_2400', 0, async function (done) {
TAG = "SUB_AA_OpenHarmony_Context_2400"
console.log(TAG + " --- start");
let abilityStageBundleContext1 = globalThis.abilityStageContext
.createBundleContext("com.example.stagecontextpropertiestest");
checkBundleContextDir(abilityStageBundleContext1);
function SubscribeCallBack(err, data) {
console.log(TAG + " Subscribe CallBack data: " + JSON.stringify(data)
+ "err: " + JSON.stringify(err));
if (data.event == 'AssistContextTwo_StageAbilityA_Start_CommonEvent') {
checkAssistHapBundleContextDir(data.parameters.abilityStageBundleContxtAssistOne)
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
}
}
await commonEvent.createSubscriber(subscriberInfo_AbilityContext).then(async (data) => {
console.log(TAG + " Create Subscriber");
Subscriber = data;
await commonEvent.subscribe(Subscriber, SubscribeCallBack);
})
function UnSubscribeCallback() {
console.log(TAG + " UnSubscribe CallBack");
done();
}
await abilityContext.startAbility({
bundleName: "com.example.actsstagecontextassisttwo",
abilityName: "MainAbility4",
parameters: {
startId: 8,
}
}).then((data) => {
console.log(TAG + ' - startAbility: ' + JSON.stringify(data));
}).catch((err) => {
console.log(TAG + " - start failed" + JSON.stringify(err));
expect.assertFail()
done()
})
});
/**
* @tc.number: SUB_AA_OpenHarmony_Context_2500
* @tc.name: Check that ApplicationContex paths of different Ability in the different hap are the same.
* @tc.desc: Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_Context_2500', 0, async function (done) {
TAG = "SUB_AA_OpenHarmony_Context_2500"
console.log(TAG + " --- start");
let num = 0;
let abilityStageAppBundleContext;
let abilityAppBundleContext;
let abilityAppBundleContext1 = globalThis.abilityStageContext.getApplicationContext()
.createBundleContext("com.example.stagecontextpropertiestest");
let abilityStageAppBundleContext1 = globalThis.abilityStageContext.getApplicationContext()
.createBundleContext("com.example.stagecontextpropertiestest");
checkBundleContextDir(abilityAppBundleContext1);
checkContextDirEqualA(abilityAppBundleContext1, abilityStageAppBundleContext1)
function SubscribeCallBack(err, data) {
console.log(TAG + " Subscribe CallBack data: " + JSON.stringify(data)
+ "err: " + JSON.stringify(err));
if (data.event == 'AssistContextTwo_StageAbilityA_Start_CommonEvent') {
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
}
if (data.event == 'AssistContextTwo_StageAbilityA_Start_CommonEvent') {
console.log(TAG + " AssistContextTwo_StageAbilityA_Start_CommonEvent")
num++;
abilityStageAppBundleContext = data.parameters.abilityStageAppContextAssistOne
}
if (data.event == 'StartMainAbility4_CommonEvent_ContextOne') {
console.log(TAG + " StartMainAbility4_CommonEvent_ContextOne")
num++;
abilityAppBundleContext = data.parameters.abilityAppContextAssistTwo
}
if (num == 2) {
console.log(TAG + " start expect");
checkAssistHapBundleContextDir(abilityAppBundleContext)
checkContextDirEqualA(abilityAppBundleContext, abilityStageAppBundleContext)
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
}
}
await commonEvent.createSubscriber(subscriberInfo_AbilityContext).then(async (data) => {
console.log(TAG + " Create Subscriber");
Subscriber = data;
await commonEvent.subscribe(Subscriber, SubscribeCallBack);
})
function UnSubscribeCallback() {
console.log(TAG + " UnSubscribe CallBack");
done();
}
await abilityContext.startAbility({
bundleName: "com.example.actsstagecontextassisttwo",
abilityName: "MainAbility4",
parameters: {
startId: 9,
}
}).then((data) => {
console.log(TAG + ' - startAbility: ' + JSON.stringify(data));
}).catch((err) => {
console.log(TAG + " - start failed" + JSON.stringify(err));
expect.assertFail()
done()
})
});
/**
* @tc.number: SUB_AA_OpenHarmony_Context_2600
* @tc.name: Check that Context paths of different Ability in the different hap are the same.
* @tc.desc: Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_Context_2600', 0, async function (done) {
TAG = "SUB_AA_OpenHarmony_Context_2600"
console.log(TAG + " --- start");
let abilityBundleContext1 = globalThis.abilityStageContext
.createBundleContext("com.example.stagecontextpropertiestest");
checkBundleContextDir(abilityBundleContext1);
function SubscribeCallBack(err, data) {
console.log(TAG + " Subscribe CallBack data: " + JSON.stringify(data)
+ "err: " + JSON.stringify(err));
if (data.event == 'StartMainAbility4_CommonEvent_ContextOne') {
expect(data.parameters.abilityBundleContextTest).assertEqual(401)
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
}
}
await commonEvent.createSubscriber(subscriberInfo_AbilityContext).then(async (data) => {
console.log(TAG + " Create Subscriber");
Subscriber = data;
await commonEvent.subscribe(Subscriber, SubscribeCallBack);
})
function UnSubscribeCallback() {
console.log(TAG + " UnSubscribe CallBack");
done();
}
await abilityContext.startAbility({
bundleName: "com.example.actsstagecontextassisttwo",
abilityName: "MainAbility4",
parameters: {
startId: 10,
}
}).then((data) => {
console.log(TAG + ' - startAbility: ' + JSON.stringify(data));
}).catch((err) => {
console.log(TAG + " - start failed" + JSON.stringify(err));
expect.assertFail()
done()
})
});
function checkApplicationContextDir(applicationContext) {
expect(applicationContext.cacheDir).assertEqual("/data/storage/el2/base/cache");
expect(applicationContext.tempDir).assertEqual("/data/storage/el2/base/temp");
expect(applicationContext.filesDir).assertEqual("/data/storage/el2/base/files");
expect(applicationContext.distributedFilesDir).assertEqual("/data/storage/el2/distributedfiles");
expect(applicationContext.databaseDir).assertEqual("/data/storage/el2/database");
expect(applicationContext.preferencesDir).assertEqual("/data/storage/el2/base/preferences");
expect(applicationContext.bundleCodeDir).assertEqual("/data/storage/el1/bundle");
}
function checkAbilityContextDir() {
expect(abilityContext.cacheDir).assertEqual("/data/storage/el2/base/haps/entry_test/cache");
expect(abilityContext.tempDir).assertEqual("/data/storage/el2/base/haps/entry_test/temp");
expect(abilityContext.filesDir).assertEqual("/data/storage/el2/base/haps/entry_test/files");
expect(abilityContext.distributedFilesDir).assertEqual("/data/storage/el2/distributedfiles");
expect(abilityContext.databaseDir).assertEqual("/data/storage/el2/database/entry_test");
expect(abilityContext.preferencesDir).assertEqual("/data/storage/el2/base/haps/entry_test/preferences");
expect(abilityContext.bundleCodeDir).assertEqual("/data/storage/el1/bundle");
}
function checkContextDirEqualA(abilityContext, abilityContext2) {
expect(abilityContext.cacheDir).assertEqual(abilityContext2.cacheDir);
expect(abilityContext.tempDir).assertEqual(abilityContext2.tempDir);
expect(abilityContext.filesDir).assertEqual(abilityContext2.filesDir);
expect(abilityContext.distributedFilesDir).assertEqual(abilityContext2.distributedFilesDir);
expect(abilityContext.databaseDir).assertEqual(abilityContext2.databaseDir);
expect(abilityContext.storageDir).assertEqual(abilityContext2.storageDir);
expect(abilityContext.bundleCodeDir).assertEqual(abilityContext2.bundleCodeDir);
}
function checkContextDirEqualB(abilityContext, abilityContext2) {
expect(abilityContext2.cacheDir == "/data/storage/el2/base/haps/feature_assistone/cache" &&
abilityContext2.cacheDir != abilityContext.cacheDir).assertTrue();
expect(abilityContext2.databaseDir == "/data/storage/el2/database/feature_assistone" &&
abilityContext2.databaseDir != abilityContext.databaseDir).assertTrue();
expect(abilityContext2.filesDir == "/data/storage/el2/base/haps/feature_assistone/files" &&
abilityContext2.filesDir != abilityContext.filesDir).assertTrue();
expect(abilityContext2.preferencesDir == "/data/storage/el2/base/haps/feature_assistone/preferences" &&
abilityContext2.preferencesDir != abilityContext.preferencesDir).assertTrue();
expect(abilityContext2.tempDir == "/data/storage/el2/base/haps/feature_assistone/temp" &&
abilityContext2.tempDir != abilityContext.tempDir).assertTrue();
expect(abilityContext.distributedFilesDir).assertEqual(abilityContext2.distributedFilesDir);
expect(abilityContext.bundleCodeDir).assertEqual(abilityContext2.bundleCodeDir);
}
function checkContextDirEqualC(abilityContext, abilityContext2) {
expect(abilityContext2.cacheDir == "/data/storage/el2/base/haps/entry_assisttow/cache" &&
abilityContext2.cacheDir != abilityContext.cacheDir).assertTrue();
expect(abilityContext2.databaseDir == "/data/storage/el2/database/entry_assisttow" &&
abilityContext2.databaseDir != abilityContext.databaseDir).assertTrue();
expect(abilityContext2.filesDir == "/data/storage/el2/base/haps/entry_assisttow/files" &&
abilityContext2.filesDir != abilityContext.filesDir).assertTrue();
expect(abilityContext2.preferencesDir == "/data/storage/el2/base/haps/entry_assisttow/preferences" &&
abilityContext2.preferencesDir != abilityContext.preferencesDir).assertTrue();
expect(abilityContext2.tempDir == "/data/storage/el2/base/haps/entry_assisttow/temp" &&
abilityContext2.tempDir != abilityContext.tempDir).assertTrue();
expect(abilityContext.distributedFilesDir).assertEqual(abilityContext2.distributedFilesDir);
expect(abilityContext.bundleCodeDir).assertEqual(abilityContext2.bundleCodeDir);
}
function checkAbilityStageContextDir() {
expect(globalThis.abilityStageContext.cacheDir).assertEqual("/data/storage/el2/base/haps/entry_test/cache");
expect(globalThis.abilityStageContext.tempDir).assertEqual("/data/storage/el2/base/haps/entry_test/temp");
expect(globalThis.abilityStageContext.filesDir).assertEqual("/data/storage/el2/base/haps/entry_test/files");
expect(globalThis.abilityStageContext.distributedFilesDir).assertEqual("/data/storage/el2/distributedfiles");
expect(globalThis.abilityStageContext.databaseDir).assertEqual("/data/storage/el2/database/entry_test");
expect(globalThis.abilityStageContext.preferencesDir).assertEqual("/data/storage/el2/base/haps/entry_test/preferences");
expect(globalThis.abilityStageContext.bundleCodeDir).assertEqual("/data/storage/el1/bundle");
}
function checkBundleContextDir(bundleContext) {
expect(bundleContext.bundleCodeDir).assertEqual("/data/bundles/com.example.stagecontextpropertiestest");
expect(bundleContext.tempDir).assertEqual("/data/app/el2/100/base/com.example.stagecontextpropertiestest/temp");
expect(bundleContext.filesDir).assertEqual("/data/app/el2/100/base/com.example.stagecontextpropertiestest/files");
expect(bundleContext.cacheDir).assertEqual("/data/app/el2/100/base/com.example.stagecontextpropertiestest/cache");
expect(bundleContext.databaseDir).assertEqual("/data/app/el2/100/database/com.example.stagecontextpropertiestest");
expect(bundleContext.preferencesDir).assertEqual("/data/app/el2/100/base/com.example.stagecontextpropertiestest/preferences");
expect(bundleContext.distributedFilesDir).assertEqual("/mnt/hmdfs/100/device_view/local/data/com.example.stagecontextpropertiestest");
}
function checkAssistHapBundleContextDir(bundleContext) {
expect(bundleContext.bundleCodeDir).assertEqual("/data/bundles/com.example.actsstagecontextassisttwo");
expect(bundleContext.tempDir).assertEqual("/data/app/el2/100/base/com.example.actsstagecontextassisttwo/temp");
expect(bundleContext.filesDir).assertEqual("/data/app/el2/100/base/com.example.actsstagecontextassisttwo/files");
expect(bundleContext.cacheDir).assertEqual("/data/app/el2/100/base/com.example.actsstagecontextassisttwo/cache");
expect(bundleContext.databaseDir).assertEqual("/data/app/el2/100/database/com.example.actsstagecontextassisttwo");
expect(bundleContext.preferencesDir).assertEqual("/data/app/el2/100/base/com.example.actsstagecontextassisttwo/preferences");
expect(bundleContext.distributedFilesDir).assertEqual("/mnt/hmdfs/100/device_view/local/data/com.example.actsstagecontextassisttwo");
}
})
}
\ No newline at end of file
{
"module": {
"name": "entry_test",
"type": "entry",
"srcEntrance": "./ets/Application/MyAbilityStage.ts",
"description": "$string:entry_test_desc",
"mainElement": "MainAbility",
"deviceTypes": [
"default",
"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"
]
}
]
},
{
"name": "MainAbility2",
"srcEntrance": "./ets/MainAbility2/MainAbility2.ts",
"description": "$string:MainAbility_desc",
"icon": "$media:icon",
"label": "$string:MainAbility_label",
"visible": true,
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
]
}
],
"requestPermissions": [
{
"name":"ohos.permission.START_ABILITIES_FROM_BACKGROUND",
"reason":"need use ohos.permission.START_ABILITIES_FROM_BACKGROUND"
}
]
}
}
\ No newline at end of file
{
"string": [
{
"name": "entry_test_desc",
"value": "description"
},
{
"name": "app_name",
"value": "ActsStageContextPropertiesTest"
},
{
"name": "description_application",
"value": "demo for test"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "entry_MainAbility"
}
]
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册