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

!3988 XTS元能力用例整改

Merge pull request !3988 from chengxingzhen/master
......@@ -25,7 +25,6 @@ group("ability_runtime") {
"actscalltest:actscalltest",
"actsfwkdataaccessortest:dataability",
"actsserviceabilityclienttest:serviceability",
"actsstartcomponenttest:actsstartcomponenttest",
"actsstserviceabilityclientcase:ActsStServiceAbilityClientCaseTest",
"actsusers:actsusers",
"amscontextualinforquery:amscontextualinforquery",
......
......@@ -95,6 +95,10 @@ function getMissionId(abilityName, state) {
})
}
function sleep(time) {
return new Promise((resolve)=>setTimeout(resolve,time));
}
function delay(time) {
let delta;
if (typeof time != 'number' || time <= 0) {
......@@ -1767,6 +1771,7 @@ export default function abilityTest(abilityContext) {
done();
}
}
await sleep(1000);
await globalThis.abilityContext.startAbility(want, startAbilityCallback);
......
# 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("//build/ohos_var.gni")
group("actsstartcomponenttest") {
testonly = true
if (is_standard_system) {
deps = [
"SpecifiedUserActionExtension_100:ActsSpecifiedUserActionextensionZeroTest",
"SpecifiedUserActionExtension_101:ActsSpecifiedUserActionextensiononeTest",
# "SpecifiedUserAction_100:ActsSpecifiedUserActionZeroTest",
# "SpecifiedUserAction_101:ActsSpecifiedUserActiononeTest",
]
}
}
{
"app": {
"bundleName": "com.example.actsspecifieduseractionextensionzerotest",
"vendor": "huawei",
"versionCode": 1000000,
"versionName": "1.0.0",
"debug": false,
"icon" : "$media:icon",
"label" : "$string:app_name",
"description" : "$string:description_application",
"distributedNotificationEnabled": true,
"keepAlive" : true,
"singleUser": true,
"minAPIVersion": 8,
"targetAPIVersion": 8,
"car": {
"apiCompatibleVersion": 8,
"singleUser": false
}
}
}
\ No newline at end of file
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsSpecifiedUserActionextensionZeroTest") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":actsspecifieduseractionextensionzerotest_js_assets",
":actsspecifieduseractionextensionzerotest_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsSpecifiedUserActionextensionZeroTest"
}
ohos_app_scope("actsspecifieduseractionextensionzerotest_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("actsspecifieduseractionextensionzerotest_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("actsspecifieduseractionextensionzerotest_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":actsspecifieduseractionextensionzerotest_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "120000",
"package": "com.example.actsspecifieduseractionextensionzerotest",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"ActsSpecifiedUserActionextensionZeroTest.hap",
"ActsSpecifiedUserActionextensiononeTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "PushKit",
"push": [
"ActsSpecifiedUserActionextensionZeroTest.hap->/system/app/ActsSpecifiedUserActionextensionZeroTest.hap"]
},
{
"type": "ShellKit",
"run-command": [
"acm create -n 101 -t normal",
"acm create -n 102 -t normal",
"acm switch -i 101"
],
"teardown-command":[
"acm delete -i 101",
"acm delete -i 102"
]
},
{
"type": "PushKit",
"push": [
"ActsSpecifiedUserActionextensiononeTest.hap->/system/app/ActsSpecifiedUserActionextensiononeTest.hap"]
},
{
"type": "ShellKit",
"run-command": [
"acm switch -i 100"
]
}
]
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityStage from "@ohos.application.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("MyAbilityStage onCreate")
globalThis.stageContext = this.context;
globalThis.startnum = 0
console.log("MyAbilityStage finish")
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Ability from '@ohos.application.Ability'
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
// Ability is creating, initialize resources for this ability
console.log("MainAbility onCreate");
globalThis.abilityWant = want;
globalThis.abilityContext = this.context
}
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");
windowStage.setUIContent(this.context, "pages/index/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");
}
};
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Ability from '@ohos.application.Ability'
import commonEvent from '@ohos.commonEvent'
function PublishCallBackOne() {
console.debug("====>Publish CallBack ACTS_STAWA_CommonEvent====>");
console.debug("====>close this context====>")
globalThis.ability2Context.terminateSelf();
}
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
// Ability is creating, initialize resources for this ability
console.log("MainAbility2 onCreate")
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("MainAbility2 onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("MainAbility2 onWindowStageCreate")
globalThis.ability2Context = this.context
windowStage.setUIContent(this.context, "pages/index", null)
commonEvent.publish("ABILITYCONTEX_Start_CommonEvent", PublishCallBackOne);
}
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")
}
};
/*
* 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 ServiceExtensionAbility from '@ohos.application.ServiceExtensionAbility'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index"
import rpc from '@ohos.rpc';
import osaccount from '@ohos.account.osAccount'
globalThis.ACCOUNT_ID100;
globalThis.ACCOUNT_ID101;
globalThis.ACCOUNT_ID102;
class Stub extends rpc.RemoteObject {
constructor(des) {
super(des);
}
// process client's request
onRemoteRequest(code, data, reply, option) {
reply.writeNoException();
reply.writeString("success");
return true;
}
}
function onConnectCallback(element) {
console.log('connectAbilityWithAccount onConnect element.bundleName : ' + element.bundleName)
console.log('connectAbilityWithAccount onConnect element.abilityName : ' + element.abilityName)
}
function onDisconnectCallback(element) {
console.log('connectAbilityWithAccount onDisconnect element.bundleName : ' + element.bundleName)
console.log('connectAbilityWithAccount onDisconnect element.abilityName : ' + element.abilityName)
}
function onFailedCallback(code) {
console.log('connectAbilityWithAccount onFailed errCode : ' + code)
}
export default class ServiceAbility extends ServiceExtensionAbility {
onCreate(want) {
console.log('ServiceAbility onCreate');
}
onDestory(){
console.log('ServiceAbility onDestory');
}
onRequest(want,startId) {
console.log('ServiceAbility onRequest');
}
onConnect(want) {
console.log('ServiceAbility onConnect');
console.log('globalThis.startnum is ' + globalThis.startnum);
switch (globalThis.startnum) {
case 1:
console.log('ServiceAbility case 1');
this.context.startAbilityWithAccount(
{
bundleName: 'com.example.actsspecifieduseractionextensionzerotest',
abilityName: 'com.example.actsspecifieduseractionextensionzerotest.MainAbility2'
},globalThis.ACCOUNT_ID100 ,{
windowMode: 2,
displayId: 1
}).then(() => {
console.log("====>end ACTS_StartServiceAbilityWithAccount_0100 ====>success!")
})
console.debug("====>case 1 end====>");
var myStub = new Stub("com.example.actsspecifieduseractionextensionzerotest.MainAbility");
console.log('ThirdAbility onConnect before return:')
return myStub;
break;
case 2:
console.log('ServiceAbility case 2');
this.context.startAbilityWithAccount(
{
bundleName: 'com.example.actsspecifieduseractionextensionzerotest',
abilityName: 'com.example.actsspecifieduseractionextensionzerotest.MainAbility2'
},globalThis.ACCOUNT_ID102 ,{
windowMode: 2,
displayId: 1
}).then(() => {
console.log("====>end ACTS_StartServiceAbilityWithAccount_0300 ====>success!")
})
console.debug("====>case 2 end====>");
var myStub = new Stub("com.example.actsspecifieduseractionextensionzerotest.MainAbility");
console.log('ThirdAbility onConnect before return:')
return myStub;
break;
case 3:
console.log('ServiceAbility case 3');
this.context.startAbilityWithAccount(
{
bundleName: 'com.example.actsspecifieduseractionextensiononetest',
abilityName: 'com.example.actsspecifieduseractionextensiononetest.MainAbility2'
},globalThis.ACCOUNT_ID101,((err, data) => {
console.log("====>end ACTS_StartServiceAbilityWithAccount_0500====>fail!!!"+ JSON.stringify(err))
console.log("====>end ACTS_StartServiceAbilityWithAccount_0500====>sunccess!"+ JSON.stringify(data))
}))
console.debug("====>case 3 end====>");
var myStub = new Stub("com.example.actsspecifieduseractionextensionzerotest.MainAbility");
console.log('ThirdAbility onConnect before return:')
return myStub;
break;
case 4:
console.log('ServiceAbility case 4');
this.context.startAbilityWithAccount(
{
bundleName: 'com.example.actsspecifieduseractionextensionzerotest',
abilityName: 'com.example.actsspecifieduseractionextensionzerotest.MainAbility2'
},globalThis.ACCOUNT_ID102, {
windowMode: 2,
displayId: 1
},((err, data) => {
console.log("====>end ACTS_StartServiceAbilityWithAccount_0600====>fail!!!"+ JSON.stringify(err))
console.log("====>end ACTS_StartServiceAbilityWithAccount_0600====>sunccess!"+ JSON.stringify(data))
}))
console.debug("====>case 4 end====>");
var myStub = new Stub("com.example.actsspecifieduseractionextensionzerotest.MainAbility");
console.log('ThirdAbility onConnect before return:')
return myStub;
break;
case 5:
console.log('ServiceAbility case 5');
this.context.startAbilityWithAccount(
{
bundleName: 'com.example.actsspecifieduseractionextensionzerotest',
abilityName: 'com.example.actsspecifieduseractionextensionzerotest.ServiceAbility2'
},globalThis.ACCOUNT_ID100).then((data) => {
console.log("====>end ACTS_StartServiceAbilityWithAccount_0700====>success!"+ JSON.stringify(data))
})
break;
case 6:
console.log('ServiceAbility case 6');
this.context.startAbilityWithAccount(
{
bundleName: 'com.example.actsspecifieduseractionextensionzerotest',
abilityName: 'com.example.actsspecifieduseractionextensionzerotest.ServiceAbility2'
},globalThis.ACCOUNT_ID102,((err, data) => {
console.log("====>end ACTS_StartServiceAbilityWithAccount_0900====>fail!!!")
console.log("====>end ACTS_StartServiceAbilityWithAccount_0900====>sunccess!")
}))
console.debug("====>case 6 end====>");
var myStub = new Stub("com.example.actsspecifieduseractionextensionzerotest.MainAbility");
console.log('ThirdAbility onConnect before return:')
return myStub;
break;
case 7:
console.log('ServiceAbility case 7');
this.context.startAbilityWithAccount(
{
bundleName: 'com.example.actsspecifieduseractionextensiononetest',
abilityName: 'com.example.actsspecifieduseractionextensiononetest.ServiceAbility2'
}, globalThis.ACCOUNT_ID101,((err, data) => {
console.log("====>end ACTS_StartServiceAbilityWithAccount_1100====>fail!!!"+ JSON.stringify(err))
console.log("====>end ACTS_StartServiceAbilityWithAccount_1100====>sunccess!"+ JSON.stringify(data))
}))
console.debug("====>case 7 end====>");
var myStub = new Stub("com.example.actsspecifieduseractionextensionzerotest.MainAbility");
console.log('ThirdAbility onConnect before return:')
return myStub;
break;
case 8:
console.log('ServiceAbility case 8');
this.context.startAbilityWithAccount(
{
bundleName: 'com.example.actsspecifieduseractionextensionzerotest',
abilityName: 'com.example.actsspecifieduseractionextensionzerotest.ServiceAbility2'
}, globalThis.ACCOUNT_ID102,((err, data) => {
console.log("====>end ACTS_StartServiceAbilityWithAccount_1200====>fail!!!"+ JSON.stringify(err))
console.log("====>end ACTS_StartServiceAbilityWithAccount_1200====>sunccess!"+ JSON.stringify(data))
}))
console.debug("====>case 8 end====>");
var myStub = new Stub("com.example.actsspecifieduseractionextensionzerotest.MainAbility");
console.log('ThirdAbility onConnect before return:')
return myStub;
break;
case 9:
console.log('ServiceAbility case 9');
this.context.connectAbilityWithAccount(
{
bundleName: 'com.example.actsspecifieduseractionextensionzerotest',
abilityName: 'com.example.actsspecifieduseractionextensionzerotest.ServiceAbility2',
action: "StartAbilityPromise"
}, globalThis.ACCOUNT_ID100, {
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback,
},)
break;
case 10:
console.log('ServiceAbility case 10');
this.context.connectAbilityWithAccount(
{
bundleName: 'com.example.actsspecifieduseractionextensionzerotest',
abilityName: 'com.example.actsspecifieduseractionextensionzerotest.ServiceAbility2',
action: "StartAbilityPromise"
},globalThis.ACCOUNT_ID102, {
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback,
},)
console.debug("====>case 10 end====>");
var myStub = new Stub("com.example.actsspecifieduseractionextensionzerotest.MainAbility");
console.log('ThirdAbility onConnect before return:')
return myStub;
break;
default:
console.log("====> ServiceAbility end default =====>")
break;
}
}
onDisconnect(want) {
console.log('ServiceAbility onDisconnect, want:' + want.abilityName);
}
onDestroy() {
console.log('ServiceAbility onDestroy');
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
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) 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 ServiceExtensionAbility from '@ohos.application.ServiceExtensionAbility'
import Want from '@ohos.application.Want';
import commonEvent from "@ohos.commonEvent"
import rpc from '@ohos.rpc';
export default class ServiceAbility2 extends ServiceExtensionAbility {
onCreate(want) {
console.log('ServiceAbility2 onCreate');
globalThis.abilityWant = want;
}
onDestory(){
console.log('ServiceAbility2 onDestory');
}
onRequest(want,startId) {
console.log('ServiceAbility2 onRequest');
commonEvent.publish("ABILITYCONTEX_Start_CommonEvent",() => {
console.log("publish Publish ABILITYCONTEX_Start_CommonEvent callback")
this.context.terminateSelf();
console.log("====> terminateSelf End=====>")
});
}
onConnect(want: Want) {
console.log('ServiceAbility2 onConnect');
if (want.action == 'StartAbilityPromise') {
console.log('stub StartAbilityPromise OnConnect start ');
commonEvent.publish("ABILITYCONTEX_Start_CommonEvent",() => {
console.log("publish Publish ABILITYCONTEX_Start_CommonEvent callback")
this.context.terminateSelf();
console.log("====> StartAbilityPromise End=====>")
});
}
return new rpc.RemoteObject('connect');
}
onDisconnect(want) {
console.log('ServiceAbility2 onDisconnect, want:' + want.abilityName);
}
onDestroy() {
console.log('ServiceAbility2 onDestroy');
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
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) 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 file from '@system.file';
import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index"
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)
console.info("subscribeEvent run !!!!")
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('MainAbility')
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import router from '@system.router';
@Entry
@Component
struct Second {
private content: string = "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
/*
* 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 abilityTest from './Ability.test.ets'
export default function testsuite(context) {
console.debug("====>in list.test====>");
abilityTest(context)
}
\ No newline at end of file
{
"module": {
"name": "phone",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
"phone"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"abilities": [
{
"name": "com.example.actsspecifieduseractionextensionzerotest.MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"skills": [
{
"actions": [
"action.system.home"
],
"entities": [
"entity.system.home"
]
}
]
},
{
"name": "com.example.actsspecifieduseractionextensionzerotest.MainAbility2",
"srcEntrance": "./ets/MainAbility2/MainAbility2.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"skills": [
{
"actions": [
"action.system.home"
],
"entities": [
"entity.system.home"
]
}
]
}
],
"extensionAbilities": [
{
"srcEntrance": "./ets/ServiceAbility/ServiceAbility.ts",
"name": "com.example.actsspecifieduseractionextensionzerotest.ServiceAbility",
"icon": "$media:icon",
"srcLanguage": "ets",
"description": "$string:phone_entry_main",
"type": "service",
"visible": true
},
{
"srcEntrance": "./ets/ServiceAbility2/ServiceAbility2.ts",
"name": "com.example.actsspecifieduseractionextensionzerotest.ServiceAbility2",
"icon": "$media:icon",
"srcLanguage": "ets",
"description": "$string:phone_entry_main",
"type": "service",
"visible": true
}
],
"requestPermissions": [
{
"name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
"reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
},
{
"name":"ohos.permission.GET_BUNDLE_INFO",
"reason":"need use ohos.permission.GET_BUNDLE_INFO"
},
{
"name":"ohos.permission.CHANGE_ABILITY_ENABLED_STATE",
"reason":"need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE"
},
{
"name": "ohos.permission.MANAGE_LOCAL_ACCOUNTS",
"reason": "ceshi"
},
{
"name": "ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION",
"reason": "ceshi"
},
{
"name":"ohos.permission.REMOVE_CACHE_FILES",
"reason":"need use ohos.permission.REMOVE_CACHE_FILES"
},
{
"name":"ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS",
"reason":"need use ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS"
},
{
"name":"ohos.permission.LISTEN_BUNDLE_CHANGE",
"reason":"need use ohos.permission.LISTEN_BUNDLE_CHANGE"
},
{
"name":"ohos.permission.INSTALL_BUNDLE",
"reason":"need use ohos.permission.INSTALL_BUNDLE"
},
{
"name":"ohos.permission.MANAGE_MISSIONS",
"reason":"need use ohos.permission.MANAGE_MISSIONS"
},
{
"name":"ohos.permission.GET_RUNNING_INFO",
"reason":"need use ohos.permission.GET_RUNNING_INFO"
},
{
"name":"ohos.permission.CLEAN_BACKGROUND_PROCESSES",
"reason":"need use ohos.permission.CLEAN_BACKGROUND_PROCESSES"
},
{
"name":"ohos.permission.CLEAN_APPLICATION_DATA",
"reason":"need use ohos.permission.CLEAN_APPLICATION_DATA"
}
]
}
}
{
"string": [
{
"name": "phone_entry_dsc",
"value": "i am an entry for phone"
},
{
"name": "phone_entry_main",
"value": "the phone entry ability"
},
{
"name": "entry_label",
"value": "ActsContextTest"
},
{
"name": "form_description",
"value": "my form"
},
{
"name": "serviceability_description",
"value": "my whether"
},
{
"name": "description_application",
"value": "demo for test"
},
{
"name": "app_name",
"value": "Demo"
}
]
}
\ No newline at end of file
{
"app": {
"bundleName": "com.example.actsspecifieduseractionextensiononetest",
"vendor": "huawei",
"versionCode": 1000000,
"versionName": "1.0.0",
"debug": false,
"icon" : "$media:icon",
"label" : "$string:app_name",
"description" : "$string:description_application",
"distributedNotificationEnabled": true,
"keepAlive" : true,
"singleUser": true,
"minAPIVersion": 8,
"targetAPIVersion": 8,
"car": {
"apiCompatibleVersion": 8,
"singleUser": false
}
}
}
\ No newline at end of file
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsSpecifiedUserActionextensiononeTest") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":actsspecifieduseractionextensiononetest_js_assets",
":actsspecifieduseractionextensiononetest_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsSpecifiedUserActionextensiononeTest"
}
ohos_app_scope("actsspecifieduseractionextensiononetest_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("actsspecifieduseractionextensiononetest_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("actsspecifieduseractionextensiononetest_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":actsspecifieduseractionextensiononetest_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "300000",
"package": "com.example.actsspecifieduseractionextensiononetest",
"shell-timeout": "300000"
},
"kits": [
{
"type": "ShellKit",
"run-command": [
"acm create -n 101 -t normal",
"acm create -n 102 -t normal",
"acm switch -i 101"
],
"teardown-command":[
"acm delete -i 101",
"acm delete -i 102"
]
},
{
"test-file-name": [
"ActsSpecifiedUserActionextensiononeTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"remount"
]
},
{
"type": "PushKit",
"push": [
"ActsSpecifiedUserActionextensiononeTest.hap->/system/app/ActsSpecifiedUserActionextensiononeTest.hap"
]
},
{
"type": "ShellKit",
"run-command": [
"acm switch -i 100"
]
},
{
"type": "PushKit",
"push": [
"ActsSpecifiedUserActionextensionZeroTest.hap->/system/app/ActsSpecifiedUserActionextensionZeroTest.hap"
]
},
{
"type": "ShellKit",
"run-command": [
"acm switch -i 101"
]
},
{
"type": "ShellKit",
"run-command": [
"chmod 644 /data/*.hap"
]
}
]
}
/*
* 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 AbilityStage from "@ohos.application.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("MyAbilityStage onCreate")
globalThis.stageContext = this.context;
globalThis.startnum = 0
console.log("MyAbilityStage finish")
}
}
\ 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 permissions and
* limitations under the License.
*/
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;
globalThis.abilityContext = this.context
}
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");
windowStage.setUIContent(this.context, "pages/index/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");
}
};
/*
* 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 Ability from '@ohos.application.Ability'
import commonEvent from '@ohos.commonEvent'
function PublishCallBackOne() {
console.debug("====>Publish CallBack ACTS_STAWA_CommonEvent====>");
console.debug("====>close this context====>")
globalThis.ability2Context.terminateSelf();
}
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
// Ability is creating, initialize resources for this ability
console.log("MainAbility2 onCreate")
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("MainAbility2 onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("MainAbility2 onWindowStageCreate")
globalThis.ability2Context = this.context
windowStage.setUIContent(this.context, "pages/index", null)
commonEvent.publish("ABILITYCONTEX_Start_CommonEvent", PublishCallBackOne);
}
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")
}
};
/*
* 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 ServiceExtensionAbility from '@ohos.application.ServiceExtensionAbility'
import rpc from '@ohos.rpc';
class Stub extends rpc.RemoteObject {
constructor(des) {
super(des);
}
// process client's request
onRemoteRequest(code, data, reply, option) {
reply.writeNoException();
reply.writeString("success");
return true;
}
}
function onConnectCallback(element) {
console.log('connectAbilityWithAccount onConnect element.bundleName : ' + element.bundleName)
console.log('connectAbilityWithAccount onConnect element.abilityName : ' + element.abilityName)
}
function onDisconnectCallback(element) {
console.log('connectAbilityWithAccount onDisconnect element.bundleName : ' + element.bundleName)
console.log('connectAbilityWithAccount onDisconnect element.abilityName : ' + element.abilityName)
}
function onFailedCallback(code) {
console.log('connectAbilityWithAccount onFailed errCode : ' + code)
}
export default class ServiceAbility extends ServiceExtensionAbility {
onCreate(want) {
console.log('ServiceAbility onCreate');
}
onDestory(){
console.log('ServiceAbility onDestory');
}
onRequest(want,startId) {
console.log('ServiceAbility onRequest');
}
onConnect(want) {
console.log('ServiceAbility onConnect');
console.log('globalThis.startnum is ' + globalThis.startnum);
switch (globalThis.startnum) {
case 1:
console.log('ServiceAbility case 1');
this.context.startAbilityWithAccount(
{
bundleName: 'com.example.actsspecifieduseractionextensionzerotest',
abilityName: 'com.example.actsspecifieduseractionextensionzerotest.MainAbility2'
},100, {
windowMode: 2,
displayId: 1
}).then((data) => {
console.log("====>end ACTS_StartServiceAbilityWithAccount_0200 ====>success!")
})
console.debug("====>case 1 end====>");
var myStub = new Stub("com.example.actsspecifieduseractionextensiononetest.MainAbility");
console.log('ThirdAbility onConnect before return:')
return myStub;
break;
break;
case 2:
console.log('ServiceAbility case 2');
this.context.startAbilityWithAccount(
{
bundleName: 'com.example.actsspecifieduseractionextensionzerotest',
abilityName: 'com.example.actsspecifieduseractionextensionzerotest.ServiceAbility2'
}, globalThis.ACCOUNT_ID100).then((data) => {
console.log("====>end ACTS_StartServiceAbilityWithAccount_0800====>success!"+ JSON.stringify(data))
})
console.debug("====>case 3 end====>");
var myStub = new Stub("com.example.actsspecifieduseractionextensiononetest.MainAbility");
console.log('ThirdAbility onConnect before return:')
return myStub;
break;
case 3:
console.log('ServiceAbility case 3');
this.context.connectAbilityWithAccount(
{
bundleName: 'com.example.actsspecifieduseractionextensionzerotest',
abilityName: 'com.example.actsspecifieduseractionextensionzerotest.ServiceAbility2'
}, globalThis.ACCOUNT_ID100, {
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback,
},)
console.debug("====>case 5 end====>");
var myStub = new Stub("com.example.actsspecifieduseractionextensiononetest.MainAbility");
console.log('ThirdAbility onConnect before return:')
return myStub;
break;
case 4:
console.log('ServiceAbility case 4');
this.context.startAbilityWithAccount(
{
bundleName: 'com.example.actsspecifieduseractionextensiononetest',
abilityName: 'com.example.actsspecifieduseractionextensiononetest.ServiceAbility2'
},101,((err, data) => {
console.log("====>end ACTS_StartServiceAbilityWithAccount_1000====>fail!!!"+ JSON.stringify(err))
console.log("====>end ACTS_StartServiceAbilityWithAccount_1000====>sunccess!"+ JSON.stringify(data))
}))
break;
case 5:
console.log('ServiceAbility case 5');
this.context.startAbilityWithAccount(
{
bundleName: 'com.example.actsspecifieduseractionextensiononetest',
abilityName: 'com.example.actsspecifieduseractionextensiononetest.ServiceAbility2'
}, globalThis.ACCOUNT_ID101,((err, data) => {
console.log("====>end ACTS_StartServiceAbilityWithAccount_0400====>fail!!!"+ JSON.stringify(err))
console.log("====>end ACTS_StartServiceAbilityWithAccount_0400====>sunccess!"+ JSON.stringify(data))
}))
break;
default:
console.log("====> ServiceAbility end default =====>")
break;
}
}
onDisconnect(want) {
console.log('ServiceAbility onDisconnect, want:' + want.abilityName);
}
onDestroy() {
console.log('ServiceAbility onDestroy');
}
}
\ No newline at end of file
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 permissions and
* limitations under the License.
*/
import ServiceExtensionAbility from '@ohos.application.ServiceExtensionAbility'
import Want from '@ohos.application.Want';
import commonEvent from "@ohos.commonEvent"
import rpc from '@ohos.rpc';
export default class ServiceAbility2 extends ServiceExtensionAbility {
onCreate(want) {
console.log('ServiceAbility2 onCreate');
globalThis.abilityWant = want;
}
onDestory(){
console.log('ServiceAbility2 onDestory');
}
onRequest(want,startId) {
console.log('ServiceAbility2 onRequest');
commonEvent.publish("ABILITYCONTEX_Start_CommonEvent",() => {
console.log("publish Publish ABILITYCONTEX_Start_CommonEvent callback")
this.context.terminateSelf();
console.log("====> terminateSelf End=====>")
});
}
onConnect(want: Want) {
console.log('ServiceAbility2 onConnect');
return new rpc.RemoteObject('connect');
}
onDisconnect(want) {
console.log('ServiceAbility2 onDisconnect, want:' + want.abilityName);
}
onDestroy() {
console.log('ServiceAbility2 onDestroy');
}
}
\ No newline at end of file
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 permissions and
* limitations under the License.
*/
import file from '@system.file';
import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index"
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)
console.info("subscribeEvent run !!!!")
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('MainAbility')
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import router from '@system.router';
@Entry
@Component
struct Second {
private content: string = "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
/*
* 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 abilityTest from './Ability.test.ets'
export default function testsuite(context) {
console.debug("====>in list.test====>");
abilityTest(context)
}
\ No newline at end of file
{
"module": {
"name": "phone",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
"phone"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"abilities": [
{
"name": "com.example.actsspecifieduseractionextensiononetest.MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"skills": [
{
"actions": [
"action.system.home"
],
"entities": [
"entity.system.home"
]
}
]
},
{
"name": "com.example.actsspecifieduseractionextensiononetest.MainAbility2",
"srcEntrance": "./ets/MainAbility2/MainAbility2.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"skills": [
{
"actions": [
"action.system.home"
],
"entities": [
"entity.system.home"
]
}
]
}
],
"extensionAbilities": [
{
"srcEntrance": "./ets/ServiceAbility/ServiceAbility.ts",
"name": "com.example.actsspecifieduseractionextensiononetest.ServiceAbility",
"icon": "$media:icon",
"srcLanguage": "ets",
"description": "$string:phone_entry_main",
"type": "service",
"visible": true
},
{
"srcEntrance": "./ets/ServiceAbility2/ServiceAbility2.ts",
"name": "com.example.actsspecifieduseractionextensiononetest.ServiceAbility2",
"icon": "$media:icon",
"srcLanguage": "ets",
"description": "$string:phone_entry_main",
"type": "service",
"visible": true
}
],
"requestPermissions": [
{
"name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
"reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
},
{
"name":"ohos.permission.GET_BUNDLE_INFO",
"reason":"need use ohos.permission.GET_BUNDLE_INFO"
},
{
"name":"ohos.permission.CHANGE_ABILITY_ENABLED_STATE",
"reason":"need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE"
},
{
"name": "ohos.permission.MANAGE_LOCAL_ACCOUNTS",
"reason": "ceshi"
},
{
"name": "ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION",
"reason": "ceshi"
},
{
"name":"ohos.permission.REMOVE_CACHE_FILES",
"reason":"need use ohos.permission.REMOVE_CACHE_FILES"
},
{
"name":"ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS",
"reason":"need use ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS"
},
{
"name":"ohos.permission.LISTEN_BUNDLE_CHANGE",
"reason":"need use ohos.permission.LISTEN_BUNDLE_CHANGE"
},
{
"name":"ohos.permission.INSTALL_BUNDLE",
"reason":"need use ohos.permission.INSTALL_BUNDLE"
},
{
"name":"ohos.permission.MANAGE_MISSIONS",
"reason":"need use ohos.permission.MANAGE_MISSIONS"
},
{
"name":"ohos.permission.GET_RUNNING_INFO",
"reason":"need use ohos.permission.GET_RUNNING_INFO"
},
{
"name":"ohos.permission.CLEAN_BACKGROUND_PROCESSES",
"reason":"need use ohos.permission.CLEAN_BACKGROUND_PROCESSES"
},
{
"name":"ohos.permission.CLEAN_APPLICATION_DATA",
"reason":"need use ohos.permission.CLEAN_APPLICATION_DATA"
}
]
}
}
{
"string": [
{
"name": "phone_entry_dsc",
"value": "i am an entry for phone"
},
{
"name": "phone_entry_main",
"value": "the phone entry ability"
},
{
"name": "entry_label",
"value": "ActsContextTest"
},
{
"name": "form_description",
"value": "my form"
},
{
"name": "serviceability_description",
"value": "my whether"
},
{
"name": "description_application",
"value": "demo for test"
},
{
"name": "app_name",
"value": "Demo"
}
]
}
\ No newline at end of file
{
"app": {
"bundleName": "com.example.actsspecifieduseractionzerotest",
"vendor": "huawei",
"versionCode": 1000000,
"versionName": "1.0.0",
"debug": false,
"icon" : "$media:icon",
"label" : "$string:app_name",
"description" : "$string:description_application",
"distributedNotificationEnabled": true,
"keepAlive" : true,
"singleUser": true,
"minAPIVersion": 8,
"targetAPIVersion": 8,
"car": {
"apiCompatibleVersion": 8,
"singleUser": false
}
}
}
\ No newline at end of file
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsSpecifiedUserActionZeroTest") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":actsspecifieduseractionzerotest_js_assets",
":actsspecifieduseractionzerotest_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsSpecifiedUserActionZeroTest"
}
ohos_app_scope("actsspecifieduseractionzerotest_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("actsspecifieduseractionzerotest_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("actsspecifieduseractionzerotest_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":actsspecifieduseractionzerotest_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "300000",
"package": "com.example.actsspecifieduseractionzerotest",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"ActsSpecifiedUserActionZeroTest.hap",
"ActsSpecifiedUserActiononeTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "PushKit",
"push": [
"ActsSpecifiedUserActionZeroTest.hap->/system/app/ActsSpecifiedUserActionZeroTest.hap"]
},
{
"type": "ShellKit",
"run-command": [
"acm create -n 101 -t normal",
"acm create -n 102 -t normal",
"acm switch -i 101"
]
},
{
"type": "PushKit",
"push": [
"ActsSpecifiedUserActiononeTest.hap->/system/app/ActsSpecifiedUserActiononeTest.hap"]
},
{
"type": "ShellKit",
"run-command": [
"acm switch -i 100"
],
"teardown-command":[
"acm delete -i 101",
"acm delete -i 102"
]
}
]
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityStage from "@ohos.application.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("MyAbilityStage onCreate")
globalThis.stageOnCreateRun = 1;
globalThis.stageContext = this.context;
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Ability from '@ohos.application.Ability'
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/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")
}
};
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Ability from '@ohos.application.Ability'
import commonEvent from '@ohos.commonEvent'
function PublishCallBackOne() {
console.debug("====>Publish CallBack ACTS_STAWA_CommonEvent====>");
console.debug("====>close this context====>")
globalThis.ability2Context.terminateSelf();
}
export default class MainAbility2 extends Ability {
onCreate(want, launchParam) {
// Ability is creating, initialize resources for this ability
console.log("MainAbility2 onCreate")
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("MainAbility2 onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("MainAbility2 onWindowStageCreate")
globalThis.ability2Context = this.context
windowStage.setUIContent(this.context, "pages/index", null)
commonEvent.publish("ABILITYCONTEX_Start_CommonEvent", PublishCallBackOne);
}
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")
}
};
/*
* 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 ServiceExtensionAbility from '@ohos.application.ServiceExtensionAbility'
import commonEvent from "@ohos.commonEvent"
import rpc from '@ohos.rpc';
class Stub extends rpc.RemoteObject {
constructor(des) {
super(des);
}
// process client's request
onRemoteRequest(code, data, reply, option) {
reply.writeNoException();
reply.writeString("success");
return true;
}
}
export default class ServiceAbility2 extends ServiceExtensionAbility {
onCreate(want) {
console.log('ServiceAbility2 onCreate');
globalThis.abilityWant = want;
}
onDestory(){
console.log('ServiceAbility2 onDestory');
}
onRequest(want,startId) {
console.log('ServiceAbility2 onRequest');
}
onConnect(want) {
console.log('ServiceAbility2 onConnect');
if (want.action == 'StartAbilityPromise') {
console.log('stub StartAbilityPromise OnConnect start ');
commonEvent.publish("ABILITYCONTEX_Start_CommonEvent",() => {
console.log("publish Publish ABILITYCONTEX_Start_CommonEvent callback")
console.log("====> StartAbilityPromise End=====>")
});
var myStub = new Stub("com.example.actsspecifieduseractionzerotest.MainAbility");
console.log('ThirdAbility onConnect before return:')
return myStub;
}
}
onDisconnect(want) {
console.log('ServiceAbility2 onDisconnect, want:' + want.abilityName);
}
onDestroy() {
console.log('ServiceAbility2 onDestroy');
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
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) 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 file from '@system.file';
import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index"
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)
console.info("subscribeEvent run !!!!")
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('MainAbility')
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import router from '@system.router';
@Entry
@Component
struct Second {
private content: string = "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
/*
* 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 abilityTest from './abilityTest.ets'
export default function testsuite(context) {
abilityTest(context)
}
\ No newline at end of file
{
"module": {
"name": "phone",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
"phone"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"abilities": [
{
"name": "com.example.actsspecifieduseractionzerotest.MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"skills": [
{
"actions": [
"action.system.home"
],
"entities": [
"entity.system.home"
]
}
]
},
{
"name": "com.example.actsspecifieduseractionzerotest.MainAbility2",
"srcEntrance": "./ets/MainAbility2/MainAbility2.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"skills": [
{
"actions": [
"action.system.home"
],
"entities": [
"entity.system.home"
]
}
]
}
],
"extensionAbilities": [
{
"srcEntrance": "./ets/ServiceAbility2/ServiceAbility2.ts",
"name": "com.example.actsspecifieduseractionzerotest.ServiceAbility2",
"icon": "$media:icon",
"srcLanguage": "ets",
"description": "$string:phone_entry_main",
"type": "service",
"visible": true
}
],
"requestPermissions": [
{
"name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
"reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
},
{
"name":"ohos.permission.GET_BUNDLE_INFO",
"reason":"need use ohos.permission.GET_BUNDLE_INFO"
},
{
"name":"ohos.permission.CHANGE_ABILITY_ENABLED_STATE",
"reason":"need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE"
},
{
"name": "ohos.permission.MANAGE_LOCAL_ACCOUNTS",
"reason": "ceshi"
},
{
"name": "ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION",
"reason": "ceshi"
},
{
"name":"ohos.permission.REMOVE_CACHE_FILES",
"reason":"need use ohos.permission.REMOVE_CACHE_FILES"
},
{
"name":"ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS",
"reason":"need use ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS"
},
{
"name":"ohos.permission.LISTEN_BUNDLE_CHANGE",
"reason":"need use ohos.permission.LISTEN_BUNDLE_CHANGE"
},
{
"name":"ohos.permission.INSTALL_BUNDLE",
"reason":"need use ohos.permission.INSTALL_BUNDLE"
},
{
"name":"ohos.permission.MANAGE_MISSIONS",
"reason":"need use ohos.permission.MANAGE_MISSIONS"
},
{
"name":"ohos.permission.GET_RUNNING_INFO",
"reason":"need use ohos.permission.GET_RUNNING_INFO"
},
{
"name":"ohos.permission.CLEAN_BACKGROUND_PROCESSES",
"reason":"need use ohos.permission.CLEAN_BACKGROUND_PROCESSES"
},
{
"name":"ohos.permission.CLEAN_APPLICATION_DATA",
"reason":"need use ohos.permission.CLEAN_APPLICATION_DATA"
}
]
}
}
{
"string": [
{
"name": "phone_entry_dsc",
"value": "i am an entry for phone"
},
{
"name": "phone_entry_main",
"value": "the phone entry ability"
},
{
"name": "entry_label",
"value": "ActsContextTest"
},
{
"name": "form_description",
"value": "my form"
},
{
"name": "serviceability_description",
"value": "my whether"
},
{
"name": "description_application",
"value": "demo for test"
},
{
"name": "app_name",
"value": "Demo"
}
]
}
\ No newline at end of file
{
"app": {
"bundleName": "com.example.actsspecifieduseractiononetest",
"vendor": "huawei",
"versionCode": 1000000,
"versionName": "1.0.0",
"debug": false,
"icon" : "$media:icon",
"label" : "$string:app_name",
"description" : "$string:description_application",
"distributedNotificationEnabled": true,
"keepAlive" : true,
"singleUser": true,
"minAPIVersion": 8,
"targetAPIVersion": 8,
"car": {
"apiCompatibleVersion": 8,
"singleUser": false
}
}
}
\ No newline at end of file
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsSpecifiedUserActiononeTest") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":actsspecifieduseractiononetest_js_assets",
":actsspecifieduseractiononetest_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsSpecifiedUserActiononeTest"
}
ohos_app_scope("actsspecifieduseractiononetest_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("actsspecifieduseractiononetest_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("actsspecifieduseractiononetest_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":actsspecifieduseractiononetest_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "300000",
"package": "com.example.actsspecifieduseractiononetest",
"shell-timeout": "300000"
},
"kits": [
{
"type": "ShellKit",
"run-command": [
"acm create -n 101 -t normal",
"acm create -n 102 -t normal",
"acm switch -i 101"
]
},
{
"test-file-name": [
"ActsSpecifiedUserActiononeTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"remount"
]
},
{
"type": "PushKit",
"push": [
"ActsSpecifiedUserActiononeTest.hap->/system/app/ActsSpecifiedUserActiononeTest.hap"
]
},
{
"type": "ShellKit",
"run-command": [
"acm switch -i 100"
]
},
{
"type": "PushKit",
"push": [
"ActsSpecifiedUserActionZeroTest.hap->/system/app/ActsSpecifiedUserActionZeroTest.hap"
]
},
{
"type": "ShellKit",
"run-command": [
"acm switch -i 101"
]
},
{
"type": "ShellKit",
"run-command": [
"chmod 644 /data/*.hap"
]
}
]
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityStage from "@ohos.application.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("MyAbilityStage onCreate")
globalThis.stageOnCreateRun = 1;
globalThis.stageContext = this.context;
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Ability from '@ohos.application.Ability'
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/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")
}
};
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Ability from '@ohos.application.Ability'
import commonEvent from '@ohos.commonEvent'
function PublishCallBackOne() {
console.debug("====>Publish CallBack ACTS_STAWA_CommonEvent====>");
console.debug("====>close this context====>")
globalThis.ability2Context.terminateSelf();
}
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
// Ability is creating, initialize resources for this ability
console.log("MainAbility2 onCreate")
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("MainAbility2 onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("MainAbility2 onWindowStageCreate")
globalThis.ability2Context = this.context
commonEvent.publish("ABILITYCONTEX_Start_CommonEvent", PublishCallBackOne);
}
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")
}
};
/*
* 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 ServiceExtension from '@ohos.application.ServiceExtensionAbility'
import commonEvent from "@ohos.commonEvent"
import rpc from '@ohos.rpc';
class Stub extends rpc.RemoteObject {
constructor(des) {
super(des);
}
// process client's request
onRemoteRequest(code, data, reply, option) {
reply.writeNoException();
reply.writeString("success");
return true;
}
}
export default class ServiceAbility2 extends ServiceExtensionAbility {
onCreate(want) {
console.log('ServiceAbility2 onCreate');
globalThis.abilityWant = want;
}
onDestory(){
console.log('ServiceAbility2 onDestory');
}
onRequest(want,startId) {
console.log('ServiceAbility2 onRequest');
}
onConnect(want) {
let extensionContext = this.context
console.log('ServiceAbility2 onConnect');
if (want.action == 'StartAbilityPromise') {
console.log('stub StartAbilityPromise OnConnect start ');
commonEvent.publish("ABILITYCONTEX_Start_CommonEvent",() => {
console.log("publish Publish ABILITYCONTEX_Start_CommonEvent callback")
extensionContext.terminateSelf();
console.log("====> StartAbilityPromise End=====>")
});
var myStub = new Stub("com.example.actsspecifieduseractiononetest.MainAbility");
console.log('ThirdAbility onConnect before return:')
return myStub;
}
}
onDisconnect(want) {
console.log('ServiceAbility2 onDisconnect, want:' + want.abilityName);
}
onDestroy() {
console.log('ServiceAbility2 onDestroy');
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
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) 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 file from '@system.file';
import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index"
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)
console.info("subscribeEvent run !!!!")
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('MainAbility')
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册