提交 8db098fa 编写于 作者: H huyanqiang 提交者: hu0475

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

Signed-off-by: Nhuyanqiang <huyanqiang5@huawei.com>
...@@ -17,8 +17,9 @@ group("ability") { ...@@ -17,8 +17,9 @@ group("ability") {
testonly = true testonly = true
if (is_standard_system) { if (is_standard_system) {
deps = [ deps = [
"crossplatform:ability_crossplatform",
"ability_runtime:ability_runtime", "ability_runtime:ability_runtime",
"crossplatform:ability_crossplatform",
"crossplatform:ability_crossplatform",
"dmsfwk:dmsfwk", "dmsfwk:dmsfwk",
] ]
} }
......
...@@ -432,5 +432,121 @@ export default function missionManagerTest() { ...@@ -432,5 +432,121 @@ export default function missionManagerTest() {
done(); done();
}) })
}) })
/**
* @tc.number: System_API_Test_Mission_Manager_2200
* @tc.name: callback form moveMissionsToForeground system interface interception test
* @tc.desc: Test the third-party application call moveMissionsToForeground will be blocked
* @tc.level 3
*/
it('System_API_Test_Mission_Manager_2200', 0, function (done) {
let TAG = 'System_API_Test_Mission_Manager_2200';
let missionIds = [1, 2, 3];
missionManager.moveMissionsToForeground(missionIds, (err) => {
console.log(TAG + " err.code: " + err.code);
expect(err.code).assertEqual(ERROR_CODE);
done();
});
})
/**
* @tc.number: System_API_Test_Mission_Manager_2300
* @tc.name: promise form moveMissionsToForeground system interface interception test
* @tc.desc: Test the third-party application call moveMissionsToForeground will be blocked
* @tc.level 3
*/
it('System_API_Test_Mission_Manager_2300', 0, function (done) {
let TAG = 'System_API_Test_Mission_Manager_2300';
let missionIds = [1, 2, 3];
missionManager.moveMissionsToForeground(missionIds)
.then(err => {
console.log(TAG + ` err->${JSON.stringify(err)}`);
expect().assertFail();
done();
})
.catch(err => {
console.log(TAG + " err.code: " + err.code);
expect(err.code).assertEqual(ERROR_CODE);
done();
})
})
/**
* @tc.number: System_API_Test_Mission_Manager_2400
* @tc.name: Multi-parameter moveMissionsToForeground system interface interception test in the form of callback
* @tc.desc: Test the third-party application call moveMissionsToForeground will be blocked
* @tc.level 3
*/
it('System_API_Test_Mission_Manager_2400', 0, function (done) {
let TAG = 'System_API_Test_Mission_Manager_2400';
let missionIds = [1, 2, 3];
let topMission = 2;
missionManager.moveMissionsToForeground(missionIds, topMission, (err) => {
console.log(TAG + " err.code: " + err.code);
expect(err.code).assertEqual(ERROR_CODE);
done();
});
})
/**
* @tc.number: System_API_Test_Mission_Manager_2500
* @tc.name: Multi-parameter moveMissionsToForeground system interface interception test in the form of promise
* @tc.desc: Test the third-party application call moveMissionsToForeground will be blocked
* @tc.level 3
*/
it('System_API_Test_Mission_Manager_2500', 0, function (done) {
let TAG = 'System_API_Test_Mission_Manager_2500';
let missionIds = [1, 2, 3];
let topMission = 2;
missionManager.moveMissionsToForeground(missionIds, topMission)
.then(err => {
console.log(TAG + ` err->${JSON.stringify(err)}`);
expect().assertFail();
done();
})
.catch(err => {
console.log(TAG + " err.code: " + err.code);
expect(err.code).assertEqual(ERROR_CODE);
done();
})
})
/**
* @tc.number: System_API_Test_Mission_Manager_2600
* @tc.name: callback form moveMissionsToBackground system interface interception test
* @tc.desc: Test the third-party application call moveMissionsToBackground will be blocked
* @tc.level 3
*/
it('System_API_Test_Mission_Manager_2600', 0, function (done) {
let TAG = 'System_API_Test_Mission_Manager_2600';
let missionIds = [1, 2, 3];
missionManager.moveMissionsToBackground(missionIds, (err) => {
console.log(TAG + " err.code: " + err.code);
expect(err.code).assertEqual(ERROR_CODE);
done();
});
})
/**
* @tc.number: System_API_Test_Mission_Manager_2700
* @tc.name: promise form moveMissionsToBackground system interface interception test
* @tc.desc: Test the third-party application call moveMissionsToBackground will be blocked
* @tc.level 3
*/
it('System_API_Test_Mission_Manager_2700', 0, function (done) {
let TAG = 'System_API_Test_Mission_Manager_2700';
let missionIds = [1, 2, 3];
missionManager.moveMissionsToBackground(missionIds)
.then(err => {
console.log(TAG + ` err->${JSON.stringify(err)}`);
expect().assertFail();
done();
})
.catch(err => {
console.log(TAG + " err.code: " + err.code);
expect(err.code).assertEqual(ERROR_CODE);
done();
})
})
}) })
} }
\ No newline at end of file
{ {
"module": { "module": {
"name": "entry", "name": "entry",
"type": "entry", "type": "entry",
"srcEntrance": "./ets/Application/MyAbilityStage.ts", "srcEntrance": "./ets/Application/MyAbilityStage.ts",
"description": "$string:entry_desc", "description": "$string:entry_desc",
"mainElement": "MainAbility", "mainElement": "MainAbility",
"deviceTypes": [ "deviceTypes": [
"default", "default",
"tablet" "tablet",
], "2in1"
"deliveryWithInstall": true, ],
"installationFree": false, "deliveryWithInstall": true,
"pages": "$profile:main_pages", "installationFree": false,
"abilities": [ "pages": "$profile:main_pages",
{ "abilities": [
"name": "MainAbility", {
"srcEntrance": "./ets/MainAbility/MainAbility.ts", "name": "MainAbility",
"description": "$string:MainAbility_desc", "srcEntrance": "./ets/MainAbility/MainAbility.ts",
"icon": "$media:icon", "description": "$string:MainAbility_desc",
"label": "$string:MainAbility_label", "icon": "$media:icon",
"startWindowIcon": "$media:icon", "label": "$string:MainAbility_label",
"startWindowBackground": "$color:white", "startWindowIcon": "$media:icon",
"visible": true, "startWindowBackground": "$color:white",
"skills": [ "visible": true,
{ "skills": [
"entities": [ {
"entity.system.home" "entities": [
], "entity.system.home"
"actions": [ ],
"action.system.home" "actions": [
] "action.system.home"
} ]
] }
} ]
], }
"extensionAbilities": [ ],
{ "extensionAbilities": [
"name": "UIExtAbility", {
"icon": "$media:icon", "name": "UIExtAbility",
"description": "UIExtAbility", "icon": "$media:icon",
"type": "ui", "description": "UIExtAbility",
"visible": true, "type": "ui",
"srcEntrance": "./ets/UIExtensionAbility/UIExtAbility.ts", "visible": true,
"metadata": [ "srcEntrance": "./ets/UIExtensionAbility/UIExtAbility.ts",
{ "metadata": [
"name": "ohos.extension.servicetype", {
"value": "share" "name": "ohos.extension.servicetype",
} "value": "share"
] }
} ]
] }
} ]
}
} }
\ No newline at end of file
{ {
"module": { "module": {
"name": "entry", "name": "entry",
"type": "entry", "type": "entry",
"srcEntrance": "./ets/Application/TestAbilityStage.ts", "srcEntrance": "./ets/Application/TestAbilityStage.ts",
"description": "$string:entry_test_desc", "description": "$string:entry_test_desc",
"mainElement": "TestAbility", "mainElement": "TestAbility",
"deviceTypes": [ "deviceTypes": [
"default", "default",
"tablet" "tablet",
], "2in1"
"deliveryWithInstall": true, ],
"installationFree": false, "deliveryWithInstall": true,
"pages": "$profile:test_pages", "installationFree": false,
"abilities": [ "pages": "$profile:test_pages",
{ "abilities": [
"name": "TestAbility", {
"srcEntrance": "./ets/TestAbility/TestAbility.ets", "name": "TestAbility",
"description": "$string:TestAbility_desc", "srcEntrance": "./ets/TestAbility/TestAbility.ets",
"icon": "$media:icon", "description": "$string:TestAbility_desc",
"label": "$string:TestAbility_label", "icon": "$media:icon",
"visible": true, "label": "$string:TestAbility_label",
"startWindowIcon": "$media:icon", "visible": true,
"startWindowBackground": "$color:white", "startWindowIcon": "$media:icon",
"skills": [ "startWindowBackground": "$color:white",
{ "skills": [
"actions": [ {
"action.system.home" "actions": [
], "action.system.home"
"entities": [ ],
"entity.system.home" "entities": [
] "entity.system.home"
} ]
] }
} ]
] }
} ]
} }
}
\ No newline at end of file
...@@ -20,6 +20,11 @@ import wantConstant from '@ohos.ability.wantConstant'; ...@@ -20,6 +20,11 @@ import wantConstant from '@ohos.ability.wantConstant';
var INVALID_PARAM = 401 var INVALID_PARAM = 401
var TAG var TAG
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
export default function verificationTest(){ export default function verificationTest(){
describe('VerificationTestTest', function() { describe('VerificationTestTest', function() {
...@@ -319,6 +324,113 @@ export default function verificationTest(){ ...@@ -319,6 +324,113 @@ export default function verificationTest(){
done(); done();
}) })
/*
* @tc.number SUB_AA_OpenHarmony_SetMissionLabel_0200
* @tc.name Verify setMissionLabel that the input parameter is number.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_SetMissionLabel_0200', 0, async function(done) {
TAG = 'SUB_AA_OpenHarmony_SetMissionLabel_0200 ==>';
let label = 0;
try {
await globalThis.abilityContext.setMissionLabel(label).then((data) => {
console.info(TAG + "setMissionLabel data = " + JSON.stringify(data));
}).catch((err) => {
console.info(TAG + "setMissionLabel err = " + JSON.stringify(err));
});
expect().assertFail();
} catch (err) {
console.info(TAG + "setMissionLabel err = " + JSON.stringify(err));
expect(err.code).assertEqual(INVALID_PARAM);
}
try {
await globalThis.abilityContext.setMissionLabel(label, (err, data) => {
console.info(TAG + "setMissionLabel err = " + JSON.stringify(err));
console.info(TAG + "setMissionLabel data = " + JSON.stringify(data));
})
expect().assertFail();
} catch (err) {
console.info(TAG + "setMissionLabel err = " + JSON.stringify(err));
expect(err.code).assertEqual(INVALID_PARAM);
}
done();
})
/*
* @tc.number SUB_AA_OpenHarmony_SetMissionLabel_0300
* @tc.name Verify setMissionLabel that the input parameter is string.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_SetMissionLabel_0300', 0, async function(done) {
TAG = 'SUB_AA_OpenHarmony_SetMissionLabel_0300 ==>';
let label = "testlabel";
let missionLabelUpdatedFlag = false;
await globalThis.abilityContext.setMissionLabel(label).then((data) => {
console.info(TAG + "setMissionLabel data = " + JSON.stringify(data));
missionLabelUpdatedFlag = true;
}).catch((err) => {
console.info(TAG + "setMissionLabel err = " + JSON.stringify(err));
});
await sleep(1000);
expect(missionLabelUpdatedFlag).assertTrue();
done();
})
/*
* @tc.number SUB_AA_OpenHarmony_SetMissionLabel_0400
* @tc.name Verify multiple setMissionLabel that the input parameter is string.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_SetMissionLabel_0400', 0, async function(done) {
TAG = 'SUB_AA_OpenHarmony_SetMissionLabel_0400 ==>';
let label1 = "testlabel1";
let label2 = "testlabel2";
let missionLabelUpdatedCount = 0;
await globalThis.abilityContext.setMissionLabel(label1).then((data) => {
console.info(TAG + "setMissionLabel1 data = " + JSON.stringify(data));
missionLabelUpdatedCount++;
}).catch((err) => {
console.info(TAG + "setMissionLabel1 err = " + JSON.stringify(err));
});
await globalThis.abilityContext.setMissionLabel(label2).then((data) => {
console.info(TAG + "setMissionLabel2 data = " + JSON.stringify(data));
missionLabelUpdatedCount++;
}).catch((err) => {
console.info(TAG + "setMissionLabel2 err = " + JSON.stringify(err));
});
await sleep(1000);
expect(missionLabelUpdatedCount).assertEqual(2);
missionLabelUpdatedCount = 0;
await globalThis.abilityContext.setMissionLabel(label1, (err, data) => {
console.info(TAG + "setMissionLabel1 err = " + JSON.stringify(err));
console.info(TAG + "setMissionLabel1 data = " + JSON.stringify(data));
if (err.code == 0) {
missionLabelUpdatedCount++;
}
})
await globalThis.abilityContext.setMissionLabel(label2, (err, data) => {
console.info(TAG + "setMissionLabel2 err = " + JSON.stringify(err));
console.info(TAG + "setMissionLabel2 data = " + JSON.stringify(data));
if (err.code == 0) {
missionLabelUpdatedCount++;
}
})
await sleep(1000);
expect(missionLabelUpdatedCount).assertEqual(2);
done();
})
/* /*
* @tc.number SUB_AA_OpenHarmony_StartAbilityLife_0100 * @tc.number SUB_AA_OpenHarmony_StartAbilityLife_0100
* @tc.name Ability startup and termination will not trigger the migration lifecycle. * @tc.name Ability startup and termination will not trigger the migration lifecycle.
......
...@@ -16,8 +16,6 @@ import("//build/ohos_var.gni") ...@@ -16,8 +16,6 @@ import("//build/ohos_var.gni")
group("ability_crossplatform") { group("ability_crossplatform") {
testonly = true testonly = true
if (is_standard_system) { if (is_standard_system) {
deps = [ deps = [ "ability_runtime:ability_crossplatform_runtime" ]
"ability_runtime:ability_crossplatform_runtime",
]
} }
} }
{
"app": {
"bundleName": "com.test.lifecycle_crossplatform_xts",
"vendor": "example",
"versionCode": 1000000,
"versionName": "1.0.0",
"icon": "$media:app_icon",
"label": "$string:app_name",
"minAPIVersion": 10,
"targetAPIVersion": 10,
"car": {
"apiCompatibleVersion": 10,
"singleUser": false
}
}
}
# 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("ActsLifeCycleEtsFeatureTest") {
hap_profile = "src/main/module.json"
deps = [
":windowStage_js_assets",
":windowStage_resources",
]
ets2abc = true
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsLifeCycleEtsFeatureTest"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("windowStage_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("windowStage_js_assets") {
source_dir = "src/main/ets"
}
ohos_resources("windowStage_resources") {
sources = [ "src/main/resources" ]
deps = [ ":windowStage_app_profile" ]
hap_profile = "src/main/module.json"
}
import AbilityStage from '@ohos.app.ability.AbilityStage';
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("[Demo] MyAbilityStage onCreate")
}
}
\ No newline at end of file
/*
* Copyright (c) 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 Ability from '@ohos.app.ability.UIAbility'
const abilityname = 'FeatureMainAbility';
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] MainAbility onCreate")
globalThis.abilityWant1 = want;
console.log("[Demo] MainAbility context: " + JSON.stringify(this.context));
var listKey1 = [];
let AbilityLifecycleCallback = {
onAbilityCreate(ability) {
console.log("[Demo] AbilityLifecycleCallback1 onAbilityCreate ability:"
+ JSON.stringify(ability));
console.log("[Demo] AbilityLifecycleCallback1 onAbilityCreate abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityCreate");
listKey1.push(abilityname + " onAbilityCreate");
console.log("[Demo] 1listKey1:" + JSON.stringify(listKey1));
},
onWindowStageCreate(ability, windowStage) {
console.log("[Demo] AbilityLifecycleCallback1 onWindowStageCreate ability:"
+ JSON.stringify(ability));
console.log("[Demo] AbilityLifecycleCallback1 onWindowStageCreate abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onWindowStageCreate");
listKey1.push(abilityname + " onWindowStageCreate");
console.log("[Demo] 2listKey1:" + JSON.stringify(listKey1));
},
onWindowStageActive(ability, windowStage) {
console.log(abilityname + " onWindowStageActive")
},
onWindowStageInactive(ability, windowStage) {
console.log(abilityname + " onWindowStageInactive")
},
onWindowStageDestroy(ability, windowStage) {
console.log("[Demo] AbilityLifecycleCallback1 onWindowStageDestroy ability:"
+ JSON.stringify(ability));
listKey1.push(abilityname + " onWindowStageDestroy");
console.log("[Demo] 3listKey1:" + JSON.stringify(listKey1));
},
onAbilityDestroy(ability) {
console.log("[Demo] AbilityLifecycleCallback1 onAbilityDestroy ability:"
+ JSON.stringify(ability));
console.log("[Demo] AbilityLifecycleCallback1 onAbilityDestroy abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityDestroy");
listKey1.push(abilityname + " onAbilityDestroy");
console.log("[Demo] 4listKey1:" + JSON.stringify(listKey1));
},
onAbilityForeground(ability) {
console.log("[Demo] AbilityLifecycleCallback1 onAbilityForeground ability:"
+ JSON.stringify(ability));
console.log("[Demo] AbilityLifecycleCallback1 onAbilityForeground abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityForeground");
listKey1.push(abilityname + " onAbilityForeground");
console.log("[Demo] 5listKey1:" + JSON.stringify(listKey1));
},
onAbilityBackground(ability) {
console.log("[Demo] AbilityLifecycleCallback1 onAbilityBackground ability:"
+ JSON.stringify(ability));
console.log("[Demo] AbilityLifecycleCallback1 onAbilityBackground abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityBackground");
listKey1.push(abilityname + " onAbilityBackground");
console.log("[Demo] 6listKey1:" + JSON.stringify(listKey1));
},
onAbilityContinue(ability) {
console.log("[Demo] AbilityLifecycleCallback1 onAbilityContinue ability:"
+ JSON.stringify(ability));
console.log("[Demo] AbilityLifecycleCallback1 onAbilityContinue abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityContinue");
listKey1.push(abilityname + " onAbilityContinue");
console.log("[Demo] 7listKey1:" + JSON.stringify(listKey1));
}
}
globalThis.applicationContext1 = this.context.getApplicationContext();
let lifecycleid = globalThis.applicationContext1.on('abilityLifecycle', AbilityLifecycleCallback);
console.log("[Demo] registerAbilityLifecycleCallback1 number: " + JSON.stringify(lifecycleid));
setTimeout(function () {
console.log("[Demo] registerAbilityLifecycleCallback1 listKey: " + JSON.stringify(listKey1));
globalThis.featureList1 = listKey1;
globalThis.featureCallbackid1 = lifecycleid;
}, 1500);
}
onDestroy() {
console.log("[Demo] MainAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] MainAbility onWindowStageCreate")
globalThis.featureAbilityContext = this.context;
windowStage.loadContent('pages/Index', (err, data) => {
if (err.code) {
console.log('MainAbility loadContent error');
return;
}
console.log('MainAbility loadContent success');
});
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[Demo] MainAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] MainAbility onForeground")
}
onBackground() {
// Ability has back to background
console.log("[Demo] MainAbility onBackground")
}
};
/*
* 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": "feature",
"type": "feature",
"description": "$string:module_test_desc",
"mainElement": "MainAbility",
"deviceTypes": [
"phone"
],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:test_pages",
"abilities": [
{
"name": "MainAbility",
"srcEntry": "./ets/mainability/MainAbility.ts",
"description": "$string:TestAbility_desc",
"icon": "$media:icon",
"label": "$string:TestAbility_label",
"exported": true,
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:start_window_background",
"skills": [
{
"actions": [
"action.system.home"
],
"entities": [
"entity.system.home"
]
}
]
}
]
}
}
{
"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.test.lifecycle_crossplatform_xts",
"vendor": "example",
"versionCode": 1000000,
"versionName": "1.0.0",
"icon": "$media:app_icon",
"label": "$string:app_name",
"minAPIVersion": 10,
"targetAPIVersion": 10,
"car": {
"apiCompatibleVersion": 10,
"singleUser": false
}
}
}
# 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("ActsLifeCycleEtsTest") {
hap_profile = "src/main/module.json"
deps = [
":windowStage_js_assets",
":windowStage_resources",
]
ets2abc = true
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsLifeCycleEtsTest"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("windowStage_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("windowStage_js_assets") {
source_dir = "src/main/ets"
}
ohos_resources("windowStage_resources") {
sources = [ "src/main/resources" ]
deps = [ ":windowStage_app_profile" ]
hap_profile = "src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "60000",
"shell-timeout": "60000",
"testcase-timeout": 15000,
"bundle-name": "com.test.lifecycle_crossplatform_xts",
"module-name": "entry_test"
},
"kits": [
{
"test-file-name": [
"commonTestAbilityApp.hap",
"ActsLifeCycleEtsFeatureTest.hap",
"ActsLifeCycleEtsTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
\ 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("[Demo] MyAbilityStage onCreate")
console.log("[Demo] MyAbilityStage stagecontext: " + JSON.stringify(this.context));
var listKey = [];
let AbilityLifecycleCallback = {
onAbilityCreate(ability) {
console.log("[Demo] AbilityLifecycleCallback onAbilityCreate ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback onAbilityCreate abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityCreate");
listKey.push(abilityname + " onAbilityCreate");
console.log("[Demo] 1listKey:" + JSON.stringify(listKey));
},
onWindowStageCreate(ability, windowStage) {
console.log("[Demo] AbilityLifecycleCallback onWindowStageCreate ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback onWindowStageCreate abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onWindowStageCreate");
listKey.push(abilityname + " onWindowStageCreate");
console.log("[Demo] 2listKey:" + JSON.stringify(listKey));
},
onWindowStageActive(ability, windowStage) {
let abilityname = ability.context.abilityInfo.name;
console.log(abilityname + " onWindowStageActive")
},
onWindowStageInactive(ability, windowStage) {
let abilityname = ability.context.abilityInfo.name;
console.log(abilityname + " onWindowStageInactive")
},
onWindowStageDestroy(ability, windowStage) {
console.log("[Demo] AbilityLifecycleCallback onWindowStageDestroy ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback onWindowStageDestroy abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onWindowStageDestroy");
listKey.push(abilityname + " onWindowStageDestroy");
console.log("[Demo] 3listKey:" + JSON.stringify(listKey));
},
onAbilityDestroy(ability) {
console.log("[Demo] AbilityLifecycleCallback onAbilityDestroy ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback onAbilityDestroy abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityDestroy");
listKey.push(abilityname + " onAbilityDestroy");
console.log("[Demo] 4listKey:" + JSON.stringify(listKey));
},
onAbilityForeground(ability) {
console.log("[Demo] AbilityLifecycleCallback onAbilityForeground ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback onAbilityForeground abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityForeground");
listKey.push(abilityname + " onAbilityForeground");
console.log("[Demo] 5listKey:" + JSON.stringify(listKey));
},
onAbilityBackground(ability) {
console.log("[Demo] AbilityLifecycleCallback onAbilityBackground ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback onAbilityBackground abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityBackground");
listKey.push(abilityname + " onAbilityBackground");
console.log("[Demo] 6listKey:" + JSON.stringify(listKey));
},
onAbilityContinue(ability) {
console.log("[Demo] AbilityLifecycleCallback onAbilityContinue ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback onAbilityContinue abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityContinue");
listKey.push(abilityname + " onAbilityContinue");
console.log("[Demo] 7listKey:" + JSON.stringify(listKey));
}
}
globalThis.applicationContext = this.context.getApplicationContext();
console.log("[Demo] stage applicationContext: " + JSON.stringify(globalThis.applicationContext));
let lifecycleid = globalThis.applicationContext.on('abilityLifecycle', AbilityLifecycleCallback);
console.log("[Demo] registerAbilityLifecycleCallback number: " + JSON.stringify(lifecycleid));
setTimeout(function () {
console.log("[Demo] AbilityLifecycleCallback listKey : " + JSON.stringify(listKey));
globalThis.list = listKey;
globalThis.callbackid = lifecycleid;
}, 2000);
}
}
\ 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 Hap1MainAbility1 extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] Hap1MainAbility1 onCreate")
globalThis.ability1Hap1Want = want;
setTimeout(() => {
this.context.terminateSelf().then((data) => {
console.log("Hap1MainAbility1 EventTest terminateSelf data: " + JSON.stringify(data));
}).catch((error) => {
console.log("Hap1MainAbility1 EventTest terminateSelf error: " + JSON.stringify(error));
})
}, 2000)
}
onDestroy() {
console.log("[Demo] Hap1MainAbility1 onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] Hap1MainAbility1 onWindowStageCreate")
windowStage.loadContent('testability/pages/indexh1a1', (err, data) => {
if (err.code) {
console.log('Hap1MainAbility1 loadContent error');
return;
}
console.log('Hap1MainAbility1 loadContent success');
});
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[Demo] Hap1MainAbility1 onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] Hap1MainAbility1 onForeground")
}
onBackground() {
// Ability has back to background
console.log("[Demo] Hap1MainAbility1 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 Hap1MainAbility2 extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] Hap1MainAbility2 onCreate")
globalThis.ability2Hap1Want = want;
setTimeout(() => {
this.context.terminateSelf().then((data) => {
console.log("Hap1MainAbility2 EventTest terminateSelf data: " + JSON.stringify(data));
}).catch((error) => {
console.log("Hap1MainAbility2 EventTest terminateSelf error: " + JSON.stringify(error));
})
}, 2000)
}
onDestroy() {
console.log("[Demo] Hap1MainAbility2 onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] Hap1MainAbility2 onWindowStageCreate")
windowStage.loadContent('testability/pages/indexh1a2', (err, data) => {
if (err.code) {
console.log('Hap1MainAbility2 loadContent error');
return;
}
console.log('Hap1MainAbility2 loadContent success');
});
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[Demo] Hap1MainAbility2 onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] Hap1MainAbility2 onForeground")
}
onBackground() {
// Ability has back to background
console.log("[Demo] Hap1MainAbility2 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 Ability from '@ohos.app.ability.UIAbility'
export default class MainAbility1 extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] MainAbility1 onCreate")
globalThis.abilityWant1 = want;
console.log("[Demo] MainAbility1 context: " + JSON.stringify(this.context));
var listKey1 = [];
let AbilityLifecycleCallback = {
onAbilityCreate(ability) {
console.log("[Demo] AbilityLifecycleCallback1 onAbilityCreate ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback1 onAbilityCreate abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityCreate");
listKey1.push(abilityname + " onAbilityCreate");
console.log("[Demo] 1listKey1:" + JSON.stringify(listKey1));
},
onWindowStageCreate(ability, windowStage) {
console.log("[Demo] AbilityLifecycleCallback1 onWindowStageCreate ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback1 onWindowStageCreate abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onWindowStageCreate");
listKey1.push(abilityname + " onWindowStageCreate");
console.log("[Demo] 2listKey1:" + JSON.stringify(listKey1));
},
onWindowStageActive(ability, windowStage) {
let abilityname = ability.context.abilityInfo.name;
console.log(abilityname + " onWindowStageActive")
},
onWindowStageInactive(ability, windowStage) {
let abilityname = ability.context.abilityInfo.name;
console.log(abilityname + " onWindowStageInactive")
},
onWindowStageDestroy(ability, windowStage) {
console.log("[Demo] AbilityLifecycleCallback1 onWindowStageDestroy ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
listKey1.push(abilityname + " onWindowStageDestroy");
console.log("[Demo] 3listKey1:" + JSON.stringify(listKey1));
},
onAbilityDestroy(ability) {
console.log("[Demo] AbilityLifecycleCallback1 onAbilityDestroy ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback1 onAbilityDestroy abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityDestroy");
listKey1.push(abilityname + " onAbilityDestroy");
console.log("[Demo] 4listKey1:" + JSON.stringify(listKey1));
},
onAbilityForeground(ability) {
console.log("[Demo] AbilityLifecycleCallback1 onAbilityForeground ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback1 onAbilityForeground abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityForeground");
listKey1.push(abilityname + " onAbilityForeground");
console.log("[Demo] 5listKey1:" + JSON.stringify(listKey1));
},
onAbilityBackground(ability) {
console.log("[Demo] AbilityLifecycleCallback1 onAbilityBackground ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback1 onAbilityBackground abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityBackground");
listKey1.push(abilityname + " onAbilityBackground");
console.log("[Demo] 6listKey1:" + JSON.stringify(listKey1));
},
onAbilityContinue(ability) {
console.log("[Demo] AbilityLifecycleCallback1 onAbilityContinue ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback1 onAbilityContinue abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityContinue");
listKey1.push(abilityname + " onAbilityContinue");
console.log("[Demo] 7listKey1:" + JSON.stringify(listKey1));
}
}
globalThis.applicationContext1 = this.context.getApplicationContext();
let lifecycleid = globalThis.applicationContext1.on('abilityLifecycle', AbilityLifecycleCallback);
console.log("[Demo] registerAbilityLifecycleCallback1 number: " + JSON.stringify(lifecycleid));
setTimeout(function () {
console.log("[Demo] registerAbilityLifecycleCallback1 listKey: " + JSON.stringify(listKey1));
globalThis.list1 = listKey1;
globalThis.callbackid1 = lifecycleid;
}, 2500);
}
onDestroy() {
console.log("[Demo] MainAbility1 onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] MainAbility1 onWindowStageCreate")
globalThis.ability1context = this.context;
windowStage.loadContent('testability/pages/index1', (err, data) => {
if (err.code) {
console.log('MainAbility1 loadContent error');
return;
}
console.log('MainAbility1 loadContent success');
});
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[Demo] MainAbility1 onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] MainAbility1 onForeground")
}
onBackground() {
// Ability has back to background
console.log("[Demo] MainAbility1 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 MainAbility10 extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] MainAbility10 onCreate")
globalThis.abilityWant10 = want;
var listKey10 = [];
let AbilityLifecycleCallback = {
onAbilityCreate(ability) {
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback10 onAbilityCreate abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityCreate");
listKey10.push(abilityname + " onAbilityCreate");
console.log("[Demo] 1listKey10:" + JSON.stringify(listKey10));
},
onWindowStageCreate(ability, windowStage) {
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback10 onWindowStageCreate abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onWindowStageCreate");
listKey10.push(abilityname + " onWindowStageCreate");
console.log("[Demo] 2listKey10:" + JSON.stringify(listKey10));
},
onWindowStageActive(ability, windowStage) {
let abilityname = ability.context.abilityInfo.name;
console.log(abilityname + " onWindowStageActive")
},
onWindowStageInactive(ability, windowStage) {
let abilityname = ability.context.abilityInfo.name;
console.log(abilityname + " onWindowStageInactive")
},
onWindowStageDestroy(ability, windowStage) {
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback10 onWindowStageDestroy abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onWindowStageDestroy");
listKey10.push(abilityname + " onWindowStageDestroy");
console.log("[Demo] 3listKey10:" + JSON.stringify(listKey10));
},
onAbilityDestroy(ability) {
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback10 onAbilityDestroy abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityDestroy");
listKey10.push(abilityname + " onAbilityDestroy");
console.log("[Demo] 4listKey10:" + JSON.stringify(listKey10));
},
onAbilityForeground(ability) {
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback10 onAbilityForeground abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityForeground");
listKey10.push(abilityname + " onAbilityForeground");
console.log("[Demo] 5listKey10:" + JSON.stringify(listKey10));
},
onAbilityBackground(ability) {
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback10 onAbilityBackground abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityBackground");
listKey10.push(abilityname + " onAbilityBackground");
console.log("[Demo] 6listKey10:" + JSON.stringify(listKey10));
},
onAbilityContinue(ability) {
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback10 onAbilityContinue abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityContinue");
listKey10.push(abilityname + " onAbilityContinue");
console.log("[Demo] 7listKey10:" + JSON.stringify(listKey10));
}
}
globalThis.applicationContext10 = this.context.getApplicationContext();
let lifecycleid = globalThis.applicationContext10.on('abilityLifecycle', AbilityLifecycleCallback);
console.log("[Demo] registerAbilityLifecycleCallback10 number: " + JSON.stringify(lifecycleid));
setTimeout(function () {
console.log("[Demo] registerAbilityLifecycleCallback10 listKey: " + JSON.stringify(listKey10));
globalThis.list10 = listKey10;
globalThis.callbackid10 = lifecycleid;
}, 1500);
}
onDestroy() {
console.log("[Demo] MainAbility10 onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] MainAbility10 onWindowStageCreate")
globalThis.ability10 = this.context;
windowStage.loadContent('testability/pages/index10', (err, data) => {
if (err.code) {
console.log('MainAbility10 loadContent error');
return;
}
console.log('MainAbility10 loadContent success');
});
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[Demo] MainAbility10 onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] MainAbility10 onForeground")
}
onBackground() {
// Ability has back to background
console.log("[Demo] MainAbility10 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 MainAbility11 extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] MainAbility11 onCreate")
globalThis.abilityWant11 = want;
globalThis.ability11 = this.context;
var listKey11 = [];
let AbilityLifecycleCallback = {
onAbilityCreate(ability) {
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback11 onAbilityCreate abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityCreate");
listKey11.push(abilityname + " onAbilityCreate");
},
onWindowStageCreate(ability, windowStage) {
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback11 onWindowStageCreate abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onWindowStageCreate");
listKey11.push(abilityname + " onWindowStageCreate");
},
onWindowStageActive(ability, windowStage) {
let abilityname = ability.context.abilityInfo.name;
console.log(abilityname + " onWindowStageActive")
},
onWindowStageInactive(ability, windowStage) {
let abilityname = ability.context.abilityInfo.name;
console.log(abilityname + " onWindowStageInactive")
},
onWindowStageDestroy(ability, windowStage) {
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback11 onWindowStageDestroy abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onWindowStageDestroy");
listKey11.push(abilityname + " onWindowStageDestroy");
},
onAbilityDestroy(ability) {
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback11 onAbilityDestroy abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityDestroy");
listKey11.push(abilityname + " onAbilityDestroy");
},
onAbilityForeground(ability) {
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback11 onAbilityForeground abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityForeground");
listKey11.push(abilityname + " onAbilityForeground");
},
onAbilityBackground(ability) {
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback11 onAbilityBackground abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityBackground");
listKey11.push(abilityname + " onAbilityBackground");
},
onAbilityContinue(ability) {
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback11 onAbilityContinue abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityContinue");
listKey11.push(abilityname + " onAbilityContinue");
}
}
globalThis.applicationContext11 = globalThis.ability11.getApplicationContext();
let lifecycleid = globalThis.applicationContext11.on('abilityLifecycle', AbilityLifecycleCallback);
console.log("[Demo] registerAbilityLifecycleCallback11 number: " + JSON.stringify(lifecycleid));
setTimeout(function () {
console.log("[Demo] registerAbilityLifecycleCallback11 listKey: " + JSON.stringify(listKey11));
globalThis.list11 = listKey11;
globalThis.callbackid11 = lifecycleid;
}, 2000);
}
onDestroy() {
console.log("[Demo] MainAbility11 onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] MainAbility11 onWindowStageCreate")
windowStage.loadContent('testability/pages/index11', (err, data) => {
if (err.code) {
console.log('MainAbility11 loadContent error');
return;
}
console.log('MainAbility11 loadContent success');
});
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[Demo] MainAbility11 onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] MainAbility11 onForeground")
}
onBackground() {
// Ability has back to background
console.log("[Demo] 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 MainAbility12 extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] MainAbility12 onCreate")
globalThis.abilityWant12 = want;
var listKey12 = [];
let AbilityLifecycleCallback = {
onAbilityCreate(ability) {
console.log("[Demo] AbilityLifecycleCallback12 onAbilityCreate ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] " + abilityname + " onAbilityCreate");
listKey12.push(abilityname + " onAbilityCreate");
},
onWindowStageCreate(ability, windowStage) {
console.log("[Demo] AbilityLifecycleCallback12 onWindowStageCreate ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] " + abilityname + " onWindowStageCreate");
listKey12.push(abilityname + " onWindowStageCreate");
},
onWindowStageActive(ability, windowStage) {
let abilityname = ability.context.abilityInfo.name;
console.log(abilityname + " onWindowStageActive")
},
onWindowStageInactive(ability, windowStage) {
let abilityname = ability.context.abilityInfo.name;
console.log(abilityname + " onWindowStageInactive")
},
onWindowStageDestroy(ability, windowStage) {
console.log("[Demo] AbilityLifecycleCallback12 onWindowStageDestroy ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] " + abilityname + " onWindowStageDestroy");
listKey12.push(abilityname + " onWindowStageDestroy");
},
onAbilityDestroy(ability) {
console.log("[Demo] AbilityLifecycleCallback12 onAbilityDestroy ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] " + abilityname + " onAbilityDestroy");
listKey12.push(abilityname + " onAbilityDestroy");
},
onAbilityForeground(ability) {
console.log("[Demo] AbilityLifecycleCallback12 onAbilityForeground ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] " + abilityname + " onAbilityForeground");
listKey12.push(abilityname + " onAbilityForeground");
},
onAbilityBackground(ability) {
console.log("[Demo] AbilityLifecycleCallback12 onAbilityBackground ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] " + abilityname + " onAbilityBackground");
listKey12.push(abilityname + " onAbilityBackground");
},
onAbilityContinue(ability) {
console.log("[Demo] AbilityLifecycleCallback12 onAbilityContinue ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] " + abilityname + " onAbilityContinue");
listKey12.push(abilityname + " onAbilityContinue");
}
}
globalThis.applicationContext12 = this.context.getApplicationContext();
let lifecycleid = globalThis.applicationContext12.on('abilityLifecycle', AbilityLifecycleCallback);
console.log("[Demo] registerAbilityLifecycleCallback12 number: " + JSON.stringify(lifecycleid));
setTimeout(function () {
console.log("[Demo] registerAbilityLifecycleCallback12 listKey: " + JSON.stringify(listKey12));
globalThis.list12 = listKey12;
globalThis.callbackid12 = lifecycleid;
}, 1700);
}
onDestroy() {
console.log("[Demo] MainAbility12 onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] MainAbility12 onWindowStageCreate")
globalThis.ability12 = this.context;
windowStage.loadContent('testability/pages/index12', (err, data) => {
if (err.code) {
console.log('MainAbility12 loadContent error');
return;
}
console.log('MainAbility12 loadContent success');
});
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[Demo] MainAbility12 onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] MainAbility12 onForeground")
}
onBackground() {
// Ability has back to background
console.log("[Demo] MainAbility12 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 MainAbility13 extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] MainAbility13 onCreate")
globalThis.abilityWant1 = want;
console.log("[Demo] MainAbility13 context: " + JSON.stringify(this.context));
var listKey1 = [];
let AbilityLifecycleCallback = {
onAbilityCreate(ability) {
console.log("[Demo] AbilityLifecycleCallback1 onAbilityCreate ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback1 onAbilityCreate abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityCreate");
listKey1.push(abilityname + " onAbilityCreate");
console.log("[Demo] 1listKey1:" + JSON.stringify(listKey1));
},
onWindowStageCreate(ability, windowStage) {
console.log("[Demo] AbilityLifecycleCallback1 onWindowStageCreate ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback1 onWindowStageCreate abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onWindowStageCreate");
listKey1.push(abilityname + " onWindowStageCreate");
console.log("[Demo] 2listKey1:" + JSON.stringify(listKey1));
},
onWindowStageActive(ability, windowStage) {
let abilityname = ability.context.abilityInfo.name;
console.log(abilityname + " onWindowStageActive")
},
onWindowStageInactive(ability, windowStage) {
let abilityname = ability.context.abilityInfo.name;
console.log(abilityname + " onWindowStageInactive")
},
onWindowStageDestroy(ability, windowStage) {
console.log("[Demo] AbilityLifecycleCallback1 onWindowStageDestroy ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
listKey1.push(abilityname + " onWindowStageDestroy");
console.log("[Demo] 3listKey1:" + JSON.stringify(listKey1));
},
onAbilityDestroy(ability) {
console.log("[Demo] AbilityLifecycleCallback1 onAbilityDestroy ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback1 onAbilityDestroy abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityDestroy");
listKey1.push(abilityname + " onAbilityDestroy");
console.log("[Demo] 4listKey1:" + JSON.stringify(listKey1));
},
onAbilityForeground(ability) {
console.log("[Demo] AbilityLifecycleCallback1 onAbilityForeground ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback1 onAbilityForeground abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityForeground");
listKey1.push(abilityname + " onAbilityForeground");
console.log("[Demo] 5listKey1:" + JSON.stringify(listKey1));
},
onAbilityBackground(ability) {
console.log("[Demo] AbilityLifecycleCallback1 onAbilityBackground ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback1 onAbilityBackground abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityBackground");
listKey1.push(abilityname + " onAbilityBackground");
console.log("[Demo] 6listKey1:" + JSON.stringify(listKey1));
},
onAbilityContinue(ability) {
console.log("[Demo] AbilityLifecycleCallback1 onAbilityContinue ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback1 onAbilityContinue abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityContinue");
listKey1.push(abilityname + " onAbilityContinue");
console.log("[Demo] 7listKey1:" + JSON.stringify(listKey1));
}
}
var listKey2 = [];
let AbilityLifecycleCallback2 = {
onAbilityCreate(ability) {
console.log("[Demo] AbilityLifecycleCallback1 onAbilityCreate ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback1 onAbilityCreate abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityCreate");
listKey2.push(abilityname + " onAbilityCreate");
console.log("[Demo] 1listKey2:" + JSON.stringify(listKey2));
},
onWindowStageCreate(ability, windowStage) {
console.log("[Demo] AbilityLifecycleCallback1 onWindowStageCreate ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback1 onWindowStageCreate abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onWindowStageCreate");
listKey2.push(abilityname + " onWindowStageCreate");
console.log("[Demo] 2listKey2:" + JSON.stringify(listKey2));
},
onWindowStageActive(ability, windowStage) {
let abilityname = ability.context.abilityInfo.name;
console.log(abilityname + " onWindowStageActive")
},
onWindowStageInactive(ability, windowStage) {
let abilityname = ability.context.abilityInfo.name;
console.log(abilityname + " onWindowStageInactive")
},
onWindowStageDestroy(ability, windowStage) {
console.log("[Demo] AbilityLifecycleCallback1 onWindowStageDestroy ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
listKey2.push(abilityname + " onWindowStageDestroy");
console.log("[Demo] 3listKey2:" + JSON.stringify(listKey2));
},
onAbilityDestroy(ability) {
console.log("[Demo] AbilityLifecycleCallback1 onAbilityDestroy ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback1 onAbilityDestroy abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityDestroy");
listKey2.push(abilityname + " onAbilityDestroy");
console.log("[Demo] 4listKey2:" + JSON.stringify(listKey2));
},
onAbilityForeground(ability) {
console.log("[Demo] AbilityLifecycleCallback1 onAbilityForeground ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback1 onAbilityForeground abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityForeground");
listKey2.push(abilityname + " onAbilityForeground");
console.log("[Demo] 5listKey2:" + JSON.stringify(listKey2));
},
onAbilityBackground(ability) {
console.log("[Demo] AbilityLifecycleCallback1 onAbilityBackground ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback1 onAbilityBackground abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityBackground");
listKey2.push(abilityname + " onAbilityBackground");
console.log("[Demo] 6listKey2:" + JSON.stringify(listKey2));
},
onAbilityContinue(ability) {
console.log("[Demo] AbilityLifecycleCallback1 onAbilityContinue ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback1 onAbilityContinue abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityContinue");
listKey2.push(abilityname + " onAbilityContinue");
console.log("[Demo] 7listKey2:" + JSON.stringify(listKey2));
}
}
globalThis.ability13 = this.context;
globalThis.applicationContext13 = this.context.getApplicationContext();
let lifecycleid = globalThis.applicationContext13.on('abilityLifecycle', AbilityLifecycleCallback);
let lifecycleid2 = globalThis.applicationContext13.on('abilityLifecycle', AbilityLifecycleCallback2);
console.log("[Demo] registerAbilityLifecycleCallback1 number: " + JSON.stringify(lifecycleid));
setTimeout(function () {
console.log("[Demo] registerAbilityLifecycleCallback1 listKey: " + JSON.stringify(listKey1));
console.log("[Demo] registerAbilityLifecycleCallback1 listKey: " + JSON.stringify(listKey2));
globalThis.list13 = listKey1;
globalThis.callbackid13 = lifecycleid;
globalThis.otherList13 = listKey2;
globalThis.otherCallbackid13 = lifecycleid2;
}, 1500);
}
onDestroy() {
console.log("[Demo] MainAbility13 onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] MainAbility13 onWindowStageCreate")
globalThis.ability1context = this.context;
windowStage.loadContent('testability/pages/index1', (err, data) => {
if (err.code) {
console.log('MainAbility13 loadContent error');
return;
}
console.log('MainAbility13 loadContent success');
});
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[Demo] MainAbility13 onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] MainAbility13 onForeground")
}
onBackground() {
// Ability has back to background
console.log("[Demo] MainAbility13 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 MainAbility14 extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] MainAbility14 onCreate")
globalThis.abilityWant14 = want;
}
onDestroy() {
console.log("[Demo] MainAbility14 onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] MainAbility14 onWindowStageCreate")
globalThis.ability14 = this.context;
windowStage.loadContent('testability/pages/index2', (err, data) => {
if (err.code) {
console.log('MainAbility14 loadContent error');
return;
}
console.log('MainAbility14 loadContent success');
});
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[Demo] MainAbility14 onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] MainAbility14 onForeground")
}
onBackground() {
// Ability has back to background
console.log("[Demo] MainAbility14 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 MainAbility2 extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] MainAbility2 onCreate")
globalThis.abilityWant2 = want;
}
onDestroy() {
console.log("[Demo] MainAbility2 onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] MainAbility2 onWindowStageCreate")
globalThis.ability2 = this.context;
windowStage.loadContent('testability/pages/index2', (err, data) => {
if (err.code) {
console.log('MainAbility2 loadContent error');
return;
}
console.log('MainAbility2 loadContent success');
});
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[Demo] MainAbility2 onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] MainAbility2 onForeground")
setTimeout(function () {
globalThis.ability2.terminateSelf()
.then((data) => {
console.info('[Demo] MainAbility2 terminateself succeeded: ' + data);
}).catch((error) => {
console.error('[Demo] MainAbility2 terminateself failed. Cause: ' + error);
})
}, 1500);
}
onBackground() {
// Ability has back to background
console.log("[Demo] 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 MainAbility3 extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] MainAbility3 onCreate")
globalThis.abilityWant3 = want;
console.log("[Demo] MainAbility3 context: " + JSON.stringify(this.context));
var listKey3 = [];
let AbilityLifecycleCallback = {
onAbilityCreate(ability) {
console.log("[Demo] AbilityLifecycleCallback3 onAbilityCreate ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback3 onAbilityCreate abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityCreate");
listKey3.push(abilityname + " onAbilityCreate");
console.log("[Demo] 1listKey3:" + JSON.stringify(listKey3));
},
onWindowStageCreate(ability, windowStage) {
console.log("[Demo] AbilityLifecycleCallback3 onWindowStageCreate ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback3 onWindowStageCreate abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onWindowStageCreate");
listKey3.push(abilityname + " onWindowStageCreate");
console.log("[Demo] 2listKey3:" + JSON.stringify(listKey3));
},
onWindowStageActive(ability, windowStage) {
let abilityname = ability.context.abilityInfo.name;
console.log(abilityname + " onWindowStageActive")
},
onWindowStageInactive(ability, windowStage) {
let abilityname = ability.context.abilityInfo.name;
console.log(abilityname + " onWindowStageInactive")
},
onWindowStageDestroy(ability, windowStage) {
console.log("[Demo] AbilityLifecycleCallback3 onWindowStageDestroy ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback3 onWindowStageDestroy abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onWindowStageDestroy");
listKey3.push(abilityname + " onWindowStageDestroy");
console.log("[Demo] 3listKey3:" + JSON.stringify(listKey3));
},
onAbilityDestroy(ability) {
console.log("[Demo] AbilityLifecycleCallback3 onAbilityDestroy ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback3 onAbilityDestroy abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityDestroy");
listKey3.push(abilityname + " onAbilityDestroy");
console.log("[Demo] 4listKey3:" + JSON.stringify(listKey3));
},
onAbilityForeground(ability) {
console.log("[Demo] AbilityLifecycleCallback3 onAbilityForeground ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback3 onAbilityForeground abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityForeground");
listKey3.push(abilityname + " onAbilityForeground");
console.log("[Demo] 5listKey3:" + JSON.stringify(listKey3));
},
onAbilityBackground(ability) {
console.log("[Demo] AbilityLifecycleCallback3 onAbilityBackground ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback3 onAbilityBackground abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityBackground");
listKey3.push(abilityname + " onAbilityBackground");
console.log("[Demo] 6listKey3:" + JSON.stringify(listKey3));
},
onAbilityContinue(ability) {
console.log("[Demo] AbilityLifecycleCallback3 onAbilityContinue ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback3 onAbilityContinue abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityContinue");
listKey3.push(abilityname + " onAbilityContinue");
console.log("[Demo] 7listKey3:" + JSON.stringify(listKey3));
}
}
globalThis.applicationContext3 = this.context.getApplicationContext();
let lifecycleid = globalThis.applicationContext3.on('abilityLifecycle', AbilityLifecycleCallback);
console.log("[Demo] registerAbilityLifecycleCallback3 number: " + JSON.stringify(lifecycleid));
setTimeout(function () {
console.log("[Demo] registerAbilityLifecycleCallback3 listKey : " + JSON.stringify(listKey3));
globalThis.list3 = listKey3;
globalThis.callbackid3 = lifecycleid;
}, 2000);
}
onDestroy() {
console.log("[Demo] MainAbility3 onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] MainAbility3 onWindowStageCreate")
globalThis.ability3 = this.context
windowStage.loadContent('testability/pages/index3', (err, data) => {
if (err.code) {
console.log('MainAbility3 loadContent error');
return;
}
console.log('MainAbility3 loadContent success');
});
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[Demo] MainAbility3 onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] MainAbility onForeground")
}
onBackground() {
// Ability has back to background
console.log("[Demo] 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 MainAbility4 extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] MainAbility4 onCreate")
globalThis.abilityWant4 = want;
console.log("[Demo] MainAbility4 context: " + JSON.stringify(this.context));
var listKey4 = [];
let AbilityLifecycleCallback = {
onAbilityCreate(ability) {
console.log("[Demo] AbilityLifecycleCallback4 onAbilityCreate ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback4 onAbilityCreate abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityCreate");
listKey4.push(abilityname + " onAbilityCreate");
console.log("[Demo] 1listKey4:" + JSON.stringify(listKey4));
},
onWindowStageCreate(ability, windowStage) {
console.log("[Demo] AbilityLifecycleCallback4 onWindowStageCreate ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback4 onWindowStageCreate abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onWindowStageCreate");
listKey4.push(abilityname + " onWindowStageCreate");
console.log("[Demo] 2listKey4:" + JSON.stringify(listKey4));
},
onWindowStageActive(ability, windowStage) {
let abilityname = ability.context.abilityInfo.name;
console.log(abilityname + " onWindowStageActive")
},
onWindowStageInactive(ability, windowStage) {
let abilityname = ability.context.abilityInfo.name;
console.log(abilityname + " onWindowStageInactive")
},
onWindowStageDestroy(ability, windowStage) {
console.log("[Demo] AbilityLifecycleCallback4 onWindowStageDestroy ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback4 onWindowStageDestroy abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onWindowStageDestroy");
listKey4.push(abilityname + " onWindowStageDestroy");
console.log("[Demo] 3listKey4:" + JSON.stringify(listKey4));
},
onAbilityDestroy(ability) {
console.log("[Demo] AbilityLifecycleCallback4 onAbilityDestroy ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback4 onAbilityDestroy abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityDestroy");
listKey4.push(abilityname + " onAbilityDestroy");
console.log("[Demo] 4listKey4:" + JSON.stringify(listKey4));
},
onAbilityForeground(ability) {
console.log("[Demo] AbilityLifecycleCallback4 onAbilityForeground ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback4 onAbilityForeground abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityForeground");
listKey4.push(abilityname + " onAbilityForeground");
console.log("[Demo] 5listKey4:" + JSON.stringify(listKey4));
},
onAbilityBackground(ability) {
console.log("[Demo] AbilityLifecycleCallback4 onAbilityBackground ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback4 onAbilityBackground abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityBackground");
listKey4.push(abilityname + " onAbilityBackground");
console.log("[Demo] 6listKey4:" + JSON.stringify(listKey4));
},
onAbilityContinue(ability) {
console.log("[Demo] AbilityLifecycleCallback4 onAbilityContinue ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback4 onAbilityContinue abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityContinue");
listKey4.push(abilityname + " onAbilityContinue");
console.log("[Demo] 7listKey4:" + JSON.stringify(listKey4));
}
}
globalThis.applicationContext4 = this.context.getApplicationContext();
let lifecycleid = globalThis.applicationContext4.on('abilityLifecycle', AbilityLifecycleCallback);
console.log("[Demo] registerAbilityLifecycleCallback4 number: " + JSON.stringify(lifecycleid));
globalThis.callbackid4 = lifecycleid;
setTimeout(function () {
console.log("[Demo] registerAbilityLifecycleCallback4 listKey : " + JSON.stringify(listKey4));
globalThis.list4 = listKey4;
}, 1500);
}
onDestroy() {
console.log("[Demo] MainAbility4 onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] MainAbility4 onWindowStageCreate")
globalThis.ability4 = this.context;
windowStage.loadContent('testability/pages/index4', (err, data) => {
if (err.code) {
console.log('MainAbility4 loadContent error');
return;
}
console.log('MainAbility4 loadContent success');
});
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[Demo] MainAbility4 onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] MainAbility4 onForeground")
setTimeout(function () {
globalThis.ability4.terminateSelf()
.then((data) => {
console.info('[Demo] MainAbility4 terminateself succeeded: ' + data);
}).catch((error) => {
console.error('[Demo] MainAbility4 terminateself failed. Cause: ' + error);
})
}, 5000);
}
onBackground() {
// Ability has back to background
console.log("[Demo] MainAbility4 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 MainAbility5 extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] MainAbility5 onCreate")
globalThis.abilityWant5 = want;
}
onDestroy() {
console.log("[Demo] MainAbility5 onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] MainAbility5 onWindowStageCreate")
globalThis.ability5 = this.context;
windowStage.loadContent('testability/pages/index5', (err, data) => {
if (err.code) {
console.log('MainAbility5 loadContent error');
return;
}
console.log('MainAbility5 loadContent success');
});
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[Demo] MainAbility5 onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] MainAbility5 onForeground")
setTimeout(function () {
globalThis.ability5.terminateSelf()
.then((data) => {
console.info('[Demo] MainAbility5 terminateself succeeded: ' + data);
}).catch((error) => {
console.error('[Demo] MainAbility5 terminateself failed. Cause: ' + error);
})
}, 500);
}
onBackground() {
// Ability has back to background
console.log("[Demo] MainAbility5 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 MainAbility6 extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] MainAbility6 onCreate")
globalThis.abilityWant6 = want;
}
onDestroy() {
console.log("[Demo] MainAbility6 onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] MainAbility6 onWindowStageCreate")
globalThis.ability6 = this.context;
windowStage.loadContent('testability/pages/index6', (err, data) => {
if (err.code) {
console.log('MainAbility6 loadContent error');
return;
}
console.log('MainAbility6 loadContent success');
});
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[Demo] MainAbility6 onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] MainAbility6 onForeground")
var listKey6 = [];
let AbilityLifecycleCallback = {
onAbilityCreate(ability) {
console.log("[Demo] AbilityLifecycleCallback6 onAbilityCreate ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback6 onAbilityCreate abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityCreate");
listKey6.push(abilityname + " onAbilityCreate");
console.log("[Demo] 1listKey6:" + JSON.stringify(listKey6));
},
onWindowStageCreate(ability, windowStage) {
console.log("[Demo] AbilityLifecycleCallback6 onWindowStageCreate ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback6 onWindowStageCreate abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onWindowStageCreate");
listKey6.push(abilityname + " onWindowStageCreate");
console.log("[Demo] 2listKey6:" + JSON.stringify(listKey6));
},
onWindowStageActive(ability, windowStage) {
let abilityname = ability.context.abilityInfo.name;
console.log(abilityname + " onWindowStageActive")
},
onWindowStageInactive(ability, windowStage) {
let abilityname = ability.context.abilityInfo.name;
console.log(abilityname + " onWindowStageInactive")
},
onWindowStageDestroy(ability, windowStage) {
console.log("[Demo] AbilityLifecycleCallback6 onWindowStageDestroy ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback6 onWindowStageDestroy abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onWindowStageDestroy");
listKey6.push(abilityname + " onWindowStageDestroy");
console.log("[Demo] 3listKey6:" + JSON.stringify(listKey6));
},
onAbilityDestroy(ability) {
console.log("[Demo] AbilityLifecycleCallback6 onAbilityDestroy ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback6 onAbilityDestroy abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityDestroy");
listKey6.push(abilityname + " onAbilityDestroy");
console.log("[Demo] 4listKey6:" + JSON.stringify(listKey6));
},
onAbilityForeground(ability) {
console.log("[Demo] AbilityLifecycleCallback6 onAbilityForeground ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback6 onAbilityForeground abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityForeground");
listKey6.push(abilityname + " onAbilityForeground");
console.log("[Demo] 5listKey6:" + JSON.stringify(listKey6));
},
onAbilityBackground(ability) {
console.log("[Demo] AbilityLifecycleCallback6 onAbilityBackground ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback6 onAbilityBackground abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityBackground");
listKey6.push(abilityname + " onAbilityBackground");
console.log("[Demo] 6listKey6:" + JSON.stringify(listKey6));
},
onAbilityContinue(ability) {
console.log("[Demo] AbilityLifecycleCallback6 onAbilityContinue ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback6 onAbilityContinue abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityContinue");
listKey6.push(abilityname + " onAbilityContinue");
console.log("[Demo] 7listKey6:" + JSON.stringify(listKey6));
}
}
globalThis.applicationContext6 = globalThis.ability6.getApplicationContext();
let lifecycleid = globalThis.applicationContext6.on('abilityLifecycle', AbilityLifecycleCallback);
console.log("[Demo] registerAbilityLifecycleCallback6 number: " + JSON.stringify(lifecycleid));
setTimeout(function () {
console.log("[Demo] registerAbilityLifecycleCallback6 listKey: " + JSON.stringify(listKey6));
globalThis.list6 = listKey6;
globalThis.callbackid6 = lifecycleid;
}, 1500);
}
onBackground() {
// Ability has back to background
console.log("[Demo] MainAbility6 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 MainAbility7 extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] MainAbility7 onCreate")
globalThis.abilityWant7 = want;
}
onDestroy() {
console.log("[Demo] MainAbility7 onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] MainAbility7 onWindowStageCreate")
globalThis.ability7 = this.context;
windowStage.loadContent('testability/pages/index7', (err, data) => {
if (err.code) {
console.log('MainAbility7 loadContent error');
return;
}
console.log('MainAbility7 loadContent success');
});
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[Demo] MainAbility7 onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] MainAbility7 onForeground")
var listKey7 = [];
let AbilityLifecycleCallback = {
onAbilityCreate(ability) {
console.log("[Demo] AbilityLifecycleCallback7 onAbilityCreate ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback7 onAbilityCreate abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityCreate");
listKey7.push(abilityname + " onAbilityCreate");
console.log("[Demo] 1listKey7:" + JSON.stringify(listKey7));
},
onWindowStageCreate(ability, windowStage) {
console.log("[Demo] AbilityLifecycleCallback7 onWindowStageCreate ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback7 onWindowStageCreate abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onWindowStageCreate");
listKey7.push(abilityname + " onWindowStageCreate");
console.log("[Demo] 2listKey7:" + JSON.stringify(listKey7));
},
onWindowStageActive(ability, windowStage) {
let abilityname = ability.context.abilityInfo.name;
console.log(abilityname + " onWindowStageActive")
},
onWindowStageInactive(ability, windowStage) {
let abilityname = ability.context.abilityInfo.name;
console.log(abilityname + " onWindowStageInactive")
},
onWindowStageDestroy(ability, windowStage) {
console.log("[Demo] AbilityLifecycleCallback7 onWindowStageDestroy ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback7 onWindowStageDestroy abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onWindowStageDestroy");
listKey7.push(abilityname + " onWindowStageDestroy");
console.log("[Demo] 3listKey7:" + JSON.stringify(listKey7));
},
onAbilityDestroy(ability) {
console.log("[Demo] AbilityLifecycleCallback7 onAbilityDestroy ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback7 onAbilityDestroy abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityDestroy");
listKey7.push(abilityname + " onAbilityDestroy");
console.log("[Demo] 4listKey7:" + JSON.stringify(listKey7));
},
onAbilityForeground(ability) {
console.log("[Demo] AbilityLifecycleCallback7 onAbilityForeground ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback7 onAbilityForeground abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityForeground");
listKey7.push(abilityname + " onAbilityForeground");
console.log("[Demo] 5listKey7:" + JSON.stringify(listKey7));
},
onAbilityBackground(ability) {
console.log("[Demo] AbilityLifecycleCallback7 onAbilityBackground ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback7 onAbilityBackground abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityBackground");
listKey7.push(abilityname + " onAbilityBackground");
console.log("[Demo] 6listKey7:" + JSON.stringify(listKey7));
},
onAbilityContinue(ability) {
console.log("[Demo] AbilityLifecycleCallback7 onAbilityContinue ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback7 onAbilityContinue abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityContinue");
listKey7.push(abilityname + " onAbilityContinue");
console.log("[Demo] 7listKey7:" + JSON.stringify(listKey7));
}
}
globalThis.applicationContext7 = this.context.getApplicationContext();
let lifecycleid = globalThis.applicationContext7.on('abilityLifecycle', AbilityLifecycleCallback);
console.log("[Demo] AbilityLifecycleCallback7 number: " + JSON.stringify(lifecycleid));
setTimeout(function () {
console.log("[Demo] AbilityLifecycleCallback7 listKey: " + JSON.stringify(listKey7));
globalThis.list7 = listKey7;
globalThis.callbackid7 = lifecycleid;
}, 1500);
}
onBackground() {
// Ability has back to background
console.log("[Demo] MainAbility7 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 MainAbility8 extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] MainAbility8 onCreate")
globalThis.abilityWant8 = want;
}
onDestroy() {
console.log("[Demo] MainAbility8 onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] MainAbility8 onWindowStageCreate")
globalThis.ability8 = this.context;
windowStage.loadContent('testability/pages/index8', (err, data) => {
if (err.code) {
console.log('MainAbility8 loadContent error');
return;
}
console.log('MainAbility8 loadContent success');
});
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[Demo] MainAbility8 onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] MainAbility8 onForeground")
var listKey8 = [];
let AbilityLifecycleCallback = {
onAbilityCreate(ability) {
console.log("[Demo] AbilityLifecycleCallback8 onAbilityCreate ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback8 onAbilityCreate abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityCreate");
listKey8.push(abilityname + " onAbilityCreate");
console.log("[Demo] 1listKey8:" + JSON.stringify(listKey8));
},
onWindowStageCreate(ability, windowStage) {
console.log("[Demo] AbilityLifecycleCallback8 onWindowStageCreate ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback8 onWindowStageCreate abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onWindowStageCreate");
listKey8.push(abilityname + " onWindowStageCreate");
console.log("[Demo] 2listKey8:" + JSON.stringify(listKey8));
},
onWindowStageActive(ability, windowStage) {
let abilityname = ability.context.abilityInfo.name;
console.log(abilityname + " onWindowStageActive")
},
onWindowStageInactive(ability, windowStage) {
let abilityname = ability.context.abilityInfo.name;
console.log(abilityname + " onWindowStageInactive")
},
onWindowStageDestroy(ability, windowStage) {
console.log("[Demo] AbilityLifecycleCallback8 onWindowStageDestroy ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback8 onWindowStageDestroy abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onWindowStageDestroy");
listKey8.push(abilityname + " onWindowStageDestroy");
console.log("[Demo] 3listKey8:" + JSON.stringify(listKey8));
},
onAbilityDestroy(ability) {
console.log("[Demo] AbilityLifecycleCallback8 onAbilityDestroy ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback8 onAbilityDestroy abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityDestroy");
listKey8.push(abilityname + " onAbilityDestroy");
console.log("[Demo] 4listKey8:" + JSON.stringify(listKey8));
},
onAbilityForeground(ability) {
console.log("[Demo] AbilityLifecycleCallback8 onAbilityForeground ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback8 onAbilityForeground abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityForeground");
listKey8.push(abilityname + " onAbilityForeground");
console.log("[Demo] 5listKey8:" + JSON.stringify(listKey8));
},
onAbilityBackground(ability) {
console.log("[Demo] AbilityLifecycleCallback8 onAbilityBackground ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback8 onAbilityBackground abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityBackground");
listKey8.push(abilityname + " onAbilityBackground");
console.log("[Demo] 6listKey8:" + JSON.stringify(listKey8));
},
onAbilityContinue(ability) {
console.log("[Demo] AbilityLifecycleCallback8 onAbilityContinue ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback8 onAbilityContinue abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityContinue");
listKey8.push(abilityname + " onAbilityContinue");
console.log("[Demo] 7listKey8:" + JSON.stringify(listKey8));
}
}
globalThis.applicationContext8 = this.context.getApplicationContext();
let lifecycleid = globalThis.applicationContext8.on('abilityLifecycle', AbilityLifecycleCallback);
console.log("[Demo] AbilityLifecycleCallback8 number: " + JSON.stringify(lifecycleid));
setTimeout(function () {
console.log("[Demo] AbilityLifecycleCallback8 listKey: " + JSON.stringify(listKey8));
globalThis.list8 = listKey8;
globalThis.callbackid8 = lifecycleid;
}, 1500);
}
onBackground() {
// Ability has back to background
console.log("[Demo] MainAbility8 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 MainAbility9 extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] MainAbility9 onCreate")
globalThis.abilityWant9 = want;
}
onDestroy() {
console.log("[Demo] MainAbility9 onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] MainAbility9 onWindowStageCreate")
windowStage.loadContent('testability/pages/index9', (err, data) => {
if (err.code) {
console.log('MainAbility9 loadContent error');
return;
}
console.log('MainAbility9 loadContent success');
});
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[Demo] MainAbility9 onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] MainAbility9 onForeground")
var listKey9 = [];
var abilityName = "";
let AbilityLifecycleCallback = {
onAbilityCreate(ability) {
abilityName = ability.context.abilityInfo.name;
console.log(abilityName + " onAbilityCreate")
listKey9.push(abilityName + " onAbilityCreate");
},
onWindowStageCreate(ability, windowStage) {
abilityName = ability.context.abilityInfo.name;
console.log(abilityName + " onWindowStageCreate")
listKey9.push(abilityName + " onWindowStageCreate");
},
onWindowStageActive(ability, windowStage) {
abilityName = ability.context.abilityInfo.name;
console.log(abilityName + " onWindowStageActive")
},
onWindowStageInactive(ability, windowStage) {
abilityName = ability.context.abilityInfo.name;
console.log(abilityName + " onWindowStageInactive")
},
onAbilityForeground(ability) {
abilityName = ability.context.abilityInfo.name;
console.log(abilityName + " onAbilityForeground")
listKey9.push(abilityName + " onAbilityForeground");
},
onAbilityBackground(ability) {
abilityName = ability.context.abilityInfo.name;
console.log(abilityName + " onAbilityBackground")
listKey9.push(abilityName + " onAbilityBackground");
},
onWindowStageDestroy(ability, windowStage) {
abilityName = ability.context.abilityInfo.name;
console.log(abilityName + " onWindowStageDestroy")
listKey9.push(abilityName + " onWindowStageDestroy");
},
onAbilityDestroy(ability) {
abilityName = ability.context.abilityInfo.name;
console.log(abilityName + " onAbilityDestroy")
listKey9.push(abilityName + " onAbilityDestroy");
},
onAbilityContinue(ability) {
abilityName = ability.context.abilityInfo.name;
console.log(abilityName + " onAbilityContinue")
listKey9.push(abilityName + " onAbilityContinue");
}
}
globalThis.applicationContext9 = this.context.getApplicationContext();
var callBackId = globalThis.applicationContext9.on('abilityLifecycle', AbilityLifecycleCallback);
console.log("callBackId is aaa :" + callBackId);
setTimeout(() => {
globalThis.mainAbility9ListKey = listKey9
globalThis.mainAbility9CallBackId = callBackId
console.log("listKey is :" + listKey9);
console.log("callBackId is :" + callBackId);
}, 3000)
}
onBackground() {
// Ability has back to background
console.log("[Demo] MainAbility9 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'
var listKey1 = [];
export default class MultiMainability1 extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] MultiMainability1 onCreate")
globalThis.abilityWant1 = want;
console.log("[Demo] MultiMainability1 context: " + JSON.stringify(this.context));
let AbilityLifecycleCallback = {
onAbilityCreate(ability) {
console.log("[Demo] AbilityLifecycleCallback1 onAbilityCreate ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback1 onAbilityCreate abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityCreate");
listKey1.push(abilityname + " onAbilityCreate");
console.log("[Demo] 1listKey1:" + JSON.stringify(listKey1));
},
onWindowStageCreate(ability, windowStage) {
console.log("[Demo] AbilityLifecycleCallback1 onWindowStageCreate ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback1 onWindowStageCreate abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onWindowStageCreate");
listKey1.push(abilityname + " onWindowStageCreate");
console.log("[Demo] 2listKey1:" + JSON.stringify(listKey1));
},
onWindowStageActive(ability, windowStage) {
let abilityname = ability.context.abilityInfo.name;
console.log(abilityname + " onWindowStageActive")
},
onWindowStageInactive(ability, windowStage) {
let abilityname = ability.context.abilityInfo.name;
console.log(abilityname + " onWindowStageInactive")
},
onWindowStageDestroy(ability, windowStage) {
console.log("[Demo] AbilityLifecycleCallback1 onWindowStageDestroy ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
listKey1.push(abilityname + " onWindowStageDestroy");
console.log("[Demo] 3listKey1:" + JSON.stringify(listKey1));
},
onAbilityDestroy(ability) {
console.log("[Demo] AbilityLifecycleCallback1 onAbilityDestroy ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback1 onAbilityDestroy abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityDestroy");
listKey1.push(abilityname + " onAbilityDestroy");
console.log("[Demo] 4listKey1:" + JSON.stringify(listKey1));
},
onAbilityForeground(ability) {
console.log("[Demo] AbilityLifecycleCallback1 onAbilityForeground ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback1 onAbilityForeground abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityForeground");
listKey1.push(abilityname + " onAbilityForeground");
console.log("[Demo] 5listKey1:" + JSON.stringify(listKey1));
},
onAbilityBackground(ability) {
console.log("[Demo] AbilityLifecycleCallback1 onAbilityBackground ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback1 onAbilityBackground abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityBackground");
listKey1.push(abilityname + " onAbilityBackground");
console.log("[Demo] 6listKey1:" + JSON.stringify(listKey1));
},
onAbilityContinue(ability) {
console.log("[Demo] AbilityLifecycleCallback1 onAbilityContinue ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback1 onAbilityContinue abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityContinue");
listKey1.push(abilityname + " onAbilityContinue");
console.log("[Demo] 7listKey1:" + JSON.stringify(listKey1));
}
}
globalThis.applicationContext1 = this.context.getApplicationContext();
let lifecycleid = globalThis.applicationContext1.on('abilityLifecycle', AbilityLifecycleCallback);
console.log("[Demo] registerAbilityLifecycleCallback1 number: " + JSON.stringify(lifecycleid));
setTimeout(function () {
console.log("[Demo] registerAbilityLifecycleCallback1 listKey: " + JSON.stringify(listKey1));
globalThis.mlist1 = listKey1;
globalThis.mCallbackid1 = lifecycleid;
}, 1000);
}
onDestroy() {
console.log("[Demo] MultiMainability1 onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] MultiMainability1 onWindowStageCreate")
globalThis.ability1context = this.context;
windowStage.loadContent('testability/pages/index1', (err, data) => {
if (err.code) {
console.log('MultiMainability1 loadContent error');
return;
}
console.log('MultiMainability1 loadContent success');
});
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[Demo] MultiMainability1 onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] MultiMainability1 onForeground")
}
onBackground() {
// Ability has back to background
console.log("[Demo] MultiMainability1 onBackground")
}
};
/*
* 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 UIAbility from '@ohos.app.ability.UIAbility';
import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
import hilog from '@ohos.hilog';
import { Hypium } from '@ohos/hypium';
import testsuite from '../test/List.test';
import window from '@ohos.window';
export default class TestAbility extends UIAbility {
onCreate(want, launchParam) {
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.info(0x0000, 'testTag', '%{public}s', 'start run testcase!!!');
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
onDestroy() {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onDestroy');
}
onWindowStageCreate(windowStage: window.WindowStage) {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageCreate');
globalThis.abilityContext = this.context;
windowStage.loadContent('TestAbility/pages/Index', (err, data) => {
if (err.code) {
hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
return;
}
hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s',
JSON.stringify(data) ?? '');
});
}
onWindowStageDestroy() {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageDestroy');
}
onForeground() {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onForeground');
}
onBackground() {
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.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
/*
* 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 Index1 {
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('Hello World Mainability1')
.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 Index10 {
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('Hello World Mainability10')
.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 Index11 {
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('Hello World Mainability11')
.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 Index12 {
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('Hello World Mainability12')
.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 Index2 {
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('Hello World Mainability2')
.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 Index3 {
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('Hello World Mainability3')
.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 Index4 {
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('Hello World Mainability4')
.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 Index5 {
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('Hello World Mainability5')
.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 Index6 {
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('Hello World Mainability6')
.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 Index7 {
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('Hello World Mainability7')
.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 Index8 {
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('Hello World Mainability8')
.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 Index9 {
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('Hello World Mainability9')
.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 indexh1a1 {
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('Hello World Hap1MainAbility1')
.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 indexh1a2 {
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('Hello World Hap1MainAbility2')
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
import hilog from '@ohos.hilog';
import TestRunner from '@ohos.application.testRunner';
import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
var abilityDelegator = undefined
var abilityDelegatorArguments = undefined
async function onAbilityCreateCallback() {
hilog.info(0x0000, 'testTag', '%{public}s', 'onAbilityCreateCallback');
}
async function addAbilityMonitorCallback(err: any) {
hilog.info(0x0000, 'testTag', 'addAbilityMonitorCallback : %{public}s', JSON.stringify(err) ?? '');
}
export default class OpenHarmonyTestRunner implements TestRunner {
constructor() {
}
onPrepare() {
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare ');
}
async onRun() {
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
var debug = abilityDelegatorArguments.parameters['-D']
if (debug == 'true')
{
cmd += ' -D'
}
hilog.info(0x0000, 'testTag', 'cmd : %{public}s', cmd);
abilityDelegator.executeShellCommand(cmd,
(err: any, d: any) => {
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 LifeCycleTest from './LifeCycleTest.test'
export default function testsuite() {
LifeCycleTest()
}
\ No newline at end of file
{
"module": {
"name": "entry_test",
"type": "feature",
"srcEntry": "./ets/Application/AbilityStage.ts",
"description": "$string:module_test_desc",
"mainElement": "TestAbility",
"deviceTypes": [
"phone"
],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:test_pages",
"abilities": [
{
"name": "TestAbility",
"srcEntry": "./ets/TestAbility/TestAbility.ets",
"description": "$string:TestAbility_desc",
"icon": "$media:icon",
"label": "$string:TestAbility_label",
"exported": true,
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:start_window_background",
"skills": [
{
"actions": [
"action.system.home"
],
"entities": [
"entity.system.home"
]
}
]
},
{
"name": "MainAbility1",
"srcEntry": "./ets/MainAbility1/MainAbility1.ts",
"description": "$string:MainAbility1_desc",
"icon": "$media:icon",
"label": "$string:MainAbility1_label",
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:start_window_background"
},
{
"name": "MainAbility2",
"srcEntry": "./ets/MainAbility2/MainAbility2.ts",
"description": "$string:MainAbility2_desc",
"icon": "$media:icon",
"label": "$string:MainAbility2_label",
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:start_window_background"
},
{
"name": "MainAbility3",
"srcEntry": "./ets/MainAbility3/MainAbility3.ts",
"description": "$string:MainAbility3_desc",
"icon": "$media:icon",
"label": "$string:MainAbility3_label",
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:start_window_background"
},
{
"name": "MainAbility4",
"srcEntry": "./ets/MainAbility4/MainAbility4.ts",
"description": "$string:MainAbility4_desc",
"icon": "$media:icon",
"label": "$string:MainAbility4_label",
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:start_window_background"
},
{
"name": "MainAbility5",
"srcEntry": "./ets/MainAbility5/MainAbility5.ts",
"description": "$string:MainAbility5_desc",
"icon": "$media:icon",
"label": "$string:MainAbility5_label",
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:start_window_background"
},
{
"name": "MainAbility6",
"srcEntry": "./ets/MainAbility6/MainAbility6.ts",
"description": "$string:MainAbility6_desc",
"icon": "$media:icon",
"label": "$string:MainAbility6_label",
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:start_window_background"
},
{
"name": "MainAbility7",
"srcEntry": "./ets/MainAbility7/MainAbility7.ts",
"description": "$string:MainAbility7_desc",
"launchType": "singleton",
"icon": "$media:icon",
"label": "$string:MainAbility7_label",
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:start_window_background"
},
{
"name": "MainAbility8",
"srcEntry": "./ets/MainAbility8/MainAbility8.ts",
"description": "$string:MainAbility8_desc",
"launchType": "standard",
"icon": "$media:icon",
"label": "$string:MainAbility8_label",
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:start_window_background"
},
{
"name": "MainAbility9",
"srcEntry": "./ets/MainAbility9/MainAbility9.ts",
"description": "$string:MainAbility9_desc",
"icon": "$media:icon",
"label": "$string:MainAbility9_label",
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:start_window_background"
},
{
"name": "Hap1MainAbility1",
"srcEntry": "./ets/Hap1MainAbility1/Hap1MainAbility1.ts",
"description": "$string:Hap1MainAbility1_desc",
"icon": "$media:icon",
"label": "$string:Hap1MainAbility1_label",
"launchType": "singleton",
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:start_window_background"
},
{
"name": "Hap1MainAbility2",
"srcEntry": "./ets/Hap1MainAbility2/Hap1MainAbility2.ts",
"description": "$string:Hap1MainAbility2_desc",
"icon": "$media:icon",
"label": "$string:Hap1MainAbility2_label",
"launchType": "standard",
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:start_window_background"
},
{
"name": "MainAbility10",
"srcEntry": "./ets/MainAbility10/MainAbility10.ts",
"description": "$string:MainAbility10_desc",
"icon": "$media:icon",
"label": "$string:MainAbility10_label",
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:start_window_background"
},
{
"name": "MainAbility11",
"srcEntry": "./ets/MainAbility11/MainAbility11.ts",
"description": "$string:MainAbility11_desc",
"icon": "$media:icon",
"label": "$string:MainAbility11_label",
"launchType": "standard",
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:start_window_background"
},
{
"name": "MainAbility12",
"srcEntry": "./ets/MainAbility12/MainAbility12.ts",
"description": "$string:MainAbility12_desc",
"icon": "$media:icon",
"label": "$string:MainAbility12_label",
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:start_window_background"
},
{
"name": "MainAbility13",
"srcEntry": "./ets/MainAbility13/MainAbility13.ts",
"description": "$string:MainAbility12_desc",
"icon": "$media:icon",
"label": "$string:MainAbility12_label",
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:start_window_background"
},
{
"name": "MainAbility14",
"srcEntry": "./ets/MainAbility14/MainAbility14.ts",
"description": "$string:MainAbility12_desc",
"icon": "$media:icon",
"label": "$string:MainAbility12_label",
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:start_window_background"
},
{
"name": "MultiMainability1",
"srcEntry": "./ets/MultiMainability1/MultiMainability1.ts",
"description": "$string:MultiMainability1_desc",
"icon": "$media:icon",
"launchType": "standard",
"label": "$string:MultiMainability1_label",
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:start_window_background"
}
]
}
}
{
"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"
},
{
"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": "entry_desc",
"value": "description"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
},
{
"name": "MainAbility1_desc",
"value": "description"
},
{
"name": "MainAbility1_label",
"value": "label"
},
{
"name": "MainAbility2_desc",
"value": "description"
},
{
"name": "MainAbility2_label",
"value": "label"
},
{
"name": "MainAbility3_desc",
"value": "description"
},
{
"name": "MainAbility3_label",
"value": "label"
},
{
"name": "MainAbility4_desc",
"value": "description"
},
{
"name": "MainAbility4_label",
"value": "label"
},
{
"name": "MainAbility5_desc",
"value": "description"
},
{
"name": "MainAbility5_label",
"value": "label"
},
{
"name": "MainAbility6_desc",
"value": "description"
},
{
"name": "MainAbility6_label",
"value": "label"
},
{
"name": "MainAbility7_desc",
"value": "description"
},
{
"name": "MainAbility7_label",
"value": "label"
},
{
"name": "MainAbility8_desc",
"value": "description"
},
{
"name": "MainAbility8_label",
"value": "label"
},
{
"name": "MainAbility9_desc",
"value": "description"
},
{
"name": "MainAbility9_label",
"value": "label"
},
{
"name": "Hap1MainAbility1_desc",
"value": "description"
},
{
"name": "Hap1MainAbility1_label",
"value": "label"
},
{
"name": "Hap1MainAbility2_desc",
"value": "description"
},
{
"name": "Hap1MainAbility2_label",
"value": "label"
},
{
"name": "MainAbility10_desc",
"value": "description"
},
{
"name": "MainAbility10_label",
"value": "label"
},
{
"name": "MainAbility11_desc",
"value": "description"
},
{
"name": "MainAbility11_label",
"value": "label"
},
{
"name": "MainAbility12_desc",
"value": "description"
},
{
"name": "MainAbility12_label",
"value": "label"
},
{
"name": "MainAbility13_desc",
"value": "description"
},
{
"name": "MainAbility13_label",
"value": "label"
},
{
"name": "MultiMainability1_desc",
"value": "description"
},
{
"name": "MultiMainability1_label",
"value": "label"
}
]
}
\ No newline at end of file
{
"src": [
"TestAbility/pages/Index",
"TestAbility/pages/index1",
"TestAbility/pages/index2",
"TestAbility/pages/index3",
"TestAbility/pages/index4",
"TestAbility/pages/index5",
"TestAbility/pages/index6",
"TestAbility/pages/index7",
"TestAbility/pages/index8",
"TestAbility/pages/index9",
"TestAbility/pages/index10",
"TestAbility/pages/index11",
"TestAbility/pages/index12",
"TestAbility/pages/indexh1a1",
"TestAbility/pages/indexh1a2"
]
}
{
"app": {
"bundleName": "com.example.uiabilitylifecycle",
"vendor": "example",
"versionCode": 1000000,
"versionName": "1.0.0",
"icon": "$media:app_icon",
"label": "$string:app_name",
"minAPIVersion": 9,
"targetAPIVersion": 9,
"car": {
"apiCompatibleVersion": 9,
"singleUser": false
}
}
}
# 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("ActsUiAbilityEtsTest") {
hap_profile = "src/main/module.json"
deps = [
":windowStage_js_assets",
":windowStage_resources",
]
ets2abc = true
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsUiAbilityEtsTest"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("windowStage_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("windowStage_js_assets") {
source_dir = "src/main/ets"
}
ohos_resources("windowStage_resources") {
sources = [ "src/main/resources" ]
deps = [ ":windowStage_app_profile" ]
hap_profile = "src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "60000",
"shell-timeout": "60000",
"testcase-timeout": 15000,
"bundle-name": "com.example.uiabilitylifecycle",
"module-name": "entry_test"
},
"kits": [
{
"test-file-name": [
"ActsUiAbilityEtsTest.hap",
"commonTestAbilityApp.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
\ No newline at end of file
import AbilityStage from '@ohos.app.ability.AbilityStage';
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("[Demo] MyAbilityStage onCreate")
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Ability from '@ohos.app.ability.UIAbility'
let abilityName = null;
function recordLife(ownList, abilityName, lifeName) {
ownList.push(abilityName + ' ' + lifeName);
}
export default class MainAbility1 extends Ability {
onNewWant(want, launchParam) {
console.log("[Demo] MainAbility1 onNewWant")
globalThis.onNewWantStr = abilityName + ' ' + 'onNewWant';
}
onCreate(want, launchParam) {
console.log("[Demo] MainAbility1 onCreate")
globalThis.launchParam1 = launchParam;
abilityName = want.abilityName
globalThis.list1 = [];
recordLife(globalThis.list1, abilityName, 'onCreate');
}
onDestroy() {
console.log("[Demo] MainAbility1 onDestroy")
recordLife(globalThis.list1, abilityName, 'onDestroy');
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] MainAbility1 onWindowStageCreate")
globalThis.ability1context = this.context;
recordLife(globalThis.list1, abilityName, 'onWindowStageCreate');
windowStage.loadContent('TestAbility/pages/Index1', (err, data) => {
if (err.code) {
console.log('MainAbility1 loadContent error');
return;
}
console.log('MainAbility1 loadContent success');
});
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[Demo] MainAbility1 onWindowStageDestroy")
recordLife(globalThis.list1, abilityName, 'onWindowStageDestroy');
}
onForeground() {
console.log("[Demo] MainAbility1 onForeground")
recordLife(globalThis.list1, abilityName, 'onForeground');
}
onBackground() {
// Ability has back to background
console.log("[Demo] MainAbility1 onBackground")
recordLife(globalThis.list1, abilityName, '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'
let abilityName = null;
function recordLife(ownList, abilityName, lifeName) {
ownList.push(abilityName + ' ' + lifeName);
}
export default class MainAbility2 extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] MainAbility2 onCreate")
abilityName = want.abilityName
globalThis.list2 = [];
recordLife(globalThis.list2, abilityName, 'onCreate');
}
onDestroy() {
console.log("[Demo] MainAbility2 onDestroy")
recordLife(globalThis.list2, abilityName, 'onDestroy');
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] MainAbility2 onWindowStageCreate")
globalThis.ability2context = this.context;
recordLife(globalThis.list2, abilityName, 'onWindowStageCreate');
windowStage.loadContent('TestAbility/pages/Index2', (err, data) => {
if (err.code) {
console.log('MainAbility2 loadContent error');
return;
}
console.log('MainAbility2 loadContent success');
});
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[Demo] MainAbility2 onWindowStageDestroy")
recordLife(globalThis.list2, abilityName, 'onWindowStageDestroy');
}
onForeground() {
console.log("[Demo] MainAbility2 onForeground")
recordLife(globalThis.list2, abilityName, 'onForeground');
setTimeout(function () {
console.log("[Demo] MainAbility2 onForeground after 1500ms")
globalThis.ability2context.terminateSelf()
.then((data) => {
console.info('[Demo] MainAbility2 terminateself succeeded: ' + data);
}).catch((error) => {
console.error('[Demo] MainAbility2 terminateself failed. Cause: ' + error);
})
}, 1500);
}
onBackground() {
// Ability has back to background
console.log("[Demo] MainAbility2 onBackground")
recordLife(globalThis.list2, abilityName, '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'
let abilityName = null;
function recordLife(ownList, abilityName, lifeName) {
ownList.push(abilityName + ' ' + lifeName);
}
export default class MainAbility3 extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] MainAbility3 onCreate")
abilityName = want.abilityName
globalThis.list3 = [];
recordLife(globalThis.list3, abilityName, 'onCreate');
}
onDestroy() {
console.log("[Demo] MainAbility3 onDestroy")
recordLife(globalThis.list3, abilityName, 'onDestroy');
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] MainAbility3 onWindowStageCreate")
globalThis.ability3context = this.context;
recordLife(globalThis.list3, abilityName, 'onWindowStageCreate');
windowStage.loadContent('TestAbility/pages/Index2', (err, data) => {
if (err.code) {
console.log('MainAbility3 loadContent error');
return;
}
console.log('MainAbility3 loadContent success');
});
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[Demo] MainAbility3 onWindowStageDestroy")
recordLife(globalThis.list3, abilityName, 'onWindowStageDestroy');
}
onForeground() {
console.log("[Demo] MainAbility3 onForeground")
recordLife(globalThis.list3, abilityName, 'onForeground');
}
onBackground() {
// Ability has back to background
console.log("[Demo] MainAbility3 onBackground")
recordLife(globalThis.list3, abilityName, 'onBackground');
}
};
/*
* 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 UIAbility from '@ohos.app.ability.UIAbility';
import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
import hilog from '@ohos.hilog';
import { Hypium } from '@ohos/hypium';
import testsuite from '../test/List.test';
import window from '@ohos.window';
export default class TestAbility extends UIAbility {
onCreate(want, launchParam) {
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.info(0x0000, 'testTag', '%{public}s', 'start run testcase!!!');
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
onDestroy() {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onDestroy');
}
onWindowStageCreate(windowStage: window.WindowStage) {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageCreate');
windowStage.loadContent('TestAbility/pages/Index', (err, data) => {
if (err.code) {
hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
return;
}
hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s',
JSON.stringify(data) ?? '');
});
globalThis.abilityContext = this.context;
}
onWindowStageDestroy() {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageDestroy');
}
onForeground() {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onForeground');
}
onBackground() {
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.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
/*
* 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 Index1 {
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('Hello World Mainability1')
.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 Index2 {
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('Hello World Mainability2')
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
import hilog from '@ohos.hilog';
import TestRunner from '@ohos.application.testRunner';
import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
var abilityDelegator = undefined
var abilityDelegatorArguments = undefined
async function onAbilityCreateCallback() {
hilog.info(0x0000, 'testTag', '%{public}s', 'onAbilityCreateCallback');
}
async function addAbilityMonitorCallback(err: any) {
hilog.info(0x0000, 'testTag', 'addAbilityMonitorCallback : %{public}s', JSON.stringify(err) ?? '');
}
export default class OpenHarmonyTestRunner implements TestRunner {
constructor() {
}
onPrepare() {
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare ');
}
async onRun() {
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
var debug = abilityDelegatorArguments.parameters['-D']
if (debug == 'true')
{
cmd += ' -D'
}
hilog.info(0x0000, 'testTag', 'cmd : %{public}s', cmd);
abilityDelegator.executeShellCommand(cmd,
(err: any, d: any) => {
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 abilityLifeCycleTest from './abilityLifeCycle.test'
export default function testsuite() {
abilityLifeCycleTest()
}
\ No newline at end of file
{
"module": {
"name": "entry_test",
"type": "feature",
"description": "$string:module_test_desc",
"mainElement": "TestAbility",
"deviceTypes": [
"phone"
],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:test_pages",
"abilities": [
{
"name": "TestAbility",
"srcEntry": "./ets/TestAbility/TestAbility.ets",
"description": "$string:TestAbility_desc",
"icon": "$media:icon",
"label": "$string:TestAbility_label",
"exported": true,
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:start_window_background",
"skills": [
{
"actions": [
"action.system.home"
],
"entities": [
"entity.system.home"
]
}
]
},
{
"name": "MainAbility1",
"srcEntry": "./ets/MainAbility1/MainAbility1.ts",
"description": "$string:MainAbility1_desc",
"icon": "$media:icon",
"launchType": "singleton",
"label": "$string:MainAbility1_label",
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:start_window_background"
},
{
"name": "MainAbility2",
"srcEntry": "./ets/MainAbility2/MainAbility2.ts",
"description": "$string:MainAbility2_desc",
"icon": "$media:icon",
"label": "$string:MainAbility2_label",
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:start_window_background"
},
{
"name": "MainAbility3",
"srcEntry": "./ets/MainAbility3/MainAbility3.ts",
"description": "$string:MainAbility2_desc",
"launchType": "standard",
"icon": "$media:icon",
"label": "$string:MainAbility2_label",
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:start_window_background"
}
]
}
}
{
"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"
},
{
"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": "entry_desc",
"value": "description"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
},
{
"name": "MainAbility1_desc",
"value": "description"
},
{
"name": "MainAbility1_label",
"value": "label"
},
{
"name": "MainAbility2_desc",
"value": "description"
},
{
"name": "MainAbility2_label",
"value": "label"
},
{
"name": "MainAbility3_desc",
"value": "description"
},
{
"name": "MainAbility3_label",
"value": "label"
},
{
"name": "MainAbility4_desc",
"value": "description"
},
{
"name": "MainAbility4_label",
"value": "label"
},
{
"name": "MainAbility5_desc",
"value": "description"
},
{
"name": "MainAbility5_label",
"value": "label"
},
{
"name": "MainAbility6_desc",
"value": "description"
},
{
"name": "MainAbility6_label",
"value": "label"
},
{
"name": "MainAbility7_desc",
"value": "description"
},
{
"name": "MainAbility7_label",
"value": "label"
},
{
"name": "MainAbility8_desc",
"value": "description"
},
{
"name": "MainAbility8_label",
"value": "label"
},
{
"name": "MainAbility9_desc",
"value": "description"
},
{
"name": "MainAbility9_label",
"value": "label"
},
{
"name": "Hap1MainAbility1_desc",
"value": "description"
},
{
"name": "Hap1MainAbility1_label",
"value": "label"
},
{
"name": "Hap1MainAbility2_desc",
"value": "description"
},
{
"name": "Hap1MainAbility2_label",
"value": "label"
},
{
"name": "MainAbility10_desc",
"value": "description"
},
{
"name": "MainAbility10_label",
"value": "label"
},
{
"name": "MainAbility11_desc",
"value": "description"
},
{
"name": "MainAbility11_label",
"value": "label"
},
{
"name": "MainAbility12_desc",
"value": "description"
},
{
"name": "MainAbility12_label",
"value": "label"
},
{
"name": "MainAbility13_desc",
"value": "description"
},
{
"name": "MainAbility13_label",
"value": "label"
}
]
}
\ No newline at end of file
{
"src": [
"TestAbility/pages/Index",
"TestAbility/pages/Index1",
"TestAbility/pages/Index2"
]
}
...@@ -19,6 +19,10 @@ group("ability_crossplatform_runtime") { ...@@ -19,6 +19,10 @@ group("ability_crossplatform_runtime") {
deps = [ deps = [
"actscontexttest:ActsCrossplatformAbilityContextTest", "actscontexttest:ActsCrossplatformAbilityContextTest",
"actscontexttestentry:ActsCrossplatformAbilityContextEntryTest" "actscontexttestentry:ActsCrossplatformAbilityContextEntryTest"
"ActsLifeCycleEtsFeatureTest:ActsLifeCycleEtsFeatureTest",
"ActsLifeCycleEtsTest:ActsLifeCycleEtsTest",
"ActsUiAbilityEtsTest:ActsUiAbilityEtsTest",
"commonTestAbilityApp:commonTestAbilityApp",
] ]
} }
} }
...@@ -36,4 +36,4 @@ ohos_resources("windowStage_resources") { ...@@ -36,4 +36,4 @@ ohos_resources("windowStage_resources") {
sources = [ "src/main/resources" ] sources = [ "src/main/resources" ]
deps = [ ":windowStage_app_profile" ] deps = [ ":windowStage_app_profile" ]
hap_profile = "src/main/module.json" hap_profile = "src/main/module.json"
} }
\ No newline at end of file
...@@ -36,4 +36,4 @@ ohos_resources("windowStage_resources") { ...@@ -36,4 +36,4 @@ ohos_resources("windowStage_resources") {
sources = [ "src/main/resources" ] sources = [ "src/main/resources" ]
deps = [ ":windowStage_app_profile" ] deps = [ ":windowStage_app_profile" ]
hap_profile = "src/main/module.json" hap_profile = "src/main/module.json"
} }
\ No newline at end of file
{
"app": {
"bundleName": "com.example.commontestabilityapp",
"vendor": "example",
"versionCode": 1000000,
"versionName": "1.0.0",
"icon": "$media:app_icon",
"label": "$string:app_name",
"minAPIVersion": 9,
"targetAPIVersion": 9,
"car": {
"apiCompatibleVersion": 9,
"singleUser": false
}
}
}
# 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("commonTestAbilityApp") {
hap_profile = "src/main/module.json"
deps = [
":windowStage_js_assets",
":windowStage_resources",
]
ets2abc = true
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "commonTestAbilityApp"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("windowStage_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("windowStage_js_assets") {
source_dir = "src/main/ets"
}
ohos_resources("windowStage_resources") {
sources = [ "src/main/resources" ]
deps = [ ":windowStage_app_profile" ]
hap_profile = "src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "60000",
"shell-timeout": "60000",
"bundle-name": "com.example.commontestabilityapp",
"module-name": "entry_test"
},
"kits": [
{
"test-file-name": [
"commonTestAbilityApp.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
\ No newline at end of file
import AbilityStage from '@ohos.app.ability.AbilityStage';
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("[Demo] MyAbilityStage onCreate")
}
}
\ No newline at end of file
/*
* Copyright (c) 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 UIAbility from '@ohos.app.ability.UIAbility';
import window from '@ohos.window';
export default class MainAbility extends UIAbility {
onCreate(want, launchParam) {
globalThis.commonList1 = [];
console.log('testTag', '%{public}s', 'Ability onCreate');
globalThis.commonList1.push('common MainAbility onCreate');
}
onDestroy() {
console.log('testTag', '%{public}s', 'Ability onDestroy');
globalThis.commonList1.push('common MainAbility onDestroy');
}
onWindowStageCreate(windowStage: window.WindowStage) {
// Main window is created, set main page for this ability
console.log('testTag', '%{public}s', 'Ability onWindowStageCreate');
globalThis.commonList1.push('common MainAbility onWindowStageCreate');
globalThis.commonAbilityContext = this.context;
windowStage.loadContent('pages/Index', (err, data) => {
if (err.code) {
console.log('testTag', '%{public}s', 'Ability onWindowStageCreate');
return;
}
console.log('testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? '');
});
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log('testTag', '%{public}s', 'Ability onWindowStageDestroy');
globalThis.commonList1.push('common MainAbility onWindowStageDestroy');
}
onForeground() {
// Ability has brought to foreground
console.log('testTag', '%{public}s', 'Ability onForeground');
globalThis.commonList1.push('common MainAbility onForeground');
setTimeout(function () {
console.log("[Demo] MainAbility onForeground after 1500ms")
globalThis.commonAbilityContext.terminateSelf()
.then((data) => {
console.info('[Demo] MainAbility terminateself succeeded: ' + data);
}).catch((error) => {
console.error('[Demo] MainAbility terminateself failed. Cause: ' + error);
})
}, 1500);
}
onBackground() {
// Ability has back to background
console.log('testTag', '%{public}s', 'Ability onBackground');
globalThis.commonList1.push('common MainAbility onBackground');
}
}
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册