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

!5425 singleton xts用例

Merge pull request !5425 from xinking129/master
......@@ -34,6 +34,7 @@ group("ability_runtime") {
"actsqueryfunctiontest:actsqueryfunctiontest",
"actsserviceabilityclienttest:serviceability",
"actsshellcommandfunctionalitytest:actsshellcommandfunctionalitytest",
"actssingleton:actssingleton",
"actsstartrunnertest:ActsStartRunnerTest",
"actsstserviceabilityclientcase:ActsStServiceAbilityClientCaseTest",
"actssupportfunction:actssupportfunction",
......
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
group("actssingleton") {
testonly = true
if (is_standard_system) {
deps = [
"SystemSingleton:ActsSystemSingleton",
"SystemSingletonExtension:ActsSystemSingletonExtension",
"SystemSingletonExtensionFalse:ActsSystemSingletonExtensionFalse",
"SystemSingletonFalse:ActsSystemSingletonFalse",
"ThirdSingleton:ActsThirdSingleton",
"ThirdSingletonExtension:ActsThirdSingletonExtension",
"ThirdSingletonExtensionFalse:ActsThirdSingletonExtensionFalse",
"ThirdSingletonFalse:ActsThirdSingletonFalse",
]
}
}
{
"app": {
"bundleName": "com.singleusermodel.actssingleusertest",
"vendor": "example",
"versionCode": 1000000,
"versionName": "1.0.0",
"icon": "$media:app_icon",
"label": "$string:app_name",
"distributedNotificationEnabled": true,
"keepAlive" : true,
"singleUser": true,
"minAPIVersion": 9,
"targetAPIVersion": 9,
"car": {
"apiCompatibleVersion": 9,
"singleUser": false
}
}
}
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsSystemSingleton") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":systemsingleton_js_assets",
":systemsingleton_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsSystemSingleton"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("systemsingleton_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("systemsingleton_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("systemsingleton_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":systemsingleton_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for aceceshi Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "600000",
"bundle-name": "com.singleusermodel.actssingleusertest",
"module-name": "entry",
"shell-timeout": "600000",
"testcase-timeout": "10000"
},
"kits": [
{
"type": "ShellKit",
"run-command": [
"acm create -n 101 -t normal"
],
"teardown-command":[
"acm delete -i 101"
]
},
{
"type": "PushKit",
"push": [
"ActsSystemSingleton.hap->/system/ActsSystemSingleton.hap"
]
},
{
"test-file-name": [
"ActsSystemSingleton.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityStage from "@ohos.application.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("[Demo] MyAbilityStage onCreate")
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Ability from '@ohos.application.Ability'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../test/List.test'
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
console.log('MainAbility onCreate')
globalThis.abilityContext = this.context;
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
onDestroy() {
console.log('MainAbility onDestroy')
}
onWindowStageCreate(windowStage) {
console.log('MainAbility onWindowStageCreate')
windowStage.setUIContent(this.context, 'MainAbility/pages/index', null)
}
onWindowStageDestroy() {
console.log('MainAbility onWindowStageDestroy')
}
onForeground() {
console.log('MainAbility onForeground')
}
onBackground() {
console.log('MainAbility onBackground')
}
};
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import router from '@ohos.router';
@Entry
@Component
struct Index {
aboutToAppear() {
console.info('MainAbility 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 Ability from '@ohos.application.Ability'
export default class SingleUserModel1400 extends Ability {
onCreate(want, launchParam) {
console.log("SingleUserModel1400 onCreate");
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("SingleUserModel1400 onDestroy");
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("SingleUserModel1400 onWindowStageCreate");
windowStage.setUIContent(this.context, "pages/index", null);
globalThis.ability2Context = this.context;
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("SingleUserModel1400 onWindowStageDestroy");
}
onForeground() {
// Ability has brought to foreground
console.log("SingleUserModel1400 onForeground");
}
onBackground() {
// Ability has back to background
console.log("SingleUserModel1400 onBackground");
}
};
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Ability from '@ohos.application.Ability'
export default class SingleUserModel1500 extends Ability {
onCreate(want, launchParam) {
console.log("SingleUserModel1500 onCreate");
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("SingleUserModel1500 onDestroy");
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("SingleUserModel1500 onWindowStageCreate");
windowStage.setUIContent(this.context, "pages/index", null);
globalThis.ability3Context = this.context;
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("SingleUserModel1500 onWindowStageDestroy");
}
onForeground() {
// Ability has brought to foreground
console.log("SingleUserModel1500 onForeground");
}
onBackground() {
// Ability has back to background
console.log("SingleUserModel1500 onBackground");
}
};
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Ability from '@ohos.application.Ability'
export default class SingleUserModel1600 extends Ability {
onCreate(want, launchParam) {
console.log("SingleUserModel1600 onCreate");
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("SingleUserModel1600 onDestroy");
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("SingleUserModel1600 onWindowStageCreate");
windowStage.setUIContent(this.context, "pages/index", null);
globalThis.ability4Context = this.context;
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("SingleUserModel1600 onWindowStageDestroy");
}
onForeground() {
// Ability has brought to foreground
console.log("SingleUserModel1600 onForeground");
}
onBackground() {
// Ability has back to background
console.log("SingleUserModel1600 onBackground");
}
};
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Ability from '@ohos.application.Ability'
export default class SingleUserModel1700 extends Ability {
onCreate(want, launchParam) {
console.log("SingleUserModel1700 onCreate");
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("SingleUserModel1700 onDestroy");
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("SingleUserModel1700 onWindowStageCreate");
windowStage.setUIContent(this.context, "pages/index", null);
globalThis.ability4Context = this.context;
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("SingleUserModel1700 onWindowStageDestroy");
}
onForeground() {
// Ability has brought to foreground
console.log("SingleUserModel1700 onForeground");
}
onBackground() {
// Ability has back to background
console.log("SingleUserModel1700 onBackground");
}
};
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Ability from '@ohos.application.Ability'
export default class SingleUserModel1800 extends Ability {
onCreate(want, launchParam) {
console.log("SingleUserModel1800 onCreate");
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("SingleUserModel1800 onDestroy");
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("SingleUserModel1800 onWindowStageCreate");
windowStage.setUIContent(this.context, "pages/index", null);
globalThis.ability5Context = this.context;
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("SingleUserModel1800 onWindowStageDestroy");
}
onForeground() {
// Ability has brought to foreground
console.log("SingleUserModel1800 onForeground");
}
onBackground() {
// Ability has back to background
console.log("SingleUserModel1800 onBackground");
}
};
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import 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()
globalThis.abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var MainAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility'
let lMonitor = {
abilityName: MainAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
var cmd = 'aa start -d 0 -a MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters)
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd,
(err: any, d: any) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + d.stdResult);
console.info('executeShellCommand : data : ' + d.exitCode);
})
console.info('OpenHarmonyTestRunner onRun end')
}
};
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@Entry
@Component
struct Index {
@State message: string = 'Hello WorldA'
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.
*/
// @ts-nocheck
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
const START_ABILITY_TIMEOUT = 2000;
const ABILITY_TIMEOUT = 5000;
var user100 = 100;
var user101 = 101;
var user102 = 102;
export default function singleusermodelTest() {
describe('ActsSingleUserTest', function () {
/**
*@tc.number: ACTS_SingleUserModel_1400
*@tc.name: Support singleuser operation mode
*@tc.desc:When singleuser not set, create an ability page with the current user under the influence of
* the system
*/
it('ACTS_SingleUserModel_1400', 0, async function (done) {
let abilityDelegator = undefined
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
console.log("ACTS_SingleUserModel_1400====>callback start====>");
console.debug("====>start startAbilityWithAccount====>");
await globalThis.abilityContext.startAbilityWithAccount(
{
bundleName: 'com.singleusermodel.actssingleusertest',
abilityName: 'SingleUserModel1400'
}, user100).then(() => {
console.debug("====>startAbilityWithAccount 1400 end====>");
})
setTimeout(async () => {
console.debug('ACTS_SingleUserModel_1400====>timeout====>');
let temp
let cmd = 'aa dump -a'
await abilityDelegator.executeShellCommand(cmd).then((data) => {
console.info('====> executeShellCommand : data : ' + JSON.stringify(data));
console.info('====> executeShellCommand : data : ' + data.exitCode);
temp = data["stdResult"];
console.info('====> executeShellCommand : data["stdResult"]; : ' + JSON.stringify(temp));
expect(temp.indexOf("SingleUserModel1400") >= 0).assertTrue()
}).catch((err) => {
console.info('====> executeShellCommand : err : ' + JSON.stringify(err));
})
cmd = 'aa dump -a -u 0'
await abilityDelegator.executeShellCommand(cmd).then((data) => {
console.info('executeShellCommand : data 0: ' + JSON.stringify(data));
temp = data["stdResult"];
expect(temp.indexOf("SingleUserModel1400") == -1).assertTrue()
console.info('executeShellCommand 0: data : ' + data.exitCode);
}).catch((err) => {
console.info('executeShellCommand 0: err : ' + JSON.stringify(err));
})
}, START_ABILITY_TIMEOUT);
setTimeout(() => {
globalThis.ability2Context.terminateSelf();
console.debug('ACTS_SingleUserModel_1400====>done====>');
done();
}, ABILITY_TIMEOUT)
})
/**
*@tc.number: ACTS_SingleUserModel_1500
*@tc.name: Support singleuser operation mode
*@tc.desc:When singleuser not set, create an ability page with an existing non-current user under the
* influence of the system
*/
it('ACTS_SingleUserModel_1500', 0, async function (done) {
let abilityDelegator = undefined
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
console.debug("====>start startAbilityWithAccount====>");
await globalThis.abilityContext.startAbilityWithAccount(
{
bundleName: 'com.singleusermodel.actssingleusertest',
abilityName: 'SingleUserModel1500'
}, user101).then((data) => {
console.debug("====>startAbilityWithAccount 1500 end====>" + data);
}).catch((err) => {
console.debug("====>startAbilityWithAccount 1500 end====>" + err);
})
setTimeout(async () => {
let temp
let cmd = 'aa dump -a -101'
await abilityDelegator.executeShellCommand(cmd).then((data) => {
console.info('executeShellCommand : data : ' + JSON.stringify(data));
temp = data["stdResult"];
expect(temp.indexOf("SingleUserModel1500") == -1).assertTrue()
console.info('executeShellCommand : data : ' + data.exitCode);
}).catch((err) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
})
cmd = 'aa dump -a'
await abilityDelegator.executeShellCommand(cmd).then((data) => {
console.info('executeShellCommand : data : ' + JSON.stringify(data));
temp = data["stdResult"];
expect(temp.indexOf("SingleUserModel1500") == -1).assertTrue()
console.info('executeShellCommand : data : ' + data.exitCode);
}).catch((err) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
})
cmd = 'aa dump -a -u 0'
await abilityDelegator.executeShellCommand(cmd).then((data) => {
console.info('executeShellCommand : data 0: ' + JSON.stringify(data));
temp = data["stdResult"];
expect(temp.indexOf("SingleUserModel1500") == -1).assertTrue()
console.info('executeShellCommand 0: data : ' + data.exitCode);
}).catch((err) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
})
console.debug('ACTS_SingleUserModel_1500====>timeout====>');
}, START_ABILITY_TIMEOUT);
setTimeout(() => {
console.debug('ACTS_SingleUserModel_1500====>done====>');
done();
}, ABILITY_TIMEOUT)
})
/**
*@tc.number: ACTS_SingleUserModel_1600
*@tc.name: Support singleuser operation mode
*@tc.desc:Create an ability page with an empty user under system influence when singleuser not set
*/
it('ACTS_SingleUserModel_1600', 0, async function (done) {
console.debug("====>start startAbilityWithAccount====>");
try {
await globalThis.abilityContext.startAbilityWithAccount(
{
bundleName: 'com.singleusermodel.actssingleusertest',
abilityName: 'SingleUserModel1600'
}, null).then((data) => {
console.debug("====>startAbilityWithAccount 1600 end====>" + data);
}).catch((err) => {
console.debug("====>startAbilityWithAccount 1600 end====>" + err);
})
} catch (err) {
let e = err.toString()
let errLog = "Cannot read property then of undefined"
console.debug("====>e====>" + e);
expect(e.indexOf(errLog) >= 0).assertTrue()
}
setTimeout(async () => {
let abilityDelegator = undefined
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
let temp
let cmd = 'aa dump -a'
await abilityDelegator.executeShellCommand(cmd).then((data) => {
console.info('executeShellCommand : data : ' + JSON.stringify(data));
temp = data["stdResult"];
expect(temp.indexOf("SingleUserModel1600") == -1).assertTrue()
console.info('executeShellCommand : data : ' + data.exitCode);
}).catch((err) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
})
cmd = 'aa dump -a -u 0'
await abilityDelegator.executeShellCommand(cmd).then((data) => {
console.info('executeShellCommand : data 0: ' + JSON.stringify(data));
temp = data["stdResult"];
expect(temp.indexOf("SingleUserModel1600") == -1).assertTrue()
console.info('executeShellCommand 0: data : ' + data.exitCode);
}).catch((err) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
})
console.debug('ACTS_SingleUserModel_1600====>timeout====>');
}, START_ABILITY_TIMEOUT)
setTimeout(() => {
console.debug('ACTS_SingleUserModel_1600====>done====>');
done();
}, ABILITY_TIMEOUT)
})
/**
*@tc.number: ACTS_SingleUserModel_1700
*@tc.name: Support singleuser operation mode
*@tc.desc:Create an ability page with an uncreated user under system influence when singleuser not set
*/
it('ACTS_SingleUserModel_1700', 0, async function (done) {
let abilityDelegator = undefined
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
console.debug("====>start startAbilityWithAccount====>");
try {
await globalThis.abilityContext.startAbilityWithAccount(
{
bundleName: 'com.singleusermodel.actssingleusertest',
abilityName: 'SingleUserModel1700'
}, undefined).then((data) => {
console.debug("====>startAbilityWithAccount 1700 end====>" + data);
}).catch((err) => {
console.debug("====>startAbilityWithAccount 1700 end====>" + err);
})
} catch (err) {
let e = err.toString()
let errLog = "Cannot read property then of undefined"
console.debug("====>e====>" + e);
expect(e.indexOf(errLog) >= 0).assertTrue()
}
setTimeout(async() => {
let temp
let cmd = 'aa dump -a'
await abilityDelegator.executeShellCommand(cmd).then((data) => {
console.info('executeShellCommand : data : ' + JSON.stringify(data));
temp = data["stdResult"];
expect(temp.indexOf("SingleUserModel1700") == -1).assertTrue()
console.info('executeShellCommand : data : ' + data.exitCode);
}).catch((err) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
})
cmd = 'aa dump -a -u 0'
await abilityDelegator.executeShellCommand(cmd).then((data) => {
console.info('executeShellCommand : data 0: ' + JSON.stringify(data));
temp = data["stdResult"];
expect(temp.indexOf("SingleUserModel1700") == -1).assertTrue()
console.info('executeShellCommand 0: data : ' + data.exitCode);
}).catch((err) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
})
console.debug('ACTS_SingleUserModel_1700====>timeout====>');
}, START_ABILITY_TIMEOUT);
setTimeout(() => {
console.debug('ACTS_SingleUserModel_1700====>done====>');
done();
}, ABILITY_TIMEOUT)
})
/**
*@tc.number: ACTS_SingleUserModel_1800
*@tc.name: Support singleuser operation mode
*@tc.desc:Create an ability page with an uncreated user under system influence when singleuser not set
*/
it('ACTS_SingleUserModel_1800', 0, async function (done) {
let abilityDelegator = undefined
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
console.debug("====>start startAbilityWithAccount====>");
await globalThis.abilityContext.startAbilityWithAccount(
{
bundleName: 'com.singleusermodel.actssingleusertest',
abilityName: 'SingleUserModel1800'
}, user102).then((data) => {
console.debug("====>startAbilityWithAccount 1800 end====>" + data);
}).catch((err) => {
console.debug("====>startAbilityWithAccount 1800 end====>" + err);
})
setTimeout(async() => {
let temp
let cmd = 'aa dump -a'
await abilityDelegator.executeShellCommand(cmd).then((data) => {
console.info('executeShellCommand 0800: err : ' + JSON.stringify(err));
console.info('executeShellCommand 0800: data : ' + JSON.stringify(data));
temp = data["stdResult"];
expect(temp.indexOf("SingleUserModel1800") == -1).assertTrue()
console.info('executeShellCommand : data : ' + data.exitCode);
}).catch((err) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
})
cmd = 'aa dump -a -u 0'
await abilityDelegator.executeShellCommand(cmd).then((data) => {
console.info('executeShellCommand 0: err : ' + JSON.stringify(err));
console.info('executeShellCommand : data 0: ' + JSON.stringify(data));
temp = data["stdResult"];
expect(temp.indexOf("SingleUserModel1800") == -1).assertTrue()
console.info('executeShellCommand 0: data : ' + data.exitCode);
}).catch((err) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
})
console.debug('ACTS_SingleUserModel_1800====>timeout====>');
}, START_ABILITY_TIMEOUT);
setTimeout(() => {
console.debug('ACTS_SingleUserModel_1400====>done====>');
done();
}, ABILITY_TIMEOUT)
})
})
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import abilityTest from './Ability.test'
export default function testsuite() {
abilityTest()
}
\ No newline at end of file
{
"module": {
"name": "entry",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:entry_desc",
"mainElement": "MainAbility",
"deviceTypes": [
"phone",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:main_pages",
"uiSyntax": "ets",
"abilities": [
{
"name": "MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:MainAbility_desc",
"icon": "$media:icon",
"label": "$string:MainAbility_label",
"visible": true,
"skills": [
{
"actions": [
"action.system.home"
],
"entities": [
"entity.system.home"
]
}
]
},
{
"name": "SingleUserModel1400",
"srcEntrance": "./ets/SingleUserModel1400/SingleUserModel1400.ts",
"description": "$string:SingleUserModel1400_desc",
"icon": "$media:icon",
"label": "$string:SingleUserModel1400_label"
},
{
"name": "SingleUserModel1500",
"srcEntrance": "./ets/SingleUserModel1500/SingleUserModel1500.ts",
"description": "$string:SingleUserModel1500_desc",
"icon": "$media:icon",
"label": "$string:SingleUserModel1500_label"
},
{
"name": "SingleUserModel1600",
"srcEntrance": "./ets/SingleUserModel1600/SingleUserModel1600.ts",
"description": "$string:SingleUserModel1600_desc",
"icon": "$media:icon",
"label": "$string:SingleUserModel1600_label"
},
{
"name": "SingleUserModel1700",
"srcEntrance": "./ets/SingleUserModel1700/SingleUserModel1700.ts",
"description": "$string:SingleUserModel1700_desc",
"icon": "$media:icon",
"label": "$string:SingleUserModel1700_label"
},
{
"name": "SingleUserModel1800",
"srcEntrance": "./ets/SingleUserModel1800/SingleUserModel1800.ts",
"description": "$string:SingleUserModel1800_desc",
"icon": "$media:icon",
"label": "$string:SingleUserModel1800_label"
}
]
}
}
\ No newline at end of file
{
"string": [
{
"name": "entry_desc",
"value": "description"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
},
{
"name": "SingleUserModel1400_desc",
"value": "description"
},
{
"name": "SingleUserModel1400_label",
"value": "label"
},
{
"name": "SingleUserModel1500_desc",
"value": "description"
},
{
"name": "SingleUserModel1500_label",
"value": "label"
},
{
"name": "SingleUserModel1600_desc",
"value": "description"
},
{
"name": "SingleUserModel1600_label",
"value": "label"
},
{
"name": "SingleUserModel1700_desc",
"value": "description"
},
{
"name": "SingleUserModel1700_label",
"value": "label"
},
{
"name": "SingleUserModel1800_desc",
"value": "description"
},
{
"name": "SingleUserModel1800_label",
"value": "label"
}
]
}
\ No newline at end of file
{
"app": {
"bundleName": "com.singleusermodel.actssingleusertest",
"vendor": "example",
"versionCode": 1000000,
"versionName": "1.0.0",
"icon": "$media:app_icon",
"label": "$string:app_name",
"distributedNotificationEnabled": true,
"keepAlive" : true,
"singleUser": true,
"minAPIVersion": 9,
"targetAPIVersion": 9,
"car": {
"apiCompatibleVersion": 9,
"singleUser": false
}
}
}
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsSystemSingletonExtension") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":systemsingletonextension_js_assets",
":systemsingletonextension_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsSystemSingletonExtension"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("systemsingletonextension_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("systemsingletonextension_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("systemsingletonextension_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":systemsingletonextension_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for aceceshi Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "600000",
"bundle-name": "com.singleusermodel.actssingleusertest",
"module-name": "entry",
"shell-timeout": "600000",
"testcase-timeout": "10000"
},
"kits": [
{
"type": "ShellKit",
"run-command": [
"acm create -n 101 -t normal"
],
"teardown-command":[
"acm delete -i 101"
]
},
{
"type": "PushKit",
"push": [
"ActsSystemSingletonExtension.hap->/system/ActsSystemSingletonExtension.hap"
]
},
{
"test-file-name": [
"ActsSystemSingletonExtension.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityStage from "@ohos.application.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("[Demo] MyAbilityStage onCreate")
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Ability from '@ohos.application.Ability'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../test/List.test'
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
globalThis.abilityContext = this.context;
console.log('MainAbility onCreate')
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
onDestroy() {
console.log('MainAbility onDestroy')
}
onWindowStageCreate(windowStage) {
console.log('MainAbility onWindowStageCreate')
windowStage.setUIContent(this.context, 'MainAbility/pages/index', null)
}
onWindowStageDestroy() {
console.log('MainAbility onWindowStageDestroy')
}
onForeground() {
console.log('MainAbility onForeground')
}
onBackground() {
console.log('MainAbility onBackground')
}
};
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import router from '@ohos.router';
@Entry
@Component
struct Index {
aboutToAppear() {
console.info('MainAbility 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 rpc from '@ohos.rpc';
import ServiceExtension from '@ohos.application.ServiceExtensionAbility'
export default class ServiceAbility1 extends ServiceExtension {
onCreate(want) {
console.log('ServiceAbility1 onCreate, want: ' + want.abilityName);
}
onRequest(want, startId) {
console.log('ServiceAbility1 onRequest, want: ' + want.abilityName + ', startId: ' + startId);
}
onConnect(want) {
console.log('ServiceAbility1 onConnect, want:' + want.abilityName);
if (want.action == 'StartAbilityPromise') {
console.log('stub SerivceAbilityServer OnConnect start 1');
console.log('=======startAbilityPromise=======');
return new rpc.RemoteObject('ServiceAbility1');
}
}
onDisconnect(want) {
console.log('ServiceAbility1 onDisconnect, want:' + want.abilityName);
}
onDestroy() {
console.log('ServiceAbility1 onDestroy');
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import rpc from '@ohos.rpc';
import ServiceExtension from '@ohos.application.ServiceExtensionAbility'
export default class ServiceAbility2 extends ServiceExtension {
onCreate(want) {
console.log('ServiceAbility2 onCreate, want: ' + want.abilityName);
}
onRequest(want, startId) {
console.log('ServiceAbility2 onRequest, want: ' + want.abilityName + ', startId: ' + startId);
}
onConnect(want) {
console.log('ServiceAbility2 onConnect, want:' + want.abilityName);
if (want.action == 'StartAbilityPromise') {
return new rpc.RemoteObject('ServiceAbility2');
}
}
onDisconnect(want) {
console.log('ServiceAbility2 onDisconnect, want:' + want.abilityName);
}
onDestroy() {
console.log('ServiceAbility2 onDestroy');
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import rpc from '@ohos.rpc';
import ServiceExtension from '@ohos.application.ServiceExtensionAbility'
export default class ServiceAbility5 extends ServiceExtension {
onCreate(want) {
console.log('ServiceAbility5 onCreate, want: ' + want.abilityName);
}
onRequest(want, startId) {
console.log('ServiceAbility5 onRequest, want: ' + want.abilityName + ', startId: ' + startId);
}
onConnect(want) {
console.log('ServiceAbility5 onConnect, want:' + want.abilityName);
if (want.action == 'StartAbilityPromise') {
return new rpc.RemoteObject('ServiceAbility5');
}
}
onDisconnect(want) {
console.log('ServiceAbility5 onDisconnect, want:' + want.abilityName);
}
onDestroy() {
console.log('ServiceAbility5 onDestroy');
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import rpc from '@ohos.rpc';
import ServiceExtension from '@ohos.application.ServiceExtensionAbility'
export default class ServiceAbility4 extends ServiceExtension {
onCreate(want) {
console.log('ServiceAbility4 onCreate, want: ' + want.abilityName);
}
onRequest(want, startId) {
console.log('ServiceAbility4 onRequest, want: ' + want.abilityName + ', startId: ' + startId);
}
onConnect(want) {
console.log('ServiceAbility4 onConnect, want:' + want.abilityName);
if (want.action == 'StartAbilityPromise') {
return new rpc.RemoteObject('ServiceAbility4');
}
}
onDisconnect(want) {
console.log('ServiceAbility4 onDisconnect, want:' + want.abilityName);
}
onDestroy() {
console.log('ServiceAbility4 onDestroy');
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export default {
onStart() {
console.info('ServiceAbility onStart');
},
onStop() {
console.info('ServiceAbility onStop');
},
onCommand(want, startId) {
console.info('ServiceAbility onCommand');
}
};
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import rpc from '@ohos.rpc';
import ServiceExtension from '@ohos.application.ServiceExtensionAbility'
export default class ServiceAbility5 extends ServiceExtension {
onCreate(want) {
console.log('ServiceAbility5 onCreate, want: ' + want.abilityName);
}
onRequest(want, startId) {
console.log('ServiceAbility5 onRequest, want: ' + want.abilityName + ', startId: ' + startId);
}
onConnect(want) {
console.log('ServiceAbility5 onConnect, want:' + want.abilityName);
if (want.action == 'StartAbilityPromise') {
return new rpc.RemoteObject('ServiceAbility5');
}
}
onDisconnect(want) {
console.log('ServiceAbility5 onDisconnect, want:' + want.abilityName);
}
onDestroy() {
console.log('ServiceAbility5 onDestroy');
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import TestRunner from '@ohos.application.testRunner'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
var abilityDelegator = undefined
var abilityDelegatorArguments = undefined
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s it',
'-s level', '-s testType', '-s size', '-s timeout'
])
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 MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters)
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd,
(err: any, d: any) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + d.stdResult);
console.info('executeShellCommand : data : ' + d.exitCode);
})
console.info('OpenHarmonyTestRunner onRun end')
}
};
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@Entry
@Component
struct Index {
@State message: string = 'Hello World'
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.
*/
// @ts-nocheck
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
const START_ABILITY_TIMEOUT = 3000;
const ABILITY_TIMEOUT = 5000;
export default function singleusermodelTest() {
describe('ActsSingleUserTest', function () {
var user100 = 100
var user101 = 101
var user102 = 102
function onConnectCallbackA(element, remote) {
console.log('ACTS_ExtensionSingleUserModel_0500 onConnectCallback====> element=' + JSON.stringify(element));
console.log('ACTS_ExtensionSingleUserModel_0500 onConnectCallback====> remote=' + JSON.stringify(remote));
}
function onDisconnectCallbackA(element) {
console.log('onDisconnectCallback====> element=' + JSON.stringify(element));
}
function onFailedCallbackA(code) {
console.log('ACTS_ExtensionSingleUserModel_0500====>ACTS_ConnectAbility ' +
'ConnectAbility onFailed errCode : ' + code)
}
/**
*@tc.number: ACTS_ExtensionSingleUserModel_0500
*@tc.name: Support singleuser operation mode
*@tc.desc:When singleuser is false under the system application, the current user starts a serviceability
*/
it('ACTS_ExtensionSingleUserModel_0500', 0, async function (done) {
console.log("ACTS_ExtensionSingleUserModel_0500====>callback start====>")
let connId;
console.debug("====>start connectAbilityWithAccount====>");
connId = globalThis.abilityContext.connectAbilityWithAccount(
{
bundleName: "com.singleusermodel.actssingleusertest",
abilityName: "ServiceAbility1",
action: "StartAbilityPromise"
},
user100,
{
onConnect: onConnectCallbackA,
onDisconnect: onDisconnectCallbackA,
onFailed: onFailedCallbackA,
}
);
console.log('ACTS_ExtensionSingleUserModel_0500====>StartConnectNative ' +
'connectAbilityWithAccount connId : ' + connId);
setTimeout(async () => {
let abilityDelegator = undefined
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
let temp
let cmd = 'aa dump -e'
await abilityDelegator.executeShellCommand(cmd).then((data) => {
console.info('executeShellCommand : data : ' + JSON.stringify(data));
temp = data["stdResult"];
expect(temp.indexOf("ServiceAbility1") >= 0).assertTrue()
console.info('executeShellCommand : data : ' + data.exitCode);
}).catch((err) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
})
cmd = 'aa dump -e -u 0'
await abilityDelegator.executeShellCommand(cmd).then((data) => {
console.info('executeShellCommand : data 0: ' + JSON.stringify(data));
temp = data["stdResult"];
expect(temp.indexOf("ServiceAbility1") == -1).assertTrue()
console.info('executeShellCommand 0: data : ' + data.exitCode);
}).catch((err) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
})
console.debug('ACTS_ExtensionSingleUserModel_0500====>timeout====>');
await globalThis.abilityContext.disconnectAbility(connId).then((data) => {
console.debug("====>data is====>" + JSON.stringify(data));
})
}, START_ABILITY_TIMEOUT);
setTimeout(() => {
console.debug('ACTS_ExtensionSingleUserModel_0500====>done====>');
done();
}, ABILITY_TIMEOUT)
})
function onConnectCallbackB(element, remote) {
console.log('ACTS_ExtensionSingleUserModel_0600 onConnectCallback====> element=' + JSON.stringify(element));
console.log('ACTS_ExtensionSingleUserModel_0600 onConnectCallback====> remote=' + JSON.stringify(remote));
}
function onDisconnectCallbackB(element) {
console.log('onDisconnectCallback====> element=' + JSON.stringify(element));
}
function onFailedCallbackB(code) {
console.log('ACTS_ExtensionSingleUserModel_0600====>ACTS_ConnectAbility ' +
'ConnectAbility onFailed errCode : ' + code)
}
/**
*@tc.number: ACTS_ExtensionSingleUserModel_0600
*@tc.name: Support singleuser operation mode
*@tc.desc:When singleuser is false under the system application, other existing users start a serviceability
*/
it('ACTS_ExtensionSingleUserModel_0600', 0, async function (done) {
console.log("ACTS_ExtensionSingleUserModel_0600====>callback start====>")
let connId;
console.debug("====>start connectAbilityWithAccount====>");
connId = globalThis.abilityContext.connectAbilityWithAccount(
{
bundleName: "com.singleusermodel.actssingleusertest",
abilityName: "ServiceAbility2",
action: "StartAbilityPromise"
},
user101,
{
onConnect: onConnectCallbackB,
onDisconnect: onDisconnectCallbackB,
onFailed: onFailedCallbackB,
}
);
console.log('ACTS_ExtensionSingleUserModel_0600====>StartConnectNative ' +
'connectAbilityWithAccount connId : ' + connId);
setTimeout(async () => {
let abilityDelegator = undefined
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
let temp
let cmd = 'aa dump -e'
await abilityDelegator.executeShellCommand(cmd).then((data) => {
console.info('executeShellCommand : data : ' + JSON.stringify(data));
temp = data["stdResult"];
expect(temp.indexOf("ServiceAbility2") == -1).assertTrue()
console.info('executeShellCommand : data : ' + data.exitCode);
}).catch((err) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
})
cmd = 'aa dump -e -u 0'
await abilityDelegator.executeShellCommand(cmd).then((data) => {
console.info('executeShellCommand : data 0: ' + JSON.stringify(data));
temp = data["stdResult"];
expect(temp.indexOf("ServiceAbility2") == -1).assertTrue()
console.info('executeShellCommand 0: data : ' + data.exitCode);
}).catch((err) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
})
console.debug('ACTS_ExtensionSingleUserModel_0600====>timeout====>');
}, START_ABILITY_TIMEOUT);
setTimeout(() => {
console.debug('ACTS_ExtensionSingleUserModel_0600====>done====>');
done();
}, ABILITY_TIMEOUT)
})
function onConnectCallbackC(element, remote) {
console.log('ACTS_ExtensionSingleUserModel_0700 onConnectCallback====> element=' + JSON.stringify(element));
console.log('ACTS_ExtensionSingleUserModel_0700 onConnectCallback====> remote=' + JSON.stringify(remote));
}
function onDisconnectCallbackC(element) {
console.log('onDisconnectCallback====> element=' + JSON.stringify(element));
}
function onFailedCallbackC(code) {
console.log('ACTS_ExtensionSingleUserModel_0700====>ACTS_ConnectAbility ' +
'ConnectAbility onFailed errCode : ' + code)
}
/**
*@tc.number: ACTS_ExtensionSingleUserModel_0700
*@tc.name: Support singleuser operation mode
*@tc.desc:When singleuser is false under the system application, other users that do not exist
* tart a serviceability
*/
it('ACTS_ExtensionSingleUserModel_0700', 0, async function (done) {
console.log("ACTS_ExtensionSingleUserModel_0700====>callback start====>");
let connId;
console.debug("====>start connectAbilityWithAccount====>");
connId = globalThis.abilityContext.connectAbilityWithAccount(
{
bundleName: "com.singleusermodel.actssingleusertest",
abilityName: "ServiceAbility3",
action: "StartAbilityPromise"
},
null,
{
onConnect: onConnectCallbackC,
onDisconnect: onDisconnectCallbackC,
onFailed: onFailedCallbackC,
}
);
console.log('ACTS_ExtensionSingleUserModel_0700====>StartConnectNative ' +
'connectAbilityWithAccount connId : ' + connId);
setTimeout(async () => {
let abilityDelegator = undefined
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
let temp
let cmd = 'aa dump -e'
await abilityDelegator.executeShellCommand(cmd).then((data) => {
console.info('executeShellCommand : data : ' + JSON.stringify(data));
temp = data["stdResult"];
expect(temp.indexOf("ServiceAbility3") == -1).assertTrue()
console.info('executeShellCommand : data : ' + data.exitCode);
}).catch((err) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
})
cmd = 'aa dump -e -u 0'
await abilityDelegator.executeShellCommand(cmd).then((data) => {
console.info('executeShellCommand : data 0: ' + JSON.stringify(data));
temp = data["stdResult"];
expect(temp.indexOf("ServiceAbility3") == -1).assertTrue()
console.info('executeShellCommand 0: data : ' + data.exitCode);
}).catch((err) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
})
console.debug('ACTS_ExtensionSingleUserModel_0700====>timeout====>');
}, START_ABILITY_TIMEOUT);
setTimeout(() => {
console.debug('ACTS_ExtensionSingleUserModel_0700====>done====>');
done();
}, ABILITY_TIMEOUT)
})
function onConnectCallbackD(element, remote) {
console.log('ACTS_ExtensionSingleUserModel_0800 onConnectCallback====> element=' + JSON.stringify(element));
console.log('ACTS_ExtensionSingleUserModel_0800 onConnectCallback====> remote=' + JSON.stringify(remote));
}
function onDisconnectCallbackD(element) {
console.log('onDisconnectCallback====> element=' + JSON.stringify(element));
}
function onFailedCallbackD(code) {
console.log('ACTS_ExtensionSingleUserModel_0800====>ACTS_ConnectAbility ' +
'ConnectAbility onFailed errCode : ' + code)
}
/**
*@tc.number: ACTS_ExtensionSingleUserModel_0800
*@tc.name: Support singleuser operation mode
*@tc.desc:When singleuser is false, create an ability page with the current user under the influence of
* the system
*/
it('ACTS_ExtensionSingleUserModel_0800', 0, async function (done) {
console.log("ACTS_ExtensionSingleUserModel_0800====>callback start====>")
let connId;
console.debug("====>start connectAbilityWithAccount====>");
connId = globalThis.abilityContext.connectAbilityWithAccount(
{
bundleName: "com.singleusermodel.actssingleusertest",
abilityName: "ServiceAbility4",
action: "StartAbilityPromise"
},
user102,
{
onConnect: onConnectCallbackD,
onDisconnect: onDisconnectCallbackD,
onFailed: onFailedCallbackD,
}
);
console.log('ACTS_ExtensionSingleUserModel_0800====>StartConnectNative ' +
'connectAbilityWithAccount connId : ' + connId);
setTimeout(async () => {
let abilityDelegator = undefined
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
let temp
let cmd = 'aa dump -e'
await abilityDelegator.executeShellCommand(cmd).then((data) => {
console.info('executeShellCommand : data : ' + JSON.stringify(data));
temp = data["stdResult"];
expect(temp.indexOf("ServiceAbility4") == -1).assertTrue()
console.info('executeShellCommand : data : ' + data.exitCode);
}).catch((err) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
})
cmd = 'aa dump -e -u 0'
await abilityDelegator.executeShellCommand(cmd).then((data) => {
console.info('executeShellCommand : data 0: ' + JSON.stringify(data));
temp = data["stdResult"];
expect(temp.indexOf("ServiceAbility4") == -1).assertTrue()
console.info('executeShellCommand 0: data : ' + data.exitCode);
}).catch((err) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
})
console.debug('ACTS_ExtensionSingleUserModel_0800====>timeout====>');
}, START_ABILITY_TIMEOUT);
setTimeout(() => {
console.debug('ACTS_ExtensionSingleUserModel_0800====>done====>');
done();
}, ABILITY_TIMEOUT)
})
function onConnectCallbackE(element, remote) {
console.log('ACTS_ExtensionSingleUserModel_1300 onConnectCallback====> element=' + JSON.stringify(element));
console.log('ACTS_ExtensionSingleUserModel_1300 onConnectCallback====> remote=' + JSON.stringify(remote));
}
function onDisconnectCallbackE(element) {
console.log('onDisconnectCallback====> element=' + JSON.stringify(element));
}
function onFailedCallbackE(code) {
console.log('ACTS_ExtensionSingleUserModel_1300====>ACTS_ConnectAbility ' +
'ConnectAbility onFailed errCode : ' + code)
}
/**
*@tc.number: ACTS_ExtensionSingleUserModel_1300
*@tc.name: Support singleuser operation mode
*@tc.desc:When singleuser is false under the system application, other users that do not exist
* tart a serviceability
*/
it('ACTS_ExtensionSingleUserModel_1300', 0, async function (done) {
console.log("ACTS_ExtensionSingleUserModel_1300====>callback start====>");
let connId;
connId = globalThis.abilityContext.connectAbilityWithAccount(
{
bundleName: "com.singleusermodel.actssingleusertest",
abilityName: "ServiceAbility5",
action: "StartAbilityPromise"
},
undefined,
{
onConnect: onConnectCallbackE,
onDisconnect: onDisconnectCallbackE,
onFailed: onFailedCallbackE,
}
);
console.log('ACTS_ExtensionSingleUserModel_1300====>StartConnectNative ' +
'connectAbilityWithAccount connId : ' + connId);
setTimeout(async () => {
let abilityDelegator = undefined
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
let temp
let cmd = 'aa dump -e'
await abilityDelegator.executeShellCommand(cmd).then((data) => {
console.info('executeShellCommand : data : ' + JSON.stringify(data));
temp = data["stdResult"];
expect(temp.indexOf("ServiceAbility5") == -1).assertTrue()
console.info('executeShellCommand : data : ' + data.exitCode);
}).catch((err) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
})
cmd = 'aa dump -e -u 0'
await abilityDelegator.executeShellCommand(cmd).then((data) => {
console.info('executeShellCommand : data 0: ' + JSON.stringify(data));
temp = data["stdResult"];
expect(temp.indexOf("ServiceAbility5") == -1).assertTrue()
console.info('executeShellCommand 0: data : ' + data.exitCode);
}).catch((err) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
})
console.debug('ACTS_ExtensionSingleUserModel_1300====>timeout====>');
}, START_ABILITY_TIMEOUT);
setTimeout(() => {
console.debug('ACTS_ExtensionSingleUserModel_1300====>done====>');
done();
}, ABILITY_TIMEOUT)
console.debug("====>start connectAbilityWithAccount====>");
})
})
}
\ 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 singleusermodelTest from './Ability.test'
export default function testsuite() {
singleusermodelTest()
}
\ No newline at end of file
{
"module": {
"name": "entry",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:entry_desc",
"mainElement": "MainAbility",
"deviceTypes": [
"phone",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:main_pages",
"uiSyntax": "ets",
"abilities": [
{
"name": "MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:MainAbility_desc",
"icon": "$media:icon",
"label": "$string:MainAbility_label",
"visible": true,
"skills": [
{
"actions": [
"action.system.home"
],
"entities": [
"entity.system.home"
]
}
]
}
],
"extensionAbilities": [
{
"name": "ServiceAbility1",
"srcEntrance": "./ets/ServiceAbility1/ServiceAbility1.ts",
"label": "$string:form_ServiceAbility1_label",
"description": "$string:form_ServiceAbility1_desc",
"type": "service|dataShare"
},
{
"name": "ServiceAbility2",
"srcEntrance": "./ets/ServiceAbility2/ServiceAbility2.ts",
"label": "$string:form_ServiceAbility1_label",
"description": "$string:form_ServiceAbility1_desc",
"type": "service|dataShare"
},
{
"name": "ServiceAbility3",
"srcEntrance": "./ets/ServiceAbility3/ServiceAbility3.ts",
"label": "$string:form_ServiceAbility1_label",
"description": "$string:form_ServiceAbility1_desc",
"type": "service|dataShare"
},
{
"name": "ServiceAbility4",
"srcEntrance": "./ets/ServiceAbility4/ServiceAbility4.ts",
"label": "$string:form_ServiceAbility1_label",
"description": "$string:form_ServiceAbility1_desc",
"type": "service|dataShare"
},
{
"name": "ServiceAbility5",
"srcEntrance": "./ets/ServiceAbility5/ServiceAbility5.ts",
"label": "$string:form_ServiceAbility1_label",
"description": "$string:form_ServiceAbility1_desc",
"type": "service|dataShare"
}
]
}
}
\ No newline at end of file
{
"string": [
{
"name": "entry_desc",
"value": "description"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
},
{
"name": "form_ServiceAbility1_desc",
"value": "form_description"
},
{
"name": "form_ServiceAbility1_label",
"value": "form_label"
},
{
"name": "form_ServiceAbility2_desc",
"value": "form_description"
},
{
"name": "form_ServiceAbility2_label",
"value": "form_label"
},
{
"name": "form_ServiceAbility3_desc",
"value": "form_description"
},
{
"name": "form_ServiceAbility3_label",
"value": "form_label"
},
{
"name": "form_ServiceAbility4_desc",
"value": "form_description"
},
{
"name": "form_ServiceAbility4_label",
"value": "form_label"
},
{
"name": "form_ServiceAbility5_desc",
"value": "form_description"
},
{
"name": "form_ServiceAbility5_label",
"value": "form_label"
}
]
}
\ No newline at end of file
{
"app": {
"bundleName": "com.singleusermodel.actssingleusertest",
"vendor": "example",
"versionCode": 1000000,
"versionName": "1.0.0",
"icon": "$media:app_icon",
"label": "$string:app_name",
"distributedNotificationEnabled": true,
"singleton":false,
"keepAlive" : true,
"singleUser": true,
"minAPIVersion": 9,
"targetAPIVersion": 9,
"car": {
"apiCompatibleVersion": 9,
"singleUser": false
}
}
}
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsSystemSingletonExtensionFalse") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":systemsingletonextensionfalse_js_assets",
":systemsingletonextensionfalse_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsSystemSingletonExtensionFalse"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("systemsingletonextensionfalse_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("systemsingletonextensionfalse_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("systemsingletonextensionfalse_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":systemsingletonextensionfalse_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for aceceshi Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "600000",
"bundle-name": "com.singleusermodel.actssingleusertest",
"module-name": "entry",
"shell-timeout": "600000",
"testcase-timeout": "10000"
},
"kits": [
{
"type": "ShellKit",
"run-command": [
"acm create -n 101 -t normal"
],
"teardown-command":[
"acm delete -i 101"
]
},
{
"type": "PushKit",
"push": [
"ActsSystemSingletonExtensionFalse.hap->/system/ActsSystemSingletonExtensionFalse.hap"
]
},
{
"test-file-name": [
"ActsSystemSingletonExtensionFalse.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityStage from "@ohos.application.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("[Demo] MyAbilityStage onCreate")
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Ability from '@ohos.application.Ability'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../test/List.test'
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
globalThis.abilityContext = this.context;
console.log('MainAbility onCreate')
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
onDestroy() {
console.log('MainAbility onDestroy')
}
onWindowStageCreate(windowStage) {
console.log('MainAbility onWindowStageCreate')
windowStage.setUIContent(this.context, '../pages/index', null)
}
onWindowStageDestroy() {
console.log('MainAbility onWindowStageDestroy')
}
onForeground() {
console.log('MainAbility onForeground')
}
onBackground() {
console.log('MainAbility onBackground')
}
};
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import rpc from '@ohos.rpc';
import ServiceExtension from '@ohos.application.ServiceExtensionAbility'
export default class ServiceAbility1 extends ServiceExtension {
onCreate(want) {
console.log('ServiceAbility1 onCreate, want: ' + want.abilityName);
}
onRequest(want, startId) {
console.log('ServiceAbility1 onRequest, want: ' + want.abilityName + ', startId: ' + startId);
}
onConnect(want) {
console.log('ServiceAbility1 onConnect, want:' + want.abilityName);
if (want.action == 'StartAbilityPromise') {
console.log('stub SerivceAbilityServer OnConnect start 1');
console.log('=======startAbilityPromise=======');
return new rpc.RemoteObject('ServiceAbility1');
}
}
onDisconnect(want) {
console.log('ServiceAbility1 onDisconnect, want:' + want.abilityName);
}
onDestroy() {
console.log('ServiceAbility1 onDestroy');
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import rpc from '@ohos.rpc';
import ServiceExtension from '@ohos.application.ServiceExtensionAbility'
export default class ServiceAbility2 extends ServiceExtension {
onCreate(want) {
console.log('ServiceAbility2 onCreate, want: ' + want.abilityName);
}
onRequest(want, startId) {
console.log('ServiceAbility2 onRequest, want: ' + want.abilityName + ', startId: ' + startId);
}
onConnect(want) {
console.log('ServiceAbility2 onConnect, want:' + want.abilityName);
if (want.action == 'StartAbilityPromise') {
return new rpc.RemoteObject('ServiceAbility2');
}
}
onDisconnect(want) {
console.log('ServiceAbility2 onDisconnect, want:' + want.abilityName);
}
onDestroy() {
console.log('ServiceAbility2 onDestroy');
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import rpc from '@ohos.rpc';
import ServiceExtension from'@ohos.application.ServiceExtensionAbility'
export default class ServiceAbility3 extends ServiceExtension {
onCreate(want) {
console.log('ServiceAbility3 onCreate, want: ' + want.abilityName);
}
onRequest(want, startId) {
console.log('ServiceAbility3 onRequest, want: ' + want.abilityName + ', startId: ' + startId);
}
onConnect(want) {
console.log('ServiceAbility3 onConnect, want:' + want.abilityName);
if (want.action == 'StartAbilityPromise') {
console.log('stub SerivceAbilityServer OnConnect start 1');
console.log('=======startAbilityPromise=======');
return new rpc.RemoteObject('ServiceAbility3');
}
}
onDisconnect(want) {
console.log('ServiceAbility3 onDisconnect, want:' + want.abilityName);
}
onDestroy() {
console.log('ServiceAbility3 onDestroy');
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import rpc from '@ohos.rpc';
import ServiceExtension from '@ohos.application.ServiceExtensionAbility'
export default class ServiceAbility4 extends ServiceExtension {
onCreate(want) {
console.log('ServiceAbility4 onCreate, want: ' + want.abilityName);
}
onRequest(want, startId) {
console.log('ServiceAbility4 onRequest, want: ' + want.abilityName + ', startId: ' + startId);
}
onConnect(want) {
console.log('ServiceAbility4 onConnect, want:' + want.abilityName);
if (want.action == 'StartAbilityPromise') {
return new rpc.RemoteObject('ServiceAbility4');
}
}
onDisconnect(want) {
console.log('ServiceAbility4 onDisconnect, want:' + want.abilityName);
}
onDestroy() {
console.log('ServiceAbility4 onDestroy');
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import rpc from '@ohos.rpc';
import ServiceExtension from '@ohos.application.ServiceExtensionAbility'
export default class ServiceAbility5 extends ServiceExtension {
onCreate(want) {
console.log('ServiceAbility5 onCreate, want: ' + want.abilityName);
}
onRequest(want, startId) {
console.log('ServiceAbility5 onRequest, want: ' + want.abilityName + ', startId: ' + startId);
}
onConnect(want) {
console.log('ServiceAbility5 onConnect, want:' + want.abilityName);
if (want.action == 'StartAbilityPromise') {
return new rpc.RemoteObject('ServiceAbility5');
}
}
onDisconnect(want) {
console.log('ServiceAbility5 onDisconnect, want:' + want.abilityName);
}
onDestroy() {
console.log('ServiceAbility5 onDestroy');
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import TestRunner from '@ohos.application.testRunner'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
var abilityDelegator = undefined
var abilityDelegatorArguments = undefined
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s it',
'-s level', '-s testType', '-s size', '-s timeout',
'-s dryRun'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams = `${targetParams} ${key} ${parameters[key]}`
}
}
return targetParams.trim()
}
async function onAbilityCreateCallback() {
console.log("onAbilityCreateCallback");
}
async function addAbilityMonitorCallback(err: any) {
console.info("addAbilityMonitorCallback : " + JSON.stringify(err))
}
export default class OpenHarmonyTestRunner implements TestRunner {
constructor() {
}
onPrepare() {
console.info("OpenHarmonyTestRunner OnPrepare ")
}
async onRun() {
console.log('OpenHarmonyTestRunner onRun run')
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
globalThis.abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var MainAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility'
let lMonitor = {
abilityName: MainAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
var cmd = 'aa start -d 0 -a MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters)
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd,
(err: any, d: any) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + d.stdResult);
console.info('executeShellCommand : data : ' + d.exitCode);
})
console.info('OpenHarmonyTestRunner onRun end')
}
};
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@Entry
@Component
struct Index {
@State message: string = 'Hello World'
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.
*/
// @ts-nocheck
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
const ABILITY_TIMEOUT=5000;
const START_ABILITY_TIMEOUT = 3000;
export default function singleusermodelTest() {
describe('ActsSingleUserTest', function () {
var user100=100
var user101=101
var user102=102
function onConnectCallbackA(element, remote) {
console.log('ACTS_ExtensionSingleUserModel_1400 onConnectCallback====> element=' + JSON.stringify(element));
console.log('ACTS_ExtensionSingleUserModel_1400 onConnectCallback====> remote=' + JSON.stringify(remote));
}
function onDisconnectCallbackA(element) {
console.log('onDisconnectCallback====> element=' + JSON.stringify(element));
}
function onFailedCallbackA(code) {
console.log('ACTS_ExtensionSingleUserModel_1400====>ACTS_ConnectAbility ' +
'ConnectAbility onFailed errCode : ' + code)
}
/**
*@tc.number: ACTS_ExtensionSingleUserModel_1400
*@tc.name: Support singleuser operation mode
*@tc.desc:When singleuser is false under the system application, the current user starts a serviceability
*/
it('ACTS_ExtensionSingleUserModel_1400', 0, async function(done){
console.log("ACTS_ExtensionSingleUserModel_1400====>callback start====>")
let connId;
console.debug("====>start connectAbilityWithAccount====>");
connId = globalThis.abilityContext.connectAbilityWithAccount(
{
bundleName: "com.singleusermodel.actssingleusertest",
abilityName:"ServiceAbility1",
action: "StartAbilityPromise"
},
user100,
{
onConnect: onConnectCallbackA,
onDisconnect: onDisconnectCallbackA,
onFailed: onFailedCallbackA,
}
);
setTimeout(async()=>{
let abilityDelegator = undefined
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
let temp
let cmd ='aa dump -e'
await abilityDelegator.executeShellCommand(cmd).then((data) => {
console.info('executeShellCommand : data : ' + JSON.stringify(data));
temp = data["stdResult"];
expect(temp.indexOf("ServiceAbility1") >= 0).assertTrue()
console.info('executeShellCommand : data : ' + data.exitCode);
}).catch((err) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
})
cmd ='aa dump -e -u 0'
await abilityDelegator.executeShellCommand(cmd).then((data) => {
console.info('executeShellCommand : data 0: ' + JSON.stringify(data));
temp = data["stdResult"];
expect(temp.indexOf("ServiceAbility1") == -1).assertTrue()
console.info('executeShellCommand 0: data : ' + data.exitCode);
}).catch((err) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
})
console.debug('ACTS_ExtensionSingleUserModel_1400====>timeout====>');
globalThis.abilityContex.disconnectAbility(connId).then((data)=>{
console.debug("====>data is====>" + JSON.stringify(data));
})
},START_ABILITY_TIMEOUT);
console.log('ACTS_ExtensionSingleUserModel_1400====>StartConnectNative ' +
'connectAbilityWithAccount connId : ' + connId);
setTimeout(()=>{
console.debug('ACTS_ExtensionSingleUserModel_1400====>done====>');
done();
},ABILITY_TIMEOUT)
})
function onConnectCallbackB(element, remote) {
console.log('ACTS_ExtensionSingleUserModel_1500 onConnectCallback====> element=' + JSON.stringify(element));
console.log('ACTS_ExtensionSingleUserModel_1500 onConnectCallback====> remote=' + JSON.stringify(remote));
}
function onDisconnectCallbackB(element) {
console.log('onDisconnectCallback====> element=' + JSON.stringify(element));
}
function onFailedCallbackB(code) {
console.log('ACTS_ExtensionSingleUserModel_1500====>ACTS_ConnectAbility ' +
'ConnectAbility onFailed errCode : ' + code)
}
/**
*@tc.number: ACTS_ExtensionSingleUserModel_1500
*@tc.name: Support singleuser operation mode
*@tc.desc:When singleuser is false under the system application, other existing users start a serviceability
*/
it('ACTS_ExtensionSingleUserModel_1500', 0, async function(done){
console.log("ACTS_ExtensionSingleUserModel_1500====>callback start====>")
let connId;
console.debug("====>start connectAbilityWithAccount====>");
connId = globalThis.abilityContext.connectAbilityWithAccount(
{
bundleName: "com.singleusermodel.actssingleusertest",
abilityName: "ServiceAbility2",
action: "StartAbilityPromise"
},
user101,
{
onConnect: onConnectCallbackB,
onDisconnect: onDisconnectCallbackB,
onFailed: onFailedCallbackB,
}
);
console.log('ACTS_ExtensionSingleUserModel_1500====>StartConnectNative ' +
'connectAbilityWithAccount connId : ' + connId);
setTimeout(async()=>{
let abilityDelegator = undefined
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
let temp
let cmd ='aa dump -e'
await abilityDelegator.executeShellCommand(cmd).then((data) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + JSON.stringify(data));
temp = data["stdResult"];
expect(temp.indexOf("ServiceAbility2") == -1).assertTrue()
console.info('executeShellCommand : data : ' + data.exitCode);
}).catch((err) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
})
cmd ='aa dump -e -u 0'
await abilityDelegator.executeShellCommand(cmd).then((data) => {
console.info('executeShellCommand 0: err : ' + JSON.stringify(err));
console.info('executeShellCommand : data 0: ' + JSON.stringify(data));
temp = data["stdResult"];
expect(temp.indexOf("ServiceAbility2") == -1).assertTrue()
console.info('executeShellCommand 0: data : ' + data.exitCode);
}).catch((err) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
})
console.debug('ACTS_ExtensionSingleUserModel_1500====>timeout====>');
},START_ABILITY_TIMEOUT);
setTimeout(()=>{
console.debug('ACTS_ExtensionSingleUserModel_1500====>done====>');
done();
},ABILITY_TIMEOUT)
})
function onConnectCallbackC(element, remote) {
console.log('ACTS_ExtensionSingleUserModel_1600 onConnectCallback====> element=' + JSON.stringify(element));
console.log('ACTS_ExtensionSingleUserModel_1600 onConnectCallback====> remote=' + JSON.stringify(remote));
}
function onDisconnectCallbackC(element) {
console.log('onDisconnectCallback====> element=' + JSON.stringify(element));
}
function onFailedCallbackC(code) {
console.log('ACTS_ExtensionSingleUserModel_1600====>ACTS_ConnectAbility ' +
'ConnectAbility onFailed errCode : ' + code)
}
/**
*@tc.number: ACTS_ExtensionSingleUserModel_1600
*@tc.name: Support singleuser operation mode
*@tc.desc:When singleuser is false under the system application, other users that do not exist
* tart a serviceability
*/
it('ACTS_ExtensionSingleUserModel_1600', 0, async function(done){
console.log("ACTS_ExtensionSingleUserModel_1600====>callback start====>");
let connId;
console.debug("====>start connectAbilityWithAccount====>");
connId = globalThis.abilityContext.connectAbilityWithAccount(
{
bundleName: "com.singleusermodel.actssingleusertest",
abilityName: "ServiceAbility3",
action: "StartAbilityPromise"
},
null,
{
onConnect: onConnectCallbackC,
onDisconnect: onDisconnectCallbackC,
onFailed: onFailedCallbackC,
}
);
console.log('ACTS_ExtensionSingleUserModel_1600====>StartConnectNative ' +
'connectAbilityWithAccount connId : ' + connId);
setTimeout(async()=> {
let abilityDelegator = undefined
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
let temp
let cmd ='aa dump -e'
await abilityDelegator.executeShellCommand(cmd).then((data) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + JSON.stringify(data));
temp = data["stdResult"];
expect(temp.indexOf("ServiceAbility3") == -1).assertTrue()
console.info('executeShellCommand : data : ' + data.exitCode);
}).catch((err) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
})
cmd ='aa dump -e -u 0'
await abilityDelegator.executeShellCommand(cmd).then((data) => {
console.info('executeShellCommand 0: err : ' + JSON.stringify(err));
console.info('executeShellCommand : data 0: ' + JSON.stringify(data));
temp = data["stdResult"];
expect(temp.indexOf("ServiceAbility3") == -1).assertTrue()
console.info('executeShellCommand 0: data : ' + data.exitCode);
}).catch((err) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
})
console.debug('ACTS_ExtensionSingleUserModel_1600====>timeout====>');
},START_ABILITY_TIMEOUT);
setTimeout(()=>{
console.debug('ACTS_ExtensionSingleUserModel_1600====>done====>');
done();
},ABILITY_TIMEOUT)
})
function onConnectCallbackD(element, remote) {
console.log('ACTS_ExtensionSingleUserModel_1700 onConnectCallback====> element=' + JSON.stringify(element));
console.log('ACTS_ExtensionSingleUserModel_1700 onConnectCallback====> remote=' + JSON.stringify(remote));
}
function onDisconnectCallbackD(element) {
console.log('onDisconnectCallback====> element=' + JSON.stringify(element));
}
function onFailedCallbackD(code) {
console.log('ACTS_ExtensionSingleUserModel_1700====>ACTS_ConnectAbility ' +
'ConnectAbility onFailed errCode : ' + code)
}
/**
*@tc.number: ACTS_ExtensionSingleUserModel_1700
*@tc.name: Support singleuser operation mode
*@tc.desc:When singleuser is false, create an ability page with the current user under the influence of
* the system
*/
it('ACTS_ExtensionSingleUserModel_1700', 0, async function(done){
console.log("ACTS_ExtensionSingleUserModel_1700====>callback start====>")
let connId;
console.debug("====>start connectAbilityWithAccount====>");
connId = globalThis.abilityContext.connectAbilityWithAccount(
{
bundleName: "com.singleusermodel.actssingleusertest",
abilityName: "ServiceAbility4",
action: "StartAbilityPromise"
},
user102,
{
onConnect: onConnectCallbackD,
onDisconnect: onDisconnectCallbackD,
onFailed: onFailedCallbackD,
}
);
console.log('ACTS_ExtensionSingleUserModel_1700====>StartConnectNative ' +
'connectAbilityWithAccount connId : ' + connId);
setTimeout(async()=>{
let abilityDelegator = undefined
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
let temp
let cmd ='aa dump -e'
await abilityDelegator.executeShellCommand(cmd).then((data) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + JSON.stringify(data));
temp = data["stdResult"];
expect(temp.indexOf("ServiceAbility4") == -1).assertTrue()
console.info('executeShellCommand : data : ' + data.exitCode);
}).catch((err) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
})
cmd ='aa dump -e -u 0'
await abilityDelegator.executeShellCommand(cmd).then((data) => {
console.info('executeShellCommand 0: err : ' + JSON.stringify(err));
console.info('executeShellCommand : data 0: ' + JSON.stringify(data));
temp = data["stdResult"];
expect(temp.indexOf("ServiceAbility4") == -1).assertTrue()
console.info('executeShellCommand 0: data : ' + data.exitCode);
}).catch((err) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
})
console.debug('ACTS_ExtensionSingleUserModel_1700====>timeout====>');
},START_ABILITY_TIMEOUT);
setTimeout(()=>{
console.debug('ACTS_ExtensionSingleUserModel_1700====>done====>');
done();
},ABILITY_TIMEOUT)
})
function onConnectCallbackE(element, remote) {
console.log('ACTS_ExtensionSingleUserModel_1900 onConnectCallback====> element=' + JSON.stringify(element));
console.log('ACTS_ExtensionSingleUserModel_1900 onConnectCallback====> remote=' + JSON.stringify(remote));
}
function onDisconnectCallbackE(element) {
console.log('onDisconnectCallback====> element=' + JSON.stringify(element));
}
function onFailedCallbackE(code) {
console.log('ACTS_ExtensionSingleUserModel_1900====>ACTS_ConnectAbility ' +
'ConnectAbility onFailed errCode : ' + code)
}
/**
*@tc.number: ACTS_ExtensionSingleUserModel_1900
*@tc.name: Support singleuser operation mode
*@tc.desc:When singleuser is false under the system application, other users that do not exist
* tart a serviceability
*/
it('ACTS_ExtensionSingleUserModel_1900', 0, async function(done){
console.log("ACTS_ExtensionSingleUserModel_1900====>callback start====>");
let connId;
connId = globalThis.abilityContext.connectAbilityWithAccount(
{
bundleName: "com.singleusermodel.actssingleusertest",
abilityName: "ServiceAbility5",
action: "StartAbilityPromise"
},
undefined,
{
onConnect: onConnectCallbackE,
onDisconnect: onDisconnectCallbackE,
onFailed: onFailedCallbackE,
}
);
console.log('ACTS_ExtensionSingleUserModel_1900====>StartConnectNative ' +
'connectAbilityWithAccount connId : ' + connId);
setTimeout(async()=> {
let abilityDelegator = undefined
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
let temp
let cmd ='aa dump -e'
await abilityDelegator.executeShellCommand(cmd).then((data) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + JSON.stringify(data));
temp = data["stdResult"];
expect(temp.indexOf("ServiceAbility5") == -1).assertTrue()
console.info('executeShellCommand : data : ' + data.exitCode);
}).catch((err) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
})
cmd ='aa dump -e -u 0'
await abilityDelegator.executeShellCommand(cmd).then((data) => {
console.info('executeShellCommand 0: err : ' + JSON.stringify(err));
console.info('executeShellCommand : data 0: ' + JSON.stringify(data));
temp = data["stdResult"];
expect(temp.indexOf("ServiceAbility5") == -1).assertTrue()
console.info('executeShellCommand 0: data : ' + data.exitCode);
}).catch((err) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
})
console.debug('ACTS_ExtensionSingleUserModel_1900====>timeout====>');
},START_ABILITY_TIMEOUT);
setTimeout(()=>{
console.debug('ACTS_ExtensionSingleUserModel_1900====>done====>');
done();
},ABILITY_TIMEOUT)
})
})
}
\ 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 singleusermodelTest from './Ability.test'
export default function testsuite() {
singleusermodelTest()
}
\ No newline at end of file
{
"module": {
"name": "entry",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:entry_desc",
"mainElement": "MainAbility",
"deviceTypes": [
"phone",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:main_pages",
"uiSyntax": "ets",
"abilities": [
{
"name": "MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:MainAbility_desc",
"icon": "$media:icon",
"label": "$string:MainAbility_label",
"visible": true,
"skills": [
{
"actions": [
"action.system.home"
],
"entities": [
"entity.system.home"
]
}
]
}
],
"extensionAbilities": [
{
"name": "ServiceAbility1",
"srcEntrance": "./ets/ServiceAbility1/ServiceAbility1.ts",
"label": "$string:form_ServiceAbility1_label",
"description": "$string:form_ServiceAbility1_desc",
"type": "service|dataShare"
},
{
"name": "ServiceAbility2",
"srcEntrance": "./ets/ServiceAbility2/ServiceAbility2.ts",
"label": "$string:form_ServiceAbility1_label",
"description": "$string:form_ServiceAbility1_desc",
"type": "service|dataShare"
},
{
"name": "ServiceAbility3",
"srcEntrance": "./ets/ServiceAbility3/ServiceAbility3.ts",
"label": "$string:form_ServiceAbility1_label",
"description": "$string:form_ServiceAbility1_desc",
"type": "service|dataShare"
},
{
"name": "ServiceAbility4",
"srcEntrance": "./ets/ServiceAbility4/ServiceAbility4.ts",
"label": "$string:form_ServiceAbility1_label",
"description": "$string:form_ServiceAbility1_desc",
"type": "service|dataShare"
},
{
"name": "ServiceAbility5",
"srcEntrance": "./ets/ServiceAbility5/ServiceAbility5.ts",
"label": "$string:form_ServiceAbility1_label",
"description": "$string:form_ServiceAbility1_desc",
"type": "service|dataShare"
}
]
}
}
\ No newline at end of file
{
"string": [
{
"name": "entry_desc",
"value": "description"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
},
{
"name": "form_ServiceAbility1_desc",
"value": "form_description"
},
{
"name": "form_ServiceAbility1_label",
"value": "form_label"
},
{
"name": "form_ServiceAbility2_desc",
"value": "form_description"
},
{
"name": "form_ServiceAbility2_label",
"value": "form_label"
},
{
"name": "form_ServiceAbility3_desc",
"value": "form_description"
},
{
"name": "form_ServiceAbility3_label",
"value": "form_label"
},
{
"name": "form_ServiceAbility4_desc",
"value": "form_description"
},
{
"name": "form_ServiceAbility4_label",
"value": "form_label"
},
{
"name": "form_ServiceAbility5_desc",
"value": "form_description"
},
{
"name": "form_ServiceAbility5_label",
"value": "form_label"
}
]
}
\ No newline at end of file
{
"app": {
"bundleName": "com.singleusermodel.actssingleusertest",
"vendor": "example",
"versionCode": 1000000,
"versionName": "1.0.0",
"icon": "$media:app_icon",
"label": "$string:app_name",
"distributedNotificationEnabled": true,
"singleton":false,
"keepAlive" : true,
"singleUser": true,
"minAPIVersion": 9,
"targetAPIVersion": 9,
"car": {
"apiCompatibleVersion": 9,
"singleUser": false
}
}
}
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsSystemSingletonFalse") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":systemsingletonfalse_js_assets",
":systemsingletonfalse_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsSystemSingletonFalse"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("systemsingletonfalse_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("systemsingletonfalse_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("systemsingletonfalse_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":systemsingletonfalse_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for aceceshi Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "600000",
"bundle-name": "com.singleusermodel.actssingleusertest",
"module-name": "entry",
"shell-timeout": "600000",
"testcase-timeout": "10000"
},
"kits": [
{
"type": "ShellKit",
"run-command": [
"acm create -n 101 -t normal"
],
"teardown-command":[
"acm delete -i 101"
]
},
{
"type": "PushKit",
"push": [
"ActsSystemSingletonFalse.hap->/system/ActsSystemSingletonFalse.hap"
]
},
{
"test-file-name": [
"ActsSystemSingletonFalse.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityStage from "@ohos.application.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("[Demo] MyAbilityStage onCreate")
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Ability from '@ohos.application.Ability'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../test/List.test'
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
console.log('MainAbility onCreate')
globalThis.abilityContext = this.context;
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
onDestroy() {
console.log('MainAbility onDestroy')
}
onWindowStageCreate(windowStage) {
console.log('MainAbility onWindowStageCreate')
windowStage.setUIContent(this.context, 'MainAbility/pages/index', null)
}
onWindowStageDestroy() {
console.log('MainAbility onWindowStageDestroy')
}
onForeground() {
console.log('MainAbility onForeground')
}
onBackground() {
console.log('MainAbility onBackground')
}
};
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import router from '@ohos.router';
@Entry
@Component
struct Index {
aboutToAppear() {
console.info('MainAbility 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 Ability from '@ohos.application.Ability'
export default class SingleUserModel0500 extends Ability {
onCreate(want, launchParam) {
console.log("SingleUserModel0500 onCreate");
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("SingleUserModel0500 onDestroy");
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("SingleUserModel0500 onWindowStageCreate");
windowStage.setUIContent(this.context, "pages/index1", null);
globalThis.ability2Context = this.context;
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("SingleUserModel0500 onWindowStageDestroy");
}
onForeground() {
// Ability has brought to foreground
console.log("SingleUserModel0500 onForeground");
}
onBackground() {
// Ability has back to background
console.log("SingleUserModel0500 onBackground");
}
};
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Ability from '@ohos.application.Ability'
export default class SingleUserModel0600 extends Ability {
onCreate(want, launchParam) {
console.log("SingleUserModel0600 onCreate");
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("SingleUserModel0600 onDestroy");
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("SingleUserModel0600 onWindowStageCreate");
windowStage.setUIContent(this.context, "pages/index2", null);
globalThis.ability3Context = this.context;
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("SingleUserModel0600 onWindowStageDestroy");
}
onForeground() {
// Ability has brought to foreground
console.log("SingleUserModel0600 onForeground");
}
onBackground() {
// Ability has back to background
console.log("SingleUserModel0600 onBackground");
}
};
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Ability from '@ohos.application.Ability'
export default class SingleUserModel0700 extends Ability {
onCreate(want, launchParam) {
console.log("SingleUserModel0700 onCreate");
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("SingleUserModel0700 onDestroy");
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("SingleUserModel0700 onWindowStageCreate");
windowStage.setUIContent(this.context, "pages/index3", null);
globalThis.ability4Context = this.context;
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("SingleUserModel0700 onWindowStageDestroy");
}
onForeground() {
// Ability has brought to foreground
console.log("SingleUserModel0700 onForeground");
}
onBackground() {
// Ability has back to background
console.log("SingleUserModel0700 onBackground");
}
};
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Ability from '@ohos.application.Ability'
export default class SingleUserModel0800 extends Ability {
onCreate(want, launchParam) {
console.log("SingleUserModel0800 onCreate");
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("SingleUserModel0800 onDestroy");
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("SingleUserModel0800 onWindowStageCreate");
windowStage.setUIContent(this.context, "pages/index4", null);
globalThis.ability5Context = this.context;
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("SingleUserModel0800 onWindowStageDestroy");
}
onForeground() {
// Ability has brought to foreground
console.log("SingleUserModel0800 onForeground");
}
onBackground() {
// Ability has back to background
console.log("SingleUserModel0800 onBackground");
}
};
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Ability from '@ohos.application.Ability'
export default class SingleUserModel1300 extends Ability {
onCreate(want, launchParam) {
console.log("SingleUserModel1300 onCreate");
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("SingleUserModel1300 onDestroy");
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("SingleUserModel1300 onWindowStageCreate");
windowStage.setUIContent(this.context, "pages/index5", null);
globalThis.ability6Context = this.context;
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("SingleUserModel1300 onWindowStageDestroy");
}
onForeground() {
// Ability has brought to foreground
console.log("SingleUserModel1300 onForeground");
}
onBackground() {
// Ability has back to background
console.log("SingleUserModel1300 onBackground");
}
};
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import 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()
globalThis.abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var MainAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility'
let lMonitor = {
abilityName: MainAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
var cmd = 'aa start -d 0 -a MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters)
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd,
(err: any, d: any) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + d.stdResult);
console.info('executeShellCommand : data : ' + d.exitCode);
})
console.info('OpenHarmonyTestRunner onRun end')
}
};
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@Entry
@Component
struct Index {
@State message: string = 'Hello World'
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.
*/
@Entry
@Component
struct Index {
@State message: string = 'SingleUserModel0500'
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.
*/
@Entry
@Component
struct Index {
@State message: string = 'SingleUserModel0600'
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.
*/
@Entry
@Component
struct Index {
@State message: string = 'SingleUserModel0700'
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.
*/
@Entry
@Component
struct Index {
@State message: string = 'SingleUserModel0800'
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.
*/
@Entry
@Component
struct Index {
@State message: string = 'SingleUserModel1300'
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.
*/
// @ts-nocheck
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
const START_ABILITY_TIMEOUT = 3000;
const ABILITY_TIMEOUT = 5000;
export default function singleusermodelTest() {
describe('ActsSingleUserTest', function () {
var user100 = 100
var user101 = 101
var user102 = 102
/**
*@tc.number: ACTS_SingleUserModel_0500
*@tc.name: Support singleuser operation mode
*@tc.desc:When singleuser is false, create an ability page with the current user under the influence of
* the system
*/
it('ACTS_SingleUserModel_0500', 0, async function (done) {
console.log("ACTS_SingleUserModel_0500====>callback start====>");
console.debug("====>start startAbilityWithAccount====>");
await globalThis.abilityContext.startAbilityWithAccount(
{
bundleName: 'com.singleusermodel.actssingleusertest',
abilityName: 'SingleUserModel0500'
}, user100).then(() => {
console.debug("====>startAbilityWithAccount 500 end====>");
})
setTimeout(async () => {
let abilityDelegator = undefined
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
let temp
let cmd = 'aa dump -a'
await abilityDelegator.executeShellCommand(cmd).then((data) => {
console.info('executeShellCommand : data : ' + JSON.stringify(data));
temp = data["stdResult"];
expect(temp.indexOf("SingleUserModel0500") >= 0).assertTrue()
console.info('executeShellCommand : data : ' + data.exitCode);
}).catch((err) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
})
cmd = 'aa dump -a -u 0'
await abilityDelegator.executeShellCommand(cmd).then((data) => {
console.info('executeShellCommand 0: data : ' + JSON.stringify(data))
temp = data["stdResult"];
expect(temp.indexOf("SingleUserModel0500") == -1).assertTrue()
console.info('executeShellCommand 0: data : ' + data.exitCode);
}).catch((err) => {
console.info('executeShellCommand 0: err : ' + JSON.stringify(err));
})
console.debug('ACTS_SingleUserModel_0500====>timeout====>');
}, START_ABILITY_TIMEOUT);
setTimeout(() => {
globalThis.ability2Context.terminateSelf();
console.debug('ACTS_SingleUserModel_0500====>done====>');
done();
}, ABILITY_TIMEOUT)
})
/**
*@tc.number: ACTS_SingleUserModel_0600
*@tc.name: Support singleuser operation mode
*@tc.desc:When singleuser is false, create an ability page with an existing non-current user under the
* influence of the system
*/
it('ACTS_SingleUserModel_0600', 0, async function (done) {
console.log("ACTS_SingleUserModel_0600====>callback start====>")
console.debug("====>start startAbilityWithAccount====>");
await globalThis.abilityContext.startAbilityWithAccount(
{
bundleName: 'com.singleusermodel.actssingleusertest',
abilityName: 'SingleUserModel0600'
}, user101).then((data) => {
console.debug("====>startAbilityWithAccount 600 end====>" + data);
}).catch((err) => {
console.debug("====>startAbilityWithAccount 600 end====>" + err);
})
console.log("ACTS_SingleUserModel_0600====>end====>")
setTimeout(async () => {
let abilityDelegator = undefined
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
let temp
let cmd = 'aa dump -a -u 101'
await abilityDelegator.executeShellCommand(cmd).then((data) => {
console.info('executeShellCommand : data : ' + JSON.stringify(data));
temp = data["stdResult"];
expect(temp.indexOf("SingleUserModel0600") == -1).assertTrue()
console.info('executeShellCommand : data 600: ' + data.exitCode);
}).catch((err) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
})
cmd = 'aa dump -a'
await abilityDelegator.executeShellCommand(cmd).then((data) => {
console.info('executeShellCommand : data 600: ' + JSON.stringify(data));
temp = data["stdResult"];
expect(temp.indexOf("SingleUserModel0600") == -1).assertTrue()
console.info('executeShellCommand : data 600: ' + data.exitCode);
}).catch((err) => {
console.info('executeShellCommand : err 600: ' + JSON.stringify(err));
})
cmd = 'aa dump -a -u 0'
await abilityDelegator.executeShellCommand(cmd).then((data) => {
console.info('executeShellCommand 0: data 600: ' + JSON.stringify(data));
temp = data["stdResult"];
expect(temp.indexOf("SingleUserModel0600") == -1).assertTrue()
console.info('executeShellCommand 0: data 600: ' + data.exitCode);
}).catch((err) => {
console.info('executeShellCommand 0: err 600: ' + JSON.stringify(err));
})
console.debug('ACTS_SingleUserModel_0600====>timeout====>');
}, START_ABILITY_TIMEOUT);
setTimeout(() => {
console.debug('ACTS_SingleUserModel_0600====>done====>');
done();
}, ABILITY_TIMEOUT)
})
/**
*@tc.number: ACTS_SingleUserModel_0700
*@tc.name: Support singleuser operation mode
*@tc.desc:Create an ability page with an empty user under system influence when singleuser is false
*/
it('ACTS_SingleUserModel_0700', 0, async function (done) {
console.log("ACTS_SingleUserModel_0700====>callback start====>");
console.debug("====>start startAbilityWithAccount====>");
try {
await globalThis.abilityContext.startAbilityWithAccount(
{
bundleName: 'com.singleusermodel.actssingleusertest',
abilityName: 'SingleUserModel0700'
}, null).then((data) => {
console.debug("====>startAbilityWithAccount 700 end====>" + data);
}).catch((err) => {
console.debug("====>startAbilityWithAccount 700 end====>" + err);
})
} catch (err) {
let e = err.toString();
let errLog = "Cannot read property then of undefined"
console.debug("====>e====>" + e);
expect(e.indexOf(errLog) >= 0).assertTrue()
}
setTimeout(async () => {
let abilityDelegator = undefined
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
let temp
let cmd = 'aa dump -a'
await abilityDelegator.executeShellCommand(cmd).then((data) => {
console.info('executeShellCommand : data : ' + JSON.stringify(data));
temp = data["stdResult"];
expect(temp.indexOf("SingleUserModel0700") == -1).assertTrue()
console.info('executeShellCommand : data : ' + data.exitCode);
}).catch((err) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
})
cmd = 'aa dump -a -u 0'
await abilityDelegator.executeShellCommand(cmd).then((data) => {
console.info('executeShellCommand 0: data : ' + JSON.stringify(data));
temp = data["stdResult"];
expect(temp.indexOf("SingleUserModel0700") == -1).assertTrue()
console.info('executeShellCommand 0: data : ' + data.exitCode);
}).catch((err) => {
console.info('executeShellCommand 0: err : ' + JSON.stringify(err));
})
console.debug('ACTS_SingleUserModel_0700====>timeout====>');
}, START_ABILITY_TIMEOUT)
setTimeout(() => {
console.debug('ACTS_SingleUserModel_0700====>done====>');
done();
}, ABILITY_TIMEOUT)
})
/**
*@tc.number: ACTS_SingleUserModel_0800
*@tc.name: Support singleuser operation mode
*@tc.desc:Create an ability page with an uncreated user under system influence when singleuser is false
*/
it('ACTS_SingleUserModel_0800', 0, async function (done) {
console.log("ACTS_SingleUserModel_0800====>callback start====>");
console.debug("====>start startAbilityWithAccount====>");
await globalThis.abilityContext.startAbilityWithAccount(
{
bundleName: 'com.singleusermodel.actssingleusertest',
abilityName: 'SingleUserModel0800'
}, user102).then((data) => {
console.debug("====>startAbilityWithAccount 800 end data====>" + data);
}).catch((err) => {
console.debug("====>startAbilityWithAccount 800 end err====>" + err);
})
setTimeout(async () => {
console.debug('ACTS_SingleUserModel_0800====>timeout====>');
let abilityDelegator = undefined
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
let temp
let cmd = 'aa dump -a'
await abilityDelegator.executeShellCommand(cmd).then((data) => {
console.info('executeShellCommand 0800: data : ' + JSON.stringify(data));
temp = data["stdResult"];
expect(temp.indexOf("SingleUserModel0800") == -1).assertTrue()
console.info('executeShellCommand : data : ' + data.exitCode);
}).catch((err) => {
console.info('executeShellCommand 0: err : ' + JSON.stringify(err));
})
cmd = 'aa dump -a -u 0'
await abilityDelegator.executeShellCommand(cmd).then((data) => {
console.info('executeShellCommand 0: data : ' + JSON.stringify(data))
temp = data["stdResult"];
expect(temp.indexOf("SingleUserModel0800") == -1).assertTrue()
console.info('executeShellCommand 0: data : ' + data.exitCode);
}).catch((err) => {
console.info('executeShellCommand 0: err : ' + JSON.stringify(err));
})
}, START_ABILITY_TIMEOUT);
setTimeout(() => {
console.debug('ACTS_SingleUserModel_0800====>done====>');
done();
}, ABILITY_TIMEOUT)
})
/**
*@tc.number: ACTS_SingleUserModel_1300
*@tc.name: Support singleuser operation mode
*@tc.desc:Create an ability page with an uncreated user under system influence when singleuser is false
*/
it('ACTS_SingleUserModel_1300', 0, async function (done) {
console.log("ACTS_SingleUserModel_1300====>callback start====>");
console.debug("====>start startAbilityWithAccount====>");
try {
await globalThis.abilityContext.startAbilityWithAccount(
{
bundleName: 'com.singleusermodel.actssingleusertest',
abilityName: 'SingleUserModel1300'
}, undefined).then((data) => {
console.debug("====>startAbilityWithAccount 1300 end====>" + data);
}).catch((err) => {
console.debug("====>startAbilityWithAccount 1300 end====>" + err);
})
} catch (err) {
let e = err.toString();
let errLog = "Cannot read property then of undefined"
console.debug("====>e====>" + e);
expect(e.indexOf(errLog) >= 0).assertTrue()
}
setTimeout(async () => {
let temp
let cmd = 'aa dump -a'
let abilityDelegator = undefined
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
await abilityDelegator.executeShellCommand(cmd).then((data) => {
console.info('executeShellCommand : data : ' + JSON.stringify(data));
temp = data["stdResult"];
expect(temp.indexOf("SingleUserModel1300") == -1).assertTrue()
console.info('executeShellCommand : data : ' + data.exitCode);
}).catch((err) => {
console.info('executeShellCommand 0: err : ' + JSON.stringify(err));
})
cmd = 'aa dump -a -u 0'
await abilityDelegator.executeShellCommand(cmd).then((data) => {
console.info('executeShellCommand 0: data : ' + JSON.stringify(data))
temp = data["stdResult"];
expect(temp.indexOf("SingleUserModel1300") == -1).assertTrue()
console.info('executeShellCommand 0: data : ' + data.exitCode);
}).catch((err) => {
console.info('executeShellCommand 0: err : ' + JSON.stringify(err));
})
console.debug('ACTS_SingleUserModel_1300====>timeout====>');
}, START_ABILITY_TIMEOUT);
setTimeout(() => {
console.debug('ACTS_SingleUserModel_1300====>done====>');
done();
}, ABILITY_TIMEOUT)
})
})
}
\ 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 singleusermodelTest from './Ability.test'
export default function testsuite() {
singleusermodelTest()
}
\ No newline at end of file
{
"module": {
"name": "entry",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:entry_desc",
"mainElement": "MainAbility",
"deviceTypes": [
"phone",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:main_pages",
"uiSyntax": "ets",
"abilities": [
{
"name": "MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:MainAbility_desc",
"icon": "$media:icon",
"label": "$string:MainAbility_label",
"visible": true,
"skills": [
{
"actions": [
"action.system.home"
],
"entities": [
"entity.system.home"
]
}
]
},
{
"name": "MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:MainAbility_desc",
"icon": "$media:icon",
"label": "$string:MainAbility_label"
},
{
"name": "SingleUserModel0500",
"srcEntrance": "./ets/SingleUserModel0500/SingleUserModel0500.ts",
"description": "$string:SingleUserModel0500_desc",
"icon": "$media:icon",
"label": "$string:SingleUserModel0500_label"
},
{
"name": "SingleUserModel0600",
"srcEntrance": "./ets/SingleUserModel0600/SingleUserModel0600.ts",
"description": "$string:SingleUserModel0600_desc",
"icon": "$media:icon",
"label": "$string:SingleUserModel0600_label"
},
{
"name": "SingleUserModel0700",
"srcEntrance": "./ets/SingleUserModel0700/SingleUserModel0700.ts",
"description": "$string:SingleUserModel0700_desc",
"icon": "$media:icon",
"label": "$string:SingleUserModel0700_label"
},
{
"name": "SingleUserModel0800",
"srcEntrance": "./ets/SingleUserModel0800/SingleUserModel0800.ts",
"description": "$string:SingleUserModel0800_desc",
"icon": "$media:icon",
"label": "$string:SingleUserModel0800_label"
},
{
"name": "SingleUserModel1300",
"srcEntrance": "./ets/SingleUserModel1300/SingleUserModel1300.ts",
"description": "$string:SingleUserModel1300_desc",
"icon": "$media:icon",
"label": "$string:SingleUserModel1300_label"
}
]
}
}
\ No newline at end of file
{
"string": [
{
"name": "entry_desc",
"value": "description"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
},
{
"name": "SingleUserModel0500_desc",
"value": "description"
},
{
"name": "SingleUserModel0500_label",
"value": "label"
},
{
"name": "SingleUserModel0600_desc",
"value": "description"
},
{
"name": "SingleUserModel0600_label",
"value": "label"
},
{
"name": "SingleUserModel0700_desc",
"value": "description"
},
{
"name": "SingleUserModel0700_label",
"value": "label"
},
{
"name": "SingleUserModel0800_desc",
"value": "description"
},
{
"name": "SingleUserModel0800_label",
"value": "label"
},
{
"name": "SingleUserModel1300_desc",
"value": "description"
},
{
"name": "SingleUserModel1300_label",
"value": "label"
}
]
}
\ No newline at end of file
{
"app": {
"bundleName": "com.singleusermodel.actssingleusertest",
"vendor": "example",
"versionCode": 1000000,
"versionName": "1.0.0",
"icon": "$media:app_icon",
"label": "$string:app_name",
"distributedNotificationEnabled": true,
"keepAlive" : true,
"singleUser": true,
"minAPIVersion": 9,
"targetAPIVersion": 9,
"car": {
"apiCompatibleVersion": 9,
"singleUser": false
}
}
}
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsThirdSingleton") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":thirdsingleton_js_assets",
":thirdsingleton_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsThirdSingleton"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("thirdsingleton_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("thirdsingleton_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("thirdsingleton_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":thirdsingleton_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for aceceshi Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "600000",
"bundle-name": "com.singleusermodel.actssingleusertest",
"module-name": "entry",
"shell-timeout": "600000",
"testcase-timeout": "10000"
},
"kits": [
{
"type": "ShellKit",
"run-command": [
"acm create -n 101 -t normal"
],
"teardown-command":[
"acm delete -i 101"
]
},
{
"type": "PushKit",
"push": [
"ActsThirdSingleton.hap->/data/ActsThirdSingleton.hap"
]
},
{
"test-file-name": [
"ActsThirdSingleton.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册