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

!4969 多用户用例转自动化

Merge pull request !4969 from xinking129/master
{
"app": {
"bundleName": "com.acts.actsinterfacemultiusersextensiontest",
"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("ActsAmsUsersExtensionSystemTest") {
hap_profile = "./entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":actsamsusersextensionsystemtest_js_assets",
":actsamsusersextensionsystemtest_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsAmsUsersExtensionSystemTest"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("actsamsusersextensionsystemtest_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("actsamsusersextensionsystemtest_js_assets") {
source_dir = "./entry/src/main/ets"
}
ohos_resources("actsamsusersextensionsystemtest_resources") {
sources = [ "./entry/src/main/resources" ]
deps = [ ":actsamsusersextensionsystemtest_app_profile" ]
hap_profile = "./entry/src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "300000",
"bundle-name": "com.acts.actsinterfacemultiusersextensiontest",
"module-name":"phone",
"shell-timeout": "300000",
"testcase-timeout": "30000"
},
"kits": [
{
"type": "ShellKit",
"run-command": [
"acm create -n user101 -t normal",
"acm switch -i 101"
],
"teardown-command": [
"acm switch -i 100",
"acm delete -i 101"
]
},
{
"test-file-name": [
"ActsAmsUsersExtensionSystemTest.hap",
"ActsAmsUsersApi7AppA.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
\ 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 AbilityStage from "@ohos.application.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("MyAbilityStage onCreate")
globalThis.stageOnCreateRun = 1;
globalThis.stageContext = this.context;
}
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Ability from '@ohos.application.Ability'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../test/List.test'
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
console.log('MainAbility onCreate')
globalThis.abilityWant = want;
globalThis.abilityContext = this.context;
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
onDestroy() {
console.log('MainAbility onDestroy')
}
onWindowStageCreate(windowStage) {
console.log('MainAbility onWindowStageCreate')
windowStage.setUIContent(this.context, 'MainAbility/pages/index/index', null)
}
onWindowStageDestroy() {
console.log('MainAbility onWindowStageDestroy')
}
onForeground() {
console.log('MainAbility onForeground')
}
onBackground() {
console.log('MainAbility onBackground')
}
};
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@Entry
@Component
struct Index {
@State message: string = 'ActsAmsUsersExtensionSystemTest'
build() {
Row() {
Column() {
Text(this.message)
.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 Ability from '@ohos.application.Ability'
import commonEvent from "@ohos.commonEvent"
export default class MainAbility2 extends Ability {
onCreate(want, launchParam) {
console.log("MainAbility2 onCreate");
globalThis.abilityContext2 = this.context
}
onDestroy() {
console.log("MainAbility2 onDestroy");
}
onWindowStageCreate(windowStage) {
console.log("MainAbility2 onWindowStageCreate");
windowStage.setUIContent(this.context, "MainAbility/pages/index/second", null);
commonEvent.publish("ACTS_InterfaceMultiUsersExtension_CommonEvent", () => {
console.log("publish Publish ACTS_InterfaceMultiUsersExtension_CommonEvent callback")
globalThis.abilityContext2.terminateSelf().then(() => {
commonEvent.publish("ACTS_TerminateSelf_CommonEvent", ()=>{
console.log('terminateSelf promise');
});
});
})
}
onWindowStageDestroy() {
console.log("MainAbility2 onWindowStageDestroy");
}
onForeground() {
console.log("MainAbility2 onForeground");
}
onBackground() {
console.log("MainAbility2 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);
}
onRemoteRequest(code, data, reply, option) {
reply.writeNoException();
reply.writeString("success");
return true;
}
}
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:
this.context.startAbility(
{
bundleName: 'com.acts.actsinterfacemultiusersextensiontest',
abilityName: 'com.acts.actsinterfacemultiusersextensiontest.MainAbility2'
},{
windowMode:0
}
).then((data) => {
console.debug("====>startAbility end====>");
console.debug("====>data is====>" + JSON.stringify(data));
}).catch((err)=>{
console.debug("==== err is====>"+ JSON.stringify(err));
console.debug("==== errCode is====>"+ JSON.stringify(err.code));
})
break;
case 2:
this.context.startAbility(
{
bundleName: 'com.acts.error',
abilityName: 'com.acts.error.MainAbility2'
},{
windowMode:0
}).then(()=>{
console.debug("====>startAbility end====>");
})
console.debug("====>case 2 end====>");
var myStub1 = new Stub("com.acts.actsinterfacemultiusersextensiontest.MainAbility");
console.log('ThirdAbility onConnect before return:')
return myStub1;
break;
case 3:
this.context.startAbility(
{
bundleName: 'com.acts.actsinterfacemultiusersextensiontest',
abilityName: 'com.acts.actsinterfacemultiusersextensiontest.MainAbility2'
},{
windowMode:0
},(err,data) => {
console.debug("==== err is====>"+ JSON.stringify(err));
console.debug("==== errCode is====>"+ JSON.stringify(err.code));
console.debug("====>startAbility end====>" );
})
var myStub7 = new Stub("com.acts.actsinterfacemultiusersextensiontest.MainAbility");
console.log('ThirdAbility onConnect before return:')
return myStub7;
break;
case 4:
this.context.startAbility(
{
bundleName: 'com.acts.error',
abilityName: 'com.acts.error.MainAbility2'
},{
windowMode:0
},(err,data) => {
console.debug("==== err is====>"+ JSON.stringify(err));
console.debug("==== errCode is====>"+ JSON.stringify(err.code));
console.debug("====>startAbility end====>" );
})
var myStub2 = new Stub("com.acts.actsinterfacemultiusersextensiontest.MainAbility");
console.log('ThirdAbility onConnect before return:')
return myStub2;
break;
case 5:
this.context.startAbility(
{
bundleName: 'com.acts.actsinterfacemultiusersextensiontest',
abilityName: 'com.acts.actsinterfacemultiusersextensiontest.ServiceAbility2'
}).then((data)=>{
console.debug("====>startAbility end====>");
console.debug("====>data is====>" + JSON.stringify(data));
})
break;
case 6:
this.context.startAbility(
{
bundleName: 'com.acts.error',
abilityName: 'com.acts.error.ServiceAbility2'
}).then(()=>{
console.debug("====>startAbility end====>");
})
var myStub3 = new Stub("com.acts.actsinterfacemultiusersextensiontest.MainAbility");
console.log('ThirdAbility onConnect before return:')
return myStub3;
break;
case 7:
this.context.startAbility(
{
bundleName: 'com.acts.actsinterfacemultiusersextensiontest',
abilityName: 'com.acts.actsinterfacemultiusersextensiontest.ServiceAbility2'
},(err,data) => {
console.debug("==== err is====>"+ JSON.stringify(err));
console.debug("==== errCode is====>"+ JSON.stringify(err.code));
console.debug("====>startAbility end====>" );
})
var myStub8 = new Stub("com.acts.actsinterfacemultiusersextensiontest.MainAbility");
console.log('ThirdAbility onConnect before return:')
return myStub8;
break;
case 8:
this.context.startAbility(
{
bundleName: 'com.acts.error',
abilityName: 'com.acts.error.ServiceAbility2'
},(err,data) => {
console.debug("==== err is====>"+ JSON.stringify(err));
console.debug("==== errCode is====>"+ JSON.stringify(err.code));
console.debug("====>startAbility end====>" );
})
var myStub4 = new Stub("com.acts.actsinterfacemultiusersextensiontest.MainAbility");
console.log('ThirdAbility onConnect before return:')
return myStub4;
break;
case 9:
this.context.startAbility(
{
bundleName: 'com.acts.actsinterfacemultiusersextensiontest',
abilityName: 'com.acts.actsinterfacemultiusersextensiontest.ServiceAbility2'
}).then(()=>{
console.debug("====>startAbility end====>");
})
var myStub11 = new Stub("com.acts.actsinterfacemultiusersextensiontest.MainAbility");
console.log('ThirdAbility onConnect before return:')
return myStub11;
break;
case 10:
this.context.startAbility(
{
bundleName: 'com.acts.error',
abilityName: 'com.acts.error.ServiceAbility2'
}).then(()=>{
console.debug("====>startAbility end====>");
})
var myStub5 = new Stub("com.acts.actsinterfacemultiusersextensiontest.MainAbility");
console.log('ThirdAbility onConnect before return:')
return myStub5;
break;
case 11:
this.context.startAbility(
{
bundleName: 'com.acts.actsinterfacemultiusersextensiontest',
abilityName: 'com.acts.actsinterfacemultiusersextensiontest.ServiceAbility2'
}).then(()=>{
console.debug("====>startAbility end====>");
})
var myStub12 = new Stub("com.acts.actsinterfacemultiusersextensiontest.MainAbility");
console.log('ThirdAbility onConnect before return:')
return myStub12;
break;
case 12:
this.context.startAbility(
{
bundleName: 'com.acts.error',
abilityName: 'com.acts.error.ServiceAbility2'
},(err,data) => {
console.debug("==== err is====>"+ JSON.stringify(err));
console.debug("==== errCode is====>"+ JSON.stringify(err.code));
console.debug("====>startAbility end====>" );
})
var myStub6 = new Stub("com.acts.actsinterfacemultiusersextensiontest.MainAbility");
console.log('ThirdAbility onConnect before return:')
return myStub6;
break;
case 13:
this.context.startAbility(
{
bundleName: 'com.example.userservicesystemapi7',
abilityName: 'com.example.userservicesystemapi7.ServiceAbility'
}).then(() => {
console.debug("====>startAbility end====>" );
})
var myStub9 = new Stub("com.acts.actsinterfacemultiusersextensiontest.MainAbility");
console.log('ThirdAbility onConnect before return:')
return myStub9;
break;
case 14:
this.context.startAbility(
{
bundleName: 'com.example.userservicesystemapi7',
abilityName: 'com.example.userservicesystemapi7.ServiceAbility'
},(err,data) => {
console.debug("==== err is====>"+ JSON.stringify(err));
console.debug("==== errCode is====>"+ JSON.stringify(err.code));
console.debug("====>startAbility end====>" );
})
var myStub10 = new Stub("com.acts.actsinterfacemultiusersextensiontest.MainAbility");
console.log('ThirdAbility onConnect before return:')
return myStub10;
break;
default:
break;
}
return new rpc.RemoteObject('connect');
}
onDisconnect(want) {
console.log('ServiceAbility onDisconnect');
}
onDestroy() {
console.log('ServiceAbility onDestroy');
}
}
\ 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 commonEvent from "@ohos.commonEvent"
import rpc from '@ohos.rpc';
export default class ServiceAbility2 extends ServiceExtensionAbility {
onCreate(want) {
console.log('ServiceAbility2 onCreate');
}
onDestory(){
console.log('ServiceAbility2 onDestory');
}
onRequest(want,startId) {
console.log('ServiceAbility2 onRequest');
commonEvent.publish("ACTS_InterfaceMultiUsersExtension_CommonEvent", () => {
console.log("publish Publish ACTS_InterfaceMultiUsersExtension_CommonEvent callback")
this.context.terminateSelf().then(() => {
commonEvent.publish("ACTS_TerminateSelf_CommonEvent", ()=>{
console.log('terminateSelf promise');
});
});
})
}
onConnect(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
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import TestRunner from '@ohos.application.testRunner'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
var abilityDelegator = undefined
var abilityDelegatorArguments = undefined
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s it',
'-s level', '-s testType', '-s size', '-s timeout',
'-s dryRun'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams = `${targetParams} ${key} ${parameters[key]}`
}
}
return targetParams.trim()
}
async function onAbilityCreateCallback() {
console.log("onAbilityCreateCallback");
}
async function addAbilityMonitorCallback(err: any) {
console.info("addAbilityMonitorCallback : " + JSON.stringify(err))
}
export default class OpenHarmonyTestRunner implements TestRunner {
constructor() {
}
onPrepare() {
console.info("OpenHarmonyTestRunner OnPrepare ")
}
async onRun() {
console.log('OpenHarmonyTestRunner onRun run')
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility'
let lMonitor = {
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
var cmd = 'aa start -d 0 -a com.acts.actsinterfacemultiusersextensiontest.MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters)
var debug = abilityDelegatorArguments.parameters["-D"]
if (debug == 'true')
{
cmd += ' -D'
}
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd,
(err: any, d: any) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + d.stdResult);
console.info('executeShellCommand : data : ' + d.exitCode);
})
console.info('OpenHarmonyTestRunner onRun end')
}
};
\ No newline at end of file
/*
* Copyright (c) 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() {
console.debug("====>in list.test====>");
abilityTest()
}
\ 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.acts.actsinterfacemultiusersextensiontest.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.acts.actsinterfacemultiusersextensiontest.MainAbility2",
"srcEntrance": "./ets/MainAbility2/MainAbility2.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait"
}
],
"extensionAbilities": [
{
"srcEntrance": "./ets/ServiceAbility/ServiceAbility.ts",
"name": "com.acts.actsinterfacemultiusersextensiontest.ServiceAbility",
"icon": "$media:icon",
"srcLanguage": "ets",
"description": "$string:phone_entry_main",
"type": "service",
"visible": true
},
{
"srcEntrance": "./ets/ServiceAbility2/ServiceAbility2.ts",
"name": "com.acts.actsinterfacemultiusersextensiontest.ServiceAbility2",
"icon": "$media:icon",
"srcLanguage": "ets",
"description": "$string:phone_entry_main",
"type": "service",
"visible": true
}
],
"defPermissions": [
{
"availableScope": [],
"grantMode": "system_grant",
"name": "ohos.permission.MANAGE_LOCAL_ACCOUNTS"
},
{
"availableScope": [],
"grantMode": "system_grant",
"name": "ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION"
}
],
"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.REMOVE_CACHE_FILES",
"reason": "need use ohos.permission.REMOVE_CACHE_FILES"
},
{
"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.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.MANAGE_LOCAL_ACCOUNTS",
"reason": "need use ohos.permission.MANAGE_LOCAL_ACCOUNTS"
},
{
"name": "ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION",
"reason": "need use ohos.permission.MANAGE_LOCAL_ACCOUNTS"
}
]
}
}
{
"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
{
"src": [
"MainAbility/pages/index/index",
"MainAbility/pages/second/second"
]
}
\ No newline at end of file
{
"app": {
"bundleName": "com.acts.actsinterfacemultiusersextensionthirdtest",
"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("ActsAmsUsersExtensionThirdTest") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":actsamsusersextensionthirdtest_js_assets",
":actsamsusersextensionthirdtest_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsAmsUsersExtensionThirdTest"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("actsamsusersextensionthirdtest_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("actsamsusersextensionthirdtest_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("actsamsusersextensionthirdtest_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":actsamsusersextensionthirdtest_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "300000",
"bundle-name": "com.acts.actsinterfacemultiusersextensionthirdtest",
"module-name":"phone",
"shell-timeout": "300000",
"testcase-timeout": "30000"
},
"kits": [
{
"type": "ShellKit",
"run-command": [
"acm create -n user101 -t normal",
"acm switch -i 101"
],
"teardown-command": [
"acm switch -i 100",
"acm delete -i 101"
]
},
{
"test-file-name": [
"ActsAmsUsersExtensionThirdTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
\ 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 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'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../test/List.test'
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
console.log('MainAbility onCreate')
globalThis.abilityWant = want;
globalThis.abilityContext = this.context;
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
onDestroy() {
console.log('MainAbility onDestroy')
}
onWindowStageCreate(windowStage) {
console.log('MainAbility onWindowStageCreate')
windowStage.setUIContent(this.context, 'MainAbility/pages/index/index', null)
}
onWindowStageDestroy() {
console.log('MainAbility onWindowStageDestroy')
}
onForeground() {
console.log('MainAbility onForeground')
}
onBackground() {
console.log('MainAbility onBackground')
}
};
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@Entry
@Component
struct Index {
@State message: string = 'ActsAmsUsersExtensionSystemTest'
build() {
Row() {
Column() {
Text(this.message)
.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 Ability from '@ohos.application.Ability'
import commonEvent from "@ohos.commonEvent"
export default class MainAbility2 extends Ability {
onCreate(want, launchParam) {
console.log("MainAbility2 onCreate");
globalThis.abilityContext2 = this.context
}
onDestroy() {
console.log("MainAbility2 onDestroy");
}
onWindowStageCreate(windowStage) {
console.log("MainAbility2 onWindowStageCreate");
windowStage.setUIContent(this.context, "MainAbility/pages/index/second", null);
commonEvent.publish("ACTS_InterfaceMultiUsersExtension_CommonEvent", () => {
console.log("publish Publish ACTS_InterfaceMultiUsersExtension_CommonEvent callback")
globalThis.abilityContext2.terminateSelf().then(() => {
commonEvent.publish("ACTS_TerminateSelf_CommonEvent", ()=>{
console.log('terminateSelf promise');
});
});
})
}
onWindowStageDestroy() {
console.log("MainAbility2 onWindowStageDestroy");
}
onForeground() {
console.log("MainAbility2 onForeground");
}
onBackground() {
console.log("MainAbility2 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 Want from '@ohos.application.Want';
import rpc from '@ohos.rpc';
class Stub extends rpc.RemoteObject {
constructor(des) {
super(des);
}
onRemoteRequest(code, data, reply, option) {
reply.writeNoException();
reply.writeString("success");
return true;
}
}
export default class ServiceAbility extends ServiceExtensionAbility {
onCreate(want: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:
this.context.startAbility(
{
bundleName: 'com.acts.actsinterfacemultiusersextensionthirdtest',
abilityName: 'com.acts.actsinterfacemultiusersextensionthirdtest.MainAbility2'
},{
windowMode:0
}
).then((data) => {
console.debug("====>startAbility end====>");
console.debug("====>data is====>" + JSON.stringify(data));
})
break;
case 2:
this.context.startAbility(
{
bundleName: 'com.acts.error',
abilityName: 'com.acts.error.MainAbility2'
},{
windowMode:0
}).then(()=>{
console.debug("====>startAbility end====>");
})
console.debug("====>case 2 end====>");
var myStub1 = new Stub("com.acts.actsinterfacemultiusersextensionthirdtest.MainAbility");
console.log('ThirdAbility onConnect before return:')
return myStub1;
break;
case 3:
this.context.startAbility(
{
bundleName: 'com.acts.actsinterfacemultiusersextensionthirdtest',
abilityName: 'com.acts.actsinterfacemultiusersextensionthirdtest.MainAbility2'
},{
windowMode:0
},(err,data) => {
console.debug("====>err is====>" + JSON.stringify(err));
console.debug("====>startAbility end====>" );
})
var myStub7 = new Stub("com.acts.actsinterfacemultiusersextensionthirdtest.MainAbility");
console.log('ThirdAbility onConnect before return:')
return myStub7;
break;
case 4:
this.context.startAbility(
{
bundleName: 'com.acts.error',
abilityName: 'com.acts.error.MainAbility2'
},{
windowMode:0
},(err,data) => {
console.debug("====>err is====>" + JSON.stringify(err));
console.debug("====>startAbility end====>" );
})
var myStub2 = new Stub("com.acts.actsinterfacemultiusersextensionthirdtest.MainAbility");
console.log('ThirdAbility onConnect before return:')
return myStub2;
break;
case 5:
this.context.startAbility(
{
bundleName: 'com.acts.actsinterfacemultiusersextensionthirdtest',
abilityName: 'com.acts.actsinterfacemultiusersextensionthirdtest.ServiceAbility2'
}).then((data)=>{
console.debug("====>startAbility end====>");
console.debug("====>data is====>" + JSON.stringify(data));
})
break;
case 6:
this.context.startAbility(
{
bundleName: 'com.acts.error',
abilityName: 'com.acts.error.ServiceAbility2'
}).then(()=>{
console.debug("====>startAbility end====>");
})
var myStub3 = new Stub("com.acts.actsinterfacemultiusersextensionthirdtest.MainAbility");
console.log('ThirdAbility onConnect before return:')
return myStub3;
break;
case 7:
this.context.startAbility(
{
bundleName: 'com.acts.actsinterfacemultiusersextensionthirdtest',
abilityName: 'com.acts.actsinterfacemultiusersextensionthirdtest.ServiceAbility2'
},(err,data) => {
console.debug("====>err is====>" + JSON.stringify(err));
console.debug("====>startAbility end====>" );
})
var myStub8 = new Stub("com.acts.actsinterfacemultiusersextensionthirdtest.MainAbility");
console.log('ThirdAbility onConnect before return:')
return myStub8;
break;
case 8:
this.context.startAbility(
{
bundleName: 'com.acts.error',
abilityName: 'com.acts.error.ServiceAbility2'
},(err,data) => {
console.debug("====>err is====>" + JSON.stringify(err));
console.debug("====>startAbility end====>" );
})
var myStub4 = new Stub("com.acts.actsinterfacemultiusersextensionthirdtest.MainAbility");
console.log('ThirdAbility onConnect before return:')
return myStub4;
break;
case 9:
this.context.startAbility(
{
bundleName: 'com.acts.actsinterfacemultiusersextensionthirdtest',
abilityName: 'com.acts.actsinterfacemultiusersextensionthirdtest.ServiceAbility2'
}).then(()=>{
console.debug("====>startAbility end====>");
})
break;
case 10:
this.context.startAbility(
{
bundleName: 'com.acts.error',
abilityName: 'com.acts.error.ServiceAbility2'
}).then(()=>{
console.debug("====>startAbility end====>");
})
var myStub5 = new Stub("com.acts.actsinterfacemultiusersextensionthirdtest.MainAbility");
console.log('ThirdAbility onConnect before return:')
return myStub5;
break;
case 11:
this.context.startAbility(
{
bundleName: 'com.acts.actsinterfacemultiusersextensionthirdtest',
abilityName: 'com.acts.actsinterfacemultiusersextensionthirdtest.ServiceAbility2'
}).then(()=>{
console.debug("====>startAbility end====>");
})
break;
case 12:
this.context.startAbility(
{
bundleName: 'com.acts.error',
abilityName: 'com.acts.error.ServiceAbility2'
},(err,data) => {
console.debug("====>err is====>" + JSON.stringify(err));
console.debug("====>startAbility end====>" );
})
var myStub6 = new Stub("com.acts.actsinterfacemultiusersextensionthirdtest.MainAbility");
console.log('ThirdAbility onConnect before return:')
return myStub6;
break;
default:
break;
}
return new rpc.RemoteObject('connect');
}
onDisconnect(want) {
console.log('ServiceAbility onDisconnect');
}
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.
*/
import ServiceExtensionAbility from '@ohos.application.ServiceExtensionAbility'
import commonEvent from "@ohos.commonEvent"
import Want from '@ohos.application.Want';
import rpc from "@ohos.rpc";
export default class ServiceAbility2 extends ServiceExtensionAbility {
onCreate(want:Want) {
console.log('ServiceAbility2 onCreate');
}
onDestory(){
console.log('ServiceAbility2 onDestory');
}
onRequest(want,startId) {
console.log('ServiceAbility2 onRequest');
commonEvent.publish("ACTS_InterfaceMultiUsersExtension_CommonEvent", () => {
console.log("publish Publish ACTS_InterfaceMultiUsersExtension_CommonEvent callback")
this.context.terminateSelf().then(() => {
commonEvent.publish("ACTS_TerminateSelf_CommonEvent", ()=>{
console.log('terminateSelf promise');
});
});
})
}
onConnect(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
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import TestRunner from '@ohos.application.testRunner'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
var abilityDelegator = undefined
var abilityDelegatorArguments = undefined
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s it',
'-s level', '-s testType', '-s size', '-s timeout',
'-s dryRun'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams = `${targetParams} ${key} ${parameters[key]}`
}
}
return targetParams.trim()
}
async function onAbilityCreateCallback() {
console.log("onAbilityCreateCallback");
}
async function addAbilityMonitorCallback(err: any) {
console.info("addAbilityMonitorCallback : " + JSON.stringify(err))
}
export default class OpenHarmonyTestRunner implements TestRunner {
constructor() {
}
onPrepare() {
console.info("OpenHarmonyTestRunner OnPrepare ")
}
async onRun() {
console.log('OpenHarmonyTestRunner onRun run')
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility'
let lMonitor = {
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
var cmd = 'aa start -d 0 -a com.acts.actsinterfacemultiusersextensionthirdtest.MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters)
var debug = abilityDelegatorArguments.parameters["-D"]
if (debug == 'true')
{
cmd += ' -D'
}
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd,
(err: any, d: any) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + d.stdResult);
console.info('executeShellCommand : data : ' + d.exitCode);
})
console.info('OpenHarmonyTestRunner onRun end')
}
};
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import abilityTest from './Ability.test.ets'
export default function testsuite() {
console.debug("====>in list.test====>");
abilityTest()
}
\ 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.acts.actsinterfacemultiusersextensionthirdtest.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.acts.actsinterfacemultiusersextensionthirdtest.MainAbility2",
"srcEntrance": "./ets/MainAbility2/MainAbility2.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait"
}
],
"extensionAbilities": [
{
"srcEntrance": "./ets/ServiceAbility/ServiceAbility.ts",
"name": "com.acts.actsinterfacemultiusersextensionthirdtest.ServiceAbility",
"icon": "$media:icon",
"srcLanguage": "ets",
"description": "$string:phone_entry_main",
"type": "service",
"visible": true
},
{
"srcEntrance": "./ets/ServiceAbility2/ServiceAbility2.ts",
"name": "com.acts.actsinterfacemultiusersextensionthirdtest.ServiceAbility2",
"icon": "$media:icon",
"srcLanguage": "ets",
"description": "$string:phone_entry_main",
"type": "service",
"visible": true
}
]
}
}
{
"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"
}
]
}
{
"src": [
"MainAbility/pages/index/index",
"MainAbility/pages/second/second"
]
}
\ No newline at end of file
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
"bundle-name": "com.acts.actsinterfacemultiuserstest", "bundle-name": "com.acts.actsinterfacemultiuserstest",
"module-name":"phone", "module-name":"phone",
"shell-timeout": "300000", "shell-timeout": "300000",
"testcase-timeout": 300000 "testcase-timeout": "30000"
}, },
"kits": [ "kits": [
{ {
......
{
"app":{
"bundleName":"com.acts.actsinterfacemultiusersthirdtest",
"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
}
}
}
{
"string":[
{
"name":"app_name",
"value":"ohosProject"
}
]
}
\ 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("ActsAmsUsersThirdTest") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":actsamsusersthirdtest_js_assets",
":actsamsusersthirdtest_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx_thirdparty.p7b"
hap_name = "ActsAmsUsersThirdTest"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("actsamsusersthirdtest_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("actsamsusersthirdtest_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("actsamsusersthirdtest_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":actsamsusersthirdtest_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "300000",
"bundle-name": "com.acts.actsinterfacemultiusersthirdtest",
"module-name":"phone",
"shell-timeout": "300000",
"testcase-timeout": "30000"
},
"kits": [
{
"type": "ShellKit",
"run-command": [
"acm create -n user101 -t normal",
"acm switch -i 101"
],
"teardown-command":[
"acm switch -i 100",
"acm delete -i 101"
]
},
{
"test-file-name": [
"ActsAmsUsersThirdTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
\ 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 AbilityStage from "@ohos.application.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("MyAbilityStage onCreate")
globalThis.stageOnCreateRun = 1;
globalThis.stageContext = this.context;
}
}
/*
* 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) {
console.log("MainAbility onCreate")
globalThis.abilityWant = want;
}
onDestroy() {
console.log("MainAbility onDestroy")
}
onWindowStageCreate(windowStage) {
console.log("MainAbility onWindowStageCreate")
globalThis.abilityContext = this.context
windowStage.setUIContent(this.context, "MainAbility/pages/index/index", null)
}
onWindowStageDestroy() {
console.log("MainAbility onWindowStageDestroy")
}
onForeground() {
console.log("MainAbility onForeground")
}
onBackground() {
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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../../../test/List.test'
import router from '@ohos.router'
@Entry
@Component
struct Index {
aboutToAppear() {
console.info("start run testcase!!!!")
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
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 Ability from '@ohos.application.Ability'
import commonEvent from '@ohos.commonEvent'
function PublishCallBackOne() {
console.debug("====>Publish CallBack ACTS_StartAbility_0100_CommonEvent====>");
globalThis.abilityContext2.terminateSelf();
console.debug("====>terminateSelf succese====>")
commonEvent.publish("ACTS_TerminateSelf_CommonEvent", ()=>{
console.debug("====>publish ACTS_TerminateSelf_CommonEvent====>")
});
}
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
console.log("MainAbility2 onCreate")
}
onDestroy() {
console.log("MainAbility2 onDestroy")
}
onWindowStageCreate(windowStage) {
console.log("MainAbility2 onWindowStageCreate")
globalThis.abilityContext2 = this.context
commonEvent.publish("ACTS_InterfaceMultiUsers_0100_Start_CommonEvent", PublishCallBackOne);
}
onWindowStageDestroy() {
console.log("MainAbility onWindowStageDestroy")
}
onForeground() {
console.log("MainAbility onForeground")
}
onBackground() {
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'
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
console.log("MainAbility3 onCreate")
}
onDestroy() {
console.log("MainAbility3 onDestroy")
}
onWindowStageCreate(windowStage) {
console.log("MainAbility3 onWindowStageCreate")
globalThis.abilityContext3 = this.context
windowStage.setUIContent(this.context, "pages/index/second", null)
globalThis.abilityContext3.terminateSelfWithResult(
{
resultCode:1,
want:{
action:'ACTION'
}
},()=>{
console.debug("====>terminateSelfWithResult succese====>")
});
console.debug("====>terminateSelf end====>")
}
onWindowStageDestroy() {
console.log("MainAbility3 onWindowStageDestroy")
}
onForeground() {
console.log("MainAbility3 onForeground")
globalThis.abilityContext3.terminateSelfWithResult({
resultCode: 1
})
}
onBackground() {
console.log("MainAbility3 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'
export default class TestAbility extends Ability {
onCreate(want, launchParam) {
console.log('TestAbility onCreate')
}
onDestroy() {
console.log('TestAbility onDestroy')
}
onWindowStageCreate(windowStage) {
console.log('TestAbility onWindowStageCreate')
windowStage.loadContent("TestAbility/pages/index", (err, data) => {
if (err.code) {
console.error('Failed to load the content. Cause:' + JSON.stringify(err));
return;
}
console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data))
});
globalThis.abilityContext = this.context;
}
onWindowStageDestroy() {
console.log('TestAbility onWindowStageDestroy')
}
onForeground() {
console.log('TestAbility onForeground')
}
onBackground() {
console.log('TestAbility onBackground')
}
};
\ 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 router from '@ohos.router';
@Entry
@Component
struct Index {
aboutToAppear() {
console.info('TestAbility index aboutToAppear')
}
@State message: string = 'Hello World'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('next page')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width('35%')
.height('5%')
.onClick(()=>{
})
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import TestRunner from '@ohos.application.testRunner'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
var abilityDelegator = undefined
var abilityDelegatorArguments = undefined
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s it',
'-s level', '-s testType', '-s size', '-s timeout',
'-s dryRun'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams = `${targetParams} ${key} ${parameters[key]}`
}
}
return targetParams.trim()
}
async function onAbilityCreateCallback() {
console.log("onAbilityCreateCallback");
}
async function addAbilityMonitorCallback(err: any) {
console.info("addAbilityMonitorCallback : " + JSON.stringify(err))
}
export default class OpenHarmonyTestRunner implements TestRunner {
constructor() {
}
onPrepare() {
console.info("OpenHarmonyTestRunner OnPrepare ")
}
async onRun() {
console.log('OpenHarmonyTestRunner onRun run')
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility'
let lMonitor = {
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
var cmd = 'aa start -d 0 -a com.acts.actsinterfacemultiusersthirdtest.MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters)
var debug = abilityDelegatorArguments.parameters["-D"]
if (debug == 'true')
{
cmd += ' -D'
}
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd,
(err: any, d: any) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + d.stdResult);
console.info('executeShellCommand : data : ' + d.exitCode);
})
console.info('OpenHarmonyTestRunner onRun end')
}
};
\ No newline at end of file
{
"src": [
"MainAbility/pages/index/index",
"MainAbility/pages/second/second"
]
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册