提交 a6c98c12 编写于 作者: J jiyong

add stage

Signed-off-by: Njiyong <jiyong@huawei.com>
上级 ab224c61
......@@ -49,6 +49,7 @@ group("aafwk_standard") {
"serviceability/stserviceabilityserver:amsStServiceAilityServer",
"serviceability/stserviceabilityserversecond:ActsAmsStServiceAilityServerSecondTest",
"setshowonlockscreen:setshowonlockscreen",
"stage:stage",
"want:want",
]
}
......
# 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("stage") {
testonly = true
if (is_standard_system) {
deps = [ "stage_extension_service_test:StageExtensionServiceTest" ]
}
}
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("StageExtensionServiceTest") {
hap_profile = "./entry/src/main/config.json"
deps = [
":stage_extension_service_assets",
":stage_extension_service_resources",
]
ets2abc = true
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "StageExtensionServiceTest"
}
ohos_js_assets("stage_extension_service_assets") {
source_dir = "./entry/src/main/ets/MainAbility"
}
ohos_resources("stage_extension_service_resources") {
sources = [ "./entry/src/main/resources" ]
hap_profile = "./entry/src/main/config.json"
}
{
"description": "Configuration for serviceExtension Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "600000",
"package": "com.example.serviceextension",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"StageExtensionServiceTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "com.example.serviceextension",
"vendor": "example",
"version": {
"code": 1000000,
"name": "1.0.0"
}
},
"deviceConfig": {},
"module": {
"package": "com.example.serviceextension",
"name": ".MyApplication",
"mainAbility": ".MainAbility",
"srcPath": "",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry",
"installationFree": false
},
"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:description_mainability",
"formsEnabled": false,
"label": "$string:entry_MainAbility",
"type": "page",
"launchType": "standard"
},
{
"srcPath": "ServiceAbility",
"name": ".ServiceAbility",
"icon": "$media:icon",
"srcLanguage": "ets",
"description": "$string:description_serviceability",
"type": "service"
},
{
"srcPath": "ServiceAbility2",
"name": ".ServiceAbility2",
"icon": "$media:icon",
"srcLanguage": "ets",
"description": "$string:description_serviceability2",
"type": "service"
}
],
"js": [
{
"mode": {
"syntax": "ets",
"type": "pageAbility"
},
"pages": [
"pages/index",
"pages/second"
],
"name": ".MainAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
\ No newline at end of file
import AbilityStage from "@ohos.application.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("MyAbilityStage onCreate")
globalThis.stageOnCreateRun = 1;
globalThis.stageContext = this.context;
globalThis.lifeCycleList = [];
}
}
\ No newline at end of file
import Ability from '@ohos.application.Ability'
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
// Ability is creating, initialize resources for this ability
console.log("MainAbility onCreate")
globalThis.abilityWant = want;
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("MainAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("MainAbility onWindowStageCreate")
globalThis.abilityContext = this.context
windowStage.setUIContent(this.context, "pages/index", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("MainAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("MainAbility onForeground")
}
onBackground() {
// Ability has back to background
console.log("MainAbility onBackground")
}
};
export default {
onCreate() {
console.info('Application onCreate')
},
onDestroy() {
console.info('Application onDestroy')
},
}
\ No newline at end of file
import file from '@system.file';
import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index.ets"
import testsuite from "../../test/List.test.ets"
@Entry
@Component
struct Index {
aboutToAppear() {
console.info("start run testcase!!!!")
const core = Core.getInstance()
const expectExtend = new ExpectExtend({
'id': 'extend'
})
core.addService('expect', expectExtend)
const reportExtend = new ReportExtend(file)
core.addService('report', reportExtend)
core.init()
core.subscribeEvent('task', reportExtend)
const configService = core.getDefaultService('config')
console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters))
configService.setConfig(globalThis.abilityWant.parameters)
testsuite(globalThis.abilityContext)
core.execute()
}
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('Hello World 111!')
.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
import router from '@system.router';
@Entry
@Component
struct Second {
private content: string = "Second Page"
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text(`${this.content}`)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('back to index')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.onClick(() => {
router.back()
})
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
import ServiceExtension from "@ohos.application.ServiceExtension"
export default class MyServiceAbility extends ServiceExtension {
onCreate(want){
console.log('MyApplication.MyServiceExtension onCreate' + JSON.stringify(want));
globalThis.extensionContext = this.context;
}
onDestroy(){
console.log('[MyApplication] MyServiceExtension onDestroy');
}
onRequest(want,startId){
console.log('[MyApplication] MyServiceExtension onRequest' + JSON.stringify(want) + JSON.stringify(startId));
}
onConnect(want){
console.log('[MyApplication] MyServiceExtension onConnect' + JSON.stringify(want));
}
onDisconnect(want){
console.log('[MyApplication] MyServiceExtension onConnect' + JSON.stringify(want));
}
onReconnect(want){
console.log('[MyApplication] MyServiceExtension onConnect' + JSON.stringify(want));
}
}
export default {
onStart() {
console.info('ServiceAbility onStart');
},
onStop() {
console.info('ServiceAbility onStop');
},
onCommand(want, startId) {
console.info('ServiceAbility onCommand');
}
};
\ No newline at end of file
import ServiceExtension from "@ohos.application.ServiceExtension"
export default class MyServiceAbility extends ServiceExtension {
onCreate(want){
console.log('ServiceAbility2 onCreate' + JSON.stringify(want));
globalThis.extensionContext2 = this.context;
globalThis.lifeCycleList.push('ServiceAbility2_onCreate');
console.log('ServiceAbility2 lifeCycleList is' + JSON.stringify(globalThis.lifeCycleList));
}
onDestroy(){
console.log('ServiceAbility2 onDestroy');
globalThis.lifeCycleList.push('ServiceAbility2_onDestroy');
console.log('ServiceAbility2 lifeCycleList is' + JSON.stringify(globalThis.lifeCycleList));
}
onRequest(want,startId){
console.log('ServiceAbility2 onRequest' + JSON.stringify(want) + JSON.stringify(startId));
globalThis.lifeCycleList.push('ServiceAbility2_onRequest');
globalThis.startId2 = startId;
globalThis.serviceWant2 = want;
console.log("ServiceAbility2 serviceWant2 is " + JSON.stringify(globalThis.serviceWant2));
console.log('ServiceAbility2 lifeCycleList is' + JSON.stringify(globalThis.lifeCycleList));
setTimeout(()=>{
this.context.terminateSelf().then((data) => {
console.log("ServiceAbility2 terminateSelf data: " + JSON.stringify(data))
}).catch((error) => {
console.log("ServiceAbility2 terminateSelf error: " + JSON.stringify(error))
});
}, 1000);
}
onConnect(want){
console.log('ServiceAbility2 onConnect' + JSON.stringify(want));
globalThis.lifeCycleList.push('ServiceAbility2_onConnect');
console.log('ServiceAbility2 lifeCycleList is' + JSON.stringify(globalThis.lifeCycleList));
}
onDisconnect(want){
console.log('ServiceAbility2 onDisconnect' + JSON.stringify(want));
globalThis.lifeCycleList.push('ServiceAbility2_onDisconnect');
console.log('ServiceAbility2 lifeCycleList is' + JSON.stringify(globalThis.lifeCycleList));
}
onReconnect(want){
console.log('ServiceAbility2 onReconnect' + JSON.stringify(want));
globalThis.lifeCycleList.push('ServiceAbility2_onReconnect');
console.log('ServiceAbility2 lifeCycleList is' + JSON.stringify(globalThis.lifeCycleList));
}
}
export default {
onStart() {
console.info('ServiceAbility onStart');
},
onStop() {
console.info('ServiceAbility onStop');
},
onCommand(want, startId) {
console.info('ServiceAbility onCommand');
}
};
\ No newline at end of file
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permisrsions and
* limitations under the License.
*/
import ExtensionTest from './ExtensionTest.test.ets'
export default function testsuite(context) {
ExtensionTest(context)
}
\ No newline at end of file
{
"string": [
{
"name": "entry_MainAbility",
"value": "entry_MainAbility"
},
{
"name": "description_mainability",
"value": "eTS_Empty Ability"
},
{
"name": "description_serviceability",
"value": "hap sample empty service"
},
{
"name": "description_serviceability2",
"value": "hap sample empty service"
}
]
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册