TDD source code cannot be compiled to hap

Signed-off-by: zhoujun62 <zhoujun62@huawei.com>
Change-Id: Icebb33e2152eb9f59ba9fec99fb67d48cf18e8b1
This commit is contained in:
zhoujun62 2022-09-13 16:31:27 +08:00 committed by z00445003
parent 5ea4de9de3
commit 808ebd005d
40 changed files with 944 additions and 78 deletions

View File

@ -28,6 +28,8 @@ ohos_benchmarktest("BenchmarkTestForAbilityContext") {
deps = [
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
"${ability_runtime_native_path}/ability/native:abilitykit_native",
"${ability_runtime_path}/test/resource/benchmark/form_test_bundle:formTestWidget1",
"${ability_runtime_path}/test/resource/benchmark/ohos_test:copy_ohos_test",
"//third_party/benchmark:benchmark",
"//third_party/googletest:gtest_main",
]
@ -39,8 +41,6 @@ ohos_benchmarktest("BenchmarkTestForAbilityContext") {
"hiviewdfx_hilog_native:libhilog",
"ipc:ipc_core",
]
resource_config_file =
"${form_fwk_path}/test/resource/benchmark/ohos_test.xml"
}
group("benchmarktest") {

View File

@ -28,6 +28,8 @@ ohos_benchmarktest("BenchmarkTestForMissionManager") {
deps = [
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
"${ability_runtime_native_path}/ability/native:abilitykit_native",
"${ability_runtime_path}/test/resource/benchmark/form_test_bundle:formTestWidget1",
"${ability_runtime_path}/test/resource/benchmark/ohos_test:copy_ohos_test",
"//third_party/benchmark:benchmark",
"//third_party/googletest:gtest_main",
]
@ -38,8 +40,6 @@ ohos_benchmarktest("BenchmarkTestForMissionManager") {
"hiviewdfx_hilog_native:libhilog",
"ipc:ipc_core",
]
resource_config_file =
"${form_fwk_path}/test/resource/benchmark/ohos_test.xml"
}
group("benchmarktest") {

View File

@ -0,0 +1,38 @@
# 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("//build/ohos.gni")
ohos_hap("formTestWidget1") {
hap_profile = "./src/main/config.json"
hap_name = "formTestWidget1"
subsystem_name = "ability"
part_name = "ability_runtime"
final_hap_path = "$root_out_dir/tests/benchmark/ability_runtime/interfaces/resource/form_test_bundle/${hap_name}.hap"
testonly = true
deps = [
":formtestwidget1_ets_assets",
":formtestwidget1_ets_resources",
]
ets2abc = true
certificate_profile = "./signature/openharmony_sx.p7b"
}
ohos_js_assets("formtestwidget1_ets_assets") {
source_dir = "./src/main/ets"
hap_profile = "./src/main/config.json"
ets2abc = true
}
ohos_resources("formtestwidget1_ets_resources") {
sources = [ "./src/main/resources" ]
hap_profile = "./src/main/config.json"
}

View File

@ -0,0 +1,113 @@
{
"app": {
"vendor": "samples",
"bundleName": "ohos.samples.FormApplication",
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 8,
"releaseType": "Betal",
"target": 8
}
},
"deviceConfig": {},
"module": {
"mainAbility": ".MainAbility",
"deviceType": [
"default"
],
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"orientation": "unspecified",
"visible": true,
"srcPath": "MainAbility",
"name": ".MainAbility",
"srcLanguage": "ets",
"icon": "$media:icon",
"description": "$string:MainAbility_desc",
"formsEnabled": false,
"label": "$string:MainAbility_label",
"type": "page",
"launchType": "singleton"
},
{
"srcPath": "FormAbility",
"name": "FormAbility",
"icon": "$media:icon",
"srcLanguage": "ets",
"description": "$string:form_FormAbility_desc",
"formsEnabled": true,
"label": "$string:form_FormAbility_label",
"type": "service",
"forms": [
{
"jsComponentName": "widget",
"isDefault": true,
"scheduledUpdateTime": "10:30",
"defaultDimension": "2*4",
"formVisibleNotify": true,
"name": "widget",
"description": "This is a service widget.",
"colorMode": "auto",
"type": "JS",
"supportDimensions": [
"2*4",
"4*4"
],
"updateEnabled": true,
"updateDuration": 1
}
]
}
],
"distro": {
"moduleType": "entry",
"installationFree": false,
"deliveryWithInstall": true,
"moduleName": "entry"
},
"package": "ohos.samples.FormApplication",
"srcPath": "",
"name": ".entry",
"js": [
{
"mode": {
"syntax": "ets",
"type": "pageAbility"
},
"pages": [
"pages/index",
"pages/second"
],
"name": ".MainAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
},
{
"pages": [
"pages/index/index"
],
"name": "widget",
"window": {
"designWidth": 720,
"autoDesignWidth": true
},
"type": "form"
}
]
}
}

