提交 e54c1884 编写于 作者: C chensi10

Merge branch 'master' of https://gitee.com/openharmony/xts_acts

Signed-off-by: Nchensi10 <chensi52@huawei.com>
......@@ -30,6 +30,7 @@ group("ability_runtime") {
"actsdataabilityaccessdatasharetest:dataabilityaccessdatashare",
"actsfwkdataaccessortest:dataability",
"actsqueryfunctiontest:actsqueryfunctiontest",
"actsrequestdialogtest:actsrequestdialogtest",
"actsserviceabilityclienttest:serviceability",
"actsshellcommandfunctionalitytest:actsshellcommandfunctionalitytest",
"actsstartrunnertest:ActsStartRunnerTest",
......@@ -43,6 +44,7 @@ group("ability_runtime") {
"amsgetabilityprocessinfo:amsgetabilityprocessinfo",
"apicover:apicover",
"apitest:ActsApiTest",
"apprecovery:apprecovery",
"context:context",
"fa:fa",
"faapicover:faapicover",
......
......@@ -83,7 +83,7 @@ export default function ActsAmsCallBackFourthScene() {
},
}, (error, data) => {
console.info('ActsAmsCallBackFourthScene SimulateEntryAbilityFir start, error.code \
' + error.code + ', data length [' + data.length + ']');
' + error.code + ', data length [' + data?.length + ']');
}
);
sleep(500);
......
# 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("actsrequestdialogtest") {
testonly = true
if (is_standard_system) {
deps = [ "actsrequestdialog:ActsRequestDialogTest" ]
}
}
{
"app":{
"bundleName":"com.acts.example.requestdialog",
"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":9,
"targetAPIVersion":9,
"car":{
"apiCompatibleVersion":9,
"singleUser":false
}
}
}
{
"string":[
{
"name":"app_name",
"value":"ohosProject"
}
]
}
\ 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("ActsRequestDialogTest") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":actsrequestdialog_js_assets",
":actsrequestrecent_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsRequestDialogTest"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("actsrequestdialog_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("actsrequestdialog_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("actsrequestrecent_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":actsrequestdialog_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "180000",
"bundle-name": "com.acts.example.requestdialog",
"module-name": "phone",
"shell-timeout": "600000",
"testcase-timeout": 70000
},
"kits": [
{
"test-file-name": [
"ActsRequestDialogTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"remount",
"mkdir /data/test"
]
},
{
"type": "PushKit",
"push": [
"ActsRequestDialogTest.hap->/data/test/ActsRequestDialogTest.hap"
]
},
{
"type": "ShellKit",
"run-command": [
"chmod 644 /data/test/*.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.stageContext = this.context;
}
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Ability from '@ohos.app.ability.UIAbility'
export default class MainAbility extends Ability {
onCreate(want,launchParam){
// Ability is creating, initialize resources for this ability
console.log("MainAbility onCreate");
globalThis.abilityWant = want;
globalThis.abilityContext = this.context;
globalThis.applicationContext = this.context.getApplicationContext();
globalThis.requestDialogSuccess = false;
globalThis.validRequestInfo = false;
globalThis.validRequestCallback = false;
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("MainAbility onDestroy");
globalThis.applicationContext.killAllProcesses().then((data)=>{
console.log(`MainAbility getRunningProcessInformation data ${JSON.stringify(data)}`);
}).catch((err)=>{
console.log(`MainAbility getRunningProcessInformation err ${JSON.stringify(err)}`);
})
globalThis.applicationContext.killAllProcesses((err, data)=>{
console.log(`MainAbility getRunningProcessInformation data ${JSON.stringify(data)}
err: ${JSON.stringify(err)}`);
})
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("MainAbility onWindowStageCreate");
windowStage.setUIContent(this.context, "MainAbility/pages/index/index", null)
}
onWindowStageDestroy() {
//Main window is destroyed, release UI related resources
console.log("MainAbility onWindowStageDestroy");
}
onForeground() {
// Ability has brought to foreground
console.log("MainAbility onForeground");
}
onBackground() {
// Ability has back to background
console.log("MainAbility onBackground");
}
};
\ No newline at end of file
/*
* Copyright (c) 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'
var testTime = 0;
@Entry
@Component
struct Index {
aboutToAppear(){
console.info("start run testcase!!!!")
if(testTime++==0){
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)
Button() {
Text('next page')
.fontSize(25)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.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 router from '@system.router';
@Entry
@Component
struct Second {
private content: string = "Second Page"
build() {
Flex({ direction: FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text(`${this.content}`)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('back to index')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.onClick(() => {
router.back()
})
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Ability from '@ohos.app.ability.UIAbility'
import commonEvent from '@ohos.commonEvent'
import dialogRequest from '@ohos.app.ability.dialogRequest'
async function publishEvent() {
var event = 'ACTS_REQUEST_DIALOG_EVENT1';
var commonEventPublishData = {
parameters: {
instanceCount: 1,
}
};
commonEvent.publish(event, commonEventPublishData, () => {
console.log('============>publish event success.==========>>')
});
}
export default class MainAbility2 extends Ability {
onCreate(want, launchParam) {
// Ability is creating, initialize resources for this ability
console.log("MainAbility2 onCreate");
globalThis.abilityWant2 = want;
globalThis.requestDialogSuccess = true;
try {
let requestInfo = dialogRequest.getRequestInfo(want);
if (requestInfo) {
globalThis.validRequestInfo = true;
console.log("MainAbility2 requestInfo is valid");
} else {
console.log("MainAbility2 requestInfo is invalid");
}
let requestCallback = dialogRequest.getRequestCallback(want);
if (requestCallback) {
console.log("MainAbility2 requestCallback is valid");
globalThis.validRequestCallback = true;
let resultCode = {
result : dialogRequest.ResultCode.RESULT_CANCEL,
};
let resultCode2 ={
result : dialogRequest.ResultCode.RESULT_OK,
};
console.log(`resultCjode2 is ${JSON.stringify(resultCode2)}`);
requestCallback.setRequestResult(resultCode);
} else {
console.log("MainAbility2 requestCallback is invalid");
}
publishEvent();
} catch {
console.log("MainAbility2 testRequest fail");
}
console.log("AbilityMultiInstanceAppA abilityWant = " + JSON.stringify( globalThis.abilityWant2));
}
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")
globalThis.abilityContext2 = this.context;
windowStage.setUIContent(this.context, "MainAbility/pages/second/second", 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 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.example.requestdialog.MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName;
cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters);
var debug = abilityDelegatorArguments.parameters["-D"];
if (debug == 'true')
{
cmd += ' -D'
}
console.info('cmd : '+cmd);
abilityDelegator.executeShellCommand(cmd,
(err: any, d: any) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + d.stdResult);
console.info('executeShellCommand : data : ' + d.exitCode);
})
console.info('OpenHarmonyTestRunner onRun end');
}
};
\ No newline at end of file
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { describe, it, expect } from "@ohos/hypium"
import commonEvent from '@ohos.commonEvent'
var subscriberInfo = {
events: ["ACTS_REQUEST_DIALOG_EVENT1", "ACTS_REQUEST_DIALOG_EVENT2"]
};
const CASE_TIMEOUT = 3000;
console.info("====>in Ability.test====>");
export default function abilityTest() {
describe('ActsRequestDialogTest', function () {
console.info("====>in ActsRequestDialogTest====>");
function sleep(time) {
return new Promise((resolve) => setTimeout(resolve, time));
}
/*
* @tc.number: ACTS_requestDialog_0100
* @tc.name: Start Recent Ability with no permission.
* @tc.desc: reguest dialog service
*/
it('ACTS_requestDialog_0100', 0, async function (done) {
console.log('ACTS_requestDialog_0100====<begin');
var subscriber;
let id;
let resultCode;
async function subscribeCallBack(err, data) {
console.info("====>ACTS_requestDialog_0100 Subscribe CallBack data:====>" + JSON.stringify(data));
async function processInfoCheck(data) {
console.info('====> ACTS_requestDialog_0100 processInfoCheck=====>');
expect(globalThis.requestDialogSuccess).assertTrue();
expect(globalThis.validRequestInfo).assertTrue();
expect(globalThis.validRequestCallback).assertTrue();
commonEvent.unsubscribe(subscriber, unSubscribeCallback);
done();
}
if (data.event == "ACTS_REQUEST_DIALOG_EVENT1") {
console.info('====> ACTS_startRecent_0100 ACTS_StartAbility_CommonEvent1 success=====>');
await sleep(500);
processInfoCheck(data);
}
}
commonEvent.createSubscriber(subscriberInfo).then(async (data) => {
console.info("====>ACTS_requestDialog_0100 Create Subscriber====>");
subscriber = data;
commonEvent.subscribe(subscriber, subscribeCallBack);
try {
await globalThis.abilityContext.requestDialogService(
{
bundleName: 'com.acts.example.requestdialog',
abilityName: 'com.acts.example.requestdialog.MainAbility2',
}).then((data) => {
console.info("====>ACTS_requestDialog_0100 request end + data:" + JSON.stringify(data));
resultCode = data.result;
})
} catch (paramError) {
console.info("====>ACTS_requestDialog_0100 requestDialogSerivce paramError====>");
}
})
function unSubscribeCallback() {
console.info("====>UnSubscribe0100 CallBack====>");
}
function timeout() {
console.log('ACTS_requestDialog_0100 timeout.');
done();
}
id = setTimeout(timeout, CASE_TIMEOUT);
console.log('Start ACTS_requestDialog_0100 timer id : ' + id);
})
})
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import abilityTest from './Ability.test.ets'
export default function testsuite() {
abilityTest()
}
\ No newline at end of file
{
"module": {
"name": "phone",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"abilities": [
{
"name": "com.acts.example.requestdialog.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.example.requestdialog.MainAbility2",
"srcEntrance": "./ets/MainAbility2/MainAbility2.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"launchType":"standard",
"orientation": "portrait"
}
]
}
}
\ No newline at end of file
{
"string": [
{
"name": "phone_entry_dsc",
"value": "i am an entry for phone"
},
{
"name": "phone_entry_main",
"value": "the phone entry ability"
},
{
"name": "entry_label",
"value": "ActsContextTest"
},
{
"name": "form_description",
"value": "my form"
},
{
"name": "serviceability_description",
"value": "my whether"
},
{
"name": "description_application",
"value": "demo for test"
},
{
"name": "app_name",
"value": "Demo"
}
]
}
{
"src": [
"MainAbility/pages/index/index",
"MainAbility/pages/second/second"
]
}
\ No newline at end of file
......@@ -12,16 +12,13 @@
* 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 { describe, afterEach, it, expect } from '@ohos/hypium'
import formProvider from '@ohos.application.formProvider';
import FormInfo from '@ohos.application.formInfo';
import formInfoNew from '@ohos.app.form.formInfo';
import formError from '@ohos.application.formError';
import formHost from '@ohos.application.formHost';
import errorManager from '@ohos.app.ability.errorManager';
import abilityConstant from '@ohos.app.ability.AbilityConstant'
import appManager from '@ohos.application.appManager'
import appManagerNew from '@ohos.app.ability.appManager'
import commonEvent from '@ohos.commonEvent';
import ability from '@ohos.ability.ability';
......@@ -29,12 +26,11 @@ import abilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry
import common from '@ohos.app.ability.common';
import contextConstant from "@ohos.app.ability.contextConstant"
var EXTENSION_INFO_ERR = 16000001
var INNER_ERROR = 16000050
var CROSS_USER_DENY = 201
var INVALID_PARAM = 401
var trueInfo;
var array = new Array();
let EXTENSION_INFO_ERR = 16000001;
let INNER_ERROR = 16000050;
let CROSS_USER_DENY = 201;
let array = new Array();
let TAG = '';
function sleep(time) {
return new Promise((resolve)=>setTimeout(resolve,time));
}
......@@ -661,5 +657,115 @@ export default function ApiCoverTest() {
done()
})
})
/*
* @tc.number SUB_AA_AbilityAppManager_0100
* @tc.name The form of a promise getRunningProcessInformation
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_AbilityAppManager_0100', 0, async function (done) {
TAG = 'SUB_AA_AbilityAppManager_0100';
await appManagerNew.getRunningProcessInformation().then((data)=>{
console.log(`${TAG} getRunningProcessInformation data ${JSON.stringify(data.length)}`);
for (let i = 0; i < data.length; i++) {
console.log(`${TAG} getRunningProcessInformation${i} : JSON.stringify(data[i])`);
expect(typeof (data[i].pid)).assertEqual("number");
expect(data[i].pid).assertLarger(0);
expect(typeof (data[i].uid)).assertEqual("number");
expect(data[i].uid).assertLarger(0);
expect(typeof (data[i].processName)).assertEqual("string");
expect(data[i].processName.length).assertLarger(0);
expect(Array.isArray(data[i].bundleNames)).assertEqual(true);
expect(data[i].bundleNames.length).assertLarger(0);
}
done();
}).catch((err)=>{
console.log(`${TAG} getRunningProcessInformation err ${JSON.stringify(err)}`);
expect().assertFail();
done();
})
})
/*
* @tc.number SUB_AA_AbilityAppManager_0200
* @tc.name The form of a callback getRunningProcessInformation
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_AbilityAppManager_0200', 0, async function (done) {
TAG = 'SUB_AA_AbilityAppManager_0100';
appManagerNew.getRunningProcessInformation((err, data) => {
console.log(`${TAG} getRunningProcessInformation data ${JSON.stringify(data.length)}
err: ${JSON.stringify(err)}`);
for (let i = 0; i < data.length; i++) {
console.log(`${TAG} getRunningProcessInformation${i} : JSON.stringify(data[i])`);
expect(typeof (data[i].pid)).assertEqual("number");
expect(data[i].pid).assertLarger(0);
expect(typeof (data[i].uid)).assertEqual("number");
expect(data[i].uid).assertLarger(0);
expect(typeof (data[i].processName)).assertEqual("string");
expect(data[i].processName.length).assertLarger(0);
expect(Array.isArray(data[i].bundleNames)).assertEqual(true);
expect(data[i].bundleNames.length).assertLarger(0);
}
done();
})
})
/*
* @tc.number SUB_AA_ApplicationContext_0100
* @tc.name The form of a promise getRunningProcessInformation
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_ApplicationContext_0100', 0, async function (done) {
TAG = 'SUB_AA_ApplicationContext_0100';
await globalThis.applicationContext.getRunningProcessInformation().then((data)=>{
console.log(`${TAG} getRunningProcessInformation data ${JSON.stringify(data.length)}`);
for (let i = 0; i < data.length; i++) {
console.log(`${TAG} getRunningProcessInformation${i} : JSON.stringify(data[i])`);
expect(typeof (data[i].pid)).assertEqual("number");
expect(data[i].pid).assertLarger(0);
expect(typeof (data[i].uid)).assertEqual("number");
expect(data[i].uid).assertLarger(0);
expect(typeof (data[i].processName)).assertEqual("string");
expect(data[i].processName.length).assertLarger(0);
expect(Array.isArray(data[i].bundleNames)).assertEqual(true);
expect(data[i].bundleNames.length).assertLarger(0);
}
done();
}).catch((err)=>{
console.log(`${TAG} getRunningProcessInformation err ${JSON.stringify(err)}`);
expect().assertFail();
done();
})
})
/*
* @tc.number SUB_AA_ApplicationContext_0200
* @tc.name The form of a callback getRunningProcessInformation
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_ApplicationContext_0200', 0, async function (done) {
TAG = 'SUB_AA_ApplicationContext_0200';
globalThis.applicationContext.getRunningProcessInformation((err, data) => {
console.log(`${TAG} getRunningProcessInformation data ${JSON.stringify(data.length)}
err: ${JSON.stringify(err)}`);
for (let i = 0; i < data.length; i++) {
console.log(`${TAG} getRunningProcessInformation${i} : JSON.stringify(data[i])`);
expect(typeof (data[i].pid)).assertEqual("number");
expect(data[i].pid).assertLarger(0);
expect(typeof (data[i].uid)).assertEqual("number");
expect(data[i].uid).assertLarger(0);
expect(typeof (data[i].processName)).assertEqual("string");
expect(data[i].processName.length).assertLarger(0);
expect(Array.isArray(data[i].bundleNames)).assertEqual(true);
expect(data[i].bundleNames.length).assertLarger(0);
}
done();
})
})
})
}
......@@ -67,8 +67,10 @@ export default function verificationTest(){
console.info(TAG + "startAbility data = " + JSON.stringify(data));
}).catch((err) => {
console.info(TAG + "startAbility err = " + JSON.stringify(err));
expect().assertFail();
done();
if (err.code != 16000017) {
expect().assertFail();
done();
}
});
} catch (err) {
console.info(TAG + "catch err = " + JSON.stringify(err));
......@@ -130,8 +132,10 @@ export default function verificationTest(){
console.info(TAG + "startAbility data = " + JSON.stringify(data));
}).catch((err) => {
console.info(TAG + "startAbility err = " + JSON.stringify(err));
expect().assertFail();
done();
if (err.code != 16000017) {
expect().assertFail();
done();
}
});
} catch (err) {
console.info(TAG + "catch err = " + JSON.stringify(err));
......@@ -207,8 +211,10 @@ export default function verificationTest(){
console.info(TAG + "startAbility data = " + JSON.stringify(data));
}).catch((err) => {
console.info(TAG + "startAbility err = " + JSON.stringify(err));
expect().assertFail();
done();
if (err.code != 16000017) {
expect().assertFail();
done();
}
});
} catch (err) {
console.info(TAG + "catch err = " + JSON.stringify(err));
......@@ -263,8 +269,10 @@ export default function verificationTest(){
console.info(TAG + "startAbility data = " + JSON.stringify(data));
}).catch((err) => {
console.info(TAG + "startAbility err = " + JSON.stringify(err));
expect().assertFail();
done();
if (err.code != 16000017) {
expect().assertFail();
done();
}
});
} catch (err) {
console.info(TAG + "catch err = " + JSON.stringify(err));
......@@ -365,8 +373,10 @@ export default function verificationTest(){
console.info(TAG + "startAbility data = " + JSON.stringify(data) + ";" + JSON.stringify(data));
}).catch((err) => {
console.info(TAG + "startAbility err = " + JSON.stringify(err));
expect().assertFail();
done();
if (err.code != 16000017) {
expect().assertFail();
done();
}
});
} catch (err) {
console.info(TAG + "catch err = " + JSON.stringify(err));
......
......@@ -14,6 +14,7 @@
*/
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import wantAgent from '@ohos.app.ability.wantAgent';
import wantConstant from '@ohos.app.ability.wantConstant'
var TAG
export default function wantAgentCoverTest() {
......@@ -60,6 +61,8 @@ export default function wantAgentCoverTest() {
});
setTimeout(() => {
expect(wantConstant.Params.ABILITY_BACK_TO_OTHER_MISSION_STACK)
.assertEqual('ability.params.backToOtherMissionStack');
expect(status).assertTrue();
expect(code1).assertEqual(2);
done()
......
{
"app": {
"bundleName": "com.example.actsapprecoverytestcaller",
"vendor": "example",
"versionCode": 1000000,
"versionName": "1.0.0",
"icon": "$media:app_icon",
"label": "$string:app_name",
"distributedNotificationEnabled": true,
"keepAlive" : true,
"singleUser": true,
"minAPIVersion": 10,
"targetAPIVersion": 10,
"car": {
"apiCompatibleVersion": 10,
"singleUser": false
}
}
}
{
"string": [
{
"name": "app_name",
"value": "ActsAppRecoveryTestCaller"
}
]
}
# Copyright (c) 2023 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("ActsAppRecoveryTestCaller") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":actsapprecoverytestcaller_js_assets",
":actsapprecoverytestcaller_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsAppRecoveryTestCaller"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("actsapprecoverytestcaller_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("actsapprecoverytestcaller_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("actsapprecoverytestcaller_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":actsapprecoverytestcaller_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for aceceshi Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "600000",
"bundle-name": "com.example.actsapprecoverytestcaller",
"module-name": "entry_test",
"shell-timeout": "600000"
},
"kits": [
{
"test-file-name": [
"ActsAppRecoveryTestCaller.hap",
"AppRecoveryRely.hap",
"AppRecoverysRely.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"power-shell wakeup",
"power-shell setmode 602"
]
}
]
}
\ No newline at end of file
/*
* Copyright (c) 2023 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';
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() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'onAbilityCreateCallback');
}
async function addAbilityMonitorCallback(err: any) {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', 'addAbilityMonitorCallback : %{public}s', JSON.stringify(err) ?? '');
}
export default class OpenHarmonyTestRunner implements TestRunner {
constructor() {
}
onPrepare() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare ');
}
async onRun() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun run');
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.bundleName + '.TestAbility'
let lMonitor = {
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
var cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters)
var debug = abilityDelegatorArguments.parameters['-D']
if (debug == 'true')
{
cmd += ' -D'
}
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', 'cmd : %{public}s', cmd);
abilityDelegator.executeShellCommand(cmd,
(err: any, d: any) => {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', 'executeShellCommand : err : %{public}s', JSON.stringify(err) ?? '');
hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.stdResult ?? '');
hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.exitCode ?? '');
})
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun end');
}
}
\ No newline at end of file
/*
* Copyright (c) 2023 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
/*
* Copyright (c) 2023 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'
// import Ability from '@ohos.application.Ability'
import Ability from '@ohos.app.ability.UIAbility'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../test/List.test'
import Window from '@ohos.window'
export default class TestAbility extends Ability {
onCreate(want, launchParam) {
globalThis.abilityContext = this.context;
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onCreate');
hilog.info(0x0000, 'testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? '');
hilog.info(0x0000, 'testTag', '%{public}s', 'launchParam:'+ JSON.stringify(launchParam) ?? '');
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'start run testcase!!!');
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
onDestroy() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onDestroy');
}
onWindowStageCreate(windowStage: Window.WindowStage) {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageCreate');
windowStage.loadContent('testability/pages/Index', (err, data) => {
if (err.code) {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.ERROR);
hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
return;
}
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s',
JSON.stringify(data) ?? '');
});
}
onWindowStageDestroy() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageDestroy');
}
onForeground() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onForeground');
}
onBackground() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onBackground');
}
}
\ No newline at end of file
/*
* Copyright (c) 2023 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';
@Entry
@Component
struct Index {
aboutToAppear() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', '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
{
"module": {
"name": "entry_test",
"type": "feature",
"description": "$string:module_test_desc",
"mainElement": "TestAbility",
"deviceTypes": [
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:test_pages",
"abilities": [
{
"name": "TestAbility",
"srcEntrance": "./ets/testability/TestAbility.ets",
"description": "$string:TestAbility_desc",
"icon": "$media:icon",
"label": "$string:TestAbility_label",
"visible": true,
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:start_window_background",
"skills": [
{
"actions": [
"action.system.home"
],
"entities": [
"entity.system.home"
]
}
]
}
],
"requestPermissions": [
{
"name": "ohos.permission.START_ABILITIES_FROM_BACKGROUND"
},
{
"name": "ohos.permission.MANAGE_MISSIONS"
}
]
}
}
{
"color": [
{
"name": "start_window_background",
"value": "#FFFFFF"
}
]
}
\ No newline at end of file
{
"string": [
{
"name": "module_test_desc",
"value": "test ability description"
},
{
"name": "TestAbility_desc",
"value": "the test ability"
},
{
"name": "TestAbility_label",
"value": "test label"
}
]
}
\ No newline at end of file
{
"app": {
"bundleName": "com.example.apprecoveryrely",
"vendor": "example",
"versionCode": 1000000,
"versionName": "1.0.0",
"icon": "$media:app_icon",
"label": "$string:app_name",
"distributedNotificationEnabled": true,
"keepAlive" : true,
"singleUser": true,
"minAPIVersion": 10,
"targetAPIVersion": 10,
"car": {
"apiCompatibleVersion": 10,
"singleUser": false
}
}
}
{
"string": [
{
"name": "app_name",
"value": "AppRecoveryRely"
}
]
}
# Copyright (c) 2023 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("AppRecoveryRely") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":apprecoveryrely_js_assets",
":apprecoveryrely_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "AppRecoveryRely"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("apprecoveryrely_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("apprecoveryrely_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("apprecoveryrely_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":apprecoveryrely_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
/*
* Copyright (c) 2023 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';
import appRecovery from '@ohos.app.ability.appRecovery';
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("Maple Create");
// global switch for appRecovery function in current package
appRecovery.enableAppRecovery();
}
}
\ No newline at end of file
/*
* Copyright (c) 2023 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'
import Ability from '@ohos.app.ability.UIAbility'
import Window from '@ohos.window'
import commonEvent from '@ohos.commonEvent'
import appRecovery from '@ohos.app.ability.appRecovery'
import AbilityConstant from '@ohos.app.ability.AbilityConstant'
let message;
let commonEventData={
parameters:{
message:message,
}
}
let strAction = "";
export default class EntryAbility extends Ability {
onCreate(want, launchParam) {
globalThis.context = this.context;
strAction = want.action;
console.log(strAction + "Rely====> want:" + JSON.stringify(want));
console.log(strAction + "Rely====> launchParam:" + JSON.stringify(launchParam));
commonEventData.parameters.message = want.parameters;
}
onDestroy() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
}
onWindowStageCreate(windowStage: Window.WindowStage) {
// Main window is created, set main page for this ability
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
windowStage.loadContent('pages/Index', (err, data) => {
if (err.code) {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.ERROR);
hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
return;
}
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? '');
});
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
}
onForeground() {
// Ability has brought to foreground
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
if (strAction == "Acts_AppRecovery_0100_once" || strAction == "Acts_AppRecovery_0300_once" ||
strAction == "Acts_AppRecovery_0700_once" || strAction == "Acts_AppRecovery_0900_once" ||
strAction == "Acts_AppRecovery_1100_once") {
if (strAction == "Acts_AppRecovery_0100_once" || strAction == "Acts_AppRecovery_0300_once" ||
strAction == "Acts_AppRecovery_1100_once") {
appRecovery.saveAppState(this.context);
console.log(strAction + "Rely====> saveAppState");
} else {
console.log(strAction + "Rely====> not saveAppState");
}
setTimeout(() => {
commonEvent.publish("ACTS_AppRecovery_First",commonEventData,(err)=>{
console.log(strAction + "Rely====> publish err:" + JSON.stringify(err));
if (strAction == "Acts_AppRecovery_0100_once" ||
strAction == "Acts_AppRecovery_0700_once") {
setTimeout(()=>{
globalThis.context.terminateSelf().then(() => {
console.info(strAction + "Rely====> terminateSelf end");
}).catch((err) => {
console.info(strAction + "Rely====> terminateSelf err:" + JSON.stringify(err));
});
}, 50)
}
})
}, 200);
}
if (strAction == "Acts_AppRecovery_0100_twice" || strAction == "Acts_AppRecovery_0300_twice" ||
strAction == "Acts_AppRecovery_0700_twice" || strAction == "Acts_AppRecovery_0900_twice" ||
strAction == "Acts_AppRecovery_1100_twice") {
commonEvent.publish("ACTS_AppRecovery_Second", commonEventData, (err) => {
console.log(strAction + "Rely====> second publish err:" + JSON.stringify(err));
setTimeout(()=>{
globalThis.context.terminateSelf().then(() => {
console.info(strAction + "Rely====> terminateSelf end");
}).catch((err) => {
console.info(strAction + "Rely====> terminateSelf err:" + JSON.stringify(err));
});
}, 50)
})
}
}
onBackground() {
// Ability has back to background
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
}
onSaveState(reason, wantParam: {[key:string]: any}) {
console.log(strAction + "RelyonSaveStage====> wantParam:" + JSON.stringify(wantParam));
return AbilityConstant.OnSaveResult.RECOVERY_AGREE;
}
}
/*
* Copyright (c) 2023 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
{
"module": {
"name": "entry",
"type": "entry",
"description": "$string:module_desc",
"mainElement": "EntryAbility",
"deviceTypes": [
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"srcEntrance": "./ets/app/MyAbilityStage.ets",
"pages": "$profile:main_pages",
"abilities": [
{
"name": "EntryAbility",
"srcEntrance": "./ets/entryability/EntryAbility.ts",
"description": "$string:EntryAbility_desc",
"icon": "$media:icon",
"label": "$string:EntryAbility_label",
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:start_window_background",
"visible": true,
"recoverable": true,
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
]
}
]
}
}
\ No newline at end of file
{
"color": [
{
"name": "start_window_background",
"value": "#FFFFFF"
}
]
}
\ No newline at end of file
{
"string": [
{
"name": "module_desc",
"value": "module description"
},
{
"name": "EntryAbility_desc",
"value": "description"
},
{
"name": "EntryAbility_label",
"value": "AppRecoveryRely"
}
]
}
\ No newline at end of file
{
"string": [
{
"name": "module_desc",
"value": "module description"
},
{
"name": "EntryAbility_desc",
"value": "description"
},
{
"name": "EntryAbility_label",
"value": "AppRecoveryRely"
}
]
}
\ No newline at end of file
{
"string": [
{
"name": "module_desc",
"value": "模块描述"
},
{
"name": "EntryAbility_desc",
"value": "description"
},
{
"name": "EntryAbility_label",
"value": "AppRecoveryRely"
}
]
}
\ No newline at end of file
{
"app": {
"bundleName": "com.example.apprecoverysrely",
"vendor": "example",
"versionCode": 1000000,
"versionName": "1.0.0",
"icon": "$media:app_icon",
"label": "$string:app_name",
"distributedNotificationEnabled": true,
"keepAlive" : true,
"singleUser": true,
"minAPIVersion": 10,
"targetAPIVersion": 10,
"car": {
"apiCompatibleVersion": 10,
"singleUser": false
}
}
}
{
"string": [
{
"name": "app_name",
"value": "AppRecoverysRely"
}
]
}
# Copyright (c) 2023 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("AppRecoverysRely") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":apprecoverysrely_js_assets",
":apprecoverysrely_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "AppRecoverysRely"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("apprecoverysrely_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("apprecoverysrely_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("apprecoverysrely_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":apprecoverysrely_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
/*
* Copyright (c) 2023 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';
import appRecovery from '@ohos.app.ability.appRecovery';
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("Maple Create");
// global switch for appRecovery function in current package
appRecovery.enableAppRecovery();
}
}
\ No newline at end of file
/*
* Copyright (c) 2023 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'
import Ability from '@ohos.app.ability.UIAbility'
import Window from '@ohos.window'
import commonEvent from '@ohos.commonEvent'
import appRecovery from '@ohos.app.ability.appRecovery'
import AbilityConstant from '@ohos.app.ability.AbilityConstant'
let message;
let commonEventData={
parameters:{
message:message,
}
}
let strAction = "";
export default class EntryAbility extends Ability {
onCreate(want, launchParam) {
globalThis.contextFirst = this.context;
strAction = want.action;
console.log(strAction + "Rely1====> want:" + JSON.stringify(want));
console.log(strAction + "Rely1====> launchParam:" + JSON.stringify(launchParam));
commonEventData.parameters.message = want.parameters;
}
onDestroy() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
}
onWindowStageCreate(windowStage: Window.WindowStage) {
// Main window is created, set main page for this ability
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
windowStage.loadContent('pages/Index', (err, data) => {
if (err.code) {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.ERROR);
hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
return;
}
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? '');
});
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
}
onForeground() {
// Ability has brought to foreground
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
if (strAction == "Acts_AppRecovery_0200_once" || strAction == "Acts_AppRecovery_0400_once" ||
strAction == "Acts_AppRecovery_0800_once" ||
strAction == "Acts_AppRecovery_1000_once" || strAction == "Acts_AppRecovery_1200_once") {
if (strAction == "Acts_AppRecovery_0200_once" ||
strAction == "Acts_AppRecovery_0400_once" ||
strAction == "Acts_AppRecovery_1200_once") {
appRecovery.saveAppState(this.context);
console.log(strAction + "Rely1====> saveAppState");
} else {
console.log(strAction + "Rely1====> not saveAppState");
}
setTimeout(() => {
commonEvent.publish("ACTS_AppRecovery_First",commonEventData,(err)=>{
console.log(strAction + "Rely1====> publish err:" + JSON.stringify(err));
})
}, 200);
}
if (strAction == "Acts_AppRecovery_0200_twice" || strAction == "Acts_AppRecovery_0400_twice" ||
strAction == "Acts_AppRecovery_0800_twice" ||
strAction == "Acts_AppRecovery_1000_twice" || strAction == "Acts_AppRecovery_1200_twice") {
setTimeout(() => {
commonEvent.publish("ACTS_AppRecovery_Second", commonEventData, (err) => {
console.log(strAction + "Rely1====> second publish err:" + JSON.stringify(err));
})
}, 200);
}
this.context.startAbility({
bundleName: "com.example.apprecoverysrely",
abilityName: "EntryAbilitySec",
action: strAction
},(err) => {
console.debug(strAction + "Rely1====> startAbility err:"+JSON.stringify(err));
if (strAction == "Acts_AppRecovery_0200_once" || strAction == "Acts_AppRecovery_0200_twice" ||
strAction == "Acts_AppRecovery_0400_twice" ||
strAction == "Acts_AppRecovery_0800_once" || strAction == "Acts_AppRecovery_0800_twice" ||
strAction == "Acts_AppRecovery_1000_twice" || strAction == "Acts_AppRecovery_1200_twice") {
setTimeout(()=>{
globalThis.contextFirst.terminateSelf().then(() => {
console.info(strAction + "Rely1====> terminateSelf end");
}).catch((err) => {
console.info(strAction + "Rely1====> terminateSelf err:" + JSON.stringify(err));
});
}, 200)
}
});
}
onBackground() {
// Ability has back to background
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
}
onSaveState(reason, wantParam: {[key:string]: any}) {
console.log(strAction + "Rely1onSaveStage====> wantParam:" + JSON.stringify(wantParam));
return AbilityConstant.OnSaveResult.RECOVERY_AGREE;
}
}
/*
* Copyright (c) 2023 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'
import Ability from '@ohos.app.ability.UIAbility'
import Window from '@ohos.window'
import commonEvent from '@ohos.commonEvent'
import appRecovery from '@ohos.app.ability.appRecovery'
import AbilityConstant from '@ohos.app.ability.AbilityConstant'
let message;
let commonEventData={
parameters:{
message:message,
}
}
let strAction = "";
export default class EntryAbilitySec extends Ability {
onCreate(want, launchParam) {
globalThis.contextSecond = this.context;
strAction = want.action;
console.log(strAction + "Rely2====> want:" + JSON.stringify(want));
console.log(strAction + "Rely2====> launchParam:" + JSON.stringify(launchParam));
commonEventData.parameters.message = want.parameters;
}
onDestroy() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
}
onWindowStageCreate(windowStage: Window.WindowStage) {
// Main window is created, set main page for this ability
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
windowStage.loadContent('pages/Index_sec', (err, data) => {
if (err.code) {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.ERROR);
hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
return;
}
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? '');
});
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
}
onForeground() {
// Ability has brought to foreground
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
if (strAction == "Acts_AppRecovery_0200_once" || strAction == "Acts_AppRecovery_0400_once" ||
strAction == "Acts_AppRecovery_0800_once" ||
strAction == "Acts_AppRecovery_1000_once" || strAction == "Acts_AppRecovery_1200_once") {
if (strAction == "Acts_AppRecovery_0200_once" ||
strAction == "Acts_AppRecovery_0400_once" ||
strAction == "Acts_AppRecovery_1200_once") {
appRecovery.saveAppState(this.context);
console.log(strAction + "Rely2====> saveAppState");
} else {
console.log(strAction + "Rely2====> not saveAppState");
}
setTimeout(() => {
commonEvent.publish("ACTS_AppRecovery_First",commonEventData,(err)=>{
console.log(strAction + "Rely2====> publish err:" + JSON.stringify(err));
})
}, 200);
}
if (strAction == "Acts_AppRecovery_0200_twice" || strAction == "Acts_AppRecovery_0400_twice" ||
strAction == "Acts_AppRecovery_0800_twice" ||
strAction == "Acts_AppRecovery_1000_twice" || strAction == "Acts_AppRecovery_1200_twice") {
setTimeout(() => {
commonEvent.publish("ACTS_AppRecovery_Second", commonEventData, (err) => {
console.log(strAction + "Rely2====> second publish err:" + JSON.stringify(err));
})
}, 200);
}
if (strAction == "Acts_AppRecovery_0200_once" || strAction == "Acts_AppRecovery_0200_twice" ||
strAction == "Acts_AppRecovery_0400_twice" ||
strAction == "Acts_AppRecovery_0800_once" || strAction == "Acts_AppRecovery_0800_twice" ||
strAction == "Acts_AppRecovery_1000_twice" || strAction == "Acts_AppRecovery_1200_twice") {
setTimeout(()=>{
globalThis.contextSecond.terminateSelf().then(() => {
console.info(strAction + "Rely2====> terminateSelf end");
}).catch((err) => {
console.info(strAction + "Rely2====> terminateSelf err:" + JSON.stringify(err));
});
}, 300)
}
}
onBackground() {
// Ability has back to background
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
}
onSaveState(reason, wantParam: {[key:string]: any}) {
console.log(strAction + "Rely2onSaveStage====> wantParam:" + JSON.stringify(wantParam));
return AbilityConstant.OnSaveResult.RECOVERY_AGREE;
}
}
/*
* Copyright (c) 2023 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 = 'Rely1 Abilitys'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
/*
* Copyright (c) 2023 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 IndexSec {
@State message: string = 'Rely2 Abilitys'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
{
"module": {
"name": "entry",
"type": "entry",
"description": "$string:module_desc",
"mainElement": "EntryAbility",
"deviceTypes": [
"default",
"tablet"
],
"srcEntrance": "./ets/app/MyAbilityStage.ets",
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:main_pages",
"abilities": [
{
"name": "EntryAbility",
"srcEntrance": "./ets/entryability/EntryAbility.ts",
"description": "$string:EntryAbility_desc",
"icon": "$media:icon",
"label": "$string:EntryAbility_label",
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:start_window_background",
"visible": true,
"recoverable": true,
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
]
},
{
"name": "EntryAbilitySec",
"srcEntrance": "./ets/entryabilitysec/EntryAbilitySec.ts",
"description": "$string:EntryAbilitySec_desc",
"icon": "$media:icon",
"label": "$string:EntryAbilitySec_label",
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:start_window_background",
"recoverable": true,
"visible": true
}
]
}
}
\ No newline at end of file
{
"color": [
{
"name": "start_window_background",
"value": "#FFFFFF"
}
]
}
\ No newline at end of file
{
"string": [
{
"name": "module_desc",
"value": "module description"
},
{
"name": "EntryAbility_desc",
"value": "description"
},
{
"name": "EntryAbility_label",
"value": "label"
},
{
"name": "EntryAbilitySec_desc",
"value": "description"
},
{
"name": "EntryAbilitySec_label",
"value": "label"
}
]
}
\ No newline at end of file
{
"string": [
{
"name": "module_desc",
"value": "module description"
},
{
"name": "EntryAbility_desc",
"value": "description"
},
{
"name": "EntryAbility_label",
"value": "label"
},
{
"name": "EntryAbilitySec_desc",
"value": "description"
},
{
"name": "EntryAbilitySec_label",
"value": "label"
}
]
}
\ No newline at end of file
{
"string": [
{
"name": "module_desc",
"value": "模块描述"
},
{
"name": "EntryAbility_desc",
"value": "description"
},
{
"name": "EntryAbility_label",
"value": "label"
},
{
"name": "EntryAbilitySec_desc",
"value": "description"
},
{
"name": "EntryAbilitySec_label",
"value": "label"
}
]
}
\ No newline at end of file
# Copyright (c) 2023 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("apprecovery") {
testonly = true
if (is_standard_system) {
deps = [
"ActsAppRecoveryTestCaller:ActsAppRecoveryTestCaller",
"AppRecoveryRely:AppRecoveryRely",
"AppRecoverysRely:AppRecoverysRely",
]
}
}
......@@ -45,6 +45,10 @@
{
"name":"ohos.permission.LISTEN_BUNDLE_CHANGE",
"reason":"need use ohos.permission.LISTEN_BUNDLE_CHANGE"
},
{
"name":"ohos.permission.START_ABILITIES_FROM_BACKGROUND",
"reason":"need use ohos.permission.START_ABILITIES_FROM_BACKGROUND"
}
],
"abilities": [
......
......@@ -46,11 +46,12 @@ export default function ActsAccountAppAccess() {
parameters:
{},
},
},
)
await sleep(1500);
}, (err, data) => {
console.debug("====>accountauthenticatorfeatureAbility.startAbilityForResult err:" + JSON.stringify(err))
console.debug("====>accountauthenticatorfeatureAbility.startAbilityForResult data:" + JSON.stringify(data))
done();
})
console.debug("====>ActsAccountAuthenticator beforeAll end====");
done();
});
beforeEach(async (done)=>{
console.debug("====>afterEach start====");
......
......@@ -60,6 +60,7 @@ export default function ActsAccountOnOff() {
*/
it('ActsAccountOnOff_0300', 0, async function (done) {
testInit();
await sleep(500);
console.debug("====>ActsAccountOnOff_0300 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat appAccountManager finish");
......@@ -124,6 +125,7 @@ export default function ActsAccountOnOff() {
*/
it('ActsAccountOnOff_0400', 0, async function (done) {
testInit();
await sleep(500);
console.debug("====>ActsAccountOnOff_0400 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat appAccountManager finish");
......@@ -192,6 +194,7 @@ export default function ActsAccountOnOff() {
*/
it('ActsAccountOnOff_0500', 0, async function (done) {
testInit();
await sleep(500);
console.debug("====>ActsAccountOnOff_0500 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat appAccountManager finish");
......@@ -251,6 +254,7 @@ export default function ActsAccountOnOff() {
*/
it('ActsAccountOnOff_0600', 0, async function (done) {
testInit();
await sleep(500);
console.debug("====>ActsAccountOnOff_0600 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat appAccountManager finish");
......
......@@ -32,7 +32,7 @@ export default function testsuite() {
ActsAccountRemoveAccount()
ActsAccountErrPermission()
ActsAccountAuthToken()
ActsAccountOnOff()
ActsAccountAuthenticator()
ActsAccountErrCode()
ActsAccountOnOff()
}
\ No newline at end of file
......@@ -42,6 +42,10 @@
"name":"ohos.permission.REMOVE_CACHE_FILES",
"reason":"need use ohos.permission.REMOVE_CACHE_FILES"
},
{
"name":"ohos.permission.START_ABILITIES_FROM_BACKGROUND",
"reason":"need use ohos.permission.START_ABILITIES_FROM_BACKGROUND"
},
{
"name":"ohos.permission.LISTEN_BUNDLE_CHANGE",
"reason":"need use ohos.permission.LISTEN_BUNDLE_CHANGE"
......
......@@ -32,7 +32,8 @@ export default function ActsAccountAppAccess() {
console.info(`sleep #{time} over ...`)
})
}
beforeAll(async function (done) {
beforeAll(async function (done) {
console.debug("====>accountauthenticatorbeforeAll start====");
await featureAbility.startAbility(
{
want:
......@@ -44,10 +45,12 @@ export default function ActsAccountAppAccess() {
parameters:
{},
},
},
)
await sleep(1000)
done();
}, (err, data) => {
console.debug("====>accountauthenticatorfeatureAbility.startAbility err:" + JSON.stringify(err))
console.debug("====>accountauthenticatorfeatureAbility.startAbility data:" + JSON.stringify(data))
done();
})
console.debug("====>accountauthenticatorfeatureAbility.startAbility end")
});
beforeEach(async function (done) {
console.debug("====>afterEach start====");
......
......@@ -33,6 +33,6 @@ export default function testsuite() {
ActsAccountSetGetExtraInfo()
ActsAccountNoPermission()
ActsAccountOAuthToken()
ActsAccountChangeOnOff()
ActsAccountAuthenticator()
ActsAccountChangeOnOff()
}
\ No newline at end of file
......@@ -60,6 +60,7 @@ export default function ActsAccountChangeOnOff() {
*/
it('ActsAccountChangeOnOff_0100', 0, async function (done) {
testInit();
await sleep(1000);
console.debug("====>ActsAccountChangeOnOff_0100 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat appAccountManager finish");
......@@ -129,6 +130,7 @@ export default function ActsAccountChangeOnOff() {
*/
it('ActsAccountChangeOnOff_0200', 0, async function (done) {
testInit();
await sleep(1000);
console.debug("====>ActsAccountChangeOnOff_0200 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat appAccountManager finish");
......@@ -193,6 +195,7 @@ export default function ActsAccountChangeOnOff() {
*/
it('ActsAccountChangeOnOff_0300', 0, async function (done) {
testInit();
await sleep(1000);
console.debug("====>ActsAccountChangeOnOff_0300 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat appAccountManager finish");
......@@ -257,6 +260,7 @@ export default function ActsAccountChangeOnOff() {
*/
it('ActsAccountChangeOnOff_0400', 0, async function (done) {
testInit();
await sleep(1000);
console.debug("====>ActsAccountChangeOnOff_0400 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat appAccountManager finish");
......@@ -325,6 +329,7 @@ export default function ActsAccountChangeOnOff() {
*/
it('ActsAccountChangeOnOff_0500', 0, async function (done) {
testInit();
await sleep(1000);
console.debug("====>ActsAccountChangeOnOff_0500 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat appAccountManager finish");
......@@ -384,6 +389,7 @@ export default function ActsAccountChangeOnOff() {
*/
it('ActsAccountChangeOnOff_0600', 0, async function (done) {
testInit();
await sleep(1000);
console.debug("====>ActsAccountChangeOnOff_0600 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat appAccountManager finish");
......@@ -456,6 +462,7 @@ export default function ActsAccountChangeOnOff() {
*/
it('ActsAccountChangeOnOff_0700', 0, async function (done) {
testInit();
await sleep(1000);
console.debug("====>ActsAccountChangeOnOff_0700 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat appAccountManager finish");
......@@ -520,6 +527,7 @@ export default function ActsAccountChangeOnOff() {
it('ActsAccountChangeOnOff_0800', 0, async function (done) {
console.debug("====>ActsAccountChangeOnOff_0800 start====");
let dataMap = new Map();
await sleep(1000);
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat appAccountManager finish");
console.debug("====>add account ActsAccountChangeOnOff_0800 start");
......@@ -575,6 +583,7 @@ export default function ActsAccountChangeOnOff() {
it('ActsAccountChangeOnOff_0900', 0, async function (done) {
console.debug("====>ActsAccountChangeOnOff_0900 start====");
let dataMap = new Map();
await sleep(1000);
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat appAccountManager finish");
console.debug("====>add first account ActsAccountChangeOnOff_0900 start");
......@@ -642,6 +651,7 @@ export default function ActsAccountChangeOnOff() {
console.debug("====>ActsAccountChangeOnOff_1000 start====");
let dataMapFir = new Map();
let dataMapSec = new Map();
await sleep(1000);
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat appAccountManager finish");
console.debug("====>add account ActsAccountChangeOnOff_1000 start");
......@@ -718,6 +728,7 @@ export default function ActsAccountChangeOnOff() {
it('ActsAccountChangeOnOff_1100', 0, async function (done) {
console.debug("====>ActsAccountChangeOnOff_1100 start====");
let dataMap = new Map();
await sleep(1000);
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat appAccountManager finish");
console.debug("====>add account ActsAccountChangeOnOff_1100 start");
......@@ -778,6 +789,7 @@ export default function ActsAccountChangeOnOff() {
it('ActsAccountChangeOnOff_1200', 0, async function (done) {
console.debug("====>ActsAccountChangeOnOff_1200 start====");
let dataMap = new Map();
await sleep(1000);
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat appAccountManager finish");
console.debug("====>add account ActsAccountChangeOnOff_1200 start");
......@@ -838,6 +850,7 @@ export default function ActsAccountChangeOnOff() {
*/
it('ActsAccountChangeOnOff_1300', 0, async function (done) {
console.debug("====>ActsAccountChangeOnOff_1300 start====");
await sleep(1000);
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat appAccountManager finish");
console.debug("====>add account ActsAccountChangeOnOff_1300 start");
......@@ -884,6 +897,7 @@ export default function ActsAccountChangeOnOff() {
*/
it('ActsAccountChangeOnOff_1400', 0, async function (done) {
console.debug("====>ActsAccountChangeOnOff_1400 start====");
await sleep(1000);
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat appAccountManager finish");
console.debug("====>add account ActsAccountChangeOnOff_1400 start");
......
......@@ -261,7 +261,7 @@ class MyAuthenticator extends rpc.RemoteObject {
case 5 :
name = readString8(data)
callback = new MyAuthenticatorCallback(data.readRemoteObject())
this.authenticatorImpl.isAccountRemovable(name, callback)
this.authenticatorImpl.checkAccountRemovable(name, callback)
break
}
return true
......@@ -345,7 +345,7 @@ class MyAuthenticatorImpl {
callback.onResult(10016, {})
}
isAccountRemovable(name, callback) {
checkAccountRemovable(name, callback) {
console.log(TAG + "name: " + name)
var isRemovable = this.accountRemovability[name]
if (isRemovable == undefined || isRemovable == false) {
......
......@@ -160,7 +160,7 @@ class MyAuthenticator extends account_appAccount.Authenticator {
callback.onResult(10016, {})
}
isAccountRemovable(name, callback) {
checkAccountRemovable(name, callback) {
console.log(TAG + "name: " + name)
var isRemovable = false;
try {
......
......@@ -36,9 +36,10 @@ export default {
data: {
},
onShow() {
this.title = "scene on off";
// this.title = "scene on off";
},
onInit() {
this.title = "scene on off";
console.debug("====>change on off scene start====");
var appAccountManager = account.createAppAccountManager();
var commonEventSubscribeInfo = {
......@@ -51,11 +52,12 @@ export default {
console.debug("====>publish call back scene err:" + JSON.stringify(err));
console.debug("====>scene off start====");
appAccountManager.off('accountChange', function (){
appAccountManager.off('change', function (){
console.debug("====>scene off finish====");
});
console.debug("====>scene off accountChange finish====");
});
appAccountManager.off('change', function (){
console.debug("====>scene off change finish====");
});
// featureAbility.terminateSelf()
featureAbility.terminateSelf()
}
// Subscribe to the callback of account information changes, verify the received account information, and send
......
......@@ -213,7 +213,7 @@ export default function ActsOsAccountThirdPartyTest_third_2() {
console.debug("====>get type err: " + JSON.stringify(err));
console.debug("====>type obtained by process:" + JSON.stringify(accountType));
expect(err).assertEqual(null);
expect(accountType.ADMIN).assertEqual(0);
expect(accountType).assertEqual(0);
console.debug("====>ActsOsAccountGetTypeFormProcess_0100 end====");
done();
});
......@@ -230,7 +230,7 @@ export default function ActsOsAccountThirdPartyTest_third_2() {
console.debug("====>get AccountManager finish====");
var accountType = await osAccountManager.getOsAccountTypeFromProcess();
console.debug("====>type obtained by process:" + JSON.stringify(accountType));
expect(accountType.ADMIN).assertEqual(0);
expect(accountType).assertEqual(0);
console.debug("====>ActsOsAccountGetTypeFormProcess_0200 end====");
done();
});
......@@ -354,7 +354,7 @@ export default function ActsOsAccountThirdPartyTest_third_2() {
expect(err).assertEqual(null);
expect(data.localName).assertEqual("osAccountNameIdSerialA");
expect(data.domainInfo.accountName == "").assertEqual(true)
expect(data.type.NORMAL).assertEqual(1);
expect(data.type).assertEqual(1);
expect(data.constraints.length > 0).assertEqual(true);
expect(data.isVerified).assertEqual(false);
expect(data.distributedInfo.name != null).assertEqual(true);
......@@ -644,7 +644,7 @@ export default function ActsOsAccountThirdPartyTest_third_2() {
var data = await AccountManager.queryCurrentOsAccount();
console.debug("====>queryCurrentOsAccount data:" + JSON.stringify(data));
expect(data.localId).assertEqual(100);
expect(data.type.ADMIN).assertEqual(0);
expect(data.type).assertEqual(0);
var serialNumberStr = data.serialNumber.toString();
var serialIntercept = serialNumberStr.substring(8);
console.debug("====>truncate the last eight characters: " + serialIntercept);
......
......@@ -24,7 +24,7 @@ group("arkui") {
"ace_ets_component_ui:ActsAceEtsComponentUITest",
"ace_ets_components_ux:componnetUxTest",
"ace_ets_dev:ActsAceDevTest",
"ace_ets_layout_test:ArkUIActsLayoutTest",
"ace_ets_layout_test:ActsAceEtsLayoutTest",
"ace_ets_standard:ActsAceEtsStTest",
"ace_ets_test:ActsAceEtsTest",
"ace_ets_third_test:ActsAceEtsThirdTest",
......
......@@ -65,6 +65,7 @@ export default function appearJsunit() {
console.info("testAppear01 on appearEvent err : " + JSON.stringify(err));
}
console.info("testAppear01 click result is: " + JSON.stringify(sendEventByKey('appear', 10, "")));
await Utils.sleep(1000);
console.info('[testAppear01] END');
console.info('[testAppear02] START');
......
......@@ -126,7 +126,7 @@ export default function scrollOnScrollBeginJsunit() {
console.info("[testscrollOnScrollBegin0005] component align strJson:" + strJson);
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Scroll');
expect(obj.$attrs.scrollBarWidth).assertEqual("30.00px");
expect(obj.$attrs.scrollBarWidth).assertEqual("30.00vp");
console.info("[testscrollOnScrollBegin0005] scrollBarWidth value :" + obj.$attrs.scrollBarWidth);
done();
});
......
......@@ -25,7 +25,7 @@ const TAG = 'ets_apiLack_add';
struct Second {
private content: string = "这是第二页"
@State text: string = router.getParams()['text']
@State data: any = router.getParams()['data']
@State data: number[] = router.getParams()['data']
@State secondData : string = ''
build() {
......@@ -37,7 +37,7 @@ struct Second {
.fontSize(30)
.key("DataText")
.onClick(()=>{
this.secondData = (this.data.array[1]).toString()
this.secondData = (this.data[1]).toString()
try {
var backData = {
data: {
......
......@@ -25,7 +25,7 @@ const TAG = 'ets_apiLack_add';
struct Second {
private content: string = "这是第二页"
@State text: string = router.getParams()['text']
@State data: any = router.getParams()['data']
@State data: number[] = router.getParams()['data']
@State secondData : string = ''
build() {
......@@ -37,7 +37,7 @@ struct Second {
.fontSize(30)
.key("SingleDataText")
.onClick(()=>{
this.secondData = (this.data.array[1]).toString()
this.secondData = (this.data[1]).toString()
try {
var backData = {
data: {
......
......@@ -30,9 +30,7 @@ struct RouterStandard {
url: 'pages/page1',
params: {
text: '这是第一页的值',
data: {
array: [12, 45, 78]
}
data: [12, 45, 78]
}
}
try {
......
......@@ -63,7 +63,7 @@ export default function alertDialogCenterStartJsunit() {
var callback = (eventData) => {
console.info("testalertDialogCenterStart0001 get event data is: " + JSON.stringify(eventData));
expect(eventData.data.Result).assertEqual(true);
console.info('testalertDialogCenterStart0011 END');
console.info('testalertDialogCenterStart0001 END');
done();
}
console.info("testalertDialogCenterStart0001 click result is: " + JSON.stringify(sendEventByKey('CenterStartButton', 10, "")));
......@@ -85,7 +85,7 @@ export default function alertDialogCenterStartJsunit() {
let measureOptions = {textContent : "alertDialog-CenterStart"};
let width = measure.measureText(measureOptions);
console.info("++++++++++++++++++++++" + width.toString());
expect(width > 0).assertFalse();
expect(width > 0).assertTrue();
done();
} catch (err) {
console.info("testMeasureText0001 err : " + JSON.stringify(err));
......
......@@ -56,7 +56,7 @@ export default function appVersionCodeJsunit() {
}
var callback = (eventData) => {
console.info("testappVersionCode_0011 get event state result is: " + JSON.stringify(eventData));
expect(eventData.data.Code).assertEqual("1");
expect(eventData.data.Code).assertEqual(1000000);
}
console.info("testappVersion click result is: " + JSON.stringify(sendEventByKey('versionCodeText', 10, "")));
events_emitter.on(innerEvent, callback);
......
......@@ -75,7 +75,7 @@ export default function checkBoxGroupPartJsunit() {
}
var callback = (eventData) => {
console.info("testcheckBoxGroup0001 get event state result is: " + JSON.stringify(eventData));
expect(eventData.data.STATUS).assertEqual(2);
expect(eventData.data.STATUS).assertEqual(0);
done();
}
events_emitter.on(innerEvent, callback);
......
......@@ -62,7 +62,7 @@ export default function unitsModuleNameJsunit() {
}
var callback = (eventData) => {
console.info("testunitsModuleName0001 get event state result is: " + JSON.stringify(eventData));
expect(eventData.data.ModuleName).assertEqual(true);
expect(eventData.data.ModuleName).assertFalse();
}
events_emitter.on(innerEvent, callback);
} catch (err) {
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册