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

!7093 xts-系统API下库

Merge pull request !7093 from chengxingzhen/master
......@@ -32,7 +32,6 @@ group("ability_runtime") {
"actsqueryfunctiontest:actsqueryfunctiontest",
"actsserviceabilityclienttest:serviceability",
"actsshellcommandfunctionalitytest:actsshellcommandfunctionalitytest",
"actssingleton:actssingleton",
"actsstartrunnertest:ActsStartRunnerTest",
"actsstserviceabilityclientcase:ActsStServiceAbilityClientCaseTest",
"actssupportfunction:actssupportfunction",
......@@ -49,7 +48,6 @@ group("ability_runtime") {
"featureability:featureability",
"formmanager:formmanager",
"freeinstalltest:freeinstalltest",
"killprocesswithaccountstage:killprocesswithaccountstage",
"newwant:newwant",
"non_concurrent:non_concurrent",
"stage:stage",
......
# 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:ActsSystemSingletonTest",
"SystemSingletonFalse:ActsSystemSingletonFalseTest",
"ThirdSingleton:ActsThirdSingletonTest",
"ThirdSingletonFalse:ActsThirdSingletonFalseTest",
]
}
}
{
"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("ActsSystemSingletonTest") {
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 = "ActsSystemSingletonTest"
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": [
"ActsSystemSingletonTest.hap->/system/ActsSystemSingletonTest.hap"
]
},
{
"test-file-name": [
"ActsSystemSingletonTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityStage from "@ohos.app.ability.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("[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.app.ability.UIAbility'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../test/List.test'
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
console.log('MainAbility onCreate')
globalThis.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.app.ability.UIAbility'
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.app.ability.UIAbility'
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.app.ability.UIAbility'
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.app.ability.UIAbility'
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.app.ability.UIAbility'
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.
*/
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.info("====>start startAbilityWithAccount====>");
try {
await globalThis.abilityContext.startAbilityWithAccount(
{
bundleName: 'com.singleusermodel.actssingleusertest',
abilityName: 'SingleUserModel1600'
}, null).then((data) => {
console.info("====>startAbilityWithAccount 1600 end====>" + data);
}).catch((err) => {
console.info("====>startAbilityWithAccount 1600 end====>" + err);
})
} catch (err) {
let e = err.toString()
let errLog = "Invalid input parameter"
console.info("ACTS_SingleUserModel_1600 ====>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.info('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 = "Invalid input parameter"
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: 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 : 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": [
"default",
"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,
"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("ActsSystemSingletonFalseTest") {
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 = "ActsSystemSingletonFalseTest"
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": [
"ActsSystemSingletonFalseTest.hap->/system/ActsSystemSingletonFalseTest.hap"
]
},
{
"test-file-name": [
"ActsSystemSingletonFalseTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityStage from "@ohos.app.ability.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("[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.app.ability.UIAbility'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../test/List.test'
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
console.log('MainAbility onCreate')
globalThis.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.app.ability.UIAbility'
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.app.ability.UIAbility'
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.app.ability.UIAbility'
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.app.ability.UIAbility'
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.app.ability.UIAbility'
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.
*/
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 = "Invalid input parameter"
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 = "Invalid input parameter"
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": [
"default",
"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("ActsThirdSingletonTest") {
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 = "ActsThirdSingletonTest"
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": [
"ActsThirdSingletonTest.hap->/data/ActsThirdSingletonTest.hap"
]
},
{
"test-file-name": [
"ActsThirdSingletonTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityStage from "@ohos.app.ability.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("[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.app.ability.UIAbility'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../test/List.test'
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
console.log('MainAbility onCreate')
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)
globalThis.abilityContext = this.context;
}
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.
*/
@Entry
@Component
struct Index {
aboutToAppear() {
console.info("start run testcase!!!!")
}
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('Hello World')
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Ability from '@ohos.app.ability.UIAbility'
function PublishCallBackOne4() {
console.debug("====>Publish CallBack ACTS_StartAbility_1900_CommonEvent====>");
console.debug("====>close this context====>1900====>")
}
export default class SingleUserModel1900 extends Ability {
onCreate(want, launchParam) {
console.log("SingleUserModel1900 onCreate")
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("SingleUserModel1900 onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("SingleUserModel1900 onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/index", null)
globalThis.ability2Context = this.context;
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("SingleUserModel1900 onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("SingleUserModel1900 onForeground")
}
onBackground() {
// Ability has back to background
console.log("SingleUserModel1900 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 = '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.
*/
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
const START_ABILITY_TIMEOUT = 3000;
const ABILITY_TIMEOUT = 5000;
export default function singleusermodelTest() {
describe('ActsSingleUserTest', function () {
var user100 = 100
/**
*@tc.number: ACTS_SingleUserModel_1900
*@tc.name: Support singleuser operation mode
*@tc.desc:When singleuser is false, create an ability page with the current user under a third-party application
*/
it('ACTS_SingleUserModel_1900', 0, async function (done) {
console.log("ACTS_SingleUserModel_1900====>callback start====>")
await globalThis.abilityContext.startAbilityWithAccount(
{
bundleName: 'com.singleusermodel.actssingleusertest',
abilityName: 'SingleUserModel1900'
}, user100).then(() => {
console.debug("====>startAbilityWithAccount end====>");
})
setTimeout(async () => {
let abilityDelegator = undefined
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
console.debug('ACTS_SingleUserModel_1900====>in timeout====>');
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("SingleUserModel1900") >= 0).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("SingleUserModel1900") == -1).assertTrue()
console.info('executeShellCommand 0: data : ' + data.exitCode);
}).catch((err) => {
console.info('executeShellCommand 0: err : ' + JSON.stringify(err));
})
globalThis.ability2Context.terminateSelf();
}, START_ABILITY_TIMEOUT);
setTimeout(() => {
console.debug('ACTS_SingleUserModel_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 '../test/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": [
"default",
"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": "SingleUserModel1900",
"srcEntrance": "./ets/SingleUserModel1900/SingleUserModel1900.ts",
"description": "$string:SingleUserModel1900_desc",
"icon": "$media:icon",
"label": "$string:SingleUserModel1900_label"
}
]
}
}
\ No newline at end of file
{
"string": [
{
"name": "entry_desc",
"value": "description"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
},
{
"name": "SingleUserModel1900_desc",
"value": "description"
},
{
"name": "SingleUserModel1900_label",
"value": "label"
}
]
}
\ No newline at end of file
{
"app": {
"bundleName": "com.singleusermodel.actssingleusertest",
"singleton": false,
"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("ActsThirdSingletonFalseTest") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":thirdsingletonfalse_js_assets",
":thirdsingletonfalse_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsThirdSingletonFalseTest"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("thirdsingletonfalse_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("thirdsingletonfalse_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("thirdsingletonfalse_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":thirdsingletonfalse_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": [
"ActsThirdSingletonFalseTest.hap->/data/ActsThirdSingletonFalseTest.hap"
]
},
{
"test-file-name": [
"ActsThirdSingletonFalseTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityStage from "@ohos.app.ability.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("[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.app.ability.UIAbility'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../test/List.test'
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
console.log('MainAbility onCreate')
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)
globalThis.abilityContext = this.context;
}
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.
*/
@Entry
@Component
struct Index {
aboutToAppear() {
console.info("start run testcase!!!!")
}
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('Hello World')
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Ability from '@ohos.app.ability.UIAbility'
export default class SingleUserModel1000 extends Ability {
onCreate(want, launchParam) {
console.log("SingleUserModel1000 onCreate")
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("SingleUserModel1000 onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("SingleUserModel1000 onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/index", null)
globalThis.ability2Context = this.context;
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("SingleUserModel1000 onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("SingleUserModel1000 onForeground")
}
onBackground() {
// Ability has back to background
console.log("SingleUserModel1000 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 {
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('SingleUserModel1000')
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button("SingleUserModel1000")
.onClick(() => {
globalThis.ability2Context.terminateSelf();
})
}
.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 {
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('SingleUserModel1000')
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button("SingleUserModel1000")
.onClick(() => {
globalThis.ability2Context.terminateSelf();
})
}
.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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
const START_ABILITY_TIMEOUT = 3000;
const ABILITY_TIMEOUT=5000;
export default function singleusermodelTest() {
describe('ActsSingleUserTest', function () {
var user100=100;
/**
*@tc.number: ACTS_SingleUserModel_1000
*@tc.name: Support singleuser operation mode
*@tc.desc:When singleuser is false, create an ability page with the current user under a third-party application
*/
it('ACTS_SingleUserModel_1000', 0, async function (done) {
console.log("ACTS_SingleUserModel_1000====>callback start====>")
await globalThis.abilityContext.startAbilityWithAccount(
{
bundleName: 'com.singleusermodel.actssingleusertest',
abilityName: 'SingleUserModel1000'
},user100).then(()=>{
console.debug("====>startAbilityWithAccount end====>");
})
setTimeout(async()=>{
let abilityDelegator = undefined
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
let temp
let cmd ='aa dump -a'
console.log("ACTS_SingleUserModel_1000====>callback start====>")
await abilityDelegator.executeShellCommand(cmd).then((data) => {
console.info('====>executeShellCommand : data : ' + JSON.stringify(data));
temp = data["stdResult"];
expect(temp.indexOf("SingleUserModel1000") >= 0).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("SingleUserModel1000") == -1).assertTrue()
console.info('====>executeShellCommand 0: data : ' + data.exitCode);
}).catch((err) => {
console.info('executeShellCommand 0: err : ' + JSON.stringify(err));
})
console.debug('ACTS_SingleUserModel_1000====>timeout====>');
globalThis.ability2Context.terminateSelf();
}, START_ABILITY_TIMEOUT);
setTimeout(()=>{
console.debug('ACTS_SingleUserModel_1000====>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 '../test/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": [
"default",
"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": "SingleUserModel1000",
"srcEntrance": "./ets/SingleUserModel1000/SingleUserModel1000.ts",
"description": "$string:SingleUserModel1000_desc",
"icon": "$media:icon",
"label": "$string:SingleUserModel1000_label"
}
]
}
}
\ No newline at end of file
{
"string": [
{
"name": "entry_desc",
"value": "description"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
},
{
"name": "SingleUserModel1000_desc",
"value": "description"
},
{
"name": "SingleUserModel1000_label",
"value": "label"
}
]
}
\ No newline at end of file
{
"forms": [
{
"name": "widget",
"description": "This is a service widget.",
"src": "./js/widget/pages/index/index",
"window": {
"designWidth": 720,
"autoDesignWidth": true
},
"colorMode": "auto",
"isDefault": true,
"updateEnabled": true,
"scheduledUpdateTime": "10:30",
"updateDuration": 1,
"defaultDimension": "2*2",
"supportDimensions": [
"2*2"
],
"formConfigAbility": "ability://xxxxx"
}
]
}
\ No newline at end of file
......@@ -44,11 +44,6 @@ export default class MainAbility extends Ability {
// Ability has brought to foreground
console.log("MainAbility onForeground")
console.log("in killhap onForeground")
setTimeout(()=>{
appManager.killProcessesByBundleName('com.example.killprocessthirdhap').then((data)=>{
console.info('====>ACTS_KillProcess_0100 killProcessesByBundleName=====>' + JSON.stringify(data))
})
},2000)
}
onBackground() {
......
......@@ -44,11 +44,6 @@ export default class MainAbility extends Ability {
// Ability has brought to foreground
console.log("MainAbility onForeground")
console.log("in killhap onForeground")
setTimeout(()=>{
appManager.killProcessesByBundleName('com.example.killprocessthirdhap2',(err,data)=>{
console.info('====>ACTS_KillProcess_0100 killProcessesByBundleName=====>' + JSON.stringify(data))
})
},2000)
}
onBackground() {
......
......@@ -850,158 +850,6 @@ export default function abilityTest() {
})
})
/*
* @tc.number : ACTS_KillProcess_0100
* @tc.name : Use terminateselfwithresult to terminate ability and return result
* @tc.desc : Starting mainability3 with startAbilityforresult
* then terminateself ability and return result failed.(promise)
*/
it('ACTS_KillProcess_0100', 0, async function (done) {
let TAG = 'ACTS_KillProcess_0100'
var Subscriber
var flag = true
function SubscribeCallBack (err, data) {
expect(data.event == "ACTS_KillProcess").assertTrue();
console.debug(TAG + "====>ACTS_KillProcess_0100 Subscribe CallBack data:====>" + JSON.stringify(data));
appManager.getProcessRunningInfos().then((data)=> {
console.info(TAG + '====>ACTS_KillProcess_0100 getProcessRunningInfos=====>' + JSON.stringify(data))
for(var i = 0; i<data.length ;i++){
if (data[i].processName=='com.acts.killprocesshap'){
console.info(TAG + '====>has com.acts.killprocesshap=====>')
break
}
}
console.log(TAG + '====>i is:====>' + JSON.stringify(i))
if(i==data.length && data[i].processName!='com.acts.killprocesshap'){
expect().assertFail()
}
appManager.killProcessesByBundleName('com.acts.killprocesshap').then((data)=>{
console.info(TAG + '====>ACTS_KillProcess_0100 killProcessesByBundleName=====>' + JSON.stringify(data))
setTimeout(()=>{
appManager.getProcessRunningInfos().then((data)=> {
console.info(TAG + '====>ACTS_KillProcess_0100 getProcessRunningInfos2=====>' + JSON.stringify(data))
for(var i = 0; i<data.length ;i++){
if (data[i].processName=='com.acts.killprocesshap'){
expect().assertFail()
break
}
}
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
})
},15000)
})
})
}
commonEvent.createSubscriber(subscriberInfo_killprocess).then(async (data) => {
console.debug(TAG + "====>Create Subscriber====>");
data.getSubscribeInfo().then(async (SubscribeInfo)=>{
console.debug(TAG + "====>SubscribeInfo is====>" + JSON.stringify(SubscribeInfo));
Subscriber = data;
commonEvent.subscribe(Subscriber, SubscribeCallBack);
console.debug(TAG + "====>start startAbility====>");
await globalThis.abilityContext.startAbility(
{
bundleName: 'com.acts.killprocesshap',
abilityName: 'com.acts.killprocesshap.MainAbility'
}).then((data)=>{
console.debug(TAG + "====>startAbility end====>");
console.debug(TAG + "====>data is====>" + JSON.stringify(data));
})
})
})
function UnSubscribeCallback() {
console.debug(TAG + "====>UnSubscribeCallback====>");
flag = false
done();
}
function timeout() {
if(flag == true) {
expect().assertFail();
console.debug(TAG + 'ACTS_KillProcess_0100 - timeout');
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback)
}
}
setTimeout(timeout, 19500);
})
/*
* @tc.number : ACTS_KillProcess_0200
* @tc.name : Use terminateselfwithresult to terminate ability and return result
* @tc.desc : Starting mainability3 with startAbilityforresult
* then terminateself ability and return result failed.(callback)
*/
it('ACTS_KillProcess_0200', 0, async function (done) {
let TAG = 'ACTS_KillProcess_0200'
var Subscriber
var flag = true
function SubscribeCallBack (err, data) {
expect(data.event == "ACTS_KillProcess").assertTrue();
console.debug(TAG + "====>ACTS_KillProcess_0200 Subscribe CallBack data:====>" + JSON.stringify(data));
appManager.getProcessRunningInfos().then((data)=> {
console.info(TAG + '====>ACTS_KillProcess_0200 getProcessRunningInfos=====>' + JSON.stringify(data))
for(var i = 0; i<data.length ;i++){
if (data[i].processName=='com.acts.killprocesshap'){
console.info(TAG + '====>has com.acts.killprocesshap=====>')
break
}
}
console.log(TAG + '====>i is:====>' + JSON.stringify(i))
if(i==data.length && data[i].processName!='com.acts.killprocesshap'){
expect().assertFail()
}
appManager.killProcessesByBundleName('com.acts.killprocesshap',(data)=>{
console.info(TAG + '====>ACTS_KillProcess_0200 killProcessesByBundleName=====>' + JSON.stringify(data))
setTimeout(()=> {
appManager.getProcessRunningInfos().then((data) => {
console.info(TAG + '====>ACTS_KillProcess_0200 getProcessRunningInfos2=====>' + JSON.stringify(data))
for (var i = 0; i < data.length; i++) {
if (data[i].processName == 'com.acts.killprocesshap') {
expect().assertFail()
break
}
}
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
})
},15000)
})
})
}
commonEvent.createSubscriber(subscriberInfo_killprocess).then(async (data) => {
console.debug(TAG + "====>Create Subscriber====>");
data.getSubscribeInfo().then(async (SubscribeInfo)=>{
console.debug(TAG + "====>SubscribeInfo is====>" + JSON.stringify(SubscribeInfo));
Subscriber = data;
commonEvent.subscribe(Subscriber, SubscribeCallBack);
console.debug(TAG + "====>start startAbility====>");
await globalThis.abilityContext.startAbility(
{
bundleName: 'com.acts.killprocesshap',
abilityName: 'com.acts.killprocesshap.MainAbility'
}).then((data)=>{
console.debug(TAG + "====>startAbility end====>");
console.debug(TAG + "====>data is====>" + JSON.stringify(data));
})
})
})
function UnSubscribeCallback() {
console.debug(TAG + "====>UnSubscribeCallback====>");
flag = false
done();
}
function timeout() {
if(flag == true) {
expect().assertFail();
console.debug(TAG + 'ACTS_KillProcess_0200 - timeout');
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback)
}
}
setTimeout(timeout, 19500);
})
/*
* @tc.number : ACTS_ThirdPartyKillProcess_0100
* @tc.name : Use terminateselfwithresult to terminate ability and return result
......
......@@ -80,48 +80,6 @@ export default function ApiCoverTest() {
}
});
/*
* @tc.number SUB_AA_GetTopAbility_0100
* @tc.name Test getTopAbility.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_GetTopAbility_0100', 0, async function (done) {
try {
await abilityManager.getTopAbility().then((data)=>{
expect(true).assertTrue();
done();
}).catch((err)=>{
expect().assertFail()
done();
})
} catch (error) {
expect().assertFail()
done();
}
});
/*
* @tc.number SUB_AA_GetAbilityRunningInfo_0100
* @tc.name Test getAbilityRunningInfo.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_GetAbilityRunningInfo_0100', 0, async function (done) {
try {
await abilityManager.getAbilityRunningInfos().then((data)=>{
expect(true).assertTrue();
done();
}).catch((err)=>{
expect().assertFail()
done();
})
} catch (error) {
expect().assertFail()
done();
}
});
/*
* @tc.number SUB_AA_GetExtensionRunningInfos_0100
* @tc.name Test getExtensionRunningInfos.
......
......@@ -22,9 +22,7 @@ group("context") {
"actscreatemodulecontextassistone:ActsCreateModuleContextAssistOne",
"actscreatemodulecontexttest:ActsCreateModuleContextTest",
"actsfa8contexttest:ActsFa8ContextTest",
"actsfa8contexttest/module1:ActsFa8ContextModule1",
"actsfacontexttest:ActsFaContextTest",
"actsfacontexttest/module1:ActsFaContextModule1",
"actsstageappcontext:actsstageappcontext",
"actsstagecontext:actsstagecontext",
"actsstagecontexttest:ActsStageContextTest",
......
......@@ -11,8 +11,7 @@
"kits": [
{
"test-file-name": [
"ActsFa8ContextTest.hap",
"ActsFa8ContextModule1.hap"
"ActsFa8ContextTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
......
......@@ -13,10 +13,8 @@
* limitations under the License.
*/
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import { describe, it, expect } from '@ohos/hypium'
import resourceManager from '@ohos.resourceManager';
import bundle from '@ohos.bundle';
import bundleManager from '@ohos.bundle.bundleManager';
export default function actsFa8ContextTest() {
describe('ActsFa8ContextTest', function () {
......@@ -38,49 +36,5 @@ export default function actsFa8ContextTest() {
done();
})
})
/*
* @tc.number : ACTS_FA8Context_0200
* @tc.name : get resource by labelId in applicationInfo
* @tc.desc : get resource by labelId in applicationInfo
*/
it('ACTS_FA8Context_0200',0, async function (done) {
await Promise.all([
resourceManager.getResourceManager(),
bundleManager.getApplicationInfo("com.example.fa8_context", 0)
]).then(results => {
return results[0].getString(Number(results[1].labelId))
}).then(str => {
console.info("ACTS_FA8Context_0200 label: " + str)
expect(str).assertEqual("fa8_module1")
done()
}).catch(e => {
console.info("ACTS_FA8Context_0200 error: " + e)
expect().assertFail()
done()
})
})
/*
* @tc.number : ACTS_FA8Context_0300
* @tc.name : get resource by labelId in abilityInfo
* @tc.desc : get resource by labelId in abilityInfo
*/
it('ACTS_FA8Context_0300',0, async function (done) {
await Promise.all([
resourceManager.getResourceManager(),
bundle.getAbilityInfo("com.example.fa8_context", "com.example.module1.MainAbility")
]).then(results => {
return results[0].getString(Number(results[1].labelId))
}).then(str => {
console.info("ACTS_FA8Context_0300 label: " + str)
expect(str).assertEqual("fa8_module1")
done()
}).catch(e => {
console.info("ACTS_FA8Context_0300 error: " + e)
expect().assertFail()
done()
})
})
})
}
\ No newline at end of file
# Copyright (C) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_hap_assist_suite("ActsFa8ContextModule1") {
hap_profile = "./src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
ets2abc = true
certificate_profile = "../signature/openharmony_sx.p7b"
hap_name = "ActsFa8ContextModule1"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./src/main/ets/MainAbility"
}
ohos_resources("hjs_demo_resources") {
sources = [ "./src/main/resources" ]
hap_profile = "./src/main/config.json"
}
{
"app": {
"bundleName": "com.example.fa8_context",
"vendor": "example",
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 8,
"releaseType": "Release",
"target": 8
}
},
"deviceConfig": {},
"module": {
"package": "com.example.module1",
"name": ".module1",
"mainAbility": ".MainAbility",
"deviceType": [
"default",
"tablet"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "module1",
"moduleType": "feature",
"installationFree": false
},
"abilities": [
{
"orientation": "unspecified",
"formsEnabled": false,
"name": ".MainAbility",
"srcLanguage": "ets",
"srcPath": "MainAbility",
"icon": "$media:icon",
"description": "$string:MainAbility_desc",
"label": "$string:MainAbility_label",
"type": "page",
"visible": true,
"launchType": "standard"
}
],
"js": [
{
"mode": {
"syntax": "ets",
"type": "pageAbility"
},
"pages": [
"pages/index"
],
"name": ".MainAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
\ No newline at end of file
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import hilog from '@ohos.hilog';
export default {
onCreate() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'Application onCreate');
},
onDestroy() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'Application onDestroy');
},
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册