View File

@ -0,0 +1,180 @@
/*
* 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 dataStorage from '@ohos.data.storage';
import formBindingData from '@ohos.application.formBindingData';
import formInfo from '@ohos.application.formInfo';
import formProvider from '@ohos.application.formProvider';
import Logger from '../model/Logger'
const DATA_STORAGE_PATH = "/data/storage/el2/base/haps/form_store";
const FORM_PARAM_IDENTITY_KEY = "ohos.extra.param.key.form_identity";
const FORM_PARAM_NAME_KEY = "ohos.extra.param.key.form_name";
const FORM_PARAM_TEMPORARY_KEY = "ohos.extra.param.key.form_temporary";
function getTemperature(formId: string, count: number) {
const DECIMAL: number = 10;
const parsedFormId: number = parseInt(formId, DECIMAL);
const BASE_TEMP_MOD: number = 20;
const baseTemperature: number = parsedFormId % BASE_TEMP_MOD;
const RANGE_TEMP_MOD: number = 20;
return baseTemperature + Math.abs(count % RANGE_TEMP_MOD - RANGE_TEMP_MOD / 2);
}
function padZero(num: number) {
// trans num to string and pad 0
if (num < 10) {
return `0${num}`;
} else {
return num.toString();
}
}
function getTime() {
const date = new Date();
const hours = padZero(date.getHours());
const minutes = padZero(date.getMinutes());
const seconds = padZero(date.getSeconds());
return `${hours}:${minutes}:${seconds}`
}
async function storeFormInfo(formId: string, formName: string, tempFlag: boolean) {
let formInfo = {
"formName": formName,
"tempFlag": tempFlag,
"updateCount": 0
};
try {
const storage = await dataStorage.getStorage(DATA_STORAGE_PATH);
// put form info
await storage.put(formId, JSON.stringify(formInfo));
Logger.log(`storeFormInfo, put form info successfully, formId: ${formId}`);
await storage.flush();
} catch (err) {
Logger.error(`failed to storeFormInfo, err: ${JSON.stringify(err)}`);
}
}
async function updateTempFormInfo(formId: string) {
let formInfoDefault = {
"formName": "",
"tempFlag": false,
"updateCount": 0
};
try {
const storage = await dataStorage.getStorage(DATA_STORAGE_PATH);
// get form info
const data = await storage.get(formId, JSON.stringify(formInfoDefault));
Logger.log(`updateTempFormInfo, get form info successfully, formId: ${formId}`);
const formInfo = JSON.parse(data.toString());
if (!formInfo.tempFlag) {
Logger.log(`updateTempFormInfo, formId: ${formId} is not temporary.`);
return;
}
formInfo.tempFlag = false;
// update form info
await storage.put(formId, JSON.stringify(formInfo));
Logger.log(`updateTempFormInfo, update form info successfully, formId: ${formId}`);
await storage.flush();
} catch (err) {
Logger.error(`failed to updateTempFormInfo, err: ${JSON.stringify(err)}`);
}
}
async function updateForm(formId: string) {
let formInfoDefault = {
"formName": "",
"tempFlag": false,
"updateCount": 0
};
try {
const storage = await dataStorage.getStorage(DATA_STORAGE_PATH);
// get form info
const data = await storage.get(formId, JSON.stringify(formInfoDefault));
Logger.log(`updateForm, get form info successfully, formId: ${formId}`);
const formInfo = JSON.parse(data.toString());
formInfo.updateCount = formInfo.updateCount + 1;
let obj = {
"temperature": getTemperature(formId, formInfo.updateCount).toString(),
"time": getTime()
};
let formData = formBindingData.createFormBindingData(obj);
formProvider.updateForm(formId, formData).catch((err) => {
Logger.error(`updateForm, err: ${JSON.stringify(err)}`);
});
// update form info
await storage.put(formId, JSON.stringify(formInfo));
Logger.log(`updateForm, update form info successfully, formId: ${formId}`);
await storage.flush();
} catch (err) {
Logger.error(`failed to updateForm, err: ${JSON.stringify(err)}`);
}
}
async function deleteFormInfo(formId: string) {
try {
const storage = await dataStorage.getStorage(DATA_STORAGE_PATH);
// del form info
await storage.delete(formId);
Logger.log(`deleteFormInfo, del form info successfully, formId: ${formId}`);
await storage.flush();
} catch (err) {
Logger.error(`failed to deleteFormInfo, err: ${JSON.stringify(err)}`);
}
}
export default {
onCreate(want) {
Logger.log(`FormAbility onCreate, want: ${JSON.stringify(want)}`);
// get form info
let formId = want.parameters[FORM_PARAM_IDENTITY_KEY];
let formName = want.parameters[FORM_PARAM_NAME_KEY];
let tempFlag = want.parameters[FORM_PARAM_TEMPORARY_KEY];
storeFormInfo(formId, formName, tempFlag);
let obj = {
"temperature": getTemperature(formId, 0).toString(),
"time": getTime()
};
let formData = formBindingData.createFormBindingData(obj);
return formData;
},
onCastToNormal(formId) {
Logger.log(`FormAbility onCastToNormal, formId: ${formId}`);
updateTempFormInfo(formId);
},
onUpdate(formId) {
Logger.log(`FormAbility onUpdate, formId: ${formId}`);
updateForm(formId);
},
onVisibilityChange(newStatus) {
Logger.log(`FormAbility onVisibilityChange`);
},
onEvent(formId, message) {
Logger.log(`FormAbility onEvent, formId = ${formId}, message: ${JSON.stringify(message)}`);
},
onDestroy(formId) {
Logger.log(`FormAbility onDestroy, formId = ${formId}`);
deleteFormInfo(formId);
},
onAcquireFormState(want) {
Logger.log(`FormAbility onAcquireFormState`);
return formInfo.FormState.READY;
},
}

View File

@ -0,0 +1,25 @@
/*
* 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 Logger from '../model/Logger';
export default {
onCreate() {
Logger.info('Application onCreate')
},
onDestroy() {
Logger.info('Application onDestroy')
},
}

View File

@ -0,0 +1,61 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import router from '@ohos.router';
import Logger from '../../model/Logger';
async function routePage() {
let options = {
url: 'pages/second'
}
try {
await router.push(options)
} catch (err) {
Logger.error(`fail callback, code: ${err.code}, msg: ${err.msg}`)
}
}
@Entry
@Component
struct Index {
@State message: string = 'Hello World'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('next page')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}
.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width('35%')
.height('5%')
.onClick(() => {
routePage()
})
}
.width('100%')
}
.height('100%')
}
}

View File

@ -0,0 +1,49 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import router from '@ohos.router';
@Entry
@Component
struct Second {
@State message: string = 'Second Page'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('back to index')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}
.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width('35%')
.height('5%')
.onClick(() => {
router.back()
})
}
.width('100%')
}
.height('100%')
}
}

View File

@ -0,0 +1,41 @@
/*
* 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.
*/
class Logger {
constructor(private prefix: string) {
}
public log(...args: any[]) {
console.log(`[${this.prefix}]: ${args.join('')}`)
}
public info(...args: any[]) {
console.info(`[${this.prefix}]: ${args.join('')}`)
}
public debug(...args: any[]) {
console.debug(`[${this.prefix}]: ${args.join('')}`)
}
public warn(...args: any[]) {
console.warn(`[${this.prefix}]: ${args.join('')}`)
}
public error(...args: any[]) {
console.error(`[${this.prefix}]: ${args.join('')}`)
}
}
export default new Logger('eTSFormAbility')

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

