提交 5e62a8e0 编写于 作者: X xuchenghua09

update

Signed-off-by: Nxuchenghua09 <xuchenghua09@huawei.com>
上级 c275cd86
......@@ -14,7 +14,7 @@
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsAmsUsersExtensionSystemTest") {
hap_profile = "entry/src/main/module.json"
hap_profile = "./entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":actsamsusersextensionsystemtest_js_assets",
......@@ -23,6 +23,8 @@ ohos_js_hap_suite("ActsAmsUsersExtensionSystemTest") {
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsAmsUsersExtensionSystemTest"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("actsamsusersextensionsystemtest_app_profile") {
......@@ -31,11 +33,11 @@ ohos_app_scope("actsamsusersextensionsystemtest_app_profile") {
}
ohos_js_assets("actsamsusersextensionsystemtest_js_assets") {
source_dir = "entry/src/main/ets"
source_dir = "./entry/src/main/ets"
}
ohos_resources("actsamsusersextensionsystemtest_resources") {
sources = [ "entry/src/main/resources" ]
sources = [ "./entry/src/main/resources" ]
deps = [ ":actsamsusersextensionsystemtest_app_profile" ]
hap_profile = "entry/src/main/module.json"
hap_profile = "./entry/src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"type": "OHJSUnitTest",
"test-timeout": "300000",
"package": "com.acts.actsinterfacemultiusersextensiontest",
"shell-timeout": "300000"
"bundle-name": "com.acts.actsinterfacemultiusersextensiontest",
"module-name":"phone",
"shell-timeout": "300000",
"testcase-timeout": "30000"
},
"kits": [
{
......@@ -12,6 +14,10 @@
"run-command": [
"acm create -n user101 -t normal",
"acm switch -i 101"
],
"teardown-command": [
"acm switch -i 100",
"acm delete -i 101"
]
},
{
......
......@@ -4,7 +4,7 @@
* 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
* 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,
......@@ -13,38 +13,42 @@
* 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){
// Ability is creating, initialize resources for this ability
console.log("MainAbility onCreate")
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() {
// Ability is destroying, release resources for this ability
console.log("MainAbility onDestroy")
console.log('MainAbility onDestroy')
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("MainAbility onWindowStageCreate")
globalThis.abilityContext = this.context
windowStage.setUIContent(this.context, "pages/index/index", null)
console.log('MainAbility onWindowStageCreate')
windowStage.setUIContent(this.context, 'MainAbility/pages/index/index', null)
}
onWindowStageDestroy() {
//Main window is destroyed, release UI related resources
console.log("MainAbility onWindowStageDestroy")
console.log('MainAbility onWindowStageDestroy')
}
onForeground() {
// Ability has brought to foreground
console.log("MainAbility onForeground")
console.log('MainAbility onForeground')
}
onBackground() {
// Ability has back to background
console.log("MainAbility 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
......@@ -19,7 +19,7 @@ export default class MainAbility2 extends Ability {
onCreate(want, launchParam) {
console.log("MainAbility2 onCreate");
globalThis.abilityContext = this.context
globalThis.abilityContext2 = this.context
}
onDestroy() {
......@@ -28,10 +28,10 @@ export default class MainAbility2 extends Ability {
onWindowStageCreate(windowStage) {
console.log("MainAbility2 onWindowStageCreate");
windowStage.setUIContent(this.context, "pages/index/second", null);
windowStage.setUIContent(this.context, "MainAbility/pages/index/second", null);
commonEvent.publish("ACTS_InterfaceMultiUsersExtension_CommonEvent", () => {
console.log("publish Publish ACTS_InterfaceMultiUsersExtension_CommonEvent callback")
globalThis.abilityContext.terminateSelf().then(() => {
globalThis.abilityContext2.terminateSelf().then(() => {
commonEvent.publish("ACTS_TerminateSelf_CommonEvent", ()=>{
console.log('terminateSelf promise');
});
......
......@@ -79,6 +79,8 @@ export default class ServiceAbility extends ServiceExtensionAbility {
},{
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");
......@@ -92,7 +94,9 @@ export default class ServiceAbility extends ServiceExtensionAbility {
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");
......@@ -126,8 +130,10 @@ export default class ServiceAbility extends ServiceExtensionAbility {
{
bundleName: 'com.acts.actsinterfacemultiusersextensiontest',
abilityName: 'com.acts.actsinterfacemultiusersextensiontest.ServiceAbility2'
},() => {
console.debug("====>startAbility end====>" );
},(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:')
......@@ -138,8 +144,10 @@ export default class ServiceAbility extends ServiceExtensionAbility {
{
bundleName: 'com.acts.error',
abilityName: 'com.acts.error.ServiceAbility2'
},() => {
console.debug("====>startAbility end====>" );
},(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:')
......@@ -186,8 +194,10 @@ export default class ServiceAbility extends ServiceExtensionAbility {
{
bundleName: 'com.acts.error',
abilityName: 'com.acts.error.ServiceAbility2'
},() => {
console.debug("====>startAbility end====>" );
},(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:')
......@@ -210,8 +220,10 @@ export default class ServiceAbility extends ServiceExtensionAbility {
{
bundleName: 'com.example.userservicesystemapi7',
abilityName: 'com.example.userservicesystemapi7.ServiceAbility'
},() => {
console.debug("====>startAbility end====>" );
},(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:')
......
/*
* 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
......@@ -14,7 +14,7 @@
*/
import abilityTest from './Ability.test.ets'
export default function testsuite(context) {
export default function testsuite() {
console.debug("====>in list.test====>");
abilityTest(context)
abilityTest()
}
\ No newline at end of file
{
"src": [
"pages/index/index",
"pages/second/second"
"MainAbility/pages/index/index",
"MainAbility/pages/second/second"
]
}
\ No newline at end of file
......@@ -22,6 +22,8 @@ ohos_js_hap_suite("ActsAmsUsersExtensionThirdTest") {
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsAmsUsersExtensionThirdTest"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("actsamsusersextensionthirdtest_app_profile") {
......
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"type": "OHJSUnitTest",
"test-timeout": "300000",
"package": "com.acts.actsinterfacemultiusersextensionthirdtest",
"shell-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"
......
......@@ -13,39 +13,42 @@
* 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)
}
onCreate(want, launchParam) {
// Ability is creating, initialize resources for this ability
console.log("MainAbility onCreate");
globalThis.abilityWant = want;
globalThis.abilityContext = this.context
}
onDestroy() {
console.log('MainAbility onDestroy')
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("MainAbility onDestroy");
}
onWindowStageCreate(windowStage) {
console.log('MainAbility onWindowStageCreate')
windowStage.setUIContent(this.context, 'MainAbility/pages/index/index', null)
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("MainAbility onWindowStageCreate");
windowStage.setUIContent(this.context, "pages/index/index", null);
}
onWindowStageDestroy() {
console.log('MainAbility onWindowStageDestroy')
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("MainAbility onWindowStageDestroy");
}
onForeground() {
console.log('MainAbility onForeground')
}
onForeground() {
// Ability has brought to foreground
console.log("MainAbility onForeground");
}
onBackground() {
// Ability has back to background
console.log("MainAbility onBackground");
}
};
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
......@@ -19,7 +19,7 @@ export default class MainAbility2 extends Ability {
onCreate(want, launchParam) {
console.log("MainAbility2 onCreate");
globalThis.abilityContext = this.context
globalThis.abilityContext2 = this.context
}
onDestroy() {
......@@ -28,10 +28,10 @@ export default class MainAbility2 extends Ability {
onWindowStageCreate(windowStage) {
console.log("MainAbility2 onWindowStageCreate");
windowStage.setUIContent(this.context, "pages/index/second", null);
windowStage.setUIContent(this.context, "MainAbility/pages/index/second", null);
commonEvent.publish("ACTS_InterfaceMultiUsersExtension_CommonEvent", () => {
console.log("publish Publish ACTS_InterfaceMultiUsersExtension_CommonEvent callback")
globalThis.abilityContext.terminateSelf().then(() => {
globalThis.abilityContext2.terminateSelf().then(() => {
commonEvent.publish("ACTS_TerminateSelf_CommonEvent", ()=>{
console.log('terminateSelf promise');
});
......
......@@ -76,7 +76,8 @@ export default class ServiceAbility extends ServiceExtensionAbility {
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");
......@@ -90,7 +91,8 @@ export default class ServiceAbility extends ServiceExtensionAbility {
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");
......@@ -124,9 +126,10 @@ export default class ServiceAbility extends ServiceExtensionAbility {
{
bundleName: 'com.acts.actsinterfacemultiusersextensionthirdtest',
abilityName: 'com.acts.actsinterfacemultiusersextensionthirdtest.ServiceAbility2'
},() => {
console.debug("====>startAbility end====>" );
})
},(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;
......@@ -136,9 +139,10 @@ export default class ServiceAbility extends ServiceExtensionAbility {
{
bundleName: 'com.acts.error',
abilityName: 'com.acts.error.ServiceAbility2'
},() => {
console.debug("====>startAbility end====>" );
})
},(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;
......@@ -178,9 +182,10 @@ export default class ServiceAbility extends ServiceExtensionAbility {
{
bundleName: 'com.acts.error',
abilityName: 'com.acts.error.ServiceAbility2'
},() => {
console.debug("====>startAbility end====>" );
})
},(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;
......
/*
* 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.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
......@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index"
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "@ohos/hypium"
import commonEvent from '@ohos.commonEvent'
import osaccount from '@ohos.account.osAccount'
......@@ -26,20 +26,11 @@ var osAccountManager
const START_ABILITY_TIMEOUT = 6000;
globalThis.number = 0;
console.debug("====>in Ability.test====>");
export default function abilityTest(abilityContext) {
export default function abilityTest() {
console.debug("====>in function abilityTest====>");
describe('ActsInterfaceMultiUsersExtensionThirdTest', function () {
afterAll(function() {
osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
osAccountManager.activateOsAccount(100, (err)=>{
console.debug("====>activateOsAccount localId: 100 err:" + JSON.stringify(err));
osAccountManager.removeOsAccount(101, (err)=>{
console.debug("====>remove localId: 101" + " err:" + JSON.stringify(err));
})
})
})
console.debug("====>in ACTS_InterfaceMultiUsers====>");
/*
* @tc.number : ACTS_ThirdPartyExtensionStartAbility_0100
* @tc.name : start new ability
......@@ -57,7 +48,7 @@ export default function abilityTest(abilityContext) {
if(data.event == "ACTS_InterfaceMultiUsersExtension_CommonEvent"){
startresult = true
}
abilityContext.disconnectAbility(globalThis.number).then((data)=>{
globalThis.abilityContext.disconnectAbility(globalThis.number).then((data)=>{
console.debug("====>data is====>" + JSON.stringify(data));
})
console.log('====>disconnectAbility finish');
......@@ -70,7 +61,7 @@ export default function abilityTest(abilityContext) {
Subscriber = data;
commonEvent.subscribe(Subscriber, SubscribeCallBack);
console.debug("====>0100start connectAbility====>");
globalThis.number = await abilityContext.connectAbility(
globalThis.number = await globalThis.abilityContext.connectAbility(
{
bundleName: 'com.acts.actsinterfacemultiusersextensionthirdtest',
abilityName: 'com.acts.actsinterfacemultiusersextensionthirdtest.ServiceAbility'
......@@ -124,7 +115,7 @@ export default function abilityTest(abilityContext) {
console.debug("====>UnSubscribeCallback====>");
flag = false
expect(startresult).assertEqual(false);
abilityContext.disconnectAbility(globalThis.number).then((data)=>{
globalThis.abilityContext.disconnectAbility(globalThis.number).then((data)=>{
console.debug("====>data is====>" + JSON.stringify(data));
})
console.log('====>disconnectAbility finish');
......@@ -158,7 +149,7 @@ export default function abilityTest(abilityContext) {
Subscriber = data;
commonEvent.subscribe(Subscriber, SubscribeCallBack);
console.debug("====>0200start connectAbility====>");
globalThis.number = await abilityContext.connectAbility(
globalThis.number = await globalThis.abilityContext.connectAbility(
{
bundleName: 'com.acts.actsinterfacemultiusersextensionthirdtest',
abilityName: 'com.acts.actsinterfacemultiusersextensionthirdtest.ServiceAbility'
......@@ -189,7 +180,7 @@ export default function abilityTest(abilityContext) {
if(data.event == "ACTS_InterfaceMultiUsersExtension_CommonEvent"){
startresult = true
}
abilityContext.disconnectAbility(globalThis.number).then((data)=>{
globalThis.abilityContext.disconnectAbility(globalThis.number).then((data)=>{
console.debug("====>data is====>" + JSON.stringify(data));
})
console.log('====>disconnectAbility finish');
......@@ -202,7 +193,7 @@ export default function abilityTest(abilityContext) {
Subscriber = data;
commonEvent.subscribe(Subscriber, SubscribeCallBack);
console.debug("====>0300start connectAbility====>");
globalThis.number = await abilityContext.connectAbility(
globalThis.number = await globalThis.abilityContext.connectAbility(
{
bundleName: 'com.acts.actsinterfacemultiusersextensionthirdtest',
abilityName: 'com.acts.actsinterfacemultiusersextensionthirdtest.ServiceAbility'
......@@ -256,7 +247,7 @@ export default function abilityTest(abilityContext) {
console.debug("====>UnSubscribeCallback====>");
flag = false
expect(startresult).assertEqual(false);
abilityContext.disconnectAbility(globalThis.number).then((data)=>{
globalThis.abilityContext.disconnectAbility(globalThis.number).then((data)=>{
console.debug("====>data is====>" + JSON.stringify(data));
})
console.log('====>disconnectAbility finish');
......@@ -290,7 +281,7 @@ export default function abilityTest(abilityContext) {
Subscriber = data;
commonEvent.subscribe(Subscriber, SubscribeCallBack);
console.debug("====>0400start connectAbility====>");
globalThis.number = await abilityContext.connectAbility(
globalThis.number = await globalThis.abilityContext.connectAbility(
{
bundleName: 'com.acts.actsinterfacemultiusersextensionthirdtest',
abilityName: 'com.acts.actsinterfacemultiusersextensionthirdtest.ServiceAbility'
......@@ -322,7 +313,7 @@ export default function abilityTest(abilityContext) {
if(data.event == "ACTS_InterfaceMultiUsersExtension_CommonEvent"){
startresult = true
}
abilityContext.disconnectAbility(globalThis.number).then((data)=>{
globalThis.abilityContext.disconnectAbility(globalThis.number).then((data)=>{
console.debug("====>data is====>" + JSON.stringify(data));
})
console.log('====>disconnectAbility finish');
......@@ -335,7 +326,7 @@ export default function abilityTest(abilityContext) {
Subscriber = data;
commonEvent.subscribe(Subscriber, SubscribeCallBack);
console.debug("====>0500start connectAbility====>");
globalThis.number = await abilityContext.connectAbility(
globalThis.number = await globalThis.abilityContext.connectAbility(
{
bundleName: 'com.acts.actsinterfacemultiusersextensionthirdtest',
abilityName: 'com.acts.actsinterfacemultiusersextensionthirdtest.ServiceAbility'
......@@ -389,7 +380,7 @@ export default function abilityTest(abilityContext) {
console.debug("====>UnSubscribeCallback====>");
flag = false
expect(startresult).assertEqual(false);
abilityContext.disconnectAbility(globalThis.number).then((data)=>{
globalThis.abilityContext.disconnectAbility(globalThis.number).then((data)=>{
console.debug("====>data is====>" + JSON.stringify(data));
})
console.log('====>disconnectAbility finish');
......@@ -423,7 +414,7 @@ export default function abilityTest(abilityContext) {
Subscriber = data;
commonEvent.subscribe(Subscriber, SubscribeCallBack);
console.debug("====>0600start connectAbility====>");
globalThis.number = await abilityContext.connectAbility(
globalThis.number = await globalThis.abilityContext.connectAbility(
{
bundleName: 'com.acts.actsinterfacemultiusersextensionthirdtest',
abilityName: 'com.acts.actsinterfacemultiusersextensionthirdtest.ServiceAbility'
......@@ -454,7 +445,7 @@ export default function abilityTest(abilityContext) {
if(data.event == "ACTS_InterfaceMultiUsersExtension_CommonEvent"){
startresult = true
}
abilityContext.disconnectAbility(globalThis.number).then((data)=>{
globalThis.abilityContext.disconnectAbility(globalThis.number).then((data)=>{
console.debug("====>data is====>" + JSON.stringify(data));
})
console.log('====>disconnectAbility finish');
......@@ -467,7 +458,7 @@ export default function abilityTest(abilityContext) {
Subscriber = data;
commonEvent.subscribe(Subscriber, SubscribeCallBack);
console.debug("====>0700start connectAbility====>");
globalThis.number = await abilityContext.connectAbility(
globalThis.number = await globalThis.abilityContext.connectAbility(
{
bundleName: 'com.acts.actsinterfacemultiusersextensionthirdtest',
abilityName: 'com.acts.actsinterfacemultiusersextensionthirdtest.ServiceAbility'
......@@ -522,7 +513,7 @@ export default function abilityTest(abilityContext) {
console.debug("====>UnSubscribeCallback====>");
flag = false
expect(startresult).assertEqual(false);
abilityContext.disconnectAbility(globalThis.number).then((data)=>{
globalThis.abilityContext.disconnectAbility(globalThis.number).then((data)=>{
console.debug("====>data is====>" + JSON.stringify(data));
})
console.log('====>disconnectAbility finish');
......@@ -556,7 +547,7 @@ export default function abilityTest(abilityContext) {
Subscriber = data;
commonEvent.subscribe(Subscriber, SubscribeCallBack);
console.debug("====>0800start connectAbility====>");
globalThis.number = await abilityContext.connectAbility(
globalThis.number = await globalThis.abilityContext.connectAbility(
{
bundleName: 'com.acts.actsinterfacemultiusersextensionthirdtest',
abilityName: 'com.acts.actsinterfacemultiusersextensionthirdtest.ServiceAbility'
......@@ -586,7 +577,7 @@ export default function abilityTest(abilityContext) {
if(data.event == "ACTS_TerminateSelf_CommonEvent"){
startresult = true
}
abilityContext.disconnectAbility(globalThis.number).then((data)=>{
globalThis.abilityContext.disconnectAbility(globalThis.number).then((data)=>{
console.debug("====>data is====>" + JSON.stringify(data));
})
console.log('====>disconnectAbility finish');
......@@ -599,7 +590,7 @@ export default function abilityTest(abilityContext) {
Subscriber = data;
commonEvent.subscribe(Subscriber, SubscribeCallBack);
console.debug("====>0100start connectAbility====>");
globalThis.number = await abilityContext.connectAbility(
globalThis.number = await globalThis.abilityContext.connectAbility(
{
bundleName: 'com.acts.actsinterfacemultiusersextensionthirdtest',
abilityName: 'com.acts.actsinterfacemultiusersextensionthirdtest.ServiceAbility'
......@@ -652,7 +643,7 @@ export default function abilityTest(abilityContext) {
console.debug("====>UnSubscribeCallback====>");
flag = false
expect(startresult).assertEqual(false);
abilityContext.disconnectAbility(globalThis.number).then((data)=>{
globalThis.abilityContext.disconnectAbility(globalThis.number).then((data)=>{
console.debug("====>data is====>" + JSON.stringify(data));
})
console.log('====>disconnectAbility finish');
......@@ -686,7 +677,7 @@ export default function abilityTest(abilityContext) {
Subscriber = data;
commonEvent.subscribe(Subscriber, SubscribeCallBack);
console.debug("====>0200start connectAbility====>");
globalThis.number = await abilityContext.connectAbility(
globalThis.number = await globalThis.abilityContext.connectAbility(
{
bundleName: 'com.acts.actsinterfacemultiusersextensionthirdtest',
abilityName: 'com.acts.actsinterfacemultiusersextensionthirdtest.ServiceAbility'
......@@ -717,7 +708,7 @@ export default function abilityTest(abilityContext) {
if(data.event == "ACTS_TerminateSelf_CommonEvent"){
startresult = true
}
abilityContext.disconnectAbility(globalThis.number).then((data)=>{
globalThis.abilityContext.disconnectAbility(globalThis.number).then((data)=>{
console.debug("====>data is====>" + JSON.stringify(data));
})
console.log('====>disconnectAbility finish');
......@@ -730,7 +721,7 @@ export default function abilityTest(abilityContext) {
Subscriber = data;
commonEvent.subscribe(Subscriber, SubscribeCallBack);
console.debug("====>0300start connectAbility====>");
globalThis.number = await abilityContext.connectAbility(
globalThis.number = await globalThis.abilityContext.connectAbility(
{
bundleName: 'com.acts.actsinterfacemultiusersextensionthirdtest',
abilityName: 'com.acts.actsinterfacemultiusersextensionthirdtest.ServiceAbility'
......@@ -784,7 +775,7 @@ export default function abilityTest(abilityContext) {
console.debug("====>UnSubscribeCallback====>");
flag = false
expect(startresult).assertEqual(false);
abilityContext.disconnectAbility(globalThis.number).then((data)=>{
globalThis.abilityContext.disconnectAbility(globalThis.number).then((data)=>{
console.debug("====>data is====>" + JSON.stringify(data));
})
console.log('====>disconnectAbility finish');
......@@ -820,7 +811,7 @@ export default function abilityTest(abilityContext) {
Subscriber = data;
commonEvent.subscribe(Subscriber, SubscribeCallBack);
console.debug("====>0400start connectAbility====>");
globalThis.number = await abilityContext.connectAbility(
globalThis.number = await globalThis.abilityContext.connectAbility(
{
bundleName: 'com.acts.actsinterfacemultiusersextensionthirdtest',
abilityName: 'com.acts.actsinterfacemultiusersextensionthirdtest.ServiceAbility'
......
......@@ -14,7 +14,7 @@
*/
import abilityTest from './Ability.test.ets'
export default function testsuite(context) {
export default function testsuite() {
console.debug("====>in list.test====>");
abilityTest(context)
abilityTest()
}
\ No newline at end of file
{
"src": [
"pages/index/index",
"pages/second/second"
"MainAbility/pages/index/index",
"MainAbility/pages/second/second"
]
}
\ No newline at end of file
......@@ -6,7 +6,7 @@
"bundle-name": "com.acts.actsinterfacemultiuserstest",
"module-name":"phone",
"shell-timeout": "300000",
"testcase-timeout": 300000
"testcase-timeout": "30000"
},
"kits": [
{
......
......@@ -23,6 +23,8 @@ ohos_js_hap_suite("ActsAmsUsersThirdTest") {
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") {
......
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"type": "OHJSUnitTest",
"test-timeout": "300000",
"package": "com.acts.actsinterfacemultiusersthirdtest",
"shell-timeout": "300000"
"bundle-name": "com.acts.actsinterfacemultiusersthirdtest",
"module-name":"phone",
"shell-timeout": "300000",
"testcase-timeout": "30000"
},
"kits": [
{
......@@ -14,6 +16,7 @@
"acm switch -i 101"
],
"teardown-command":[
"acm switch -i 100",
"acm delete -i 101"
]
},
......
......@@ -28,7 +28,7 @@ export default class MainAbility extends Ability {
onWindowStageCreate(windowStage) {
console.log("MainAbility onWindowStageCreate")
globalThis.abilityContext = this.context
windowStage.setUIContent(this.context, "pages/index/index", null)
windowStage.setUIContent(this.context, "MainAbility/pages/index/index", null)
}
onWindowStageDestroy() {
......
/*
* 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
......@@ -16,7 +16,7 @@ import Ability from '@ohos.application.Ability'
import commonEvent from '@ohos.commonEvent'
function PublishCallBackOne() {
console.debug("====>Publish CallBack ACTS_StartAbility_0100_CommonEvent====>");
globalThis.abilityContext.terminateSelf();
globalThis.abilityContext2.terminateSelf();
console.debug("====>terminateSelf succese====>")
commonEvent.publish("ACTS_TerminateSelf_CommonEvent", ()=>{
console.debug("====>publish ACTS_TerminateSelf_CommonEvent====>")
......@@ -34,7 +34,7 @@ export default class MainAbility extends Ability {
onWindowStageCreate(windowStage) {
console.log("MainAbility2 onWindowStageCreate")
globalThis.abilityContext = this.context
globalThis.abilityContext2 = this.context
commonEvent.publish("ACTS_InterfaceMultiUsers_0100_Start_CommonEvent", PublishCallBackOne);
}
......
......@@ -26,9 +26,9 @@ export default class MainAbility extends Ability {
onWindowStageCreate(windowStage) {
console.log("MainAbility3 onWindowStageCreate")
globalThis.abilityContext = this.context
globalThis.abilityContext3 = this.context
windowStage.setUIContent(this.context, "pages/index/second", null)
globalThis.abilityContext.terminateSelfWithResult(
globalThis.abilityContext3.terminateSelfWithResult(
{
resultCode:1,
want:{
......@@ -46,7 +46,7 @@ export default class MainAbility extends Ability {
onForeground() {
console.log("MainAbility3 onForeground")
globalThis.abilityContext.terminateSelfWithResult({
globalThis.abilityContext3.terminateSelfWithResult({
resultCode: 1
})
}
......
/*
* 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
......@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index"
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "@ohos/hypium"
import commonEvent from '@ohos.commonEvent'
import osaccount from '@ohos.account.osAccount'
......@@ -22,7 +22,7 @@ var subscriberInfo_MainAbility = {
var osAccountManager
const START_ABILITY_TIMEOUT = 6000;
console.debug("====>in Ability.test====>");
export default function abilityTest(abilityContext) {
export default function abilityTest() {
console.debug("====>in function abilityTest====>");
describe('ActsInterfaceMultiUsersThirdTest', function () {
......@@ -50,7 +50,7 @@ export default function abilityTest(abilityContext) {
Subscriber = data;
commonEvent.subscribe(Subscriber, SubscribeCallBack);
console.debug("====>start startAbility====>");
await abilityContext.startAbility(
await globalThis.abilityContext.startAbility(
{
bundleName: 'com.acts.actsinterfacemultiusersthirdtest',
abilityName: 'com.acts.actsinterfacemultiusersthirdtest.MainAbility2'
......@@ -101,7 +101,7 @@ export default function abilityTest(abilityContext) {
Subscriber = data;
commonEvent.subscribe(Subscriber, SubscribeCallBack);
console.debug("====>start startAbility====>");
await abilityContext.startAbility(
await globalThis.abilityContext.startAbility(
{
bundleName: 'com.acts.error',
abilityName: 'com.acts.error.MainAbility2'
......@@ -151,15 +151,16 @@ export default function abilityTest(abilityContext) {
Subscriber = data;
commonEvent.subscribe(Subscriber, SubscribeCallBack);
console.debug("====>start startAbility====>");
abilityContext.startAbility(
globalThis.abilityContext.startAbility(
{
bundleName: 'com.acts.actsinterfacemultiusersthirdtest',
abilityName: 'com.acts.actsinterfacemultiusersthirdtest.MainAbility2'
}, {
windowMode:0
},() => {
},(err,data) => {
console.debug("====>startAbility err:====>" + JSON.stringify(err));
console.debug("====>startAbility end====>" );
})
})
})
})
......@@ -203,7 +204,7 @@ export default function abilityTest(abilityContext) {
commonEvent.subscribe(Subscriber, SubscribeCallBack);
})
console.debug("====>start startAbility====>");
await abilityContext.startAbility(
await globalThis.abilityContext.startAbility(
{
bundleName: 'com.acts.error',
abilityName: 'com.acts.error.MainAbility2'
......@@ -252,7 +253,7 @@ export default function abilityTest(abilityContext) {
Subscriber = data;
commonEvent.subscribe(Subscriber, SubscribeCallBack);
console.debug("====>start startAbility====>");
await abilityContext.startAbility(
await globalThis.abilityContext.startAbility(
{
bundleName: 'com.acts.actsinterfacemultiusersthirdtest',
abilityName: 'com.acts.actsinterfacemultiusersthirdtest.MainAbility2'
......@@ -301,7 +302,7 @@ export default function abilityTest(abilityContext) {
Subscriber = data;
commonEvent.subscribe(Subscriber, SubscribeCallBack);
console.debug("====>start startAbility====>");
await abilityContext.startAbility(
await globalThis.abilityContext.startAbility(
{
bundleName: 'com.acts.error',
abilityName: 'com.acts.error.MainAbility2'
......@@ -349,12 +350,13 @@ export default function abilityTest(abilityContext) {
Subscriber = data;
commonEvent.subscribe(Subscriber, SubscribeCallBack);
console.debug("====>start startAbility====>");
abilityContext.startAbility(
globalThis.abilityContext.startAbility(
{
bundleName: 'com.acts.actsinterfacemultiusersthirdtest',
abilityName: 'com.acts.actsinterfacemultiusersthirdtest.MainAbility2'
},() => {
console.debug("====>startAbility end====>" );
},(err,data) => {
console.debug("====>startAbility err:====>" + JSON.stringify(err));
console.debug("====>startAbility end====>" );
})
})
})
......@@ -399,7 +401,7 @@ export default function abilityTest(abilityContext) {
commonEvent.subscribe(Subscriber, SubscribeCallBack);
})
console.debug("====>start startAbility====>");
await abilityContext.startAbility(
await globalThis.abilityContext.startAbility(
{
bundleName: 'com.acts.error',
abilityName: 'com.acts.error.MainAbility2'
......@@ -438,7 +440,7 @@ export default function abilityTest(abilityContext) {
}
setTimeout(timeout, START_ABILITY_TIMEOUT);
console.debug("====>start startAbilityForResult====>");
await abilityContext.startAbilityForResult(
await globalThis.abilityContext.startAbilityForResult(
{
bundleName: 'com.acts.actsinterfacemultiusersthirdtest',
abilityName: 'com.acts.actsinterfacemultiusersthirdtest.MainAbility3',
......@@ -466,7 +468,7 @@ export default function abilityTest(abilityContext) {
}
setTimeout(timeout, START_ABILITY_TIMEOUT);
console.debug("====>start startAbilityForResult====>");
await abilityContext.startAbilityForResult(
await globalThis.abilityContext.startAbilityForResult(
{
bundleName: 'com.acts.error',
abilityName: 'com.acts.error.MainAbility3',
......@@ -497,7 +499,7 @@ export default function abilityTest(abilityContext) {
}
setTimeout(timeout, START_ABILITY_TIMEOUT);
console.debug("====>start startAbilityForResult====>");
await abilityContext.startAbilityForResult(
await globalThis.abilityContext.startAbilityForResult(
{
bundleName: 'com.acts.actsinterfacemultiusersthirdtest',
abilityName: 'com.acts.actsinterfacemultiusersthirdtest.MainAbility3',
......@@ -524,7 +526,7 @@ export default function abilityTest(abilityContext) {
}
setTimeout(timeout, START_ABILITY_TIMEOUT);
console.debug("====>start startAbilityForResult====>");
await abilityContext.startAbilityForResult(
await globalThis.abilityContext.startAbilityForResult(
{
bundleName: 'com.acts.error',
abilityName: 'com.acts.error.MainAbility3',
......@@ -555,7 +557,7 @@ export default function abilityTest(abilityContext) {
}
setTimeout(timeout, START_ABILITY_TIMEOUT);
console.debug("====>start startAbilityForResult====>");
await abilityContext.startAbilityForResult(
await globalThis.abilityContext.startAbilityForResult(
{
bundleName: 'com.acts.actsinterfacemultiusersthirdtest',
abilityName: 'com.acts.actsinterfacemultiusersthirdtest.MainAbility3',
......@@ -581,7 +583,7 @@ export default function abilityTest(abilityContext) {
}
setTimeout(timeout, START_ABILITY_TIMEOUT);
console.debug("====>start startAbilityForResult====>");
await abilityContext.startAbilityForResult(
await globalThis.abilityContext.startAbilityForResult(
{
bundleName: 'com.acts.error',
abilityName: 'com.acts.error.MainAbility3',
......@@ -610,7 +612,7 @@ export default function abilityTest(abilityContext) {
}
setTimeout(timeout, START_ABILITY_TIMEOUT);
console.debug("====>start startAbilityForResult====>");
await abilityContext.startAbilityForResult(
await globalThis.abilityContext.startAbilityForResult(
{
bundleName: 'com.acts.actsinterfacemultiusersthirdtest',
abilityName: 'com.acts.actsinterfacemultiusersthirdtest.MainAbility3',
......@@ -635,7 +637,7 @@ export default function abilityTest(abilityContext) {
}
setTimeout(timeout, START_ABILITY_TIMEOUT);
console.debug("====>start startAbilityForResult====>");
await abilityContext.startAbilityForResult(
await globalThis.abilityContext.startAbilityForResult(
{
bundleName: 'com.acts.error',
abilityName: 'com.acts.error.MainAbility3',
......@@ -673,7 +675,7 @@ export default function abilityTest(abilityContext) {
Subscriber = data;
commonEvent.subscribe(Subscriber, SubscribeCallBack);
console.debug("====>start startAbility====>");
await abilityContext.startAbility(
await globalThis.abilityContext.startAbility(
{
bundleName: 'com.acts.actsinterfacemultiusersthirdtest',
abilityName: 'com.acts.actsinterfacemultiusersthirdtest.MainAbility2'
......@@ -722,7 +724,7 @@ export default function abilityTest(abilityContext) {
Subscriber = data;
commonEvent.subscribe(Subscriber, SubscribeCallBack);
console.debug("====>start startAbility====>");
await abilityContext.startAbility(
await globalThis.abilityContext.startAbility(
{
bundleName: 'com.acts.error',
abilityName: 'com.acts.error.MainAbility2'
......@@ -772,7 +774,7 @@ export default function abilityTest(abilityContext) {
Subscriber = data;
commonEvent.subscribe(Subscriber, SubscribeCallBack);
console.debug("====>start startAbility====>");
abilityContext.startAbility(
globalThis.abilityContext.startAbility(
{
bundleName: 'com.acts.actsinterfacemultiusersthirdtest',
abilityName: 'com.acts.actsinterfacemultiusersthirdtest.MainAbility2'
......@@ -821,7 +823,7 @@ export default function abilityTest(abilityContext) {
Subscriber = data;
commonEvent.subscribe(Subscriber, SubscribeCallBack);
console.debug("====>start startAbility====>");
await abilityContext.startAbility(
await globalThis.abilityContext.startAbility(
{
bundleName: 'com.acts.error',
abilityName: 'com.acts.error.MainAbility2'
......@@ -862,7 +864,7 @@ export default function abilityTest(abilityContext) {
}
setTimeout(timeout, START_ABILITY_TIMEOUT);
console.debug("====>start startAbilityForResult====>");
await abilityContext.startAbilityForResult(
await globalThis.abilityContext.startAbilityForResult(
{
bundleName: 'com.acts.actsinterfacemultiusersthirdtest',
abilityName: 'com.acts.actsinterfacemultiusersthirdtest.MainAbility3',
......@@ -889,7 +891,7 @@ export default function abilityTest(abilityContext) {
}
setTimeout(timeout, START_ABILITY_TIMEOUT);
console.debug("====>start startAbilityForResult====>");
await abilityContext.startAbilityForResult(
await globalThis.abilityContext.startAbilityForResult(
{
bundleName: 'com.acts.error',
abilityName: 'com.acts.error.MainAbility3',
......@@ -919,7 +921,7 @@ export default function abilityTest(abilityContext) {
}
setTimeout(timeout, START_ABILITY_TIMEOUT);
console.debug("====>start startAbilityForResult====>");
await abilityContext.startAbilityForResult(
await globalThis.abilityContext.startAbilityForResult(
{
bundleName: 'com.acts.actsinterfacemultiusersthirdtest',
abilityName: 'com.acts.actsinterfacemultiusersthirdtest.MainAbility3',
......@@ -945,7 +947,7 @@ export default function abilityTest(abilityContext) {
}
setTimeout(timeout, START_ABILITY_TIMEOUT);
console.debug("====>start startAbilityForResult====>");
await abilityContext.startAbilityForResult(
await globalThis.abilityContext.startAbilityForResult(
{
bundleName: 'com.acts.error',
abilityName: 'com.acts.error.MainAbility3',
......
......@@ -14,7 +14,7 @@
*/
import abilityTest from './Ability.test.ets'
export default function testsuite(context) {
export default function testsuite() {
console.debug("====>in list.test====>");
abilityTest(context)
abilityTest()
}
\ No newline at end of file
{
"src": [
"pages/index/index",
"pages/second/second"
"MainAbility/pages/index/index",
"MainAbility/pages/second/second"
]
}
\ No newline at end of file
......@@ -13,7 +13,7 @@
import("//build/ohos_var.gni")
group("actsusers") {
group("actsusers900") {
testonly = true
if (is_standard_system) {
deps = [
......
......@@ -22,6 +22,8 @@ ohos_js_hap_suite("ActsConnectAbilitySystemAbilityTest") {
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsConnectAbilitySystemAbilityTest"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("actsconnectabilitysystemabilitytest_app_profile") {
......
......@@ -2,10 +2,12 @@
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "120000",
"package": "com.example.actsconnectabilitysystemabilitytest",
"shell-timeout": "60000"
"type": "OHJSUnitTest",
"test-timeout": "300000",
"bundle-name": "com.example.actsconnectabilitysystemabilitytest",
"module-name":"phone",
"shell-timeout": "300000",
"testcase-timeout": "30000"
},
"kits": [
{
......@@ -15,6 +17,7 @@
"acm switch -i 101"
],
"teardown-command":[
"acm switch -i 101",
"acm delete -i 101"
]
},
......
/*
* 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.
*/
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Ability from '@ohos.application.Ability'
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
onCreate(want,launchParam){
// Ability is creating, initialize resources for this ability
console.log("AbilityMultiInstanceTest onCreate")
console.log("MainAbility onCreate")
globalThis.abilityWant = want;
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("AbilityMultiInstanceTest onDestroy")
console.log("MainAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("AbilityMultiInstanceTest onWindowStageCreate")
console.log("MainAbility onWindowStageCreate")
globalThis.abilityContext = this.context
windowStage.setUIContent(this.context, "pages/index/index", null)
windowStage.setUIContent(this.context, "MainAbility/pages/index/index", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("AbilityMultiInstanceTest onWindowStageDestroy")
//Main window is destroyed, release UI related resources
console.log("MainAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("AbilityMultiInstanceTest onForeground")
console.log("MainAbility onForeground")
}
onBackground() {
// Ability has back to background
console.log("AbilityMultiInstanceTest onBackground")
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 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.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
......@@ -13,6 +13,6 @@
* limitations under the License.
*/
import abilityTest from './manyusersabilitytest.test.ets'
export default function testsuite(context) {
abilityTest(context)
export default function testsuite() {
abilityTest()
}
\ No newline at end of file
......@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index"
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium"
import commonEvent from '@ohos.commonEvent'
......@@ -66,7 +66,7 @@ var unsubscriberInfoStartAbility_0200 = {
const START_ABILITY_TIMEOUT = 1000;
globalThis.number = 0;
export default function abilityTest(abilityContext) {
export default function abilityTest() {
describe('ActssystemabilityTest', function () {
/*
......@@ -87,7 +87,7 @@ export default function abilityTest(abilityContext) {
clearTimeout(id);
expect(data.event).assertEqual("AMS_ConnectAbility_0100_commonEvent");
console.debug("====>ACTS_ConnectAbility_0100 5 ");
abilityContext.disconnectAbility(
globalThis.abilityContext.disconnectAbility(
connId,
(error, data) => {
console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data)
......@@ -114,7 +114,7 @@ export default function abilityTest(abilityContext) {
expect().assertFail();
console.debug('AMS_ConnectAbility_0100 timeout');
commonEvent.unsubscribe(subscriber, unSubscribeCallback)
abilityContext.disconnectAbility(
globalThis.abilityContext.disconnectAbility(
connId,
(error, data) => {
console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data)
......@@ -139,7 +139,7 @@ export default function abilityTest(abilityContext) {
id = setTimeout(timeout, START_ABILITY_TIMEOUT);
console.debug("====>ACTS_ConnectAbility_0100 3 ");
connId = await abilityContext.connectAbility(
connId = await globalThis.abilityContext.connectAbility(
{
bundleName: "com.example.actsconnectabilitysystemabilitytest",
abilityName: "com.example.actsconnectabilitysystemabilitytest.ServiceAbility",
......@@ -189,7 +189,7 @@ export default function abilityTest(abilityContext) {
commonEvent.unsubscribe(subscriber, unSubscribeCallback)
}
id = setTimeout(timeout, START_ABILITY_TIMEOUT);
connId = await abilityContext.connectAbility(
connId = await globalThis.abilityContext.connectAbility(
{
bundleName: "com.example.actsconnectabilitysystemabilitytest",
abilityName: "com.example.actsconnectabilitysystemabilitytest.ServiceAbilityone",
......@@ -217,7 +217,7 @@ export default function abilityTest(abilityContext) {
console.debug("====>ACTS_DisconnectAbility_0100 5 CallBack data:====>" + JSON.stringify(data));
clearTimeout(id);
console.debug("====>ACTS_DisconnectAbility_0100 6====>");
abilityContext.disconnectAbility(
globalThis.abilityContext.disconnectAbility(
connId,
(error, data) => {
console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data)
......@@ -241,7 +241,7 @@ export default function abilityTest(abilityContext) {
expect().assertFail();
console.debug('AMS_DonnectAbility_0300 timeout');
commonEvent.unsubscribe(subscriber, unSubscribeCallback)
abilityContext.disconnectAbility(
globalThis.abilityContext.disconnectAbility(
connId,
(error, data) => {
console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data)
......@@ -249,7 +249,7 @@ export default function abilityTest(abilityContext) {
}
id = setTimeout(timeout, START_ABILITY_TIMEOUT);
console.debug("====>ACTS_DisconnectAbility_0100 3====>");
connId = await abilityContext.connectAbility(
connId = await globalThis.abilityContext.connectAbility(
{
bundleName: "com.example.actsconnectabilitysystemabilitytest",
abilityName: "com.example.actsconnectabilitysystemabilitytest.ServiceAbility",
......@@ -283,7 +283,7 @@ export default function abilityTest(abilityContext) {
console.debug("====>ACTS_DisconnectAbility_0200 1111 connectAbility2====>");
console.debug("====>ACTS_DisconnectAbility_0200 66 Subscriber====>");
abilityContext.disconnectAbility(
globalThis.abilityContext.disconnectAbility(
999,
(error, data) => {
console.log('ACTS_DisconnectAbility_0200 5 DisconnectAbility result errCode : '
......@@ -309,7 +309,7 @@ export default function abilityTest(abilityContext) {
console.debug('unsubscribe subscriberdisconnect');
commonEvent.unsubscribe(subscriber, () => {
console.debug('unsubscribe subscriber')
abilityContext.disconnectAbility(
globalThis.abilityContext.disconnectAbility(
connId,
(error, data) => {
console.log('ACTS_DisconnectAbility_0200 9 DisconnectAbility result errCode : '
......@@ -326,7 +326,7 @@ export default function abilityTest(abilityContext) {
console.debug("====>ACTS_DisconnectAbility_0200 10 Subscriber====>");
subscriber = data;
await commonEvent.subscribe(subscriber, subscribeCallBack)
connId = await abilityContext.connectAbility(
connId = await globalThis.abilityContext.connectAbility(
{
bundleName: "com.example.actsconnectabilitysystemabilitytest",
abilityName: "com.example.actsconnectabilitysystemabilitytest.ServiceAbility",
......@@ -358,7 +358,7 @@ export default function abilityTest(abilityContext) {
console.debug("====>ACTS_DisconnectAbility_0300 4 CallBack data:====>" + JSON.stringify(data));
clearTimeout(id);
expect(data.event).assertEqual("AMS_ConnectAbility_0500_commonEvent");
abilityContext.disconnectAbility(
globalThis.abilityContext.disconnectAbility(
connId,
(error, data) => {
console.log('ACTS_DisconnectAbility_0300 5 DisconnectAbility result errCode : '
......@@ -382,7 +382,7 @@ export default function abilityTest(abilityContext) {
expect().assertFail();
console.debug('AMS_ConnectAbility_0500 timeout');
commonEvent.unsubscribe(subscriber, unSubscribeCallback)
abilityContext.disconnectAbility(
globalThis.abilityContext.disconnectAbility(
connId,
(error, data) => {
console.log('ACTS_DisconnectAbility_0300 7 DisconnectAbility result errCode : '
......@@ -391,7 +391,7 @@ export default function abilityTest(abilityContext) {
}
id = setTimeout(timeout, START_ABILITY_TIMEOUT);
console.debug("====>ACTS_DisconnectAbility_0300 3 ");
connId = await abilityContext.connectAbility(
connId = await globalThis.abilityContext.connectAbility(
{
bundleName: "com.example.actsconnectabilitysystemabilitytest",
abilityName: "com.example.actsconnectabilitysystemabilitytest.ServiceAbility",
......@@ -425,7 +425,7 @@ export default function abilityTest(abilityContext) {
console.debug("====>ACTS_DisconnectAbility_0400 1111 connectAbility2====>");
console.debug("====>ACTS_DisconnectAbility_0400 66 Subscriber====>");
abilityContext.disconnectAbility(
globalThis.abilityContext.disconnectAbility(
999,
(error, data) => {
console.log('ACTS_DisconnectAbility_0400 5 DisconnectAbility result errCode : '
......@@ -451,7 +451,7 @@ export default function abilityTest(abilityContext) {
console.debug('unsubscribe subscriberdisconnect');
commonEvent.unsubscribe(subscriber, () => {
console.debug('unsubscribe subscriber')
abilityContext.disconnectAbility(
globalThis.abilityContext.disconnectAbility(
connId,
(error, data) => {
console.log('ACTS_DisconnectAbility_0400 9 DisconnectAbility result errCode : '
......@@ -468,7 +468,7 @@ export default function abilityTest(abilityContext) {
console.debug("====>ACTS_DisconnectAbility_0400 10 Subscriber====>");
subscriber = data;
await commonEvent.subscribe(subscriber, subscribeCallBack)
connId = await abilityContext.connectAbility(
connId = await globalThis.abilityContext.connectAbility(
{
bundleName: "com.example.actsconnectabilitysystemabilitytest",
abilityName: "com.example.actsconnectabilitysystemabilitytest.ServiceAbility",
......@@ -501,7 +501,7 @@ export default function abilityTest(abilityContext) {
clearTimeout(id);
expect(data.event).assertEqual("AMS_ConnectAbility_0700_commonEvent");
console.debug("====>ACTS_ExtensionConnectAbility_0100 5 ");
abilityContext.disconnectAbility(
globalThis.abilityContext.disconnectAbility(
connId,
(error, data) => {
console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data)
......@@ -525,7 +525,7 @@ export default function abilityTest(abilityContext) {
expect().assertFail();
console.debug('ACTS_ExtensionConnectAbility_0100 timeout');
commonEvent.unsubscribe(subscriber, unSubscribeCallback)
abilityContext.disconnectAbility(
globalThis.abilityContext.disconnectAbility(
connId,
(error, data) => {
console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data)
......@@ -533,7 +533,7 @@ export default function abilityTest(abilityContext) {
}
id = setTimeout(timeout, START_ABILITY_TIMEOUT);
console.debug("====>ACTS_ExtensionConnectAbility_0100 3 ");
connId = await abilityContext.connectAbility(
connId = await globalThis.abilityContext.connectAbility(
{
bundleName: "com.example.actsconnectabilitysystemabilitytest",
abilityName: "com.example.actsconnectabilitysystemabilitytest.ServiceAbility",
......@@ -560,7 +560,7 @@ export default function abilityTest(abilityContext) {
clearTimeout(id);
expect(data.event).assertEqual("AMS_ConnectAbility_0800_commonEvent");
console.debug("====>ACTS_ExtensionConnectAbility_0200 5 ");
abilityContext.disconnectAbility(
globalThis.abilityContext.disconnectAbility(
connId,
(error, data) => {
console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data)
......@@ -583,7 +583,7 @@ export default function abilityTest(abilityContext) {
function timeout() {
console.debug('ACTS_ExtensionConnectAbility_0200 timeout');
commonEvent.unsubscribe(subscriber, unSubscribeCallback)
abilityContext.disconnectAbility(
globalThis.abilityContext.disconnectAbility(
connId,
(error, data) => {
console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data)
......@@ -591,7 +591,7 @@ export default function abilityTest(abilityContext) {
}
id = setTimeout(timeout, START_ABILITY_TIMEOUT);
console.debug("====>ACTS_ExtensionConnectAbility_0200 3 ");
connId = await abilityContext.connectAbility(
connId = await globalThis.abilityContext.connectAbility(
{
bundleName: "com.example.actsconnectabilitysystemabilitytest",
abilityName: "com.example.actsconnectabilitysystemabilitytest.ServiceAbility",
......@@ -618,7 +618,7 @@ export default function abilityTest(abilityContext) {
clearTimeout(id);
expect(data.event).assertEqual("AMS_ConnectAbility_0900_commonEvent");
console.debug("====>ACTS_ExtensionDisconnectAbility_0100 5 ");
abilityContext.disconnectAbility(
globalThis.abilityContext.disconnectAbility(
connId,
(error, data) => {
console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data)
......@@ -642,7 +642,7 @@ export default function abilityTest(abilityContext) {
expect().assertFail();
console.debug('ACTS_ExtensionDisconnectAbility_0100 timeout');
commonEvent.unsubscribe(subscriber, unSubscribeCallback)
abilityContext.disconnectAbility(
globalThis.abilityContext.disconnectAbility(
connId,
(error, data) => {
console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data)
......@@ -650,7 +650,7 @@ export default function abilityTest(abilityContext) {
}
id = setTimeout(timeout, START_ABILITY_TIMEOUT);
console.debug("====>ACTS_ExtensionDisconnectAbility_0100 3 ");
connId = await abilityContext.connectAbility(
connId = await globalThis.abilityContext.connectAbility(
{
bundleName: "com.example.actsconnectabilitysystemabilitytest",
abilityName: "com.example.actsconnectabilitysystemabilitytest.ServiceAbility",
......@@ -677,7 +677,7 @@ export default function abilityTest(abilityContext) {
clearTimeout(id);
expect(data.event).assertEqual("AMS_ConnectAbility_1000_commonEvent");
console.debug("====>ACTS_ExtensionDisconnectAbility_0200 5 ");
abilityContext.disconnectAbility(
globalThis.abilityContext.disconnectAbility(
connId,
(error, data) => {
console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data)
......@@ -701,7 +701,7 @@ export default function abilityTest(abilityContext) {
expect().assertFail();
console.debug('ACTS_ExtensionDisconnectAbility_0200 timeout');
commonEvent.unsubscribe(subscriber, unSubscribeCallback)
abilityContext.disconnectAbility(
globalThis.abilityContext.disconnectAbility(
connId,
(error, data) => {
console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data)
......@@ -709,7 +709,7 @@ export default function abilityTest(abilityContext) {
}
id = setTimeout(timeout, START_ABILITY_TIMEOUT);
console.debug("====>ACTS_ExtensionDisconnectAbility_0200 3 ");
connId = await abilityContext.connectAbility(
connId = await globalThis.abilityContext.connectAbility(
{
bundleName: "com.example.actsconnectabilitysystemabilitytest",
abilityName: "com.example.actsconnectabilitysystemabilitytest.ServiceAbility",
......@@ -736,7 +736,7 @@ export default function abilityTest(abilityContext) {
clearTimeout(id);
expect(data.event).assertEqual("AMS_ConnectAbility_1100_commonEvent");
console.debug("====>ACTS_ExtensionDisconnectAbility_0300 5 ");
abilityContext.disconnectAbility(
globalThis.abilityContext.disconnectAbility(
connId,
(error, data) => {
console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data)
......@@ -759,7 +759,7 @@ export default function abilityTest(abilityContext) {
function timeout() {
console.debug('ACTS_ExtensionDisconnectAbility_0300 timeout');
commonEvent.unsubscribe(subscriber, unSubscribeCallback)
abilityContext.disconnectAbility(
globalThis.abilityContext.disconnectAbility(
connId,
(error, data) => {
console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data)
......@@ -767,7 +767,7 @@ export default function abilityTest(abilityContext) {
}
id = setTimeout(timeout, START_ABILITY_TIMEOUT);
console.debug("====>ACTS_ExtensionDisconnectAbility_0300 3 ");
connId = await abilityContext.connectAbility(
connId = await globalThis.abilityContext.connectAbility(
{
bundleName: "com.example.actsconnectabilitysystemabilitytest",
abilityName: "com.example.actsconnectabilitysystemabilitytest.ServiceAbility",
......@@ -795,7 +795,7 @@ export default function abilityTest(abilityContext) {
clearTimeout(id);
expect(data.event).assertEqual("AMS_ConnectAbility_1200_commonEvent");
console.debug("====>ACTS_ExtensionDisconnectAbility_0400 5 ");
abilityContext.disconnectAbility(
globalThis.abilityContext.disconnectAbility(
connId,
(error, data) => {
console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data)
......@@ -818,7 +818,7 @@ export default function abilityTest(abilityContext) {
function timeout() {
console.debug('ACTS_ExtensionDisconnectAbility_0400 timeout');
commonEvent.unsubscribe(subscriber, unSubscribeCallback)
abilityContext.disconnectAbility(
globalThis.abilityContext.disconnectAbility(
connId,
(error, data) => {
console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data)
......@@ -826,7 +826,7 @@ export default function abilityTest(abilityContext) {
}
id = setTimeout(timeout, START_ABILITY_TIMEOUT);
console.debug("====>ACTS_ExtensionDisconnectAbility_0400 3 ");
connId = await abilityContext.connectAbility(
connId = await globalThis.abilityContext.connectAbility(
{
bundleName: "com.example.actsconnectabilitysystemabilitytest",
abilityName: "com.example.actsconnectabilitysystemabilitytest.ServiceAbility",
......
{
"src": [
"pages/index/index",
"pages/second/second"
"MainAbility/pages/index/index",
"MainAbility/pages/second/second"
]
}
\ No newline at end of file
......@@ -21,8 +21,10 @@ ohos_js_hap_suite("ActsManyUsersAbilityTest") {
":actsmanyusersabilitytest_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx_thirdparty.p7b"
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsManyUsersAbilityTest"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("actsmanyusersabilitytest_app_profile") {
......
......@@ -2,10 +2,12 @@
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "120000",
"package": "com.example.actsmanyusersabilitytest",
"shell-timeout": "60000"
"type": "OHJSUnitTest",
"test-timeout": "300000",
"bundle-name": "com.example.actsmanyusersabilitytest",
"module-name":"phone",
"shell-timeout": "300000",
"testcase-timeout": "30000"
},
"kits": [
{
......
......@@ -20,7 +20,6 @@ export default class MainAbility extends Ability {
// Ability is creating, initialize resources for this ability
console.log("MainAbility onCreate")
globalThis.abilityWant = want;
globalThis.abilityContext = this.context
}
onDestroy() {
......@@ -31,8 +30,8 @@ export default class MainAbility extends Ability {
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("MainAbility onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/index/index", null)
globalThis.abilityContext = this.context
windowStage.setUIContent(this.context, "MainAbility/pages/index/index", null)
}
onWindowStageDestroy() {
......
/*
* 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 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.example.actsmanyusersabilitytest.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
......@@ -13,7 +13,7 @@
* limitations under the License.
*/
import abilityTest from './manyusersabilitytest.test.ets'
export default function testsuite(context) {
export default function testsuite() {
abilityTest(context)
abilityTest()
}
\ No newline at end of file
......@@ -13,7 +13,7 @@
* limitations under the License.
*/
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index"
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium"
import commonEvent from '@ohos.commonEvent'
......@@ -87,7 +87,7 @@ function onFailedCallback(code) {
console.log('ACTS_ConnectAbility onFailedCallback====> code=' + JSON.stringify(code))
}
export default function abilityTest(abilityContext) {
export default function abilityTest() {
describe('manyuserability', function () {
function onFailedCallBack(code) {
......@@ -111,7 +111,7 @@ export default function abilityTest(abilityContext) {
clearTimeout(id);
expect(data.event).assertEqual("AMS_ConnectAbility_0100_commonEvent");
console.debug("====>ACTS_ThirdPartyConnectAbility_0100 5 ");
abilityContext.disconnectAbility(
globalThis.abilityContext.disconnectAbility(
connId,
(error, data) => {
console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data)
......@@ -136,7 +136,7 @@ export default function abilityTest(abilityContext) {
expect().assertFail();
console.debug('ACTS_ThirdPartyConnectAbility_0100 timeout');
commonEvent.unsubscribe(subscriber, unSubscribeCallback)
abilityContext.disconnectAbility(
globalThis.abilityContext.disconnectAbility(
connId,
(error, data) => {
console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data)
......@@ -145,7 +145,7 @@ export default function abilityTest(abilityContext) {
id = setTimeout(timeout, START_ABILITY_TIMEOUT);
console.debug("====>ACTS_ThirdPartyConnectAbility_0100 3 ");
connId = await abilityContext.connectAbility(
connId = await globalThis.abilityContext.connectAbility(
{
bundleName: "com.example.actsmanyusersabilitytest",
abilityName: "com.example.actsmanyusersabilitytest.ServiceAbility",
......@@ -197,7 +197,7 @@ export default function abilityTest(abilityContext) {
}
id = setTimeout(timeout, START_ABILITY_TIMEOUT);
connId = await abilityContext.connectAbility(
connId = await globalThis.abilityContext.connectAbility(
{
bundleName: "com.example.actsmanyusersabilitytest",
abilityName: "com.example.actsmanyusersabilitytest.ServiceAbilityone",
......@@ -221,7 +221,7 @@ export default function abilityTest(abilityContext) {
console.debug("====>ACTS_ThirdPartyDisconnectAbility_0100 5 CallBack data:====>" + JSON.stringify(data));
clearTimeout(id);
console.debug("====>ACTS_ThirdPartyDisconnectAbility_0100 6====>");
abilityContext.disconnectAbility(
globalThis.abilityContext.disconnectAbility(
connId,
(error, data) => {
console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data)
......@@ -250,7 +250,7 @@ export default function abilityTest(abilityContext) {
expect().assertFail();
console.debug('AMS_DonnectAbility_0300 timeout');
commonEvent.unsubscribe(subscriber, unSubscribeCallback)
abilityContext.disconnectAbility(
globalThis.abilityContext.disconnectAbility(
connId,
(error, data) => {
console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data)
......@@ -259,7 +259,7 @@ export default function abilityTest(abilityContext) {
id = setTimeout(timeout, START_ABILITY_TIMEOUT);
console.debug("====>ACTS_ThirdPartyDisconnectAbility_0100 3====>");
connId = await abilityContext.connectAbility(
connId = await globalThis.abilityContext.connectAbility(
{
bundleName: "com.example.actsmanyusersabilitytest",
abilityName: "com.example.actsmanyusersabilitytest.ServiceAbility",
......@@ -292,7 +292,7 @@ export default function abilityTest(abilityContext) {
console.debug("====>ACTS_ThirdPartyDisconnectAbility_0200 1111 connectAbility2====>");
console.debug("====>ACTS_ThirdPartyDisconnectAbility_0200 66 Subscriber====>");
abilityContext.disconnectAbility(
globalThis.abilityContext.disconnectAbility(
999,
(error, data) => {
console.log('ACTS_ThirdPartyDisconnectAbility_0200 5 DisconnectAbility result errCode : ' + error.code + " data: " + data)
......@@ -320,7 +320,7 @@ export default function abilityTest(abilityContext) {
console.debug('unsubscribe subscriberdisconnect');
commonEvent.unsubscribe(subscriber, () => {
console.debug('unsubscribe subscriber')
abilityContext.disconnectAbility(
globalThis.abilityContext.disconnectAbility(
connId,
(error, data) => {
console.log('ACTS_ThirdPartyDisconnectAbility_0200 9 DisconnectAbility result errCode : ' + error.code + " data: " + data)
......@@ -339,7 +339,7 @@ export default function abilityTest(abilityContext) {
console.debug("====>ACTS_ThirdPartyDisconnectAbility_0200 10 Subscriber====>");
subscriber = data;
await commonEvent.subscribe(subscriber, subscribeCallBack)
connId = await abilityContext.connectAbility(
connId = await globalThis.abilityContext.connectAbility(
{
bundleName: "com.example.actsmanyusersabilitytest",
abilityName: "com.example.actsmanyusersabilitytest.ServiceAbility",
......@@ -374,7 +374,7 @@ export default function abilityTest(abilityContext) {
console.debug("====>ACTS_ThirdPartyDisconnectAbility_0300 4 CallBack data:====>" + JSON.stringify(data));
clearTimeout(id);
expect(data.event).assertEqual("AMS_ConnectAbility_0500_commonEvent");
abilityContext.disconnectAbility(
globalThis.abilityContext.disconnectAbility(
connId,
(error, data) => {
console.log('ACTS_ThirdPartyDisconnectAbility_0300 5 DisconnectAbility result errCode : ' + error.code + " data: " + data)
......@@ -402,7 +402,7 @@ export default function abilityTest(abilityContext) {
expect().assertFail();
console.debug('ACTS_ThirdPartyDisconnectAbility_0300 timeout');
commonEvent.unsubscribe(subscriber, unSubscribeCallback)
abilityContext.disconnectAbility(
globalThis.abilityContext.disconnectAbility(
connId,
(error, data) => {
console.log('ACTS_ThirdPartyDisconnectAbility_0300 7 DisconnectAbility result errCode : ' + error.code + " data: " + data)
......@@ -411,7 +411,7 @@ export default function abilityTest(abilityContext) {
id = setTimeout(timeout, START_ABILITY_TIMEOUT);
console.debug("====>ACTS_ThirdPartyDisconnectAbility_0300 3 ");
connId = await abilityContext.connectAbility(
connId = await globalThis.abilityContext.connectAbility(
{
bundleName: "com.example.actsmanyusersabilitytest",
abilityName: "com.example.actsmanyusersabilitytest.ServiceAbility",
......@@ -443,7 +443,7 @@ export default function abilityTest(abilityContext) {
console.debug("====>ACTS_ThirdPartyDisconnectAbility_0400 1111 connectAbility2====>");
console.debug("====>ACTS_ThirdPartyDisconnectAbility_0400 66 Subscriber====>");
abilityContext.disconnectAbility(
globalThis.abilityContext.disconnectAbility(
999,
(error, data) => {
console.log('ACTS_ThirdPartyDisconnectAbility_0400 5 DisconnectAbility result errCode : ' + error.code + " data: " + data)
......@@ -471,7 +471,7 @@ export default function abilityTest(abilityContext) {
console.debug('unsubscribe subscriberdisconnect');
commonEvent.unsubscribe(subscriber, () => {
console.debug('unsubscribe subscriber')
abilityContext.disconnectAbility(
globalThis.abilityContext.disconnectAbility(
connId,
(error, data) => {
console.log('ACTS_ThirdPartyDisconnectAbility_0400 9 DisconnectAbility result errCode : ' + error.code + " data: " + data)
......@@ -490,7 +490,7 @@ export default function abilityTest(abilityContext) {
console.debug("====>ACTS_ThirdPartyDisconnectAbility_0400 10 Subscriber====>");
subscriber = data;
await commonEvent.subscribe(subscriber, subscribeCallBack)
connId = await abilityContext.connectAbility(
connId = await globalThis.abilityContext.connectAbility(
{
bundleName: "com.example.actsmanyusersabilitytest",
abilityName: "com.example.actsmanyusersabilitytest.ServiceAbility",
......@@ -525,7 +525,7 @@ export default function abilityTest(abilityContext) {
clearTimeout(id);
expect(data.event).assertEqual("AMS_ConnectAbility_0700_commonEvent");
console.debug("====>ACTS_ThirdPartyExtensionConnectAbility_0100 5 ");
abilityContext.disconnectAbility(
globalThis.abilityContext.disconnectAbility(
connId,
(error, data) => {
console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data)
......@@ -554,7 +554,7 @@ export default function abilityTest(abilityContext) {
expect().assertFail();
console.debug('ACTS_ExtensionConnectAbility_0100 timeout');
commonEvent.unsubscribe(subscriber, unSubscribeCallback)
abilityContext.disconnectAbility(
globalThis.abilityContext.disconnectAbility(
connId,
(error, data) => {
console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data)
......@@ -563,7 +563,7 @@ export default function abilityTest(abilityContext) {
id = setTimeout(timeout, START_ABILITY_TIMEOUT);
console.debug("====>ACTS_ThirdPartyExtensionConnectAbility_0100 3 ");
connId = await abilityContext.connectAbility(
connId = await globalThis.abilityContext.connectAbility(
{
bundleName: "com.example.actsmanyusersabilitytest",
abilityName: "com.example.actsmanyusersabilitytest.ServiceAbility",
......@@ -591,7 +591,7 @@ export default function abilityTest(abilityContext) {
clearTimeout(id);
expect(data.event).assertEqual("AMS_ConnectAbility_0800_commonEvent");
console.debug("====>ACTS_ThirdPartyExtensionConnectAbility_0200 5 ");
abilityContext.disconnectAbility(
globalThis.abilityContext.disconnectAbility(
connId,
(error, data) => {
console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data)
......@@ -619,7 +619,7 @@ export default function abilityTest(abilityContext) {
function timeout() {
console.debug('ACTS_ThirdPartyExtensionConnectAbility_0200 timeout');
commonEvent.unsubscribe(subscriber, unSubscribeCallback)
abilityContext.disconnectAbility(
globalThis.abilityContext.disconnectAbility(
connId,
(error, data) => {
console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data)
......@@ -628,7 +628,7 @@ export default function abilityTest(abilityContext) {
id = setTimeout(timeout, START_ABILITY_TIMEOUT);
console.debug("====>ACTS_ThirdPartyExtensionConnectAbility_0200 3 ");
connId = await abilityContext.connectAbility(
connId = await globalThis.abilityContext.connectAbility(
{
bundleName: "com.example.actsmanyusersabilitytest",
abilityName: "com.example.actsmanyusersabilitytest.ServiceAbility",
......@@ -655,7 +655,7 @@ export default function abilityTest(abilityContext) {
clearTimeout(id);
expect(data.event).assertEqual("AMS_ConnectAbility_0900_commonEvent");
console.debug("====>ACTS_ThirdPartyExtensionDisconnectAbility_0100 5 ");
abilityContext.disconnectAbility(
globalThis.abilityContext.disconnectAbility(
connId,
(error, data) => {
console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data)
......@@ -684,7 +684,7 @@ export default function abilityTest(abilityContext) {
expect().assertFail();
console.debug('ACTS_ThirdPartyExtensionDisconnectAbility_0100 timeout');
commonEvent.unsubscribe(subscriber, unSubscribeCallback)
abilityContext.disconnectAbility(
globalThis.abilityContext.disconnectAbility(
connId,
(error, data) => {
console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data)
......@@ -693,7 +693,7 @@ export default function abilityTest(abilityContext) {
id = setTimeout(timeout, START_ABILITY_TIMEOUT);
console.debug("====>ACTS_ThirdPartyExtensionDisconnectAbility_0100 3 ");
connId = await abilityContext.connectAbility(
connId = await globalThis.abilityContext.connectAbility(
{
bundleName: "com.example.actsmanyusersabilitytest",
abilityName: "com.example.actsmanyusersabilitytest.ServiceAbility",
......@@ -721,7 +721,7 @@ export default function abilityTest(abilityContext) {
clearTimeout(id);
expect(data.event).assertEqual("AMS_ConnectAbility_1000_commonEvent");
console.debug("====>ACTS_ThirdPartyExtensionDisconnectAbility_0200 5 ");
abilityContext.disconnectAbility(
globalThis.abilityContext.disconnectAbility(
connId,
(error, data) => {
console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data)
......@@ -750,7 +750,7 @@ export default function abilityTest(abilityContext) {
expect().assertFail();
console.debug('ACTS_ThirdPartyExtensionDisconnectAbility_0200 timeout');
commonEvent.unsubscribe(subscriber, unSubscribeCallback)
abilityContext.disconnectAbility(
globalThis.abilityContext.disconnectAbility(
connId,
(error, data) => {
console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data)
......@@ -759,7 +759,7 @@ export default function abilityTest(abilityContext) {
id = setTimeout(timeout, START_ABILITY_TIMEOUT);
console.debug("====>ACTS_ThirdPartyExtensionDisconnectAbility_0200 3 ");
connId = await abilityContext.connectAbility(
connId = await globalThis.abilityContext.connectAbility(
{
bundleName: "com.example.actsmanyusersabilitytest",
abilityName: "com.example.actsmanyusersabilitytest.ServiceAbility",
......@@ -787,7 +787,7 @@ export default function abilityTest(abilityContext) {
clearTimeout(id);
expect(data.event).assertEqual("AMS_ConnectAbility_1100_commonEvent");
console.debug("====>ACTS_ThirdPartyExtensionDisconnectAbility_0200 5 ");
abilityContext.disconnectAbility(
globalThis.abilityContext.disconnectAbility(
connId,
(error, data) => {
console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data)
......@@ -815,7 +815,7 @@ export default function abilityTest(abilityContext) {
function timeout() {
console.debug('ACTS_ThirdPartyExtensionDisconnectAbility_0300 timeout');
commonEvent.unsubscribe(subscriber, unSubscribeCallback)
abilityContext.disconnectAbility(
globalThis.abilityContext.disconnectAbility(
connId,
(error, data) => {
console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data)
......@@ -824,7 +824,7 @@ export default function abilityTest(abilityContext) {
id = setTimeout(timeout, START_ABILITY_TIMEOUT);
console.debug("====>ACTS_ThirdPartyExtensionDisconnectAbility_0300 3 ");
connId = await abilityContext.connectAbility(
connId = await globalThis.abilityContext.connectAbility(
{
bundleName: "com.example.actsmanyusersabilitytest",
abilityName: "com.example.actsmanyusersabilitytest.ServiceAbility",
......@@ -852,7 +852,7 @@ export default function abilityTest(abilityContext) {
clearTimeout(id);
expect(data.event).assertEqual("AMS_ConnectAbility_1200_commonEvent");
console.debug("====>ACTS_ThirdPartyExtensionDisconnectAbility_0400 5 ");
abilityContext.disconnectAbility(
globalThis.abilityContext.disconnectAbility(
connId,
(error, data) => {
console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data)
......@@ -880,7 +880,7 @@ export default function abilityTest(abilityContext) {
function timeout() {
console.debug('ACTS_ThirdPartyExtensionDisconnectAbility_0400 timeout');
commonEvent.unsubscribe(subscriber, unSubscribeCallback)
abilityContext.disconnectAbility(
globalThis.abilityContext.disconnectAbility(
connId,
(error, data) => {
console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data)
......@@ -889,7 +889,7 @@ export default function abilityTest(abilityContext) {
id = setTimeout(timeout, START_ABILITY_TIMEOUT);
console.debug("====>ACTS_ThirdPartyExtensionDisconnectAbility_0400 3 ");
connId = await abilityContext.connectAbility(
connId = await globalThis.abilityContext.connectAbility(
{
bundleName: "com.example.actsmanyusersabilitytest",
abilityName: "com.example.actsmanyusersabilitytest.ServiceAbility",
......
{
"src": [
"pages/index/index",
"pages/second/second"
"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.
先完成此消息的编辑!
想要评论请 注册