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

!6964 XTS签名文件修改

Merge pull request !6964 from chengxingzhen/master
......@@ -54,8 +54,6 @@ group("ability_runtime") {
"stage:stage",
"want:want",
"workercontextcover:workercontextcover",
#"zidltest:zidltest",
]
}
}
......@@ -18,8 +18,8 @@
"mainAbility": ".MainAbility",
"srcPath": "",
"deviceType": [
"default",
"tablet"
"default",
"tablet"
],
"distro": {
"deliveryWithInstall": true,
......
{
"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.app.ability.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.app.ability.UIAbility'
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.app.ability.UIAbility'
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": [
"default",
"tablet"
],
"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"
},
{
"name":"ohos.permission.START_ABILITIES_FROM_BACKGROUND",
"reason":"need use ohos.permission.START_ABILITIES_FROM_BACKGROUND"
},
{
"name":"ohos.permission.START_INVISIBLE_ABILITY",
"reason":"need use ohos.permission.START_INVISIBLE_ABILITY"
}
]
}
}
{
"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.app.ability.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.app.ability.UIAbility'
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.app.ability.UIAbility'
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 Ability from '@ohos.app.ability.UIAbility'
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.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": [
"default",
"tablet"
],
"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
}
],
"requestPermissions": [
{
"name":"ohos.permission.START_ABILITIES_FROM_BACKGROUND",
"reason":"need use ohos.permission.START_ABILITIES_FROM_BACKGROUND"
},
{
"name":"ohos.permission.START_INVISIBLE_ABILITY",
"reason":"need use ohos.permission.START_INVISIBLE_ABILITY"
}
]
}
}
{
"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,8 +6,8 @@
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
"default",
"tablet"
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
......
......@@ -6,8 +6,8 @@
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
"default",
"tablet"
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
......
/*
* 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 ServiceAbility extends ServiceExtensionAbility {
onCreate(want) {
console.log('ServiceAbility onCreate');
}
onDestory(){
console.log('ServiceAbility onDestory');
}
onRequest(want,startId) {
console.log('ServiceAbility onRequest');
commonEvent.publish("ACTS_InterfaceMultiUsers_0100_Start_CommonEvent", () => {
console.log(" Publish ACTS_InterfaceMultiUsersExtension_CommonEvent callback")
this.context.terminateSelf().then(()=>{
console.log(" terminateSelf callback")
})
})
}
onConnect(want) {
console.log('ServiceAbility onConnect');
return new rpc.RemoteObject('connect');
}
onDisconnect(want) {
console.log('ServiceAbility onDisconnect');
}
onDestroy() {
console.log('ServiceAbility onDestroy');
}
}
\ No newline at end of file
......@@ -52,17 +52,6 @@
"orientation": "portrait"
}
],
"extensionAbilities": [
{
"srcEntrance": "./ets/ServiceAbility/ServiceAbility.ts",
"name": "com.acts.actsinterfacemultiuserstest.ServiceAbility",
"icon": "$media:icon",
"srcLanguage": "ets",
"description": "$string:phone_entry_main",
"type": "service",
"visible": true
}
],
"defPermissions": [
{
"availableScope": [],
......@@ -76,54 +65,22 @@
}
],
"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"
},
{
"name":"ohos.permission.START_ABILITIES_FROM_BACKGROUND",
"reason":"need use ohos.permission.START_ABILITIES_FROM_BACKGROUND"
},
{
"name":"ohos.permission.START_INVISIBLE_ABILITY",
"reason":"need use ohos.permission.START_INVISIBLE_ABILITY"
}
{
"name": "ohos.permission.CLEAN_BACKGROUND_PROCESSES",
"reason": "need use ohos.permission.CLEAN_BACKGROUND_PROCESSES"
},
{
"name": "ohos.permission.GET_BUNDLE_INFO",
"reason": "need use ohos.permission.GET_BUNDLE_INFO"
},
{
"name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
"reason": "need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
},
{
"name": "ohos.permission.GET_RUNNING_INFO",
"reason": "need use ohos.permission.GET_RUNNING_INFO"
}
]
}
}
......@@ -18,15 +18,11 @@ group("actsusers") {
if (is_standard_system) {
deps = [
"ActsAmsUsersApi7AppA:ActsAmsUsersApi7AppA",
"ActsAmsUsersExtensionSystemTest:ActsAmsUsersExtensionSystemTest",
"ActsAmsUsersExtensionThirdTest:ActsAmsUsersExtensionThirdTest",
"ActsAmsUsersKillProcessAppA:ActsAmsUsersKillProcessAppA",
"ActsAmsUsersKillProcessAppB:ActsAmsUsersKillProcessAppB",
"ActsAmsUsersKillProcessAppC:ActsAmsUsersKillProcessAppC",
"ActsAmsUsersSystemTest:ActsAmsUsersSystemTest",
"ActsAmsUsersThirdTest:ActsAmsUsersThirdTest",
"actsconnectabilitysystemabilitytest:ActsConnectAbilitySystemAbilityTest",
"actsmanyuserthirdabilitytest:ActsManyUsersAbilityTest",
]
}
}
{
"app": {
"bundleName": "com.example.actsconnectabilitysystemabilitytest",
"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("ActsConnectAbilitySystemAbilityTest") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":actsconnectabilitysystemabilitytest_js_assets",
":actsconnectabilitysystemabilitytest_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsConnectAbilitySystemAbilityTest"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("actsconnectabilitysystemabilitytest_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("actsconnectabilitysystemabilitytest_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("actsconnectabilitysystemabilitytest_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":actsconnectabilitysystemabilitytest_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "300000",
"bundle-name": "com.example.actsconnectabilitysystemabilitytest",
"module-name":"phone",
"shell-timeout": "300000",
"testcase-timeout": "30000"
},
"kits": [
{
"type": "ShellKit",
"run-command": [
"acm create -n 101 -t normal",
"acm switch -i 101"
],
"teardown-command":[
"acm switch -i 101",
"acm delete -i 101"
]
},
{
"test-file-name": [
"ActsConnectAbilitySystemAbilityTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
/*
* 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.app.ability.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.app.ability.UIAbility'
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, "MainAbility/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")
}
};
\ 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 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) 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 commonEvent from '@ohos.commonEvent'
import ServiceExtension from '@ohos.application.ServiceExtensionAbility'
import rpc from '@ohos.rpc';
var conn = -1;
function publishCallBackOne() {
console.log("========Publish CallBack AMS_ConnectAbility_0100_commonEvent========");
}
function publishCallBackTwo() {
console.log("========Publish CallBack AMS_ConnectAbility_0200_commonEvent========");
}
function publishCallBackThree() {
console.log("========Publish CallBack AMS_ConnectAbility_0300_commonEvent========");
}
function publishCallBackFour() {
console.log("========Publish CallBack AMS_ConnectAbility_0400_commonEvent========");
}
function publishCallBackFive() {
console.log("========Publish CallBack AMS_ConnectAbility_0500_commonEvent========");
}
function publishCallBackSix() {
console.log("========Publish CallBack AMS_ConnectAbility_0600_commonEvent========");
}
function publishCallBackzero() {
console.log("========Publish CallBack AMSc_disonnectAbility_0100_commonEvent========");
}
function publishCallBackttwo() {
console.log("========Publish CallBack AMSc_disonnectAbility_0200_commonEvent========");
}
function onConnectCallback(element, remote) {
console.log('onConnectCallback====> element=' + JSON.stringify(element));
console.log('onConnectCallback====> remote=' + JSON.stringify(remote));
}
function onDisconnectCallback(element) {
console.log('onDisconnectCallback====> element=' + JSON.stringify(element));
}
function onFailedCallback(code) {
console.log('onFailedCallback====> code=' + JSON.stringify(code))
}
export default class ServiceAbility extends ServiceExtension {
onCreate(want) {
console.log('ServiceAbility onCreate, want: ' + want.abilityName);
}
onRequest(want, startId) {
console.log('ServiceAbility onRequest, want: ' + want.abilityName + ', startId: ' + startId);
console.log('ServiceAbility registerApplicationStateObserver begin');
console.log('ServiceAbility registerApplicationStateObserver end, conn: ' + conn);
}
onConnect(want) {
console.log('ServiceAbility onConnect, want:' + want.abilityName);
let extensionContext = this.context
if (want.action == "one") {
commonEvent.publish("AMS_ConnectAbility_0100_commonEvent", publishCallBackOne);
}
;
if (want.action == "two") {
commonEvent.publish("AMS_ConnectAbility_0200_commonEvent", publishCallBackTwo);
}
;
if (want.action == "Three") {
commonEvent.publish("AMS_ConnectAbility_0300_commonEvent", publishCallBackThree);
}
;
if (want.action == "Four") {
commonEvent.publish("AMS_ConnectAbility_0400_commonEvent", publishCallBackFour);
}
;
if (want.action == "Five") {
commonEvent.publish("AMS_ConnectAbility_0500_commonEvent", publishCallBackFive);
}
;
if (want.action == "Six") {
commonEvent.publish("AMS_ConnectAbility_0600_commonEvent", publishCallBackSix);
}
;
if (want.action == "Seven") {
extensionContext.connectAbility(
{
bundleName: "com.example.actsconnectabilitysystemabilitytest",
abilityName: "com.example.actsconnectabilitysystemabilitytest.ServiceAbility2",
}, {
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback
}
);
};
if (want.action == "Eight") {
extensionContext.connectAbility(
{
bundleName: "com.example.actsconnectabilitysystemabilitytest",
abilityName: "com.example.actsconnectabilitysystemabilitytest.ServiceAbility3",
}, {
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback
}
);
};
if (want.action == "Nine") {
console.log('connectAbility 111');
let num = extensionContext.connectAbility(
{
bundleName: 'com.example.actsconnectabilitysystemabilitytest',
abilityName: 'com.example.actsconnectabilitysystemabilitytest.ServiceAbility2'
}, {
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback
})
setTimeout(() => {
extensionContext.disconnectAbility(num).then(() => {
console.log('in disconnectAbility');
})
}, 1000)
};
if (want.action == "Ten") {
console.log('connectAbility 222');
let num = extensionContext.connectAbility(
{
bundleName: 'com.example.actsconnectabilitysystemabilitytest',
abilityName: 'com.example.actsconnectabilitysystemabilitytest.ServiceAbility2'
}, {
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback
})
setTimeout(() => {
extensionContext.disconnectAbility(num).then(() => {
console.log('in disconnectAbility2');
})
}, 1000)
};
if (want.action == "Ten one") {
console.log('connectAbility 333');
let num = extensionContext.connectAbility(
{
bundleName: 'com.example.actsconnectabilitysystemabilitytest',
abilityName: 'com.example.actsconnectabilitysystemabilitytest.ServiceAbility2'
}, {
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback
})
setTimeout(() => {
extensionContext.disconnectAbility(2222).then(() => {
console.log('in disconnectAbility3');
})
}, 1000)
};
if (want.action == "Ten two") {
console.log('connectAbility 444');
let num = extensionContext.connectAbility(
{
bundleName: 'com.example.actsconnectabilitysystemabilitytest',
abilityName: 'com.example.actsconnectabilitysystemabilitytest.ServiceAbility2'
}, {
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback
})
setTimeout(() => {
extensionContext.disconnectAbility(2222).then(() => {
console.log('in disconnectAbility4');
})
}, 1000)
};
return new rpc.RemoteObject('connect');
}
onDisconnect(want) {
console.log('ServiceAbility onDisconnect, want:' + want.abilityName);
commonEvent.publish("AMSc_disonnectAbility_0100_commonEvent", publishCallBackzero);
commonEvent.publish("AMSc_disonnectAbility_0200_commonEvent", publishCallBackttwo);
}
onDestroy() {
console.log('ServiceAbility onDestroy');
}
}
/*
* 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) 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 ServiceExtension from '@ohos.application.ServiceExtensionAbility'
import commonEvent from "@ohos.commonEvent"
import rpc from '@ohos.rpc';
export default class ServiceAbility2 extends ServiceExtension {
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');
commonEvent.publish("AMS_ConnectAbility_0700_commonEvent", () => {
console.log("publish Publish AMS_ConnectAbility_0700_commonEvent callback");
})
commonEvent.publish("AMS_ConnectAbility_0900_commonEvent", () => {
console.log("publish Publish AMS_ConnectAbility_0900_commonEvent callback");
})
commonEvent.publish("AMS_ConnectAbility_1000_commonEvent", () => {
console.log("publish Publish AMS_ConnectAbility_1000_commonEvent callback");
})
commonEvent.publish("AMS_ConnectAbility_1100_commonEvent", () => {
console.log("publish Publish AMS_ConnectAbility_1100_commonEvent callback");
})
commonEvent.publish("AMS_ConnectAbility_1200_commonEvent", () => {
console.log("publish Publish AMS_ConnectAbility_1200_commonEvent callback");
})
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('ServiceAbility2 onStart');
},
onStop() {
console.info('ServiceAbility2 onStop');
},
onCommand(want, startId) {
console.info('ServiceAbility2 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 Ability from '@ohos.app.ability.UIAbility'
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.example.actsconnectabilitysystemabilitytest.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 './manyusersabilitytest.test.ets'
export default function testsuite() {
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": [
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"abilities": [
{
"name": "com.example.actsconnectabilitysystemabilitytest.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"
]
}
]
}
],
"extensionAbilities": [
{
"srcEntrance": "./ets/ServiceAbility/ServiceAbility.ts",
"name": "com.example.actsconnectabilitysystemabilitytest.ServiceAbility",
"icon": "$media:icon",
"srcLanguage": "ets",
"description": "$string:phone_entry_main",
"type": "service",
"visible": true
},
{
"srcEntrance": "./ets/ServiceAbility2/ServiceAbility2.ts",
"name": "com.example.actsconnectabilitysystemabilitytest.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.REMOVE_CACHE_FILES",
"reason":"need use ohos.permission.REMOVE_CACHE_FILES"
},
{
"name": "ohos.permission.MANAGE_LOCAL_ACCOUNTS",
"reason": "ceshi"
},
{
"name": "ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION",
"reason": "ceshi"
},
{
"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
{
"src": [
"MainAbility/pages/index/index",
"MainAbility/pages/second/second"
]
}
\ No newline at end of file
{
"app": {
"bundleName": "com.example.actsmanyusersabilitytest",
"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("ActsManyUsersAbilityTest") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":actsmanyusersabilitytest_js_assets",
":actsmanyusersabilitytest_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsManyUsersAbilityTest"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("actsmanyusersabilitytest_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("actsmanyusersabilitytest_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("actsmanyusersabilitytest_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":actsmanyusersabilitytest_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "300000",
"bundle-name": "com.example.actsmanyusersabilitytest",
"module-name":"phone",
"shell-timeout": "300000",
"testcase-timeout": "30000"
},
"kits": [
{
"type": "ShellKit",
"run-command": [
"acm create -n 101 -t normal",
"acm switch -i 101"
],
"teardown-command":[
"acm delete -i 101"
]
},
{
"test-file-name": [
"ActsManyUsersAbilityTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
/*
* 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.app.ability.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.app.ability.UIAbility'
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, "MainAbility/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 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
{
"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.
先完成此消息的编辑!
想要评论请 注册