View File

@ -0,0 +1,6 @@
{
"strings": {
"temperature": "Current Temperature: ",
"time": "Last Update Time: "
}
}

View File

@ -0,0 +1,6 @@
{
"strings": {
"temperature": "当前温度: ",
"time": "更新时间: "
}
}

View File

@ -0,0 +1,36 @@
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.bg-img {
flex-shrink: 0;
height: 100%;
}
.container-inner {
flex-direction: column;
justify-content: flex-end;
align-items: flex-start;
height: 100%;
width: 100%;
padding: 12px;
}
.title {
font-size: 19px;
font-weight: bold;
color: white;
text-overflow: ellipsis;
max-lines: 1;
}
.detail_text {
font-size: 16px;
color: white;
opacity: 0.66;
text-overflow: ellipsis;
max-lines: 1;
margin-top: 6px;
}

View File

@ -0,0 +1,11 @@
<div class="container">
<stack>
<div class="container-img">
<image src="/common/widget.png" class="bg-img"></image>
</div>
<div class="container-inner">
<text class="title" onclick="routerEvent">{{ $t('strings.temperature') }}{{ temperature }} ℃</text>
<text class="detail_text" onclick="messageEvent">{{ $t('strings.time') }} {{ time }}</text>
</div>
</stack>
</div>

