提交 77665827 编写于 作者: H hu0475

完成ability子系统context模块的跨平台测试套

Signed-off-by: Nhu0475 <huyanqiang5@huawei.com>
上级 19172b16
......@@ -17,6 +17,7 @@ group("ability") {
testonly = true
if (is_standard_system) {
deps = [
"crossplatform:ability_crossplatform",
"ability_runtime:ability_runtime",
"dmsfwk:dmsfwk",
]
......
# Copyright (c) 2023 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("//build/ohos_var.gni")
group("ability_crossplatform") {
testonly = true
if (is_standard_system) {
deps = [
"ability_runtime:ability_crossplatform_runtime",
]
}
}
# Copyright (c) 2023 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("//build/ohos_var.gni")
group("ability_crossplatform_runtime") {
testonly = true
if (is_standard_system) {
deps = [
"actscontexttest:context_ets_normal_test",
"actscontexttestentry:context_entry_ets_normal_test"
]
}
}
{
"app": {
"bundleName": "com.example.contexttest",
"vendor": "example",
"versionCode": 1000000,
"versionName": "1.0.0",
"icon": "$media:app_icon",
"label": "$string:app_name",
"minAPIVersion": 9,
"targetAPIVersion": 9,
"car": {
"apiCompatibleVersion": 9,
"singleUser": false
}
}
}
# Copyright (c) 2023 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("context_ets_normal_test") {
hap_profile = "src/main/module.json"
deps = [
":windowStage_js_assets",
":windowStage_resources",
]
ets2abc = true
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsAbilityContextTest"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("windowStage_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("windowStage_js_assets") {
source_dir = "src/main/ets"
}
ohos_resources("windowStage_resources") {
sources = [ "src/main/resources" ]
deps = [ ":windowStage_app_profile" ]
hap_profile = "src/main/module.json"
}
\ No newline at end of file
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "300000",
"shell-timeout": "300000",
"bundle-name": "com.example.contexttest",
"module-name": "entryTest",
"testcase-timeout": 5000
},
"kits": [
{
"test-file-name": [
"ActsAbilityContextTest.hap",
"ActsAbilityContextEntryTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
\ No newline at end of file
import AbilityStage from '@ohos.app.ability.AbilityStage';
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("[Demo] MyAbilityStage onCreate")
globalThis.stageContext = this.context;
}
}
\ No newline at end of file
/*
* Copyright (c) 2023 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.app.ability.UIAbility'
let abilityName = null;
function recordLife(ownList, abilityName, lifeName) {
ownList.push(abilityName + ' ' + lifeName);
}
export default class MainAbility1 extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] MainAbility1 onCreate")
abilityName = want.abilityName;
globalThis.list1 = [];
globalThis.parameters = null;
recordLife(globalThis.list1, abilityName, 'onCreate');
if (want.parameters) {
globalThis.parameters = want.parameters;
}
}
onDestroy() {
console.log("[Demo] MainAbility1 onDestroy")
recordLife(globalThis.list1, abilityName, 'onDestroy');
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] MainAbility1 onWindowStageCreate")
globalThis.ability1Context = this.context;
windowStage.loadContent('TestAbility/pages/Index1', (err, data) => {
if (err.code) {
console.log('MainAbility1 loadContent error');
return;
}
console.log('MainAbility1 loadContent success');
});
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[Demo] MainAbility1 onWindowStageDestroy")
}
onForeground() {
console.log("[Demo] MainAbility1 onForeground")
}
onBackground() {
// Ability has back to background
console.log("[Demo] MainAbility1 onBackground")
}
};
/*
* Copyright (c) 2023 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 UIAbility from '@ohos.app.ability.UIAbility';
import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
import hilog from '@ohos.hilog';
import { Hypium } from '@ohos/hypium';
import testsuite from '../test/List.test';
import window from '@ohos.window';
export default class TestAbility extends UIAbility {
onCreate(want, launchParam) {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onCreate');
hilog.info(0x0000, 'testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? '');
hilog.info(0x0000, 'testTag', '%{public}s', 'launchParam:'+ JSON.stringify(launchParam) ?? '');
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
hilog.info(0x0000, 'testTag', '%{public}s', 'start run testcase!!!');
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
onDestroy() {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onDestroy');
}
onWindowStageCreate(windowStage: window.WindowStage) {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageCreate');
windowStage.loadContent('TestAbility/pages/Index', (err, data) => {
if (err.code) {
hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
return;
}
hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s',
JSON.stringify(data) ?? '');
});
globalThis.abilityContext = this.context;
globalThis.colorMode = this.context.config.colorMode;
globalThis.direction = this.context.config.direction;
}
onWindowStageDestroy() {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageDestroy');
}
onForeground() {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onForeground');
}
onBackground() {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onBackground');
}
}
\ No newline at end of file
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import hilog from '@ohos.hilog';
@Entry
@Component
struct Index {
aboutToAppear() {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility index aboutToAppear');
}
@State message: string = 'Hello World'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('next page')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width('35%')
.height('5%')
.onClick(()=>{
})
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
/*
* Copyright (c) 2023 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 Index1 {
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('Hello World Mainability1')
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
import hilog from '@ohos.hilog';
import TestRunner from '@ohos.application.testRunner';
import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
var abilityDelegator = undefined
var abilityDelegatorArguments = undefined
async function onAbilityCreateCallback() {
hilog.info(0x0000, 'testTag', '%{public}s', 'onAbilityCreateCallback');
}
async function addAbilityMonitorCallback(err: any) {
hilog.info(0x0000, 'testTag', 'addAbilityMonitorCallback : %{public}s', JSON.stringify(err) ?? '');
}
export default class OpenHarmonyTestRunner implements TestRunner {
constructor() {
}
onPrepare() {
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare ');
}
async onRun() {
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun run');
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.bundleName + '.TestAbility'
let lMonitor = {
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
var cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName
var debug = abilityDelegatorArguments.parameters['-D']
if (debug == 'true')
{
cmd += ' -D'
}
hilog.info(0x0000, 'testTag', 'cmd : %{public}s', cmd);
abilityDelegator.executeShellCommand(cmd,
(err: any, d: any) => {
hilog.info(0x0000, 'testTag', 'executeShellCommand : err : %{public}s', JSON.stringify(err) ?? '');
hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.stdResult ?? '');
hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.exitCode ?? '');
})
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun end');
}
}
\ No newline at end of file
/*
* Copyright (c) 2023 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 Common from './actsCommonTest/Common.test';
import Configuration from './actsConfigurationTest/Configuration.test';
import AbilityStageContext from './actsAbilityStageContextTest/AbilityStageContext.test';
import ApplicationContext from './actsApplicationContextTest/ApplicationContext.test';
import UIAbilityContext from './actsUIAbilityContextTest/UIAbilityContext.test';
export default function testsuite() {
Common();
Configuration();
AbilityStageContext();
ApplicationContext();
UIAbilityContext();
}
/*
* Copyright (c) 2023 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 common from '@ohos.app.ability.common';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
export default function AbilityStageContext() {
describe("AbilityStageContext", function () {
let bundleName: any;
beforeAll(async function () {
console.info("beforeAll case");
});
beforeEach(async function () {
console.info("beforeEach case");
});
afterEach(async function () {
console.info('afterEach case');
});
afterAll(async function () {
console.info("afterAll case");
});
/**
* @tc.number : ABILITY_TEST_ABILITYSTAGECONTEXT_CURRENTHAPMODULEINFO_0100
* @tc.name : testAbilityStageContextCurrentHapModuleInfo001
* @tc.desc : test filed of currentHapModuleInfo
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 1
*/
it('testAbilityStageContextCurrentHapModuleInfo001', 0, async function (done) {
try {
let context: common.AbilityStageContext = globalThis.stageContext;
expect(context != null).assertTrue();
let hapModuleInfo = context.currentHapModuleInfo;
expect(hapModuleInfo != null).assertTrue();
console.log(`testAbilityStageContextCurrentHapModuleInfo001 hapModuleInfo.name: ` + hapModuleInfo.name);
expect(hapModuleInfo.name == "entryTest").assertTrue();
console.log(`testAbilityStageContextCurrentHapModuleInfo001 hapModuleInfo.icon: ` + hapModuleInfo.icon);
expect(hapModuleInfo.icon == "$media:icon").assertTrue();
console.log(`testAbilityStageContextCurrentHapModuleInfo001 hapModuleInfo.iconId: ` + hapModuleInfo.iconId);
expect(typeof (hapModuleInfo.iconId) == 'number').assertTrue();
console.log(`testAbilityStageContextCurrentHapModuleInfo001 hapModuleInfo.label: ` + hapModuleInfo.label);
expect(hapModuleInfo.label == "$string:TestAbility_label").assertTrue();
console.log(`testAbilityStageContextCurrentHapModuleInfo001 hapModuleInfo.labelId: ` + hapModuleInfo.labelId);
expect(typeof (hapModuleInfo.labelId) == 'number').assertTrue();
console.log(`testAbilityStageContextCurrentHapModuleInfo001 hapModuleInfo.description: ` + hapModuleInfo.description);
expect(hapModuleInfo.description == "$string:module_test_desc").assertTrue();
console.log(`testAbilityStageContextCurrentHapModuleInfo001 hapModuleInfo.descriptionId: ` + hapModuleInfo.descriptionId);
expect(typeof (hapModuleInfo.descriptionId) == 'number').assertTrue();
console.log(`testAbilityStageContextCurrentHapModuleInfo001 hapModuleInfo.mainElementName: ` + hapModuleInfo.mainElementName);
expect(hapModuleInfo.mainElementName == "TestAbility").assertTrue();
console.log(`testAbilityStageContextCurrentHapModuleInfo001 hapModuleInfo.metadata: ` + hapModuleInfo.metadata.length);
expect(hapModuleInfo.metadata.length >= 0).assertTrue();
console.log(`testAbilityStageContextCurrentHapModuleInfo001 success`);
done();
} catch (err) {
console.log(`testAbilityStageContextCurrentHapModuleInfo001 fail: ` + err);
expect().assertFail();
done();
}
})
/**
* @tc.number : ABILITY_TEST_ABILITYSTAGECONTEXT_CONFIG_0100
* @tc.name : testAbilityStageContextConfig001
* @tc.desc : test filed of config
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 1
*/
it('testAbilityStageContextConfig001', 0, async function (done) {
try {
let context: common.AbilityStageContext = globalThis.stageContext;
expect(context != null).assertTrue();
let config = context.config;
expect(config != null).assertTrue();
console.log(`testAbilityStageContextConfig001 config.colorMode: ` + config.colorMode);
expect(typeof (config.colorMode) == 'number').assertTrue();
console.log(`testAbilityStageContextConfig001 config.direction: ` + config.direction);
expect(typeof (config.direction) == 'number').assertTrue();
console.log(`testAbilityStageContextConfig001 success`);
done();
} catch (err) {
console.log(`testAbilityStageContextConfig001 fail: ` + err);
expect().assertFail();
done();
}
})
/**
* @tc.number : ABILITY_TEST_STAGEMODE_0100
* @tc.name : testStageMode001
* @tc.desc : test filed of stageMode
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 1
*/
it('testStageMode001', 0, async function (done) {
try {
let context: common.AbilityStageContext = globalThis.stageContext;
expect(context.stageMode).assertTrue();
console.log(`testStageMode001 success`);
done();
} catch (err) {
console.log(`testStageMode001 fail: ` + err);
expect().assertFail();
done();
}
})
/**
* @tc.number : ABILITY_TEST_RESOURCEMANAGER_0100
* @tc.name : testResourceManager001
* @tc.desc : test filed of resourceManager
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 1
*/
it('testResourceManager001', 0, async function (done) {
try {
let context: common.AbilityStageContext = globalThis.stageContext;
expect(context.resourceManager != null).assertTrue();
console.log(`testResourceManager001 success`);
done();
} catch (err) {
console.log(`testResourceManager001 fail: ` + err);
expect().assertFail();
done();
}
})
/**
* @tc.number : ABILITY_TEST_APPLICATIONINFO_0100
* @tc.name : testApplicationInfo001
* @tc.desc : test filed of applicationInfo
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 1
*/
it('testApplicationInfo001', 0, async function (done) {
try {
let context: common.AbilityStageContext = globalThis.stageContext;
expect(context != null).assertTrue();
let applicationInfo = context.applicationInfo;
expect(applicationInfo != null).assertTrue();
console.log(`testApplicationInfo001 applicationInfo.name: ` + applicationInfo.name);
expect(applicationInfo.name == 'com.example.contexttest').assertTrue();
console.log(`testApplicationInfo001 applicationInfo.description: ` + applicationInfo.description.length);
expect(applicationInfo.description.length >= 0).assertTrue();
console.log(`testApplicationInfo001 applicationInfo.descriptionId: ` + applicationInfo.descriptionId);
expect(applicationInfo.descriptionId == 0).assertTrue();
console.log(`testApplicationInfo001 applicationInfo.label: ` + applicationInfo.label);
expect(applicationInfo.label == '$string:app_name').assertTrue();
console.log(`testApplicationInfo001 applicationInfo.labelId: ` + applicationInfo.labelId);
expect(applicationInfo.labelId != null).assertTrue();
console.log(`testApplicationInfo001 applicationInfo.icon: ` + applicationInfo.icon);
expect(applicationInfo.icon == '$media:app_icon').assertTrue();
console.log(`testApplicationInfo001 applicationInfo.iconId: ` + applicationInfo.iconId);
expect(applicationInfo.iconId != null).assertTrue();
console.log(`testApplicationInfo001 applicationInfo.codePath: ` + applicationInfo.codePath);
expect(typeof (applicationInfo.codePath) == 'string').assertTrue();
console.log(`testApplicationInfo001 success`);
done();
} catch (err) {
console.log(`testApplicationInfo001 fail: ` + err);
expect().assertFail();
done();
}
})
/**
* @tc.number : ABILITY_TEST_CACHEDIR_0100
* @tc.name : testCacheDir001
* @tc.desc : test filed of cacheDir
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 1
*/
it('testCacheDir001', 0, async function (done) {
try {
let context: common.AbilityStageContext = globalThis.stageContext;
console.log(`testCacheDir001 cacheDir:` + context.cacheDir);
expect(typeof (context.cacheDir) == 'string').assertTrue();
console.log(`testCacheDir001 success`);
done();
} catch (err) {
console.log(`testCacheDir001 fail: ` + err);
expect().assertFail();
done();
}
})
/**
* @tc.number : ABILITY_TEST_TEMPDIR_0100
* @tc.name : testTempDir001
* @tc.desc : test filed of tempDir
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 1
*/
it('testTempDir001', 0, async function (done) {
try {
let context: common.AbilityStageContext = globalThis.stageContext;
console.log(`testTempDir001 tempDir:` + context.tempDir);
expect(typeof (context.tempDir) == 'string').assertTrue();
console.log(`testTempDir001 success`);
done();
} catch (err) {
console.log(`testTempDir001 fail: ` + err);
expect().assertFail();
done();
}
})
/**
* @tc.number : ABILITY_TEST_FILESDIR_0100
* @tc.name : testFilesDir001
* @tc.desc : test filed of filesDir
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 1
*/
it('testFilesDir001', 0, async function (done) {
try {
let context: common.AbilityStageContext = globalThis.stageContext;
console.log(`testFilesDir001 filesDir:` + context.filesDir);
expect(typeof (context.filesDir) == 'string').assertTrue();
console.log(`testFilesDir001 success`);
done();
} catch (err) {
console.log(`testFilesDir001 fail: ` + err);
expect().assertFail();
done();
}
})
/**
* @tc.number : ABILITY_TEST_DATABASEDIR_0100
* @tc.name : testDatabaseDir001
* @tc.desc : test filed of databaseDir
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 1
*/
it('testDatabaseDir001', 0, async function (done) {
try {
let context: common.AbilityStageContext = globalThis.stageContext;
console.log(`testDatabaseDir001 databaseDir:` + context.databaseDir);
expect(typeof (context.databaseDir) == 'string').assertTrue();
console.log(`testDatabaseDir001 success`);
done();
} catch (err) {
console.log(`testDatabaseDir001 fail: ` + err);
expect().assertFail();
done();
}
})
/**
* @tc.number : ABILITY_TEST_PREFERENCESDIR_0100
* @tc.name : testPreferencesDir001
* @tc.desc : test filed of preferencesDir
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 1
*/
it('testPreferencesDir001', 0, async function (done) {
try {
let context: common.AbilityStageContext = globalThis.stageContext;
console.log(`testPreferencesDir001 preferencesDir:` + context.preferencesDir);
expect(typeof (context.preferencesDir) == 'string').assertTrue();
console.log(`testPreferencesDir001 success`);
done();
} catch (err) {
console.log(`testPreferencesDir001 fail: ` + err);
expect().assertFail();
done();
}
})
/**
* @tc.number : ABILITY_TEST_BUNDLECODEDIR_0100
* @tc.name : testBundleCodeDir001
* @tc.desc : test filed of bundleCodeDir
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 1
*/
it('testBundleCodeDir001', 0, async function (done) {
try {
let context: common.AbilityStageContext = globalThis.stageContext;
console.log(`testBundleCodeDir001 bundleCodeDir:` + context.bundleCodeDir);
expect(typeof (context.bundleCodeDir) == 'string').assertTrue();
console.log(`testBundleCodeDir001 success`);
done();
} catch (err) {
console.log(`testBundleCodeDir001 fail: ` + err);
expect().assertFail();
done();
}
})
/**
* @tc.number : ABILITY_TEST_CREATEMODULECONTEXT_0100
* @tc.name : testCreateModuleContext001
* @tc.desc : Context calls createModuleContext, passing in the moduleName of the current application hap1
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 2
*/
it("testCreateModuleContext001", 0, async function (done) {
try {
console.info("testCreateModuleContext001 begin");
let context: common.AbilityStageContext = globalThis.stageContext;
expect(context != null).assertTrue();
let moduleContext = context.createModuleContext("entry");
expect(moduleContext != null).assertTrue();
bundleName = moduleContext.applicationInfo.name;
console.info("testCreateModuleContext001 bundleName: " + bundleName);
expect(bundleName).assertEqual("com.example.contexttest");
done();
} catch (err) {
console.info("testCreateModuleContext001 err: " + err);
expect().assertFail();
done();
}
})
/**
* @tc.number : ABILITY_TEST_CREATEMODULECONTEXT_0200
* @tc.name : testCreateModuleContext002
* @tc.desc : Context calls createModuleContext, passing in the moduleName of the current application hap2
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 2
*/
it("testCreateModuleContext002", 0, async function (done) {
try {
console.log("testCreateModuleContext002 begin");
let context: common.AbilityStageContext = globalThis.stageContext;
expect(context != null).assertTrue();
let moduleContext = context.createModuleContext("entryTest");
expect(moduleContext != null).assertTrue();
bundleName = moduleContext.applicationInfo.name;
console.info("testCreateModuleContext002 bundleName: " + bundleName);
expect(bundleName).assertEqual("com.example.contexttest");
done();
} catch (err) {
console.info("testCreateModuleContext002 err: " + err);
expect().assertFail();
done();
}
})
/**
* @tc.number : ABILITY_TEST_CREATEMODULECONTEXT_0300
* @tc.name : testCreateModuleContext003
* @tc.desc : Context calls createModuleContext, passing in the moduleName of the cross-application hap1
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 2
*/
it("testCreateModuleContext003", 0, async function (done) {
try {
console.info("testCreateModuleContext003 begin");
let context: common.AbilityStageContext = globalThis.stageContext;
let moduleContext = context.createModuleContext("entry_assist");
expect(!moduleContext).assertTrue();
done();
} catch (err) {
let e = err.toString();
let errLog = "Invalid input parameter"
console.debug("testCreateModuleContext003 ====>e====>" + e);
expect(e.indexOf(errLog) >= 0).assertTrue();
done();
}
})
/**
* @tc.number : ABILITY_TEST_CREATEMODULECONTEXT_0400
* @tc.name : testCreateModuleContext004
* @tc.desc : Context calls createModuleContext, passing in a non-existing moduleName
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 2
*/
it("testCreateModuleContext004", 0, async function (done) {
try {
console.info("testCreateModuleContext004 begin");
let context: common.AbilityStageContext = globalThis.stageContext;
let moduleContext = context.createModuleContext("abc");
expect(!moduleContext).assertTrue();
done();
} catch (err) {
let e = err.toString();
let errLog = "Invalid input parameter"
console.debug("testCreateModuleContext004 ====>e====>" + e);
expect(e.indexOf(errLog) >= 0).assertTrue();
done();
}
})
/**
* @tc.number : ABILITY_TEST_CREATEMODULECONTEXT_0500
* @tc.name : testCreateModuleContext005
* @tc.desc : Context calls createModuleContext, and the incoming moduleName is undefined
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 2
*/
it("testCreateModuleContext005", 0, async function (done) {
try {
console.info("testCreateModuleContext005 begin");
let context: common.AbilityStageContext = globalThis.stageContext;
let moduleContext = context.createModuleContext(undefined);
expect(moduleContext != null).assertTrue();
done();
} catch (err) {
let e = err.toString();
let errLog = "Invalid input parameter"
console.debug("testCreateModuleContext005 ====>e====>" + e);
expect(e.indexOf(errLog) >= 0).assertTrue();
done();
}
})
/**
* @tc.number : ABILITY_TEST_GETAPPLICATIONCONTEXT_0100
* @tc.name : testGetApplicationContext001
* @tc.desc : test getApplicationContext return not empty
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 2
*/
it("testGetApplicationContext001", 0, async function (done) {
try {
console.info("testGetApplicationContext001 begin");
let context: common.AbilityStageContext = globalThis.stageContext;
let applicationContext = context.getApplicationContext();
expect(applicationContext != null).assertTrue();
console.info("testGetApplicationContext001 success");
done();
} catch (err) {
console.log(`testGetApplicationContext001 fail: ` + err);
expect().assertFail();
done();
}
});
})
}
/*
* Copyright (c) 2023 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 common from '@ohos.app.ability.common';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
export default function Common() {
describe("Common", function () {
beforeAll(async function () {
console.info("beforeAll case");
});
beforeEach(async function () {
console.info("beforeEach case");
});
afterEach(async function () {
console.info('afterEach case');
});
afterAll(async function () {
console.info("afterAll case");
});
/**
* @tc.number : ABILITY_TEST_COMMON_0100
* @tc.name : testCommon001
* @tc.desc : test Common of UIAbilityContext
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 1
*/
it('testCommon001', 0, async function (done) {
try {
let abilityContext: common.UIAbilityContext = globalThis.abilityContext;
expect(abilityContext != null).assertTrue();
console.log(`testCommon001 success`);
done();
} catch (err) {
console.log(`testCommon001 fail:` + err);
expect().assertFail();
done();
}
})
/**
* @tc.number : ABILITY_TEST_COMMON_0200
* @tc.name : testCommon002
* @tc.desc : test Common of AbilityStageContext
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 1
*/
it('testCommon002', 0, async function (done) {
try {
let stageContext: common.AbilityStageContext = globalThis.stageContext;
expect(stageContext != null).assertTrue();
console.log(`testCommon002 success`);
done();
} catch (err) {
console.log(`testCommon002 fail:` + err);
expect().assertFail();
done();
}
})
/**
* @tc.number : ABILITY_TEST_COMMON_0300
* @tc.name : testCommon003
* @tc.desc : test Common of ApplicationContext
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 1
*/
it('testCommon003', 0, async function (done) {
try {
let abilityContext: common.UIAbilityContext = globalThis.abilityContext;
expect(abilityContext != null).assertTrue();
let appContext: common.ApplicationContext = abilityContext.getApplicationContext();
expect(appContext != null).assertTrue();
console.log(`testCommon003 success`);
done();
} catch (err) {
console.log(`testCommon003 fail:` + err);
expect().assertFail();
done();
}
})
/**
* @tc.number : ABILITY_TEST_COMMON_0400
* @tc.name : testCommon004
* @tc.desc : test Common of BaseContext
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 1
*/
it('testCommon004', 0, async function (done) {
try {
let stageContext: common.AbilityStageContext = globalThis.stageContext;
expect(stageContext != null).assertTrue();
let baseContext: common.BaseContext = stageContext;
expect(baseContext != null).assertTrue();
console.log(`testCommon004 success`);
done();
} catch (err) {
console.log(`testCommon004 fail:` + err);
expect().assertFail();
done();
}
})
/**
* @tc.number : ABILITY_TEST_COMMON_0500
* @tc.name : testCommon005
* @tc.desc : test Common of Context
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 1
*/
it('testCommon005', 0, async function (done) {
try {
let stageContext: common.AbilityStageContext = globalThis.stageContext;
expect(stageContext != null).assertTrue();
let context: common.Context = stageContext;
expect(context != null).assertTrue();
console.log(`testCommon005 success`);
done();
} catch (err) {
console.log(`testCommon005 fail:` + err);
expect().assertFail();
done();
}
})
})
}
/*
* Copyright (c) 2023 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 common from '@ohos.app.ability.common';
import configurationConstant from '@ohos.app.ability.ConfigurationConstant';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
export default function Configuration() {
describe("Configuration", function () {
beforeAll(async function () {
console.info("beforeAll case");
});
beforeEach(async function () {
console.info("beforeEach case");
});
afterEach(async function () {
console.info('afterEach case');
});
afterAll(async function () {
console.info("afterAll case");
});
/**
* @tc.number : ABILITY_TEST_COLORMODE_0100
* @tc.name : testColorMode001
* @tc.desc : test filed of colorMode
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 1
*/
it('testColorMode001', 0, async function (done) {
try {
let colorMode = globalThis.colorMode;
let context: common.UIAbilityContext = globalThis.abilityContext;
console.log(`testColorMode001 colorMode:` + colorMode);
if (colorMode == configurationConstant.ColorMode.COLOR_MODE_NOT_SET) {
expect(context.config.colorMode).assertEqual(configurationConstant.ColorMode.COLOR_MODE_NOT_SET);
} else if (colorMode == configurationConstant.ColorMode.COLOR_MODE_DARK) {
expect(context.config.colorMode).assertEqual(configurationConstant.ColorMode.COLOR_MODE_DARK);
expect(context.config.colorMode != configurationConstant.ColorMode.COLOR_MODE_NOT_SET).assertTrue();
expect(context.config.colorMode != configurationConstant.ColorMode.COLOR_MODE_LIGHT).assertTrue();
} else if (colorMode == configurationConstant.ColorMode.COLOR_MODE_LIGHT) {
expect(context.config.colorMode).assertEqual(configurationConstant.ColorMode.COLOR_MODE_LIGHT);
expect(context.config.colorMode != configurationConstant.ColorMode.COLOR_MODE_NOT_SET).assertTrue();
expect(context.config.colorMode != configurationConstant.ColorMode.COLOR_MODE_DARK).assertTrue();
}
console.log(`testColorMode001 success`);
done();
} catch (err) {
console.log(`testColorMode001 fail: ` + err);
expect().assertFail();
done();
}
})
/**
* @tc.number : ABILITY_TEST_DIRECTION_0100
* @tc.name : testDirection001
* @tc.desc : test filed of direction
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 1
*/
it('testDirection001', 0, async function (done) {
try {
let direction = globalThis.direction;
let context: common.UIAbilityContext = globalThis.abilityContext;
console.log(`testDirection001 direction:` + direction);
if (direction == configurationConstant.Direction.DIRECTION_NOT_SET) {
expect(context.config.direction).assertEqual(configurationConstant.Direction.DIRECTION_NOT_SET);
} else if (direction == configurationConstant.Direction.DIRECTION_VERTICAL) {
expect(context.config.direction).assertEqual(configurationConstant.Direction.DIRECTION_VERTICAL);
expect(context.config.direction != configurationConstant.Direction.DIRECTION_NOT_SET).assertTrue();
expect(context.config.direction != configurationConstant.Direction.DIRECTION_HORIZONTAL).assertTrue();
} else if (direction == configurationConstant.Direction.DIRECTION_HORIZONTAL) {
expect(context.config.direction).assertEqual(configurationConstant.Direction.DIRECTION_HORIZONTAL);
expect(context.config.direction != configurationConstant.Direction.DIRECTION_NOT_SET).assertTrue();
expect(context.config.direction != configurationConstant.Direction.DIRECTION_VERTICAL).assertTrue();
}
console.log(`testDirection001 success`);
done();
} catch (err) {
console.log(`testDirection001 fail: ` + err);
expect().assertFail();
done();
}
})
})
}
{
"module": {
"name": "entryTest",
"type": "feature",
"description": "$string:module_test_desc",
"srcEntry": "./ets/Application/AbilityStage.ts",
"mainElement": "TestAbility",
"deviceTypes": [
"phone"
],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:test_pages",
"abilities": [
{
"name": "TestAbility",
"srcEntry": "./ets/TestAbility/TestAbility.ets",
"description": "$string:TestAbility_desc",
"icon": "$media:icon",
"label": "$string:TestAbility_label",
"exported": true,
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:start_window_background",
"skills": [
{
"actions": [
"action.system.home"
],
"entities": [
"entity.system.home"
]
}
]
},
{
"name": "MainAbility1",
"srcEntry": "./ets/MainAbility1/MainAbility1.ts",
"description": "$string:MainAbility1_desc",
"icon": "$media:icon",
"label": "$string:MainAbility1_label",
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:start_window_background",
"launchType": "multiton"
}
]
}
}
\ No newline at end of file
{
"color": [
{
"name": "start_window_background",
"value": "#FFFFFF"
}
]
}
\ No newline at end of file
{
"string": [
{
"name": "module_test_desc",
"value": "test ability description"
},
{
"name": "TestAbility_desc",
"value": "the test ability"
},
{
"name": "TestAbility_label",
"value": "test label"
},
{
"name": "MainAbility1_desc",
"value": "description"
},
{
"name": "MainAbility1_label",
"value": "label"
}
]
}
\ No newline at end of file
{
"app": {
"bundleName": "com.example.contexttest",
"vendor": "example",
"versionCode": 1000000,
"versionName": "1.0.0",
"icon": "$media:app_icon",
"label": "$string:app_name",
"minAPIVersion": 9,
"targetAPIVersion": 9,
"car": {
"apiCompatibleVersion": 9,
"singleUser": false
}
}
}
# Copyright (c) 2023 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("context_entry_ets_normal_test") {
hap_profile = "src/main/module.json"
deps = [
":windowStage_js_assets",
":windowStage_resources",
]
ets2abc = true
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsAbilityContextEntryTest"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("windowStage_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("windowStage_js_assets") {
source_dir = "src/main/ets"
}
ohos_resources("windowStage_resources") {
sources = [ "src/main/resources" ]
deps = [ ":windowStage_app_profile" ]
hap_profile = "src/main/module.json"
}
\ No newline at end of file
import AbilityStage from '@ohos.app.ability.AbilityStage';
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("[Demo] MyAbilityStage onCreate")
}
}
\ No newline at end of file
/*
* Copyright (c) 2023 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.app.ability.UIAbility'
const abilityname = 'FeatureMainAbility';
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] MainAbility onCreate")
globalThis.abilityWant1 = want;
console.log("[Demo] MainAbility context: " + JSON.stringify(this.context));
var listKey1 = [];
let AbilityLifecycleCallback = {
onAbilityCreate(ability) {
console.log("[Demo] AbilityLifecycleCallback1 onAbilityCreate ability:"
+ JSON.stringify(ability));
console.log("[Demo] AbilityLifecycleCallback1 onAbilityCreate abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityCreate");
listKey1.push(abilityname + " onAbilityCreate");
console.log("[Demo] 1listKey1:" + JSON.stringify(listKey1));
},
onWindowStageCreate(ability, windowStage) {
console.log("[Demo] AbilityLifecycleCallback1 onWindowStageCreate ability:"
+ JSON.stringify(ability));
console.log("[Demo] AbilityLifecycleCallback1 onWindowStageCreate abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onWindowStageCreate");
listKey1.push(abilityname + " onWindowStageCreate");
console.log("[Demo] 2listKey1:" + JSON.stringify(listKey1));
},
onWindowStageActive(ability, windowStage) {
console.log(abilityname + " onWindowStageActive")
},
onWindowStageInactive(ability, windowStage) {
console.log(abilityname + " onWindowStageInactive")
},
onWindowStageDestroy(ability, windowStage) {
console.log("[Demo] AbilityLifecycleCallback1 onWindowStageDestroy ability:"
+ JSON.stringify(ability));
listKey1.push(abilityname + " onWindowStageDestroy");
console.log("[Demo] 3listKey1:" + JSON.stringify(listKey1));
},
onAbilityDestroy(ability) {
console.log("[Demo] AbilityLifecycleCallback1 onAbilityDestroy ability:"
+ JSON.stringify(ability));
console.log("[Demo] AbilityLifecycleCallback1 onAbilityDestroy abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityDestroy");
listKey1.push(abilityname + " onAbilityDestroy");
console.log("[Demo] 4listKey1:" + JSON.stringify(listKey1));
},
onAbilityForeground(ability) {
console.log("[Demo] AbilityLifecycleCallback1 onAbilityForeground ability:"
+ JSON.stringify(ability));
console.log("[Demo] AbilityLifecycleCallback1 onAbilityForeground abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityForeground");
listKey1.push(abilityname + " onAbilityForeground");
console.log("[Demo] 5listKey1:" + JSON.stringify(listKey1));
},
onAbilityBackground(ability) {
console.log("[Demo] AbilityLifecycleCallback1 onAbilityBackground ability:"
+ JSON.stringify(ability));
console.log("[Demo] AbilityLifecycleCallback1 onAbilityBackground abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityBackground");
listKey1.push(abilityname + " onAbilityBackground");
console.log("[Demo] 6listKey1:" + JSON.stringify(listKey1));
},
onAbilityContinue(ability) {
console.log("[Demo] AbilityLifecycleCallback1 onAbilityContinue ability:"
+ JSON.stringify(ability));
console.log("[Demo] AbilityLifecycleCallback1 onAbilityContinue abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityContinue");
listKey1.push(abilityname + " onAbilityContinue");
console.log("[Demo] 7listKey1:" + JSON.stringify(listKey1));
}
}
globalThis.applicationContext1 = this.context.getApplicationContext();
// let lifecycleid = globalThis.applicationContext1.registerAbilityLifecycleCallback(AbilityLifecycleCallback);
let lifecycleid = globalThis.applicationContext1.on('abilityLifecycle', AbilityLifecycleCallback);
console.log("[Demo] registerAbilityLifecycleCallback1 number: " + JSON.stringify(lifecycleid));
setTimeout(function () {
console.log("[Demo] registerAbilityLifecycleCallback1 listKey: " + JSON.stringify(listKey1));
globalThis.featureList1 = listKey1;
globalThis.featureCallbackid1 = lifecycleid;
}, 1500);
}
onDestroy() {
console.log("[Demo] MainAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] MainAbility onWindowStageCreate")
globalThis.featureAbilityContext = this.context;
// windowStage.setUIContent(this.context, "testability/pages/index1", null)
windowStage.loadContent('pages/Index', (err, data) => {
if (err.code) {
console.log('MainAbility loadContent error');
return;
}
console.log('MainAbility loadContent success');
});
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[Demo] MainAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] MainAbility onForeground")
}
onBackground() {
// Ability has back to background
console.log("[Demo] MainAbility onBackground")
}
};
/*
* Copyright (c) 2023 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)
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
{
"module": {
"name": "entry",
"type": "feature",
"description": "$string:module_test_desc",
"mainElement": "MainAbility",
"deviceTypes": [
"phone"
],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:test_pages",
"abilities": [
{
"name": "MainAbility",
"srcEntry": "./ets/mainability/MainAbility.ts",
"description": "$string:TestAbility_desc",
"icon": "$media:icon",
"label": "$string:TestAbility_label",
"exported": true,
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:start_window_background",
"skills": [
{
"actions": [
"action.system.home"
],
"entities": [
"entity.system.home"
]
}
]
}
]
}
}
{
"color": [
{
"name": "start_window_background",
"value": "#FFFFFF"
}
]
}
\ No newline at end of file
{
"string": [
{
"name": "module_test_desc",
"value": "test ability description"
},
{
"name": "TestAbility_desc",
"value": "the test ability"
},
{
"name": "TestAbility_label",
"value": "test label"
}
]
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册