提交 ecd0c185 编写于 作者: K kirl75

“xts_系统api下库”

Signed-off-by: Nkirl75 <kirl.liu@huawei.com>
上级 ef99c709
......@@ -59,7 +59,6 @@ group("ability_runtime") {
"freeinstalltest:freeinstalltest",
"getrunningprocessinformation:getrunningprocessinformation",
"newwant:newwant",
"non_concurrent:non_concurrent",
"registerjserror:registerjserror",
"shareextensionability:actsshareextensionability",
"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("non_concurrent") {
testonly = true
if (is_standard_system) {
deps = [
"acts_systemappa_test:ActsSystemAppATest",
"acts_systemappone_rely_test:ActsSystemAppOneRelyHap",
]
}
}
{
"app": {
"bundleName": "com.acts.abilitypermissiontest",
"vendor": "huawei",
"versionCode": 1000000,
"versionName": "1.0.0",
"debug": false,
"icon" : "$media:icon",
"label" : "$string:app_name",
"description" : "$string:description_application",
"distributedNotificationEnabled": true,
"keepAlive" : true,
"singleUser": true,
"minAPIVersion": 8,
"targetAPIVersion": 8,
"car": {
"apiCompatibleVersion": 8,
"singleUser": false
}
}
}
\ No newline at end of file
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsSystemAppATest") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":actssystemappatest_js_assets",
":actssystemappatest_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsSystemAppATest"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("actssystemappatest_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("actssystemappatest_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("actssystemappatest_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":actssystemappatest_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "300000",
"bundle-name": "com.acts.abilitypermissiontest",
"module-name": "com.acts.abilitypermissiontest",
"shell-timeout": "600000",
"testcase-timeout": 70000
},
"kits": [
{
"test-file-name": [
"ActsSystemAppATest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"remount"
]
},
{
"type": "PushKit",
"push": [
"ActsSystemAppATest.hap->/system/app/ActsSystemAppATest.hap"
]
},
{
"type": "ShellKit",
"run-command": [
"acm create -n 101 -t normal",
"acm switch -i 101"
]
},
{
"type": "PushKit",
"push": [
"ActsSystemAppOneRelyHap.hap->/system/app/ActsSystemAppOneRelyHap.hap"
]
},
{
"test-file-name": [
"ActsSystemAppOneRelyHap.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"acm switch -i 100"
]
},
{
"type": "ShellKit",
"run-command": [
"chmod 644 /data/*.hap"
]
}
]
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityStage from "@ohos.app.ability.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("MyAbilityStage onCreate")
globalThis.stageOnCreateRun = 1;
globalThis.stageContext = this.context;
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Ability from '@ohos.app.ability.UIAbility'
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
// Ability is creating, initialize resources for this ability
console.log("MainAbility onCreate")
globalThis.abilityWant = want;
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("MainAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("MainAbility onWindowStageCreate")
globalThis.abilityContext = this.context
windowStage.setUIContent(this.context, "MainAbility/pages/index/index", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("MainAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("MainAbility onForeground")
}
onBackground() {
// Ability has back to background
console.log("MainAbility onBackground")
}
};
/*
* Copyright (c) 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';
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../../../test/List.test'
@Entry
@Component
struct Index {
aboutToAppear() {
console.info("start run testcase!!!!")
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('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.
*/
@Entry
@Component
struct Index {
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('页面2')
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import router from '@system.router';
@Entry
@Component
struct Second {
private content: string = "Second Page"
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text(`${this.content}`)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('back to index')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.onClick(() => {
router.back()
})
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Ability from '@ohos.app.ability.UIAbility'
import commonEvent from '@ohos.commonEvent'
function PublishCallBackOne1() {
console.debug("====>Publish CallBack ACTS_ThirdPartyAbilityPermission_0100_CommonEvent====>");
globalThis.ability2Context.terminateSelf();
console.debug("====>close this context====>")
}
export default class MainAbility2 extends Ability {
onCreate(want, launchParam) {
console.log("MainAbility2 onCreate")
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("MainAbility2 onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("MainAbility2 onWindowStageCreate")
windowStage.setUIContent(this.context, "MainAbility/pages/index/index2", null)
globalThis.ability2Context = this.context;
commonEvent.publish("ACTS_AbilityPermission_0100_Start_CommonEvent", PublishCallBackOne1);
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("MainAbility2 onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("MainAbility2 onForeground")
}
onBackground() {
// Ability has back to background
console.log("MainAbility2 onBackground")
}
};
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Ability from '@ohos.app.ability.UIAbility'
export default class TestAbility extends Ability {
onCreate(want, launchParam) {
console.log('TestAbility onCreate')
}
onDestroy() {
console.log('TestAbility onDestroy')
}
onWindowStageCreate(windowStage) {
console.log('TestAbility onWindowStageCreate')
windowStage.loadContent("TestAbility/pages/index", (err, data) => {
if (err.code) {
console.error('Failed to load the content. Cause:' + JSON.stringify(err));
return;
}
console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data))
});
globalThis.abilityContext = this.context;
}
onWindowStageDestroy() {
console.log('TestAbility onWindowStageDestroy')
}
onForeground() {
console.log('TestAbility onForeground')
}
onBackground() {
console.log('TestAbility onBackground')
}
};
\ No newline at end of file
/*
* Copyright (c) 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('TestAbility index aboutToAppear')
}
@State message: string = 'Hello World'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('next page')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width('35%')
.height('5%')
.onClick(()=>{
})
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import TestRunner from '@ohos.application.testRunner'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
var abilityDelegator = undefined
var abilityDelegatorArguments = undefined
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s it',
'-s level', '-s testType', '-s size', '-s timeout',
'-s dryRun'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams = `${targetParams} ${key} ${parameters[key]}`
}
}
return targetParams.trim()
}
async function onAbilityCreateCallback() {
console.log("onAbilityCreateCallback");
}
async function addAbilityMonitorCallback(err: any) {
console.info("addAbilityMonitorCallback : " + JSON.stringify(err))
}
export default class OpenHarmonyTestRunner implements TestRunner {
constructor() {
}
onPrepare() {
console.info("OpenHarmonyTestRunner OnPrepare ")
}
async onRun() {
console.log('OpenHarmonyTestRunner onRun run')
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility'
let lMonitor = {
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
var cmd = 'aa start -d 0 -a com.acts.abilitypermissiontest.MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters)
var debug = abilityDelegatorArguments.parameters["-D"]
if (debug == 'true')
{
cmd += ' -D'
}
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd,
(err: any, d: any) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + d.stdResult);
console.info('executeShellCommand : data : ' + d.exitCode);
})
console.info('OpenHarmonyTestRunner onRun end')
}
};
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// @ts-nocheck
import osaccount from '@ohos.account.osAccount'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium"
import commonEvent from '@ohos.commonEvent'
var AbilityPermission1 = {
events: ["ACTS_AbilityPermission_0100_Start_CommonEvent"]
}
var AbilityPermission3 = {
events: ["ACTS_AbilityPermission_0300_Start_CommonEvent"]
}
var AbilityPermission6 = {
events: ["ACTS_AbilityPermission_0600_Start_CommonEvent"]
}
const START_ABILITY_TIMEOUT = 3000;
export default function abilityPermissionTest() {
describe('ActsAbilityPermissionTest', function () {
var osAccountManager = osaccount.getAccountManager();
var userA;
var userB;
beforeAll(async function(done){
osAccountManager.getOsAccountLocalIdFromProcess().then((data)=>{
userA = data
userB=userA+1
console.log("userA=====>"+userA)
done()
});
})
afterAll(async function(done){
await osAccountManager.removeOsAccount(userB, (err)=>{
console.debug("====>remove localId: " + userB + " err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
done();
})
})
/*
* @tc.number: ACTS_AbilityPermission_0100
* @tc.name: In non-concurrent mode, if the target application is not the current user, it is forbidden to start
* @tc.desc: Start an ability that belongs to the current user with the current user
*/
it('ACTS_AbilityPermission_0100', 0, async function (done) {
console.log("ACTS_AbilityPermission_0100====>callback start====>")
var Subscriber;
var flag = true;
function SubscribeCallBack(err, data) {
console.debug("ACTS_AbilityPermission_0100====>Subscribe CallBack data:====>" + JSON.stringify(data));
expect(data.event == 'ACTS_AbilityPermission_0100_Start_CommonEvent').assertTrue()
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
}
commonEvent.createSubscriber(AbilityPermission1).then(async (data) => {
console.debug("ACTS_AbilityPermission_0100====>Create Subscriber====>");
Subscriber = data;
commonEvent.subscribe(Subscriber, SubscribeCallBack);
console.debug("====>start startAbility_100====>");
await globalThis.abilityContext.startAbilityWithAccount(
{
bundleName: 'com.acts.abilitypermissiontest',
abilityName: 'com.acts.abilitypermissiontest.MainAbility2'
}, userA, () => {
console.debug("====>startAbility end_100====>");
})
})
function UnSubscribeCallback() {
flag = false
console.debug("ACTS_AbilityPermission_0100====>UnSubscribe CallBack====>"+flag);
done();
}
setTimeout(()=>{
if (flag == true) {
expect().assertFail();
console.debug('in ACTS_AbilityPermission_0100====>timeout====>'+flag);
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback)
}
console.debug('ACTS_AbilityPermission_0100====>timeout====>');
}, START_ABILITY_TIMEOUT);
})
/*
* @tc.number: ACTS_AbilityPermission_0300
* @tc.name: In non-concurrent mode, if the target application is not the current user, it is forbidden to start
* @tc.desc: Start an ability under user U101 with the current user
*/
it('ACTS_AbilityPermission_0300', 0, async function (done) {
console.log("ACTS_AbilityPermission_0300====>callback start====>")
var Subscriber
var flag = 0;
console.debug("====>get AccountManager finish====");
function SubscribeCallBack(err, data) {
console.debug("ACTS_AbilityPermission_0300====>Subscribe CallBack data:====>" + JSON.stringify(data));
expect(data.event == 'ACTS_AbilityPermission_0300_Start_CommonEvent').assertTrue()
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback)
}
commonEvent.createSubscriber(AbilityPermission3).then(async (data) => {
console.debug("ACTS_AbilityPermission_0300====>Create Subscriber====>");
Subscriber = data;
commonEvent.subscribe(Subscriber, SubscribeCallBack);
console.debug("====>start startAbility_0300====>");
await globalThis.abilityContext.startAbilityWithAccount(
{
bundleName: 'com.acts.systemapponerely',
abilityName: 'com.acts.systemapponerely.MainAbility'
}, userA ).then().catch((err) => {
console.debug("ACTS_AbilityPermission_0300====>" + err)
console.debug("====>startAbility end_0300====>");
})
})
function UnSubscribeCallback() {
if(flag == 0) {
expect().assertFail();
}
console.debug("ACTS_AbilityPermission_0300====>UnSubscribe CallBack====>");
done();
}
function timeout() {
console.debug('ACTS_AbilityPermission_0300====>timeout====>');
if(flag == 0){
flag = 1;
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback)
}
}
setTimeout(timeout, START_ABILITY_TIMEOUT);
})
/*
* @tc.number: ACTS_AbilityPermission_0600
* @tc.name: In non-concurrent mode, if the target application is not the current user, it is forbidden to start
* @tc.desc: Bind a U101 Ability with the current user
*/
it('ACTS_AbilityPermission_0600', 0, async function (done) {
console.log("ACTS_AbilityPermission_0600====>callback start====>")
let Subscriber
let connId
function onConnectCallbackC(element, remote) {
console.log('ACTS_AbilityPermission_0600_Start_CommonEvent onConnectCallback====> element=' + JSON.stringify(element));
console.log('ACTS_AbilityPermission_0600_Start_CommonEvent onConnectCallback====> remote=' + JSON.stringify(remote));
expect().assertFail();
}
function onDisconnectCallbackC(element) {
console.log('onDisconnectCallback====> element=' + JSON.stringify(element));
}
function onFailedCallbackC(code) {
console.log('onFailedCallback====> code=' + JSON.stringify(code))
}
function SubscribeCallBackF(err, data) {
console.debug("====>0600 Subscribe CallBack data:====>" + JSON.stringify(data));
}
function UnSubscribeCallbackF() {
console.debug("====>UnSubscribeCallback====>");
}
commonEvent.createSubscriber(AbilityPermission6).then(async (data) => {
console.debug("====>Create Subscriber====>");
Subscriber = data;
commonEvent.subscribe(Subscriber, SubscribeCallBackF);
})
console.debug("====>0600start connectAbility====>");
connId = await globalThis.abilityContext.connectAbilityWithAccount(
{
bundleName: 'com.acts.systemapponerely',
abilityName: 'com.acts.systemapponerely.ServiceAbility',
action: "StartAbilityPromise"
}, userA, {
onConnect: onConnectCallbackC,
onDisconnect: onDisconnectCallbackC,
onFailed: onFailedCallbackC
})
console.debug("====>number is====>" + JSON.stringify(connId));
setTimeout(() =>{
console.debug('in ACTS_AbilityPermission_0600_Start_CommonEvent timeout');
commonEvent.unsubscribe(Subscriber, UnSubscribeCallbackF)
done()
}, START_ABILITY_TIMEOUT);
})
})
}
\ 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 abilityPermissionText from './AbilityPermission.test.ets'
export default function testsuite() {
abilityPermissionText()
}
\ No newline at end of file
{
"module": {
"name": "com.acts.abilitypermissiontest",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"abilities": [
{
"name": "com.acts.abilitypermissiontest.MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"skills": [
{
"actions": [
"action.system.home"
],
"entities": [
"entity.system.home"
]
}
]
},
{
"name": "com.acts.abilitypermissiontest.MainAbility2",
"srcEntrance": "./ets/MainAbility2/MainAbility2.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"skills": [
{
"actions": [
"action.system.home"
],
"entities": [
"entity.system.home"
]
}
]
}
],
"requestPermissions": [
{
"name":"ohos.permission.CLEAN_BACKGROUND_PROCESSES",
"reason":"need use ohos.permission.CLEAN_BACKGROUND_PROCESSES"
},
{
"name":"ohos.permission.GET_BUNDLE_INFO",
"reason":"need use ohos.permission.GET_BUNDLE_INFO"
}
]
}
}
{
"string": [
{
"name": "phone_entry_dsc",
"value": "i am an entry for phone"
},
{
"name": "phone_entry_main",
"value": "the phone entry ability"
},
{
"name": "entry_label",
"value": "ActsContextTest"
},
{
"name": "form_description",
"value": "my form"
},
{
"name": "serviceability_description",
"value": "my whether"
},
{
"name": "description_application",
"value": "demo for test"
},
{
"name": "app_name",
"value": "Demo"
}
]
}
\ No newline at end of file
{
"src": [
"MainAbility/pages/index/index",
"MainAbility/pages/second/second"
]
}
\ No newline at end of file
{
"app": {
"bundleName": "com.acts.pmvendorappa",
"vendor": "huawei",
"versionCode": 1000000,
"versionName": "1.0.0",
"debug": false,
"icon" : "$media:icon",
"label" : "$string:app_name",
"description" : "$string:description_application",
"distributedNotificationEnabled": true,
"keepAlive" : true,
"singleUser": true,
"minAPIVersion": 8,
"targetAPIVersion": 8,
"car": {
"apiCompatibleVersion": 8,
"singleUser": false
}
}
}
\ No newline at end of file
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_hap_assist_suite("ActsSystemAppOneRelyHap") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
hap_name = "ActsSystemAppOneRelyHap"
testonly = true
deps = [
":acts_systemappone_rely_test_js_assets",
":acts_systemappone_rely_test_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("acts_systemappone_rely_test_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("acts_systemappone_rely_test_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("acts_systemappone_rely_test_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":acts_systemappone_rely_test_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityStage from "@ohos.app.ability.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("MyAbilityStage onCreate")
globalThis.stageOnCreateRun = 1;
globalThis.stageContext = this.context;
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Ability from '@ohos.app.ability.UIAbility'
import commonEvent from '@ohos.commonEvent'
function PublishCallBackOne3() {
console.debug("====>Publish CallBack ACTS_StartAbility_0300_CommonEvent====>");
setTimeout(globalThis.abilityContext.terminateSelfWithResult(()=>{
console.debug("====>terminateSelfWithResult succese====>")
}),1000)
}
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
// Ability is creating, initialize resources for this ability
console.log("MainAbility onCreate")
globalThis.abilityWant = want;
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("MainAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("MainAbility onWindowStageCreate")
globalThis.abilityContext = this.context
commonEvent.publish("ACTS_AbilityPermission_0300_Start_CommonEvent", PublishCallBackOne3);
windowStage.setUIContent(this.context, "pages/index/index", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("MainAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("MainAbility onForeground")
}
onBackground() {
// Ability has back to background
console.log("MainAbility onBackground")
}
};
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import router from '@system.router';
async function routePage() {
let options = {
uri: 'pages/second'
}
try {
await router.push(options)
} catch (err) {
console.error(`fail callback, code: ${err.code}, msg: ${err.msg}`)
}
}
@Entry
@Component
struct Index {
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 router from '@system.router';
@Entry
@Component
struct Second {
private content: string = "Second Page"
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text(`${this.content}`)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('back to index')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.onClick(() => {
router.back()
})
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
{
"module": {
"name": "com.acts.systemapponerely",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"abilities": [
{
"name": "com.acts.systemapponerely.MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"skills": [
{
"actions": [
"action.system.home"
],
"entities": [
"entity.system.home"
]
}
]
}
]
}
}
{
"string": [
{
"name": "phone_entry_dsc",
"value": "i am an entry for phone"
},
{
"name": "phone_entry_main",
"value": "the phone entry ability"
},
{
"name": "entry_label",
"value": "ActsContextTest"
},
{
"name": "form_description",
"value": "my form"
},
{
"name": "serviceability_description",
"value": "my whether"
},
{
"name": "description_application",
"value": "demo for test"
},
{
"name": "app_name",
"value": "Demo"
}
]
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册