View File

@ -0,0 +1,22 @@
{
"data": {
"temperature": "0",
"time": "00:00:00"
},
"actions": {
"routerEvent": {
"action": "router",
"bundleName": "ohos.samples.FormApplication",
"abilityName": "ohos.samples.FormApplication.MainAbility",
"params": {
"message": "add detail"
}
},
"messageEvent": {
"action": "message",
"params": {
"message": "add detail"
}
}
}
}

View File

@ -0,0 +1,24 @@
{
"string": [
{
"name": "entry_desc",
"value": "description"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "eTSFormAbility"
},
{
"name": "form_FormAbility_desc",
"value": "form_description"
},
{
"name": "form_FormAbility_label",
"value": "form_label"
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

View File

@ -0,0 +1,19 @@
# 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("//build/ohos.gni")
ohos_copy("copy_ohos_test") {
sources = [ "./ohos_test.xml" ]
outputs = [ "$root_out_dir/tests/benchmark/ability_runtime/interfaces/resource/ohos_test.xml" ]
}

View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
* Copyright (c) 2021-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.
-->
<configuration ver="2.0">
<target name="BenchmarkTestForAbilityContext">
<preparer>
<option name="push" value="form_test_bundle/formTestWidget1.hap -> /data/test/" src="res"/>
<option name="shell" value="bm install -r -p /data/test/formTestWidget1.hap"/>
</preparer>
</target>
<target name="BenchmarkTestForMissionManager">
<preparer>
<option name="push" value="form_test_bundle/formTestWidget1.hap -> /data/test/" src="res"/>
<option name="shell" value="bm install -r -p /data/test/formTestWidget1.hap"/>
</preparer>
</target>
</configuration>

View File

@ -5,7 +5,12 @@
"version": {
"code": 1000000,
"name": "1.0.0"
}
},
"apiVersion": {
"compatible": 8,
"releaseType": "Betal",
"target": 8
}
},
"deviceConfig": {},
"module": {
@ -77,4 +82,4 @@
}
]
}
}
}

View File

@ -28,7 +28,7 @@ ohos_hap("pageAbilityBundleForDump") {
certificate_profile = "../signature/openharmony_sx.p7b"
}
ohos_js_assets("pageAbilityBundleForDump_ets_assets") {
source_dir = "./src/main/ets"
source_dir = "./src/main/ets/MainAbility"
hap_profile = "./src/main/config.json"
ets2abc = true
}

View File

@ -5,7 +5,12 @@
"version": {
"code": 1000000,
"name": "1.0.0"
}
},
"apiVersion": {
"compatible": 8,
"releaseType": "Betal",
"target": 8
}
},
"deviceConfig": {},
"module": {
@ -63,4 +68,4 @@
}
]
}
}
}

View File

