diff --git a/ability/ability_runtime/abilitymontior/entry/src/main/ets/test/Ability.test.ets b/ability/ability_runtime/abilitymontior/entry/src/main/ets/test/Ability.test.ets index 37cbf1f99eb45f18ed24e7e79b360cbb2872bbdd..9b3273043183ca68cf2b29f66291b87c1aaa532e 100644 --- a/ability/ability_runtime/abilitymontior/entry/src/main/ets/test/Ability.test.ets +++ b/ability/ability_runtime/abilitymontior/entry/src/main/ets/test/Ability.test.ets @@ -109,7 +109,10 @@ export default function abilityTest() { data.addAbilityMonitor( { abilityName: 'MainAbility2', - onAbilityForeground: onAbilityForeground + onAbilityForeground: onAbilityForeground, + onWindowStageRestore:(Ability)=>{ + console.info("===>onWindowStageRestore"); + } }, (async (err) => { console.debug("====>ACTS_AddAbilityMonitor_0200 success====>" + err.code); await globalThis.abilitydelegator.startAbility( diff --git a/ability/ability_runtime/actsqueryfunctiontest/actsgetabilitystatestagetest/entry/src/main/ets/test/Ability.test.ets b/ability/ability_runtime/actsqueryfunctiontest/actsgetabilitystatestagetest/entry/src/main/ets/test/Ability.test.ets index aefa1ec9ebfb4b3d81b78eb6f761643b1756899a..06b6e8e828e96db63bf44351a92c8bba1120c3f4 100644 --- a/ability/ability_runtime/actsqueryfunctiontest/actsgetabilitystatestagetest/entry/src/main/ets/test/Ability.test.ets +++ b/ability/ability_runtime/actsqueryfunctiontest/actsgetabilitystatestagetest/entry/src/main/ets/test/Ability.test.ets @@ -97,6 +97,8 @@ export default function abilityTest() { var state = abilityDelegator.getAbilityState(ability); console.debug("====>ACTS_GetAbilityState_0300 state:" + state); expect(state).assertEqual(AbilityDelegatorRegistry.AbilityLifecycleState.FOREGROUND); + expect(state != AbilityDelegatorRegistry.AbilityLifecycleState.CREATE).assertTrue() + expect(state != AbilityDelegatorRegistry.AbilityLifecycleState.DESTROY).assertTrue() abilityDelegator.doAbilityBackground(ability, (err, isBackground)=>{ console.debug("====>doAbilityBackground_0300 data:" + JSON.stringify(isBackground)); expect(isBackground).assertTrue(); diff --git a/ability/ability_runtime/apicover/apicoverhaptest/entry/src/main/ets/CreateFormAbility/CreateFormAbility.ts b/ability/ability_runtime/apicover/apicoverhaptest/entry/src/main/ets/CreateFormAbility/CreateFormAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..481070a0daa9da861c7451a088c1e43afe74414a --- /dev/null +++ b/ability/ability_runtime/apicover/apicoverhaptest/entry/src/main/ets/CreateFormAbility/CreateFormAbility.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import Ability from '@ohos.application.Ability' +export default class CreateFormAbility extends Ability { + + onCreate(want, launchParam) { + console.log("[Demo] CreateFormAbility onCreate") + globalThis.abilityWant = want; + globalThis.applicationContext = this.context.getApplicationContext(); + globalThis.isCreateForm = want.parameters["createForm"]; + } + + onDestroy() { + console.log("[Demo] CreateFormAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("[Demo] CreateFormAbility onWindowStageCreate") + globalThis.abilityContext = this.context; + windowStage.setUIContent(this.context, "CreateFormAbility/pages/MainAbility_pages", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("[Demo] CreateFormAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("[Demo] CreateFormAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("[Demo] SecondAbility onBackground") + } +}; diff --git a/ability/ability_runtime/apicover/apicoverhaptest/entry/src/main/ets/CreateFormAbility/pages/MainAbility_pages.ets b/ability/ability_runtime/apicover/apicoverhaptest/entry/src/main/ets/CreateFormAbility/pages/MainAbility_pages.ets new file mode 100644 index 0000000000000000000000000000000000000000..bd1a181eafb32a9bc64d156d02d9f98bd27aff64 --- /dev/null +++ b/ability/ability_runtime/apicover/apicoverhaptest/entry/src/main/ets/CreateFormAbility/pages/MainAbility_pages.ets @@ -0,0 +1,66 @@ +// @ts-nocheck +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import router from '@ohos.router'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../test/List.test' + +@Entry +@Component +struct Index { + @State message: string = 'CreateFormAbility' + @State isShowing: boolean = true; + + @State formId: number = 0; + @State bundle: string = "com.example.apicoverhaptest"; + @State ability: string = "FormAbility"; + @State moduleName: string = "phone"; + @State name: string = "widget"; + private dimension: FormDimension = FormDimension.Dimension_2_2; + private temporary = false; + + aboutToAppear() { + this.isShowing = globalThis.isCreateForm + } + + build() { + Row() { + Column() { + if (this.isShowing) { + FormComponent({ + id: this.formId, + name: this.name, + bundle: this.bundle, + ability: this.ability, + module: this.moduleName, + dimension: this.dimension, + temporary: this.temporary, + }) + .allowUpdate(this.allowUpate) + .visibility(this.isShowing ? Visibility.Visible : Visibility.Hidden) + .onAcquired((form) => { + console.log("[FormComponent.host] get form, form id:" + form.id); + }) + } + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/apicover/apicoverhaptest/entry/src/main/ets/FormAbility/FormAbility.ts b/ability/ability_runtime/apicover/apicoverhaptest/entry/src/main/ets/FormAbility/FormAbility.ts index 7c6ef8300e32e9aa59af887de858e1882850ed0b..e07c8d2677a609954848949db2d116b99e7ffbe9 100644 --- a/ability/ability_runtime/apicover/apicoverhaptest/entry/src/main/ets/FormAbility/FormAbility.ts +++ b/ability/ability_runtime/apicover/apicoverhaptest/entry/src/main/ets/FormAbility/FormAbility.ts @@ -16,13 +16,27 @@ import FormExtension from '@ohos.application.FormExtension'; import formBindingData from '@ohos.application.formBindingData'; import formInfo from '@ohos.application.formInfo'; +import commonEvent from '@ohos.commonEvent'; -var extensionInfo_config_direction export default class FormAbility extends FormExtension { onCreate(want) { // Called to return a FormBindingData object. - let formData = {}; console.info("FormAbility onCreate") + let formData = { + temperature: "11°", + time: "11:00", + area: "Shenyang" + }; + console.info("FormAbility onCreate===StarAbility=== ") + this.context.startAbility({ + bundleName:"com.example.apicoverhaptest", + abilityName:"SecondAbility" + }).then((data)=>{ + console.info("FormAbility startAbility success") + }).catch((err)=>{ + console.info("FormAbility startAbility failed " + err.code) + }) + console.info("FormAbility onCreate===end=== ") return formBindingData.createFormBindingData(formData); } @@ -49,6 +63,7 @@ export default class FormAbility extends FormExtension { onAcquireFormState(want) { // Called to return a {@link FormState} object. + console.info("FormAbility want success" + JSON.stringify(want.parameters)) return formInfo.FormState.READY; } }; \ No newline at end of file diff --git a/ability/ability_runtime/apicover/apicoverhaptest/entry/src/main/ets/SecondAbility/SecondAbility.ts b/ability/ability_runtime/apicover/apicoverhaptest/entry/src/main/ets/SecondAbility/SecondAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..5a2b21198a7510b760d93a98d453e998258aa43c --- /dev/null +++ b/ability/ability_runtime/apicover/apicoverhaptest/entry/src/main/ets/SecondAbility/SecondAbility.ts @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import Ability from '@ohos.application.Ability' +import commonEvent from '@ohos.commonEvent'; +export default class SecondAbility extends Ability { + + onCreate(want, launchParam) { + console.log("[Demo] SecondAbility onCreate") + globalThis.abilityWant = want; + globalThis.applicationContext = this.context.getApplicationContext(); + } + + onDestroy() { + console.log("[Demo] SecondAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("[Demo] SecondAbility onWindowStageCreate") + globalThis.abilityContext = this.context; + windowStage.setUIContent(this.context, "SecondAbility/pages/MainAbility_pages", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("[Demo] SecondAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("[Demo] SecondAbility onForeground") + var CommonEventPublishData = { + parameters: { + "Life": "onForeground" + } + } + commonEvent.publish("Form_StartAbility", CommonEventPublishData, (err) => { + console.info("Form_StartAbility onCreate"); + }); + } + + onBackground() { + // Ability has back to background + console.log("[Demo] SecondAbility onBackground") + } +}; diff --git a/ability/ability_runtime/apicover/apicoverhaptest/entry/src/main/ets/SecondAbility/pages/MainAbility_pages.ets b/ability/ability_runtime/apicover/apicoverhaptest/entry/src/main/ets/SecondAbility/pages/MainAbility_pages.ets new file mode 100644 index 0000000000000000000000000000000000000000..351e255f16e266ff4d6e6252b1541f1f06aaaf52 --- /dev/null +++ b/ability/ability_runtime/apicover/apicoverhaptest/entry/src/main/ets/SecondAbility/pages/MainAbility_pages.ets @@ -0,0 +1,37 @@ +// @ts-nocheck +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import router from '@ohos.router'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../test/List.test' + +@Entry +@Component +struct Index { + @State message: string = 'MainAbility' + @State create: string = 'MainAbility' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/apicover/apicoverhaptest/entry/src/main/ets/ServiceAbility/ServiceAbility.ts b/ability/ability_runtime/apicover/apicoverhaptest/entry/src/main/ets/ServiceAbility/ServiceAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..9817979907de1adda9ef8802aba894e092a50367 --- /dev/null +++ b/ability/ability_runtime/apicover/apicoverhaptest/entry/src/main/ets/ServiceAbility/ServiceAbility.ts @@ -0,0 +1,63 @@ +/* + * 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 ServiceExtension from '@ohos.application.ServiceExtensionAbility' +import commonEvent from "@ohos.commonEvent"; +import Want from '@ohos.application.Want'; +import rpc from '@ohos.rpc'; +export default class ServiceAbility extends ServiceExtension { + onCreate(want:Want) { + globalThis.abilityWant = want; + let direction = this.context.config.direction + let pointerDervice = this.context.config.hasPointerDevice + let AbilityInfo = this.context.extensionAbilityInfo.bundleName + console.log('ServiceAbility onCreate, want: ' + want.abilityName); + var CommonEventPublishData = { + parameters: { + "config": direction, + "poniterDevices": pointerDervice, + "AbilityInfo":AbilityInfo + } + } + commonEvent.publish("ExtensionConext_StartAbility", CommonEventPublishData, (err) => { + console.info("ExtensionConext_StartAbility onCreate"); + }); + } + + onRequest(want, startId) { + console.log('ServiceAbility onRequest, want: ' + want.abilityName + ', startId: ' + startId); + console.log('ServiceAbility registerApplicationStateObserver begin'); + setTimeout(()=>{ + this.context.terminateSelf().then((data) => { + console.info("terminateSelf data = " + JSON.stringify(data)); + }).catch((err) => { + console.info("terminateSelf err = " + JSON.stringify(err)); + }); + }, 3000) + } + + onConnect(want) { + console.log('ServiceAbility onConnect, want:' + want.abilityName); + return null; + } + + onDisconnect(want) { + console.log('ServiceAbility onDisconnect, want:' + want.abilityName); + } + + onDestroy() { + console.log('ServiceAbility onDestroy'); + } +} \ No newline at end of file diff --git a/ability/ability_runtime/apicover/apicoverhaptest/entry/src/main/ets/test/ApiCoverAbility.test.ets b/ability/ability_runtime/apicover/apicoverhaptest/entry/src/main/ets/test/ApiCoverAbility.test.ets index 7d18d34f735b4bf48847b4f75a7b563366aea7e9..b4e284fc6c97d8a30f2b00837e708a9683bb0f1b 100644 --- a/ability/ability_runtime/apicover/apicoverhaptest/entry/src/main/ets/test/ApiCoverAbility.test.ets +++ b/ability/ability_runtime/apicover/apicoverhaptest/entry/src/main/ets/test/ApiCoverAbility.test.ets @@ -17,6 +17,14 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from import formProvider from '@ohos.application.formProvider'; import FormInfo from '@ohos.application.formInfo'; import formError from '@ohos.application.formError'; +import formHost from '@ohos.application.formHost'; +import errorManager from '@ohos.application.errorManager'; +import abilityConstant from '@ohos.application.AbilityConstant' +import appManager from '@ohos.application.appManager' +import appContext from '@ohos.application.context' +import commonEvent from '@ohos.commonEvent'; +import ability from '@ohos.ability.ability' +FormDimension var EXTENSION_INFO_ERR = 2097152 var USERID_ERR = 2097177 var trueInfo; @@ -315,6 +323,9 @@ export default function ApiCoverTest() { expect("ohos.extra.param.key.form_name").assertEqual(FormInfo.FormParam.NAME_KEY) expect("ohos.extra.param.key.form_temporary").assertEqual(FormInfo.FormParam.TEMPORARY_KEY) expect("ohos.extra.param.key.form_width").assertEqual(FormInfo.FormParam.WIDTH_KEY) + expect("ohos.extra.param.key.form_identity").assertEqual(FormInfo.FormParam.IDENTITY_KEY) + expect("ohos.extra.param.key.bundle_name").assertEqual(FormInfo.FormParam.BUNDLE_NAME_KEY) + expect("ohos.extra.param.key.ability_name").assertEqual(FormInfo.FormParam.ABILITY_NAME_KEY) expect(0).assertEqual(FormInfo.FormState.DEFAULT) expect(1).assertEqual(FormInfo.FormState.READY) expect(-1).assertEqual(FormInfo.FormState.UNKNOWN) @@ -322,5 +333,248 @@ export default function ApiCoverTest() { expect(1).assertEqual(FormInfo.ColorMode.MODE_LIGHT) done(); }); + + /* + * @tc.number SUB_AA_ReisterErrorObserver_0100 + * @tc.name Test ReisterErrorObserver. + * @tc.desc Function test + * @tc.level 3 + */ + it('SUB_AA_ReisterErrorObserver_0100', 0, async function (done) { + let errorObserver:errorManager.ErrorObserver; + errorObserver = { + onUnhandledException:(errMessage) => { + console.info("SUB_AA_ReisterErrorObserver_0100" + JSON.stringify(errMessage)); + } + } + let errCodeId = errorManager.registerErrorObserver(errorObserver) + expect(errCodeId).assertEqual(0) + errorManager.unregisterErrorObserver(errCodeId).then((data)=>{ + expect(data).assertEqual(undefined) + done(); + }).catch((err)=>{ + expect().assertFail() + done(); + }) + }); + + /* + * @tc.number SUB_AA_ReisterErrorObserver_0200 + * @tc.name Test unregisterErrorObserver with error number. + * @tc.desc Function test + * @tc.level 3 + */ + it('SUB_AA_ReisterErrorObserver_0200', 0, async function (done) { + errorManager.unregisterErrorObserver(-1, (err, data)=>{ + console.info("SUB_AA_ReisterErrorObserver_0200:" + JSON.stringify(err) + " " + JSON.stringify(data)); + console.info("SUB_AA_ReisterErrorObserver_0200:" + typeof(err.code)); + if(err.code != 0){ + expect(err.code).assertEqual(-2) + done() + }else{ + expect().assertFail() + done(); + } + }) + }); + + /* + * @tc.number SUB_AA_Test_AbilityConstant_0100 + * @tc.name Test abilityConstant. + * @tc.desc Function test + * @tc.level 3 + */ + it('SUB_AA_AbilityConstant_0200', 0, async function (done) { + expect(1).assertEqual(abilityConstant.LaunchReason.START_ABILITY) + expect(1).assertEqual(abilityConstant.LastExitReason.ABILITY_NOT_RESPONDING) + expect(2).assertEqual(abilityConstant.LastExitReason.NORMAL) + done() + }); + + /* + * @tc.number SUB_AA_Test_ProcessRunningInformation_0100 + * @tc.name Test getProcessRunningInformation in appManager. + * @tc.desc Function test + * @tc.level 3 + */ + it('SUB_AA_Test_ProcessRunningInformation_0100', 0, async function (done) { + let processRunningInformation:appManager.ProcessRunningInformation; + let process; + appManager.getProcessRunningInformation().then((processRunningInformations)=>{ + console.info("SUB_AA_Test_ProcessRunningInformation_0100:" + JSON.stringify(processRunningInformations)); + for(let i = 0; i < processRunningInformations.length; i++){ + console.info("SUB_AA_Test_ProcessRunningInformation_0100:" + JSON.stringify(processRunningInformations[i])); + expect(processRunningInformations[i].pid).assertLarger(0) + expect(processRunningInformations[i].uid).assertLarger(0) + if(processRunningInformations[i].processName == "com.example.apicoverhaptest"){ + process = processRunningInformations[i] + } + } + expect(process.bundleNames[0]).assertEqual("com.example.apicoverhaptest") + done() + }).catch((error)=>{ + console.info("SUB_AA_Test_ProcessRunningInformation_0100:" + JSON.stringify(error)); + expect().assertFail() + done() + }) + }); + + /* + * @tc.number SUB_AA_Test_ProcessRunningInformation_0200 + * @tc.name Test getProcessRunningInformation by callback in appManager. + * @tc.desc Function test + * @tc.level 3 + */ + it('SUB_AA_Test_ProcessRunningInformation_0200', 0, async function (done) { + let process; + appManager.getProcessRunningInformation((error, processRunningInformations)=>{ + if(error.code == 0){ + console.info("SUB_AA_Test_ProcessRunningInformation_0100:" + JSON.stringify(processRunningInformations)); + for(let i = 0; i < processRunningInformations.length; i++){ + console.info("SUB_AA_Test_ProcessRunningInformation_0100:" + JSON.stringify(processRunningInformations[i])); + expect(processRunningInformations[i].pid).assertLarger(0) + expect(processRunningInformations[i].uid).assertLarger(0) + if(processRunningInformations[i].processName == "com.example.apicoverhaptest"){ + process = processRunningInformations[i] + } + } + expect(process.bundleNames[0]).assertEqual("com.example.apicoverhaptest") + done() + }else{ + console.info("SUB_AA_Test_ProcessRunningInformation_0100:" + JSON.stringify(error)); + expect().assertFail() + done() + } + }) + }); + + /* + * @tc.number SUB_AA_FMS_AbilityStage_0100 + * @tc.name Start AbilityStage and get config. + * @tc.desc Function test + * @tc.level 3 + */ + it('SUB_AA_FMS_AbilityStage_0100', 0, async function (done) { + let subscriber = null + let subscribeInfo = { + events: ["AbilityStage_StartAbility"] + } + function UnSubscribeInfoCallback(err, data) { + console.info("SUB_AA_FMS_AbilityStage_0100===UnSubscribeInfoCallback===") + done() + } + function SubscribeInfoCallback(err, data) { + console.info("SUB_AA_FMS_AbilityStage_0100===SubscribeInfoCallback===" + JSON.stringify(data)) + expect(data.parameters["config"]).assertEqual(-1) + commonEvent.unsubscribe(subscriber, UnSubscribeInfoCallback) + done() + } + commonEvent.createSubscriber(subscribeInfo, (err, data) => { + console.info("SUB_AA_FMS_AbilityStage_0100===CreateSubscriberCallback===") + subscriber = data + commonEvent.subscribe(subscriber, SubscribeInfoCallback) + }) + let formWant ={ + deviceId:"", + bundleName:"ohos.acts.aafwk.test.stagesupplement", + abilityName:"MainAbility3", + } + globalThis.abilityContext.startAbility(formWant, (err, data)=>{ + if(err.code == 0){ + console.info("SUB_AA_FMS_AbilityStage_0100===CreateSubscriberCallback===") + }else{ + expect().assertFail() + done() + } + }) + }) + + /* + * @tc.number SUB_AA_FMS_AbilityStage_0200 + * @tc.name Start Service and get config. + * @tc.desc Function test + * @tc.level 3 + */ + it('SUB_AA_FMS_AbilityStage_0200', 0, async function (done) { + let subscriber = null + let subscribeInfo = { + events: ["ExtensionConext_StartAbility"] + } + function UnSubscribeInfoCallback(err, data) { + console.info("SUB_AA_FMS_AbilityStage_0200===UnSubscribeInfoCallback===") + } + function SubscribeInfoCallback(err, data) { + console.info("SUB_AA_FMS_AbilityStage_0200===SubscribeInfoCallback===" + JSON.stringify(data)) + expect(data.parameters["config"]).assertEqual(0) + expect(data.parameters["poniterDevices"]).assertFalse() + expect(data.parameters["AbilityInfo"]).assertEqual("com.example.apicoverhaptest") + commonEvent.unsubscribe(subscriber, UnSubscribeInfoCallback) + done() + } + commonEvent.createSubscriber(subscribeInfo, (err, data) => { + console.info("SUB_AA_FMS_AbilityStage_0200===CreateSubscriberCallback===") + subscriber = data + commonEvent.subscribe(subscriber, SubscribeInfoCallback) + }) + let formWant ={ + deviceId:"", + bundleName:"com.example.apicoverhaptest", + abilityName:"ServiceAbility", + } + globalThis.abilityContext.startAbility(formWant, (err, data)=>{ + if(err.code == 0){ + console.info("SUB_AA_FMS_AbilityStage_0200===abilityContext startAbility success===") + }else{ + expect().assertFail() + done() + } + }) + }) + + /* + * @tc.number SUB_AA_FMS_AcquireForm_0100 + * @tc.name Test startAbility in FormExtensionContext. + * @tc.desc Function test + * @tc.level 3 + */ + it('SUB_AA_FMS_AcquireForm_0100', 0, async function (done) { + let subscriber = null + let formExtensionContext:appContext.FormExtensionContext + let pacMap:ability.PacMap + let subscribeInfo = { + events: ["Form_StartAbility"] + } + function UnSubscribeInfoCallback(err, data) { + console.info("SUB_AA_FMS_AcquireFormState_0700 ===UnSubscribeInfoCallback===") + } + function SubscribeInfoCallback(err, data) { + console.info("SUB_AA_FMS_AcquireFormState_0700 ===SubscribeInfoCallback===" + JSON.stringify(data)) + expect(data.parameters["Life"]).assertEqual("onForeground") + commonEvent.unsubscribe(subscriber, UnSubscribeInfoCallback) + done() + } + commonEvent.createSubscriber(subscribeInfo, (err, data) => { + console.info("SUB_AA_FMS_AcquireFormState_0700 ===CreateSubscriberCallback===") + subscriber = data + commonEvent.subscribe(subscriber, SubscribeInfoCallback) + }) + let formWant ={ + deviceId:"", + bundleName:"com.example.apicoverhaptest", + abilityName:"CreateFormAbility", + parameters:{ + "createForm": true + } + } + globalThis.abilityContext.startAbility(formWant, (err, data)=>{ + if(err.code == 0){ + console.info("SUB_AA_FMS_AcquireFormState_0700 ===acquireFormState=== " + JSON.stringify(data)) + }else{ + expect().assertFail() + done() + } + }) + }) + }) } \ No newline at end of file diff --git a/ability/ability_runtime/apicover/apicoverhaptest/entry/src/main/ets/test/ContextEnvironmentTest.test.ets b/ability/ability_runtime/apicover/apicoverhaptest/entry/src/main/ets/test/ContextEnvironmentTest.test.ets index 66112e138880c05906d4733024887320ade74377..fb64c64e7e3b53e93cf76ee93c39e49563f8e85c 100644 --- a/ability/ability_runtime/apicover/apicoverhaptest/entry/src/main/ets/test/ContextEnvironmentTest.test.ets +++ b/ability/ability_runtime/apicover/apicoverhaptest/entry/src/main/ets/test/ContextEnvironmentTest.test.ets @@ -67,7 +67,7 @@ export default function ContextEnvironmentTest(applicationContext) { var code = undefined console.info(TAG + "callbackId = " + callbackId + " callNum = " + callNum) - await sleep(1000) + await sleep(700) // unregisterEnvironmentCallback applicationContext.unregisterEnvironmentCallback(callbackId, (error, data) => { console.info(TAG + "unregisterEnvironmentCallback first err is : " + JSON.stringify(error) + ", data is : " + JSON.stringify(data)) @@ -75,7 +75,7 @@ export default function ContextEnvironmentTest(applicationContext) { }) - await sleep(1000) + await sleep(700) expect(callbackId).assertEqual(callNum) expect(code).assertEqual(0) callNum++; diff --git a/ability/ability_runtime/apicover/apicoverhaptest/entry/src/main/ets/test/List.test.ets b/ability/ability_runtime/apicover/apicoverhaptest/entry/src/main/ets/test/List.test.ets index 23781d4adba7617a15f63682a4d9bfffab4ef4a7..38a460a83beb6ff912abe6f8f49b7477fdb1f3db 100644 --- a/ability/ability_runtime/apicover/apicoverhaptest/entry/src/main/ets/test/List.test.ets +++ b/ability/ability_runtime/apicover/apicoverhaptest/entry/src/main/ets/test/List.test.ets @@ -24,4 +24,4 @@ export default function List() { verificationTest() wantAgentCover() contextEnvironmentTest(globalThis.applicationContext) -} \ No newline at end of file +} diff --git a/ability/ability_runtime/apicover/apicoverhaptest/entry/src/main/module.json b/ability/ability_runtime/apicover/apicoverhaptest/entry/src/main/module.json index 0fa974e61afec84e6edbecafe79e606dcafff7dd..bbe5d394a7dc9d9f3292ad160f002c1c4ce5d748 100644 --- a/ability/ability_runtime/apicover/apicoverhaptest/entry/src/main/module.json +++ b/ability/ability_runtime/apicover/apicoverhaptest/entry/src/main/module.json @@ -33,6 +33,28 @@ ] } ] + }, + { + "name": "SecondAbility", + "srcEntrance": "./ets/SecondAbility/SecondAbility.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:white", + "visible": true, + "launchType": "singleton" + }, + { + "name": "CreateFormAbility", + "srcEntrance": "./ets/CreateFormAbility/CreateFormAbility.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:white", + "visible": true, + "launchType": "singleton" } ], "extensionAbilities": [ @@ -48,6 +70,24 @@ "resource": "$profile:form_config" } ] + }, + { + "name": "ServiceAbility", + "srcEntrance": "./ets/ServiceAbility/ServiceAbility.ts", + "label": "$string:MainAbility_label", + "description": "$string:MainAbility_desc", + "type": "service" + } + ], + "requestPermissions":[ + { + "name":"ohos.permission.GET_RUNNING_INFO" + }, + { + "name":"ohos.permission.REQUIRE_FORM" + }, + { + "name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" } ] } diff --git a/ability/ability_runtime/apicover/apicoverhaptest/entry/src/main/resources/base/profile/main_pages.json b/ability/ability_runtime/apicover/apicoverhaptest/entry/src/main/resources/base/profile/main_pages.json index 81691245bb98976d7d8966dd406a9abd5140ef39..0860163e778f59c82e03294795f974e91404456d 100644 --- a/ability/ability_runtime/apicover/apicoverhaptest/entry/src/main/resources/base/profile/main_pages.json +++ b/ability/ability_runtime/apicover/apicoverhaptest/entry/src/main/resources/base/profile/main_pages.json @@ -1,5 +1,7 @@ { "src": [ - "MainAbility/pages/MainAbility_pages" + "MainAbility/pages/MainAbility_pages", + "SecondAbility/pages/MainAbility_pages", + "CreateFormAbility/pages/MainAbility_pages" ] } \ No newline at end of file diff --git a/ability/ability_runtime/apicover/formmodule/entry/src/main/ets/FormAbility/FormAbility.ts b/ability/ability_runtime/apicover/formmodule/entry/src/main/ets/FormAbility/FormAbility.ts index d29f2942dbf56b979a920147b58852bb7a9e58fa..22f718baed7541652ed99894fbc0e018f152be53 100644 --- a/ability/ability_runtime/apicover/formmodule/entry/src/main/ets/FormAbility/FormAbility.ts +++ b/ability/ability_runtime/apicover/formmodule/entry/src/main/ets/FormAbility/FormAbility.ts @@ -5,7 +5,9 @@ import formInfo from '@ohos.application.formInfo'; export default class FormModuleAbility extends FormExtension { onCreate(want) { // Called to return a FormBindingData object. - let formData = {}; + console.info("FormAbility onCreate") + let formData = { + }; return formBindingData.createFormBindingData(formData); } diff --git a/ability/ability_runtime/apicover/formmodule/entry/src/main/module.json b/ability/ability_runtime/apicover/formmodule/entry/src/main/module.json index 0f4f9038601384276a81fcb000cf54c49d2b9394..1a4a94b8d19de666636223f89b20b5af4159641f 100644 --- a/ability/ability_runtime/apicover/formmodule/entry/src/main/module.json +++ b/ability/ability_runtime/apicover/formmodule/entry/src/main/module.json @@ -36,7 +36,7 @@ ], "extensionAbilities": [ { - "name": "FormAbility", + "name": "FormAbility2", "srcEntrance": "./ets/FormAbility/FormAbility.ts", "label": "$string:form_FormAbility_label", "description": "$string:form_FormAbility_desc", diff --git a/ability/ability_runtime/apicover/stagesupplement/entry/src/main/ets/Application/AbilityStage.ts b/ability/ability_runtime/apicover/stagesupplement/entry/src/main/ets/Application/AbilityStage.ts index 45aaf28a4ff72e191b47bf46a421ab11a1cc4d05..d8f2468920ab67540f4c3adad5b50bb982c39bb4 100644 --- a/ability/ability_runtime/apicover/stagesupplement/entry/src/main/ets/Application/AbilityStage.ts +++ b/ability/ability_runtime/apicover/stagesupplement/entry/src/main/ets/Application/AbilityStage.ts @@ -1,7 +1,16 @@ import AbilityStage from "@ohos.application.AbilityStage" - +import commonEvent from '@ohos.commonEvent'; export default class MyAbilityStage extends AbilityStage { onCreate() { console.info("[Demo] MyAbilityStage onCreate") + let directions = this.context.config.direction + var CommonEventPublishData = { + parameters: { + "config": directions + } + } + commonEvent.publish("AbilityStage_StartAbility", CommonEventPublishData, (err) => { + console.info("AbilityStage_StartAbility onCreate"); + }); } } \ No newline at end of file