@ -28,7 +28,7 @@ ohos_hap("pageAbilityBundleForStart") {
certificate_profile = "../signature/openharmony_sx.p7b"
}
ohos_js_assets("pageAbilityBundleForStart_ets_assets") {
source_dir = "./src/main/ets"
source_dir = "./src/main/ets/MainAbility"
hap_profile = "./src/main/config.json"
ets2abc = true
}

View File

@ -5,7 +5,12 @@
"version": {
"code": 1000000,
"name": "1.0.0"
}
},
"apiVersion": {
"compatible": 8,
"releaseType": "Betal",
"target": 8
}
},
"deviceConfig": {},
"module": {
@ -64,4 +69,4 @@
}
]
}
}
}

View File

@ -5,32 +5,77 @@
"version": {
"code": 1000000,
"name": "1.0.0"
}
},
"apiVersion": {
"compatible": 8,
"releaseType": "Betal",
"target": 8
}
},
"deviceConfig": {},
"module": {
"package": "com.ohos.tools.serviceAbilityBundleForStart",
"name": "serviceAbilityBundleForStart",
"mainAbility": ".ServiceAbility",
"mainAbility": ".MainAbility",
"deviceType": [
"tv",
"car"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "testability",
"moduleName": "entry",
"moduleType": "entry",
"installationFree": false
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"orientation": "unspecified",
"formsEnabled": false,
"name": ".MainAbility",
"srcLanguage": "ets",
"srcPath": "MainAbility",
"icon": "$media:icon",
"description": "$string:MainAbility_desc",
"label": "$string:MainAbility_label",
"type": "page",
"visible": true,
"launchType": "standard"
},
{
"name": ".ServiceAbility",
"srcLanguage": "ets",
"srcPath": "ServiceAbility",
"icon": "$media:icon",
"description": "$string:ServiceAbility_desc",
"type": "service"
"type": "service",
"visible": true
}
],
"js": [
{
"mode": {
"syntax": "ets",
"type": "pageAbility"
},
"pages": [
"pages/index"
],
"name": ".MainAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
}

View File

@ -0,0 +1,23 @@
/*
* 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.
*/
export default {
onCreate() {
console.info('Application onCreate')
},
onDestroy() {
console.info('Application onDestroy')
},
}

View File

@ -0,0 +1,32 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@Entry
@Component
struct Index {
@State message: string = 'Hello World'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}

View File

@ -1,18 +1,3 @@
/*
* 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.
*/
export default {
onStart() {
console.info('ServiceAbility onStart');
@ -23,4 +8,4 @@ export default {
onCommand(want, startId) {
console.info('ServiceAbility onCommand');
}
};
};

View File

@ -13,26 +13,26 @@
import("//build/ohos.gni")
ohos_hap("pageAbilityBundleForStop") {
ohos_hap("serviceAbilityBundleForStop") {
hap_profile = "./src/main/config.json"
hap_name = "pageAbilityBundleForStop"
hap_name = "serviceAbilityBundleForStop"
subsystem_name = "ability"
part_name = "ability_runtime"
final_hap_path = "$root_out_dir/tests/systemtest/ability_tools/tools/resource/aa/${hap_name}.hap"
testonly = true
deps = [
":pageAbilityBundleForStop_ets_assets",
":pageAbilityBundleForStop_ets_resources",
":serviceAbilityBundleForStop_ets_assets",
":serviceAbilityBundleForStop_ets_resources",
]
ets2abc = true
certificate_profile = "../signature/openharmony_sx.p7b"
}
ohos_js_assets("pageAbilityBundleForStop_ets_assets") {
ohos_js_assets("serviceAbilityBundleForStop_ets_assets") {
source_dir = "./src/main/ets"
hap_profile = "./src/main/config.json"
ets2abc = true
}
ohos_resources("pageAbilityBundleForStop_ets_resources") {
ohos_resources("serviceAbilityBundleForStop_ets_resources") {
sources = [ "./src/main/resources" ]
hap_profile = "./src/main/config.json"
}

View File

@ -5,32 +5,77 @@
"version": {
"code": 1000000,
"name": "1.0.0"
}
},
"apiVersion": {
"compatible": 8,
"releaseType": "Betal",
"target": 8
}
},
"deviceConfig": {},
"module": {
"package": "com.ohos.tools.serviceAbilityBundleForStop",
"name": "serviceAbilityBundleForStop",
"mainAbility": ".ServiceAbility",
"mainAbility": ".MainAbility",
"deviceType": [
"tv",
"car"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "testability",
"moduleName": "entry",
"moduleType": "entry",
"installationFree": false
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"orientation": "unspecified",
"formsEnabled": false,
"name": ".MainAbility",
"srcLanguage": "ets",
"srcPath": "MainAbility",
"icon": "$media:icon",
"description": "$string:MainAbility_desc",
"label": "$string:MainAbility_label",
"type": "page",
"visible": true,
"launchType": "standard"
},
{
"name": ".ServiceAbility",
"srcLanguage": "ets",
"srcPath": "ServiceAbility",
"icon": "$media:icon",
"description": "$string:ServiceAbility_desc",
"type": "service"
"type": "service",
"visible": true
}
],
"js": [
{
"mode": {
"syntax": "ets",
"type": "pageAbility"
},
"pages": [
"pages/index"
],
"name": ".MainAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
}

View File

@ -0,0 +1,23 @@
/*
* 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.
*/
export default {
onCreate() {
console.info('Application onCreate')
},
onDestroy() {
console.info('Application onDestroy')
},
}

View File

@ -0,0 +1,32 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@Entry
@Component
struct Index {
@State message: string = 'Hello World'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}

View File

@ -1,18 +1,3 @@
/*
* 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.
*/
export default {
onStart() {
console.info('ServiceAbility onStart');
@ -23,4 +8,4 @@ export default {
onCommand(want, startId) {
console.info('ServiceAbility onCommand');
}
};
};

View File

@ -0,0 +1,21 @@
# 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("//build/ohos.gni")
ohos_copy("copy_ohos_test") {
sources = [ "./ohos_test.xml" ]
outputs = [
"$root_out_dir/tests/systemtest/ability_tools/tools/resource/ohos_test.xml",
]
}

View File

@ -15,21 +15,21 @@
-->
<configuration ver="2.0">
<target name="aa_command_dump_system_test">
<depend resource="aa/." pushpath="/data/test/resource/aa/" findpath="res" presetcmd="" />
<preparer>
<option name="push" value="aa/. -> /data/test/resource/aa/" src="res" />
<option name="push" value="aa/pageAbilityBundleForDump.hap -> /data/test/resource/aa/" src="res" />
<option name="push" value="aa/dataAbilityBundleForDump.hap -> /data/test/resource/aa/" src="res" />
<option name="push" value="aa/serviceAbilityBundleForStart.hap -> /data/test/resource/aa/" src="res" />
</preparer>
</target>
<target name="aa_command_start_system_test">
<depend resource="aa/." pushpath="/data/test/resource/aa/" findpath="res" presetcmd="" />
<preparer>
<option name="push" value="aa/. -> /data/test/resource/aa/" src="res" />
<option name="push" value="aa/pageAbilityBundleForStart.hap -> /data/test/resource/aa/" src="res" />
<option name="push" value="aa/serviceAbilityBundleForStart.hap -> /data/test/resource/aa/" src="res" />
</preparer>
</target>
<target name="aa_command_stop_service_system_test">
<depend resource="aa/." pushpath="/data/test/resource/aa/" findpath="res" presetcmd="" />
<preparer>
<option name="push" value="aa/. -> /data/test/resource/aa/" src="res" />
<option name="push" value="aa/serviceAbilityBundleForStop.hap -> /data/test/resource/aa/" src="res" />
</preparer>
</target>
</configuration>
</configuration>

View File

@ -39,6 +39,9 @@ ohos_systemtest("aa_command_start_system_test") {
deps = [
"${ability_runtime_path}/tools/aa:tools_aa_source_set",
"${ability_runtime_path}/tools/test/resource/aa/pageAbilityBundleForStart:pageAbilityBundleForStart",
"${ability_runtime_path}/tools/test/resource/aa/serviceAbilityBundleForStart:serviceAbilityBundleForStart",
"${ability_runtime_path}/tools/test/resource/ohos_test:copy_ohos_test",
"//third_party/googletest:gtest_main",
"//third_party/jsoncpp:jsoncpp",
]
@ -50,9 +53,6 @@ ohos_systemtest("aa_command_start_system_test") {
"hiviewdfx_hilog_native:libhilog",
"ipc:ipc_core",
]
resource_config_file =
"${ability_runtime_path}/tools/test/resource/ohos_test.xml"
}
ohos_systemtest("aa_command_stop_service_system_test") {
@ -72,6 +72,8 @@ ohos_systemtest("aa_command_stop_service_system_test") {
deps = [
"${ability_runtime_path}/tools/aa:tools_aa_source_set",
"${ability_runtime_path}/tools/test/resource/aa/serviceAbilityBundleForStop:serviceAbilityBundleForStop",
"${ability_runtime_path}/tools/test/resource/ohos_test:copy_ohos_test",
"//third_party/googletest:gtest_main",
"//third_party/jsoncpp:jsoncpp",
]
@ -83,9 +85,6 @@ ohos_systemtest("aa_command_stop_service_system_test") {
"hiviewdfx_hilog_native:libhilog",
"ipc:ipc_core",
]
resource_config_file =
"${ability_runtime_path}/tools/test/resource/ohos_test.xml"
}
ohos_systemtest("aa_command_dump_system_test") {
@ -107,6 +106,10 @@ ohos_systemtest("aa_command_dump_system_test") {
deps = [
"${ability_runtime_path}/tools/aa:tools_aa_source_set",
"${ability_runtime_path}/tools/test/resource/aa/dataAbilityBundleForDump:dataAbilityBundleForDump",
"${ability_runtime_path}/tools/test/resource/aa/pageAbilityBundleForDump:pageAbilityBundleForDump",
"${ability_runtime_path}/tools/test/resource/aa/serviceAbilityBundleForStart:serviceAbilityBundleForStart",
"${ability_runtime_path}/tools/test/resource/ohos_test:copy_ohos_test",
"//third_party/googletest:gtest_main",
"//third_party/jsoncpp:jsoncpp",
]
@ -118,9 +121,6 @@ ohos_systemtest("aa_command_dump_system_test") {
"hiviewdfx_hilog_native:libhilog",
"ipc:ipc_core",
]
resource_config_file =
"${ability_runtime_path}/tools/test/resource/ohos_test.xml"
}
group("systemtest") {

View File

@ -38,7 +38,7 @@ const std::string STRING_PAGE_ABILITY_NAME_INVALID = STRING_PAGE_ABILITY_NAME +
const std::string STRING_SERVICE_ABILITY_BUNDLE_PATH = "/data/test/resource/aa/serviceAbilityBundleForStart.hap";
const std::string STRING_SERVICE_ABILITY_BUNDLE_NAME = "com.ohos.tools.serviceAbilityBundleForStart";
const std::string STRING_SERVICE_ABILITY_BUNDLE_NAME_INVALID = STRING_SERVICE_ABILITY_BUNDLE_NAME + ".invalid";
const std::string STRING_SERVICE_ABILITY_NAME = "MainAbility";
const std::string STRING_SERVICE_ABILITY_NAME = "com.ohos.tools.serviceAbilityBundleForStart.ServiceAbility";
const std::string STRING_SERVICE_ABILITY_NAME_INVALID = STRING_SERVICE_ABILITY_NAME + ".Invalid";
} // namespace

View File

@ -30,7 +30,7 @@ const std::string STRING_DEVICE_NAME = "device";
const std::string STRING_SERVICE_ABILITY_BUNDLE_PATH = "/data/test/resource/aa/serviceAbilityBundleForStop.hap";
const std::string STRING_SERVICE_ABILITY_BUNDLE_NAME = "com.ohos.tools.serviceAbilityBundleForStop";
const std::string STRING_SERVICE_ABILITY_BUNDLE_NAME_INVALID = STRING_SERVICE_ABILITY_BUNDLE_NAME + ".invalid";
const std::string STRING_SERVICE_ABILITY_NAME = "MainAbility";
const std::string STRING_SERVICE_ABILITY_NAME = "com.ohos.tools.serviceAbilityBundleForStop.ServiceAbility";
const std::string STRING_SERVICE_ABILITY_NAME_INVALID = STRING_SERVICE_ABILITY_NAME + ".Invalid";
} // namespace