diff --git a/aafwk/aafwk_standard/formmanager/BUILD.gn b/aafwk/aafwk_standard/formmanager/BUILD.gn index c5c9b4d14f03edab8422a15ca69af872132ae317..b1f83cc8f197dadd99917edac6ee40cbdee3bb26 100644 --- a/aafwk/aafwk_standard/formmanager/BUILD.gn +++ b/aafwk/aafwk_standard/formmanager/BUILD.gn @@ -17,10 +17,23 @@ group("formmanager") { testonly = true if (is_standard_system) { deps = [ + "formhostst_ets/formsystemhostc:FormSystemHostC", + "formhostst_ets/formsystemhostf:FormSystemHostF", + "formhostst_ets/formsystemhostg:FormSystemHostG", "formhostst_ets/formsystemhostk:FormSystemHostK", "formhostst_ets/formsystemhostl:FormSystemHostL", + "formhostst_ets/formsystemhostn:FormSystemHostN", + "formhostst_ets/formsystemhostnoperm:FormSystemHostNoPerm", + "formhostst_ets/formsystemhosto:FormSystemHostO", + "formhostst_ets/formsystemhostp:FormSystemHostP", + "formproviderst_ets/formsupplyapplicationA:FormSupplyAppA", + "formproviderst_ets/formsupplyapplicationB:FormSupplyAppB", + "formproviderst_ets/formsupplyapplicationD:FormSupplyAppD", + "formproviderst_ets/formsupplyapplicationE:FormSupplyAppE", "formproviderst_ets/formsupplyapplicationF:FormSupplyAppF", "formproviderst_ets/formsupplyapplicationG:FormSupplyAppG", + "formproviderst_ets/formsupplyapplicationH:FormSupplyAppH", + "formproviderst_ets/formsupplyapplicationNotSysApp:FormSupplyAppNS", "formproviderst_ets/formsystemprovidera:FormSystemProviderA", "formproviderst_ets/formsystemproviderb:FormSystemProviderB", "formproviderst_ets/formsystemproviderc:FormSystemProviderC", @@ -33,6 +46,11 @@ group("formmanager") { "formsystemtest_ets/formgetformsinfotest/formszerotest:FormsZeroTest", "formsystemtest_ets/formhostdeathrecipienttest:FormHostDeathRecipientTest", "formsystemtest_ets/formperformancetest:FormPerformanceTest", + "formsystemtest_ets/formstatetest_disable:FormStateDisableTest", + "formsystemtest_ets/formstatetest_enable:FormStateEnableTest", + "formsystemtest_ets/formstatetest_notifyinvisible:FormStateNotifyInvisibleTest", + "formsystemtest_ets/formstatetest_notifyinvisible2:FormStateNotifyInvisibleTest2", + "formsystemtest_ets/formstatetest_notifyvisible:FormStateNotifyVisibleTest", "formsystemtest_ets/formstresstest:FormStressTest", ] } diff --git a/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostc/BUILD.gn b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostc/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..d9128314a02104ff6a2018c1d60ab69d38384cf4 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostc/BUILD.gn @@ -0,0 +1,32 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("FormSystemHostC") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":hjs_demo_js_assets", + ":hjs_demo_resources", + ] + ets2abc = true + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "FormSystemHostC" +} +ohos_js_assets("hjs_demo_js_assets") { + source_dir = "./entry/src/main/ets/MainAbility" +} +ohos_resources("hjs_demo_resources") { + sources = [ "./entry/src/main/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostc/Test.json b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostc/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..3ec911dfc7b3a17504cd4577be5bbabaf7f97e63 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostc/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} diff --git a/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostc/entry/src/main/config.json b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostc/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..ce18d9ac81a49cb0bce009638cd024f35ca4edcd --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostc/entry/src/main/config.json @@ -0,0 +1,140 @@ +{ + "app": { + "bundleName": "com.ohos.st.formsystemhostc", + "vendor": "ohos", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 7, + "releaseType": "Release", + "target": 7 + } + }, + "deviceConfig": {}, + "module": { + "package": "com.ohos.st.formsystemhostc", + "name": ".FormStHostAppC", + "mainAbility": ".MainAbility", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": false + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "visible": true, + "name": ".MainAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:description_mainability", + "label": "$string:entry_MainAbility", + "type": "page", + "launchType": "standard" + } + ], + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ], + "defPermissions": [ + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormDelete_commonEvent" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormOnAcquired_commonEvent" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormOnError_commonEvent" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormCast_commonEvent" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormOnDeleted_commonEvent" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormOnReleased_commonEvent" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_TimeChange_commonEvent" + } + ], + "reqPermissions": [ + { + "name": "FMS_FormOnAcquired_commonEvent" + }, + { + "name": "FMS_FormDelete_commonEvent" + }, + { + "name": "FMS_FormOnError_commonEvent" + }, + { + "name": "FMS_FormCast_commonEvent" + }, + { + "name": "FMS_FormOnDeleted_commonEvent" + }, + { + "name": "FMS_FormOnReleased_commonEvent" + }, + { + "name": "FMS_TimeChange_commonEvent" + }, + { + "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + }, + { + "name": "ohos.permission.INSTALL_BUNDLE" + }, + { + "name": "ohos.permission.LISTEN_BUNDLE_CHANGE" + }, + { + "name": "ohos.permission.REQUIRE_FORM" + } + ] + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostc/entry/src/main/ets/MainAbility/app.ets b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostc/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..f49f9bd10ebd29ce7eb0445bee5a5928d9212a8a --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostc/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,23 @@ +/* + * 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. + */ + +export default { + onCreate() { + console.info('[FormComponent.host] Application onCreate') + }, + onDestroy() { + console.info('[FormComponent.host] Application onDestroy') + }, +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostc/entry/src/main/ets/MainAbility/pages/FormViewModel.ets b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostc/entry/src/main/ets/MainAbility/pages/FormViewModel.ets new file mode 100644 index 0000000000000000000000000000000000000000..9b09225070d8baf4062cf466a595a441993ae53b --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostc/entry/src/main/ets/MainAbility/pages/FormViewModel.ets @@ -0,0 +1,127 @@ +/* + * 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 formManager from '@ohos.ability.formmanager'; +import bundleManager from '@ohos.bundle'; +import abilityManager from '@ohos.app.abilityManager'; + +export default class FormViewModel { + private static sFormViewModel: FormViewModel = null; + + public static getInstance(): FormViewModel { + if (FormViewModel.sFormViewModel == null) { + FormViewModel.sFormViewModel = new FormViewModel(); + } + return FormViewModel.sFormViewModel; + } + + public async castTempFormToNormal(formId: string) { + formManager.castTempForm(formId) + .then((data) => { + console.info('[FormComponent] castTempForm result:' + data); + }); + } + + public async requestForm(formId: string) { + formManager.requestForm(formId) + .then((data) => { + console.info('[FormComponent] requestForm result:' + data); + }); + } + + public async deleteCard(formId: string) { + formManager.deleteForm(formId) + .then((data) => { + console.info('[FormComponent] deleteForm result:' + data); + }); + } + + public async releaseCard(formId: string) { + formManager.releaseForm(formId) + .then((data) => { + console.info('[FormComponent] releaseForm result:' + data); + }); + } + + public async enableCard(formId: string) { + formManager.enableFormsUpdate([formId]) + .then((data) => { + console.info('[FormComponent] enableFormsUpdate result:' + data); + }); + } + + public async disableCard(formId: string) { + formManager.disableFormsUpdate([formId]) + .then((data) => { + console.info('[FormComponent] disableCard result:' + data); + }); + } + + public async changeCardVisible(formId: string, isVisible: boolean) { + if (isVisible) { + formManager.notifyVisibleForms([formId]) + .then((data) => { + console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible); + }); + } else { + formManager.notifyInvisibleForms([formId]) + .then((data) => { + console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible); + }); + } + } + + public async isFmsReady() { + formManager.isSystemReady() + .then((data) => { + console.info('[FormComponent] isFmsReady result:' + data); + }); + } + + public async getAllFormsInfo() { + formManager.getAllFormsInfo() + .then((data) => { + console.info('[FormComponent] getAllFormsInfo result:' + JSON.stringify(data)); + }); + } + + public async getFormsInfoByApp(bundle: string) { + formManager.getFormsInfo(bundle) + .then((data) => { + console.info('[FormComponent] getFormsInfoByApp result:' + JSON.stringify(data)); + }); + } + + public async getFormsInfoByModule(bundle: string, moduleName: string) { + formManager.getFormsInfo(bundle, moduleName) + .then((data) => { + console.info('[FormComponent] getFormsInfoByModule result:' + JSON.stringify(data)); + }); + } + + public async clearFormUserCache() { + abilityManager.clearUpApplicationData('com.ohos.myapplicationform') + .then((data) => { + console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data)); + }); + } + + public async clearFormProviderCache(bundle: string) { + abilityManager.clearUpApplicationData(bundle) + .then((data) => { + console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data)); + }); + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostc/entry/src/main/ets/MainAbility/pages/index.ets b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostc/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..f0b0084f43a0ef2589b40af108025321b6de8cf8 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostc/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,429 @@ +/* + * 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 FormViewModel from './FormViewModel.ets'; +import router from '@system.router'; +import featureAbility from "@ohos.ability.featureAbility"; +import formManager from '@ohos.application.formHost' +import commonEvent from '@ohos.commonEvent'; +import systemTime from '@ohos.systemTime'; + +@Entry +@Component +struct Index { + @State formId: number = 0; + @State bundle: string = "com.form.formsystemtestservicea.hmservice"; + @State ability: string = "com.form.formsystemtestservicea.hmservice.MainAbility"; + @State moduleName: string = "entry"; + @State name: string = "Form_Js001"; + @State width: number = 300; + @State height: number = 200; + @State allowUpate: boolean = true; + @State onAcquireResult: string = ""; + @State isShowing: boolean = true; + @State canCreateForm: boolean = false; + + private dimension: FormDimension = FormDimension.Dimension_1_2; + + private releaseForm = false; + private releaseId = "-1"; + private deleteForm = false; + private deleteId = "-1"; + private temporaryId="-1"; + private temporary = false; + private mFormViewModel: FormViewModel; + private isVisible = false; + private mMargin = 15; + private BTN_BG_COLOR: string = '#0D9FFB'; + private castForm = false; + private tempFormId: number = 0; + private sendCastForm = false; + private sendCastFormMsg; + + private formOnAcquiredEvent = "FMS_FormOnAcquired_commonEvent"; + private formCastEvent = "FMS_FormCast_commonEvent"; + private formOnErrorEvent = "FMS_FormOnError_commonEvent"; + private formOnDeletedEvent = "FMS_FormOnDeleted_commonEvent"; + private formOnReleasedEvent = "FMS_FormOnReleased_commonEvent"; + + private subscriberDel; + private subscriberFormDeleteEvent = { + events: ["FMS_FormDelete_commonEvent"], + }; + private subscriberTimeChange; + private subscriberTimeChangeEvent = { + events: ["FMS_TimeChange_commonEvent"], + }; + + private publishOnErrorCallBack() { + this.canCreateForm = false; + console.debug("====>formsystemhostc formOnErrorEventCallBack ====>"); + } + private publishOnDeletedCallBack() { + this.canCreateForm = false; + console.debug("====>formsystemhostc publishOnDeletedCallBack ====>"); + } + private publishOnReleasedCallBack() { + this.canCreateForm = false; + console.debug("====>formsystemhostc publishOnReleasedCallBackk ====>"); + } + private publishOnAcquiredCallBack() { + console.debug("====>formsystemhostc formOnAcquiredEventCallBack ====>"); + } + private publishCastCallBack() { + console.debug("====>formsystemhostc formCastEventCallBack ====>"); + } + + private deleteCallBack(err, data) { + console.info("!!!====>[FormComponent] deleteCallBack start:====>" + JSON.stringify(data)); + if(data.bundleName && data.bundleName != "com.ohos.st.formsystemhostc") { + return; + } + formManager.deleteForm(data.data) + .then((data2) => { + console.info('[FormComponent] deleteForm result:' + data2); + }); + + this.canCreateForm = false; + console.info("!!!====>[FormComponent] deleteCallBack end ====>"); + } + + private unSubscribeDeleteCallback() { + console.debug("====>[FormComponent] unSubscribeDeleteCallback_1100 CallBack====>"); + } + + private timeChangeCallBack(err, data) { + console.info("!!!====>[FormComponent] timeChangeCallBack start:====>" + JSON.stringify(data)); + if(data.bundleName && data.bundleName != "com.ohos.st.formsystemhostc") { + return; + } + this.changeTime(data.parameters.hour, data.parameters.min, data.parameters.second); + console.info("!!!====>[FormComponent] timeChangeCallBack end ====>"); + } + + private unSubscribeTimeChangeCallback() { + console.debug("====>[FormComponent] unSubscribeTimeChangeCallback CallBack====>"); + } + /** + * + * @param hour hour of 24H clock + * @param min minute + * @param second second + */ + private changeTime(hour: number, min: number, second: number): void { + let datetime = new Date(); + let year = datetime.getFullYear(); + let month = datetime.getMonth() + 1; + let day = datetime.getDate(); + let formatTime = year + '-' + this.fill(month) + '-' + this.fill(day) + + 'T' + this.fill(hour) + ':' + this.fill(min) + ':' + this.fill(second); + let s = (new Date(formatTime)).getTime(); + + systemTime.setTime(s).then(data => { + console.log(`set time success: ${formatTime}, result:${data}`); + }).catch(error => { + console.log(`set time failure: ${error}`); + }) + } + + private fill(value: number): string { + return (value > 9 ? "" : "0") + value; + } + private aboutToAppear() { + + const TAG = "[FormComponent.host]" + + this.mFormViewModel = FormViewModel.getInstance(); + + commonEvent.createSubscriber(this.subscriberFormDeleteEvent).then(async (data) => { + console.info("====>[FormComponent] Subscriber FormDelete data:====>", JSON.stringify(data)); + this.subscriberDel = data; + await commonEvent.subscribe(this.subscriberDel, this.deleteCallBack); + }) + + commonEvent.createSubscriber(this.subscriberTimeChangeEvent).then(async (data) => { + console.info("====>[FormComponent] Subscriber TimeChange data:====>", JSON.stringify(data)); + this.subscriberTimeChange = data; + await commonEvent.subscribe(this.subscriberTimeChange, this.timeChangeCallBack); + }) + + console.error('[FormComponent] getWant'); + featureAbility.getWant() + .then((want: any) => { + this.formId = parseInt(want.parameters.formId); + this.name = want.parameters.name; + this.bundle = want.parameters.bundle; + this.ability = want.parameters.ability; + if(want.parameters.moduleName) { + this.moduleName = want.parameters.moduleName; + } + if(want.parameters.temporary) { + this.temporary = want.parameters.temporary; + } + if(want.parameters.dimension) { + this.dimension = want.parameters.dimension; + } + if(!this.dimension) { + this.dimension = FormDimension.Dimension_1_2; + } + if(want.parameters.castForm) { + this.castForm = want.parameters.castForm; + } + if(want.parameters.temporaryId) { + this.temporaryId = want.parameters.temporaryId; + } + if(want.parameters.deleteForm) { + this.deleteForm = want.parameters.deleteForm; + } + if(want.parameters.deleteId) { + this.deleteId = want.parameters.deleteId; + } + if(want.parameters.releaseForm) { + this.releaseForm = want.parameters.releaseForm; + } + if(want.parameters.releaseId) { + this.releaseId = want.parameters.releaseId; + } + + if(want.parameters.sendCastForm) { + this.sendCastForm = want.parameters.sendCastForm; + } + if(want.parameters.sendCastFormMsg) { + this.sendCastFormMsg = want.parameters.sendCastFormMsg; + } + + setTimeout(() => { + this.canCreateForm = want.parameters.isCreate ? true : false; + console.error('[FormComponent] getWant canCreateForm:'+ this.canCreateForm); + }, 10); + console.error('[FormComponent] getWant end'+ JSON.stringify(want)); + if(!want.parameters.isCreate && this.sendCastForm) { + console.log("[FormComponent.host] sendCastForm start"); + setTimeout(() => { + let commonEventPublishData = { + data: sendCastFormMsg, + parameters: { + "formId" : "" + } + }; + commonEvent.publish(this.formCastEvent, commonEventPublishData, this.publishCastCallBack); + }, 5); + console.log("[FormComponent.host] sendCastForm end"); + } + if(!want.parameters.isCreate && this.deleteForm) { + console.log("[FormComponent] deleteForm start"); + formManager.deleteForm(this.deleteId) + .then((data) => { + console.info('[FormComponent] deleteForm result:' + data); + let commonEventPublishData = { + data: data.toString(), + parameters: { + "formId" : this.deleteId + } + }; + commonEvent.publish(this.formOnDeletedEvent, commonEventPublishData, this.publishOnDeletedCallBack); + }) + .catch((error) => { + console.info('[FormComponent] deleteForm error:' + error); + let commonEventPublishData = { + data: error.code.toString(), + parameters: { + "formId" : this.deleteId.toString() + } + }; + commonEvent.publish(this.formOnDeletedEvent, commonEventPublishData, this.publishOnDeletedCallBack); + }); + + console.log("[FormComponent] deleteForm end"); + } + if(!want.parameters.isCreate && this.releaseForm) { + console.log("[FormComponent] releaseForm start"); + formManager.releaseForm(this.releaseId, true) + .then((data) => { + console.info('[FormComponent] releaseForm result:' + data); + let commonEventPublishData = { + data: data.toString(), + parameters: { + "formId" : this.releaseId + } + }; + commonEvent.publish(this.formOnReleasedEvent, commonEventPublishData, this.publishOnReleasedCallBack); + }) + .catch((error) => { + console.info('[FormComponent] releaseForm error:' + error); + let commonEventPublishData = { + data: error.code.toString(), + parameters: { + "formId" : this.releaseId + } + }; + commonEvent.publish(this.formOnReleasedEvent, commonEventPublishData, this.publishOnReleasedCallBack); + }); + + console.log("[FormComponent] releaseForm end"); + } + }) + .catch((error: any) => { + console.error('[FormComponent] Operation failed. Cause: ' + JSON.stringify(error)); + }) + console.log(`[FormComponent.host] aboutToAppear end`); + } + + build() { + Column() { + Text('form component test begin') + Column() { + if (this.canCreateForm) { + 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); + this.formId = form.id; + if(this.castForm) { + console.log("[FormComponent.host] castTempForm start"); + formManager.castTempForm(this.temporaryId) + .then((data) => { + console.info('[FormComponent] castTempForm result:' + data); + setTimeout(() => { + let commonEventPublishData = { + data: data.toString(), + parameters: { + "formId" : this.formId.toString() + } + }; + commonEvent.publish(this.formCastEvent, commonEventPublishData, this.publishCastCallBack); + }, 5); + }) + .catch((error) => { + console.info('[FormComponent] castTempForm error:' + error); + setTimeout(() => { + let commonEventPublishData = { + data: error.code.toString(), + parameters: { + "formId" : this.formId.toString() + } + }; + commonEvent.publish(this.formCastEvent, commonEventPublishData, this.publishCastCallBack); + }, 5); + }); + console.log("[FormComponent.host] castTempForm end"); + } else if(this.deleteForm) { + console.log("[FormComponent.host] deleteForm start"); + if(this.deleteId == "self") { + this.deleteId = this.formId.toString(); + } + setTimeout(() => { + formManager.deleteForm(this.deleteId) + .then((data) => { + console.info('[FormComponent] deleteForm result:' + data); + var commonEventPublishData = { + data: data.toString(), + parameters: { + "formId" : this.deleteId + } + }; + commonEvent.publish(this.formOnDeletedEvent, commonEventPublishData, this.publishOnDeletedCallBack); + }) + .catch((error) => { + console.info('[FormComponent] deleteForm error:' + error); + var commonEventPublishData = { + data: error.code.toString(), + parameters: { + "formId" : this.deleteId + } + }; + commonEvent.publish(this.formOnDeletedEvent, commonEventPublishData, this.publishOnDeletedCallBack); + }); + + console.log("[FormComponent.host] deleteForm end"); + }, 1000); + } else if(this.releaseForm) { + console.log("[FormComponent.host] releaseForm start"); + if(this.releaseId == "self") { + this.releaseId = this.formId.toString(); + } + setTimeout(() => { + formManager.releaseForm(this.releaseId, true) + .then((data) => { + console.info('[FormComponent] releaseForm result:' + data); + var commonEventPublishData = { + data: data.toString(), + parameters: { + "formId" : this.releaseId + } + }; + commonEvent.publish(this.formOnReleasedEvent, commonEventPublishData, this.publishOnReleasedCallBack); + }) + .catch((error) => { + console.info('[FormComponent] releaseForm error:' + error); + let commonEventPublishData = { + data: error.code.toString(), + parameters: { + "formId" : this.releaseId + } + }; + commonEvent.publish(this.formOnReleasedEvent, commonEventPublishData, this.publishOnReleasedCallBack); + }); + + console.log("[FormComponent.host] releaseForm end"); + }, 1000); + } else { + var commonEventPublishData = { + data: this.formId.toString() + }; + commonEvent.publish(this.formOnAcquiredEvent, commonEventPublishData, this.publishOnAcquiredCallBack); + } + }) + // .onUninstall((info) => { + // console.log("[FormComponent] onUninstall:" + JSON.stringify(info)); + // }) + .onError((error) => { + console.log("[FormComponent.host] error code:" + error.errcode); + console.log("[FormComponent.host] error msg:" + error.msg); + this.onAcquireResult += error.errcode; + this.onAcquireResult += " "; + this.onAcquireResult += error.msg; + if(this.deleteForm && this.deleteId) { + let commonEventPublishData = { + data: error.msg, + parameters: { + "formId" : this.formId.toString() + } + }; + commonEvent.publish(this.formOnDeletedEvent, commonEventPublishData, this.publishOnDeletedCallBack); + } else { + let commonEventPublishData = { + data: error.msg + }; + commonEvent.publish(this.formOnErrorEvent, commonEventPublishData, this.publishOnErrorCallBack); + } + }) + } + } + .backgroundColor(Color.White) + Text('form component test end') + } + .backgroundColor(Color.White) + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostc/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostc/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..c09b6a139bf6b26a7d5447935d0727c7bebcd524 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostc/entry/src/main/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "formhostC" + }, + { + "name": "description_mainability", + "value": "ETS_Empty Ability" + } + ] +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostc/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostc/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostc/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostc/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostc/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..6084de2e92d6f254a93a654b02701870bef66d31 Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostc/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostf/BUILD.gn b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostf/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..e8de20fcdc7fc8bd480b936628eaeb50d2c8649c --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostf/BUILD.gn @@ -0,0 +1,32 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("FormSystemHostF") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":hjs_demo_js_assets", + ":hjs_demo_resources", + ] + ets2abc = true + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "FormSystemHostF" +} +ohos_js_assets("hjs_demo_js_assets") { + source_dir = "./entry/src/main/ets/MainAbility" +} +ohos_resources("hjs_demo_resources") { + sources = [ "./entry/src/main/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostf/Test.json b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostf/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..3ec911dfc7b3a17504cd4577be5bbabaf7f97e63 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostf/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} diff --git a/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostf/entry/src/main/config.json b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostf/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..c732ef25756ee0f6c5b6fd0ec2d28e2e2d9bf454 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostf/entry/src/main/config.json @@ -0,0 +1,132 @@ +{ + "app": { + "bundleName": "com.ohos.st.formsystemhostf", + "vendor": "ohos", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 7, + "releaseType": "Release", + "target": 7 + } + }, + "deviceConfig": {}, + "module": { + "package": "com.ohos.st.formsystemhostf", + "name": ".FormStHostAppF", + "mainAbility": ".MainAbility", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": false + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "visible": true, + "name": ".MainAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:description_mainability", + "label": "$string:entry_MainAbility", + "type": "page", + "launchType": "standard" + } + ], + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ], + "defPermissions": [ + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormDelete_commonEvent" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormOnAcquired_commonEvent" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormOnError_commonEvent" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormOnDeleted_commonEvent" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormOnReleased_commonEvent" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormUpdateRefresh_commonEvent" + } + ], + "reqPermissions": [ + { + "name": "FMS_FormOnAcquired_commonEvent" + }, + { + "name": "FMS_FormDelete_commonEvent" + }, + { + "name": "FMS_FormOnError_commonEvent" + }, + { + "name": "FMS_FormOnDeleted_commonEvent" + }, + { + "name": "FMS_FormOnReleased_commonEvent" + }, + { + "name": "FMS_FormUpdateRefresh_commonEvent" + }, + { + "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + }, + { + "name": "ohos.permission.INSTALL_BUNDLE" + }, + { + "name": "ohos.permission.LISTEN_BUNDLE_CHANGE" + }, + { + "name": "ohos.permission.REQUIRE_FORM" + } + ] + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostf/entry/src/main/ets/MainAbility/app.ets b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostf/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..f49f9bd10ebd29ce7eb0445bee5a5928d9212a8a --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostf/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,23 @@ +/* + * 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. + */ + +export default { + onCreate() { + console.info('[FormComponent.host] Application onCreate') + }, + onDestroy() { + console.info('[FormComponent.host] Application onDestroy') + }, +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostf/entry/src/main/ets/MainAbility/pages/FormViewModel.ets b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostf/entry/src/main/ets/MainAbility/pages/FormViewModel.ets new file mode 100644 index 0000000000000000000000000000000000000000..9b09225070d8baf4062cf466a595a441993ae53b --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostf/entry/src/main/ets/MainAbility/pages/FormViewModel.ets @@ -0,0 +1,127 @@ +/* + * 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 formManager from '@ohos.ability.formmanager'; +import bundleManager from '@ohos.bundle'; +import abilityManager from '@ohos.app.abilityManager'; + +export default class FormViewModel { + private static sFormViewModel: FormViewModel = null; + + public static getInstance(): FormViewModel { + if (FormViewModel.sFormViewModel == null) { + FormViewModel.sFormViewModel = new FormViewModel(); + } + return FormViewModel.sFormViewModel; + } + + public async castTempFormToNormal(formId: string) { + formManager.castTempForm(formId) + .then((data) => { + console.info('[FormComponent] castTempForm result:' + data); + }); + } + + public async requestForm(formId: string) { + formManager.requestForm(formId) + .then((data) => { + console.info('[FormComponent] requestForm result:' + data); + }); + } + + public async deleteCard(formId: string) { + formManager.deleteForm(formId) + .then((data) => { + console.info('[FormComponent] deleteForm result:' + data); + }); + } + + public async releaseCard(formId: string) { + formManager.releaseForm(formId) + .then((data) => { + console.info('[FormComponent] releaseForm result:' + data); + }); + } + + public async enableCard(formId: string) { + formManager.enableFormsUpdate([formId]) + .then((data) => { + console.info('[FormComponent] enableFormsUpdate result:' + data); + }); + } + + public async disableCard(formId: string) { + formManager.disableFormsUpdate([formId]) + .then((data) => { + console.info('[FormComponent] disableCard result:' + data); + }); + } + + public async changeCardVisible(formId: string, isVisible: boolean) { + if (isVisible) { + formManager.notifyVisibleForms([formId]) + .then((data) => { + console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible); + }); + } else { + formManager.notifyInvisibleForms([formId]) + .then((data) => { + console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible); + }); + } + } + + public async isFmsReady() { + formManager.isSystemReady() + .then((data) => { + console.info('[FormComponent] isFmsReady result:' + data); + }); + } + + public async getAllFormsInfo() { + formManager.getAllFormsInfo() + .then((data) => { + console.info('[FormComponent] getAllFormsInfo result:' + JSON.stringify(data)); + }); + } + + public async getFormsInfoByApp(bundle: string) { + formManager.getFormsInfo(bundle) + .then((data) => { + console.info('[FormComponent] getFormsInfoByApp result:' + JSON.stringify(data)); + }); + } + + public async getFormsInfoByModule(bundle: string, moduleName: string) { + formManager.getFormsInfo(bundle, moduleName) + .then((data) => { + console.info('[FormComponent] getFormsInfoByModule result:' + JSON.stringify(data)); + }); + } + + public async clearFormUserCache() { + abilityManager.clearUpApplicationData('com.ohos.myapplicationform') + .then((data) => { + console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data)); + }); + } + + public async clearFormProviderCache(bundle: string) { + abilityManager.clearUpApplicationData(bundle) + .then((data) => { + console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data)); + }); + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostf/entry/src/main/ets/MainAbility/pages/index.ets b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostf/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..d9b8ad574b6be5bde708fb539e2f39876ad92358 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostf/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,449 @@ +/* + * 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 FormViewModel from './FormViewModel.ets'; +import router from '@system.router'; +import featureAbility from '@ohos.ability.featureAbility'; +import formManager from '@ohos.application.formHost'; +import formProvider from '@ohos.application.formProvider'; +import commonEvent from '@ohos.commonEvent'; +import formBindingData from '@ohos.application.formBindingData'; + +@Entry +@Component +struct Index { + @State formId: number = 0; + @State bundle: string = "com.form.formsystemtestservicea.hmservice"; + @State ability: string = "com.form.formsystemtestservicea.hmservice.MainAbility"; + @State moduleName: string = "entry"; + @State name: string = "Form_Js001"; + @State width: number = 300; + @State height: number = 200; + @State allowUpate: boolean = true; + @State onAcquireResult: string = ""; + @State isShowing: boolean = true; + @State canCreateForm: boolean = false; + + private dimension: FormDimension = FormDimension.Dimension_1_2; + + private updateForm = false; + private updateId = "-1"; + private jsonEmpty = false; + private releaseForm = false; + private releaseId = "-1"; + private deleteForm = false; + private deleteId = "-1"; + private temporaryId="-1"; + private temporary = false; + private mFormViewModel: FormViewModel; + private isVisible = false; + private mMargin = 15; + private BTN_BG_COLOR: string = '#0D9FFB'; + private tempFormId: number = 0; + + private isStartOtherApp = false; + private otherAppState = "visible"; + + private formOnAcquiredEvent = "FMS_FormOnAcquired_commonEvent"; + private formOnErrorEvent = "FMS_FormOnError_commonEvent"; + private formOnDeletedEvent = "FMS_FormOnDeleted_commonEvent"; + private formOnReleasedEvent = "FMS_FormOnReleased_commonEvent"; + private formOnUpdatedEvent = "FMS_FormUpdateRefresh_commonEvent"; + + private subscriberDel; + private subscriberFormDeleteEvent = { + events: ["FMS_FormDelete_commonEvent"], + }; + + private publishOnErrorCallBack() { + this.canCreateForm = false; + console.debug("====>formsystemhostc formOnErrorEventCallBack ====>"); + } + private publishOnDeletedCallBack() { + this.canCreateForm = false; + console.debug("====>formsystemhostc publishOnDeletedCallBack ====>"); + } + private publishOnReleasedCallBack() { + this.canCreateForm = false; + console.debug("====>formsystemhostc publishOnReleasedCallBackk ====>"); + } + private publishOnAcquiredCallBack() { + console.debug("====>formsystemhostc formOnAcquiredEventCallBack ====>"); + } + private publishOnUpdatedCallBack() { + this.canCreateForm = false; + console.debug("====>formsystemhostc publishOnUpdatedCallBack ====>"); + } + private deleteCallBack(err, data) { + console.info("!!!====>formsystemhost deleteCallBack start:====>" + JSON.stringify(data)); + if(data.bundleName && data.bundleName != "com.ohos.st.formsystemhostf") { + return; + } + formManager.deleteForm(data.data) + .then((data2) => { + console.info('[FormComponent] deleteForm result:' + data2); + }); + + this.canCreateForm = false; + console.info("!!!====>formsystemhost deleteCallBack end ====>"); + } + + private unSubscribeDeleteCallback() { + console.debug("====>formsystemhost unSubscribeDeleteCallback_1100 CallBack====>"); + } + + private aboutToAppear() { + + const TAG = "[FormComponent.host]" + + this.mFormViewModel = FormViewModel.getInstance(); + + commonEvent.createSubscriber(this.subscriberFormDeleteEvent).then(async (data) => { + console.info("====>formsystemhost Subscriber FormDelete data:====>", JSON.stringify(data)); + this.subscriberDel = data; + await commonEvent.subscribe(this.subscriberDel, this.deleteCallBack); + }) + + console.error('[FormComponent] getWant'); + featureAbility.getWant() + .then((want: any) => { + this.formId = parseInt(want.parameters.formId); + this.name = want.parameters.name; + this.bundle = want.parameters.bundle; + this.ability = want.parameters.ability; + if(want.parameters.moduleName) { + this.moduleName = want.parameters.moduleName; + } + if(want.parameters.temporary) { + this.temporary = want.parameters.temporary; + } + if(want.parameters.dimension) { + this.dimension = want.parameters.dimension; + } + if(!this.dimension) { + this.dimension = FormDimension.Dimension_1_2; + } + if(want.parameters.temporaryId) { + this.temporaryId = want.parameters.temporaryId; + } + if(want.parameters.deleteForm) { + this.deleteForm = want.parameters.deleteForm; + } + if(want.parameters.deleteId) { + this.deleteId = want.parameters.deleteId; + } + if(want.parameters.releaseForm) { + this.releaseForm = want.parameters.releaseForm; + } + if(want.parameters.releaseId) { + this.releaseId = want.parameters.releaseId; + } + if(want.parameters.updateForm) { + this.updateForm = want.parameters.updateForm; + } + if(want.parameters.updateId) { + this.updateId = want.parameters.updateId; + } + if(want.parameters.jsonEmpty) { + this.jsonEmpty = want.parameters.jsonEmpty; + } + if(want.parameters.isStartOtherApp) { + this.isStartOtherApp = true; + if(want.parameters.otherAppState) { + this.otherAppState = want.parameters.otherAppState; + } + } + + setTimeout(() => { + this.canCreateForm = want.parameters.isCreate ? true : false; + console.error('[FormComponent] getWant canCreateForm:'+ this.canCreateForm); + }, 10); + console.error('[FormComponent] getWant end'+ JSON.stringify(want)); + + if(!want.parameters.isCreate && this.deleteForm) { + console.log("formsystemhost deleteForm start"); + formManager.deleteForm(this.deleteId) + .then((data) => { + console.info('formsystemhost deleteForm result:' + data); + let commonEventPublishData = { + data: "0", + parameters: { + "formId" : this.deleteId.toString() + } + }; + commonEvent.publish(this.formOnDeletedEvent, commonEventPublishData, this.publishOnDeletedCallBack); + }) + .catch((error) => { + console.info('formsystemhost deleteForm error:' + error); + let commonEventPublishData = { + data: error.code.toString(), + parameters: { + "formId" : this.deleteId.toString() + } + }; + commonEvent.publish(this.formOnDeletedEvent, commonEventPublishData, this.publishOnDeletedCallBack); + }); + + console.log("formsystemhost deleteForm end"); + } + + if(!want.parameters.isCreate && this.releaseForm) { + console.log("formsystemhost releaseForm start"); + formManager.releaseForm(this.releaseId) + .then((data) => { + console.info('formsystemhost releaseForm result:' + data); + let commonEventPublishData = { + data: "0", + parameters: { + "formId" : this.releaseId.toString() + } + }; + commonEvent.publish(this.formOnReleasedEvent, commonEventPublishData, this.publishOnReleasedCallBack); + }) + .catch((error) => { + console.info('formsystemhost releaseForm error:' + error); + let commonEventPublishData = { + data: error.code.toString(), + parameters: { + "formId" : this.releaseId.toString() + } + }; + commonEvent.publish(this.formOnReleasedEvent, commonEventPublishData, this.publishOnReleasedCallBack); + }); + + console.log("formsystemhost releaseForm end"); + } + + if(!want.parameters.isCreate && this.updateForm) { + console.log("formsystemhost updateForm start"); + let formData = { + temperature: "11°", + time: "11:00", + area: "Shenyang", + epidemic: true, + count: 10 + }; + if(this.jsonEmpty) { + formData = {}; + } + let bindingData = formBindingData.createFormBindingData(formData); + formProvider.updateForm(this.updateId, bindingData) + .then((data) => { + console.info('formsystemhost updateForm result:' + data); + let commonEventPublishData = { + data: "0", + parameters: { + "formId" : this.updateId + } + }; + commonEvent.publish(this.formOnUpdatedEvent, commonEventPublishData, this.publishOnUpdatedCallBack); + }) + .catch((error) => { + console.info('formsystemhost updateForm error:' + error); + let commonEventPublishData = { + data: error.code.toString(), + parameters: { + "formId" : this.updateId + } + }; + commonEvent.publish(this.formOnUpdatedEvent, commonEventPublishData, this.publishOnUpdatedCallBack); + }); + + console.log("formsystemhost releaseForm end"); + } + + }) + .catch((error: any) => { + console.error('[FormComponent] Operation failed. Cause: ' + JSON.stringify(error)); + }) + console.log(`[FormComponent.host] aboutToAppear end`); + } + + build() { + Column() { + Text('form component test begin') + Column() { + if (this.canCreateForm) { + 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); + this.formId = form.id; + if(this.deleteForm) { + console.log("[FormComponent.host] deleteForm start"); + if(this.deleteId == "self") { + this.deleteId = this.formId.toString(); + } + setTimeout(() => { + formManager.deleteForm(this.deleteId) + .then((data) => { + console.info('[FormComponent] deleteForm result:' + data); + var commonEventPublishData = { + data: "0", + parameters: { + "formId" : this.deleteId.toString() + } + }; + commonEvent.publish(this.formOnDeletedEvent, commonEventPublishData, this.publishOnDeletedCallBack); + }) + .catch((error) => { + console.info('formsystemhost deleteForm error:' + error); + let commonEventPublishData = { + data: error.code.toString(), + parameters: { + "formId" : this.deleteId.toString() + } + }; + commonEvent.publish(this.formOnDeletedEvent, commonEventPublishData, this.publishOnDeletedCallBack); + }); + console.log("[FormComponent.host] deleteForm end"); + }, 500); + } else if(this.releaseForm) { + console.log("[FormComponent.host] releaseForm start"); + if(this.releaseId == "self") { + this.releaseId = this.formId.toString(); + } + setTimeout(() => { + formManager.releaseForm(this.releaseId) + .then((data) => { + console.info('[FormComponent] releaseForm result:' + data); + var commonEventPublishData = { + data: "0", + parameters: { + "formId" : this.releaseId.toString() + } + }; + commonEvent.publish(this.formOnReleasedEvent, commonEventPublishData, this.publishOnReleasedCallBack); + }) + .catch((error) => { + console.info('formsystemhost releaseForm error:' + error); + let commonEventPublishData = { + data: error.code.toString(), + parameters: { + "formId" : this.releaseId.toString() + } + }; + commonEvent.publish(this.formOnReleasedEvent, commonEventPublishData, this.publishOnReleasedCallBack); + }); + + console.log("[FormComponent.host] releaseForm end"); + }, 500); + } else if (this.updateForm) { + console.log("formsystemhost updateForm start"); + let formData = { + temperature: "11°", + time: "11:00", + area: "Shenyang", + epidemic: true, + count: 10 + }; + if(this.jsonEmpty) { + formData = {}; + } + let bindingData = formBindingData.createFormBindingData(formData); + formProvider.updateForm(this.updateId, bindingData) + .then((data) => { + console.info('formsystemhost updateForm result:' + data); + let commonEventPublishData = { + data: "0", + parameters: { + "formId" : this.updateId + } + }; + commonEvent.publish(this.formOnUpdatedEvent, commonEventPublishData, this.publishOnUpdatedCallBack); + }) + .catch((error) => { + console.info('formsystemhost updateForm error:' + error); + let commonEventPublishData = { + data: error.code.toString(), + parameters: { + "formId" : this.updateId + } + }; + commonEvent.publish(this.formOnUpdatedEvent, commonEventPublishData, this.publishOnUpdatedCallBack); + }); + + console.log("formsystemhost releaseForm end"); + } else if (this.isStartOtherApp) { + console.log("formsystemhost app G start"); + featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "name", + "bundle" : "bundle", + "ability" : "ability", + "moduleName" : "entry", + "temporary" : false, + "stateForm" : this.otherAppState, + "stateIds" : [this.formId.toString()], + "isCreate" : false + } + } + }).then((res: any) => { + console.log(`formsystemhost featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`formsystemhost featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + } else { + var commonEventPublishData = { + data: this.formId.toString() + }; + commonEvent.publish(this.formOnAcquiredEvent, commonEventPublishData, this.publishOnAcquiredCallBack); + } + }) + // .onUninstall((info) => { + // console.log("[FormComponent] onUninstall:" + JSON.stringify(info)); + // }) + .onError((error) => { + console.log("[FormComponent.host] error code:" + error.errcode); + console.log("[FormComponent.host] error msg:" + error.msg); + this.onAcquireResult += error.errcode; + this.onAcquireResult += " "; + this.onAcquireResult += error.msg; + if(this.deleteForm && this.deleteId) { + let commonEventPublishData = { + data: error.msg, + parameters: { + "formId" : this.formId.toString() + } + }; + commonEvent.publish(this.formOnDeletedEvent, commonEventPublishData, this.publishOnDeletedCallBack); + } else { + let commonEventPublishData = { + data: error.msg + }; + commonEvent.publish(this.formOnErrorEvent, commonEventPublishData, this.publishOnErrorCallBack); + } + }) + } + } + .backgroundColor(Color.White) + Text('form component test end') + } + .backgroundColor(Color.White) + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostf/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostf/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..c882f827ab1f381a56251b150bc55eb6c3f082f2 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostf/entry/src/main/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "formhostF" + }, + { + "name": "description_mainability", + "value": "ETS_Empty Ability" + } + ] +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostf/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostf/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostf/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostf/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostf/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..6084de2e92d6f254a93a654b02701870bef66d31 Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostf/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostg/BUILD.gn b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostg/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..a4cec6e6f4b2c9d988ca269ca7191867267d2c2b --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostg/BUILD.gn @@ -0,0 +1,32 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("FormSystemHostG") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":hjs_demo_js_assets", + ":hjs_demo_resources", + ] + ets2abc = true + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "FormSystemHostG" +} +ohos_js_assets("hjs_demo_js_assets") { + source_dir = "./entry/src/main/ets/MainAbility" +} +ohos_resources("hjs_demo_resources") { + sources = [ "./entry/src/main/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostg/Test.json b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostg/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..3ec911dfc7b3a17504cd4577be5bbabaf7f97e63 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostg/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} diff --git a/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostg/entry/src/main/config.json b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostg/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..4b94f73261b48e6528c78aedf2598cffd0e71b60 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostg/entry/src/main/config.json @@ -0,0 +1,124 @@ +{ + "app": { + "bundleName": "com.ohos.st.formsystemhostg", + "vendor": "ohos", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 7, + "releaseType": "Release", + "target": 7 + } + }, + "deviceConfig": {}, + "module": { + "package": "com.ohos.st.formsystemhostg", + "name": ".FormStHostAppG", + "mainAbility": ".MainAbility", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": false + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "visible": true, + "name": ".MainAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:description_mainability", + "label": "$string:entry_MainAbility", + "type": "page", + "launchType": "standard" + } + ], + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ], + "defPermissions": [ + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormDelete_commonEvent" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormOnAcquired_commonEvent" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormOnError_commonEvent" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormOnDeleted_commonEvent" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormOnState_commonEvent" + } + ], + "reqPermissions": [ + { + "name": "FMS_FormOnAcquired_commonEvent" + }, + { + "name": "FMS_FormDelete_commonEvent" + }, + { + "name": "FMS_FormOnError_commonEvent" + }, + { + "name": "FMS_FormOnDeleted_commonEvent" + }, + { + "name": "FMS_FormOnState_commonEvent" + }, + { + "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + }, + { + "name": "ohos.permission.INSTALL_BUNDLE" + }, + { + "name": "ohos.permission.LISTEN_BUNDLE_CHANGE" + }, + { + "name": "ohos.permission.REQUIRE_FORM" + } + ] + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostg/entry/src/main/ets/MainAbility/app.ets b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostg/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..f49f9bd10ebd29ce7eb0445bee5a5928d9212a8a --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostg/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,23 @@ +/* + * 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. + */ + +export default { + onCreate() { + console.info('[FormComponent.host] Application onCreate') + }, + onDestroy() { + console.info('[FormComponent.host] Application onDestroy') + }, +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostg/entry/src/main/ets/MainAbility/pages/FormViewModel.ets b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostg/entry/src/main/ets/MainAbility/pages/FormViewModel.ets new file mode 100644 index 0000000000000000000000000000000000000000..9b09225070d8baf4062cf466a595a441993ae53b --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostg/entry/src/main/ets/MainAbility/pages/FormViewModel.ets @@ -0,0 +1,127 @@ +/* + * 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 formManager from '@ohos.ability.formmanager'; +import bundleManager from '@ohos.bundle'; +import abilityManager from '@ohos.app.abilityManager'; + +export default class FormViewModel { + private static sFormViewModel: FormViewModel = null; + + public static getInstance(): FormViewModel { + if (FormViewModel.sFormViewModel == null) { + FormViewModel.sFormViewModel = new FormViewModel(); + } + return FormViewModel.sFormViewModel; + } + + public async castTempFormToNormal(formId: string) { + formManager.castTempForm(formId) + .then((data) => { + console.info('[FormComponent] castTempForm result:' + data); + }); + } + + public async requestForm(formId: string) { + formManager.requestForm(formId) + .then((data) => { + console.info('[FormComponent] requestForm result:' + data); + }); + } + + public async deleteCard(formId: string) { + formManager.deleteForm(formId) + .then((data) => { + console.info('[FormComponent] deleteForm result:' + data); + }); + } + + public async releaseCard(formId: string) { + formManager.releaseForm(formId) + .then((data) => { + console.info('[FormComponent] releaseForm result:' + data); + }); + } + + public async enableCard(formId: string) { + formManager.enableFormsUpdate([formId]) + .then((data) => { + console.info('[FormComponent] enableFormsUpdate result:' + data); + }); + } + + public async disableCard(formId: string) { + formManager.disableFormsUpdate([formId]) + .then((data) => { + console.info('[FormComponent] disableCard result:' + data); + }); + } + + public async changeCardVisible(formId: string, isVisible: boolean) { + if (isVisible) { + formManager.notifyVisibleForms([formId]) + .then((data) => { + console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible); + }); + } else { + formManager.notifyInvisibleForms([formId]) + .then((data) => { + console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible); + }); + } + } + + public async isFmsReady() { + formManager.isSystemReady() + .then((data) => { + console.info('[FormComponent] isFmsReady result:' + data); + }); + } + + public async getAllFormsInfo() { + formManager.getAllFormsInfo() + .then((data) => { + console.info('[FormComponent] getAllFormsInfo result:' + JSON.stringify(data)); + }); + } + + public async getFormsInfoByApp(bundle: string) { + formManager.getFormsInfo(bundle) + .then((data) => { + console.info('[FormComponent] getFormsInfoByApp result:' + JSON.stringify(data)); + }); + } + + public async getFormsInfoByModule(bundle: string, moduleName: string) { + formManager.getFormsInfo(bundle, moduleName) + .then((data) => { + console.info('[FormComponent] getFormsInfoByModule result:' + JSON.stringify(data)); + }); + } + + public async clearFormUserCache() { + abilityManager.clearUpApplicationData('com.ohos.myapplicationform') + .then((data) => { + console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data)); + }); + } + + public async clearFormProviderCache(bundle: string) { + abilityManager.clearUpApplicationData(bundle) + .then((data) => { + console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data)); + }); + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostg/entry/src/main/ets/MainAbility/pages/index.ets b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostg/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..792ce411807e1c1038bf5ce55b7f9ac9860a8a43 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostg/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,524 @@ +/* + * 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 FormViewModel from './FormViewModel.ets'; +import router from '@system.router'; +import featureAbility from "@ohos.ability.featureAbility"; +import formManager from '@ohos.application.formHost' +import commonEvent from '@ohos.commonEvent'; + +@Entry +@Component +struct Index { + @State formId: number = 0; + @State bundle: string = "com.form.formsystemtestservicea.hmservice"; + @State ability: string = "com.form.formsystemtestservicea.hmservice.MainAbility"; + @State moduleName: string = "entry"; + @State name: string = "Form_Js001"; + @State width: number = 300; + @State height: number = 200; + @State allowUpate: boolean = true; + @State onAcquireResult: string = ""; + @State isShowing: boolean = true; + @State canCreateForm: boolean = false; + + private dimension: FormDimension = FormDimension.Dimension_1_2; + + private stateForm = "visible"; + private doStateForm = false; + private stateIds = []; + private deleteForm = false; + private deleteId = "-1"; + private temporaryId="-1"; + private temporary = false; + private mFormViewModel: FormViewModel; + private isVisible = false; + private mMargin = 15; + private BTN_BG_COLOR: string = '#0D9FFB'; + private tempFormId: number = 0; + + private formOnAcquiredEvent = "FMS_FormOnAcquired_commonEvent"; + private formOnErrorEvent = "FMS_FormOnError_commonEvent"; + private formOnDeletedEvent = "FMS_FormOnDeleted_commonEvent"; + private formOnStateEvent = "FMS_FormOnState_commonEvent"; + + private subscriberDel; + private subscriberFormDeleteEvent = { + events: ["FMS_FormDelete_commonEvent"], + }; + + private publishOnErrorCallBack() { + this.canCreateForm = false; + console.debug("====>[FormComponent.host] formOnErrorEventCallBack ====>"); + } + private publishOnDeletedCallBack() { + this.canCreateForm = false; + console.debug("====>[FormComponent.host] publishOnDeletedCallBack ====>"); + } + private publishOnStateCallBack() { + this.canCreateForm = false; + console.debug("====>[FormComponent.host] publishOnStateCallBack ====>"); + } + private publishOnAcquiredCallBack() { + console.debug("====>[FormComponent.host] formOnAcquiredEventCallBack ====>"); + } + private deleteCallBack(err, data) { + console.info("!!!====>[FormComponent.host] deleteCallBack start:====>" + JSON.stringify(data)); + if(data.bundleName && data.bundleName != "com.ohos.st.formsystemhostg") { + return; + } + formManager.deleteForm(data.data) + .then((data2) => { + console.info('[FormComponent] deleteForm result:' + data2); + }); + + this.canCreateForm = false; + console.info("!!!====>[FormComponent.host] deleteCallBack end ====>"); + } + + private unSubscribeDeleteCallback() { + console.debug("====>[FormComponent.host] unSubscribeDeleteCallback_1100 CallBack====>"); + } + + private aboutToAppear() { + + const TAG = "[FormComponent.host]" + + this.mFormViewModel = FormViewModel.getInstance(); + + commonEvent.createSubscriber(this.subscriberFormDeleteEvent).then(async (data) => { + console.info("====>[FormComponent.host] Subscriber FormDelete data:====>", JSON.stringify(data)); + this.subscriberDel = data; + await commonEvent.subscribe(this.subscriberDel, this.deleteCallBack); + }) + + console.error('[FormComponent] getWant'); + featureAbility.getWant() + .then((want: any) => { + this.formId = parseInt(want.parameters.formId); + this.name = want.parameters.name; + this.bundle = want.parameters.bundle; + this.ability = want.parameters.ability; + if(want.parameters.moduleName) { + this.moduleName = want.parameters.moduleName; + } + if(want.parameters.temporary) { + this.temporary = want.parameters.temporary; + } + if(want.parameters.dimension) { + this.dimension = want.parameters.dimension; + } + if(!this.dimension) { + this.dimension = FormDimension.Dimension_1_2; + } + if(want.parameters.temporaryId) { + this.temporaryId = want.parameters.temporaryId; + } + if(want.parameters.deleteForm) { + this.deleteForm = want.parameters.deleteForm; + } + if(want.parameters.deleteId) { + this.deleteId = want.parameters.deleteId; + } + if(want.parameters.stateForm) { + this.stateForm = want.parameters.stateForm; + this.doStateForm = true; + } + if(want.parameters.stateIds) { + this.stateIds = want.parameters.stateIds; + } + setTimeout(() => { + this.canCreateForm = want.parameters.isCreate ? true : false; + console.error('[FormComponent] getWant canCreateForm:'+ this.canCreateForm); + }, 10); + console.error('[FormComponent] getWant end'+ JSON.stringify(want)); + + if(!want.parameters.isCreate && this.deleteForm) { + console.log("[FormComponent.host] deleteForm start"); + formManager.deleteForm(this.deleteId) + .then((data) => { + console.info('[FormComponent.host] deleteForm result:' + data); + let commonEventPublishData = { + data: "0", + parameters: { + "formId" : this.deleteId; + } + }; + commonEvent.publish(this.formOnDeletedEvent, commonEventPublishData, this.publishOnDeletedCallBack); + }) + .catch((error) => { + console.info('[FormComponent.host] deleteForm error:' + error); + let commonEventPublishData = { + data: error.code.toString(), + parameters: { + "formId" : this.deleteId; + } + }; + commonEvent.publish(this.formOnDeletedEvent, commonEventPublishData, this.publishOnDeletedCallBack); + }); + + console.log("[FormComponent.host] deleteForm end"); + } + + if(!want.parameters.isCreate && this.stateForm) { + if(this.stateForm == "visible") { + console.log("[FormComponent.host] notifyVisibleForm start"); + formManager.notifyVisibleForms(this.stateIds) + .then((data) => { + console.info('[FormComponent.host] notifyVisibleForm result:' + data); + console.info('[FormComponent.host] notifyVisibleForm formId:' + this.stateIds[0]); + let commonEventPublishData = { + data: "0", + parameters: { + "kind": "visible", + "formId" : this.stateIds[0] + } + }; + commonEvent.publish(this.formOnStateEvent, commonEventPublishData, this.publishOnStateCallBack); + }) + .catch((error) => { + console.info('[FormComponent.host] notifyVisibleForm error:' + error); + let commonEventPublishData = { + data: error.code.toString(), + parameters: { + "kind": "visible", + "formId" : this.stateIds[0] + } + }; + commonEvent.publish(this.formOnStateEvent, commonEventPublishData, this.publishOnStateCallBack); + }); + console.log("[FormComponent.host] notifyVisibleForm end"); + } else if(this.stateForm == "invisible") { + console.log("[FormComponent.host] notifyInvisibleForm start"); + formManager.notifyInvisibleForms(this.stateIds) + .then((data) => { + console.info('[FormComponent.host] notifyInvisibleForm result:' + data); + console.info('[FormComponent.host] notifyInvisibleForm formId:' + this.stateIds[0]); + let commonEventPublishData = { + data: "0", + parameters: { + "kind": "invisible", + "formId" : this.stateIds[0] + } + }; + commonEvent.publish(this.formOnStateEvent, commonEventPublishData, this.publishOnStateCallBack); + }) + .catch((error) => { + console.info('[FormComponent.host] notifyInvisibleForm error:' + error); + let commonEventPublishData = { + data: error.code.toString(), + parameters: { + "kind": "invisible", + "formId" : this.stateIds[0] + } + }; + commonEvent.publish(this.formOnStateEvent, commonEventPublishData, this.publishOnStateCallBack); + }); + console.log("[FormComponent.host] notifyInvisibleForm end"); + } else if(this.stateForm == "enable") { + console.log("[FormComponent.host] enableFormsUpdate start"); + formManager.enableFormsUpdate(this.stateIds) + .then((data) => { + console.info('[FormComponent.host] enableFormsUpdate result:' + data); + let commonEventPublishData = { + data: "0", + parameters: { + "kind": "enable", + "formId" : this.stateIds[0] + } + }; + commonEvent.publish(this.formOnStateEvent, commonEventPublishData, this.publishOnStateCallBack); + }) + .catch((error) => { + console.info('[FormComponent.host] enableFormsUpdate error:' + error); + let commonEventPublishData = { + data: error.code.toString(), + parameters: { + "kind": "enable", + "formId" : this.stateIds[0] + } + }; + commonEvent.publish(this.formOnStateEvent, commonEventPublishData, this.publishOnStateCallBack); + }); + console.log("[FormComponent.host] enableFormsUpdate end"); + } else { + console.log("[FormComponent.host] disableFormsUpdate start"); + formManager.disableFormsUpdate(this.stateIds) + .then((data) => { + console.info('[FormComponent.host] disableFormsUpdate result:' + data); + let commonEventPublishData = { + data: "0", + parameters: { + "kind": "disable", + "formId" : this.stateIds[0] + } + }; + commonEvent.publish(this.formOnStateEvent, commonEventPublishData, this.publishOnStateCallBack); + }) + .catch((error) => { + console.info('[FormComponent.host] disableFormsUpdate error:' + error); + let commonEventPublishData = { + data: error.code.toString(), + parameters: { + "kind": "disable", + "formId" : this.stateIds[0] + } + }; + commonEvent.publish(this.formOnStateEvent, commonEventPublishData, this.publishOnStateCallBack); + }); + console.log("[FormComponent.host] disableFormsUpdate end"); + } + } + + }) + .catch((error: any) => { + console.error('[FormComponent] Operation failed. Cause: ' + JSON.stringify(error)); + }) + console.log(`[FormComponent.host] aboutToAppear end`); + } + + build() { + Column() { + Text('form component test begin') + Column() { + if (this.canCreateForm) { + 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); + this.formId = form.id; + if(this.deleteForm) { + console.log("[FormComponent.host] deleteForm start"); + if(this.deleteId == "self") { + this.deleteId = this.formId.toString(); + } + setTimeout(() => { + formManager.deleteForm(this.deleteId) + .then((data) => { + console.info('[FormComponent] deleteForm result:' + data); + let commonEventPublishData = { + data: "0", + parameters: { + "formId" : this.deleteId; + } + }; + commonEvent.publish(this.formOnDeletedEvent, commonEventPublishData, this.publishOnDeletedCallBack); + }) + .catch((error) => { + console.info('[FormComponent.host] deleteForm error:' + error); + let commonEventPublishData = { + data: error.code.toString(), + parameters: { + "formId" : this.deleteId + } + }; + commonEvent.publish(this.formOnDeletedEvent, commonEventPublishData, this.publishOnDeletedCallBack); + }); + + console.log("[FormComponent.host] deleteForm end"); + }, 500); + } else if(this.doStateForm) { + console.log("[FormComponent.host] state start"); + if((this.stateIds.length != 0) && (this.stateIds[0] == "self")) { + this.stateIds = [this.formId.toString()]; + } + console.info('[FormComponent.host] notifyVisibleForm stateIds:' + this.stateIds); + setTimeout(() => { + if(this.stateForm == "visible") { + console.log("[FormComponent.host] notifyVisibleForm start"); + formManager.notifyVisibleForms(this.stateIds) + .then((data) => { + console.info('[FormComponent.host] notifyVisibleForm result:' + data); + console.info('[FormComponent.host] notifyVisibleForm formId:' + this.stateIds[0]); + if(this.stateIds.length == 0) { + this.stateIds = ["-1"]; + } + let commonEventPublishData = { + data: "0", + parameters: { + "kind": "visible", + "formId" : this.stateIds[0] + } + }; + commonEvent.publish(this.formOnStateEvent, commonEventPublishData, this.publishOnStateCallBack); + }) + .catch((error) => { + console.info('[FormComponent.host] notifyVisibleForm error:' + error); + if(this.stateIds.length == 0) { + this.stateIds = ["-1"]; + } + let commonEventPublishData = { + data: error.code.toString(), + parameters: { + "kind": "visible", + "formId" : this.stateIds[0] + } + }; + commonEvent.publish(this.formOnStateEvent, commonEventPublishData, this.publishOnStateCallBack); + }); + console.log("[FormComponent.host] notifyVisibleForm end"); + } else if(this.stateForm == "invisible") { + console.log("[FormComponent.host] notifyInvisibleForm start"); + formManager.notifyInvisibleForms(this.stateIds) + .then((data) => { + console.info('[FormComponent.host] notifyInvisibleForm result:' + data); + if(this.stateIds.length == 0) { + this.stateIds = ["-1"]; + } + console.info('[FormComponent.host] notifyInvisibleForm formId:' + this.stateIds[0]); + let commonEventPublishData = { + data: "0", + parameters: { + "kind": "invisible", + "formId" : this.stateIds[0] + } + }; + commonEvent.publish(this.formOnStateEvent, commonEventPublishData, this.publishOnStateCallBack); + }) + .catch((error) => { + console.info('[FormComponent.host] notifyInvisibleForm error:' + error.code); + if(this.stateIds.length == 0) { + this.stateIds = ["-1"]; + } + let commonEventPublishData = { + data: error.code.toString(), + parameters: { + "kind": "invisible", + "formId" : this.stateIds[0] + } + }; + commonEvent.publish(this.formOnStateEvent, commonEventPublishData, this.publishOnStateCallBack); + }); + console.log("[FormComponent.host] notifyInvisibleForm end"); + } else if(this.stateForm == "enable") { + console.log("[FormComponent.host] enableFormsUpdate start"); + formManager.enableFormsUpdate(this.stateIds) + .then((data) => { + console.info('[FormComponent.host] enableFormsUpdate result:' + data); + if(this.stateIds.length == 0) { + this.stateIds = ["-1"]; + } + let commonEventPublishData = { + data: "0", + parameters: { + "kind": "enable", + "formId" : this.stateIds[0] + } + }; + commonEvent.publish(this.formOnStateEvent, commonEventPublishData, this.publishOnStateCallBack); + }) + .catch((error) => { + console.info('[FormComponent.host] enableFormsUpdate error:' + error); + if(this.stateIds.length == 0) { + this.stateIds = ["-1"]; + } + let commonEventPublishData = { + data: error.code.toString(), + parameters: { + "kind": "enable", + "formId" : this.stateIds[0] + } + }; + commonEvent.publish(this.formOnStateEvent, commonEventPublishData, this.publishOnStateCallBack); + }); + console.log("[FormComponent.host] enableFormsUpdate end"); + } else { + console.log("[FormComponent.host] disableFormsUpdate start"); + formManager.disableFormsUpdate(this.stateIds) + .then((data) => { + console.info('[FormComponent.host] disableFormsUpdate result:' + data); + if(this.stateIds.length == 0) { + this.stateIds = ["-1"]; + } + let commonEventPublishData = { + data: "0", + parameters: { + "kind": "disable", + "formId" : this.stateIds[0] + } + }; + commonEvent.publish(this.formOnStateEvent, commonEventPublishData, this.publishOnStateCallBack); + }) + .catch((error) => { + console.info('[FormComponent.host] disableFormsUpdate error:' + error); + if(this.stateIds.length == 0) { + this.stateIds = ["-1"]; + } + let commonEventPublishData = { + data: error.code.toString(), + parameters: { + "kind": "disable", + "formId" : this.stateIds[0] + } + }; + commonEvent.publish(this.formOnStateEvent, commonEventPublishData, this.publishOnStateCallBack); + }); + console.log("[FormComponent.host] disableFormsUpdate end"); + } + }, 1000); + } else { + let commonEventPublishData = { + data: this.formId.toString(), + parameters: { + "formId" : this.formId.toString() + } + }; + commonEvent.publish(this.formOnAcquiredEvent, commonEventPublishData, this.publishOnAcquiredCallBack); + } + }) + .onUninstall((info) => { + console.log("[FormComponent] onUninstall:" + JSON.stringify(info)); + }) + .onError((error) => { + console.log("[FormComponent.host] error code:" + error.errcode); + console.log("[FormComponent.host] error msg:" + error.msg); + this.onAcquireResult += error.errcode; + this.onAcquireResult += " "; + this.onAcquireResult += error.msg; + if(this.deleteForm && this.deleteId) { + let commonEventPublishData = { + data: error.msg, + parameters: { + "formId" : this.formId.toString() + } + }; + commonEvent.publish(this.formOnDeletedEvent, commonEventPublishData, this.publishOnDeletedCallBack); + } else { + let commonEventPublishData = { + data: error.msg, + parameters: { + "formId" : "-1" + } + }; + commonEvent.publish(this.formOnErrorEvent, commonEventPublishData, this.publishOnErrorCallBack); + } + }) + } + } + .backgroundColor(Color.White) + Text('form component test end') + } + .backgroundColor(Color.White) + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostg/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostg/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..6599b743b4595d9466e1e01cd86af8be538c06b4 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostg/entry/src/main/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "formhostG" + }, + { + "name": "description_mainability", + "value": "ETS_Empty Ability" + } + ] +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostg/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostg/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostg/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostg/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostg/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..6084de2e92d6f254a93a654b02701870bef66d31 Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostg/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostn/BUILD.gn b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostn/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..fcf084568f352b8efec14a5602fd987a28d5866e --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostn/BUILD.gn @@ -0,0 +1,32 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("FormSystemHostN") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":hjs_demo_js_assets", + ":hjs_demo_resources", + ] + ets2abc = true + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "FormSystemHostN" +} +ohos_js_assets("hjs_demo_js_assets") { + source_dir = "./entry/src/main/ets/MainAbility" +} +ohos_resources("hjs_demo_resources") { + sources = [ "./entry/src/main/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostn/Test.json b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostn/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..3ec911dfc7b3a17504cd4577be5bbabaf7f97e63 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostn/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} diff --git a/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostn/entry/src/main/config.json b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostn/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..bba04f58c33a6dcdcffec741a932da4cebdb5744 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostn/entry/src/main/config.json @@ -0,0 +1,124 @@ +{ + "app": { + "bundleName": "com.ohos.st.formsystemhostn", + "vendor": "ohos", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 7, + "releaseType": "Release", + "target": 7 + } + }, + "deviceConfig": {}, + "module": { + "package": "com.ohos.st.formsystemhostn", + "name": ".FormStHostAppN", + "mainAbility": ".MainAbility", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": false + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "visible": true, + "name": ".MainAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:description_mainability", + "label": "$string:entry_MainAbility", + "type": "page", + "launchType": "standard" + } + ], + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ], + "defPermissions": [ + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormDelete_commonEvent" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormOnAcquired_commonEvent" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormOnError_commonEvent" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormCast_commonEvent" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_SendCastForm_commonEvent" + } + ], + "reqPermissions": [ + { + "name": "FMS_FormOnAcquired_commonEvent" + }, + { + "name": "FMS_FormDelete_commonEvent" + }, + { + "name": "FMS_FormOnError_commonEvent" + }, + { + "name": "FMS_FormCast_commonEvent" + }, + { + "name": "FMS_SendCastForm_commonEvent" + }, + { + "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + }, + { + "name": "ohos.permission.INSTALL_BUNDLE" + }, + { + "name": "ohos.permission.LISTEN_BUNDLE_CHANGE" + }, + { + "name": "ohos.permission.REQUIRE_FORM" + } + ] + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostn/entry/src/main/ets/MainAbility/app.ets b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostn/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..f49f9bd10ebd29ce7eb0445bee5a5928d9212a8a --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostn/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,23 @@ +/* + * 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. + */ + +export default { + onCreate() { + console.info('[FormComponent.host] Application onCreate') + }, + onDestroy() { + console.info('[FormComponent.host] Application onDestroy') + }, +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostn/entry/src/main/ets/MainAbility/pages/index.ets b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostn/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..de99d63ccfe0fde5b84a9a4584be1b89f602e4ed --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostn/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,462 @@ +/* + * 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 featureAbility from "@ohos.ability.featureAbility"; +import formManager from '@ohos.application.formHost'; +import commonEvent from '@ohos.commonEvent'; +@Entry +@Component +struct Index { + @State bundle: string = "com.form.formsystemtestservicea.hmservice"; + @State ability: string = "com.form.formsystemtestservicea.hmservice.MainAbility"; + @State moduleName: string = "entry"; + @State name: string = "Form_Js001"; + @State width: number = 300; + @State height: number = 200; + @State allowUpate: boolean = true; + @State onAcquireResult: string = ""; + @State isShowing: boolean = true; + @State optType: number = 0; + private dimension: FormDimension = FormDimension.Dimension_1_2; + private isTemporary = false; + private isVisible = false; + private mMargin = 15; + private BTN_BG_COLOR: string = '#0D9FFB'; + + private normal = 0; + private temporary = 0; + private normaldel = 0; + private temporarydel = 0; + private normalFormIds = []; + private tempFormIds = []; + + private deleteIds = []; + private delCount = 0; + + private normalFormCounts = []; + private tempFormCounts = []; + + private castFormId = "-1"; + + private formOnAcquiredEvent = "FMS_FormOnAcquired_commonEvent"; + private formOnErrorEvent = "FMS_FormOnError_commonEvent"; + private formCastEvent = "FMS_FormCast_commonEvent"; + + private subscriberDel; + private subscriberFormDeleteEvent = { + events: ["FMS_FormDelete_commonEvent"], + }; + + private subscriberSendCastForm; + private subscriberSendCastFormEvent = { + events: ["FMS_SendCastForm_commonEvent"], + }; + + private publishOnErrorCallBack() { + console.debug("====> [FormComponent] formsystemhostn formOnErrorEvent Publish CallBack ====>"); + } + private publishOnAcquiredCallBack() { + console.debug("====> [FormComponent] formsystemhostn formOnAcquiredEvent Publish CallBack ====>"); + } + private publishDeleteCallBack() { + console.debug("====> [FormComponent] formsystemhostn publishDeleteCallBack Publish CallBack ====>"); + } + private publishCastCallBack() { + console.debug("====>formCastEvent Publish CallBack ====>"); + } + private startAbility(bundleName, abilityName, sendMsg) { + featureAbility.startAbility({ + want: { + bundleName: bundleName, + abilityName: abilityName, + parameters: { + "formId": "0", + "name": "Form_Js001", + "bundle": "com.form.formsystemtestservicea.hmservice", + "ability": "com.form.formsystemtestservicea.hmservice.MainAbility", + "moduleName": "entry", + "temporary": false, + "sendCastForm": true, + "sendCastFormMsg": sendMsg, + "isCreate": false + } + } + }).then((res: any) => { + console.info(`[FormComponent] formsystemhostn featureAbility.startAbility res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.info(`[FormComponent] formsystemhostn featureAbility.startAbility error: ${JSON.stringify(err)}`); + }); + } + private publishOnSendCastForm(err, data) { + console.info("!!!====>[FormComponent] formsystemhostn OnSendCastForm start:====>" + JSON.stringify(data)); + if (data.bundleName && data.bundleName != "com.ohos.st.formsystemhostn") { + return; + } + let formId = data.parameters.castFormId; + setTimeout(function () { + console.info("[FormComponent.host] castTempForm start, formId: " + formId); + formManager.castTempForm(formId) + .then((data) => { + console.info('[FormComponent] castTempForm result:' + data); + this.startAbility("com.ohos.st.formsystemhostc", "com.ohos.st.formsystemhostc.MainAbility", data.toString()); + }) + .catch((error) => { + console.info('[FormComponent] castTempForm error:' + JSON.stringify(error)); + this.startAbility("com.ohos.st.formsystemhostc", "com.ohos.st.formsystemhostc.MainAbility", error.code.toString()); + }); + console.info("[FormComponent.host] castTempForm end"); + }, 5000); + console.info("!!!====>[FormComponent] formsystemhostn OnSendCastForm end"); + } + + private deleteCallBack(err, data) { + console.info("!!!====>[FormComponent] formsystemhostn deleteCallBack start:====>" + JSON.stringify(data)); + const delFormIds = data.parameters.formIds; + console.info(`[FormComponent] data size ${delFormIds.length}`); + + console.info(`[FormComponent] data.subscriber ${JSON.stringify(this.subscriberDel)}`); + commonEvent.unsubscribe(this.subscriberDel, () => { + console.info("====> [FormComponent] formsystemhostn optType unSubscribeDeleteCallback CallBack====>"); + }); + commonEvent.unsubscribe(this.subscriberSendCastForm, () => { + console.info("====> [FormComponent] formsystemhostn optType unSubscribeCastFormCallback CallBack====>"); + }); + console.info(`[FormComponent] data.bundleName ${JSON.stringify(data.bundleName)}`); + console.info(`[FormComponent] tof ${"com.ohos.st.formsystemhostn" != data.bundleName}`); + if ("com.ohos.st.formsystemhostn" != data.bundleName) { + return; + } + delFormIds.forEach(async (formId, index) => { + console.info(`[FormComponent] formsystemhostn deleteForm ${index}`); + try { + const res = await formManager.deleteForm(formId); + console.info(`[FormComponent] formsystemhostn deleteForm ${index} ${formId} result: ${JSON.stringify(res)}`); + } catch (error) { + console.info(`[FormComponent] formsystemhostn deleteForm ${index} ${formId} error: ${JSON.stringify(error)}`); + } + }); + console.info("!!!====> [FormComponent] formsystemhostn optType deleteCallBack end ====>"); + } + + private unSubscribeDeleteCallback() { + console.debug("====> [FormComponent] formsystemhostn optType unSubscribeDeleteCallback CallBack====>"); + } + + private unSubscribeCastFormCallback() { + console.debug("====> [FormComponent] formsystemhostn optType unSubscribeCastFormCallback CallBack====>"); + } + + private aboutToAppear() { + const TAG = "[FormComponent.hostn]"; + + commonEvent.createSubscriber(this.subscriberFormDeleteEvent).then(async (data) => { + console.info("====>[FormComponent] formsystemhostn Subscriber FormDelete data:====>", JSON.stringify(data)); + this.subscriberDel = data; + commonEvent.subscribe(this.subscriberDel, (err, data) => { + if ("com.ohos.st.formsystemhostn" != data.bundleName) { + return; + } else { + console.info("!!!====>[FormComponent.hostn] formsystemhostn deleteCallBack start:====>" + JSON.stringify(data)); + const delFormIds = data.parameters.formIds; + console.info(`[FormComponent] data size ${delFormIds.length}`); + commonEvent.unsubscribe(this.subscriberDel, () => { + console.info("====> [FormComponent] formsystemhostn optType unSubscribeDeleteCallback CallBack====>"); + }); + commonEvent.unsubscribe(this.subscriberSendCastForm, () => { + console.info("====> [FormComponent] formsystemhostn optType unSubscribeCastFormCallback CallBack====>"); + }); + let delCounter = 0; + delFormIds.forEach((formId) => { + formManager.deleteForm(formId, (error, data) => { + console.info(`[FormComponent] formsystemhostn deleteForm ${++delCounter} ${formId} data: ${JSON.stringify(data)} err: ${JSON.stringify(error)}`); + }); + }); + } + }); + }); + + commonEvent.createSubscriber(this.subscriberSendCastFormEvent).then(async (data) => { + console.info("====>[FormComponent] formsystemhostn Subscriber SendCastForm data:====>", JSON.stringify(data)); + this.subscriberSendCastForm = data; + await commonEvent.subscribe(this.subscriberSendCastForm, this.publishOnSendCastForm); + }); + + featureAbility.getWant() + .then(async (want: any) => { + console.info(" [FormComponent] formsystemhostn getWant:" + JSON.stringify(want)); + + this.name = want.parameters.name; + this.bundle = want.parameters.bundle; + this.ability = want.parameters.ability; + if (want.parameters.moduleName) { + this.moduleName = want.parameters.moduleName; + } + + if (want.parameters.dimension) { + this.dimension = want.parameters.dimension; + } + + if (want.parameters.normal) { + this.normal = want.parameters.normal; + } + + if (want.parameters.temporary) { + this.temporary = want.parameters.temporary; + } + if (want.parameters.normaldel) { + this.normaldel = want.parameters.normaldel; + } + + if (want.parameters.temporarydel) { + this.temporarydel = want.parameters.temporarydel; + } + + if (want.parameters.deleteIds) { + this.deleteIds = want.parameters.deleteIds; + } + if (want.parameters.castFormId) { + this.castFormId = want.parameters.castFormId; + } + + if (want.parameters.releaseFormId) { + commonEvent.unsubscribe(this.subscriberDel, () => { + console.info("====> [FormComponent] formsystemhostn optType unSubscribeDeleteCallback CallBack====>"); + }); + commonEvent.unsubscribe(this.subscriberSendCastForm, () => { + console.info("====> [FormComponent] formsystemhostn optType unSubscribeCastFormCallback CallBack====>"); + }); + + const formId = want.parameters.releaseFormId; + const isReleaseCache = want.parameters.isReleaseCache; + const res = await formManager.releaseForm(formId, isReleaseCache); + console.info(`[FormComponent] releaseForm res: ${JSON.stringify(res)}`); + const commonEventPublishData = { + data: `releaseForm`, + bundleName: `com.ohos.st.formsystemhostn`, + parameters: { + formIds: [].concat(formId) + } + }; + commonEvent.publish(this.formOnAcquiredEvent, commonEventPublishData, this.publishOnAcquiredCallBack); + + this.normal = 1; + } + + this.makeCount(); + + setTimeout(() => { + this.optType = want.parameters.optType; + console.info(' [FormComponent] formsystemhostn getWant optType:' + this.optType); + }, 10); + + if (this.castFormId != "-1" && want.parameters.optType == 3) { + console.info("[FormComponent.host] castTempForm start"); + commonEvent.unsubscribe(this.subscriberDel, () => { + console.info("====> [FormComponent] formsystemhostn optType unSubscribeDeleteCallback CallBack====>"); + }); + commonEvent.unsubscribe(this.subscriberSendCastForm, () => { + console.info("====> [FormComponent] formsystemhostn optType unSubscribeCastFormCallback CallBack====>"); + }); + + formManager.castTempForm(this.castFormId) + .then((data) => { + console.info('[FormComponent] castTempForm result:' + data); + let commonEventPublishData = { + data: data || `0`, + bundleName: "com.ohos.st.formsystemhostn", + parameters: { + formId: this.castFormId.toString() + } + }; + commonEvent.publish(this.formCastEvent, commonEventPublishData, this.publishCastCallBack); + }) + .catch((error) => { + console.info('[FormComponent] castTempForm error:' + error.code); + let commonEventPublishData = { + data: error.code.toString(), + errMsg: error.msg, + bundleName: "com.ohos.st.formsystemhostn", + parameters: { + formId: this.castFormId.toString() + } + }; + commonEvent.publish(this.formCastEvent, commonEventPublishData, this.publishCastCallBack); + }); + console.info("[FormComponent.host] castTempForm end"); + } + + if (want.parameters.optType == 2 && this.deleteIds.length > 0) { + for (let iIndex = 0; iIndex < this.deleteIds.length; ++iIndex) { + console.info("[FormComponent] formsystemhostn deleteForm start"); + formManager.deleteForm(this.deleteIds[iIndex]) + .then((data) => { + console.info('[FormComponent] formsystemhostn deleteForm result:' + data); + this.delCount++; + + if (this.delCount == this.deleteIds.length) { + let commonEventPublishData = { + data: data.toString(), + bundleName: "com.ohos.st.formsystemhostn", + parameters: { + "formIds": this.deleteIds + } + }; + commonEvent.publish(this.formOnErrorEvent, commonEventPublishData, this.publishDeleteCallBack); + } + }) + .catch((error) => { + console.info(' [FormComponent] formsystemhostn deleteForm error:' + error); + let commonEventPublishData = { + data: error.code.toString(), + bundleName: "com.ohos.st.formsystemhostn", + parameters: { + "formIds": [this.deleteIds[iIndex]] + } + }; + commonEvent.publish(this.formOnErrorEvent, commonEventPublishData, this.publishOnErrorCallBack); + }); + console.info("[FormComponent] formsystemhostn deleteForm end"); + } + } + }) + .catch((error: any) => { + console.error(' [FormComponent] formsystemhostn Operation failed. Cause: ' + JSON.stringify(error)); + }) + console.info(`[FormComponent.host] aboutToAppear end`); + } + + private makeCount() { + console.info(' [FormComponent] formsystemhostn makeCount start.'); + for (let nNormal = 0; nNormal < this.normal; nNormal++) { + this.normalFormCounts.push(nNormal); + } + console.info(' [FormComponent] formsystemhostn this.normalFormCounts.length:' + this.normalFormCounts.length); + + for (let nTemp = 0; nTemp < this.temporary; nTemp++) { + this.tempFormCounts.push(nTemp); + } + console.info(' [FormComponent] formsystemhostn this.tempFormCounts.length:' + this.tempFormCounts.length); + } + + build() { + Scroll(new Scroller()) { + Column() { + if (this.optType == 1) { + Text(' [FormComponent] formsystemhostn normal form component test begin') + Grid() { + ForEach(this.normalFormCounts, (item) => { + GridItem() { + FormComponent({ + id: 0, + name: this.name, + bundle: this.bundle, + ability: this.ability, + module: this.moduleName, + dimension: this.dimension, + temporary: false + }) + .allowUpdate(this.allowUpate) + .visibility(this.isShowing ? Visibility.Visible : Visibility.Hidden) + .onAcquired((form) => { + console.info(" [FormComponent] formsystemhostn get normal form, form id:" + form.id); + + this.normalFormIds.push(form.id.toString()); + if (this.normalFormIds.length == this.normal - this.normaldel) { + let commonEventPublishData = { + data: "normalForm", + bundleName: "com.ohos.st.formsystemhostn", + parameters: { + "formIds": this.normalFormIds + } + }; + commonEvent.publish(this.formOnAcquiredEvent, commonEventPublishData, this.publishOnAcquiredCallBack); + } + }) + .onError((error) => { + console.info(" [FormComponent] formsystemhostn normal form error code:" + error.errcode); + console.info(" [FormComponent] formsystemhostn normal form error msg:" + error.msg); + let commonEventPublishData = { + data: error.msg, + bundleName: "com.ohos.st.formsystemhostn" + }; + commonEvent.publish(this.formOnErrorEvent, commonEventPublishData, this.publishOnErrorCallBack); + }) + .size({ width: 40, height: 40 }) + } + }, (item) => JSON.stringify(item)) + } + .columnsTemplate('1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr ') + .columnsGap(2) + .rowsGap(2) + .width('100%') + Text(' [FormComponent] formsystemhostn normal form component test end') + + Text(' [FormComponent] formsystemhostn temp form component test start') + Grid() { + ForEach(this.tempFormCounts, (item) => { + GridItem() { + FormComponent({ + id: 0, + name: this.name, + bundle: this.bundle, + ability: this.ability, + module: this.moduleName, + dimension: this.dimension, + temporary: true + }) + .allowUpdate(this.allowUpate) + .visibility(this.isShowing ? Visibility.Visible : Visibility.Hidden) + .onAcquired((form) => { + console.info(" [FormComponent] formsystemhostn get temp form, form id:" + form.id); + this.tempFormIds.push(form.id.toString()); + if (this.tempFormIds.length == this.temporary - this.temporarydel) { + let commonEventPublishData = { + data: "tempForm", + bundleName: "com.ohos.st.formsystemhostn", + parameters: { + "formIds": this.tempFormIds + } + }; + commonEvent.publish(this.formOnAcquiredEvent, commonEventPublishData, this.publishOnAcquiredCallBack); + } + }) + .onError((error) => { + console.info(" [FormComponent] formsystemhostn temp form error code:" + error.errcode); + console.info(" [FormComponent] formsystemhostn temp form error msg:" + error.msg); + let commonEventPublishData = { + data: error.msg, + bundleName: "com.ohos.st.formsystemhostn" + }; + commonEvent.publish(this.formOnErrorEvent, commonEventPublishData, this.publishOnErrorCallBack); + }) + .size({ width: 40, height: 40 }) + } + }, (item) => JSON.stringify(item)) + } + .columnsTemplate('1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr ') + .columnsGap(2) + .rowsGap(2) + .width('100%') + + Text(' [FormComponent] formsystemhostn temp form component test end') + } + } + .backgroundColor(Color.White) + } + .scrollable(ScrollDirection.Vertical) + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostn/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostn/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..a92ae9f033e94fcb61f4dc7bb745b4403f427bcb --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostn/entry/src/main/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "formhostN" + }, + { + "name": "description_mainability", + "value": "ETS_Empty Ability" + } + ] +} diff --git a/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostn/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostn/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostn/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostn/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostn/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..6084de2e92d6f254a93a654b02701870bef66d31 Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostn/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostnoperm/BUILD.gn b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostnoperm/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..ee371aeacba39f85e0b03f6aaa76189854c8aaf8 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostnoperm/BUILD.gn @@ -0,0 +1,32 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("FormSystemHostNoPerm") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":hjs_demo_js_assets", + ":hjs_demo_resources", + ] + ets2abc = true + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "FormSystemHostNoPerm" +} +ohos_js_assets("hjs_demo_js_assets") { + source_dir = "./entry/src/main/ets/MainAbility" +} +ohos_resources("hjs_demo_resources") { + sources = [ "./entry/src/main/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostnoperm/Test.json b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostnoperm/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..3ec911dfc7b3a17504cd4577be5bbabaf7f97e63 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostnoperm/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} diff --git a/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostnoperm/entry/src/main/config.json b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostnoperm/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..4dd2ebce23f4b3b1e06b560be819a6820f9ec6d3 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostnoperm/entry/src/main/config.json @@ -0,0 +1,137 @@ +{ + "app": { + "bundleName": "com.ohos.st.formsystemhostnoperm", + "vendor": "ohos", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 7, + "releaseType": "Release", + "target": 7 + } + }, + "deviceConfig": {}, + "module": { + "package": "com.ohos.st.formsystemhostnoperm", + "name": ".FormStHostAppNoPerm", + "mainAbility": ".MainAbility", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": false + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "visible": true, + "name": ".MainAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:description_mainability", + "label": "$string:entry_MainAbility", + "type": "page", + "launchType": "standard" + } + ], + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ], + "defPermissions": [ + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormDelete_commonEvent" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormOnAcquired_commonEvent" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormOnError_commonEvent" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormOnDeleted_commonEvent" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormOnReleased_commonEvent" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormOnRequest_commonEvent" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormOnState_commonEvent" + } + ], + "reqPermissions": [ + { + "name": "FMS_FormOnAcquired_commonEvent" + }, + { + "name": "FMS_FormDelete_commonEvent" + }, + { + "name": "FMS_FormOnError_commonEvent" + }, + { + "name": "FMS_FormOnDeleted_commonEvent" + }, + { + "name": "FMS_FormOnReleased_commonEvent" + }, + { + "name": "FMS_FormOnRequest_commonEvent" + }, + { + "name": "FMS_FormOnState_commonEvent" + }, + { + "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + }, + { + "name": "ohos.permission.INSTALL_BUNDLE" + }, + { + "name": "ohos.permission.LISTEN_BUNDLE_CHANGE" + } + ] + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostnoperm/entry/src/main/ets/MainAbility/app.ets b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostnoperm/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..f49f9bd10ebd29ce7eb0445bee5a5928d9212a8a --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostnoperm/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,23 @@ +/* + * 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. + */ + +export default { + onCreate() { + console.info('[FormComponent.host] Application onCreate') + }, + onDestroy() { + console.info('[FormComponent.host] Application onDestroy') + }, +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostnoperm/entry/src/main/ets/MainAbility/pages/FormViewModel.ets b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostnoperm/entry/src/main/ets/MainAbility/pages/FormViewModel.ets new file mode 100644 index 0000000000000000000000000000000000000000..9b09225070d8baf4062cf466a595a441993ae53b --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostnoperm/entry/src/main/ets/MainAbility/pages/FormViewModel.ets @@ -0,0 +1,127 @@ +/* + * 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 formManager from '@ohos.ability.formmanager'; +import bundleManager from '@ohos.bundle'; +import abilityManager from '@ohos.app.abilityManager'; + +export default class FormViewModel { + private static sFormViewModel: FormViewModel = null; + + public static getInstance(): FormViewModel { + if (FormViewModel.sFormViewModel == null) { + FormViewModel.sFormViewModel = new FormViewModel(); + } + return FormViewModel.sFormViewModel; + } + + public async castTempFormToNormal(formId: string) { + formManager.castTempForm(formId) + .then((data) => { + console.info('[FormComponent] castTempForm result:' + data); + }); + } + + public async requestForm(formId: string) { + formManager.requestForm(formId) + .then((data) => { + console.info('[FormComponent] requestForm result:' + data); + }); + } + + public async deleteCard(formId: string) { + formManager.deleteForm(formId) + .then((data) => { + console.info('[FormComponent] deleteForm result:' + data); + }); + } + + public async releaseCard(formId: string) { + formManager.releaseForm(formId) + .then((data) => { + console.info('[FormComponent] releaseForm result:' + data); + }); + } + + public async enableCard(formId: string) { + formManager.enableFormsUpdate([formId]) + .then((data) => { + console.info('[FormComponent] enableFormsUpdate result:' + data); + }); + } + + public async disableCard(formId: string) { + formManager.disableFormsUpdate([formId]) + .then((data) => { + console.info('[FormComponent] disableCard result:' + data); + }); + } + + public async changeCardVisible(formId: string, isVisible: boolean) { + if (isVisible) { + formManager.notifyVisibleForms([formId]) + .then((data) => { + console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible); + }); + } else { + formManager.notifyInvisibleForms([formId]) + .then((data) => { + console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible); + }); + } + } + + public async isFmsReady() { + formManager.isSystemReady() + .then((data) => { + console.info('[FormComponent] isFmsReady result:' + data); + }); + } + + public async getAllFormsInfo() { + formManager.getAllFormsInfo() + .then((data) => { + console.info('[FormComponent] getAllFormsInfo result:' + JSON.stringify(data)); + }); + } + + public async getFormsInfoByApp(bundle: string) { + formManager.getFormsInfo(bundle) + .then((data) => { + console.info('[FormComponent] getFormsInfoByApp result:' + JSON.stringify(data)); + }); + } + + public async getFormsInfoByModule(bundle: string, moduleName: string) { + formManager.getFormsInfo(bundle, moduleName) + .then((data) => { + console.info('[FormComponent] getFormsInfoByModule result:' + JSON.stringify(data)); + }); + } + + public async clearFormUserCache() { + abilityManager.clearUpApplicationData('com.ohos.myapplicationform') + .then((data) => { + console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data)); + }); + } + + public async clearFormProviderCache(bundle: string) { + abilityManager.clearUpApplicationData(bundle) + .then((data) => { + console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data)); + }); + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostnoperm/entry/src/main/ets/MainAbility/pages/index.ets b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostnoperm/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..e3b5aa05994955fe402d41ecb074a72a1d7fbf88 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostnoperm/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,354 @@ +/* + * 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 FormViewModel from './FormViewModel.ets'; +import router from '@system.router'; +import featureAbility from "@ohos.ability.featureAbility"; +import formManager from '@ohos.application.formHost' +import commonEvent from '@ohos.commonEvent'; + +@Entry +@Component +struct Index { + @State formId: number = 0; + @State bundle: string = "com.form.formsystemtestservicea.hmservice"; + @State ability: string = "com.form.formsystemtestservicea.hmservice.MainAbility"; + @State moduleName: string = "entry"; + @State name: string = "Form_Js001"; + @State width: number = 300; + @State height: number = 200; + @State allowUpate: boolean = true; + @State onAcquireResult: string = ""; + @State isShowing: boolean = true; + @State canCreateForm: boolean = false; + + private dimension: FormDimension = FormDimension.Dimension_1_2; + + private stateForm = "visible"; + private stateIds = []; + private requestForm = false; + private requestId = "-1"; + private releaseForm = false; + private releaseId = "-1"; + private deleteForm = false; + private deleteId = "-1"; + private temporary = false; + private mFormViewModel: FormViewModel; + private isVisible = false; + private mMargin = 15; + private BTN_BG_COLOR: string = '#0D9FFB'; + private castForm = false; + private tempFormId: number = 0; + + private formOnErrorEvent = "FMS_FormOnError_commonEvent"; + private formOnDeletedEvent = "FMS_FormOnDeleted_commonEvent"; + private formOnReleasedEvent = "FMS_FormOnReleased_commonEvent"; + private formOnRequestEvent = "FMS_FormOnRequest_commonEvent"; + private formOnStateEvent = "FMS_FormOnState_commonEvent"; + + private publishCallBack() { + console.debug("====>formOnErrorEvent Publish CallBack ====>"); + } + + private aboutToAppear() { + + const TAG = "[FormComponent.host]" + + this.mFormViewModel = FormViewModel.getInstance(); + + console.error('[FormComponent] getWant'); + featureAbility.getWant() + .then((want: any) => { + this.formId = parseInt(want.parameters.formId); + this.name = want.parameters.name; + this.bundle = want.parameters.bundle; + this.ability = want.parameters.ability; + if(want.parameters.moduleName) { + this.moduleName = want.parameters.moduleName; + } + if(want.parameters.temporary) { + this.temporary = want.parameters.temporary; + } + if(want.parameters.dimension) { + this.dimension = want.parameters.dimension; + } + if(want.parameters.castForm) { + this.castForm = want.parameters.castForm; + } + if(want.parameters.deleteForm) { + this.deleteForm = want.parameters.deleteForm; + } + if(want.parameters.deleteId) { + this.deleteId = want.parameters.deleteId; + } + if(want.parameters.releaseForm) { + this.releaseForm = want.parameters.releaseForm; + } + if(want.parameters.releaseId) { + this.releaseId = want.parameters.releaseId; + } + if(want.parameters.requestForm) { + this.requestForm = want.parameters.requestForm; + } + if(want.parameters.requestId) { + this.requestId = want.parameters.requestId; + } + if(want.parameters.stateForm) { + this.stateForm = want.parameters.stateForm; + } + if(want.parameters.stateIds) { + this.stateIds = want.parameters.stateIds; + } + + setTimeout(() => { + this.canCreateForm = want.parameters.isCreate ? true : false; + console.error('[FormComponent] getWant canCreateForm:'+ this.canCreateForm); + }, 10); + console.error('[FormComponent] getWant end'+ JSON.stringify(want)); + + if(!want.parameters.isCreate && this.deleteForm) { + console.log("formsystemhostnoperm deleteForm start"); + formManager.deleteForm(this.deleteId) + .then((data) => { + console.info('formsystemhostnoperm deleteForm result:' + data); + let commonEventPublishData = { + data: data.toString(), + parameters: { + "formId" : this.deleteId.toString() + } + }; + commonEvent.publish(this.formOnDeletedEvent, commonEventPublishData, this.publishCallBack); + }) + .catch((error) => { + console.info('formsystemhostnoperm deleteForm error:' + error); + let commonEventPublishData = { + data: error.code.toString(), + parameters: { + "formId" : this.deleteId.toString() + } + }; + commonEvent.publish(this.formOnDeletedEvent, commonEventPublishData, this.publishCallBack); + }); + + console.log("formsystemhostnoperm deleteForm end"); + } + + if(!want.parameters.isCreate && this.releaseForm) { + console.log("formsystemhost releaseForm start"); + formManager.releaseForm(this.releaseId) + .then((data) => { + console.info('formsystemhost releaseForm result:' + data); + let commonEventPublishData = { + data: data.toString(), + parameters: { + "formId" : this.releaseId.toString() + } + }; + commonEvent.publish(this.formOnReleasedEvent, commonEventPublishData, this.publishCallBack); + }) + .catch((error) => { + console.info('formsystemhost releaseForm error:' + error); + let commonEventPublishData = { + data: error.code.toString(), + parameters: { + "formId" : this.releaseId.toString() + } + }; + commonEvent.publish(this.formOnReleasedEvent, commonEventPublishData, this.publishCallBack); + }); + + console.log("formsystemhost releaseForm end"); + } + + if(!want.parameters.isCreate && this.requestForm) { + console.log("[FormComponent.host] requestForm start"); + formManager.requestForm(this.requestId) + .then((data) => { + console.info('[FormComponent] requestForm result:' + data); + let commonEventPublishData = { + data: data.toString(), + parameters: { + "formId" : this.requestId + } + }; + commonEvent.publish(this.formOnRequestEvent, commonEventPublishData, this.publishCallBack); + }) + .catch((error) => { + console.info('[FormComponent] requestForm error:' + error); + let commonEventPublishData = { + data: error.code.toString(), + parameters: { + "formId" : this.requestId + } + }; + commonEvent.publish(this.formOnRequestEvent, commonEventPublishData, this.publishCallBack); + }); + + console.log("[FormComponent.host] requestForm end"); + } + if(!want.parameters.isCreate && this.stateForm) { + if(this.stateForm == "visible") { + console.log("formsystemhost notifyVisibleForm start"); + formManager.notifyVisibleForms(this.stateIds) + .then((data) => { + console.info('formsystemhost notifyVisibleForm result:' + data); + let retData = "0"; + if(data == 0) { + retData = data.toString(); + } else { + retData = data.code.toString(); + } + let commonEventPublishData = { + data: retData, + parameters: { + "formId" : this.stateIds.toString() + } + }; + commonEvent.publish(this.formOnStateEvent, commonEventPublishData, this.publishCallBack); + }) + .catch((error) => { + console.info('formsystemhost notifyVisibleForm error:' + error); + let commonEventPublishData = { + data: error.code.toString(), + parameters: { + "formId" : this.stateIds.toString() + } + }; + commonEvent.publish(this.formOnStateEvent, commonEventPublishData, this.publishCallBack); + }); + console.log("formsystemhost notifyVisibleForm end"); + } else if(this.stateForm == "invisible") { + console.log("formsystemhost notifyInvisibleForm start"); + formManager.notifyInvisibleForms(this.stateIds) + .then((data) => { + console.info('formsystemhost notifyInvisibleForm result:' + data); + let commonEventPublishData = { + data: data.toString(), + parameters: { + "formId" : this.stateIds.toString() + } + }; + commonEvent.publish(this.formOnStateEvent, commonEventPublishData, this.publishCallBack); + }) + .catch((error) => { + console.info('formsystemhost notifyInvisibleForm error:' + error); + let commonEventPublishData = { + data: error.code.toString(), + parameters: { + "formId" : this.stateIds.toString() + } + }; + commonEvent.publish(this.formOnStateEvent, commonEventPublishData, this.publishCallBack); + }); + console.log("formsystemhost notifyInvisibleForm end"); + } else if(this.stateForm == "enable") { + console.log("formsystemhost enableFormsUpdate start"); + formManager.enableFormsUpdate(this.stateIds) + .then((data) => { + console.info('formsystemhost enableFormsUpdate result:' + data); + let commonEventPublishData = { + data: data.toString(), + parameters: { + "formId" : this.stateIds.toString() + } + }; + commonEvent.publish(this.formOnStateEvent, commonEventPublishData, this.publishCallBack); + }) + .catch((error) => { + console.info('formsystemhost enableFormsUpdate error:' + error); + let commonEventPublishData = { + data: error.code.toString(), + parameters: { + "formId" : this.stateIds.toString() + } + }; + commonEvent.publish(this.formOnStateEvent, commonEventPublishData, this.publishCallBack); + }); + console.log("formsystemhost enableFormsUpdate end"); + } else { + console.log("formsystemhost disableFormsUpdate start"); + formManager.disableFormsUpdate(this.stateIds) + .then((data) => { + console.info('formsystemhost disableFormsUpdate result:' + data); + let commonEventPublishData = { + data: data.toString(), + parameters: { + "formId" : this.stateIds.toString() + } + }; + commonEvent.publish(this.formOnStateEvent, commonEventPublishData, this.publishCallBack); + }) + .catch((error) => { + console.info('formsystemhost disableFormsUpdate error:' + error); + let commonEventPublishData = { + data: error.code.toString(), + parameters: { + "formId" : this.stateIds.toString() + } + }; + commonEvent.publish(this.formOnStateEvent, commonEventPublishData, this.publishCallBack); + }); + console.log("formsystemhost disableFormsUpdate end"); + } + } + + }) + .catch((error: any) => { + console.error('[FormComponent] Operation failed. Cause: ' + JSON.stringify(error)); + }) + + console.log(`[FormComponent.host] aboutToAppear end`); + } + + build() { + Column() { + Text('form component test begin') + Column() { + if (this.canCreateForm) { + 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) => { + this.formId = form.id; + console.log("[FormComponent.host] get form, form id:" + form.id); + }) + .onError((error) => { + console.log("[FormComponent.host] error code:" + error.errcode); + console.log("[FormComponent.host] error msg:" + error.msg); + this.onAcquireResult += error.errcode; + this.onAcquireResult += " "; + this.onAcquireResult += error.msg; + + let commonEventPublishData = { + data: error.msg + }; + commonEvent.publish(this.formOnErrorEvent, commonEventPublishData, this.publishCallBack); + }) + } + } + .backgroundColor(Color.White) + Text('form component test end') + } + .backgroundColor(Color.White) + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostnoperm/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostnoperm/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..66cc8e0f2ebb653c63c0a4a708e9f3705764abe3 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostnoperm/entry/src/main/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "formhostB" + }, + { + "name": "description_mainability", + "value": "ETS_Empty Ability" + } + ] +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostnoperm/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostnoperm/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostnoperm/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostnoperm/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostnoperm/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..6084de2e92d6f254a93a654b02701870bef66d31 Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostnoperm/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhosto/BUILD.gn b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhosto/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..2cb109dd4c7513203d2b00d55089e85b16af1d89 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhosto/BUILD.gn @@ -0,0 +1,32 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("FormSystemHostO") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":hjs_demo_js_assets", + ":hjs_demo_resources", + ] + ets2abc = true + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "FormSystemHostO" +} +ohos_js_assets("hjs_demo_js_assets") { + source_dir = "./entry/src/main/ets/MainAbility" +} +ohos_resources("hjs_demo_resources") { + sources = [ "./entry/src/main/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhosto/Test.json b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhosto/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..3ec911dfc7b3a17504cd4577be5bbabaf7f97e63 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhosto/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} diff --git a/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhosto/entry/src/main/config.json b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhosto/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..ce6b5e2194318dec80e6674ed341624323d4e643 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhosto/entry/src/main/config.json @@ -0,0 +1,124 @@ +{ + "app": { + "bundleName": "com.ohos.st.formsystemhosto", + "vendor": "ohos", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 7, + "releaseType": "Release", + "target": 7 + } + }, + "deviceConfig": {}, + "module": { + "package": "com.ohos.st.formsystemhosto", + "name": ".FormStHostAppO", + "mainAbility": ".MainAbility", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": false + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "visible": true, + "name": ".MainAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:description_mainability", + "label": "$string:entry_MainAbility", + "type": "page", + "launchType": "standard" + } + ], + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ], + "defPermissions": [ + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormDelete_commonEvent" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormOnAcquired_commonEvent" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormOnError_commonEvent" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormCast_commonEvent" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_SendCastForm_commonEvent" + } + ], + "reqPermissions": [ + { + "name": "FMS_FormOnAcquired_commonEvent" + }, + { + "name": "FMS_FormDelete_commonEvent" + }, + { + "name": "FMS_FormOnError_commonEvent" + }, + { + "name": "FMS_FormCast_commonEvent" + }, + { + "name": "FMS_SendCastForm_commonEvent" + }, + { + "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + }, + { + "name": "ohos.permission.INSTALL_BUNDLE" + }, + { + "name": "ohos.permission.LISTEN_BUNDLE_CHANGE" + }, + { + "name": "ohos.permission.REQUIRE_FORM" + } + ] + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhosto/entry/src/main/ets/MainAbility/app.ets b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhosto/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..f49f9bd10ebd29ce7eb0445bee5a5928d9212a8a --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhosto/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,23 @@ +/* + * 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. + */ + +export default { + onCreate() { + console.info('[FormComponent.host] Application onCreate') + }, + onDestroy() { + console.info('[FormComponent.host] Application onDestroy') + }, +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhosto/entry/src/main/ets/MainAbility/pages/index.ets b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhosto/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..93da5a98a87834e505d990e13ca58130438a0ae4 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhosto/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,438 @@ +/* + * 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 featureAbility from "@ohos.ability.featureAbility"; +import formManager from '@ohos.application.formHost'; +import commonEvent from '@ohos.commonEvent'; +@Entry +@Component +struct Index { + @State bundle: string = "com.form.formsystemtestservicea.hmservice"; + @State ability: string = "com.form.formsystemtestservicea.hmservice.FormAbility"; + @State moduleName: string = "entry"; + @State name: string = "Form_Js001"; + @State width: number = 300; + @State height: number = 200; + @State allowUpate: boolean = true; + @State onAcquireResult: string = ""; + @State isShowing: boolean = true; + @State optType: number = 0; + private dimension: FormDimension = FormDimension.Dimension_1_2; + private isTemporary = false; + private isVisible = false; + private mMargin = 15; + private BTN_BG_COLOR: string = '#0D9FFB'; + + private normal = 0; + private temporary = 0; + private normaldel = 0; + private temporarydel = 0; + private normalFormIds = []; + private tempFormIds = []; + + private deleteIds = []; + private delCount = 0; + + private normalFormCounts = []; + private tempFormCounts = []; + + private castFormId = "-1"; + + private formOnAcquiredEvent = "FMS_FormOnAcquired_commonEvent"; + private formOnErrorEvent = "FMS_FormOnError_commonEvent"; + private formCastEvent = "FMS_FormCast_commonEvent"; + + private subscriberDel; + private subscriberFormDeleteEvent = { + events: ["FMS_FormDelete_commonEvent"], + }; + + private subscriberSendCastForm; + private subscriberSendCastFormEvent = { + events: ["FMS_SendCastForm_commonEvent"], + }; + + private publishOnErrorCallBack() { + console.debug("====> [FormComponent] formsystemhosto formOnErrorEvent Publish CallBack ====>"); + } + private publishOnAcquiredCallBack() { + console.debug("====> [FormComponent] formsystemhosto formOnAcquiredEvent Publish CallBack ====>"); + } + private publishDeleteCallBack() { + console.debug("====> [FormComponent] formsystemhosto publishDeleteCallBack Publish CallBack ====>"); + } + private publishCastCallBack() { + console.debug("====>formCastEvent Publish CallBack ====>"); + } + private startAbility(bundleName, abilityName, sendMsg) { + featureAbility.startAbility({ + want: { + bundleName: bundleName, + abilityName: abilityName, + parameters: { + "formId": "0", + "name": "Form_Js001", + "bundle": "com.form.formsystemtestservicea.hmservice", + "ability": "com.form.formsystemtestservicea.hmservice.FormAbility", + "moduleName": "entry", + "temporary": false, + "sendCastForm": true, + "sendCastFormMsg": sendMsg, + "isCreate": false + } + } + }).then((res: any) => { + console.info(`[FormComponent] formsystemhosto featureAbility.startAbility res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.info(`[FormComponent] formsystemhosto featureAbility.startAbility error: ${JSON.stringify(err)}`); + }); + } + private publishOnSendCastForm(err, data) { + console.info("!!!====>[FormComponent] formsystemhosto OnSendCastForm start:====>" + JSON.stringify(data)); + if (data.bundleName && data.bundleName != "com.ohos.st.formsystemhosto") { + return; + } + let formId = data.parameters.castFormId; + setTimeout(function () { + console.info("[FormComponent.host] castTempForm start, formId: " + formId); + formManager.castTempForm(formId) + .then((data) => { + console.info('[FormComponent] castTempForm result:' + data); + this.startAbility("com.ohos.st.formsystemhostc", "com.ohos.st.formsystemhostc.MainAbility", data.toString()); + }) + .catch((error) => { + console.info('[FormComponent] castTempForm error:' + JSON.stringify(error)); + this.startAbility("com.ohos.st.formsystemhostc", "com.ohos.st.formsystemhostc.MainAbility", error.code.toString()); + }); + console.info("[FormComponent.host] castTempForm end"); + }, 5000); + console.info("!!!====>[FormComponent] formsystemhosto OnSendCastForm end"); + } + + private deleteCallBack(err, data) { + console.info("!!!====>[FormComponent] formsystemhosto deleteCallBack start:====>" + JSON.stringify(data)); + const delFormIds = data.parameters.formIds; + console.info(`[FormComponent] data size ${delFormIds.length}`); + + console.info(`[FormComponent] data.subscriber ${JSON.stringify(this.subscriberDel)}`); + commonEvent.unsubscribe(this.subscriberDel, () => { + console.info("====> [FormComponent] formsystemhosto optType unSubscribeDeleteCallback CallBack====>"); + }); + commonEvent.unsubscribe(this.subscriberSendCastForm, () => { + console.info("====> [FormComponent] formsystemhosto optType unSubscribeCastFormCallback CallBack====>"); + }); + console.info(`[FormComponent] data.bundleName ${JSON.stringify(data.bundleName)}`); + console.info(`[FormComponent] tof ${"com.ohos.st.formsystemhosto" != data.bundleName}`); + if ("com.ohos.st.formsystemhosto" != data.bundleName) { + return; + } + delFormIds.forEach(async (formId, index) => { + console.info(`[FormComponent] formsystemhosto deleteForm ${index}`); + try { + const res = await formManager.deleteForm(formId); + console.info(`[FormComponent] formsystemhosto deleteForm ${index} ${formId} result: ${JSON.stringify(res)}`); + } catch (error) { + console.info(`[FormComponent] formsystemhosto deleteForm ${index} ${formId} error: ${JSON.stringify(error)}`); + } + }); + console.info("!!!====> [FormComponent] formsystemhosto optType deleteCallBack end ====>"); + } + + private unSubscribeDeleteCallback() { + console.debug("====> [FormComponent] formsystemhosto optType unSubscribeDeleteCallback CallBack====>"); + } + + private unSubscribeCastFormCallback() { + console.debug("====> [FormComponent] formsystemhosto optType unSubscribeCastFormCallback CallBack====>"); + } + + private aboutToAppear() { + const TAG = "[FormComponent.hosto]"; + + commonEvent.createSubscriber(this.subscriberFormDeleteEvent).then(async (data) => { + console.info("====>[FormComponent] formsystemhosto Subscriber FormDelete data:====>", JSON.stringify(data)); + this.subscriberDel = data; + commonEvent.subscribe(this.subscriberDel, (err, data) => { + if ("com.ohos.st.formsystemhosto" != data.bundleName) { + return; + } else { + console.info("!!!====>[FormComponent.hosto] formsystemhosto deleteCallBack start:====>" + JSON.stringify(data)); + const delFormIds = data.parameters.formIds; + console.info(`[FormComponent] data size ${delFormIds.length}`); + commonEvent.unsubscribe(this.subscriberDel, () => { + console.info("====> [FormComponent] formsystemhosto optType unSubscribeDeleteCallback CallBack====>"); + }); + commonEvent.unsubscribe(this.subscriberSendCastForm, () => { + console.info("====> [FormComponent] formsystemhosto optType unSubscribeCastFormCallback CallBack====>"); + }); + let delCounter = 0; + delFormIds.forEach((formId) => { + formManager.deleteForm(formId, (error, data) => { + console.info(`[FormComponent] formsystemhosto deleteForm ${++delCounter} ${formId} data: ${JSON.stringify(data)} err: ${JSON.stringify(error)}`); + }); + }); + } + }); + }); + + commonEvent.createSubscriber(this.subscriberSendCastFormEvent).then(async (data) => { + console.info("====>[FormComponent] formsystemhosto Subscriber SendCastForm data:====>", JSON.stringify(data)); + this.subscriberSendCastForm = data; + await commonEvent.subscribe(this.subscriberSendCastForm, this.publishOnSendCastForm); + }); + + featureAbility.getWant() + .then((want: any) => { + console.info(" [FormComponent] formsystemhosto getWant:" + JSON.stringify(want)); + + this.name = want.parameters.name; + this.bundle = want.parameters.bundle; + this.ability = want.parameters.ability; + if (want.parameters.moduleName) { + this.moduleName = want.parameters.moduleName; + } + + if (want.parameters.dimension) { + this.dimension = want.parameters.dimension; + } + + if (want.parameters.normal) { + this.normal = want.parameters.normal; + } + + if (want.parameters.temporary) { + this.temporary = want.parameters.temporary; + } + if (want.parameters.normaldel) { + this.normaldel = want.parameters.normaldel; + } + + if (want.parameters.temporarydel) { + this.temporarydel = want.parameters.temporarydel; + } + + if (want.parameters.deleteIds) { + this.deleteIds = want.parameters.deleteIds; + } + if (want.parameters.castFormId) { + this.castFormId = want.parameters.castFormId; + } + + this.makeCount(); + + setTimeout(() => { + this.optType = want.parameters.optType; + console.info(' [FormComponent] formsystemhosto getWant optType:' + this.optType); + }, 10); + + if (this.castFormId != "-1" && want.parameters.optType == 3) { + console.info("[FormComponent.host] castTempForm start"); + commonEvent.unsubscribe(this.subscriberDel, () => { + console.info("====> [FormComponent] formsystemhosto optType unSubscribeDeleteCallback CallBack====>"); + }); + commonEvent.unsubscribe(this.subscriberSendCastForm, () => { + console.info("====> [FormComponent] formsystemhosto optType unSubscribeCastFormCallback CallBack====>"); + }); + + formManager.castTempForm(this.castFormId) + .then((data) => { + console.info('[FormComponent] castTempForm result:' + data); + let commonEventPublishData = { + data: data || `0`, + bundleName: "com.ohos.st.formsystemhosto", + parameters: { + formId: this.castFormId.toString() + } + }; + commonEvent.publish(this.formCastEvent, commonEventPublishData, this.publishCastCallBack); + }) + .catch((error) => { + console.info('[FormComponent] castTempForm error:' + JSON.stringify(error)); + let commonEventPublishData = { + data: error.code.toString(), + bundleName: "com.ohos.st.formsystemhosto", + parameters: { + errMsg: error.message, + formId: this.castFormId.toString() + } + }; + commonEvent.publish(this.formCastEvent, commonEventPublishData, this.publishCastCallBack); + }); + console.info("[FormComponent.host] castTempForm end"); + } + + if (want.parameters.optType == 2 && this.deleteIds.length > 0) { + for (let iIndex = 0; iIndex < this.deleteIds.length; ++iIndex) { + console.info("[FormComponent] formsystemhosto deleteForm start"); + formManager.deleteForm(this.deleteIds[iIndex]) + .then((data) => { + console.info('[FormComponent] formsystemhosto deleteForm result:' + data); + this.delCount++; + + if (this.delCount == this.deleteIds.length) { + let commonEventPublishData = { + data: data.toString(), + bundleName: "com.ohos.st.formsystemhosto", + parameters: { + "formIds": this.deleteIds + } + }; + commonEvent.publish(this.formOnErrorEvent, commonEventPublishData, this.publishDeleteCallBack); + } + }) + .catch((error) => { + console.info(' [FormComponent] formsystemhosto deleteForm error:' + error); + let commonEventPublishData = { + data: error.code.toString(), + bundleName: "com.ohos.st.formsystemhosto", + parameters: { + "formIds": [this.deleteIds[iIndex]] + } + }; + commonEvent.publish(this.formOnErrorEvent, commonEventPublishData, this.publishOnErrorCallBack); + }); + console.info("[FormComponent] formsystemhosto deleteForm end"); + } + } + }) + .catch((error: any) => { + console.error(' [FormComponent] formsystemhosto Operation failed. Cause: ' + JSON.stringify(error)); + }) + console.info(`[FormComponent.host] aboutToAppear end`); + } + + private makeCount() { + console.info(' [FormComponent] formsystemhosto makeCount start.'); + for (let nNormal = 0; nNormal < this.normal; nNormal++) { + this.normalFormCounts.push(nNormal); + } + console.info(' [FormComponent] formsystemhosto this.normalFormCounts.length:' + this.normalFormCounts.length); + + for (let nTemp = 0; nTemp < this.temporary; nTemp++) { + this.tempFormCounts.push(nTemp); + } + console.info(' [FormComponent] formsystemhosto this.tempFormCounts.length:' + this.tempFormCounts.length); + } + + build() { + Scroll(new Scroller()) { + Column() { + if (this.optType == 1) { + Text(' [FormComponent] formsystemhosto normal form component test begin') + Grid() { + ForEach(this.normalFormCounts, (item) => { + GridItem() { + FormComponent({ + id: 0, + name: this.name, + bundle: this.bundle, + ability: this.ability, + module: this.moduleName, + dimension: this.dimension, + temporary: false + }) + .allowUpdate(this.allowUpate) + .visibility(this.isShowing ? Visibility.Visible : Visibility.Hidden) + .onAcquired((form) => { + console.info(" [FormComponent] formsystemhosto get normal form, form id:" + form.id); + + this.normalFormIds.push(form.id.toString()); + if (this.normalFormIds.length == this.normal - this.normaldel) { + let commonEventPublishData = { + data: "normalForm", + bundleName: "com.ohos.st.formsystemhosto", + parameters: { + "formIds": this.normalFormIds + } + }; + commonEvent.publish(this.formOnAcquiredEvent, commonEventPublishData, this.publishOnAcquiredCallBack); + } + }) + .onError((error) => { + console.info(" [FormComponent] formsystemhosto normal form error code:" + error.errcode); + console.info(" [FormComponent] formsystemhosto normal form error msg:" + error.msg); + let commonEventPublishData = { + data: error.msg, + bundleName: "com.ohos.st.formsystemhosto" + }; + commonEvent.publish(this.formOnErrorEvent, commonEventPublishData, this.publishOnErrorCallBack); + }) + .size({ width: 40, height: 40 }) + } + }, (item) => JSON.stringify(item)) + } + .columnsTemplate('1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr ') + .columnsGap(2) + .rowsGap(2) + .width('100%') + Text(' [FormComponent] formsystemhosto normal form component test end') + + Text(' [FormComponent] formsystemhosto temp form component test start') + Grid() { + ForEach(this.tempFormCounts, (item) => { + GridItem() { + FormComponent({ + id: 0, + name: this.name, + bundle: this.bundle, + ability: this.ability, + module: this.moduleName, + dimension: this.dimension, + temporary: true + }) + .allowUpdate(this.allowUpate) + .visibility(this.isShowing ? Visibility.Visible : Visibility.Hidden) + .onAcquired((form) => { + console.info(" [FormComponent] formsystemhosto get temp form, form id:" + form.id); + this.tempFormIds.push(form.id.toString()); + if (this.tempFormIds.length == this.temporary - this.temporarydel) { + let commonEventPublishData = { + data: "tempForm", + bundleName: "com.ohos.st.formsystemhosto", + parameters: { + "formIds": this.tempFormIds + } + }; + commonEvent.publish(this.formOnAcquiredEvent, commonEventPublishData, this.publishOnAcquiredCallBack); + } + }) + .onError((error) => { + console.info(" [FormComponent] formsystemhosto temp form error code:" + error.errcode); + console.info(" [FormComponent] formsystemhosto temp form error msg:" + error.msg); + let commonEventPublishData = { + data: error.msg, + bundleName: "com.ohos.st.formsystemhosto" + }; + commonEvent.publish(this.formOnErrorEvent, commonEventPublishData, this.publishOnErrorCallBack); + }) + .size({ width: 40, height: 40 }) + } + }, (item) => JSON.stringify(item)) + } + .columnsTemplate('1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr ') + .columnsGap(2) + .rowsGap(2) + .width('100%') + + Text(' [FormComponent] formsystemhosto temp form component test end') + } + } + .backgroundColor(Color.White) + } + .scrollable(ScrollDirection.Vertical) + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhosto/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhosto/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..e9202859eafd7e293c7a071570cbcef3b336a4c5 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhosto/entry/src/main/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "formhostO" + }, + { + "name": "description_mainability", + "value": "ETS_Empty Ability" + } + ] +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhosto/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhosto/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhosto/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhosto/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhosto/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..6084de2e92d6f254a93a654b02701870bef66d31 Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhosto/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostp/BUILD.gn b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostp/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..f19869313ea49f1571f35bbfa46654eb752e86be --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostp/BUILD.gn @@ -0,0 +1,32 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("FormSystemHostP") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":hjs_demo_js_assets", + ":hjs_demo_resources", + ] + ets2abc = true + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "FormSystemHostP" +} +ohos_js_assets("hjs_demo_js_assets") { + source_dir = "./entry/src/main/ets/MainAbility" +} +ohos_resources("hjs_demo_resources") { + sources = [ "./entry/src/main/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostp/Test.json b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostp/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..3ec911dfc7b3a17504cd4577be5bbabaf7f97e63 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostp/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} diff --git a/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostp/entry/src/main/config.json b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostp/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..cc425ebdd7e6b6feaf12a61ed170dbcf7e4ca3b0 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostp/entry/src/main/config.json @@ -0,0 +1,124 @@ +{ + "app": { + "bundleName": "com.ohos.st.formsystemhostp", + "vendor": "ohos", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 7, + "releaseType": "Release", + "target": 7 + } + }, + "deviceConfig": {}, + "module": { + "package": "com.ohos.st.formsystemhostp", + "name": ".FormStHostAppP", + "mainAbility": ".MainAbility", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": false + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "visible": true, + "name": ".MainAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:description_mainability", + "label": "$string:entry_MainAbility", + "type": "page", + "launchType": "standard" + } + ], + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ], + "defPermissions": [ + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormDelete_commonEvent" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormOnAcquired_commonEvent" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormOnError_commonEvent" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormCast_commonEvent" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_SendCastForm_commonEvent" + } + ], + "reqPermissions": [ + { + "name": "FMS_FormOnAcquired_commonEvent" + }, + { + "name": "FMS_FormDelete_commonEvent" + }, + { + "name": "FMS_FormOnError_commonEvent" + }, + { + "name": "FMS_FormCast_commonEvent" + }, + { + "name": "FMS_SendCastForm_commonEvent" + }, + { + "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + }, + { + "name": "ohos.permission.INSTALL_BUNDLE" + }, + { + "name": "ohos.permission.LISTEN_BUNDLE_CHANGE" + }, + { + "name": "ohos.permission.REQUIRE_FORM" + } + ] + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostp/entry/src/main/ets/MainAbility/app.ets b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostp/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..f49f9bd10ebd29ce7eb0445bee5a5928d9212a8a --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostp/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,23 @@ +/* + * 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. + */ + +export default { + onCreate() { + console.info('[FormComponent.host] Application onCreate') + }, + onDestroy() { + console.info('[FormComponent.host] Application onDestroy') + }, +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostp/entry/src/main/ets/MainAbility/pages/index.ets b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostp/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..dfb47a149bf937c43ab72cad2745efe36d6bdd52 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostp/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,430 @@ +/* + * 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 featureAbility from "@ohos.ability.featureAbility"; +import formManager from '@ohos.application.formHost'; +import commonEvent from '@ohos.commonEvent'; +@Entry +@Component +struct Index { + @State bundle: string = "com.form.formsystemtestservicea.hmservice"; + @State ability: string = "com.form.formsystemtestservicea.hmservice.MainAbility"; + @State moduleName: string = "entry"; + @State name: string = "Form_Js001"; + @State width: number = 300; + @State height: number = 200; + @State allowUpate: boolean = true; + @State onAcquireResult: string = ""; + @State isShowing: boolean = true; + @State optType: number = 0; + private dimension: FormDimension = FormDimension.Dimension_1_2; + private isTemporary = false; + private isVisible = false; + private mMargin = 15; + private BTN_BG_COLOR: string = '#0D9FFB'; + + private normal = 0; + private temporary = 0; + private normaldel = 0; + private temporarydel = 0; + private normalFormIds = []; + private tempFormIds = []; + + private deleteIds = []; + private delCount = 0; + + private normalFormCounts = []; + private tempFormCounts = []; + + private castFormId = "-1"; + + private formOnAcquiredEvent = "FMS_FormOnAcquired_commonEvent"; + private formOnErrorEvent = "FMS_FormOnError_commonEvent"; + private formCastEvent = "FMS_FormCast_commonEvent"; + + private subscriberDel; + private subscriberFormDeleteEvent = { + events: ["FMS_FormDelete_commonEvent"], + }; + + private subscriberSendCastForm; + private subscriberSendCastFormEvent = { + events: ["FMS_SendCastForm_commonEvent"], + }; + + private publishOnErrorCallBack() { + console.debug("====> [FormComponent] formsystemhostp formOnErrorEvent Publish CallBack ====>"); + } + private publishOnAcquiredCallBack() { + console.debug("====> [FormComponent] formsystemhostp formOnAcquiredEvent Publish CallBack ====>"); + } + private publishDeleteCallBack() { + console.debug("====> [FormComponent] formsystemhostp publishDeleteCallBack Publish CallBack ====>"); + } + private publishCastCallBack() { + console.debug("====>formCastEvent Publish CallBack ====>"); + } + private startAbility(bundleName, abilityName, sendMsg) { + featureAbility.startAbility({ + want: { + bundleName: bundleName, + abilityName: abilityName, + parameters: { + "formId": "0", + "name": "Form_Js001", + "bundle": "com.form.formsystemtestservicea.hmservice", + "ability": "com.form.formsystemtestservicea.hmservice.MainAbility", + "moduleName": "entry", + "temporary": false, + "sendCastForm": true, + "sendCastFormMsg": sendMsg, + "isCreate": false + } + } + }).then((res: any) => { + console.info(`[FormComponent] formsystemhostp featureAbility.startAbility res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.info(`[FormComponent] formsystemhostp featureAbility.startAbility error: ${JSON.stringify(err)}`); + }); + } + private publishOnSendCastForm(err, data) { + console.info("!!!====>[FormComponent] formsystemhostp OnSendCastForm start:====>" + JSON.stringify(data)); + if (data.bundleName && data.bundleName != "com.ohos.st.formsystemhostp") { + return; + } + let formId = data.parameters.castFormId; + setTimeout(function () { + console.info("[FormComponent.host] castTempForm start, formId: " + formId); + formManager.castTempForm(formId) + .then((data) => { + console.info('[FormComponent] castTempForm result:' + data); + this.startAbility("com.ohos.st.formsystemhostc", "com.ohos.st.formsystemhostc.MainAbility", data.toString()); + }) + .catch((error) => { + console.info('[FormComponent] castTempForm error:' + JSON.stringify(error)); + this.startAbility("com.ohos.st.formsystemhostc", "com.ohos.st.formsystemhostc.MainAbility", error.code.toString()); + }); + console.info("[FormComponent.host] castTempForm end"); + }, 5000); + console.info("!!!====>[FormComponent] formsystemhostp OnSendCastForm end"); + } + + private deleteCallBack(err, data) { + console.info("!!!====>[FormComponent] formsystemhostp deleteCallBack start:====>" + JSON.stringify(data)); + const delFormIds = data.parameters.formIds; + console.info(`[FormComponent] data size ${delFormIds.length}`); + + console.info(`[FormComponent] data.subscriber ${JSON.stringify(this.subscriberDel)}`); + commonEvent.unsubscribe(this.subscriberDel, () => { + console.info("====> [FormComponent] formsystemhostp optType unSubscribeDeleteCallback CallBack====>"); + }); + commonEvent.unsubscribe(this.subscriberSendCastForm, () => { + console.info("====> [FormComponent] formsystemhostp optType unSubscribeCastFormCallback CallBack====>"); + }); + console.info(`[FormComponent] data.bundleName ${JSON.stringify(data.bundleName)}`); + console.info(`[FormComponent] tof ${"com.ohos.st.formsystemhostp" != data.bundleName}`); + if ("com.ohos.st.formsystemhostp" != data.bundleName) { + return; + } + delFormIds.forEach(async (formId, index) => { + console.info(`[FormComponent] formsystemhostp deleteForm ${index}`); + try { + const res = await formManager.deleteForm(formId); + console.info(`[FormComponent] formsystemhostp deleteForm ${index} ${formId} result: ${JSON.stringify(res)}`); + } catch (error) { + console.info(`[FormComponent] formsystemhostp deleteForm ${index} ${formId} error: ${JSON.stringify(error)}`); + } + }); + console.info("!!!====> [FormComponent] formsystemhostp optType deleteCallBack end ====>"); + } + + private unSubscribeDeleteCallback() { + console.debug("====> [FormComponent] formsystemhostp optType unSubscribeDeleteCallback CallBack====>"); + } + + private unSubscribeCastFormCallback() { + console.debug("====> [FormComponent] formsystemhostp optType unSubscribeCastFormCallback CallBack====>"); + } + + private aboutToAppear() { + const TAG = "[FormComponent.hostp]"; + + commonEvent.createSubscriber(this.subscriberFormDeleteEvent).then(async (data) => { + console.info("====>[FormComponent] formsystemhostp Subscriber FormDelete data:====>", JSON.stringify(data)); + this.subscriberDel = data; + commonEvent.subscribe(this.subscriberDel, (err, data) => { + if ("com.ohos.st.formsystemhostp" != data.bundleName) { + return; + } else { + console.info("!!!====>[FormComponent.hostp] formsystemhostp deleteCallBack start:====>" + JSON.stringify(data)); + const delFormIds = data.parameters.formIds; + console.info(`[FormComponent] data size ${delFormIds.length}`); + commonEvent.unsubscribe(this.subscriberDel, () => { + console.info("====> [FormComponent] formsystemhostp optType unSubscribeDeleteCallback CallBack====>"); + }); + commonEvent.unsubscribe(this.subscriberSendCastForm, () => { + console.info("====> [FormComponent] formsystemhostp optType unSubscribeCastFormCallback CallBack====>"); + }); + let delCounter = 0; + delFormIds.forEach((formId) => { + formManager.deleteForm(formId, (error, data) => { + console.info(`[FormComponent] formsystemhostp deleteForm ${++delCounter} ${formId} data: ${JSON.stringify(data)} err: ${JSON.stringify(error)}`); + }); + }); + } + }); + }); + + commonEvent.createSubscriber(this.subscriberSendCastFormEvent).then(async (data) => { + console.info("====>[FormComponent] formsystemhostp Subscriber SendCastForm data:====>", JSON.stringify(data)); + this.subscriberSendCastForm = data; + await commonEvent.subscribe(this.subscriberSendCastForm, this.publishOnSendCastForm); + }); + + featureAbility.getWant() + .then((want: any) => { + console.info(" [FormComponent] formsystemhostp getWant:" + JSON.stringify(want)); + + this.name = want.parameters.name; + this.bundle = want.parameters.bundle; + this.ability = want.parameters.ability; + if (want.parameters.moduleName) { + this.moduleName = want.parameters.moduleName; + } + + if (want.parameters.dimension) { + this.dimension = want.parameters.dimension; + } + + if (want.parameters.normal) { + this.normal = want.parameters.normal; + } + + if (want.parameters.temporary) { + this.temporary = want.parameters.temporary; + } + if (want.parameters.normaldel) { + this.normaldel = want.parameters.normaldel; + } + + if (want.parameters.temporarydel) { + this.temporarydel = want.parameters.temporarydel; + } + + if (want.parameters.deleteIds) { + this.deleteIds = want.parameters.deleteIds; + } + if (want.parameters.castFormId) { + this.castFormId = want.parameters.castFormId; + } + + this.makeCount(); + + setTimeout(() => { + this.optType = want.parameters.optType; + console.info(' [FormComponent] formsystemhostp getWant optType:' + this.optType); + }, 10); + + if (this.castFormId != "-1" && want.parameters.optType == 3) { + console.info("[FormComponent.host] castTempForm start"); + formManager.castTempForm(this.castFormId) + .then((data) => { + console.info('[FormComponent] castTempForm result:' + data); + let commonEventPublishData = { + data: data.toString(), + bundleName: "com.ohos.st.formsystemhostp", + parameters: { + "formId": this.castFormId.toString() + } + }; + commonEvent.publish(this.formCastEvent, commonEventPublishData, this.publishCastCallBack); + }) + .catch((error) => { + console.info('[FormComponent] castTempForm error:' + error.code); + let commonEventPublishData = { + data: error.code.toString(), + bundleName: "com.ohos.st.formsystemhostp", + parameters: { + "formId": this.castFormId.toString() + } + }; + commonEvent.publish(this.formCastEvent, commonEventPublishData, this.publishCastCallBack); + }); + console.info("[FormComponent.host] castTempForm end"); + } + + if (want.parameters.optType == 2 && this.deleteIds.length > 0) { + for (let iIndex = 0; iIndex < this.deleteIds.length; ++iIndex) { + console.info("[FormComponent] formsystemhostp deleteForm start"); + formManager.deleteForm(this.deleteIds[iIndex]) + .then((data) => { + console.info('[FormComponent] formsystemhostp deleteForm result:' + data); + this.delCount++; + + if (this.delCount == this.deleteIds.length) { + let commonEventPublishData = { + data: data.toString(), + bundleName: "com.ohos.st.formsystemhostp", + parameters: { + "formIds": this.deleteIds + } + }; + commonEvent.publish(this.formOnErrorEvent, commonEventPublishData, this.publishDeleteCallBack); + } + }) + .catch((error) => { + console.info(' [FormComponent] formsystemhostp deleteForm error:' + error); + let commonEventPublishData = { + data: error.code.toString(), + bundleName: "com.ohos.st.formsystemhostp", + parameters: { + "formIds": [this.deleteIds[iIndex]] + } + }; + commonEvent.publish(this.formOnErrorEvent, commonEventPublishData, this.publishOnErrorCallBack); + }); + console.info("[FormComponent] formsystemhostp deleteForm end"); + } + } + }) + .catch((error: any) => { + console.error(' [FormComponent] formsystemhostp Operation failed. Cause: ' + JSON.stringify(error)); + }) + console.info(`[FormComponent.host] aboutToAppear end`); + } + + private makeCount() { + console.info(' [FormComponent] formsystemhostp makeCount start.'); + for (let nNormal = 0; nNormal < this.normal; nNormal++) { + this.normalFormCounts.push(nNormal); + } + console.info(' [FormComponent] formsystemhostp this.normalFormCounts.length:' + this.normalFormCounts.length); + + for (let nTemp = 0; nTemp < this.temporary; nTemp++) { + this.tempFormCounts.push(nTemp); + } + console.info(' [FormComponent] formsystemhostp this.tempFormCounts.length:' + this.tempFormCounts.length); + } + + build() { + Scroll(new Scroller()) { + Column() { + if (this.optType == 1) { + Text(' [FormComponent] formsystemhostp normal form component test begin') + Grid() { + ForEach(this.normalFormCounts, (item) => { + GridItem() { + FormComponent({ + id: 0, + name: this.name, + bundle: this.bundle, + ability: this.ability, + module: this.moduleName, + dimension: this.dimension, + temporary: false + }) + .allowUpdate(this.allowUpate) + .visibility(this.isShowing ? Visibility.Visible : Visibility.Hidden) + .onAcquired((form) => { + console.info(" [FormComponent] formsystemhostp get normal form, form id:" + form.id); + + this.normalFormIds.push(form.id.toString()); + if (this.normalFormIds.length == this.normal - this.normaldel) { + let commonEventPublishData = { + data: "normalForm", + bundleName: "com.ohos.st.formsystemhostp", + parameters: { + "formIds": this.normalFormIds + } + }; + commonEvent.publish(this.formOnAcquiredEvent, commonEventPublishData, this.publishOnAcquiredCallBack); + } + }) + .onError((error) => { + console.info(" [FormComponent] formsystemhostp normal form error code:" + error.errcode); + console.info(" [FormComponent] formsystemhostp normal form error msg:" + error.msg); + let commonEventPublishData = { + data: error.msg, + bundleName: "com.ohos.st.formsystemhostp" + }; + commonEvent.publish(this.formOnErrorEvent, commonEventPublishData, this.publishOnErrorCallBack); + }) + .size({ width: 40, height: 40 }) + } + }, (item) => JSON.stringify(item)) + } + .columnsTemplate('1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr ') + .columnsGap(2) + .rowsGap(2) + .width('100%') + Text(' [FormComponent] formsystemhostp normal form component test end') + + Text(' [FormComponent] formsystemhostp temp form component test start') + Grid() { + ForEach(this.tempFormCounts, (item) => { + GridItem() { + FormComponent({ + id: 0, + name: this.name, + bundle: this.bundle, + ability: this.ability, + module: this.moduleName, + dimension: this.dimension, + temporary: true + }) + .allowUpdate(this.allowUpate) + .visibility(this.isShowing ? Visibility.Visible : Visibility.Hidden) + .onAcquired((form) => { + console.info(" [FormComponent] formsystemhostp get temp form, form id:" + form.id); + this.tempFormIds.push(form.id.toString()); + if (this.tempFormIds.length == this.temporary - this.temporarydel) { + let commonEventPublishData = { + data: "tempForm", + bundleName: "com.ohos.st.formsystemhostp", + parameters: { + "formIds": this.tempFormIds + } + }; + commonEvent.publish(this.formOnAcquiredEvent, commonEventPublishData, this.publishOnAcquiredCallBack); + } + }) + .onError((error) => { + console.info(" [FormComponent] formsystemhostp temp form error code:" + error.errcode); + console.info(" [FormComponent] formsystemhostp temp form error msg:" + error.msg); + let commonEventPublishData = { + data: error.msg, + bundleName: "com.ohos.st.formsystemhostp" + }; + commonEvent.publish(this.formOnErrorEvent, commonEventPublishData, this.publishOnErrorCallBack); + }) + .size({ width: 40, height: 40 }) + } + }, (item) => JSON.stringify(item)) + } + .columnsTemplate('1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr ') + .columnsGap(2) + .rowsGap(2) + .width('100%') + + Text(' [FormComponent] formsystemhostp temp form component test end') + } + } + .backgroundColor(Color.White) + } + .scrollable(ScrollDirection.Vertical) + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostp/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostp/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..e1cf22f277e3bd0a925cda8f7e3522de240c1f26 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostp/entry/src/main/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "formhostP" + }, + { + "name": "description_mainability", + "value": "ETS_Empty Ability" + } + ] +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostp/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostp/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostp/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostp/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostp/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..6084de2e92d6f254a93a654b02701870bef66d31 Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formhostst_ets/formsystemhostp/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationA/BUILD.gn b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationA/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..9c8cb85d5036f203487c03c32261cb6fa7e6e3e2 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationA/BUILD.gn @@ -0,0 +1,44 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("FormSupplyAppA") { + hap_profile = "entry/src/main/config.json" + deps = [ + ":FormOfFaEts_form_js_assets", + ":FormOfFaEts_js_assets", + ":FormOfFaEts_resources", + ] + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "FormSupplyAppA" + part_name = "prebuilt_hap" + subsystem_name = "applications" +} + +ohos_js_assets("FormOfFaEts_js_assets") { + hap_profile = "entry/src/main/config.json" + ets2abc = true + source_dir = "entry/src/main/ets" +} + +ohos_js_assets("FormOfFaEts_form_js_assets") { + hap_profile = "entry/src/main/config.json" + js2abc = true + source_dir = "entry/src/main/js" +} + +ohos_resources("FormOfFaEts_resources") { + sources = [ "entry/src/main/resources" ] + hap_profile = "entry/src/main/config.json" +} diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationA/Test.json b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationA/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..3ec911dfc7b3a17504cd4577be5bbabaf7f97e63 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationA/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationA/entry/src/main/config.json b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationA/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..4936330fa84e13a043415bee128ea8e7e66e7855 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationA/entry/src/main/config.json @@ -0,0 +1,141 @@ +{ + "app": { + "bundleName": "com.form.formsystemtestservicea.hmservice", + "vendor": "ohos", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 9, + "releaseType": "Release", + "target": 9 + } + }, + "deviceConfig": {}, + "module": { + "package": "com.form.formsystemtestservicea.hmservice", + "name": ".FormSupplyAppA", + "mainAbility": ".MainAbility", + "srcPath": "", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": false + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "visible": true, + "srcPath": "MainAbility", + "name": ".MainAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:description_mainability", + "label": "$string:entry_MainAbility", + "type": "page", + "launchType": "standard" + }, + { + "name": ".FormAbility", + "srcPath": "FormAbility", + "icon": "$media:icon", + "description": "$string:description_mainability", + "label": "$string:entry_MainAbility", + "type": "service", + "formsEnabled": true, + "forms": [ + { + "jsComponentName": "Form_Js001", + "isDefault": true, + "scheduledUpdateTime": "10:30", + "formVisibleNotify": true, + "defaultDimension": "1*2", + "name": "Form_Js001", + "description": "This is a form 001", + "colorMode": "auto", + "type": "JS", + "supportDimensions": [ + "1*2", + "2*2" + ], + "updateEnabled": true, + "updateDuration": 1 + }, + { + "jsComponentName":"Form_Js002", + "isDefault":false, + "defaultDimension":"2*2", + "formVisibleNotify":true, + "name":"Form_Js002", + "colorMode":"auto", + "description":"This is a form 002", + "supportDimensions":[ + "1*2", + "2*2" + ], + "type":"JS", + "updateEnabled":true, + "updateDuration":1 + } + ], + "srcLanguage": "ets" + } + ], + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index", + "pages/second" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + }, + { + "pages": [ + "pages/index/index" + ], + "name": "Form_Js001", + "window": { + "designWidth": 720, + "autoDesignWidth": true + }, + "type": "form" + } + ], + "defPermissions": [ + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormSupply_commonEvent" + } + ], + "reqPermissions": [ + { + "reason": "need use FormSupply commonEvent", + "name": "FMS_FormSupply_commonEvent" + } + ] + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationA/entry/src/main/ets/FormAbility/form.ts b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationA/entry/src/main/ets/FormAbility/form.ts new file mode 100644 index 0000000000000000000000000000000000000000..09124b5db447dbb7cd58da3591d7e05752bcec30 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationA/entry/src/main/ets/FormAbility/form.ts @@ -0,0 +1,88 @@ +import formBindingData from '@ohos.application.formBindingData' +import commonEvent from '@ohos.commonEvent' + +let supplyForm_Event = "FMS_FormSupply_commonEvent"; + +function publishCallBack() { + console.info("!!!====>FormAbility publishCallBack====>"); +} + +export default { + onCreate(want) { + console.info('FormAbility onCreate, want:' + JSON.stringify(want)); + let formData = { + temperature: "11°", + time: "11:00", + area: "Shenyang", + epidemic: true, + count: 10 + }; + let bindingData = formBindingData.createFormBindingData(formData); + var commonEventPublishData = { + parameters: { + "kind" : "onCreate", + "parameters" : JSON.stringify(want), + "data" : JSON.stringify(formData) + } + }; + commonEvent.publish(supplyForm_Event, commonEventPublishData, publishCallBack); + return bindingData; + }, + onUpdate(formId) { + console.info('FormAbility onUpdate, formId: ' + formId); + var commonEventPublishData = { + parameters: { + "kind" : "onUpdate", + "parameters" : formId, + "data" : "" + } + }; + commonEvent.publish(supplyForm_Event, commonEventPublishData, publishCallBack); + }, + onCastToNormal(formId) { + console.info('FormAbility onCastTemp, formId: ' + formId); + + var commonEventPublishData = { + parameters: { + "kind" : "onCastToNormal", + "parameters" : formId, + "data" : "" + } + }; + commonEvent.publish(supplyForm_Event, commonEventPublishData, publishCallBack); + }, + onEvent(formId, message) { + console.info('FormAbility onTriggerEvent, formId: ' + formId + 'message: ' + message); + + var commonEventPublishData = { + parameters: { + "kind" : "onEvent", + "parameters" : formId, + "data" : message + } + }; + commonEvent.publish(supplyForm_Event, commonEventPublishData, publishCallBack); + }, + onVisibilityChange(formEvents) { + console.info('FormAbility onVisibilityChanged, ' + JSON.stringify(formEvents)); + var commonEventPublishData = { + parameters: { + "kind" : "onVisibilityChange", + "parameters" : JSON.stringify(formEvents), + "data" : "" + } + }; + commonEvent.publish(supplyForm_Event, commonEventPublishData, publishCallBack); + }, + onDestroy(formId) { + console.info('FormAbility onDestroy, formId: ' + formId); + var commonEventPublishData = { + parameters: { + "kind" : "onDestroy", + "parameters" : formId, + "data" : "" + } + }; + commonEvent.publish(supplyForm_Event, commonEventPublishData, publishCallBack); + } +}; \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationA/entry/src/main/ets/MainAbility/app.ets b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationA/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..118b21a9e8f69e09b3a316b4df2279f860959042 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationA/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,23 @@ +/* + * 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. + */ + +export default { + onCreate() { + console.info('Application onCreate') + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationA/entry/src/main/ets/MainAbility/pages/index.ets b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationA/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..41d8e5a6830ac26c687caf51a3c30ec33b3fe5c4 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationA/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,53 @@ +/* + * 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 '@system.router'; + +async function routePage() { + let options = { + uri: 'pages/second' + } + try { + await router.push(options) + } catch (err) { + console.error(`fail callback, code: ${err.code}, msg: ${err.msg}`) + } +} + +@Entry +@Component +struct Index { + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + routePage() + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationA/entry/src/main/ets/MainAbility/pages/second.ets b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationA/entry/src/main/ets/MainAbility/pages/second.ets new file mode 100644 index 0000000000000000000000000000000000000000..89533226e76331a2c0997da0bf3c9707e6c0fc2a --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationA/entry/src/main/ets/MainAbility/pages/second.ets @@ -0,0 +1,44 @@ +/* + * 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 '@system.router'; + +@Entry +@Component +struct Second { + private content: string = "Second Page" + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('back to index') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + router.back() + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationA/entry/src/main/js/Form_Js001/pages/index/index.css b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationA/entry/src/main/js/Form_Js001/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..4a7a725b77a0209e0fd19d7872c8d2493ca888bc --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationA/entry/src/main/js/Form_Js001/pages/index/index.css @@ -0,0 +1,19 @@ +#wrapper { + flex-direction: column; +} + +#div1 { + width: 100%; + height: 100%; + justify-content: center; + align-items: center; + background-color: white; +} + +#text1 { + height: 45px; + width: 150px; + font-size: 16px; + text-align: center; +} + diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationA/entry/src/main/js/Form_Js001/pages/index/index.hml b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationA/entry/src/main/js/Form_Js001/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..cd6106fe7f4cd3e951126de70065073f0bd10a95 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationA/entry/src/main/js/Form_Js001/pages/index/index.hml @@ -0,0 +1,7 @@ +
+
+
+ {{title}} +
+
+
\ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationA/entry/src/main/js/Form_Js001/pages/index/index.json b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationA/entry/src/main/js/Form_Js001/pages/index/index.json new file mode 100644 index 0000000000000000000000000000000000000000..376c97a90068b93e4440f5c228289818c62db66b --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationA/entry/src/main/js/Form_Js001/pages/index/index.json @@ -0,0 +1,6 @@ +{ + "actions": {}, + "data": { + "title": "Hello World" + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationA/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationA/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..b0e7e3905b9f6f4ffd28fb0f8a2e7ce585cf2ac6 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationA/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "A提供方" + }, + { + "name": "description_mainability", + "value": "eTS_Empty Ability" + }, + { + "name": "description_serviceability", + "value": "hap sample empty service" + } + ] +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationA/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationA/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationA/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationA/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationA/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..6084de2e92d6f254a93a654b02701870bef66d31 Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationA/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/BUILD.gn b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..b1e630961e24dbc62310cc53b9a554a7bdff3dd5 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/BUILD.gn @@ -0,0 +1,44 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("FormSupplyAppB") { + hap_profile = "entry/src/main/config.json" + deps = [ + ":FormOfFaEts_form_js_assets", + ":FormOfFaEts_js_assets", + ":FormOfFaEts_resources", + ] + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "FormSupplyAppB" + part_name = "prebuilt_hap" + subsystem_name = "applications" +} + +ohos_js_assets("FormOfFaEts_js_assets") { + hap_profile = "entry/src/main/config.json" + ets2abc = true + source_dir = "entry/src/main/ets" +} + +ohos_js_assets("FormOfFaEts_form_js_assets") { + hap_profile = "entry/src/main/config.json" + js2abc = true + source_dir = "entry/src/main/js" +} + +ohos_resources("FormOfFaEts_resources") { + sources = [ "entry/src/main/resources" ] + hap_profile = "entry/src/main/config.json" +} diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/Test.json b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..3ec911dfc7b3a17504cd4577be5bbabaf7f97e63 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/config.json b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..20cfeb7f4579dbbbb4413e39e117efc21e81e67e --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/config.json @@ -0,0 +1,139 @@ +{ + "app": { + "bundleName": "com.form.formsystemtestserviceb.hmservice", + "vendor": "ohos", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 9, + "releaseType": "Release", + "target": 9 + } + }, + "deviceConfig": {}, + "module": { + "package": "com.form.formsystemtestserviceb.hmservice", + "name": ".FormSupplyAppB", + "mainAbility": ".MainAbility", + "srcPath": "", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": false + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "visible": true, + "srcPath": "MainAbility", + "name": ".MainAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:description_mainability", + "label": "$string:entry_MainAbility", + "type": "page", + "launchType": "standard" + }, + { + "name": ".FormAbility", + "srcPath": "FormAbility", + "icon": "$media:icon", + "description": "$string:description_mainability", + "label": "$string:entry_MainAbility", + "type": "service", + "formsEnabled": true, + "forms": [ + { + "jsComponentName": "widget", + "isDefault": true, + "formVisibleNotify": true, + "defaultDimension": "1*2", + "name": "Form_Js001", + "description": "This is a form 001", + "colorMode": "auto", + "type": "JS", + "supportDimensions": [ + "1*2", + "2*2" + ], + "updateEnabled": true, + "updateDuration": 1 + }, + { + "jsComponentName":"widget", + "isDefault":false, + "defaultDimension":"2*2", + "formVisibleNotify":true, + "name":"Form_Js002", + "colorMode":"auto", + "description":"This is a form 002", + "supportDimensions":[ + "1*2", + "2*2" + ], + "type":"JS", + "updateEnabled":true, + "scheduledUpdateTime": "10:30" + } + ], + "srcLanguage": "ets" + } + ], + "defPermissions": [ + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormSupply_commonEvent" + } + ], + "reqPermissions": [ + { + "name": "FMS_FormSupply_commonEvent", + "reason": "need use FormSupply commonEvent" + } + ], + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + }, + { + "pages": [ + "pages/index/index" + ], + "name": "widget", + "window": { + "designWidth": 720, + "autoDesignWidth": true + }, + "type": "form" + } + ] + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/ets/FormAbility/form.ts b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/ets/FormAbility/form.ts new file mode 100644 index 0000000000000000000000000000000000000000..09124b5db447dbb7cd58da3591d7e05752bcec30 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/ets/FormAbility/form.ts @@ -0,0 +1,88 @@ +import formBindingData from '@ohos.application.formBindingData' +import commonEvent from '@ohos.commonEvent' + +let supplyForm_Event = "FMS_FormSupply_commonEvent"; + +function publishCallBack() { + console.info("!!!====>FormAbility publishCallBack====>"); +} + +export default { + onCreate(want) { + console.info('FormAbility onCreate, want:' + JSON.stringify(want)); + let formData = { + temperature: "11°", + time: "11:00", + area: "Shenyang", + epidemic: true, + count: 10 + }; + let bindingData = formBindingData.createFormBindingData(formData); + var commonEventPublishData = { + parameters: { + "kind" : "onCreate", + "parameters" : JSON.stringify(want), + "data" : JSON.stringify(formData) + } + }; + commonEvent.publish(supplyForm_Event, commonEventPublishData, publishCallBack); + return bindingData; + }, + onUpdate(formId) { + console.info('FormAbility onUpdate, formId: ' + formId); + var commonEventPublishData = { + parameters: { + "kind" : "onUpdate", + "parameters" : formId, + "data" : "" + } + }; + commonEvent.publish(supplyForm_Event, commonEventPublishData, publishCallBack); + }, + onCastToNormal(formId) { + console.info('FormAbility onCastTemp, formId: ' + formId); + + var commonEventPublishData = { + parameters: { + "kind" : "onCastToNormal", + "parameters" : formId, + "data" : "" + } + }; + commonEvent.publish(supplyForm_Event, commonEventPublishData, publishCallBack); + }, + onEvent(formId, message) { + console.info('FormAbility onTriggerEvent, formId: ' + formId + 'message: ' + message); + + var commonEventPublishData = { + parameters: { + "kind" : "onEvent", + "parameters" : formId, + "data" : message + } + }; + commonEvent.publish(supplyForm_Event, commonEventPublishData, publishCallBack); + }, + onVisibilityChange(formEvents) { + console.info('FormAbility onVisibilityChanged, ' + JSON.stringify(formEvents)); + var commonEventPublishData = { + parameters: { + "kind" : "onVisibilityChange", + "parameters" : JSON.stringify(formEvents), + "data" : "" + } + }; + commonEvent.publish(supplyForm_Event, commonEventPublishData, publishCallBack); + }, + onDestroy(formId) { + console.info('FormAbility onDestroy, formId: ' + formId); + var commonEventPublishData = { + parameters: { + "kind" : "onDestroy", + "parameters" : formId, + "data" : "" + } + }; + commonEvent.publish(supplyForm_Event, commonEventPublishData, publishCallBack); + } +}; \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/ets/MainAbility/app.ets b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..118b21a9e8f69e09b3a316b4df2279f860959042 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,23 @@ +/* + * 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. + */ + +export default { + onCreate() { + console.info('Application onCreate') + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/ets/MainAbility/pages/index.ets b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..a56d6b68bd9528f0b746eb67f936020556a14bf8 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,119 @@ +/* + * 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 featureAbility from "@ohos.ability.featureAbility"; +import formBindingData from "@ohos.application.formBindingData"; +import formManager from '@ohos.ability.formManager'; +import commonEvent from '@ohos.commonEvent'; + +@Entry +@Component +struct Index { + @State formId: number = 0; + @State opt : string = "updateForm"; + @State formData: {[key: string]: any} = {temperature: "14c", "time": "12:00"}; + @State nextTime: number = 5; + + private formUpdateFormEvent = "FMS_FormUpdateRefresh_commonEvent"; + private formOnDynamicRefreshEvent = "FMS_FormDynamicRefresh_commonEvent"; + + private publishUpdateFormCallBack() { + console.debug("====>form supply B publishUpdateFormCallBack ====>"); + } + private formOnDynamicRefreshCallBack() { + console.debug("====>formsystemhostc formOnDynamicRefreshEventk ====>"); + } + + private aboutToAppear() { + console.log(`form supply B aboutToAppear start`); + console.error('form supply B getWant'); + featureAbility.getWant() + .then((want: any) => { + this.formId = parseInt(want.parameters.formId); + this.opt = want.parameters.opt; + if(want.parameters.formData) { + this.formData = want.parameters.formData; + } + if(want.parameters.nextTime) { + this.nextTime = want.parameters.nextTime; + } + console.error('form supply B getWant end'+ JSON.stringify(want)); + + if(this.opt == "updateForm") { + console.log("form supply B updateForm start"); + let dataObj = { + temperature: "14c", + "time": "12:00", + "test": 11, + "test3": true + }; + let bindingData = formBindingData.createFormBindingData(JSON.stringify(dataObj)); + formManager.updateForm(this.formId, bindingData) + .then((data) => { + console.info('form supply B updateForm result:' + data); + let commonEventPublishData = { + data: data.toString(), + parameters: { + "formId" : this.formId.toString() + } + }; + commonEvent.publish(this.formUpdateFormEvent, commonEventPublishData, this.publishUpdateFormCallBack); + }); + + console.log("form supply B deleteForm end"); + } + + if(this.opt == "setNextRefreshTime") { + console.log("form supply B setNextRefreshTime start"); + formManager.setFormNextRefreshTime(this.formId, this.nextTime) + .then((data) => { + console.info('form supply B setNextRefreshTime result:' + data); + let commonEventPublishData = { + data: data.toString(), + parameters: { + "formId" : this.formId.toString() + } + }; + commonEvent.publish(this.formOnDynamicRefreshEvent, commonEventPublishData, this.formOnDynamicRefreshCallBack); + }); + + console.log("form supply B setNextRefreshTime end"); + } + + }) + .catch((error: any) => { + console.error('form supply B Operation failed. Cause: ' + JSON.stringify(error)); + }) + console.log(`form supply aboutToAppear end`); + } + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/image_1.png b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/image_1.png new file mode 100644 index 0000000000000000000000000000000000000000..71976f509c321f9516640d6d2f7cc6463f453578 Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/image_1.png differ diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/image_2.png b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/image_2.png new file mode 100644 index 0000000000000000000000000000000000000000..a09c3c6c71db729c613a2e6765d24dd0b06b54d8 Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/image_2.png differ diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/close.svg b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/close.svg new file mode 100644 index 0000000000000000000000000000000000000000..f4623ea319fe4f41480b086da857f23ae66e4f57 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/close.svg @@ -0,0 +1,16 @@ + + + close + + + + + + + + + + + + + \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/ic_HD1.png b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/ic_HD1.png new file mode 100644 index 0000000000000000000000000000000000000000..2d440f89ac4e1b094921c9dcd3718f550c170346 Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/ic_HD1.png differ diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/ic_box.svg b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/ic_box.svg new file mode 100644 index 0000000000000000000000000000000000000000..42c600f3d7fae00a8f271e06e3d438781a3b62e1 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/ic_box.svg @@ -0,0 +1,9 @@ + + + Device/device_filled/ic_box + + + + + + \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/ic_box1.png b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/ic_box1.png new file mode 100644 index 0000000000000000000000000000000000000000..147ec64284971fc4c51235f5d413ef1c0cb3b60e Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/ic_box1.png differ diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/ic_default_image.png b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/ic_default_image.png new file mode 100644 index 0000000000000000000000000000000000000000..07f11b1185ef9bcca89ced50219513544adb7b98 Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/ic_default_image.png differ diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/ic_default_image@3x.png b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/ic_default_image@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..11a9dd87291d31f6e90dd4648ead8429aca1ff54 Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/ic_default_image@3x.png differ diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/ic_default_white.png b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/ic_default_white.png new file mode 100644 index 0000000000000000000000000000000000000000..00b47be369e7010b4330cf7bcac16e07d8a49937 Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/ic_default_white.png differ diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/ic_device_earphone_hero_filled.svg b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/ic_device_earphone_hero_filled.svg new file mode 100644 index 0000000000000000000000000000000000000000..f190038d0cbdb2fa942030e29903a4d21a62dc76 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/ic_device_earphone_hero_filled.svg @@ -0,0 +1,10 @@ + + + Devices/Filled/ic_device_earphone_hero_filled + + + + + + + \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/ic_device_earphone_hero_filled1.png b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/ic_device_earphone_hero_filled1.png new file mode 100644 index 0000000000000000000000000000000000000000..0753761fc0db3511b55ff83923c183365b3ff69c Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/ic_device_earphone_hero_filled1.png differ diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/ic_list.svg b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/ic_list.svg new file mode 100644 index 0000000000000000000000000000000000000000..553da281ae4bf91fa43e9a5b849dd792a1e7faa7 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/ic_list.svg @@ -0,0 +1,22 @@ + + + + ic_list + Created with Sketch. + + + + \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/ic_pad.svg b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/ic_pad.svg new file mode 100644 index 0000000000000000000000000000000000000000..6fbb94db7b07820b95fe289bc95ff065ebf82fd8 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/ic_pad.svg @@ -0,0 +1,8 @@ + + + Device/device_filled/ic_pad + + + + + \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/ic_pad1.png b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/ic_pad1.png new file mode 100644 index 0000000000000000000000000000000000000000..9156a9362ac30fe368f162a911a02f4ff72bbffb Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/ic_pad1.png differ diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/ic_pc.svg b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/ic_pc.svg new file mode 100644 index 0000000000000000000000000000000000000000..ebb6a162c21781f741e58a487e426b5a8fb3472e --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/ic_pc.svg @@ -0,0 +1,10 @@ + + + Device/device_filled/ic_pc + + + + + + + \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/ic_pc1.png b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/ic_pc1.png new file mode 100644 index 0000000000000000000000000000000000000000..8328aa1454f44122ca88b2e6047db02189c8df3b Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/ic_pc1.png differ diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/ic_public_search.svg b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/ic_public_search.svg new file mode 100644 index 0000000000000000000000000000000000000000..98d04d8d590343410eb1821173d70b3237343e31 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/ic_public_search.svg @@ -0,0 +1,13 @@ + + + Public/ic_public_search + + + + + + + + + + \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/ic_selfie.png b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/ic_selfie.png new file mode 100644 index 0000000000000000000000000000000000000000..9048642794b088557e7e88010422d8eb7f418fa6 Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/ic_selfie.png differ diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/ic_tv.svg b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/ic_tv.svg new file mode 100644 index 0000000000000000000000000000000000000000..afe607222b97ef6bcf89a3affbea8eaf36a819ff --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/ic_tv.svg @@ -0,0 +1,10 @@ + + + Device/device_filled/ic_tv + + + + + + + \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/ic_vision.svg b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/ic_vision.svg new file mode 100644 index 0000000000000000000000000000000000000000..95f75bf2298db8bf39929596b2c708fbb617be80 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/ic_vision.svg @@ -0,0 +1,29 @@ + + + ic_vision + + + + + \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/search.svg b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/search.svg new file mode 100644 index 0000000000000000000000000000000000000000..d475fe3a6622465b7e1e3c8463de3fe7530dafa2 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/search.svg @@ -0,0 +1,20 @@ + + + svgProgressBar/circle/normal备份 + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/superdevice.svg b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/superdevice.svg new file mode 100644 index 0000000000000000000000000000000000000000..66e1e624d8c4884a661a1fe278b798a33e79d1cb --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/superdevice.svg @@ -0,0 +1,9 @@ + + + superdevice + + + + + + \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/template.png b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/template.png new file mode 100644 index 0000000000000000000000000000000000000000..c13bb4d340435b2e8d8fd90660ffc9916e1f6d68 Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/common/img/template.png differ diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/manifest.json b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/manifest.json new file mode 100644 index 0000000000000000000000000000000000000000..a27710a2f3126ba1eb0ac2cd2d65133e38ddc8b9 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/manifest.json @@ -0,0 +1 @@ +{"appID": "com.example.myapplication","appName": "$string:entry_MainAbility","versionName": "1.0.0","versionCode": 1000000,"minPlatformVersion": 7,"pages": ["pages/index/index"],"deviceType": ["phone"],"type": "form","window": {"autoDesignWidth": true,"designWidth": 720}} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/pages/index/index.json b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/pages/index/index.json new file mode 100644 index 0000000000000000000000000000000000000000..3c42b73a47e817737770dd731b6f207796115f07 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/js/widget/pages/index/index.json @@ -0,0 +1,234 @@ +{ + "template": { + "attr": {}, + "type": "div", + "classList": [ + "container" + ], + "children": [ + { + "attr": {}, + "type": "div", + "classList": [ + "bottom" + ], + "style": { + "display": "{{isShow}}" + }, + "children": [ + { + "attr": {}, + "type": "div", + "classList": [ + "bg_color" + ], + "events": { + "click": "routerEvent" + }, + "children": [ + { + "attr": { + "src": "/common/img/ic_pad.svg" + }, + "type": "image", + "classList": [ + "img1" + ] + } + ] + }, + { + "attr": {}, + "type": "div", + "classList": [ + "pic_title_container" + ], + "children": [ + { + "attr": {}, + "type": "div", + "style": { + "flexDirection": "column" + }, + "children": [ + { + "attr": { + "value": "{{temperature}}" + }, + "type": "text", + "classList": [ + "title" + ] + }, + { + "attr": { + "value": "{{time}}" + }, + "type": "text", + "classList": [ + "content" + ] + }, + { + "attr": { + "src": "{{image1}}" + }, + "type": "image", + "classList": [ + "title" + ] + } + ] + } + ] + } + ] + } + ] + }, + "styles": { + ".container": { + "display": "flex", + "flexDirection": "column", + "left": "0px", + "top": "0px", + "width": "640vp", + "backgroundColor": "#eeeeee" + }, + ".pic_title_container": { + "backgroundColor": "#FF007DFB", + "flexDirection": "column", + "height": "100%", + "paddingTop": "12px", + "paddingStart": "12px", + "paddingBottom": "12px", + "justifyContent": "space-between" + }, + ".content": { + "fontSize": "12px", + "color": "#99ffffff", + "textOverflow": "ellipsis", + "maxLines": "1" + }, + ".title": { + "fontSize": "16px", + "color": "#e5ffffff", + "marginBottom": "2px" + }, + ".head": { + "width": "90%", + "height": "70vp", + "display": "flex", + "marginTop": "8px", + "justifyContent": "space-between", + "alignItems": "center" + }, + ".right": { + "flexGrow": 1, + "marginLeft": "260vp" + }, + ".img": { + "marginLeft": "48vp", + "marginTop": "5px", + "width": "36vp", + "height": "36vp" + }, + ".bottom": { + "marginTop": "-12px", + "width": "90%", + "display": "flex", + "flexDirection": "column", + "marginLeft": "30px" + }, + ".bg_color": { + "width": "48vp", + "height": "48vp", + "borderBottomLeftRadius": "48px", + "borderBottomRightRadius": "48px", + "borderTopLeftRadius": "48px", + "borderTopRightRadius": "48px", + "backgroundColor": "#cccccc", + "marginLeft": "36%" + }, + ".img1": { + "marginTop": "14vp", + "marginLeft": "14vp" + }, + ".text": { + "marginTop": "16px", + "fontSize": "12px", + "display": "flex", + "justifyContent": "center" + }, + ".co_blue": { + "marginLeft": "12px", + "color": "#1e90ff" + }, + ".todo-wrapper": { + "marginTop": "0vp", + "display": "flex", + "flexDirection": "row", + "width": "80%" + }, + ".todo-item": { + "width": "85vp", + "display": "flex", + "flexDirection": "column", + "marginRight": "10px", + "alignItems": "center" + }, + ".bg_color1": { + "width": "48vp", + "height": "48vp", + "borderBottomLeftRadius": "48px", + "borderBottomRightRadius": "48px", + "borderTopLeftRadius": "48px", + "borderTopRightRadius": "48px", + "backgroundColor": "#cccccc", + "marginBottom": "6vp" + }, + ".title_img": { + "marginTop": "14vp", + "marginLeft": "11vp" + }, + ".todo-title": { + "textAlign": "center", + "fontSize": "10px", + "color": "#E5000000" + } + }, + "data": { + "temperature": "超级终端", + "time": "qqqq", + "ifShow": "none", + "image1": "memory://image1", + "isShow": "flex", + "deviceList": [ + { + "img": "/common/img/ic_pad.svg", + "deviceName": "huawei", + "deviceType": 17, + "deviceId": 1 + } + ] + }, + "actions": { + "routerEvent": { + "action": "message", + "bundleName": "com.ohos.photos", + "abilityName": "com.ohos.photos.MainAbility", + "params": { + "message": "addDetail" + } + }, + "searchDeviceList": { + "action": "message", + "bundleName": "com.lizhiqi.card.hmservice", + "abilityName": "com.lizhiqi.card.MainAbility", + "params": { + "message": "searchList" + } + } + }, + "apiVersion": {} +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..ae5f28b1d118a84b9a4a9e5debff087058ae7d99 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "B提供方" + }, + { + "name": "description_mainability", + "value": "eTS_Empty Ability" + }, + { + "name": "description_serviceability", + "value": "hap sample empty service" + } + ] +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..6084de2e92d6f254a93a654b02701870bef66d31 Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationB/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/BUILD.gn b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..a7dd39bf3de61f8322f48a05d6b80d83172233b7 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/BUILD.gn @@ -0,0 +1,44 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("FormSupplyAppD") { + hap_profile = "entry/src/main/config.json" + deps = [ + ":FormOfFaEts_form_js_assets", + ":FormOfFaEts_js_assets", + ":FormOfFaEts_resources", + ] + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "FormSupplyAppD" + part_name = "prebuilt_hap" + subsystem_name = "applications" +} + +ohos_js_assets("FormOfFaEts_js_assets") { + hap_profile = "entry/src/main/config.json" + ets2abc = true + source_dir = "entry/src/main/ets" +} + +ohos_js_assets("FormOfFaEts_form_js_assets") { + hap_profile = "entry/src/main/config.json" + js2abc = true + source_dir = "entry/src/main/js" +} + +ohos_resources("FormOfFaEts_resources") { + sources = [ "entry/src/main/resources" ] + hap_profile = "entry/src/main/config.json" +} diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/Test.json b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..3ec911dfc7b3a17504cd4577be5bbabaf7f97e63 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/config.json b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..46fea018cfc773e7934d5136ceca9fa2a087f187 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/config.json @@ -0,0 +1,139 @@ +{ + "app": { + "bundleName": "com.form.formsystemtestserviced.hmservice", + "vendor": "ohos", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 9, + "releaseType": "Release", + "target": 9 + } + }, + "deviceConfig": {}, + "module": { + "package": "com.form.formsystemtestserviced.hmservice", + "name": ".FormSupplyAppD", + "mainAbility": ".MainAbility", + "srcPath": "", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": false + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "visible": true, + "srcPath": "MainAbility", + "name": ".MainAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:description_mainability", + "label": "$string:entry_MainAbility", + "type": "page", + "launchType": "standard" + }, + { + "name": ".FormAbility", + "srcPath": "FormAbility", + "icon": "$media:icon", + "description": "$string:description_mainability", + "label": "$string:entry_MainAbility", + "type": "service", + "formsEnabled": true, + "forms": [ + { + "jsComponentName": "widget", + "isDefault": true, + "formVisibleNotify": false, + "defaultDimension": "1*2", + "name": "Form_Js001", + "description": "This is a form 001", + "colorMode": "auto", + "type": "JS", + "supportDimensions": [ + "1*2", + "2*2" + ], + "updateEnabled": true, + "updateDuration": 1 + }, + { + "jsComponentName":"widget", + "isDefault":false, + "defaultDimension":"2*2", + "formVisibleNotify":true, + "name":"Form_Js002", + "colorMode":"auto", + "description":"This is a form 002", + "supportDimensions":[ + "1*2", + "2*2" + ], + "type":"JS", + "updateEnabled":true, + "scheduledUpdateTime": "10:30" + } + ], + "srcLanguage": "ets" + } + ], + "defPermissions": [ + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormSupply_commonEvent" + } + ], + "reqPermissions": [ + { + "name": "FMS_FormSupply_commonEvent", + "reason": "need use FormSupply commonEvent" + } + ], + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + }, + { + "pages": [ + "pages/index/index" + ], + "name": "widget", + "window": { + "designWidth": 720, + "autoDesignWidth": true + }, + "type": "form" + } + ] + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/ets/FormAbility/form.ts b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/ets/FormAbility/form.ts new file mode 100644 index 0000000000000000000000000000000000000000..33079f82d465413178287da8ec1eb7e312d36ae8 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/ets/FormAbility/form.ts @@ -0,0 +1,89 @@ +import formBindingData from '@ohos.application.formBindingData' +import formProvider from '@ohos.application.formProvider' +import commonEvent from '@ohos.commonEvent' + +let supplyForm_Event = "FMS_FormSupply_commonEvent"; + +function publishCallBack() { + console.info("!!!====>FormAbility publishCallBack====>"); +} + +export default { + onCreate(want) { + console.info('FormAbility onCreate, want:' + JSON.stringify(want)); + let formData = { + temperature: "11°", + time: "11:00", + area: "Shenyang", + epidemic: true, + count: 10 + }; + let bindingData = formBindingData.createFormBindingData(formData); + let commonEventPublishData = { + parameters: { + "kind" : "onCreate", + "parameters" : JSON.stringify(want), + "data" : JSON.stringify(formData) + } + }; + commonEvent.publish(supplyForm_Event, commonEventPublishData, publishCallBack); + return bindingData; + }, + onUpdate(formId) { + console.info('FormAbility onUpdate, formId: ' + formId); + let commonEventPublishData = { + parameters: { + "kind" : "onUpdate", + "parameters" : formId, + "data" : "" + } + }; + commonEvent.publish(supplyForm_Event, commonEventPublishData, publishCallBack); + }, + onCastToNormal(formId) { + console.info('FormAbility onCastTemp, formId: ' + formId); + + let commonEventPublishData = { + parameters: { + "kind" : "onCastToNormal", + "parameters" : formId, + "data" : "" + } + }; + commonEvent.publish(supplyForm_Event, commonEventPublishData, publishCallBack); + }, + onEvent(formId, message) { + console.info('FormAbility onTriggerEvent, formId: ' + formId + 'message: ' + message); + + let commonEventPublishData = { + parameters: { + "kind" : "onEvent", + "parameters" : formId, + "data" : message + } + }; + commonEvent.publish(supplyForm_Event, commonEventPublishData, publishCallBack); + }, + onVisibilityChange(formEvents) { + console.info('FormAbility onVisibilityChanged, ' + JSON.stringify(formEvents)); + var commonEventPublishData = { + parameters: { + "kind" : "onVisibilityChange", + "parameters" : JSON.stringify(formEvents), + "data" : "" + } + }; + commonEvent.publish(supplyForm_Event, commonEventPublishData, publishCallBack); + }, + onDestroy(formId) { + console.info('FormAbility onDestroy, formId: ' + formId); + let commonEventPublishData = { + parameters: { + "kind" : "onDestroy", + "parameters" : formId, + "data" : "" + } + }; + commonEvent.publish(supplyForm_Event, commonEventPublishData, publishCallBack); + } +}; \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/ets/MainAbility/app.ets b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..118b21a9e8f69e09b3a316b4df2279f860959042 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,23 @@ +/* + * 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. + */ + +export default { + onCreate() { + console.info('Application onCreate') + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/ets/MainAbility/pages/index.ets b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..a56d6b68bd9528f0b746eb67f936020556a14bf8 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,119 @@ +/* + * 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 featureAbility from "@ohos.ability.featureAbility"; +import formBindingData from "@ohos.application.formBindingData"; +import formManager from '@ohos.ability.formManager'; +import commonEvent from '@ohos.commonEvent'; + +@Entry +@Component +struct Index { + @State formId: number = 0; + @State opt : string = "updateForm"; + @State formData: {[key: string]: any} = {temperature: "14c", "time": "12:00"}; + @State nextTime: number = 5; + + private formUpdateFormEvent = "FMS_FormUpdateRefresh_commonEvent"; + private formOnDynamicRefreshEvent = "FMS_FormDynamicRefresh_commonEvent"; + + private publishUpdateFormCallBack() { + console.debug("====>form supply B publishUpdateFormCallBack ====>"); + } + private formOnDynamicRefreshCallBack() { + console.debug("====>formsystemhostc formOnDynamicRefreshEventk ====>"); + } + + private aboutToAppear() { + console.log(`form supply B aboutToAppear start`); + console.error('form supply B getWant'); + featureAbility.getWant() + .then((want: any) => { + this.formId = parseInt(want.parameters.formId); + this.opt = want.parameters.opt; + if(want.parameters.formData) { + this.formData = want.parameters.formData; + } + if(want.parameters.nextTime) { + this.nextTime = want.parameters.nextTime; + } + console.error('form supply B getWant end'+ JSON.stringify(want)); + + if(this.opt == "updateForm") { + console.log("form supply B updateForm start"); + let dataObj = { + temperature: "14c", + "time": "12:00", + "test": 11, + "test3": true + }; + let bindingData = formBindingData.createFormBindingData(JSON.stringify(dataObj)); + formManager.updateForm(this.formId, bindingData) + .then((data) => { + console.info('form supply B updateForm result:' + data); + let commonEventPublishData = { + data: data.toString(), + parameters: { + "formId" : this.formId.toString() + } + }; + commonEvent.publish(this.formUpdateFormEvent, commonEventPublishData, this.publishUpdateFormCallBack); + }); + + console.log("form supply B deleteForm end"); + } + + if(this.opt == "setNextRefreshTime") { + console.log("form supply B setNextRefreshTime start"); + formManager.setFormNextRefreshTime(this.formId, this.nextTime) + .then((data) => { + console.info('form supply B setNextRefreshTime result:' + data); + let commonEventPublishData = { + data: data.toString(), + parameters: { + "formId" : this.formId.toString() + } + }; + commonEvent.publish(this.formOnDynamicRefreshEvent, commonEventPublishData, this.formOnDynamicRefreshCallBack); + }); + + console.log("form supply B setNextRefreshTime end"); + } + + }) + .catch((error: any) => { + console.error('form supply B Operation failed. Cause: ' + JSON.stringify(error)); + }) + console.log(`form supply aboutToAppear end`); + } + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/image_1.png b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/image_1.png new file mode 100644 index 0000000000000000000000000000000000000000..71976f509c321f9516640d6d2f7cc6463f453578 Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/image_1.png differ diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/image_2.png b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/image_2.png new file mode 100644 index 0000000000000000000000000000000000000000..a09c3c6c71db729c613a2e6765d24dd0b06b54d8 Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/image_2.png differ diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/close.svg b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/close.svg new file mode 100644 index 0000000000000000000000000000000000000000..f4623ea319fe4f41480b086da857f23ae66e4f57 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/close.svg @@ -0,0 +1,16 @@ + + + close + + + + + + + + + + + + + \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/ic_HD1.png b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/ic_HD1.png new file mode 100644 index 0000000000000000000000000000000000000000..2d440f89ac4e1b094921c9dcd3718f550c170346 Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/ic_HD1.png differ diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/ic_box.svg b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/ic_box.svg new file mode 100644 index 0000000000000000000000000000000000000000..42c600f3d7fae00a8f271e06e3d438781a3b62e1 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/ic_box.svg @@ -0,0 +1,9 @@ + + + Device/device_filled/ic_box + + + + + + \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/ic_box1.png b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/ic_box1.png new file mode 100644 index 0000000000000000000000000000000000000000..147ec64284971fc4c51235f5d413ef1c0cb3b60e Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/ic_box1.png differ diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/ic_default_image.png b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/ic_default_image.png new file mode 100644 index 0000000000000000000000000000000000000000..07f11b1185ef9bcca89ced50219513544adb7b98 Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/ic_default_image.png differ diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/ic_default_image@3x.png b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/ic_default_image@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..11a9dd87291d31f6e90dd4648ead8429aca1ff54 Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/ic_default_image@3x.png differ diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/ic_default_white.png b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/ic_default_white.png new file mode 100644 index 0000000000000000000000000000000000000000..00b47be369e7010b4330cf7bcac16e07d8a49937 Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/ic_default_white.png differ diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/ic_device_earphone_hero_filled.svg b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/ic_device_earphone_hero_filled.svg new file mode 100644 index 0000000000000000000000000000000000000000..f190038d0cbdb2fa942030e29903a4d21a62dc76 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/ic_device_earphone_hero_filled.svg @@ -0,0 +1,10 @@ + + + Devices/Filled/ic_device_earphone_hero_filled + + + + + + + \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/ic_device_earphone_hero_filled1.png b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/ic_device_earphone_hero_filled1.png new file mode 100644 index 0000000000000000000000000000000000000000..0753761fc0db3511b55ff83923c183365b3ff69c Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/ic_device_earphone_hero_filled1.png differ diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/ic_list.svg b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/ic_list.svg new file mode 100644 index 0000000000000000000000000000000000000000..553da281ae4bf91fa43e9a5b849dd792a1e7faa7 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/ic_list.svg @@ -0,0 +1,22 @@ + + + + ic_list + Created with Sketch. + + + + \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/ic_pad.svg b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/ic_pad.svg new file mode 100644 index 0000000000000000000000000000000000000000..6fbb94db7b07820b95fe289bc95ff065ebf82fd8 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/ic_pad.svg @@ -0,0 +1,8 @@ + + + Device/device_filled/ic_pad + + + + + \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/ic_pad1.png b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/ic_pad1.png new file mode 100644 index 0000000000000000000000000000000000000000..9156a9362ac30fe368f162a911a02f4ff72bbffb Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/ic_pad1.png differ diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/ic_pc.svg b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/ic_pc.svg new file mode 100644 index 0000000000000000000000000000000000000000..ebb6a162c21781f741e58a487e426b5a8fb3472e --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/ic_pc.svg @@ -0,0 +1,10 @@ + + + Device/device_filled/ic_pc + + + + + + + \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/ic_pc1.png b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/ic_pc1.png new file mode 100644 index 0000000000000000000000000000000000000000..8328aa1454f44122ca88b2e6047db02189c8df3b Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/ic_pc1.png differ diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/ic_public_search.svg b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/ic_public_search.svg new file mode 100644 index 0000000000000000000000000000000000000000..98d04d8d590343410eb1821173d70b3237343e31 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/ic_public_search.svg @@ -0,0 +1,13 @@ + + + Public/ic_public_search + + + + + + + + + + \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/ic_selfie.png b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/ic_selfie.png new file mode 100644 index 0000000000000000000000000000000000000000..9048642794b088557e7e88010422d8eb7f418fa6 Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/ic_selfie.png differ diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/ic_tv.svg b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/ic_tv.svg new file mode 100644 index 0000000000000000000000000000000000000000..afe607222b97ef6bcf89a3affbea8eaf36a819ff --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/ic_tv.svg @@ -0,0 +1,10 @@ + + + Device/device_filled/ic_tv + + + + + + + \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/ic_vision.svg b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/ic_vision.svg new file mode 100644 index 0000000000000000000000000000000000000000..95f75bf2298db8bf39929596b2c708fbb617be80 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/ic_vision.svg @@ -0,0 +1,29 @@ + + + ic_vision + + + + + \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/search.svg b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/search.svg new file mode 100644 index 0000000000000000000000000000000000000000..d475fe3a6622465b7e1e3c8463de3fe7530dafa2 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/search.svg @@ -0,0 +1,20 @@ + + + svgProgressBar/circle/normal备份 + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/superdevice.svg b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/superdevice.svg new file mode 100644 index 0000000000000000000000000000000000000000..66e1e624d8c4884a661a1fe278b798a33e79d1cb --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/superdevice.svg @@ -0,0 +1,9 @@ + + + superdevice + + + + + + \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/template.png b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/template.png new file mode 100644 index 0000000000000000000000000000000000000000..c13bb4d340435b2e8d8fd90660ffc9916e1f6d68 Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/common/img/template.png differ diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/manifest.json b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/manifest.json new file mode 100644 index 0000000000000000000000000000000000000000..a27710a2f3126ba1eb0ac2cd2d65133e38ddc8b9 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/manifest.json @@ -0,0 +1 @@ +{"appID": "com.example.myapplication","appName": "$string:entry_MainAbility","versionName": "1.0.0","versionCode": 1000000,"minPlatformVersion": 7,"pages": ["pages/index/index"],"deviceType": ["phone"],"type": "form","window": {"autoDesignWidth": true,"designWidth": 720}} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/pages/index/index.json b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/pages/index/index.json new file mode 100644 index 0000000000000000000000000000000000000000..3c42b73a47e817737770dd731b6f207796115f07 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/js/widget/pages/index/index.json @@ -0,0 +1,234 @@ +{ + "template": { + "attr": {}, + "type": "div", + "classList": [ + "container" + ], + "children": [ + { + "attr": {}, + "type": "div", + "classList": [ + "bottom" + ], + "style": { + "display": "{{isShow}}" + }, + "children": [ + { + "attr": {}, + "type": "div", + "classList": [ + "bg_color" + ], + "events": { + "click": "routerEvent" + }, + "children": [ + { + "attr": { + "src": "/common/img/ic_pad.svg" + }, + "type": "image", + "classList": [ + "img1" + ] + } + ] + }, + { + "attr": {}, + "type": "div", + "classList": [ + "pic_title_container" + ], + "children": [ + { + "attr": {}, + "type": "div", + "style": { + "flexDirection": "column" + }, + "children": [ + { + "attr": { + "value": "{{temperature}}" + }, + "type": "text", + "classList": [ + "title" + ] + }, + { + "attr": { + "value": "{{time}}" + }, + "type": "text", + "classList": [ + "content" + ] + }, + { + "attr": { + "src": "{{image1}}" + }, + "type": "image", + "classList": [ + "title" + ] + } + ] + } + ] + } + ] + } + ] + }, + "styles": { + ".container": { + "display": "flex", + "flexDirection": "column", + "left": "0px", + "top": "0px", + "width": "640vp", + "backgroundColor": "#eeeeee" + }, + ".pic_title_container": { + "backgroundColor": "#FF007DFB", + "flexDirection": "column", + "height": "100%", + "paddingTop": "12px", + "paddingStart": "12px", + "paddingBottom": "12px", + "justifyContent": "space-between" + }, + ".content": { + "fontSize": "12px", + "color": "#99ffffff", + "textOverflow": "ellipsis", + "maxLines": "1" + }, + ".title": { + "fontSize": "16px", + "color": "#e5ffffff", + "marginBottom": "2px" + }, + ".head": { + "width": "90%", + "height": "70vp", + "display": "flex", + "marginTop": "8px", + "justifyContent": "space-between", + "alignItems": "center" + }, + ".right": { + "flexGrow": 1, + "marginLeft": "260vp" + }, + ".img": { + "marginLeft": "48vp", + "marginTop": "5px", + "width": "36vp", + "height": "36vp" + }, + ".bottom": { + "marginTop": "-12px", + "width": "90%", + "display": "flex", + "flexDirection": "column", + "marginLeft": "30px" + }, + ".bg_color": { + "width": "48vp", + "height": "48vp", + "borderBottomLeftRadius": "48px", + "borderBottomRightRadius": "48px", + "borderTopLeftRadius": "48px", + "borderTopRightRadius": "48px", + "backgroundColor": "#cccccc", + "marginLeft": "36%" + }, + ".img1": { + "marginTop": "14vp", + "marginLeft": "14vp" + }, + ".text": { + "marginTop": "16px", + "fontSize": "12px", + "display": "flex", + "justifyContent": "center" + }, + ".co_blue": { + "marginLeft": "12px", + "color": "#1e90ff" + }, + ".todo-wrapper": { + "marginTop": "0vp", + "display": "flex", + "flexDirection": "row", + "width": "80%" + }, + ".todo-item": { + "width": "85vp", + "display": "flex", + "flexDirection": "column", + "marginRight": "10px", + "alignItems": "center" + }, + ".bg_color1": { + "width": "48vp", + "height": "48vp", + "borderBottomLeftRadius": "48px", + "borderBottomRightRadius": "48px", + "borderTopLeftRadius": "48px", + "borderTopRightRadius": "48px", + "backgroundColor": "#cccccc", + "marginBottom": "6vp" + }, + ".title_img": { + "marginTop": "14vp", + "marginLeft": "11vp" + }, + ".todo-title": { + "textAlign": "center", + "fontSize": "10px", + "color": "#E5000000" + } + }, + "data": { + "temperature": "超级终端", + "time": "qqqq", + "ifShow": "none", + "image1": "memory://image1", + "isShow": "flex", + "deviceList": [ + { + "img": "/common/img/ic_pad.svg", + "deviceName": "huawei", + "deviceType": 17, + "deviceId": 1 + } + ] + }, + "actions": { + "routerEvent": { + "action": "message", + "bundleName": "com.ohos.photos", + "abilityName": "com.ohos.photos.MainAbility", + "params": { + "message": "addDetail" + } + }, + "searchDeviceList": { + "action": "message", + "bundleName": "com.lizhiqi.card.hmservice", + "abilityName": "com.lizhiqi.card.MainAbility", + "params": { + "message": "searchList" + } + } + }, + "apiVersion": {} +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..a45f105e0631dd0ad1c34ba36d59754793bd5ba3 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "D提供方" + }, + { + "name": "description_mainability", + "value": "eTS_Empty Ability" + }, + { + "name": "description_serviceability", + "value": "hap sample empty service" + } + ] +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..6084de2e92d6f254a93a654b02701870bef66d31 Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationD/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/BUILD.gn b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..95ed0796b91884d1bb4418c235b27646d2646a3d --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/BUILD.gn @@ -0,0 +1,44 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("FormSupplyAppE") { + hap_profile = "entry/src/main/config.json" + deps = [ + ":FormOfFaEts_form_js_assets", + ":FormOfFaEts_js_assets", + ":FormOfFaEts_resources", + ] + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "FormSupplyAppE" + part_name = "prebuilt_hap" + subsystem_name = "applications" +} + +ohos_js_assets("FormOfFaEts_js_assets") { + hap_profile = "entry/src/main/config.json" + ets2abc = true + source_dir = "entry/src/main/ets" +} + +ohos_js_assets("FormOfFaEts_form_js_assets") { + hap_profile = "entry/src/main/config.json" + js2abc = true + source_dir = "entry/src/main/js" +} + +ohos_resources("FormOfFaEts_resources") { + sources = [ "entry/src/main/resources" ] + hap_profile = "entry/src/main/config.json" +} diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/Test.json b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..3ec911dfc7b3a17504cd4577be5bbabaf7f97e63 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/config.json b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..f9c45d5aa96b580a5205be3cd017b45e4675b90a --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/config.json @@ -0,0 +1,141 @@ +{ + "app": { + "bundleName": "com.form.formsystemtestservicee.hmservice", + "vendor": "ohos", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 9, + "releaseType": "Release", + "target": 9 + } + }, + "deviceConfig": {}, + "module": { + "package": "com.form.formsystemtestservicee.hmservice", + "name": ".FormSupplyAppE", + "mainAbility": ".MainAbility", + "srcPath": "", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": false + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "visible": true, + "srcPath": "MainAbility", + "name": ".MainAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:description_mainability", + "label": "$string:entry_MainAbility", + "type": "page", + "launchType": "standard" + }, + { + "name": ".FormAbility", + "srcPath": "FormAbility", + "icon": "$media:icon", + "description": "$string:description_mainability", + "label": "$string:entry_MainAbility", + "type": "service", + "formsEnabled": true, + "forms": [ + { + "jsComponentName": "widget", + "isDefault": true, + "scheduledUpdateTime": "10:30", + "formVisibleNotify": true, + "defaultDimension": "1*2", + "name": "Form_Js001", + "description": "This is a form 001", + "colorMode": "auto", + "type": "JS", + "supportDimensions": [ + "1*2", + "2*2" + ], + "updateEnabled": true, + "updateDuration": 1 + }, + { + "jsComponentName":"widget", + "isDefault":false, + "defaultDimension":"2*2", + "formVisibleNotify":true, + "name":"Form_Js002", + "colorMode":"auto", + "description":"This is a form 002", + "supportDimensions":[ + "1*2", + "2*2" + ], + "type":"JS", + "updateEnabled":true, + "updateDuration":1 + } + ], + "srcLanguage": "ets" + } + ], + "defPermissions": [ + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormSupply_commonEvent" + } + ], + "reqPermissions": [ + { + "name": "FMS_FormSupply_commonEvent", + "reason": "need use FormSupply commonEvent" + } + ], + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index", + "pages/second" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + }, + { + "pages": [ + "pages/index/index" + ], + "name": "widget", + "window": { + "designWidth": 720, + "autoDesignWidth": true + }, + "type": "form" + } + ] + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/ets/FormAbility/form.ts b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/ets/FormAbility/form.ts new file mode 100644 index 0000000000000000000000000000000000000000..df452bf7bd9f80167967751ada95c44febfaedb1 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/ets/FormAbility/form.ts @@ -0,0 +1,99 @@ +import formBindingData from '@ohos.application.formBindingData' +import commonEvent from '@ohos.commonEvent' + +let supplyForm_Event = "FMS_FormSupply_commonEvent"; + +function publishCallBack() { + console.info("!!!====>FormAbility publishCallBack====>"); +} + +export default { + onCreate(want) { + console.info('FormAbility onCreate, want:' + JSON.stringify(want)); + let formData = { + "temperature":"11c", + "time":"11:00", + "test":11, + "test3":true, + "test_over_1k":'test over 1k of data,test over 1k of data,test over 1k of data,test over 1k of data' + + 'test over 1k of data,test over 1k of data,test over 1k of data,test over 1k of data' + + 'test over 1k of data,test over 1k of data,test over 1k of data,test over 1k of data' + + 'test over 1k of data,test over 1k of data,test over 1k of data,test over 1k of data' + + 'test over 1k of data,test over 1k of data,test over 1k of data,test over 1k of data' + + 'test over 1k of data,test over 1k of data,test over 1k of data,test over 1k of data' + + 'test over 1k of data,test over 1k of data,test over 1k of data,test over 1k of data' + + 'test over 1k of data,test over 1k of data,test over 1k of data,test over 1k of data' + + 'test over 1k of data,test over 1k of data,test over 1k of data,test over 1k of data' + + 'test over 1k of data,test over 1k of data,test over 1k of data,test over 1k of data' + + 'test over 1k of data,test over 1k of data,test over 1k of data,test over 1k of data' + + 'test over 1k of data,test over 1k of' + }; + let bindingData = formBindingData.createFormBindingData(formData); + var commonEventPublishData = { + parameters: { + "kind" : "onCreate", + "parameters" : JSON.stringify(want), + "data" : JSON.stringify(formData) + } + }; + commonEvent.publish(supplyForm_Event, commonEventPublishData, publishCallBack); + return bindingData; + }, + onUpdate(formId) { + console.info('FormAbility onUpdate, formId: ' + formId); + var commonEventPublishData = { + parameters: { + "kind" : "onUpdate", + "parameters" : formId, + "data" : "" + } + }; + commonEvent.publish(supplyForm_Event, commonEventPublishData, publishCallBack); + }, + onCastToNormal(formId) { + console.info('FormAbility onCastTemp, formId: ' + formId); + + var commonEventPublishData = { + parameters: { + "kind" : "onCastToNormal", + "parameters" : formId, + "data" : "" + } + }; + commonEvent.publish(supplyForm_Event, commonEventPublishData, publishCallBack); + }, + onEvent(formId, message) { + console.info('FormAbility onTriggerEvent, formId: ' + formId + 'message: ' + message); + + var commonEventPublishData = { + parameters: { + "kind" : "onEvent", + "parameters" : formId, + "data" : message + } + }; + commonEvent.publish(supplyForm_Event, commonEventPublishData, publishCallBack); + }, + onVisibilityChange(formEvents) { + console.info('FormAbility onVisibilityChanged, ' + JSON.stringify(formEvents)); + var commonEventPublishData = { + parameters: { + "kind" : "onVisibilityChange", + "parameters" : JSON.stringify(formEvents), + "data" : "" + } + }; + commonEvent.publish(supplyForm_Event, commonEventPublishData, publishCallBack); + }, + onDestroy(formId) { + console.info('FormAbility onDestroy, formId: ' + formId); + var commonEventPublishData = { + parameters: { + "kind" : "onDestroy", + "parameters" : formId, + "data" : "" + } + }; + commonEvent.publish(supplyForm_Event, commonEventPublishData, publishCallBack); + } +}; \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/ets/MainAbility/app.ets b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..118b21a9e8f69e09b3a316b4df2279f860959042 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,23 @@ +/* + * 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. + */ + +export default { + onCreate() { + console.info('Application onCreate') + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/ets/MainAbility/pages/index.ets b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..41d8e5a6830ac26c687caf51a3c30ec33b3fe5c4 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,53 @@ +/* + * 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 '@system.router'; + +async function routePage() { + let options = { + uri: 'pages/second' + } + try { + await router.push(options) + } catch (err) { + console.error(`fail callback, code: ${err.code}, msg: ${err.msg}`) + } +} + +@Entry +@Component +struct Index { + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + routePage() + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/ets/MainAbility/pages/second.ets b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/ets/MainAbility/pages/second.ets new file mode 100644 index 0000000000000000000000000000000000000000..89533226e76331a2c0997da0bf3c9707e6c0fc2a --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/ets/MainAbility/pages/second.ets @@ -0,0 +1,44 @@ +/* + * 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 '@system.router'; + +@Entry +@Component +struct Second { + private content: string = "Second Page" + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('back to index') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + router.back() + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/image_1.png b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/image_1.png new file mode 100644 index 0000000000000000000000000000000000000000..71976f509c321f9516640d6d2f7cc6463f453578 Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/image_1.png differ diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/image_2.png b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/image_2.png new file mode 100644 index 0000000000000000000000000000000000000000..a09c3c6c71db729c613a2e6765d24dd0b06b54d8 Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/image_2.png differ diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/close.svg b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/close.svg new file mode 100644 index 0000000000000000000000000000000000000000..f4623ea319fe4f41480b086da857f23ae66e4f57 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/close.svg @@ -0,0 +1,16 @@ + + + close + + + + + + + + + + + + + \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/ic_HD1.png b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/ic_HD1.png new file mode 100644 index 0000000000000000000000000000000000000000..2d440f89ac4e1b094921c9dcd3718f550c170346 Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/ic_HD1.png differ diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/ic_box.svg b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/ic_box.svg new file mode 100644 index 0000000000000000000000000000000000000000..42c600f3d7fae00a8f271e06e3d438781a3b62e1 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/ic_box.svg @@ -0,0 +1,9 @@ + + + Device/device_filled/ic_box + + + + + + \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/ic_box1.png b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/ic_box1.png new file mode 100644 index 0000000000000000000000000000000000000000..147ec64284971fc4c51235f5d413ef1c0cb3b60e Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/ic_box1.png differ diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/ic_default_image.png b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/ic_default_image.png new file mode 100644 index 0000000000000000000000000000000000000000..07f11b1185ef9bcca89ced50219513544adb7b98 Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/ic_default_image.png differ diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/ic_default_image@3x.png b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/ic_default_image@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..11a9dd87291d31f6e90dd4648ead8429aca1ff54 Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/ic_default_image@3x.png differ diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/ic_default_white.png b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/ic_default_white.png new file mode 100644 index 0000000000000000000000000000000000000000..00b47be369e7010b4330cf7bcac16e07d8a49937 Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/ic_default_white.png differ diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/ic_device_earphone_hero_filled.svg b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/ic_device_earphone_hero_filled.svg new file mode 100644 index 0000000000000000000000000000000000000000..f190038d0cbdb2fa942030e29903a4d21a62dc76 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/ic_device_earphone_hero_filled.svg @@ -0,0 +1,10 @@ + + + Devices/Filled/ic_device_earphone_hero_filled + + + + + + + \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/ic_device_earphone_hero_filled1.png b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/ic_device_earphone_hero_filled1.png new file mode 100644 index 0000000000000000000000000000000000000000..0753761fc0db3511b55ff83923c183365b3ff69c Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/ic_device_earphone_hero_filled1.png differ diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/ic_list.svg b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/ic_list.svg new file mode 100644 index 0000000000000000000000000000000000000000..553da281ae4bf91fa43e9a5b849dd792a1e7faa7 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/ic_list.svg @@ -0,0 +1,22 @@ + + + + ic_list + Created with Sketch. + + + + \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/ic_pad.svg b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/ic_pad.svg new file mode 100644 index 0000000000000000000000000000000000000000..6fbb94db7b07820b95fe289bc95ff065ebf82fd8 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/ic_pad.svg @@ -0,0 +1,8 @@ + + + Device/device_filled/ic_pad + + + + + \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/ic_pad1.png b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/ic_pad1.png new file mode 100644 index 0000000000000000000000000000000000000000..9156a9362ac30fe368f162a911a02f4ff72bbffb Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/ic_pad1.png differ diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/ic_pc.svg b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/ic_pc.svg new file mode 100644 index 0000000000000000000000000000000000000000..ebb6a162c21781f741e58a487e426b5a8fb3472e --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/ic_pc.svg @@ -0,0 +1,10 @@ + + + Device/device_filled/ic_pc + + + + + + + \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/ic_pc1.png b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/ic_pc1.png new file mode 100644 index 0000000000000000000000000000000000000000..8328aa1454f44122ca88b2e6047db02189c8df3b Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/ic_pc1.png differ diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/ic_public_search.svg b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/ic_public_search.svg new file mode 100644 index 0000000000000000000000000000000000000000..98d04d8d590343410eb1821173d70b3237343e31 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/ic_public_search.svg @@ -0,0 +1,13 @@ + + + Public/ic_public_search + + + + + + + + + + \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/ic_selfie.png b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/ic_selfie.png new file mode 100644 index 0000000000000000000000000000000000000000..9048642794b088557e7e88010422d8eb7f418fa6 Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/ic_selfie.png differ diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/ic_tv.svg b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/ic_tv.svg new file mode 100644 index 0000000000000000000000000000000000000000..afe607222b97ef6bcf89a3affbea8eaf36a819ff --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/ic_tv.svg @@ -0,0 +1,10 @@ + + + Device/device_filled/ic_tv + + + + + + + \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/ic_vision.svg b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/ic_vision.svg new file mode 100644 index 0000000000000000000000000000000000000000..95f75bf2298db8bf39929596b2c708fbb617be80 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/ic_vision.svg @@ -0,0 +1,29 @@ + + + ic_vision + + + + + \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/search.svg b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/search.svg new file mode 100644 index 0000000000000000000000000000000000000000..d475fe3a6622465b7e1e3c8463de3fe7530dafa2 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/search.svg @@ -0,0 +1,20 @@ + + + svgProgressBar/circle/normal备份 + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/superdevice.svg b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/superdevice.svg new file mode 100644 index 0000000000000000000000000000000000000000..66e1e624d8c4884a661a1fe278b798a33e79d1cb --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/superdevice.svg @@ -0,0 +1,9 @@ + + + superdevice + + + + + + \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/template.png b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/template.png new file mode 100644 index 0000000000000000000000000000000000000000..c13bb4d340435b2e8d8fd90660ffc9916e1f6d68 Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/common/img/template.png differ diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/manifest.json b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/manifest.json new file mode 100644 index 0000000000000000000000000000000000000000..a27710a2f3126ba1eb0ac2cd2d65133e38ddc8b9 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/manifest.json @@ -0,0 +1 @@ +{"appID": "com.example.myapplication","appName": "$string:entry_MainAbility","versionName": "1.0.0","versionCode": 1000000,"minPlatformVersion": 7,"pages": ["pages/index/index"],"deviceType": ["phone"],"type": "form","window": {"autoDesignWidth": true,"designWidth": 720}} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/pages/index/index.json b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/pages/index/index.json new file mode 100644 index 0000000000000000000000000000000000000000..3c42b73a47e817737770dd731b6f207796115f07 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/js/widget/pages/index/index.json @@ -0,0 +1,234 @@ +{ + "template": { + "attr": {}, + "type": "div", + "classList": [ + "container" + ], + "children": [ + { + "attr": {}, + "type": "div", + "classList": [ + "bottom" + ], + "style": { + "display": "{{isShow}}" + }, + "children": [ + { + "attr": {}, + "type": "div", + "classList": [ + "bg_color" + ], + "events": { + "click": "routerEvent" + }, + "children": [ + { + "attr": { + "src": "/common/img/ic_pad.svg" + }, + "type": "image", + "classList": [ + "img1" + ] + } + ] + }, + { + "attr": {}, + "type": "div", + "classList": [ + "pic_title_container" + ], + "children": [ + { + "attr": {}, + "type": "div", + "style": { + "flexDirection": "column" + }, + "children": [ + { + "attr": { + "value": "{{temperature}}" + }, + "type": "text", + "classList": [ + "title" + ] + }, + { + "attr": { + "value": "{{time}}" + }, + "type": "text", + "classList": [ + "content" + ] + }, + { + "attr": { + "src": "{{image1}}" + }, + "type": "image", + "classList": [ + "title" + ] + } + ] + } + ] + } + ] + } + ] + }, + "styles": { + ".container": { + "display": "flex", + "flexDirection": "column", + "left": "0px", + "top": "0px", + "width": "640vp", + "backgroundColor": "#eeeeee" + }, + ".pic_title_container": { + "backgroundColor": "#FF007DFB", + "flexDirection": "column", + "height": "100%", + "paddingTop": "12px", + "paddingStart": "12px", + "paddingBottom": "12px", + "justifyContent": "space-between" + }, + ".content": { + "fontSize": "12px", + "color": "#99ffffff", + "textOverflow": "ellipsis", + "maxLines": "1" + }, + ".title": { + "fontSize": "16px", + "color": "#e5ffffff", + "marginBottom": "2px" + }, + ".head": { + "width": "90%", + "height": "70vp", + "display": "flex", + "marginTop": "8px", + "justifyContent": "space-between", + "alignItems": "center" + }, + ".right": { + "flexGrow": 1, + "marginLeft": "260vp" + }, + ".img": { + "marginLeft": "48vp", + "marginTop": "5px", + "width": "36vp", + "height": "36vp" + }, + ".bottom": { + "marginTop": "-12px", + "width": "90%", + "display": "flex", + "flexDirection": "column", + "marginLeft": "30px" + }, + ".bg_color": { + "width": "48vp", + "height": "48vp", + "borderBottomLeftRadius": "48px", + "borderBottomRightRadius": "48px", + "borderTopLeftRadius": "48px", + "borderTopRightRadius": "48px", + "backgroundColor": "#cccccc", + "marginLeft": "36%" + }, + ".img1": { + "marginTop": "14vp", + "marginLeft": "14vp" + }, + ".text": { + "marginTop": "16px", + "fontSize": "12px", + "display": "flex", + "justifyContent": "center" + }, + ".co_blue": { + "marginLeft": "12px", + "color": "#1e90ff" + }, + ".todo-wrapper": { + "marginTop": "0vp", + "display": "flex", + "flexDirection": "row", + "width": "80%" + }, + ".todo-item": { + "width": "85vp", + "display": "flex", + "flexDirection": "column", + "marginRight": "10px", + "alignItems": "center" + }, + ".bg_color1": { + "width": "48vp", + "height": "48vp", + "borderBottomLeftRadius": "48px", + "borderBottomRightRadius": "48px", + "borderTopLeftRadius": "48px", + "borderTopRightRadius": "48px", + "backgroundColor": "#cccccc", + "marginBottom": "6vp" + }, + ".title_img": { + "marginTop": "14vp", + "marginLeft": "11vp" + }, + ".todo-title": { + "textAlign": "center", + "fontSize": "10px", + "color": "#E5000000" + } + }, + "data": { + "temperature": "超级终端", + "time": "qqqq", + "ifShow": "none", + "image1": "memory://image1", + "isShow": "flex", + "deviceList": [ + { + "img": "/common/img/ic_pad.svg", + "deviceName": "huawei", + "deviceType": 17, + "deviceId": 1 + } + ] + }, + "actions": { + "routerEvent": { + "action": "message", + "bundleName": "com.ohos.photos", + "abilityName": "com.ohos.photos.MainAbility", + "params": { + "message": "addDetail" + } + }, + "searchDeviceList": { + "action": "message", + "bundleName": "com.lizhiqi.card.hmservice", + "abilityName": "com.lizhiqi.card.MainAbility", + "params": { + "message": "searchList" + } + } + }, + "apiVersion": {} +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..b0e7e3905b9f6f4ffd28fb0f8a2e7ce585cf2ac6 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "A提供方" + }, + { + "name": "description_mainability", + "value": "eTS_Empty Ability" + }, + { + "name": "description_serviceability", + "value": "hap sample empty service" + } + ] +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..6084de2e92d6f254a93a654b02701870bef66d31 Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationE/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/BUILD.gn b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..92bf3940f099c960003a1ecdc9c241e1412c6206 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/BUILD.gn @@ -0,0 +1,44 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("FormSupplyAppH") { + hap_profile = "entry/src/main/config.json" + deps = [ + ":FormOfFaEts_form_js_assets", + ":FormOfFaEts_js_assets", + ":FormOfFaEts_resources", + ] + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "FormSupplyAppH" + part_name = "prebuilt_hap" + subsystem_name = "applications" +} + +ohos_js_assets("FormOfFaEts_js_assets") { + hap_profile = "entry/src/main/config.json" + ets2abc = true + source_dir = "entry/src/main/ets" +} + +ohos_js_assets("FormOfFaEts_form_js_assets") { + hap_profile = "entry/src/main/config.json" + js2abc = true + source_dir = "entry/src/main/js" +} + +ohos_resources("FormOfFaEts_resources") { + sources = [ "entry/src/main/resources" ] + hap_profile = "entry/src/main/config.json" +} diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/Test.json b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..3ec911dfc7b3a17504cd4577be5bbabaf7f97e63 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/config.json b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..8b65064d6fa24e3314f82d68a3e6c23c3cfb95fd --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/config.json @@ -0,0 +1,141 @@ +{ + "app": { + "bundleName": "com.form.formsystemtestserviceh.hmservice", + "vendor": "ohos", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 9, + "releaseType": "Release", + "target": 9 + } + }, + "deviceConfig": {}, + "module": { + "package": "com.form.formsystemtestserviceh.hmservice", + "name": ".FormSupplyAppH", + "mainAbility": ".MainAbility", + "srcPath": "", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": false + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "visible": true, + "srcPath": "MainAbility", + "name": ".MainAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:description_mainability", + "label": "$string:entry_MainAbility", + "type": "page", + "launchType": "standard" + }, + { + "name": ".FormAbility", + "srcPath": "FormAbility", + "icon": "$media:icon", + "description": "$string:description_mainability", + "label": "$string:entry_MainAbility", + "type": "service", + "formsEnabled": true, + "forms": [ + { + "jsComponentName": "widget", + "isDefault": true, + "scheduledUpdateTime": "10:30", + "formVisibleNotify": true, + "defaultDimension": "1*2", + "name": "Form_Js001", + "description": "This is a form 001", + "colorMode": "auto", + "type": "JS", + "supportDimensions": [ + "1*2", + "2*2" + ], + "updateEnabled": true, + "updateDuration": 1 + }, + { + "jsComponentName":"widget", + "isDefault":false, + "defaultDimension":"2*2", + "formVisibleNotify":true, + "name":"Form_Js002", + "colorMode":"auto", + "description":"This is a form 002", + "supportDimensions":[ + "1*2", + "2*2" + ], + "type":"JS", + "updateEnabled":true, + "updateDuration":1 + } + ], + "srcLanguage": "ets" + } + ], + "defPermissions": [ + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormSupply_commonEvent" + } + ], + "reqPermissions": [ + { + "name": "FMS_FormSupply_commonEvent", + "reason": "need use FormSupply commonEvent" + } + ], + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index", + "pages/second" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + }, + { + "pages": [ + "pages/index/index" + ], + "name": "widget", + "window": { + "designWidth": 720, + "autoDesignWidth": true + }, + "type": "form" + } + ] + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/ets/FormAbility/form.ts b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/ets/FormAbility/form.ts new file mode 100644 index 0000000000000000000000000000000000000000..df452bf7bd9f80167967751ada95c44febfaedb1 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/ets/FormAbility/form.ts @@ -0,0 +1,99 @@ +import formBindingData from '@ohos.application.formBindingData' +import commonEvent from '@ohos.commonEvent' + +let supplyForm_Event = "FMS_FormSupply_commonEvent"; + +function publishCallBack() { + console.info("!!!====>FormAbility publishCallBack====>"); +} + +export default { + onCreate(want) { + console.info('FormAbility onCreate, want:' + JSON.stringify(want)); + let formData = { + "temperature":"11c", + "time":"11:00", + "test":11, + "test3":true, + "test_over_1k":'test over 1k of data,test over 1k of data,test over 1k of data,test over 1k of data' + + 'test over 1k of data,test over 1k of data,test over 1k of data,test over 1k of data' + + 'test over 1k of data,test over 1k of data,test over 1k of data,test over 1k of data' + + 'test over 1k of data,test over 1k of data,test over 1k of data,test over 1k of data' + + 'test over 1k of data,test over 1k of data,test over 1k of data,test over 1k of data' + + 'test over 1k of data,test over 1k of data,test over 1k of data,test over 1k of data' + + 'test over 1k of data,test over 1k of data,test over 1k of data,test over 1k of data' + + 'test over 1k of data,test over 1k of data,test over 1k of data,test over 1k of data' + + 'test over 1k of data,test over 1k of data,test over 1k of data,test over 1k of data' + + 'test over 1k of data,test over 1k of data,test over 1k of data,test over 1k of data' + + 'test over 1k of data,test over 1k of data,test over 1k of data,test over 1k of data' + + 'test over 1k of data,test over 1k of' + }; + let bindingData = formBindingData.createFormBindingData(formData); + var commonEventPublishData = { + parameters: { + "kind" : "onCreate", + "parameters" : JSON.stringify(want), + "data" : JSON.stringify(formData) + } + }; + commonEvent.publish(supplyForm_Event, commonEventPublishData, publishCallBack); + return bindingData; + }, + onUpdate(formId) { + console.info('FormAbility onUpdate, formId: ' + formId); + var commonEventPublishData = { + parameters: { + "kind" : "onUpdate", + "parameters" : formId, + "data" : "" + } + }; + commonEvent.publish(supplyForm_Event, commonEventPublishData, publishCallBack); + }, + onCastToNormal(formId) { + console.info('FormAbility onCastTemp, formId: ' + formId); + + var commonEventPublishData = { + parameters: { + "kind" : "onCastToNormal", + "parameters" : formId, + "data" : "" + } + }; + commonEvent.publish(supplyForm_Event, commonEventPublishData, publishCallBack); + }, + onEvent(formId, message) { + console.info('FormAbility onTriggerEvent, formId: ' + formId + 'message: ' + message); + + var commonEventPublishData = { + parameters: { + "kind" : "onEvent", + "parameters" : formId, + "data" : message + } + }; + commonEvent.publish(supplyForm_Event, commonEventPublishData, publishCallBack); + }, + onVisibilityChange(formEvents) { + console.info('FormAbility onVisibilityChanged, ' + JSON.stringify(formEvents)); + var commonEventPublishData = { + parameters: { + "kind" : "onVisibilityChange", + "parameters" : JSON.stringify(formEvents), + "data" : "" + } + }; + commonEvent.publish(supplyForm_Event, commonEventPublishData, publishCallBack); + }, + onDestroy(formId) { + console.info('FormAbility onDestroy, formId: ' + formId); + var commonEventPublishData = { + parameters: { + "kind" : "onDestroy", + "parameters" : formId, + "data" : "" + } + }; + commonEvent.publish(supplyForm_Event, commonEventPublishData, publishCallBack); + } +}; \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/ets/MainAbility/app.ets b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..118b21a9e8f69e09b3a316b4df2279f860959042 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,23 @@ +/* + * 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. + */ + +export default { + onCreate() { + console.info('Application onCreate') + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/ets/MainAbility/pages/index.ets b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..41d8e5a6830ac26c687caf51a3c30ec33b3fe5c4 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,53 @@ +/* + * 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 '@system.router'; + +async function routePage() { + let options = { + uri: 'pages/second' + } + try { + await router.push(options) + } catch (err) { + console.error(`fail callback, code: ${err.code}, msg: ${err.msg}`) + } +} + +@Entry +@Component +struct Index { + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + routePage() + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/ets/MainAbility/pages/second.ets b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/ets/MainAbility/pages/second.ets new file mode 100644 index 0000000000000000000000000000000000000000..89533226e76331a2c0997da0bf3c9707e6c0fc2a --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/ets/MainAbility/pages/second.ets @@ -0,0 +1,44 @@ +/* + * 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 '@system.router'; + +@Entry +@Component +struct Second { + private content: string = "Second Page" + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('back to index') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + router.back() + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/image_1.png b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/image_1.png new file mode 100644 index 0000000000000000000000000000000000000000..71976f509c321f9516640d6d2f7cc6463f453578 Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/image_1.png differ diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/image_2.png b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/image_2.png new file mode 100644 index 0000000000000000000000000000000000000000..a09c3c6c71db729c613a2e6765d24dd0b06b54d8 Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/image_2.png differ diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/close.svg b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/close.svg new file mode 100644 index 0000000000000000000000000000000000000000..f4623ea319fe4f41480b086da857f23ae66e4f57 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/close.svg @@ -0,0 +1,16 @@ + + + close + + + + + + + + + + + + + \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/ic_HD1.png b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/ic_HD1.png new file mode 100644 index 0000000000000000000000000000000000000000..2d440f89ac4e1b094921c9dcd3718f550c170346 Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/ic_HD1.png differ diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/ic_box.svg b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/ic_box.svg new file mode 100644 index 0000000000000000000000000000000000000000..42c600f3d7fae00a8f271e06e3d438781a3b62e1 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/ic_box.svg @@ -0,0 +1,9 @@ + + + Device/device_filled/ic_box + + + + + + \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/ic_box1.png b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/ic_box1.png new file mode 100644 index 0000000000000000000000000000000000000000..147ec64284971fc4c51235f5d413ef1c0cb3b60e Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/ic_box1.png differ diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/ic_default_image.png b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/ic_default_image.png new file mode 100644 index 0000000000000000000000000000000000000000..07f11b1185ef9bcca89ced50219513544adb7b98 Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/ic_default_image.png differ diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/ic_default_image@3x.png b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/ic_default_image@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..11a9dd87291d31f6e90dd4648ead8429aca1ff54 Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/ic_default_image@3x.png differ diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/ic_default_white.png b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/ic_default_white.png new file mode 100644 index 0000000000000000000000000000000000000000..00b47be369e7010b4330cf7bcac16e07d8a49937 Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/ic_default_white.png differ diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/ic_device_earphone_hero_filled.svg b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/ic_device_earphone_hero_filled.svg new file mode 100644 index 0000000000000000000000000000000000000000..f190038d0cbdb2fa942030e29903a4d21a62dc76 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/ic_device_earphone_hero_filled.svg @@ -0,0 +1,10 @@ + + + Devices/Filled/ic_device_earphone_hero_filled + + + + + + + \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/ic_device_earphone_hero_filled1.png b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/ic_device_earphone_hero_filled1.png new file mode 100644 index 0000000000000000000000000000000000000000..0753761fc0db3511b55ff83923c183365b3ff69c Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/ic_device_earphone_hero_filled1.png differ diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/ic_list.svg b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/ic_list.svg new file mode 100644 index 0000000000000000000000000000000000000000..553da281ae4bf91fa43e9a5b849dd792a1e7faa7 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/ic_list.svg @@ -0,0 +1,22 @@ + + + + ic_list + Created with Sketch. + + + + \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/ic_pad.svg b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/ic_pad.svg new file mode 100644 index 0000000000000000000000000000000000000000..6fbb94db7b07820b95fe289bc95ff065ebf82fd8 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/ic_pad.svg @@ -0,0 +1,8 @@ + + + Device/device_filled/ic_pad + + + + + \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/ic_pad1.png b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/ic_pad1.png new file mode 100644 index 0000000000000000000000000000000000000000..9156a9362ac30fe368f162a911a02f4ff72bbffb Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/ic_pad1.png differ diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/ic_pc.svg b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/ic_pc.svg new file mode 100644 index 0000000000000000000000000000000000000000..ebb6a162c21781f741e58a487e426b5a8fb3472e --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/ic_pc.svg @@ -0,0 +1,10 @@ + + + Device/device_filled/ic_pc + + + + + + + \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/ic_pc1.png b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/ic_pc1.png new file mode 100644 index 0000000000000000000000000000000000000000..8328aa1454f44122ca88b2e6047db02189c8df3b Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/ic_pc1.png differ diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/ic_public_search.svg b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/ic_public_search.svg new file mode 100644 index 0000000000000000000000000000000000000000..98d04d8d590343410eb1821173d70b3237343e31 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/ic_public_search.svg @@ -0,0 +1,13 @@ + + + Public/ic_public_search + + + + + + + + + + \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/ic_selfie.png b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/ic_selfie.png new file mode 100644 index 0000000000000000000000000000000000000000..9048642794b088557e7e88010422d8eb7f418fa6 Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/ic_selfie.png differ diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/ic_tv.svg b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/ic_tv.svg new file mode 100644 index 0000000000000000000000000000000000000000..afe607222b97ef6bcf89a3affbea8eaf36a819ff --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/ic_tv.svg @@ -0,0 +1,10 @@ + + + Device/device_filled/ic_tv + + + + + + + \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/ic_vision.svg b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/ic_vision.svg new file mode 100644 index 0000000000000000000000000000000000000000..95f75bf2298db8bf39929596b2c708fbb617be80 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/ic_vision.svg @@ -0,0 +1,29 @@ + + + ic_vision + + + + + \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/search.svg b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/search.svg new file mode 100644 index 0000000000000000000000000000000000000000..d475fe3a6622465b7e1e3c8463de3fe7530dafa2 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/search.svg @@ -0,0 +1,20 @@ + + + svgProgressBar/circle/normal备份 + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/superdevice.svg b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/superdevice.svg new file mode 100644 index 0000000000000000000000000000000000000000..66e1e624d8c4884a661a1fe278b798a33e79d1cb --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/superdevice.svg @@ -0,0 +1,9 @@ + + + superdevice + + + + + + \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/template.png b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/template.png new file mode 100644 index 0000000000000000000000000000000000000000..c13bb4d340435b2e8d8fd90660ffc9916e1f6d68 Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/common/img/template.png differ diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/manifest.json b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/manifest.json new file mode 100644 index 0000000000000000000000000000000000000000..a27710a2f3126ba1eb0ac2cd2d65133e38ddc8b9 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/manifest.json @@ -0,0 +1 @@ +{"appID": "com.example.myapplication","appName": "$string:entry_MainAbility","versionName": "1.0.0","versionCode": 1000000,"minPlatformVersion": 7,"pages": ["pages/index/index"],"deviceType": ["phone"],"type": "form","window": {"autoDesignWidth": true,"designWidth": 720}} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/pages/index/index.json b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/pages/index/index.json new file mode 100644 index 0000000000000000000000000000000000000000..3c42b73a47e817737770dd731b6f207796115f07 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/js/widget/pages/index/index.json @@ -0,0 +1,234 @@ +{ + "template": { + "attr": {}, + "type": "div", + "classList": [ + "container" + ], + "children": [ + { + "attr": {}, + "type": "div", + "classList": [ + "bottom" + ], + "style": { + "display": "{{isShow}}" + }, + "children": [ + { + "attr": {}, + "type": "div", + "classList": [ + "bg_color" + ], + "events": { + "click": "routerEvent" + }, + "children": [ + { + "attr": { + "src": "/common/img/ic_pad.svg" + }, + "type": "image", + "classList": [ + "img1" + ] + } + ] + }, + { + "attr": {}, + "type": "div", + "classList": [ + "pic_title_container" + ], + "children": [ + { + "attr": {}, + "type": "div", + "style": { + "flexDirection": "column" + }, + "children": [ + { + "attr": { + "value": "{{temperature}}" + }, + "type": "text", + "classList": [ + "title" + ] + }, + { + "attr": { + "value": "{{time}}" + }, + "type": "text", + "classList": [ + "content" + ] + }, + { + "attr": { + "src": "{{image1}}" + }, + "type": "image", + "classList": [ + "title" + ] + } + ] + } + ] + } + ] + } + ] + }, + "styles": { + ".container": { + "display": "flex", + "flexDirection": "column", + "left": "0px", + "top": "0px", + "width": "640vp", + "backgroundColor": "#eeeeee" + }, + ".pic_title_container": { + "backgroundColor": "#FF007DFB", + "flexDirection": "column", + "height": "100%", + "paddingTop": "12px", + "paddingStart": "12px", + "paddingBottom": "12px", + "justifyContent": "space-between" + }, + ".content": { + "fontSize": "12px", + "color": "#99ffffff", + "textOverflow": "ellipsis", + "maxLines": "1" + }, + ".title": { + "fontSize": "16px", + "color": "#e5ffffff", + "marginBottom": "2px" + }, + ".head": { + "width": "90%", + "height": "70vp", + "display": "flex", + "marginTop": "8px", + "justifyContent": "space-between", + "alignItems": "center" + }, + ".right": { + "flexGrow": 1, + "marginLeft": "260vp" + }, + ".img": { + "marginLeft": "48vp", + "marginTop": "5px", + "width": "36vp", + "height": "36vp" + }, + ".bottom": { + "marginTop": "-12px", + "width": "90%", + "display": "flex", + "flexDirection": "column", + "marginLeft": "30px" + }, + ".bg_color": { + "width": "48vp", + "height": "48vp", + "borderBottomLeftRadius": "48px", + "borderBottomRightRadius": "48px", + "borderTopLeftRadius": "48px", + "borderTopRightRadius": "48px", + "backgroundColor": "#cccccc", + "marginLeft": "36%" + }, + ".img1": { + "marginTop": "14vp", + "marginLeft": "14vp" + }, + ".text": { + "marginTop": "16px", + "fontSize": "12px", + "display": "flex", + "justifyContent": "center" + }, + ".co_blue": { + "marginLeft": "12px", + "color": "#1e90ff" + }, + ".todo-wrapper": { + "marginTop": "0vp", + "display": "flex", + "flexDirection": "row", + "width": "80%" + }, + ".todo-item": { + "width": "85vp", + "display": "flex", + "flexDirection": "column", + "marginRight": "10px", + "alignItems": "center" + }, + ".bg_color1": { + "width": "48vp", + "height": "48vp", + "borderBottomLeftRadius": "48px", + "borderBottomRightRadius": "48px", + "borderTopLeftRadius": "48px", + "borderTopRightRadius": "48px", + "backgroundColor": "#cccccc", + "marginBottom": "6vp" + }, + ".title_img": { + "marginTop": "14vp", + "marginLeft": "11vp" + }, + ".todo-title": { + "textAlign": "center", + "fontSize": "10px", + "color": "#E5000000" + } + }, + "data": { + "temperature": "超级终端", + "time": "qqqq", + "ifShow": "none", + "image1": "memory://image1", + "isShow": "flex", + "deviceList": [ + { + "img": "/common/img/ic_pad.svg", + "deviceName": "huawei", + "deviceType": 17, + "deviceId": 1 + } + ] + }, + "actions": { + "routerEvent": { + "action": "message", + "bundleName": "com.ohos.photos", + "abilityName": "com.ohos.photos.MainAbility", + "params": { + "message": "addDetail" + } + }, + "searchDeviceList": { + "action": "message", + "bundleName": "com.lizhiqi.card.hmservice", + "abilityName": "com.lizhiqi.card.MainAbility", + "params": { + "message": "searchList" + } + } + }, + "apiVersion": {} +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..30145204027130827e3e1c7c61d1fb91d9a5c7ad --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "H提供方" + }, + { + "name": "description_mainability", + "value": "eTS_Empty Ability" + }, + { + "name": "description_serviceability", + "value": "hap sample empty service" + } + ] +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..6084de2e92d6f254a93a654b02701870bef66d31 Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationH/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationNotSysApp/BUILD.gn b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationNotSysApp/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..6f103f4a2cd05645264b77eb5c4bd6770df32da1 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationNotSysApp/BUILD.gn @@ -0,0 +1,44 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("FormSupplyAppNS") { + hap_profile = "entry/src/main/config.json" + deps = [ + ":FormOfFaEts_form_js_assets", + ":FormOfFaEts_js_assets", + ":FormOfFaEts_resources", + ] + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "FormSupplyAppNS" + part_name = "prebuilt_hap" + subsystem_name = "applications" +} + +ohos_js_assets("FormOfFaEts_js_assets") { + hap_profile = "entry/src/main/config.json" + ets2abc = true + source_dir = "entry/src/main/ets" +} + +ohos_js_assets("FormOfFaEts_form_js_assets") { + hap_profile = "entry/src/main/config.json" + js2abc = true + source_dir = "entry/src/main/js" +} + +ohos_resources("FormOfFaEts_resources") { + sources = [ "entry/src/main/resources" ] + hap_profile = "entry/src/main/config.json" +} diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationNotSysApp/Test.json b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationNotSysApp/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..3ec911dfc7b3a17504cd4577be5bbabaf7f97e63 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationNotSysApp/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationNotSysApp/entry/src/main/config.json b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationNotSysApp/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..ce21273b4bbb9e5539316415e4cd6ef53444cf0a --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationNotSysApp/entry/src/main/config.json @@ -0,0 +1,141 @@ +{ + "app": { + "bundleName": "com.form.formsystemtestservicenotsysapp.hmservice", + "vendor": "ohos", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 9, + "releaseType": "Release", + "target": 9 + } + }, + "deviceConfig": {}, + "module": { + "package": "com.form.formsystemtestservicenotsysapp.hmservice", + "name": ".FormSupplyAppNS", + "mainAbility": ".MainAbility", + "srcPath": "", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": false + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "visible": true, + "srcPath": "MainAbility", + "name": ".MainAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:description_mainability", + "label": "$string:entry_MainAbility", + "type": "page", + "launchType": "standard" + }, + { + "name": ".FormAbility", + "srcPath": "FormAbility", + "icon": "$media:icon", + "description": "$string:description_mainability", + "label": "$string:entry_MainAbility", + "type": "service", + "formsEnabled": true, + "forms": [ + { + "jsComponentName": "Form_Js001", + "isDefault": true, + "scheduledUpdateTime": "10:30", + "formVisibleNotify": true, + "defaultDimension": "1*2", + "name": "Form_Js001", + "description": "This is a form 001", + "colorMode": "auto", + "type": "JS", + "supportDimensions": [ + "1*2", + "2*2" + ], + "updateEnabled": true, + "updateDuration": 1 + }, + { + "jsComponentName":"Form_Js002", + "isDefault":false, + "defaultDimension":"2*2", + "formVisibleNotify":true, + "name":"Form_Js002", + "colorMode":"auto", + "description":"This is a form 002", + "supportDimensions":[ + "1*2", + "2*2" + ], + "type":"JS", + "updateEnabled":true, + "updateDuration":1 + } + ], + "srcLanguage": "ets" + } + ], + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index", + "pages/second" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + }, + { + "pages": [ + "pages/index/index" + ], + "name": "Form_Js001", + "window": { + "designWidth": 720, + "autoDesignWidth": true + }, + "type": "form" + } + ], + "defPermissions": [ + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormSupply_commonEvent" + } + ], + "reqPermissions": [ + { + "reason": "need use FormSupply commonEvent", + "name": "FMS_FormSupply_commonEvent" + } + ] + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationNotSysApp/entry/src/main/ets/FormAbility/form.ts b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationNotSysApp/entry/src/main/ets/FormAbility/form.ts new file mode 100644 index 0000000000000000000000000000000000000000..df452bf7bd9f80167967751ada95c44febfaedb1 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationNotSysApp/entry/src/main/ets/FormAbility/form.ts @@ -0,0 +1,99 @@ +import formBindingData from '@ohos.application.formBindingData' +import commonEvent from '@ohos.commonEvent' + +let supplyForm_Event = "FMS_FormSupply_commonEvent"; + +function publishCallBack() { + console.info("!!!====>FormAbility publishCallBack====>"); +} + +export default { + onCreate(want) { + console.info('FormAbility onCreate, want:' + JSON.stringify(want)); + let formData = { + "temperature":"11c", + "time":"11:00", + "test":11, + "test3":true, + "test_over_1k":'test over 1k of data,test over 1k of data,test over 1k of data,test over 1k of data' + + 'test over 1k of data,test over 1k of data,test over 1k of data,test over 1k of data' + + 'test over 1k of data,test over 1k of data,test over 1k of data,test over 1k of data' + + 'test over 1k of data,test over 1k of data,test over 1k of data,test over 1k of data' + + 'test over 1k of data,test over 1k of data,test over 1k of data,test over 1k of data' + + 'test over 1k of data,test over 1k of data,test over 1k of data,test over 1k of data' + + 'test over 1k of data,test over 1k of data,test over 1k of data,test over 1k of data' + + 'test over 1k of data,test over 1k of data,test over 1k of data,test over 1k of data' + + 'test over 1k of data,test over 1k of data,test over 1k of data,test over 1k of data' + + 'test over 1k of data,test over 1k of data,test over 1k of data,test over 1k of data' + + 'test over 1k of data,test over 1k of data,test over 1k of data,test over 1k of data' + + 'test over 1k of data,test over 1k of' + }; + let bindingData = formBindingData.createFormBindingData(formData); + var commonEventPublishData = { + parameters: { + "kind" : "onCreate", + "parameters" : JSON.stringify(want), + "data" : JSON.stringify(formData) + } + }; + commonEvent.publish(supplyForm_Event, commonEventPublishData, publishCallBack); + return bindingData; + }, + onUpdate(formId) { + console.info('FormAbility onUpdate, formId: ' + formId); + var commonEventPublishData = { + parameters: { + "kind" : "onUpdate", + "parameters" : formId, + "data" : "" + } + }; + commonEvent.publish(supplyForm_Event, commonEventPublishData, publishCallBack); + }, + onCastToNormal(formId) { + console.info('FormAbility onCastTemp, formId: ' + formId); + + var commonEventPublishData = { + parameters: { + "kind" : "onCastToNormal", + "parameters" : formId, + "data" : "" + } + }; + commonEvent.publish(supplyForm_Event, commonEventPublishData, publishCallBack); + }, + onEvent(formId, message) { + console.info('FormAbility onTriggerEvent, formId: ' + formId + 'message: ' + message); + + var commonEventPublishData = { + parameters: { + "kind" : "onEvent", + "parameters" : formId, + "data" : message + } + }; + commonEvent.publish(supplyForm_Event, commonEventPublishData, publishCallBack); + }, + onVisibilityChange(formEvents) { + console.info('FormAbility onVisibilityChanged, ' + JSON.stringify(formEvents)); + var commonEventPublishData = { + parameters: { + "kind" : "onVisibilityChange", + "parameters" : JSON.stringify(formEvents), + "data" : "" + } + }; + commonEvent.publish(supplyForm_Event, commonEventPublishData, publishCallBack); + }, + onDestroy(formId) { + console.info('FormAbility onDestroy, formId: ' + formId); + var commonEventPublishData = { + parameters: { + "kind" : "onDestroy", + "parameters" : formId, + "data" : "" + } + }; + commonEvent.publish(supplyForm_Event, commonEventPublishData, publishCallBack); + } +}; \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationNotSysApp/entry/src/main/ets/MainAbility/app.ets b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationNotSysApp/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..118b21a9e8f69e09b3a316b4df2279f860959042 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationNotSysApp/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,23 @@ +/* + * 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. + */ + +export default { + onCreate() { + console.info('Application onCreate') + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationNotSysApp/entry/src/main/ets/MainAbility/pages/index.ets b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationNotSysApp/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..41d8e5a6830ac26c687caf51a3c30ec33b3fe5c4 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationNotSysApp/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,53 @@ +/* + * 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 '@system.router'; + +async function routePage() { + let options = { + uri: 'pages/second' + } + try { + await router.push(options) + } catch (err) { + console.error(`fail callback, code: ${err.code}, msg: ${err.msg}`) + } +} + +@Entry +@Component +struct Index { + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + routePage() + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationNotSysApp/entry/src/main/ets/MainAbility/pages/second.ets b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationNotSysApp/entry/src/main/ets/MainAbility/pages/second.ets new file mode 100644 index 0000000000000000000000000000000000000000..89533226e76331a2c0997da0bf3c9707e6c0fc2a --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationNotSysApp/entry/src/main/ets/MainAbility/pages/second.ets @@ -0,0 +1,44 @@ +/* + * 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 '@system.router'; + +@Entry +@Component +struct Second { + private content: string = "Second Page" + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('back to index') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + router.back() + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationNotSysApp/entry/src/main/js/Form_Js001/pages/index/index.css b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationNotSysApp/entry/src/main/js/Form_Js001/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..4a7a725b77a0209e0fd19d7872c8d2493ca888bc --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationNotSysApp/entry/src/main/js/Form_Js001/pages/index/index.css @@ -0,0 +1,19 @@ +#wrapper { + flex-direction: column; +} + +#div1 { + width: 100%; + height: 100%; + justify-content: center; + align-items: center; + background-color: white; +} + +#text1 { + height: 45px; + width: 150px; + font-size: 16px; + text-align: center; +} + diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationNotSysApp/entry/src/main/js/Form_Js001/pages/index/index.hml b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationNotSysApp/entry/src/main/js/Form_Js001/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..cd6106fe7f4cd3e951126de70065073f0bd10a95 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationNotSysApp/entry/src/main/js/Form_Js001/pages/index/index.hml @@ -0,0 +1,7 @@ +
+
+
+ {{title}} +
+
+
\ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationNotSysApp/entry/src/main/js/Form_Js001/pages/index/index.json b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationNotSysApp/entry/src/main/js/Form_Js001/pages/index/index.json new file mode 100644 index 0000000000000000000000000000000000000000..376c97a90068b93e4440f5c228289818c62db66b --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationNotSysApp/entry/src/main/js/Form_Js001/pages/index/index.json @@ -0,0 +1,6 @@ +{ + "actions": {}, + "data": { + "title": "Hello World" + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationNotSysApp/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationNotSysApp/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..fd46026c39fe3454a5a4f54c2415a43bf1a3e6d0 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationNotSysApp/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "NS提供方" + }, + { + "name": "description_mainability", + "value": "eTS_Empty Ability" + }, + { + "name": "description_serviceability", + "value": "hap sample empty service" + } + ] +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationNotSysApp/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationNotSysApp/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationNotSysApp/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationNotSysApp/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationNotSysApp/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..f06e218defa7f707e22a3890903c574e1c498217 Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formproviderst_ets/formsupplyapplicationNotSysApp/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_disable/BUILD.gn b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_disable/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..07806903ba0e655ef1d0f11ef82a2c945b608d31 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_disable/BUILD.gn @@ -0,0 +1,32 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("FormStateDisableTest") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":hjs_demo_js_assets", + ":hjs_demo_resources", + ] + ets2abc = true + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "FormStateDisableTest" +} +ohos_js_assets("hjs_demo_js_assets") { + source_dir = "./entry/src/main/ets/MainAbility" +} +ohos_resources("hjs_demo_resources") { + sources = [ "./entry/src/main/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_disable/Test.json b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_disable/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..3b44f31aeaca6f2ba3ae5eaf627a6f937441ce9e --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_disable/Test.json @@ -0,0 +1,25 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "300000", + "package": "com.ohos.st.formstatedisabletest", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "FormStateDisableTest.hap", + "FormSystemHostF.hap", + "FormSystemHostG.hap", + "FormSupplyAppA.hap", + "FormSupplyAppF.hap", + "FormSupplyAppG.hap", + "FormSystemHostNoPerm.hap", + "FormSupplyAppH.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} diff --git a/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_disable/entry/src/main/config.json b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_disable/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..f70589e2662f6d5fda35341262b71627a2ac1c60 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_disable/entry/src/main/config.json @@ -0,0 +1,150 @@ +{ + "app": { + "bundleName": "com.ohos.st.formstatedisabletest", + "vendor": "ohos", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 7, + "releaseType": "Release", + "target": 7 + } + }, + "deviceConfig": {}, + "module": { + "package": "com.ohos.st.formstatedisabletest", + "name": ".FormStateSTApp", + "mainAbility": ".MainAbility", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": false + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "visible": true, + "name": ".MainAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:description_mainability", + "label": "$string:entry_MainAbility", + "type": "page", + "launchType": "standard" + } + ], + "defPermissions": [ + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormDelete_commonEvent" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormOnAcquired_commonEvent" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormOnError_commonEvent" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormOnDeleted_commonEvent" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormOnState_commonEvent" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormSupply_commonEvent" + } + ], + "reqPermissions": [ + { + "name": "FMS_FormOnAcquired_commonEvent", + "reason": "need use onAcquired commonEvent" + }, + { + "name": "FMS_FormDelete_commonEvent", + "reason": "need use delete commonEvent" + }, + { + "name": "FMS_FormOnError_commonEvent", + "reason": "need use OnError commonEvent" + }, + { + "name": "FMS_FormOnDeleted_commonEvent", + "reason": "need use OnDeleted commonEvent" + }, + { + "name": "FMS_FormOnState_commonEvent", + "reason": "need use OnState commonEvent" + }, + { + "name": "FMS_FormSupply_commonEvent", + "reason": "need use FormSupply commonEvent" + }, + { + "name": "ohos.permission.INSTALL_BUNDLE", + "reason": "need use ohos.permission.INSTALL_BUNDLE" + }, + { + "name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + }, + { + "name":"ohos.permission.CHANGE_ABILITY_ENABLED_STATE", + "reason":"need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE" + }, + { + "name":"ohos.permission.REMOVE_CACHE_FILES", + "reason":"need use ohos.permission.REMOVE_CACHE_FILES" + }, + { + "name":"ohos.permission.LISTEN_BUNDLE_CHANGE", + "reason":"need use ohos.permission.LISTEN_BUNDLE_CHANGE" + }, + { + "name":"ohos.permission.CLEAN_BACKGROUND_PROCESSES", + "reason":"need use ohos.permission.CLEAN_BACKGROUND_PROCESSES" + } + ], + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_disable/entry/src/main/ets/MainAbility/app.ets b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_disable/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..83dd3d4f89d10e36cf17e9a1f7dba026f14c088b --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_disable/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,23 @@ +/* + * 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. + */ + +export default { + onCreate() { + console.info('[FormComponent] Application onCreate') + }, + onDestroy() { + console.info('[FormComponent] Application onDestroy') + }, +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_disable/entry/src/main/ets/MainAbility/model/FormViewModel.ets b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_disable/entry/src/main/ets/MainAbility/model/FormViewModel.ets new file mode 100644 index 0000000000000000000000000000000000000000..462affde744956c2f7db057285fb6356d3fd475e --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_disable/entry/src/main/ets/MainAbility/model/FormViewModel.ets @@ -0,0 +1,131 @@ +/* + * 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 formManager from '@ohos.ability.formmanager'; +import bundleManager from '@ohos.bundle'; + +export default class FormViewModel { + private static sFormViewModel: FormViewModel = null; + + public static getInstance(): FormViewModel { + if (FormViewModel.sFormViewModel == null) { + FormViewModel.sFormViewModel = new FormViewModel(); + } + return FormViewModel.sFormViewModel; + } + + public async requestForm(formId: string) { + formManager.requestForm(formId) + .then((data) => { + console.info( '[FormComponent] requestForm result:' + data); + }); + } + + public async deleteCard(formId: string) { + formManager.deleteForm(formId) + .then((data) => { + console.info('[FormComponent] deleteForm result:' + data); + }); + } + + public async releaseCard(formId: string) { + formManager.releaseForm(formId) + .then((data) => { + console.info('[FormComponent] releaseForm result:' + data); + }); + } + + public async castTempToNormal(formId: string) { + formManager.castTempForm(formId) + .then((data) => { + console.info('[FormComponent] castTempToNormal result:' + data); + }); + } + + public async enableCard(formId: string) { + formManager.enableFormsUpdate([formId]) + .then((data) => { + console.info('[FormComponent] enableFormsUpdate result:' + data); + }); + } + + public async disableCard(formId: string) { + formManager.disableFormsUpdate([formId]) + .then((data) => { + console.info('[FormComponent] disableCard result:' + data); + }); + } + + public async changeCardVisible(formId: string, isVisible: boolean) { + if (isVisible) { + formManager.notifyVisibleForms([formId]) + .then((data) => { + console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible); + }); + } else { + formManager.notifyInvisibleForms([formId]) + .then((data) => { + console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible); + }); + } + } + + public async isFmsReady() { + formManager.isSystemReady() + .then((data) => { + console.info('[FormComponent] isFmsReady result:' + data); + }); + } + + public async getAllFormsInfo() { + console.info("[FormComponent] getAllFormsInfo start"); + formManager.getAllFormsInfo() + .then((data) => { + console.info('[FormComponent] getAllFormsInfo result:' + JSON.stringify(data)); + }) + .catch((err) => { + console.info('[FormComponent] getAllFormsInfo error:' + JSON.stringify(err)); + }); + console.info("[FormComponent] getAllFormsInfo end"); + } + + public async getFormsInfoByApp(bundle: string) { + formManager.getFormsInfo(bundle) + .then((data) => { + console.info('[FormComponent] getFormsInfoByApp result:' + JSON.stringify(data)); + }); + } + + public async getFormsInfoByModule(bundle: string, moduleName: string) { + formManager.getFormsInfo(bundle, moduleName) + .then((data) => { + console.info('[FormComponent] getFormsInfoByModule result:' + JSON.stringify(data)); + }); + } + + public async clearFormUserCache() { + bundleManager.cleanBundleCacheFiles('com.ohos.myapplicationform') + .then((data) => { + console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data)); + }); + } + + public async clearFormProviderCache(bundle: string) { + bundleManager.cleanBundleCacheFiles(bundle) + .then((data) => { + console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data)); + }); + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_disable/entry/src/main/ets/MainAbility/pages/index.ets b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_disable/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..0d531eff10a6aaa0e89517f397aea3c59d8b558f --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_disable/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,68 @@ +/* + * 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. + */ + +// @ts-nocheck +import featureAbility from "@ohos.ability.featureAbility"; +import file from '@system.file'; +import { Core, ExpectExtend, ReportExtend } from "deccjsunit/index.ets"; +import testsuite from "../test/List.test.ets"; + +@Entry +@Component +struct Index { + + aboutToAppear() { + + console.info("[FormComponent] start run testcase!!!!"); + + featureAbility.getWant() + .then((want: any) => { + console.info('[FormComponent] Operation successful. Data: ' + JSON.stringify(want)); + const core = Core.getInstance(); + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }); + core.addService('expect', expectExtend); + const reportExtend = new ReportExtend(file); + core.addService('report', reportExtend); + core.init(); + core.subscribeEvent('task', reportExtend); + const configService = core.getDefaultService('config'); + want.parameters['timeout'] = 30000; + console.info('[FormComponent] parameters---->' + JSON.stringify(want.parameters)); + configService.setConfig(want.parameters); + testsuite(); + core.execute(); + }) + .catch((error: any) => { + console.error('[FormComponent] Operation failed. Cause: ' + JSON.stringify(error)); + }) + } + + build() { + Flex({ + direction: FlexDirection.Column, + alignItems: ItemAlign.Center, + justifyContent: FlexAlign.Center + }) { + Text('Fms Main Ability Test') + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + .height('100%') + } +} + diff --git a/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_disable/entry/src/main/ets/MainAbility/test/FmsFormStateDisable.test.ets b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_disable/entry/src/main/ets/MainAbility/test/FmsFormStateDisable.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..e67e8da7e6213fa2b57b6f0eef326b12ef23602b --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_disable/entry/src/main/ets/MainAbility/test/FmsFormStateDisable.test.ets @@ -0,0 +1,907 @@ +/* + * 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 featureAbility from "@ohos.ability.featureAbility"; +import commonEvent from '@ohos.commonEvent'; +import { beforeAll, describe, expect, it } from "deccjsunit/index.ets"; + +var onErrorForm_Event = { + events: ["FMS_FormOnError_commonEvent"], +}; +var onAcquiredForm_Event = { + events: ["FMS_FormOnAcquired_commonEvent"], +}; + +var onDeletedFormEvent = { + events: ["FMS_FormOnDeleted_commonEvent"], +}; + +var onStateFormEvent = { + events: ["FMS_FormOnState_commonEvent"], +}; + +var onSupplyEvent = { + events: ["FMS_FormSupply_commonEvent"], +}; + +var deleteForm_Event = "FMS_FormDelete_commonEvent"; + +export default function test() { + describe(`FmsStateFormTest`, () => { + + beforeAll(async (done) => { + done(); + }) + + /** + * @tc.number: FMS_disableFormsUpdate_0200 + * @tc.name: The form user does not have permission. + * @tc.desc: 1.The form user calls the disable update interface. + * 2.Verify the result of the disable update interface. + */ + it(`FMS_disableFormsUpdate_0200`, 0, async (done) => { + console.log(`FMS_disableFormsUpdate_0200 start`); + let subscriberOnState; + + function onStateCallBack(err, data) { + console.info("!!!====>FMS_disableFormsUpdate_0200 onStateCallBack data:====>" + JSON.stringify(data)); + expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); + expect(data.data).assertEqual("2"); + commonEvent.unsubscribe(subscriberOnState, unsubscribeOnStateCallBack); + setTimeout(function () { + console.info('FMS_disableFormsUpdate_0200 onStateCallBack end'); + console.log(`FMS_disableFormsUpdate_0200 end`); + done(); + }, 1000) + } + function unsubscribeOnStateCallBack() { + console.debug("====>FMS_disableFormsUpdate_0200 unsubscribeOnStateCallBack====>"); + } + + commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { + console.debug("====>FMS_disableFormsUpdate_0200 onStateFormEvent Subscriber====>"); + subscriberOnState = data; + await commonEvent.subscribe(subscriberOnState, onStateCallBack); + }); + + console.log(`FMS_disableFormsUpdate_0200 featureAbility.startAbility again start`); + featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostnoperm", + abilityName: "com.ohos.st.formsystemhostnoperm.MainAbility", + parameters: { + "formId" : "0", + "name" : "Form_Js001", + "bundle" : "com.form.formsystemtestservicea.hmservice", + "ability" : "com.form.formsystemtestservicea.hmservice.FormAbility", + "moduleName" : "entry", + "temporary" : false, + "stateForm" : "disable", + "stateIds" : ["1"], + "isCreate" : false + } + } + }).then((res: any) => { + console.log(`FMS_disableFormsUpdate_0200 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_disableFormsUpdate_0200 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_disableFormsUpdate_0200 featureAbility.startAbility again end`); + }); + /** + * @tc.number: FMS_disableFormsUpdate_0300 + * @tc.name: The length of the formId list is 0 (no formId) + * @tc.desc: 1.The form user calls the disable update interface. + * 2.Verify the result of the disable update interface. + */ + it(`FMS_disableFormsUpdate_0300`, 0, async (done) => { + console.log(`FMS_disableFormsUpdate_0300 start`); + let subscriberOnState; + + function onStateCallBack(err, data) { + console.info("!!!====>FMS_disableFormsUpdate_0300 onStateCallBack data:====>" + JSON.stringify(data)); + expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); + expect(data.data).assertEqual("7"); + commonEvent.unsubscribe(subscriberOnState, unSubscribeOnStateCallback) + + setTimeout(function () { + console.info('FMS_disableFormsUpdate_0300 delPublishCallBack end'); + console.log(`FMS_disableFormsUpdate_0300 end`); + done(); + }, 100) + } + function unSubscribeOnStateCallback() { + console.debug("====>FMS_disableFormsUpdate_0300 unSubscribeOnStateCallback CallBack====>"); + } + + commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { + console.debug("====>FMS_disableFormsUpdate_0300 onStateFormEvent Subscriber====>"); + subscriberOnState = data; + await commonEvent.subscribe(subscriberOnState, onStateCallBack); + }); + console.log(`FMS_disableFormsUpdate_0300 featureAbility.startAbility start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "Form_Js001", + "bundle" : "com.form.formsystemtestservicea.hmservice", + "ability" : "com.form.formsystemtestservicea.hmservice.FormAbility", + "moduleName" : "entry", + "temporary" : false, + "stateForm" : "disable", + "stateIds" : [], + "isCreate" : false + } + } + }).then((res: any) => { + console.log(`FMS_disableFormsUpdate_0300 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_disableFormsUpdate_0300 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_disableFormsUpdate _0300 featureAbility.startAbility end`); + }); + /** + * @tc.number: FMS_disableFormsUpdate_0400 + * @tc.name: formID id is error(formID < 0) + * @tc.desc: 1.The form user calls the disable update interface. + * 2.Verify the result of the disable update interface. + */ + it(`FMS_disableFormsUpdate_0400`, 0, async (done) => { + console.log(`FMS_disableFormsUpdate_0400 start`); + let subscriberOnState; + let formId; + + function onStateCallBack(err, data) { + console.info("!!!====>FMS_disableFormsUpdate_0400 onStateCallBack data:====>" + JSON.stringify(data)); + expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); + expect(data.data).assertEqual("13"); + commonEvent.unsubscribe(subscriberOnState, unSubscribeOnStateCallback) + + setTimeout(function () { + console.info('FMS_disableFormsUpdate_0400 delPublishCallBack end'); + console.log(`FMS_disableFormsUpdate_0400 end`); + done(); + }, 100) + } + function unSubscribeOnStateCallback() { + console.debug("====>FMS_disableFormsUpdate_0400 unSubscribeOnStateCallback CallBack====>"); + } + + commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { + console.debug("====>FMS_disableFormsUpdate_0400 onStateFormEvent Subscriber====>"); + subscriberOnState = data; + await commonEvent.subscribe(subscriberOnState, onStateCallBack); + }); + console.log(`FMS_disableFormsUpdate_0400 featureAbility.startAbility start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "Form_Js001", + "bundle" : "com.form.formsystemtestservicea.hmservice", + "ability" : "com.form.formsystemtestservicea.hmservice.FormAbility", + "moduleName" : "entry", + "temporary" : false, + "stateForm" : "disable", + "stateIds" : ["-1"], + "isCreate" : false + } + } + }).then((res: any) => { + console.log(`FMS_disableFormsUpdate_0400 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_disableFormsUpdate_0400 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_disableFormsUpdate _0400 featureAbility.startAbility end`); + }); + /** + * @tc.number: FMS_disableFormsUpdate_0500 + * @tc.name: formID id is error(formID == 0) + * @tc.desc: 1.The form user calls the disable update interface. + * 2.Verify the result of the disable update interface. + */ + it(`FMS_disableFormsUpdate_0500`, 0, async (done) => { + console.log(`FMS_disableFormsUpdate_0500 start`); + let subscriberOnState; + let formId; + + function onStateCallBack(err, data) { + console.info("!!!====>FMS_disableFormsUpdate_0500 onStateCallBack data:====>" + JSON.stringify(data)); + expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); + expect(data.data).assertEqual("13"); + commonEvent.unsubscribe(subscriberOnState, unSubscribeOnStateCallback) + + setTimeout(function () { + console.info('FMS_disableFormsUpdate_0500 delPublishCallBack end'); + console.log(`FMS_disableFormsUpdate_0500 end`); + done(); + }, 100) + } + function unSubscribeOnStateCallback() { + console.debug("====>FMS_disableFormsUpdate_0500 unSubscribeOnStateCallback CallBack====>"); + } + + commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { + console.debug("====>FMS_disableFormsUpdate_0500 onStateFormEvent Subscriber====>"); + subscriberOnState = data; + await commonEvent.subscribe(subscriberOnState, onStateCallBack); + }); + console.log(`FMS_disableFormsUpdate_0500 featureAbility.startAbility start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "Form_Js001", + "bundle" : "com.form.formsystemtestservicea.hmservice", + "ability" : "com.form.formsystemtestservicea.hmservice.FormAbility", + "moduleName" : "entry", + "temporary" : false, + "stateForm" : "disable", + "stateIds" : ["0"], + "isCreate" : false + } + } + }).then((res: any) => { + console.log(`FMS_disableFormsUpdate_0500 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_disableFormsUpdate_0500 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_disableFormsUpdate_0500 featureAbility.startAbility end`); + }); + /** + * @tc.number: FMS_disableFormsUpdate_0600 + * @tc.name: formID id is error because formId is not self + * @tc.desc: 1.The form user calls the disable update interface. + * 2.Verify the result of the disable update interface. + */ + it(`FMS_disableFormsUpdate_0600`, 0, async (done) => { + console.info(`FMS_disableFormsUpdate_0600 start`); + let subscriberOnAcquired; + let subscriberDisable; + let hostFormId; + + const delPublishCallback = (err, data) => { + console.info("!!!====>FMS_disableFormsUpdate_0600 delPublishCallback====>"); + setTimeout(() => { + console.info('FMS_disableFormsUpdate_0600 delPublishCallback end'); + console.info(`FMS_disableFormsUpdate_0600 end`); + done(); + }, 1000); + } + + const onDisableCallback = (err, data) => { + if (data.parameters.kind != "disable") { + return; + } + console.debug("====>FMS_disableFormsUpdate_0600 onDisableCallback data:====>" + JSON.stringify(data)); + + expect(data.data).assertEqual("13"); + commonEvent.unsubscribe(subscriberDisable, () => { + console.info("====>FMS_disableFormsUpdate_0600 unSubscribeOnDisableCallback====>"); + }); + const commonEventPublishData = { + data: hostFormId + }; + commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallback); + } + + const onAcquiredCallBack = async (err, data) => { + console.debug("====>FMS_disableFormsUpdate_0600 onAcquiredCallback data:====>" + JSON.stringify(data)); + hostFormId = data.data; + + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId": hostFormId, + "name": "Form_Js001", + "bundle": "com.form.formsystemtestservicef.hmservice", + "ability": "com.form.formsystemtestservicef.hmservice.FormAbility", + "moduleName": "entry", + "temporary": false, + "stateForm": "disable", + "stateIds": [hostFormId], + "isCreate": false + } + } + }).then((res: any) => { + console.debug(`FMS_disableFormsUpdate_0600 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.debug(`FMS_disableFormsUpdate_0600 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + commonEvent.unsubscribe(subscriberOnAcquired, () => { + console.info("====>FMS_disableFormsUpdate_0600 unSubscribeOnAcquiredCallback====>"); + }); + } + + commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => { + console.debug("====>FMS_disableFormsUpdate_0600 onAcquiredFormEvent Subscriber====>"); + subscriberOnAcquired = data; + await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack); + }); + commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { + console.info("====>FMS_disableFormsUpdate_0600 onStateFormEvent Disable Subscriber====>"); + subscriberDisable = data; + await commonEvent.subscribe(subscriberDisable, onDisableCallback); + }); + + console.info(`FMS_disableFormsUpdate_0600 featureAbility.startAbility start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostf", + abilityName: "com.ohos.st.formsystemhostf.MainAbility", + parameters: { + "formId": "0", + "name": "Form_Js001", + "bundle": "com.form.formsystemtestservicef.hmservice", + "ability": "com.form.formsystemtestservicef.hmservice.FormAbility", + "moduleName": "entry", + "temporary": false, + "isCreate": true + } + } + }).then((res: any) => { + console.debug(`FMS_disableFormsUpdate_0600 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.debug(`FMS_disableFormsUpdate_0600 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + }); + /** + * @tc.number: FMS_disableFormsUpdate_0700 + * @tc.name: formID id is error because formId is not exist + * @tc.desc: 1.The form user calls the disable update interface. + * 2.Verify the result of the disable update interface. + */ + it(`FMS_disableFormsUpdate_0700`, 0, async (done) => { + console.info(`FMS_disableFormsUpdate_0700 start`); + let subscriberDel; + let subscriberDisable; + let hostFormId; + + const onDisableCallback = (err, data) => { + if (data.parameters.kind != "disable") { + return; + } + console.debug("====>FMS_disableFormsUpdate_0700 onDisableCallback data:====>" + JSON.stringify(data)); + + expect(data.data).assertEqual("13"); + commonEvent.unsubscribe(subscriberDisable, () => { + console.info("====>FMS_disableFormsUpdate_0700 unSubscribeOnDisableCallback====>"); + }); + done(); + } + + const onDeleteCallback = async (err, data) => { + console.debug("====>FMS_disableFormsUpdate_0700 onDeleteCallback data:====>" + JSON.stringify(data)); + hostFormId = data.parameters.formId; + + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId": "0", + "name": "Form_Js001", + "bundle": "com.form.formsystemtestservicef.hmservice", + "ability": "com.form.formsystemtestservicef.hmservice.FormAbility", + "moduleName": "entry", + "temporary": false, + "stateForm": "disable", + "stateIds": [hostFormId], + "isCreate": false + } + } + }).then((res: any) => { + console.debug(`FMS_disableFormsUpdate_0700 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.debug(`FMS_disableFormsUpdate_0700 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + + commonEvent.unsubscribe(subscriberDel, () => { + console.info("====>FMS_disableFormsUpdate_0700 unSubscribeDelCallback====>"); + }); + } + + commonEvent.createSubscriber(onDeletedFormEvent).then(async (data) => { + console.info("====>FMS_disableFormsUpdate_0700 onDeletedFormEvent Invisible Subscriber====>"); + subscriberDel = data; + await commonEvent.subscribe(subscriberDel, onDeleteCallback); + }); + commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { + console.info("====>FMS_disableFormsUpdate_0700 onStateFormEvent Disable Subscriber====>"); + subscriberDisable = data; + await commonEvent.subscribe(subscriberDisable, onDisableCallback); + }); + + console.info(`FMS_disableFormsUpdate_0700 featureAbility.startAbility start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId": "0", + "name": "Form_Js001", + "bundle": "com.form.formsystemtestservicef.hmservice", + "ability": "com.form.formsystemtestservicef.hmservice.FormAbility", + "moduleName": "entry", + "temporary": false, + "deleteForm": true, + "deleteId": "self", + "isCreate": true + } + } + }).then((res: any) => { + console.debug(`FMS_disableFormsUpdate_0700 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.debug(`FMS_disableFormsUpdate_0700 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + }); + /** + * @tc.number: FMS_disableFormsUpdate_0800 + * @tc.name: The form user has form permission. + * @tc.desc: 1.The form user calls the disable update interface. + * 2.Verify the result of the disable update interface. + */ + it(`FMS_disableFormsUpdate_0800`, 0, async (done) => { + console.log(`FMS_disableFormsUpdate_0800 start`); + let subscriberOnState; + let subscriberOnAcquired; + let formId; + + function delPublishCallBack() { + console.info("!!!====>FMS_disableFormsUpdate_0800 delPublishCallBack====>"); + setTimeout(function () { + console.info('FMS_disableFormsUpdate_0800 delPublishCallBack end'); + console.log(`FMS_disableFormsUpdate_0800 end`); + done(); + }, 1000); + } + + function onStateCallBack(err, data) { + console.info("!!!====>FMS_disableFormsUpdate_0800 onStateCallBack data:====>" + JSON.stringify(data)); + expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); + expect(data.data).assertEqual("0"); + formId = data.parameters.formId; + commonEvent.unsubscribe(subscriberOnState, unsubscribeOnStateCallback); + let commonEventPublishData = { + data: formId + }; + commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); + } + function unsubscribeOnStateCallback() { + console.debug("====>FMS_disableFormsUpdate_0800 unsubscribeOnStateCallback====>"); + } + + commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { + console.debug("====>FMS_disableFormsUpdate_0800 onStateFormEvent Subscriber====>"); + subscriberOnState = data; + await commonEvent.subscribe(subscriberOnState, onStateCallBack); + }); + console.log(`FMS_disableFormsUpdate_0800 featureAbility.startAbility start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "Form_Js001", + "bundle" : "com.form.formsystemtestservicea.hmservice", + "ability" : "com.form.formsystemtestservicea.hmservice.FormAbility", + "moduleName" : "entry", + "temporary" : false, + "stateForm" : "disable", + "stateIds" : ["self"], + "isCreate" : true + } + } + }).then((res: any) => { + console.log(`FMS_disableFormsUpdate_0800 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_disableFormsUpdate_0800 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_disableFormsUpdate_0800 featureAbility.startAbility end`); + }); + + /** + * @tc.number: FMS_disableFormsUpdate_0900 + * @tc.name: There are correct and wrong formId in the form ID parameter list. + * @tc.desc: 1.The form user calls the disable update interface. + * 2.Verify the result of the disable update interface. + */ + it(`FMS_disableFormsUpdate_0900`, 0, async (done) => { + console.log(`FMS_disableFormsUpdate_0900 start`); + let subscriberDisable; + let subscriberEnable; + let formId; + + function delPublishCallBack(err, data) { + console.info("!!!====>FMS_disableFormsUpdate_0900 delPublishCallBack====>"); + setTimeout(function () { + console.info('FMS_disableFormsUpdate_0900 delPublishCallBack end'); + console.log(`FMS_disableFormsUpdate_0900 end`); + done(); + }, 1000); + } + + function unSubscribeOnDisableCallback() { + console.info("!!!====>FMS_disableFormsUpdate_0900 unSubscribeOnDisableCallback====>"); + } + function OnDisableCallBack(err, data) { + console.info("!!!====>FMS_disableFormsUpdate_0900 OnDisableCallBack data:====>" + JSON.stringify(data)); + expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); + expect(data.data).assertEqual("0"); + commonEvent.unsubscribe(subscriberDisable, unSubscribeOnDisableCallback); + + let commonEventPublishData = { + data: formId + }; + commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); + } + function unSubscribeOnEnableCallback() { + console.info("!!!====>FMS_disableFormsUpdate_0900 unSubscribeOnEnableCallback====>"); + } + function OnEnableCallBack(err, data) { + console.info("!!!====>FMS_disableFormsUpdate_0900 OnEnableCallBack data:====>" + JSON.stringify(data)); + expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); + commonEvent.unsubscribe(subscriberEnable, unSubscribeOnEnableCallback); + formId = data.parameters.formId; + commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { + console.debug("====>FMS_disableFormsUpdate_0900 onStateFormEvent Invisible Subscriber====>"); + subscriberDisable = data; + await commonEvent.subscribe(subscriberDisable, OnDisableCallBack); + }); + console.log(`FMS_disableFormsUpdate_0900 featureAbility.startAbility start`); + featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "Form_Js001", + "bundle" : "com.form.formsystemtestservicea.hmservice", + "ability" : "com.form.formsystemtestservicea.hmservice.FormAbility", + "moduleName" : "entry", + "temporary" : false, + "stateForm" : "disable", + "stateIds" : [formId, "0"], + "isCreate" : false + } + } + }).then((res: any) => { + console.log(`FMS_disableFormsUpdate_0900 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_disableFormsUpdate_0900 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_disableFormsUpdate_0900 featureAbility.startAbility end`); + } + + commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { + console.debug("====>FMS_disableFormsUpdate_0900 onStateFormEvent Invisible Subscriber====>"); + subscriberEnable = data; + await commonEvent.subscribe(subscriberEnable, OnEnableCallBack); + }); + console.log(`FMS_disableFormsUpdate_0900 featureAbility.startAbility start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "Form_Js001", + "bundle" : "com.form.formsystemtestservicea.hmservice", + "ability" : "com.form.formsystemtestservicea.hmservice.FormAbility", + "moduleName" : "entry", + "temporary" : false, + "stateForm" : "enable", + "stateIds" : ["self"], + "isCreate" : true + } + } + }).then((res: any) => { + console.log(`FMS_disableFormsUpdate_0900 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_disableFormsUpdate_0900 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_disableFormsUpdate_0900 featureAbility.startAbility end`); + }); + /** + * @tc.number: FMS_disableFormsUpdate_1000 + * @tc.name: Set next refresh time is invalid when disable form. (cache data < 1k) + * @tc.desc: 1.The form user calls the visible notification interface. + * 2.Call the disableFormsUpdate interface. + * 3.Call the setFormNextRefreshTime interface and verify the form can not refresh. + */ + it(`FMS_disableFormsUpdate_1000`, 0, async (done) => { + console.log(`FMS_disableFormsUpdate_1000 start`); + let subscriberOnAcquired; + let subscriberStatus; + let subscriberEnable; + let subscriberSupply; + let formId; + + // timer speed up + commonEvent.publish(`fms.time_speed`, { code: 100 }, () => { + console.log(`FMS_disableFormsUpdate_1000 time speed up`); + }); + + function unSubscribeSupplyCallback() { + console.debug("====>FMS_disableFormsUpdate_1000 unSubscribeSupplyCallback====>"); + } + function delPublishCallBack(err, data) { + console.info("!!!====>FMS_disableFormsUpdate_1000 delPublishCallBack====>" + JSON.stringify(data)); + setTimeout(function () { + console.info('FMS_disableFormsUpdate_1000 delPublishCallBack end'); + console.log(`FMS_disableFormsUpdate_1000 end`); + done(); + }, 1000); + } + + function onSupplyEventCallBack(err, data) { + console.debug("====>FMS_disableFormsUpdate_1000 onSupplyEventCallBack====>" + JSON.stringify(data)); + if ("onUpdate" == data.parameters.kind) { + console.debug("FMS_disableFormsUpdate_1000 error, onUpdate called."); + commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback); + expect().assertFail(); + } + } + + function onFormDisableCallBack(err, data) { + expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); + console.debug("====>FMS_disableFormsUpdate_1000 onFormDisableCallBack====>" + JSON.stringify(data)); + commonEvent.unsubscribe(subscriberStatus, unSubscribeSupplyCallback); + expect(data.parameters.kind).assertEqual("disable"); + expect(data.data).assertEqual("0"); + + commonEvent.createSubscriber(onSupplyEvent).then(async (data) => { + console.debug("====>FMS_disableFormsUpdate_1000 onSupplyEvent Subscriber====>"); + subscriberSupply = data; + await commonEvent.subscribe(subscriberSupply, onSupplyEventCallBack); + }); + + setTimeout(() => { + // timer reset + commonEvent.publish(`fms.time_speed`, { code: 1 }, () => { + console.log(`FMS_disableFormsUpdate_1000 time reset`); + }); + commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback); + }, 9000); + + setTimeout(() => { + console.log(`FMS_disableFormsUpdate_1000 onFormDisableCallBack end`); + let commonEventPublishData = { + data: formId + }; + commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); + }, 10000); + } + + function onAcquiredCallBack(err, data) { + expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); + commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeSupplyCallback); + console.debug("====>FMS_disableFormsUpdate_1000 onAcquiredCallBack====>" + JSON.stringify(data)); + expect(data.parameters.kind).assertEqual("visible"); + expect(data.data).assertEqual("0"); + formId = data.parameters.formId; + + commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { + console.debug("====>FMS_disableFormsUpdate_1000 onStateFormEvent Subscriber====>"); + subscriberStatus = data; + await commonEvent.subscribe(subscriberStatus, onFormDisableCallBack); + }); + + console.log(`FMS_disableFormsUpdate_1000 featureAbility.startAbility notify disable start`); + featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "name", + "bundle" : "bundle", + "ability" : "ability", + "moduleName" : "entry", + "temporary" : false, + "stateForm" : "disable", + "stateIds" : [formId], + "isCreate" : false + } + } + }).then((res: any) => { + console.log(`FMS_disableFormsUpdate_1000 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_disableFormsUpdate_1000 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_disableFormsUpdate_1000 featureAbility.startAbility notify disable end`); + } + + commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { + console.debug("====>FMS_disableFormsUpdate_1000 onAcquiredForm_Event Subscriber====>"); + subscriberOnAcquired = data; + await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack); + }); + console.log(`FMS_disableFormsUpdate_1000 featureAbility.startAbility servicea start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "Form_Js001", + "bundle" : "com.form.formsystemtestservicef.hmservice", + "ability" : "com.form.formsystemtestservicef.hmservice.FormAbility", + "moduleName" : "entry", + "temporary" : false, + "isCreate" : true, + "stateIds" : ["self"], + "stateForm" : "visible" + } + } + }).then((res: any) => { + console.log(`FMS_disableFormsUpdate_1000 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_disableFormsUpdate_1000 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_disableFormsUpdate_1000 featureAbility.startAbility servicea end`); + }); + + /** + * @tc.number: FMS_disableFormsUpdate_1100 + * @tc.name: Set next refresh time is invalid when disable form. (cache data > 1k) + * @tc.desc: 1.The form user calls the visible notification interface. + * 2.Call the disableFormsUpdate interface. + * 3.Call the setFormNextRefreshTime interface and verify the form can not refresh. + */ + it(`FMS_disableFormsUpdate_1100`, 0, async (done) => { + console.log(`FMS_disableFormsUpdate_1100 start`); + let subscriberOnAcquired; + let subscriberStatus; + let subscriberEnable; + let subscriberSupply; + let formId; + + // timer speed up + commonEvent.publish(`fms.time_speed`, { code: 100 }, () => { + console.log(`FMS_disableFormsUpdate_1100 time speed up`); + }); + + function unSubscribeSupplyCallback() { + console.debug("====>FMS_disableFormsUpdate_1100 unSubscribeSupplyCallback====>"); + } + function delPublishCallBack(err, data) { + console.info("!!!====>FMS_disableFormsUpdate_1100 delPublishCallBack====>" + JSON.stringify(data)); + setTimeout(function () { + console.info('FMS_disableFormsUpdate_1100 delPublishCallBack end'); + console.log(`FMS_disableFormsUpdate_1100 end`); + done(); + }, 1000); + } + + function onSupplyEventCallBack(err, data) { + console.debug("====>FMS_disableFormsUpdate_1100 onSupplyEventCallBack====>" + JSON.stringify(data)); + if ("onUpdate" == data.parameters.kind) { + console.debug("FMS_disableFormsUpdate_1100 error, onUpdate called."); + commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback); + expect().assertFail(); + } + } + + function onFormDisableCallBack(err, data) { + expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); + console.debug("====>FMS_disableFormsUpdate_1100 onFormDisableCallBack====>" + JSON.stringify(data)); + commonEvent.unsubscribe(subscriberStatus, unSubscribeSupplyCallback); + expect(data.parameters.kind).assertEqual("disable"); + expect(data.data).assertEqual("0"); + + commonEvent.createSubscriber(onSupplyEvent).then(async (data) => { + console.debug("====>FMS_disableFormsUpdate_1100 onSupplyEvent Subscriber====>"); + subscriberSupply = data; + await commonEvent.subscribe(subscriberSupply, onSupplyEventCallBack); + }); + + setTimeout(() => { + // timer reset + commonEvent.publish(`fms.time_speed`, { code: 1 }, () => { + console.log(`FMS_disableFormsUpdate_1100 time reset`); + }); + commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback); + }, 9000); + + setTimeout(() => { + console.log(`FMS_disableFormsUpdate_1100 onFormDisableCallBack end`); + let commonEventPublishData = { + data: formId + }; + commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); + }, 10000); + } + + function onAcquiredCallBack(err, data) { + expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); + commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeSupplyCallback); + console.debug("====>FMS_disableFormsUpdate_1100 onAcquiredCallBack====>" + JSON.stringify(data)); + expect(data.parameters.kind).assertEqual("visible"); + expect(data.data).assertEqual("0"); + formId = data.parameters.formId; + + commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { + console.debug("====>FMS_disableFormsUpdate_1100 onStateFormEvent Subscriber====>"); + subscriberStatus = data; + await commonEvent.subscribe(subscriberStatus, onFormDisableCallBack); + }); + + console.log(`FMS_disableFormsUpdate_1100 featureAbility.startAbility notify disable start`); + featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "name", + "bundle" : "bundle", + "ability" : "ability", + "moduleName" : "entry", + "temporary" : false, + "stateForm" : "disable", + "stateIds" : [formId], + "isCreate" : false + } + } + }).then((res: any) => { + console.log(`FMS_disableFormsUpdate_1100 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_disableFormsUpdate_1100 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_disableFormsUpdate_1100 featureAbility.startAbility notify disable end`); + } + + commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { + console.debug("====>FMS_disableFormsUpdate_1100 onAcquiredForm_Event Subscriber====>"); + subscriberOnAcquired = data; + await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack); + }); + console.log(`FMS_disableFormsUpdate_1100 featureAbility.startAbility servicea start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "Form_Js001", + "bundle" : "com.form.formsystemtestserviceg.hmservice", + "ability" : "com.form.formsystemtestserviceg.hmservice.FormAbility", + "moduleName" : "entry", + "temporary" : false, + "isCreate" : true, + "stateIds" : ["self"], + "stateForm" : "visible" + } + } + }).then((res: any) => { + console.log(`FMS_disableFormsUpdate_1100 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_disableFormsUpdate_1100 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_disableFormsUpdate_1100 featureAbility.startAbility servicea end`); + }); + }); +} diff --git a/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_disable/entry/src/main/ets/MainAbility/test/List.test.ets b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_disable/entry/src/main/ets/MainAbility/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..ea2d993ef471e94f437059ae3dc201568b7e3f2b --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_disable/entry/src/main/ets/MainAbility/test/List.test.ets @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import test from './FmsFormStateDisable.test.ets'; + +export default function testsuite() { + test(); +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_disable/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_disable/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..95817e60f50f5e4b3c91da7e64febe07c2426751 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_disable/entry/src/main/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "formdisablestatetest" + }, + { + "name": "description_mainability", + "value": "ETS_Empty Ability" + } + ] +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_disable/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_disable/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_disable/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_disable/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_disable/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_disable/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_enable/BUILD.gn b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_enable/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..55ea97b27b1c070786607f7b766cc474fe3ef2fa --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_enable/BUILD.gn @@ -0,0 +1,32 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("FormStateEnableTest") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":hjs_demo_js_assets", + ":hjs_demo_resources", + ] + ets2abc = true + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "FormStateEnableTest" +} +ohos_js_assets("hjs_demo_js_assets") { + source_dir = "./entry/src/main/ets/MainAbility" +} +ohos_resources("hjs_demo_resources") { + sources = [ "./entry/src/main/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_enable/Test.json b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_enable/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..ef414613eae6a9d9341772eac9415803c2f70642 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_enable/Test.json @@ -0,0 +1,25 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "300000", + "package": "com.ohos.st.formstateenabletest", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "FormStateEnableTest.hap", + "FormSystemHostF.hap", + "FormSystemHostG.hap", + "FormSystemHostNoPerm.hap", + "FormSupplyAppA.hap", + "FormSupplyAppE.hap", + "FormSupplyAppF.hap", + "FormSupplyAppH.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} diff --git a/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_enable/entry/src/main/config.json b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_enable/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..60cf1e361f154ae142dae1d26a1f19909a807846 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_enable/entry/src/main/config.json @@ -0,0 +1,150 @@ +{ + "app": { + "bundleName": "com.ohos.st.formstateenabletest", + "vendor": "ohos", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 7, + "releaseType": "Release", + "target": 7 + } + }, + "deviceConfig": {}, + "module": { + "package": "com.ohos.st.formstateenabletest", + "name": ".FormStateSTApp", + "mainAbility": ".MainAbility", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": false + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "visible": true, + "name": ".MainAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:description_mainability", + "label": "$string:entry_MainAbility", + "type": "page", + "launchType": "standard" + } + ], + "defPermissions": [ + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormDelete_commonEvent" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormOnAcquired_commonEvent" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormOnError_commonEvent" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormOnDeleted_commonEvent" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormOnState_commonEvent" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormSupply_commonEvent" + } + ], + "reqPermissions": [ + { + "name": "FMS_FormOnAcquired_commonEvent", + "reason": "need use onAcquired commonEvent" + }, + { + "name": "FMS_FormDelete_commonEvent", + "reason": "need use delete commonEvent" + }, + { + "name": "FMS_FormOnError_commonEvent", + "reason": "need use OnError commonEvent" + }, + { + "name": "FMS_FormOnDeleted_commonEvent", + "reason": "need use OnDeleted commonEvent" + }, + { + "name": "FMS_FormOnState_commonEvent", + "reason": "need use OnState commonEvent" + }, + { + "name": "FMS_FormSupply_commonEvent", + "reason": "need use FormSupply commonEvent" + }, + { + "name": "ohos.permission.INSTALL_BUNDLE", + "reason": "need use ohos.permission.INSTALL_BUNDLE" + }, + { + "name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + }, + { + "name":"ohos.permission.CHANGE_ABILITY_ENABLED_STATE", + "reason":"need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE" + }, + { + "name":"ohos.permission.REMOVE_CACHE_FILES", + "reason":"need use ohos.permission.REMOVE_CACHE_FILES" + }, + { + "name":"ohos.permission.LISTEN_BUNDLE_CHANGE", + "reason":"need use ohos.permission.LISTEN_BUNDLE_CHANGE" + }, + { + "name":"ohos.permission.CLEAN_BACKGROUND_PROCESSES", + "reason":"need use ohos.permission.CLEAN_BACKGROUND_PROCESSES" + } + ], + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_enable/entry/src/main/ets/MainAbility/app.ets b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_enable/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..83dd3d4f89d10e36cf17e9a1f7dba026f14c088b --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_enable/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,23 @@ +/* + * 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. + */ + +export default { + onCreate() { + console.info('[FormComponent] Application onCreate') + }, + onDestroy() { + console.info('[FormComponent] Application onDestroy') + }, +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_enable/entry/src/main/ets/MainAbility/model/FormViewModel.ets b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_enable/entry/src/main/ets/MainAbility/model/FormViewModel.ets new file mode 100644 index 0000000000000000000000000000000000000000..462affde744956c2f7db057285fb6356d3fd475e --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_enable/entry/src/main/ets/MainAbility/model/FormViewModel.ets @@ -0,0 +1,131 @@ +/* + * 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 formManager from '@ohos.ability.formmanager'; +import bundleManager from '@ohos.bundle'; + +export default class FormViewModel { + private static sFormViewModel: FormViewModel = null; + + public static getInstance(): FormViewModel { + if (FormViewModel.sFormViewModel == null) { + FormViewModel.sFormViewModel = new FormViewModel(); + } + return FormViewModel.sFormViewModel; + } + + public async requestForm(formId: string) { + formManager.requestForm(formId) + .then((data) => { + console.info( '[FormComponent] requestForm result:' + data); + }); + } + + public async deleteCard(formId: string) { + formManager.deleteForm(formId) + .then((data) => { + console.info('[FormComponent] deleteForm result:' + data); + }); + } + + public async releaseCard(formId: string) { + formManager.releaseForm(formId) + .then((data) => { + console.info('[FormComponent] releaseForm result:' + data); + }); + } + + public async castTempToNormal(formId: string) { + formManager.castTempForm(formId) + .then((data) => { + console.info('[FormComponent] castTempToNormal result:' + data); + }); + } + + public async enableCard(formId: string) { + formManager.enableFormsUpdate([formId]) + .then((data) => { + console.info('[FormComponent] enableFormsUpdate result:' + data); + }); + } + + public async disableCard(formId: string) { + formManager.disableFormsUpdate([formId]) + .then((data) => { + console.info('[FormComponent] disableCard result:' + data); + }); + } + + public async changeCardVisible(formId: string, isVisible: boolean) { + if (isVisible) { + formManager.notifyVisibleForms([formId]) + .then((data) => { + console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible); + }); + } else { + formManager.notifyInvisibleForms([formId]) + .then((data) => { + console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible); + }); + } + } + + public async isFmsReady() { + formManager.isSystemReady() + .then((data) => { + console.info('[FormComponent] isFmsReady result:' + data); + }); + } + + public async getAllFormsInfo() { + console.info("[FormComponent] getAllFormsInfo start"); + formManager.getAllFormsInfo() + .then((data) => { + console.info('[FormComponent] getAllFormsInfo result:' + JSON.stringify(data)); + }) + .catch((err) => { + console.info('[FormComponent] getAllFormsInfo error:' + JSON.stringify(err)); + }); + console.info("[FormComponent] getAllFormsInfo end"); + } + + public async getFormsInfoByApp(bundle: string) { + formManager.getFormsInfo(bundle) + .then((data) => { + console.info('[FormComponent] getFormsInfoByApp result:' + JSON.stringify(data)); + }); + } + + public async getFormsInfoByModule(bundle: string, moduleName: string) { + formManager.getFormsInfo(bundle, moduleName) + .then((data) => { + console.info('[FormComponent] getFormsInfoByModule result:' + JSON.stringify(data)); + }); + } + + public async clearFormUserCache() { + bundleManager.cleanBundleCacheFiles('com.ohos.myapplicationform') + .then((data) => { + console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data)); + }); + } + + public async clearFormProviderCache(bundle: string) { + bundleManager.cleanBundleCacheFiles(bundle) + .then((data) => { + console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data)); + }); + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_enable/entry/src/main/ets/MainAbility/pages/index.ets b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_enable/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..0d531eff10a6aaa0e89517f397aea3c59d8b558f --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_enable/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,68 @@ +/* + * 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. + */ + +// @ts-nocheck +import featureAbility from "@ohos.ability.featureAbility"; +import file from '@system.file'; +import { Core, ExpectExtend, ReportExtend } from "deccjsunit/index.ets"; +import testsuite from "../test/List.test.ets"; + +@Entry +@Component +struct Index { + + aboutToAppear() { + + console.info("[FormComponent] start run testcase!!!!"); + + featureAbility.getWant() + .then((want: any) => { + console.info('[FormComponent] Operation successful. Data: ' + JSON.stringify(want)); + const core = Core.getInstance(); + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }); + core.addService('expect', expectExtend); + const reportExtend = new ReportExtend(file); + core.addService('report', reportExtend); + core.init(); + core.subscribeEvent('task', reportExtend); + const configService = core.getDefaultService('config'); + want.parameters['timeout'] = 30000; + console.info('[FormComponent] parameters---->' + JSON.stringify(want.parameters)); + configService.setConfig(want.parameters); + testsuite(); + core.execute(); + }) + .catch((error: any) => { + console.error('[FormComponent] Operation failed. Cause: ' + JSON.stringify(error)); + }) + } + + build() { + Flex({ + direction: FlexDirection.Column, + alignItems: ItemAlign.Center, + justifyContent: FlexAlign.Center + }) { + Text('Fms Main Ability Test') + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + .height('100%') + } +} + diff --git a/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_enable/entry/src/main/ets/MainAbility/test/FmsFormStateEnable.test.ets b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_enable/entry/src/main/ets/MainAbility/test/FmsFormStateEnable.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..058639ef7929ba43d61f53442e6a729441a63fe1 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_enable/entry/src/main/ets/MainAbility/test/FmsFormStateEnable.test.ets @@ -0,0 +1,1026 @@ +/* + * 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 featureAbility from "@ohos.ability.featureAbility"; +import commonEvent from '@ohos.commonEvent'; +import { beforeAll, describe, expect, it } from "deccjsunit/index.ets"; + +var onErrorForm_Event = { + events: ["FMS_FormOnError_commonEvent"], +}; +var onAcquiredForm_Event = { + events: ["FMS_FormOnAcquired_commonEvent"], +}; + +var onDeletedFormEvent = { + events: ["FMS_FormOnDeleted_commonEvent"], +}; + +var onStateFormEvent = { + events: ["FMS_FormOnState_commonEvent"], +}; + +var onSupplyEvent = { + events: ["FMS_FormSupply_commonEvent"], +}; + +var deleteForm_Event = "FMS_FormDelete_commonEvent"; + +export default function test() { + describe(`FmsStateFormTest`, () => { + + beforeAll(async (done) => { + done(); + }) + + /** + * @tc.number: FMS_enableFormsUpdate_0200 + * @tc.name: The form user does not have permission. + * @tc.desc: 1.The form user calls the enable update interface. + * 2.Verify the result of the enable update interface. + */ + it(`FMS_enableFormsUpdate_0200`, 0, async (done) => { + console.log(`FMS_enableFormsUpdate_0200 start`); + let subscriberOnState; + + function onStateCallBack(err, data) { + console.info("!!!====>FMS_enableFormsUpdate_0200 onStateCallBack data:====>" + JSON.stringify(data)); + expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); + expect(data.data).assertEqual("2"); + commonEvent.unsubscribe(subscriberOnState, unsubscribeOnStateCallBack); + setTimeout(function () { + console.info('FMS_enableFormsUpdate_0200 onStateCallBack end'); + console.log(`FMS_enableFormsUpdate_0200 end`); + done(); + }, 1000); + } + function unsubscribeOnStateCallBack() { + console.debug("====>FMS_enableFormsUpdate_0200 unsubscribeOnStateCallBack====>"); + } + + commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { + console.debug("====>FMS_enableFormsUpdate_0200 onStateFormEvent Subscriber====>"); + subscriberOnState = data; + await commonEvent.subscribe(subscriberOnState, onStateCallBack); + }); + + console.log(`FMS_enableFormsUpdate_0200 featureAbility.startAbility again start`); + featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostnoperm", + abilityName: "com.ohos.st.formsystemhostnoperm.MainAbility", + parameters: { + "formId" : "0", + "name" : "Form_Js001", + "bundle" : "com.form.formsystemtestservicea.hmservice", + "ability" : "com.form.formsystemtestservicea.hmservice.FormAbility", + "moduleName" : "entry", + "temporary" : false, + "stateForm" : "enable", + "stateIds" : ["1"], + "isCreate" : false + } + } + }).then((res: any) => { + console.log(`FMS_enableFormsUpdate_0200 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_enableFormsUpdate_0200 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_enableFormsUpdate_0200 featureAbility.startAbility again end`); + }); + /** + * @tc.number: FMS_enableFormsUpdate_0300 + * @tc.name: The length of the formId list is 0 (no formId) + * @tc.desc: 1.The form user calls the enable update interface. + * 2.Verify the result of the enable update interface. + */ + it(`FMS_enableFormsUpdate_0300`, 0, async (done) => { + console.log(`FMS_enableFormsUpdate_0300 start`); + let subscriberOnState; + let formId; + + function onStateCallBack(err, data) { + console.info("!!!====>FMS_enableFormsUpdate_0300 onStateCallBack data:====>" + JSON.stringify(data)); + expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); + expect(data.data).assertEqual("7"); + commonEvent.unsubscribe(subscriberOnState, unSubscribeOnStateCallback) + + setTimeout(function () { + console.info('FMS_enableFormsUpdate_0300 delPublishCallBack end'); + console.log(`FMS_enableFormsUpdate_0300 end`); + done(); + }, 100) + } + function unSubscribeOnStateCallback() { + console.debug("====>FMS_enableFormsUpdate_0300 unSubscribeOnStateCallback CallBack====>"); + } + + commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { + console.debug("====>FMS_enableFormsUpdate_0300 onStateFormEvent Subscriber====>"); + subscriberOnState = data; + await commonEvent.subscribe(subscriberOnState, onStateCallBack); + }); + console.log(`FMS_enableFormsUpdate_0300 featureAbility.startAbility start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "Form_Js001", + "bundle" : "com.form.formsystemtestservicea.hmservice", + "ability" : "com.form.formsystemtestservicea.hmservice.FormAbility", + "moduleName" : "entry", + "temporary" : false, + "stateForm" : "enable", + "stateIds" : [], + "isCreate" : false + } + } + }).then((res: any) => { + console.log(`FMS_enableFormsUpdate_0300 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_enableFormsUpdate_0300 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_enableFormsUpdate_0300 featureAbility.startAbility end`); + }); + /** + * @tc.number: FMS_enableFormsUpdate_0400 + * @tc.name: formID id is error(formID < 0) + * @tc.desc: 1.The form user calls the enable update interface. + * 2.Verify the result of the enable update interface. + */ + it(`FMS_enableFormsUpdate_0400`, 0, async (done) => { + console.log(`FMS_enableFormsUpdate_0400 start`); + let subscriberOnState; + let formId; + + function onStateCallBack(err, data) { + console.info("!!!====>FMS_enableFormsUpdate_0400 onStateCallBack data:====>" + JSON.stringify(data)); + expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); + expect(data.data).assertEqual("13"); + commonEvent.unsubscribe(subscriberOnState, unSubscribeOnStateCallback) + + setTimeout(function () { + console.info('FMS_enableFormsUpdate_0400 delPublishCallBack end'); + console.log(`FMS_enableFormsUpdate_0400 end`); + done(); + }, 100) + } + function unSubscribeOnStateCallback() { + console.debug("====>FMS_enableFormsUpdate_0400 unSubscribeOnStateCallback CallBack====>"); + } + + commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { + console.debug("====>FMS_enableFormsUpdate_0400 onStateFormEvent Subscriber====>"); + subscriberOnState = data; + await commonEvent.subscribe(subscriberOnState, onStateCallBack); + }); + console.log(`FMS_enableFormsUpdate_0400 featureAbility.startAbility start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "Form_Js001", + "bundle" : "com.form.formsystemtestservicea.hmservice", + "ability" : "com.form.formsystemtestservicea.hmservice.FormAbility", + "moduleName" : "entry", + "temporary" : false, + "stateForm" : "enable", + "stateIds" : ["-1"], + "isCreate" : false + } + } + }).then((res: any) => { + console.log(`FMS_enableFormsUpdate_0400 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_enableFormsUpdate_0400 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_enableFormsUpdate_0400 featureAbility.startAbility end`); + }); + /** + * @tc.number: FMS_enableFormsUpdate_0500 + * @tc.name: formID id is error(formID == 0) + * @tc.desc: 1.The form user calls the enable update interface. + * 2.Verify the result of the enable update interface. + */ + it(`FMS_enableFormsUpdate_0500`, 0, async (done) => { + console.log(`FMS_enableFormsUpdate_0500 start`); + let subscriberOnState; + let formId; + + function onStateCallBack(err, data) { + console.info("!!!====>FMS_enableFormsUpdate_0500 onStateCallBack data:====>" + JSON.stringify(data)); + expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); + expect(data.data).assertEqual("13"); + commonEvent.unsubscribe(subscriberOnState, unSubscribeOnStateCallback) + + setTimeout(function () { + console.info('FMS_enableFormsUpdate_0500 delPublishCallBack end'); + console.log(`FMS_enableFormsUpdate_0500 end`); + done(); + }, 100) + } + function unSubscribeOnStateCallback() { + console.debug("====>FMS_enableFormsUpdate_0500 unSubscribeOnStateCallback CallBack====>"); + } + + commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { + console.debug("====>FMS_enableFormsUpdate_0500 onStateFormEvent Subscriber====>"); + subscriberOnState = data; + await commonEvent.subscribe(subscriberOnState, onStateCallBack); + }); + console.log(`FMS_enableFormsUpdate_0500 featureAbility.startAbility start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "Form_Js001", + "bundle" : "com.form.formsystemtestservicea.hmservice", + "ability" : "com.form.formsystemtestservicea.hmservice.FormAbility", + "moduleName" : "entry", + "temporary" : false, + "stateForm" : "enable", + "stateIds" : ["0"], + "isCreate" : false + } + } + }).then((res: any) => { + console.log(`FMS_enableFormsUpdate_0500 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_enableFormsUpdate_0500 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_enableFormsUpdate_0500 featureAbility.startAbility end`); + }); + /** + * @tc.number: FMS_enableFormsUpdate_0600 + * @tc.name: formID id is error because formId is not self + * @tc.desc: 1.The form user calls the enable update interface. + * 2.Verify the result of the enable update interface. + */ + it(`FMS_enableFormsUpdate_0600`, 0, async (done) => { + console.info(`FMS_enableFormsUpdate_0600 start`); + let subscriberOnAcquired; + let subscriberEnable; + let hostFormId; + + const delPublishCallback = (err, data) => { + console.info("!!!====>FMS_enableFormsUpdate_0600 delPublishCallback====>"); + setTimeout(() => { + console.info('FMS_enableFormsUpdate_0600 delPublishCallback end'); + console.info(`FMS_enableFormsUpdate_0600 end`); + done(); + }, 1000); + } + + const onEnableCallback = (err, data) => { + if (data.parameters.kind != "enable") { + return; + } + console.debug("====>FMS_enableFormsUpdate_0600 onEnableCallback data:====>" + JSON.stringify(data)); + + expect(data.data).assertEqual("13"); + commonEvent.unsubscribe(subscriberEnable, () => { + console.info("====>FMS_enableFormsUpdate_0600 unSubscribeOnEnableCallback====>"); + }); + const commonEventPublishData = { + data: hostFormId + }; + commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallback); + } + + const onAcquiredCallBack = async (err, data) => { + console.debug("====>FMS_enableFormsUpdate_0600 onAcquiredCallback data:====>" + JSON.stringify(data)); + hostFormId = data.data; + + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId": hostFormId, + "name": "Form_Js001", + "bundle": "com.form.formsystemtestservicef.hmservice", + "ability": "com.form.formsystemtestservicef.hmservice.FormAbility", + "moduleName": "entry", + "temporary": false, + "stateForm": "enable", + "stateIds": [hostFormId], + "isCreate": false + } + } + }).then((res: any) => { + console.debug(`FMS_enableFormsUpdate_0600 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.debug(`FMS_enableFormsUpdate_0600 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + commonEvent.unsubscribe(subscriberOnAcquired, () => { + console.info("====>FMS_enableFormsUpdate_0600 unSubscribeOnAcquiredCallback====>"); + }); + } + + commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => { + console.debug("====>FMS_enableFormsUpdate_0600 onAcquiredFormEvent Subscriber====>"); + subscriberOnAcquired = data; + await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack); + }); + commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { + console.info("====>FMS_enableFormsUpdate_0600 onStateFormEvent Enable Subscriber====>"); + subscriberEnable = data; + await commonEvent.subscribe(subscriberEnable, onEnableCallback); + }); + + console.info(`FMS_enableFormsUpdate_0600 featureAbility.startAbility start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostf", + abilityName: "com.ohos.st.formsystemhostf.MainAbility", + parameters: { + "formId": "0", + "name": "Form_Js001", + "bundle": "com.form.formsystemtestservicef.hmservice", + "ability": "com.form.formsystemtestservicef.hmservice.FormAbility", + "moduleName": "entry", + "temporary": false, + "isCreate": true + } + } + }).then((res: any) => { + console.debug(`FMS_enableFormsUpdate_0600 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.debug(`FMS_enableFormsUpdate_0600 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + }); + /** + * @tc.number: FMS_enableFormsUpdate_0700 + * @tc.name: formID id is error because formId is not exist + * @tc.desc: 1.The form user calls the enable update interface. + * 2.Verify the result of the enable update interface. + */ + it(`FMS_enableFormsUpdate_0700`, 0, async (done) => { + console.info(`FMS_enableFormsUpdate_0700 start`); + let subscriberDel; + let subscriberEnable; + let hostFormId; + + const onEnableCallback = (err, data) => { + if (data.parameters.kind != "enable") { + return; + } + console.debug("====>FMS_enableFormsUpdate_0700 onEnableCallback data:====>" + JSON.stringify(data)); + + expect(data.data).assertEqual("13"); + commonEvent.unsubscribe(subscriberEnable, () => { + console.info("====>FMS_enableFormsUpdate_0700 unSubscribeOnEnableCallback====>"); + }); + done(); + } + + const onDeleteCallback = async (err, data) => { + console.debug("====>FMS_enableFormsUpdate_0700 onDeleteCallback data:====>" + JSON.stringify(data)); + hostFormId = data.parameters.formId; + + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId": "0", + "name": "Form_Js001", + "bundle": "com.form.formsystemtestservicef.hmservice", + "ability": "com.form.formsystemtestservicef.hmservice.FormAbility", + "moduleName": "entry", + "temporary": false, + "stateForm": "enable", + "stateIds": [hostFormId], + "isCreate": false + } + } + }).then((res: any) => { + console.debug(`FMS_enableFormsUpdate_0700 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.debug(`FMS_enableFormsUpdate_0700 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + + commonEvent.unsubscribe(subscriberDel, () => { + console.info("====>FMS_enableFormsUpdate_0700 unSubscribeDelCallback====>"); + }); + } + + commonEvent.createSubscriber(onDeletedFormEvent).then(async (data) => { + console.info("====>FMS_enableFormsUpdate_0700 onDeletedFormEvent Invisible Subscriber====>"); + subscriberDel = data; + await commonEvent.subscribe(subscriberDel, onDeleteCallback); + }); + commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { + console.info("====>FMS_enableFormsUpdate_0700 onStateFormEvent Enable Subscriber====>"); + subscriberEnable = data; + await commonEvent.subscribe(subscriberEnable, onEnableCallback); + }); + + console.info(`FMS_enableFormsUpdate_0700 featureAbility.startAbility start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId": "0", + "name": "Form_Js001", + "bundle": "com.form.formsystemtestservicef.hmservice", + "ability": "com.form.formsystemtestservicef.hmservice.FormAbility", + "moduleName": "entry", + "temporary": false, + "deleteForm": true, + "deleteId": "self", + "isCreate": true + } + } + }).then((res: any) => { + console.debug(`FMS_enableFormsUpdate_0700 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.debug(`FMS_enableFormsUpdate_0700 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + }); + + /** + * @tc.number: FMS_enableFormsUpdate_0900 + * @tc.name: Use -1 form Id and created 2 form card Id notify the form to be invisible. + * @tc.desc: 1.The form user calls the visible notification interface. + * 2.Verify the result of the visible notification interface. + */ + it(`FMS_enableFormsUpdate_0900`, 0, async (done) => { + console.log(`FMS_enableFormsUpdate_0900 start`); + let subscriberOnAcquired; + let subscriberStatus; + let subscriberEnable; + let subscriberSupply; + let formIds = []; + + // timer speed up + commonEvent.publish(`fms.time_speed`, { code: 300 }, () => { + console.log(`FMS_enableFormsUpdate_0900 time speed up`); + }); + + function unSubscribeSupplyCallback() { + console.debug("====>FMS_enableFormsUpdate_0900 unSubscribeSupplyCallback====>"); + } + function delPublishCallBack(err, data) { + console.info("!!!====>FMS_enableFormsUpdate_0900 delPublishCallBack====>" + JSON.stringify(data)); + setTimeout(function () { + console.info('FMS_enableFormsUpdate_0900 delPublishCallBack end'); + console.log(`FMS_enableFormsUpdate_0900 end`); + done(); + }, 1000); + } + + function onUpdateCallBack(err, data) { + if (data.parameters.kind == "onUpdate") { + expect(data.event).assertEqual("FMS_FormSupply_commonEvent"); + console.debug("====>FMS_enableFormsUpdate_0900 onUpdateCallBack====>" + JSON.stringify(data)); + expect(data.parameters.parameters).assertEqual(formIds[0]); + + commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback); + + commonEvent.publish(`fms.time_speed`, { code: 1 }, () => { + console.log(`FMS_enableFormsUpdate_0900 time reset`); + }); + + setTimeout(() => { + let commonEventPublishData = { + data: formIds[0] + }; + commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); + }, 2000); + } + } + + function onFormEnableCallBack(err, data) { + expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); + console.debug("====>FMS_enableFormsUpdate_0900 onFormEnableCallBack====>" + JSON.stringify(data)); + expect(data.parameters.formId).assertEqual(formIds[0]); + expect(data.parameters.kind).assertEqual("enable"); + commonEvent.unsubscribe(subscriberEnable, unSubscribeSupplyCallback); + } + + function onFormDisableCallBack(err, data) { + expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); + console.debug("====>FMS_enableFormsUpdate_0900 onFormDisableCallBack====>" + JSON.stringify(data)); + expect(data.parameters.formId).assertEqual(formIds[0]); + expect(data.parameters.kind).assertEqual("disable"); + commonEvent.unsubscribe(subscriberStatus, unSubscribeSupplyCallback); + + commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { + console.debug("====>FMS_enableFormsUpdate_0900 onStateFormEvent Subscriber====>"); + subscriberEnable = data; + await commonEvent.subscribe(subscriberEnable, onFormEnableCallBack); + }); + + commonEvent.createSubscriber(onSupplyEvent).then(async (data) => { + console.debug("====>FMS_enableFormsUpdate_0900 onSupplyEvent Subscriber====>"); + subscriberSupply = data; + await commonEvent.subscribe(subscriberSupply, onUpdateCallBack); + }); + + setTimeout(() => { + console.log(`FMS_enableFormsUpdate_0900 featureAbility.startAbility notifyVisible start`); + featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "name", + "bundle" : "bundle", + "ability" : "ability", + "moduleName" : "entry", + "temporary" : false, + "stateForm" : "enable", + "stateIds" : formIds, + "isCreate" : false + } + } + }).then((res: any) => { + console.log(`FMS_enableFormsUpdate_0900 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_enableFormsUpdate_0900 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_enableFormsUpdate_0900 featureAbility.startAbility notifyVisible end`); + }, 10000); + } + + function onAcquiredCallBack(err, data) { + expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent"); + commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeSupplyCallback); + console.debug("====>FMS_enableFormsUpdate_0900 onAcquiredCallBack====>" + JSON.stringify(data)); + formIds.push(data.data); + + commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { + console.debug("====>FMS_enableFormsUpdate_0900 onStateFormEvent Subscriber====>"); + subscriberStatus = data; + await commonEvent.subscribe(subscriberStatus, onFormDisableCallBack); + }); + + console.log(`FMS_enableFormsUpdate_0900 featureAbility.startAbility notify disable start`); + featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "name", + "bundle" : "bundle", + "ability" : "ability", + "moduleName" : "entry", + "temporary" : false, + "stateForm" : "disable", + "stateIds" : formIds, + "isCreate" : false + } + } + }).then((res: any) => { + console.log(`FMS_enableFormsUpdate_0900 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_enableFormsUpdate_0900 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_enableFormsUpdate_0900 featureAbility.startAbility notify disable end`); + } + + commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => { + console.debug("====>FMS_enableFormsUpdate_0900 onAcquiredForm_Event Subscriber====>"); + subscriberOnAcquired = data; + await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack); + }); + console.log(`FMS_enableFormsUpdate_0900 featureAbility.startAbility servicea start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "Form_Js001", + "bundle" : "com.form.formsystemtestservicee.hmservice", + "ability" : "com.form.formsystemtestservicee.hmservice.FormAbility", + "moduleName" : "entry", + "temporary" : false, + "isCreate" : true + } + } + }).then((res: any) => { + console.log(`FMS_enableFormsUpdate_0900 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_enableFormsUpdate_0900 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_enableFormsUpdate_0900 featureAbility.startAbility servicea end`); + }); + + /** + * @tc.number: FMS_enableFormsUpdate_1000 + * @tc.name: Use -1 form Id and created 2 form card Id notify the form to be invisible. + * @tc.desc: 1.The form user calls the visible notification interface. + * 2.Verify the result of the visible notification interface. + */ + it(`FMS_enableFormsUpdate_1000`, 0, async (done) => { + console.log(`FMS_enableFormsUpdate_1000 start`); + let subscriberOnAcquired; + let subscriberStatus; + let subscriberEnable; + let subscriberSupply; + let formIds = []; + + // timer speed up + commonEvent.publish(`fms.time_speed`, { code: 300 }, () => { + console.log(`FMS_enableFormsUpdate_1000 time speed up`); + }); + + function unSubscribeSupplyCallback() { + console.debug("====>FMS_enableFormsUpdate_1000 unSubscribeSupplyCallback====>"); + } + function delPublishCallBack(err, data) { + console.info("!!!====>FMS_enableFormsUpdate_1000 delPublishCallBack====>" + JSON.stringify(data)); + setTimeout(function () { + console.info('FMS_enableFormsUpdate_1000 delPublishCallBack end'); + console.log(`FMS_enableFormsUpdate_1000 end`); + done(); + }, 1000); + } + + function onUpdateCallBack(err, data) { + if (data.parameters.kind == "onUpdate") { + expect(data.event).assertEqual("FMS_FormSupply_commonEvent"); + console.debug("====>FMS_enableFormsUpdate_1000 onUpdateCallBack====>" + JSON.stringify(data)); + expect(data.parameters.parameters).assertEqual(formIds[0]); + + commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback); + + commonEvent.publish(`fms.time_speed`, { code: 1 }, () => { + console.log(`FMS_enableFormsUpdate_1000 time reset`); + }); + + setTimeout(() => { + let commonEventPublishData = { + data: formIds[0] + }; + commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); + }, 2000); + } + } + + function onFormEnableCallBack(err, data) { + expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); + console.debug("====>FMS_enableFormsUpdate_1000 onFormEnableCallBack====>" + JSON.stringify(data)); + expect(data.parameters.formId).assertEqual(formIds[0]); + expect(data.parameters.kind).assertEqual("enable"); + commonEvent.unsubscribe(subscriberEnable, unSubscribeSupplyCallback); + } + + function onFormDisableCallBack(err, data) { + expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); + console.debug("====>FMS_enableFormsUpdate_1000 onFormDisableCallBack====>" + JSON.stringify(data)); + expect(data.parameters.formId).assertEqual(formIds[0]); + expect(data.parameters.kind).assertEqual("disable"); + commonEvent.unsubscribe(subscriberStatus, unSubscribeSupplyCallback); + + commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { + console.debug("====>FMS_enableFormsUpdate_1000 onStateFormEvent Subscriber====>"); + subscriberEnable = data; + await commonEvent.subscribe(subscriberEnable, onFormEnableCallBack); + }); + + commonEvent.createSubscriber(onSupplyEvent).then(async (data) => { + console.debug("====>FMS_enableFormsUpdate_1000 onSupplyEvent Subscriber====>"); + subscriberSupply = data; + await commonEvent.subscribe(subscriberSupply, onUpdateCallBack); + }); + + setTimeout(() => { + console.log(`FMS_enableFormsUpdate_1000 featureAbility.startAbility notifyVisible start`); + formIds.push("0"); + featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "name", + "bundle" : "bundle", + "ability" : "ability", + "moduleName" : "entry", + "temporary" : false, + "stateForm" : "enable", + "stateIds" : formIds, + "isCreate" : false + } + } + }).then((res: any) => { + console.log(`FMS_enableFormsUpdate_1000 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_enableFormsUpdate_1000 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_enableFormsUpdate_1000 featureAbility.startAbility notifyVisible end`); + }, 10000); + } + + function onAcquiredCallBack(err, data) { + expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent"); + commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeSupplyCallback); + console.debug("====>FMS_enableFormsUpdate_1000 onAcquiredCallBack====>" + JSON.stringify(data)); + formIds.push(data.data); + + commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { + console.debug("====>FMS_enableFormsUpdate_1000 onStateFormEvent Subscriber====>"); + subscriberStatus = data; + await commonEvent.subscribe(subscriberStatus, onFormDisableCallBack); + }); + + console.log(`FMS_enableFormsUpdate_1000 featureAbility.startAbility notify disable start`); + featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "name", + "bundle" : "bundle", + "ability" : "ability", + "moduleName" : "entry", + "temporary" : false, + "stateForm" : "disable", + "stateIds" : formIds, + "isCreate" : false + } + } + }).then((res: any) => { + console.log(`FMS_enableFormsUpdate_1000 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_enableFormsUpdate_1000 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_enableFormsUpdate_1000 featureAbility.startAbility notify disable end`); + } + + commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => { + console.debug("====>FMS_enableFormsUpdate_1000 onAcquiredForm_Event Subscriber====>"); + subscriberOnAcquired = data; + await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack); + }); + console.log(`FMS_enableFormsUpdate_1000 featureAbility.startAbility servicea start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "Form_Js001", + "bundle" : "com.form.formsystemtestservicee.hmservice", + "ability" : "com.form.formsystemtestservicee.hmservice.FormAbility", + "moduleName" : "entry", + "temporary" : false, + "isCreate" : true + } + } + }).then((res: any) => { + console.log(`FMS_enableFormsUpdate_1000 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_enableFormsUpdate_1000 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_enableFormsUpdate_1000 featureAbility.startAbility servicea end`); + }); + + /** + * @tc.number: FMS_enableFormsUpdate_1200 + * @tc.name: Use -1 form Id and created 2 form card Id notify the form to be visible. + * @tc.desc: 1.The form user calls the visible notification interface. + * 2.Verify the result of the visible notification interface. + */ + it(`FMS_enableFormsUpdate_1200`, 0, async (done) => { + console.log(`FMS_enableFormsUpdate_1200 start`); + let subscriberOnAcquired; + let subscriberSupply; + let formIds = new Array(); + let retFormId; + let subscriberStatus; + let subscriberEnable; + let count = 0; + + // timer speed up + commonEvent.publish(`fms.time_speed`, { code: 300 }, () => { + console.log(`FMS_enableFormsUpdate_1200 time speed up`); + }); + + function unSubscribeSupplyCallback() { + console.debug("====>FMS_enableFormsUpdate_1200 unSubscribeSupplyCallback====>"); + } + function delPublishCallBack1(err, data) { + console.info("!!!====>FMS_notifyInvisibleForms_1400 delPublishCallBack1====>" + JSON.stringify(data)); + setTimeout(function () { + console.info('FMS_notifyInvisibleForms_1400 delPublishCallBack1 end'); + console.log(`FMS_notifyInvisibleForms_1400 end`); + }, 1000); + } + function delPublishCallBack2(err, data) { + console.info("!!!====>FMS_notifyInvisibleForms_1400 delPublishCallBack2====>" + JSON.stringify(data)); + setTimeout(function () { + console.info('FMS_notifyInvisibleForms_1400 delPublishCallBack2 end'); + console.log(`FMS_notifyInvisibleForms_1400 end`); + done(); + }, 1000); + } + + function onUpdateCallBack(err, data) { + if (data.parameters.kind == "onUpdate") { + expect(data.event).assertEqual("FMS_FormSupply_commonEvent"); + console.debug("====>FMS_enableFormsUpdate_1200 onUpdateCallBack====>" + JSON.stringify(data)); + expect(formIds.includes(data.parameters.parameters)).assertEqual(true); + + ++count; + if (count == 2) { + console.debug("====>FMS_notifyInvisibleForms_1400 OK====>"); + commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback); + + commonEvent.publish(`fms.time_speed`, { code: 1 }, () => { + console.log(`FMS_enableFormsUpdate_1200 time reset`); + }); + + setTimeout(() => { + let commonEventPublishData1 = { + data: formIds[0] + }; + commonEvent.publish(deleteForm_Event, commonEventPublishData1, delPublishCallBack1); + let commonEventPublishData2 = { + data: formIds[1] + }; + commonEvent.publish(deleteForm_Event, commonEventPublishData2, delPublishCallBack2); + }, 2000); + } + } + } + + function onFormEnableCallBack(err, data) { + expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); + console.debug("====>FMS_enableFormsUpdate_1200 onFormEnableCallBack====>" + JSON.stringify(data)); + expect(data.parameters.kind).assertEqual("enable"); + commonEvent.unsubscribe(subscriberEnable, unSubscribeSupplyCallback); + } + + function onFormDisableCallBack(err, data) { + expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); + console.debug("====>FMS_enableFormsUpdate_1200 onFormDisableCallBack====>" + JSON.stringify(data)); + commonEvent.unsubscribe(subscriberStatus, unSubscribeSupplyCallback); + + commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { + console.debug("====>FMS_enableFormsUpdate_1200 onStateFormEvent Subscriber====>"); + subscriberEnable = data; + await commonEvent.subscribe(subscriberEnable, onFormEnableCallBack); + }); + + commonEvent.createSubscriber(onSupplyEvent).then(async (data) => { + console.debug("====>FMS_enableFormsUpdate_1200 onSupplyEvent Subscriber====>"); + subscriberSupply = data; + await commonEvent.subscribe(subscriberSupply, onUpdateCallBack); + }); + + setTimeout(() => { + console.log(`FMS_enableFormsUpdate_1200 featureAbility.startAbility notifyVisible start`); + formIds.push("0"); + featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "name", + "bundle" : "bundle", + "ability" : "ability", + "moduleName" : "entry", + "temporary" : false, + "stateForm" : "enable", + "stateIds" : formIds, + "isCreate" : false + } + } + }).then((res: any) => { + console.log(`FMS_enableFormsUpdate_1200 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_enableFormsUpdate_1200 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_enableFormsUpdate_1200 featureAbility.startAbility notifyVisible end`); + }, 10000); + } + + async function onSecondAcquiredCallBack(err, data) { + expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent"); + commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeSupplyCallback); + console.debug("====>FMS_enableFormsUpdate_1200 onSecondAcquiredCallBack====>" + JSON.stringify(data)); + formIds.push(data.data); + console.debug("====>FMS_enableFormsUpdate_1200 formIds====>" + formIds); + + commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { + console.debug("====>FMS_enableFormsUpdate_1200 onStateFormEvent Subscriber====>"); + subscriberStatus = data; + await commonEvent.subscribe(subscriberStatus, onFormDisableCallBack); + }); + + console.log(`FMS_enableFormsUpdate_1200 featureAbility.startAbility notify disable start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "name", + "bundle" : "bundle", + "ability" : "ability", + "moduleName" : "entry", + "temporary" : false, + "stateForm" : "disable", + "stateIds" : formIds, + "isCreate" : false + } + } + }).then((res: any) => { + console.log(`FMS_enableFormsUpdate_1200 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_enableFormsUpdate_1200 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_enableFormsUpdate_1200 featureAbility.startAbility notify disable end`); + } + + async function onFirstAcquiredCallBack(err, data) { + expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent"); + commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeSupplyCallback); + console.debug("====>FMS_enableFormsUpdate_1200 onFirstAcquiredCallBack====>" + JSON.stringify(data)); + formIds.push(data.data); + + commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => { + console.debug("====>FMS_enableFormsUpdate_1200 onAcquiredForm_Event Subscriber====>"); + subscriberOnAcquired = data; + await commonEvent.subscribe(subscriberOnAcquired, onSecondAcquiredCallBack); + }); + + console.log(`FMS_enableFormsUpdate_1200 featureAbility.startAbility serviceb start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "Form_Js001", + "bundle" : "com.form.formsystemtestserviceh.hmservice", + "ability" : "com.form.formsystemtestserviceh.hmservice.FormAbility", + "moduleName" : "entry", + "temporary" : false, + "isCreate" : true + } + } + }).then((res: any) => { + console.log(`FMS_enableFormsUpdate_1200 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_enableFormsUpdate_1200 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_enableFormsUpdate_1200 featureAbility.startAbility serviceb end`); + } + + commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => { + console.debug("====>FMS_enableFormsUpdate_1200 onAcquiredForm_Event Subscriber====>"); + subscriberOnAcquired = data; + await commonEvent.subscribe(subscriberOnAcquired, onFirstAcquiredCallBack); + }); + console.log(`FMS_enableFormsUpdate_1200 featureAbility.startAbility servicea start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "Form_Js001", + "bundle" : "com.form.formsystemtestservicee.hmservice", + "ability" : "com.form.formsystemtestservicee.hmservice.FormAbility", + "moduleName" : "entry", + "temporary" : false, + "isCreate" : true + } + } + }).then((res: any) => { + console.log(`FMS_enableFormsUpdate_1200 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_enableFormsUpdate_1200 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_enableFormsUpdate_1200 featureAbility.startAbility servicea end`); + }); + }); +} diff --git a/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_enable/entry/src/main/ets/MainAbility/test/List.test.ets b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_enable/entry/src/main/ets/MainAbility/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..076280f4627a9d8c5b7f4b7b9f777d2765f6ee7b --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_enable/entry/src/main/ets/MainAbility/test/List.test.ets @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import test from './FmsFormStateEnable.test.ets'; + +export default function testsuite() { + test(); +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_enable/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_enable/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..d3a7164e21e4424a760d0def485e031e668883ed --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_enable/entry/src/main/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "formenablestatetest" + }, + { + "name": "description_mainability", + "value": "ETS_Empty Ability" + } + ] +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_enable/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_enable/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_enable/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_enable/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_enable/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_enable/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible/BUILD.gn b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..5030bc71b9ace589ff82276ed292995bf3bd3ea0 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible/BUILD.gn @@ -0,0 +1,32 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("FormStateNotifyInvisibleTest") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":hjs_demo_js_assets", + ":hjs_demo_resources", + ] + ets2abc = true + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "FormStateNotifyInvisibleTest" +} +ohos_js_assets("hjs_demo_js_assets") { + source_dir = "./entry/src/main/ets/MainAbility" +} +ohos_resources("hjs_demo_resources") { + sources = [ "./entry/src/main/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible/Test.json b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..93b5de06d41f58556eb2486c39b1bc34d2be7c92 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible/Test.json @@ -0,0 +1,23 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "300000", + "package": "com.ohos.st.formstatenotifyinvisibletest", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "FormStateNotifyInvisibleTest.hap", + "FormSystemHostF.hap", + "FormSystemHostG.hap", + "FormSystemHostNoPerm.hap", + "FormSupplyAppA.hap", + "FormSupplyAppF.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} diff --git a/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/config.json b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..ce10856f7c7998ea4b17818efc01aa08b47c4330 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/config.json @@ -0,0 +1,150 @@ +{ + "app": { + "bundleName": "com.ohos.st.formstatenotifyinvisibletest", + "vendor": "ohos", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 7, + "releaseType": "Release", + "target": 7 + } + }, + "deviceConfig": {}, + "module": { + "package": "com.ohos.st.formstatenotifyinvisibletest", + "name": ".FormStateSTApp", + "mainAbility": ".MainAbility", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": false + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "visible": true, + "name": ".MainAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:description_mainability", + "label": "$string:entry_MainAbility", + "type": "page", + "launchType": "standard" + } + ], + "defPermissions": [ + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormDelete_commonEvent" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormOnAcquired_commonEvent" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormOnError_commonEvent" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormOnDeleted_commonEvent" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormOnState_commonEvent" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormSupply_commonEvent" + } + ], + "reqPermissions": [ + { + "name": "FMS_FormOnAcquired_commonEvent", + "reason": "need use onAcquired commonEvent" + }, + { + "name": "FMS_FormDelete_commonEvent", + "reason": "need use delete commonEvent" + }, + { + "name": "FMS_FormOnError_commonEvent", + "reason": "need use OnError commonEvent" + }, + { + "name": "FMS_FormOnDeleted_commonEvent", + "reason": "need use OnDeleted commonEvent" + }, + { + "name": "FMS_FormOnState_commonEvent", + "reason": "need use OnState commonEvent" + }, + { + "name": "FMS_FormSupply_commonEvent", + "reason": "need use FormSupply commonEvent" + }, + { + "name": "ohos.permission.INSTALL_BUNDLE", + "reason": "need use ohos.permission.INSTALL_BUNDLE" + }, + { + "name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + }, + { + "name":"ohos.permission.CHANGE_ABILITY_ENABLED_STATE", + "reason":"need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE" + }, + { + "name":"ohos.permission.REMOVE_CACHE_FILES", + "reason":"need use ohos.permission.REMOVE_CACHE_FILES" + }, + { + "name":"ohos.permission.LISTEN_BUNDLE_CHANGE", + "reason":"need use ohos.permission.LISTEN_BUNDLE_CHANGE" + }, + { + "name":"ohos.permission.CLEAN_BACKGROUND_PROCESSES", + "reason":"need use ohos.permission.CLEAN_BACKGROUND_PROCESSES" + } + ], + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/ets/MainAbility/app.ets b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..83dd3d4f89d10e36cf17e9a1f7dba026f14c088b --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,23 @@ +/* + * 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. + */ + +export default { + onCreate() { + console.info('[FormComponent] Application onCreate') + }, + onDestroy() { + console.info('[FormComponent] Application onDestroy') + }, +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/ets/MainAbility/model/FormViewModel.ets b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/ets/MainAbility/model/FormViewModel.ets new file mode 100644 index 0000000000000000000000000000000000000000..462affde744956c2f7db057285fb6356d3fd475e --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/ets/MainAbility/model/FormViewModel.ets @@ -0,0 +1,131 @@ +/* + * 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 formManager from '@ohos.ability.formmanager'; +import bundleManager from '@ohos.bundle'; + +export default class FormViewModel { + private static sFormViewModel: FormViewModel = null; + + public static getInstance(): FormViewModel { + if (FormViewModel.sFormViewModel == null) { + FormViewModel.sFormViewModel = new FormViewModel(); + } + return FormViewModel.sFormViewModel; + } + + public async requestForm(formId: string) { + formManager.requestForm(formId) + .then((data) => { + console.info( '[FormComponent] requestForm result:' + data); + }); + } + + public async deleteCard(formId: string) { + formManager.deleteForm(formId) + .then((data) => { + console.info('[FormComponent] deleteForm result:' + data); + }); + } + + public async releaseCard(formId: string) { + formManager.releaseForm(formId) + .then((data) => { + console.info('[FormComponent] releaseForm result:' + data); + }); + } + + public async castTempToNormal(formId: string) { + formManager.castTempForm(formId) + .then((data) => { + console.info('[FormComponent] castTempToNormal result:' + data); + }); + } + + public async enableCard(formId: string) { + formManager.enableFormsUpdate([formId]) + .then((data) => { + console.info('[FormComponent] enableFormsUpdate result:' + data); + }); + } + + public async disableCard(formId: string) { + formManager.disableFormsUpdate([formId]) + .then((data) => { + console.info('[FormComponent] disableCard result:' + data); + }); + } + + public async changeCardVisible(formId: string, isVisible: boolean) { + if (isVisible) { + formManager.notifyVisibleForms([formId]) + .then((data) => { + console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible); + }); + } else { + formManager.notifyInvisibleForms([formId]) + .then((data) => { + console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible); + }); + } + } + + public async isFmsReady() { + formManager.isSystemReady() + .then((data) => { + console.info('[FormComponent] isFmsReady result:' + data); + }); + } + + public async getAllFormsInfo() { + console.info("[FormComponent] getAllFormsInfo start"); + formManager.getAllFormsInfo() + .then((data) => { + console.info('[FormComponent] getAllFormsInfo result:' + JSON.stringify(data)); + }) + .catch((err) => { + console.info('[FormComponent] getAllFormsInfo error:' + JSON.stringify(err)); + }); + console.info("[FormComponent] getAllFormsInfo end"); + } + + public async getFormsInfoByApp(bundle: string) { + formManager.getFormsInfo(bundle) + .then((data) => { + console.info('[FormComponent] getFormsInfoByApp result:' + JSON.stringify(data)); + }); + } + + public async getFormsInfoByModule(bundle: string, moduleName: string) { + formManager.getFormsInfo(bundle, moduleName) + .then((data) => { + console.info('[FormComponent] getFormsInfoByModule result:' + JSON.stringify(data)); + }); + } + + public async clearFormUserCache() { + bundleManager.cleanBundleCacheFiles('com.ohos.myapplicationform') + .then((data) => { + console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data)); + }); + } + + public async clearFormProviderCache(bundle: string) { + bundleManager.cleanBundleCacheFiles(bundle) + .then((data) => { + console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data)); + }); + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/ets/MainAbility/pages/index.ets b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..07cb76f5af58c6f15b68bfaa8a7402c4a5c9252f --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,68 @@ +/* + * 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. + */ + +// @ts-nocheck +import featureAbility from "@ohos.ability.featureAbility"; +import file from '@system.file'; +import { Core, ExpectExtend, ReportExtend } from "deccjsunit/index.ets"; +import testsuite from "../test/List.test.ets"; + +@Entry +@Component +struct Index { + + aboutToAppear() { + + console.info("[FormComponent] start run testcase!!!!"); + + featureAbility.getWant() + .then((want: any) => { + console.info('[FormComponent] Operation successful. Data: ' + JSON.stringify(want)); + const core = Core.getInstance(); + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }); + core.addService('expect', expectExtend); + const reportExtend = new ReportExtend(file); + core.addService('report', reportExtend); + core.init(); + core.subscribeEvent('task', reportExtend); + const configService = core.getDefaultService('config'); + want.parameters['timeout'] = 10000; + console.info('[FormComponent] parameters---->' + JSON.stringify(want.parameters)); + configService.setConfig(want.parameters); + testsuite(); + core.execute(); + }) + .catch((error: any) => { + console.error('[FormComponent] Operation failed. Cause: ' + JSON.stringify(error)); + }) + } + + build() { + Flex({ + direction: FlexDirection.Column, + alignItems: ItemAlign.Center, + justifyContent: FlexAlign.Center + }) { + Text('Fms Main Ability Test') + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + .height('100%') + } +} + diff --git a/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/ets/MainAbility/test/FmsFormStateNotifyInvisible.test.ets b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/ets/MainAbility/test/FmsFormStateNotifyInvisible.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..49a4e9c9d7d80d70bd1de71246c1473f7aac2392 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/ets/MainAbility/test/FmsFormStateNotifyInvisible.test.ets @@ -0,0 +1,609 @@ +/* + * 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 featureAbility from "@ohos.ability.featureAbility"; +import commonEvent from '@ohos.commonEvent'; +import { describe, expect, it } from "deccjsunit/index.ets"; + +var onAcquiredForm_Event = { + events: ["FMS_FormOnAcquired_commonEvent"], +}; + +var onDeletedFormEvent = { + events: ["FMS_FormOnDeleted_commonEvent"], +}; + +var onStateFormEvent = { + events: ["FMS_FormOnState_commonEvent"], +}; + +var onSupplyEvent = { + events: ["FMS_FormSupply_commonEvent"], +}; + +var deleteForm_Event = "FMS_FormDelete_commonEvent"; + +export default function test() { + describe(`FmsStateFormTest`, () => { + + /** + * @tc.number: FMS_notifyInvisibleForms_0200 + * @tc.name: The form user does not have permission. + * @tc.desc: 1.The form user calls the invisible notification interface. + * 2.Verify the result of the invisible notification interface. + */ + it(`FMS_notifyInvisibleForms_0200`, 0, async (done) => { + console.log(`FMS_notifyInvisibleForms_0200 start`); + let subscriberOnState; + + function onStateCallBack(err, data) { + console.info("!!!====>FMS_notifyInvisibleForms_0200 onStateCallBack data:====>" + JSON.stringify(data)); + expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); + expect(data.data).assertEqual("2"); + commonEvent.unsubscribe(subscriberOnState, unsubscribeOnStateCallBack); + setTimeout(function () { + console.info('FMS_notifyInvisibleForms_0200 onStateCallBack end'); + console.log(`FMS_notifyInvisibleForms_0200 end`); + done(); + }, 1000) + } + function unsubscribeOnStateCallBack() { + console.debug("====>FMS_notifyInvisibleForms_0200 unsubscribeOnStateCallBack====>"); + } + + commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { + console.debug("====>FMS_notifyInvisibleForms_0200 onStateFormEvent Subscriber====>"); + subscriberOnState = data; + await commonEvent.subscribe(subscriberOnState, onStateCallBack); + }); + + console.log(`FMS_notifyInvisibleForms_0200 featureAbility.startAbility again start`); + featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostnoperm", + abilityName: "com.ohos.st.formsystemhostnoperm.MainAbility", + parameters: { + "formId" : "0", + "name" : "Form_Js001", + "bundle" : "com.form.formsystemtestservicea.hmservice", + "ability" : "com.form.formsystemtestservicea.hmservice.FormAbility", + "moduleName" : "entry", + "temporary" : false, + "stateForm" : "invisible", + "stateIds" : ["1"], + "isCreate" : false + } + } + }).then((res: any) => { + console.log(`FMS_notifyInvisibleForms_0200 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_notifyInvisibleForms_0200 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_notifyInvisibleForms_0200 featureAbility.startAbility again end`); + }); + /** + * @tc.number: FMS_notifyInvisibleForms_0300 + * @tc.name: The length of the formId list is 0 (no formId) + * @tc.desc: 1.The form user calls the invisible notification interface. + * 2.Verify the result of the invisible notification interface. + */ + it(`FMS_notifyInvisibleForms_0300`, 0, async (done) => { + console.log(`FMS_notifyInvisibleForms_0300 start`); + let subscriberOnState; + + function onStateCallBack(err, data) { + console.info("!!!====>FMS_notifyInvisibleForms_0300 onStateCallBack data:====>" + JSON.stringify(data)); + expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); + expect(data.data).assertEqual("7"); + commonEvent.unsubscribe(subscriberOnState, unSubscribeOnStateCallback) + + setTimeout(function () { + console.info('FMS_notifyInvisibleForms_0300 delPublishCallBack end'); + console.log(`FMS_notifyInvisibleForms_0300 end`); + done(); + }, 100) + } + function unSubscribeOnStateCallback() { + console.debug("====>FMS_notifyInvisibleForms_0300 unSubscribeOnStateCallback CallBack====>"); + } + + commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { + console.debug("====>FMS_notifyInvisibleForms_0300 onStateFormEvent Subscriber====>"); + subscriberOnState = data; + await commonEvent.subscribe(subscriberOnState, onStateCallBack); + }); + console.log(`FMS_notifyInvisibleForms_0300 featureAbility.startAbility start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "Form_Js001", + "bundle" : "com.form.formsystemtestservicea.hmservice", + "ability" : "com.form.formsystemtestservicea.hmservice.FormAbility", + "moduleName" : "entry", + "temporary" : false, + "stateForm" : "invisible", + "stateIds" : [], + "isCreate" : false + } + } + }).then((res: any) => { + console.log(`FMS_notifyInvisibleForms_0300 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_notifyInvisibleForms_0300 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_notifyInvisibleForms_0300 featureAbility.startAbility end`); + }); + /** + * @tc.number: FMS_notifyInvisibleForms_0400 + * @tc.name: formID id is error(formID < 0) + * @tc.desc: 1.The form user calls the invisible notification interface. + * 2.Verify the result of the invisible notification interface. + */ + it(`FMS_notifyInvisibleForms_0400`, 0, async (done) => { + console.log(`FMS_notifyInvisibleForms_0400 start`); + let subscriberOnState; + + function onStateCallBack(err, data) { + console.info("!!!====>FMS_notifyInvisibleForms_0400 onStateCallBack data:====>" + JSON.stringify(data)); + expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); + expect(data.data).assertEqual("0"); + commonEvent.unsubscribe(subscriberOnState, unSubscribeOnStateCallback) + + setTimeout(function () { + console.info('FMS_notifyInvisibleForms_0400 delPublishCallBack end'); + console.log(`FMS_notifyInvisibleForms_0400 end`); + done(); + }, 100) + } + function unSubscribeOnStateCallback() { + console.debug("====>FMS_notifyInvisibleForms_0400 unSubscribeOnStateCallback CallBack====>"); + } + + commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { + console.debug("====>FMS_notifyInvisibleForms_0400 onStateFormEvent Subscriber====>"); + subscriberOnState = data; + await commonEvent.subscribe(subscriberOnState, onStateCallBack); + }); + console.log(`FMS_notifyInvisibleForms_0400 featureAbility.startAbility start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "Form_Js001", + "bundle" : "com.form.formsystemtestservicea.hmservice", + "ability" : "com.form.formsystemtestservicea.hmservice.FormAbility", + "moduleName" : "entry", + "temporary" : false, + "stateForm" : "invisible", + "stateIds" : ["-1"], + "isCreate" : false + } + } + }).then((res: any) => { + console.log(`FMS_notifyInvisibleForms_0400 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_notifyInvisibleForms_0400 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_notifyInvisibleForms_0400 featureAbility.startAbility end`); + }); + /** + * @tc.number: FMS_notifyInvisibleForms_0500 + * @tc.name: formID id is error(formID == 0) + * @tc.desc: 1.The form user calls the invisible notification interface. + * 2.Verify the result of the invisible notification interface. + */ + it(`FMS_notifyInvisibleForms_0500`, 0, async (done) => { + console.log(`FMS_notifyInvisibleForms_0500 start`); + let subscriberOnState; + + function onStateCallBack(err, data) { + console.info("!!!====>FMS_notifyInvisibleForms_0500 onStateCallBack data:====>" + JSON.stringify(data)); + expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); + expect(data.data).assertEqual("0"); + commonEvent.unsubscribe(subscriberOnState, unSubscribeOnStateCallback) + + setTimeout(function () { + console.info('FMS_notifyInvisibleForms_0500 delPublishCallBack end'); + console.log(`FMS_notifyInvisibleForms_0500 end`); + done(); + }, 100) + } + function unSubscribeOnStateCallback() { + console.debug("====>FMS_notifyInvisibleForms_0500 unSubscribeOnStateCallback CallBack====>"); + } + + commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { + console.debug("====>FMS_notifyInvisibleForms_0500 onStateFormEvent Subscriber====>"); + subscriberOnState = data; + await commonEvent.subscribe(subscriberOnState, onStateCallBack); + }); + console.log(`FMS_notifyInvisibleForms_0500 featureAbility.startAbility start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "Form_Js001", + "bundle" : "com.form.formsystemtestservicea.hmservice", + "ability" : "com.form.formsystemtestservicea.hmservice.FormAbility", + "moduleName" : "entry", + "temporary" : false, + "stateForm" : "invisible", + "stateIds" : ["0"], + "isCreate" : false + } + } + }).then((res: any) => { + console.log(`FMS_notifyInvisibleForms_0500 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_notifyInvisibleForms_0500 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_notifyInvisibleForms_0500 featureAbility.startAbility end`); + }); + /** + * @tc.number: FMS_notifyInvisibleForms_0600 + * @tc.name: formID id is error because formId is not self + * @tc.desc: 1.The form user calls the invisible notification interface. + * 2.Verify the result of the invisible notification interface. + */ + it(`FMS_notifyInvisibleForms_0600`, 0, async (done) => { + console.log(`FMS_notifyInvisibleForms_0600 start`); + let subscriberOnState; + let subscriberOnAcquired; + let formId; + + function delPublishCallBack() { + console.info("!!!====>FMS_notifyInvisibleForms_0600 delPublishCallBack====>"); + setTimeout(function () { + console.info('FMS_notifyInvisibleForms_0600 delPublishCallBack end'); + console.log(`FMS_notifyInvisibleForms_0600 end`); + done(); + }, 1000); + } + + function onStateCallBack(err, data) { + console.info("!!!====>FMS_notifyInvisibleForms_0600 onStateCallBack data:====>" + JSON.stringify(data)); + expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); + expect(data.data).assertEqual("0"); + commonEvent.unsubscribe(subscriberOnState, unsubscribeOnStateCallback); + let commonEventPublishData = { + data: formId + }; + commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); + } + function unsubscribeOnStateCallback() { + console.debug("====>FMS_notifyInvisibleForms_0600 unsubscribeOnStateCallback====>"); + } + + async function onAcquiredCallBack(err, data) { + console.info("!!!====>FMS_notifyInvisibleForms_0600 onAcquiredCallBack data:====>" + JSON.stringify(data)); + expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent"); + commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallback) + formId = data.data; + commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { + console.debug("====>FMS_notifyInvisibleForms_0600 onStateFormEvent Subscriber====>"); + subscriberOnState = data; + await commonEvent.subscribe(subscriberOnState, onStateCallBack); + }); + + console.log(`FMS_notifyInvisibleForms_0600 featureAbility.startAbility again start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "Form_Js001", + "bundle" : "com.form.formsystemtestservicea.hmservice", + "ability" : "com.form.formsystemtestservicea.hmservice.FormAbility", + "moduleName" : "entry", + "temporary" : false, + "stateForm" : "invisible", + "stateIds" : [formId], + "isCreate" : false + } + } + }).then((res: any) => { + console.log(`FMS_notifyInvisibleForms_0600 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_notifyInvisibleForms_0600 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_notifyInvisibleForms_0600 featureAbility.startAbility again end`); + } + function unSubscribeOnAcquiredCallback() { + console.debug("====>FMS_notifyInvisibleForms_0600 OnAcquired UnSubscribe CallBack====>"); + } + + commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => { + console.debug("====>FMS_notifyInvisibleForms_0600 Create OnAcquired Subscriber====>"); + subscriberOnAcquired = data; + await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack); + }); + console.log(`FMS_notifyInvisibleForms_0600 featureAbility.startAbility start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostf", + abilityName: "com.ohos.st.formsystemhostf.MainAbility", + parameters: { + "formId" : "0", + "name" : "Form_Js001", + "bundle" : "com.form.formsystemtestservicea.hmservice", + "ability" : "com.form.formsystemtestservicea.hmservice.FormAbility", + "moduleName" : "entry", + "temporary" : false, + "isCreate" : true + } + } + }).then((res: any) => { + console.log(`FMS_notifyInvisibleForms_0600 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_notifyInvisibleForms_0600 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_notifyInvisibleForms_0600 featureAbility.startAbility end`); + }); + /** + * @tc.number: FMS_notifyInvisibleForms_0700 + * @tc.name: form has been deleted + * @tc.desc: 1.The form user calls the invisible notification interface. + * 2.Verify the result of the invisible notification interface. + */ + it(`FMS_notifyInvisibleForms_0700`, 0, async (done) => { + console.info(`FMS_notifyInvisibleForms_0700 start`); + let subscriberInvisible; + let subscriberDel; + let subscriberSupply; + let hostFormId; + + const onSupplyCallback = (err, data) => { + if (data.parameters.kind != "onVisibilityChange") { + return; + } + console.debug("====>FMS_notifyInvisibleForms_0700 onSupplyCallback data:====>" + JSON.stringify(data)); + expect().assertFail(); + } + + const onInvisibleCallback = (err, data) => { + if (data.parameters.kind != "invisible") { + return; + } + console.debug("====>FMS_notifyInvisibleForms_0700 onInvisibleCallback data:====>" + JSON.stringify(data)); + + expect(data.data).assertEqual("0"); + expect(data.parameters.formId).assertEqual(hostFormId); + commonEvent.unsubscribe(subscriberInvisible, () => { + console.info("====>FMS_notifyInvisibleForms_0700 unSubscribeOnInvisibleCallback====>"); + }); + setTimeout(() => { + commonEvent.unsubscribe(subscriberSupply, () => { + console.info("====>FMS_notifyInvisibleForms_0700 unSubscribeSupplyCallback====>"); + }); + done(); + }, 2000); + } + + const onDeleteCallback = async (err, data) => { + console.debug("====>FMS_notifyInvisibleForms_0700 onDeleteCallback data:====>" + JSON.stringify(data)); + hostFormId = data.parameters.formId; + + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId": "0", + "name": "Form_Js001", + "bundle": "com.form.formsystemtestservicef.hmservice", + "ability": "com.form.formsystemtestservicef.hmservice.FormAbility", + "moduleName": "entry", + "temporary": false, + "stateForm": "invisible", + "stateIds": [hostFormId], + "isCreate": false + } + } + }).then((res: any) => { + console.debug(`FMS_notifyInvisibleForms_0700 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.debug(`FMS_notifyInvisibleForms_0700 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + + commonEvent.unsubscribe(subscriberDel, () => { + console.info("====>FMS_notifyInvisibleForms_0700 unSubscribeDelCallback====>"); + }); + } + + commonEvent.createSubscriber(onDeletedFormEvent).then(async (data) => { + console.info("====>FMS_notifyInvisibleForms_0700 onDeletedFormEvent Invisible Subscriber====>"); + subscriberDel = data; + await commonEvent.subscribe(subscriberDel, onDeleteCallback); + }); + commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { + console.info("====>FMS_notifyInvisibleForms_0700 onStateFormEvent Invisible Subscriber====>"); + subscriberInvisible = data; + await commonEvent.subscribe(subscriberInvisible, onInvisibleCallback); + }); + commonEvent.createSubscriber(onSupplyEvent).then(async (data) => { + console.info("====>FMS_notifyInvisibleForms_0700 onSupplyEvent Subscriber====>"); + subscriberSupply = data; + await commonEvent.subscribe(subscriberSupply, onSupplyCallback); + }); + + console.info(`FMS_notifyInvisibleForms_0700 featureAbility.startAbility start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId": "0", + "name": "Form_Js001", + "bundle": "com.form.formsystemtestservicef.hmservice", + "ability": "com.form.formsystemtestservicef.hmservice.FormAbility", + "moduleName": "entry", + "temporary": false, + "deleteForm": true, + "deleteId": "self", + "isCreate": true + } + } + }).then((res: any) => { + console.debug(`FMS_notifyInvisibleForms_0700 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.debug(`FMS_notifyInvisibleForms_0700 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + }); + /** + * @tc.number: FMS_notifyInvisibleForms_0800 + * @tc.name: The form provider is the system application and config When form visiblenotify is true, + * the form provider can be notified that the form is invisible. + * @tc.desc: 1.The form user calls the invisible notification interface. + * 2.Verify the result of the invisible notification interface. + */ + it(`FMS_notifyInvisibleForms_0800`, 0, async (done) => { + console.log(`FMS_notifyInvisibleForms_0800 start`); + let subscriberInvisible; + let subscriberVisible; + let subscriberSupply; + let formIdInvisible; + let formIdVisible; + let onSupplyCount = 0; + + function unSubscribeSupplyCallback() { + console.debug("====>FMS_notifyInvisibleForms_0800 unSubscribeSupplyCallback====>"); + } + function delPublishCallBack(err, data) { + console.info("!!!====>FMS_notifyInvisibleForms_0800 delPublishCallBack====>"); + setTimeout(function () { + console.info('FMS_notifyInvisibleForms_0800 delPublishCallBack end'); + console.log(`FMS_notifyInvisibleForms_0800 end`); + done(); + }, 1000); + } + + function onSupplyCallBack(err, data) { + if (data.parameters.kind == "onVisibilityChange") { + expect(data.event).assertEqual("FMS_FormSupply_commonEvent"); + console.debug("====>FMS_notifyInvisibleForms_0800 onSupplyCallBack====>" + JSON.stringify(data)); + onSupplyCount++; + if (onSupplyCount == 2) { + commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback); + } + if (formIdInvisible && formIdVisible) { + let commonEventPublishData = { + data: formIdInvisible + }; + commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); + } + } + } + + function OnInvisibleCallBack(err, data) { + console.info("!!!====>FMS_notifyInvisibleForms_0800 OnInvisibleCallBack data:====>" + JSON.stringify(data)); + expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); + expect(data.data).assertEqual("0"); + formIdInvisible = data.parameters.formId; + commonEvent.unsubscribe(subscriberInvisible, unSubscribeOnInvisibleCallback); + if (formIdInvisible && formIdVisible && onSupplyCount == 2) { + let commonEventPublishData = { + data: formIdInvisible + }; + commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); + } + } + function unSubscribeOnVisibleCallback() { + console.debug("====>FMS_notifyInvisibleForms_0800 unSubscribeOnVisibleCallback CallBack====>"); + } + function unSubscribeOnInvisibleCallback() { + console.debug("====>FMS_notifyInvisibleForms_0800 unSubscribeOnInvisibleCallback CallBack====>"); + } + async function onVisibleCallBack(err, data) { + console.info("!!!====>FMS_notifyInvisibleForms_0800 onVisibleCallBack data:====>" + JSON.stringify(data)); + expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); + expect(data.data).assertEqual("0"); + commonEvent.unsubscribe(subscriberVisible, unSubscribeOnVisibleCallback); + formIdVisible = data.parameters.formId; + + commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { + console.debug("====>FMS_notifyInvisibleForms_0800 onStateFormEvent Invisible Subscriber====>"); + subscriberInvisible = data; + await commonEvent.subscribe(subscriberInvisible, OnInvisibleCallBack); + }); + + console.log(`FMS_notifyInvisibleForms_0800 featureAbility.startAbility again start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "Form_Js001", + "bundle" : "com.form.formsystemtestservicea.hmservice", + "ability" : "com.form.formsystemtestservicea.hmservice.FormAbility", + "moduleName" : "entry", + "temporary" : false, + "stateForm" : "invisible", + "stateIds" : [formIdVisible], + "isCreate" : false + } + } + }).then((res: any) => { + console.log(`FMS_notifyInvisibleForms_0800 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_notifyInvisibleForms_0800 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_notifyInvisibleForms_0800 featureAbility.startAbility again end`); + } + + commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { + console.debug("====>FMS_notifyInvisibleForms_0800 onStateFormEvent Subscriber====>"); + subscriberVisible = data; + await commonEvent.subscribe(subscriberVisible, onVisibleCallBack); + }); + commonEvent.createSubscriber(onSupplyEvent).then(async (data) => { + console.debug("====>FMS_notifyInvisibleForms_0800 onSupplyEvent Subscriber====>"); + subscriberSupply = data; + await commonEvent.subscribe(subscriberSupply, onSupplyCallBack); + }); + console.log(`FMS_notifyInvisibleForms_0800 featureAbility.startAbility start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "Form_Js001", + "bundle" : "com.form.formsystemtestservicea.hmservice", + "ability" : "com.form.formsystemtestservicea.hmservice.FormAbility", + "moduleName" : "entry", + "temporary" : false, + "stateForm" : "visible", + "stateIds" : ["self"], + "isCreate" : true + } + } + }).then((res: any) => { + console.log(`FMS_notifyInvisibleForms_0800 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_notifyInvisibleForms_0800 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_notifyInvisibleForms_0800 featureAbility.startAbility end`); + }); + }); +} diff --git a/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/ets/MainAbility/test/List.test.ets b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/ets/MainAbility/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..03a00d6756631044e1b817a0449f5617a2a8daef --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/ets/MainAbility/test/List.test.ets @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import test from './FmsFormStateNotifyInvisible.test.ets'; + +export default function testsuite() { + test(); +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..3c18b675c9487847c521511cecb69a29dc08821c --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "forminvisiblestatetest" + }, + { + "name": "description_mainability", + "value": "ETS_Empty Ability" + } + ] +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible2/BUILD.gn b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible2/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..ca89869b71f573dc5ec998b200b063ac83574af9 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible2/BUILD.gn @@ -0,0 +1,32 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("FormStateNotifyInvisibleTest2") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":hjs_demo_js_assets", + ":hjs_demo_resources", + ] + ets2abc = true + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "FormStateNotifyInvisibleTest2" +} +ohos_js_assets("hjs_demo_js_assets") { + source_dir = "./entry/src/main/ets/MainAbility" +} +ohos_resources("hjs_demo_resources") { + sources = [ "./entry/src/main/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible2/Test.json b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible2/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..0d62b5f0ae620c4a51711445941c97918969d264 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible2/Test.json @@ -0,0 +1,24 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "300000", + "package": "com.ohos.st.formstatenotifyinvisibletest2", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "FormStateNotifyInvisibleTest2.hap", + "FormSystemHostG.hap", + "FormSupplyAppA.hap", + "FormSupplyAppB.hap", + "FormSupplyAppD.hap", + "FormSupplyAppF.hap", + "FormSupplyAppNS.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} diff --git a/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/config.json b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..27a08f66e7e762081dc6b8e2b7918f55e8ef61d9 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/config.json @@ -0,0 +1,150 @@ +{ + "app": { + "bundleName": "com.ohos.st.formstatenotifyinvisibletest2", + "vendor": "ohos", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 7, + "releaseType": "Release", + "target": 7 + } + }, + "deviceConfig": {}, + "module": { + "package": "com.ohos.st.formstatenotifyinvisibletest2", + "name": ".FormStateSTApp", + "mainAbility": ".MainAbility", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": false + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "visible": true, + "name": ".MainAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:description_mainability", + "label": "$string:entry_MainAbility", + "type": "page", + "launchType": "standard" + } + ], + "defPermissions": [ + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormDelete_commonEvent" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormOnAcquired_commonEvent" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormOnError_commonEvent" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormOnDeleted_commonEvent" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormOnState_commonEvent" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormSupply_commonEvent" + } + ], + "reqPermissions": [ + { + "name": "FMS_FormOnAcquired_commonEvent", + "reason": "need use onAcquired commonEvent" + }, + { + "name": "FMS_FormDelete_commonEvent", + "reason": "need use delete commonEvent" + }, + { + "name": "FMS_FormOnError_commonEvent", + "reason": "need use OnError commonEvent" + }, + { + "name": "FMS_FormOnDeleted_commonEvent", + "reason": "need use OnDeleted commonEvent" + }, + { + "name": "FMS_FormOnState_commonEvent", + "reason": "need use OnState commonEvent" + }, + { + "name": "FMS_FormSupply_commonEvent", + "reason": "need use FormSupply commonEvent" + }, + { + "name": "ohos.permission.INSTALL_BUNDLE", + "reason": "need use ohos.permission.INSTALL_BUNDLE" + }, + { + "name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + }, + { + "name":"ohos.permission.CHANGE_ABILITY_ENABLED_STATE", + "reason":"need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE" + }, + { + "name":"ohos.permission.REMOVE_CACHE_FILES", + "reason":"need use ohos.permission.REMOVE_CACHE_FILES" + }, + { + "name":"ohos.permission.LISTEN_BUNDLE_CHANGE", + "reason":"need use ohos.permission.LISTEN_BUNDLE_CHANGE" + }, + { + "name":"ohos.permission.CLEAN_BACKGROUND_PROCESSES", + "reason":"need use ohos.permission.CLEAN_BACKGROUND_PROCESSES" + } + ], + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/ets/MainAbility/app.ets b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..83dd3d4f89d10e36cf17e9a1f7dba026f14c088b --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,23 @@ +/* + * 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. + */ + +export default { + onCreate() { + console.info('[FormComponent] Application onCreate') + }, + onDestroy() { + console.info('[FormComponent] Application onDestroy') + }, +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/ets/MainAbility/model/FormViewModel.ets b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/ets/MainAbility/model/FormViewModel.ets new file mode 100644 index 0000000000000000000000000000000000000000..462affde744956c2f7db057285fb6356d3fd475e --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/ets/MainAbility/model/FormViewModel.ets @@ -0,0 +1,131 @@ +/* + * 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 formManager from '@ohos.ability.formmanager'; +import bundleManager from '@ohos.bundle'; + +export default class FormViewModel { + private static sFormViewModel: FormViewModel = null; + + public static getInstance(): FormViewModel { + if (FormViewModel.sFormViewModel == null) { + FormViewModel.sFormViewModel = new FormViewModel(); + } + return FormViewModel.sFormViewModel; + } + + public async requestForm(formId: string) { + formManager.requestForm(formId) + .then((data) => { + console.info( '[FormComponent] requestForm result:' + data); + }); + } + + public async deleteCard(formId: string) { + formManager.deleteForm(formId) + .then((data) => { + console.info('[FormComponent] deleteForm result:' + data); + }); + } + + public async releaseCard(formId: string) { + formManager.releaseForm(formId) + .then((data) => { + console.info('[FormComponent] releaseForm result:' + data); + }); + } + + public async castTempToNormal(formId: string) { + formManager.castTempForm(formId) + .then((data) => { + console.info('[FormComponent] castTempToNormal result:' + data); + }); + } + + public async enableCard(formId: string) { + formManager.enableFormsUpdate([formId]) + .then((data) => { + console.info('[FormComponent] enableFormsUpdate result:' + data); + }); + } + + public async disableCard(formId: string) { + formManager.disableFormsUpdate([formId]) + .then((data) => { + console.info('[FormComponent] disableCard result:' + data); + }); + } + + public async changeCardVisible(formId: string, isVisible: boolean) { + if (isVisible) { + formManager.notifyVisibleForms([formId]) + .then((data) => { + console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible); + }); + } else { + formManager.notifyInvisibleForms([formId]) + .then((data) => { + console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible); + }); + } + } + + public async isFmsReady() { + formManager.isSystemReady() + .then((data) => { + console.info('[FormComponent] isFmsReady result:' + data); + }); + } + + public async getAllFormsInfo() { + console.info("[FormComponent] getAllFormsInfo start"); + formManager.getAllFormsInfo() + .then((data) => { + console.info('[FormComponent] getAllFormsInfo result:' + JSON.stringify(data)); + }) + .catch((err) => { + console.info('[FormComponent] getAllFormsInfo error:' + JSON.stringify(err)); + }); + console.info("[FormComponent] getAllFormsInfo end"); + } + + public async getFormsInfoByApp(bundle: string) { + formManager.getFormsInfo(bundle) + .then((data) => { + console.info('[FormComponent] getFormsInfoByApp result:' + JSON.stringify(data)); + }); + } + + public async getFormsInfoByModule(bundle: string, moduleName: string) { + formManager.getFormsInfo(bundle, moduleName) + .then((data) => { + console.info('[FormComponent] getFormsInfoByModule result:' + JSON.stringify(data)); + }); + } + + public async clearFormUserCache() { + bundleManager.cleanBundleCacheFiles('com.ohos.myapplicationform') + .then((data) => { + console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data)); + }); + } + + public async clearFormProviderCache(bundle: string) { + bundleManager.cleanBundleCacheFiles(bundle) + .then((data) => { + console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data)); + }); + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/ets/MainAbility/pages/index.ets b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..07cb76f5af58c6f15b68bfaa8a7402c4a5c9252f --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,68 @@ +/* + * 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. + */ + +// @ts-nocheck +import featureAbility from "@ohos.ability.featureAbility"; +import file from '@system.file'; +import { Core, ExpectExtend, ReportExtend } from "deccjsunit/index.ets"; +import testsuite from "../test/List.test.ets"; + +@Entry +@Component +struct Index { + + aboutToAppear() { + + console.info("[FormComponent] start run testcase!!!!"); + + featureAbility.getWant() + .then((want: any) => { + console.info('[FormComponent] Operation successful. Data: ' + JSON.stringify(want)); + const core = Core.getInstance(); + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }); + core.addService('expect', expectExtend); + const reportExtend = new ReportExtend(file); + core.addService('report', reportExtend); + core.init(); + core.subscribeEvent('task', reportExtend); + const configService = core.getDefaultService('config'); + want.parameters['timeout'] = 10000; + console.info('[FormComponent] parameters---->' + JSON.stringify(want.parameters)); + configService.setConfig(want.parameters); + testsuite(); + core.execute(); + }) + .catch((error: any) => { + console.error('[FormComponent] Operation failed. Cause: ' + JSON.stringify(error)); + }) + } + + build() { + Flex({ + direction: FlexDirection.Column, + alignItems: ItemAlign.Center, + justifyContent: FlexAlign.Center + }) { + Text('Fms Main Ability Test') + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + .height('100%') + } +} + diff --git a/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/ets/MainAbility/test/FmsFormStateNotifyInvisible2.test.ets b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/ets/MainAbility/test/FmsFormStateNotifyInvisible2.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..14fba101a8d110ef170ad201c338caba7056a9bb --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/ets/MainAbility/test/FmsFormStateNotifyInvisible2.test.ets @@ -0,0 +1,932 @@ +/* + * 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 featureAbility from "@ohos.ability.featureAbility"; +import commonEvent from '@ohos.commonEvent'; +import { describe, expect, it } from "deccjsunit/index.ets"; + +var onAcquiredForm_Event = { + events: ["FMS_FormOnAcquired_commonEvent"], +}; + +var onDeletedFormEvent = { + events: ["FMS_FormOnDeleted_commonEvent"], +}; + +var onStateFormEvent = { + events: ["FMS_FormOnState_commonEvent"], +}; + +var onSupplyEvent = { + events: ["FMS_FormSupply_commonEvent"], +}; + +var deleteForm_Event = "FMS_FormDelete_commonEvent"; + +export default function test() { + + describe(`FmsStateFormTest`, () => { + /** + * @tc.number: FMS_notifyInvisibleForms_0900 + * @tc.name: There are correct and wrong formId in the form ID parameter list + * that informs that the form is invisible. + * @tc.desc: 1.The form user calls the invisible notification interface. + * 2.Verify the result of the invisible notification interface. + */ + it(`FMS_notifyInvisibleForms_0900`, 0, async (done) => { + console.log(`FMS_notifyInvisibleForms_0900 start`); + let subscriberInvisible; + let subscriberVisible; + let subscriberSupply; + let formIdInvisible; + let formIdVisible; + let onSupplyCount = 0; + + function unSubscribeSupplyCallback() { + console.debug("====>FMS_notifyInvisibleForms_0900 unSubscribeSupplyCallback====>"); + } + function delPublishCallBack(err, data) { + console.info("!!!====>FMS_notifyInvisibleForms_0900 delPublishCallBack====>"); + setTimeout(function () { + console.info('FMS_notifyInvisibleForms_0900 delPublishCallBack end'); + console.log(`FMS_notifyInvisibleForms_0900 end`); + done(); + }, 1000); + } + + function onSupplyCallBack(err, data) { + if (data.parameters.kind == "onVisibilityChange") { + expect(data.event).assertEqual("FMS_FormSupply_commonEvent"); + console.debug("====>FMS_notifyInvisibleForms_0900 onSupplyCallBack====>" + JSON.stringify(data)); + onSupplyCount++; + if (onSupplyCount == 2) { + commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback); + } + if (formIdInvisible && formIdVisible) { + let commonEventPublishData = { + data: formIdInvisible + }; + commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); + } + } + } + + function OnInvisibleCallBack(err, data) { + console.info("!!!====>FMS_notifyInvisibleForms_0900 OnInvisibleCallBack data:====>" + JSON.stringify(data)); + expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); + expect(data.data).assertEqual("0"); + formIdInvisible = data.parameters.formId; + commonEvent.unsubscribe(subscriberInvisible, unSubscribeOnInvisibleCallback); + if (formIdInvisible && formIdVisible && onSupplyCount == 2) { + let commonEventPublishData = { + data: formIdInvisible + }; + commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); + } + } + function unSubscribeOnVisibleCallback() { + console.debug("====>FMS_notifyInvisibleForms_0900 unSubscribeOnVisibleCallback CallBack====>"); + } + function unSubscribeOnInvisibleCallback() { + console.debug("====>FMS_notifyInvisibleForms_0900 unSubscribeOnInvisibleCallback CallBack====>"); + } + async function onVisibleCallBack(err, data) { + console.info("!!!====>FMS_notifyInvisibleForms_0900 onVisibleCallBack data:====>" + JSON.stringify(data)); + expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); + expect(data.data).assertEqual("0"); + commonEvent.unsubscribe(subscriberVisible, unSubscribeOnVisibleCallback); + formIdVisible = data.parameters.formId; + + commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { + console.debug("====>FMS_notifyInvisibleForms_0900 onStateFormEvent Invisible Subscriber====>"); + subscriberInvisible = data; + await commonEvent.subscribe(subscriberInvisible, OnInvisibleCallBack); + }); + + console.log(`FMS_notifyInvisibleForms_0900 featureAbility.startAbility again start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "Form_Js001", + "bundle" : "com.form.formsystemtestservicea.hmservice", + "ability" : "com.form.formsystemtestservicea.hmservice.FormAbility", + "moduleName" : "entry", + "temporary" : false, + "stateForm" : "invisible", + "stateIds" : [formIdVisible, "0"], + "isCreate" : false + } + } + }).then((res: any) => { + console.log(`FMS_notifyInvisibleForms_0900 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_notifyInvisibleForms_0900 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_notifyInvisibleForms_0900 featureAbility.startAbility again end`); + } + + commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { + console.debug("====>FMS_notifyInvisibleForms_0900 onStateFormEvent Subscriber====>"); + subscriberVisible = data; + await commonEvent.subscribe(subscriberVisible, onVisibleCallBack); + }); + commonEvent.createSubscriber(onSupplyEvent).then(async (data) => { + console.debug("====>FMS_notifyInvisibleForms_0900 onSupplyEvent Subscriber====>"); + subscriberSupply = data; + await commonEvent.subscribe(subscriberSupply, onSupplyCallBack); + }); + console.log(`FMS_notifyInvisibleForms_0900 featureAbility.startAbility start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "Form_Js001", + "bundle" : "com.form.formsystemtestservicea.hmservice", + "ability" : "com.form.formsystemtestservicea.hmservice.FormAbility", + "moduleName" : "entry", + "temporary" : false, + "stateForm" : "visible", + "stateIds" : ["self"], + "isCreate" : true + } + } + }).then((res: any) => { + console.log(`FMS_notifyInvisibleForms_0900 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_notifyInvisibleForms_0900 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_notifyInvisibleForms_0900 featureAbility.startAbility end`); + }); + /** + * @tc.number: FMS_notifyInvisibleForms_1000 + * @tc.name: When the form provider is not a system application, notify the form to be invisible + * and do not pull up the form provider. + * @tc.desc: 1.The form user calls the invisible notification interface. + * 2.Verify the result of the invisible notification interface. + */ + it(`FMS_notifyInvisibleForms_1000`, 0, async (done) => { + console.log(`FMS_notifyInvisibleForms_1000 start`); + let subscriberOnVisible; + let subscriberOnSupply; + + function delPublishCallBack(err, data) { + console.info("!!!====>FMS_notifyInvisibleForms_1000 delPublishCallBack====>" + JSON.stringify(data)); + setTimeout(function () { + console.info('FMS_notifyInvisibleForms_1000 delPublishCallBack end'); + console.log(`FMS_notifyInvisibleForms_1000 end`); + done(); + }, 1000); + } + + function unSubscribeOnVisibleCallback() { + console.debug("====>FMS_notifyInvisibleForms_1000 unSubscribeOnVisibleCallback CallBack====>"); + } + function unSubscribeSupplyCallback() { + console.debug("====>FMS_notifyInvisibleForms_1000 unSubscribeSupplyCallback CallBack====>"); + } + function onVisibleCallBack(err, data) { + if (data.parameters.kind != "invisible") { + return; + } + console.info("!!!====>FMS_notifyInvisibleForms_1000 onVisibleCallBack data:====>" + JSON.stringify(data)); + expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); + expect(data.data).assertEqual("0"); + + setTimeout(function () { + commonEvent.unsubscribe(subscriberOnVisible, unSubscribeOnVisibleCallback); + commonEvent.unsubscribe(subscriberOnSupply, unSubscribeSupplyCallback); + + let commonEventPublishData = { + data: data.parameters.formId + }; + commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); + }, 2000); + } + function onSupplyEventCallBack(err, data) { + if (data.parameters.kind != "onVisibilityChange") { + return; + } + expect(data.event).assertEqual("FMS_FormSupply_commonEvent"); + commonEvent.unsubscribe(subscriberOnSupply, unSubscribeSupplyCallback); + console.debug("====>FMS_notifyInvisibleForms_1000 onSupplyEventCallBack====>" + JSON.stringify(data)); + console.log(`FMS_notifyInvisibleForms_1000 error`); + expect().assertFail(); + } + commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { + console.debug("====>FMS_notifyInvisibleForms_1000 onStateFormEvent Invisible Subscriber====>"); + subscriberOnVisible = data; + await commonEvent.subscribe(subscriberOnVisible, onVisibleCallBack); + }); + commonEvent.createSubscriber(onSupplyEvent).then(async (data) => { + console.debug("====>FMS_notifyInvisibleForms_1000 onSupplyEvent Invisible Subscriber====>"); + subscriberOnSupply = data; + await commonEvent.subscribe(subscriberOnSupply, onSupplyEventCallBack); + }); + console.log(`FMS_notifyInvisibleForms_1000 featureAbility.startAbility start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "Form_Js001", + "bundle" : "com.form.formsystemtestservicenotsysapp.hmservice", + "ability" : "com.form.formsystemtestservicenotsysapp.hmservice.FormAbility", + "moduleName" : "entry", + "temporary" : false, + "stateForm" : "invisible", + "stateIds" : ["self"], + "isCreate" : true + } + } + }).then((res: any) => { + console.log(`FMS_notifyInvisibleForms_1000 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_notifyInvisibleForms_1000 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_notifyInvisibleForms_1000 featureAbility.startAbility end`); + }); + /** + * @tc.number: FMS_notifyInvisibleForms_1100 + * @tc.name: When formVisibleNotify is false in config.json, + * the form provider will not be pulled when the card is invisible. + * @tc.desc: 1.The form user calls the invisible notification interface. + * 2.Verify the result of the invisible notification interface. + */ + it(`FMS_notifyInvisibleForms_1100`, 0, async (done) => { + console.log(`FMS_notifyInvisibleForms_1100 start`); + let subscriberInvisible; + let subscriberVisible; + let subscriberSupply; + let supplyFlag = false; + let formIdInvisible; + let formIdVisible; + + function delPublishCallBack(err, data) { + console.info("!!!====>FMS_notifyInvisibleForms_1100 delPublishCallBack====>"); + setTimeout(function () { + commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback); + if (supplyFlag) { + expect().assertFail(); + } + console.info('FMS_notifyInvisibleForms_1100 delPublishCallBack end'); + console.log(`FMS_notifyInvisibleForms_1100 end`); + done(); + }, 1000); + } + + function unSubscribeSupplyCallback() { + console.debug("====>FMS_notifyInvisibleForms_1100 unSubscribeSupplyCallback====>"); + } + function onSupplyCallBack(err, data) { + if (data.parameters.kind == "onVisibilityChange") { + expect(data.event).assertEqual("FMS_FormSupply_commonEvent"); + console.debug("====>FMS_notifyInvisibleForms_1100 onSupplyCallBack====>" + JSON.stringify(data)); + supplyFlag = true; + commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback); + + if (formIdInvisible && formIdVisible) { + let commonEventPublishData = { + data: formIdInvisible + }; + commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); + } + } + } + + function OnInvisibleCallBack(err, data) { + console.info("!!!====>FMS_notifyInvisibleForms_1100 OnInvisibleCallBack data:====>" + JSON.stringify(data)); + expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); + expect(data.data).assertEqual("0"); + formIdInvisible = data.parameters.formId; + commonEvent.unsubscribe(subscriberInvisible, unSubscribeOnInvisibleCallback); + if (formIdInvisible && formIdVisible) { + let commonEventPublishData = { + data: formIdInvisible + }; + commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); + } + } + function unSubscribeOnVisibleCallback() { + console.debug("====>FMS_notifyInvisibleForms_1100 unSubscribeOnVisibleCallback CallBack====>"); + } + function unSubscribeOnInvisibleCallback() { + console.debug("====>FMS_notifyInvisibleForms_1100 unSubscribeOnInvisibleCallback CallBack====>"); + } + async function onVisibleCallBack(err, data) { + console.info("!!!====>FMS_notifyInvisibleForms_1100 onVisibleCallBack data:====>" + JSON.stringify(data)); + expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); + expect(data.data).assertEqual("0"); + commonEvent.unsubscribe(subscriberVisible, unSubscribeOnVisibleCallback); + formIdVisible = data.parameters.formId; + + commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { + console.debug("====>FMS_notifyInvisibleForms_1100 onStateFormEvent Invisible Subscriber====>"); + subscriberInvisible = data; + await commonEvent.subscribe(subscriberInvisible, OnInvisibleCallBack); + }); + + console.log(`FMS_notifyInvisibleForms_1100 featureAbility.startAbility again start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "Form_Js001", + "bundle" : "com.form.formsystemtestserviced.hmservice", + "ability" : "com.form.formsystemtestserviced.hmservice.FormAbility", + "moduleName" : "entry", + "temporary" : false, + "stateForm" : "invisible", + "stateIds" : [formIdVisible], + "isCreate" : false + } + } + }).then((res: any) => { + console.log(`FMS_notifyInvisibleForms_1100 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_notifyInvisibleForms_1100 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_notifyInvisibleForms_1100 featureAbility.startAbility again end`); + } + + commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { + console.debug("====>FMS_notifyInvisibleForms_1100 onStateFormEvent Subscriber====>"); + subscriberVisible = data; + await commonEvent.subscribe(subscriberVisible, onVisibleCallBack); + }); + commonEvent.createSubscriber(onSupplyEvent).then(async (data) => { + console.debug("====>FMS_notifyInvisibleForms_1100 onSupplyEvent Subscriber====>"); + subscriberSupply = data; + await commonEvent.subscribe(subscriberSupply, onSupplyCallBack); + }); + console.log(`FMS_notifyInvisibleForms_1100 featureAbility.startAbility start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "Form_Js001", + "bundle" : "com.form.formsystemtestserviced.hmservice", + "ability" : "com.form.formsystemtestserviced.hmservice.FormAbility", + "moduleName" : "entry", + "temporary" : false, + "stateForm" : "visible", + "stateIds" : ["self"], + "isCreate" : true + } + } + }).then((res: any) => { + console.log(`FMS_notifyInvisibleForms_1100 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_notifyInvisibleForms_1100 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_notifyInvisibleForms_1100 featureAbility.startAbility end`); + }); + /** + * @tc.number: FMS_notifyInvisibleForms_1200 + * @tc.name: When formVisibleNotify in config.json is true, + * the provider can be notified of the visibility of the form. + * @tc.desc: 1. The form is created successfully. + * 2. The invisible interface is invoked successfully, + * and the visibility notification of form providers A and B is triggered. + * The formId is the same as the created formId, and the visibility status is invisible. + */ + it(`FMS_notifyInvisibleForms_1200`, 0, async (done) => { + console.log(`FMS_notifyInvisibleForms_1200 start`); + let subscriberOnAcquired; + let subscriberOnState; + let subscriberSupply; + let formId1; + let formId2; + let delCount = 0; + let onSupplyCount = 0; + + function delPublishCallBack() { + console.info("!!!====>FMS_notifyInvisibleForms_1200 delPublishCallBack====>"); + delCount++; + if (delCount == 2) { + setTimeout(function () { + console.info('FMS_notifyInvisibleForms_1200 delPublishCallBack end'); + console.info('FMS_notifyInvisibleForms_1200 end'); + done(); + }, 500); + } + } + function onAcquiredCallBack_Normal1(err, data) { + console.info("!!!====>FMS_notifyInvisibleForms_1200 onAcquiredCallBack_Normal1 data:====>" + JSON.stringify(data)); + expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent"); + commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallBack_Normal1) + formId1 = data.data; + + FMS_notifyInvisibleForms_1200_normal2(); + } + function unSubscribeOnAcquiredCallBack_Normal1() { + console.debug("====>FMS_notifyInvisibleForms_1200 unSubscribeOnAcquiredCallBack_Normal1 CallBack====>"); + } + + async function FMS_notifyInvisibleForms_1200_normal1() { + console.log(`FMS_notifyInvisibleForms_1200_normal1 start`); + commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => { + console.debug("====>FMS_notifyInvisibleForms_1200_normal1 Create OnAcquired Subscriber====>"); + subscriberOnAcquired = data; + await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack_Normal1); + }); + + console.log(`FMS_notifyInvisibleForms_1200_normal1 featureAbility.startAbility start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "Form_Js001", + "bundle" : "com.form.formsystemtestservicea.hmservice", + "ability" : "com.form.formsystemtestservicea.hmservice.FormAbility", + "moduleName" : "entry", + "temporary" : false, + "isCreate" : true + } + } + }).then((res: any) => { + console.log(`FMS_notifyInvisibleForms_1200_normal1 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_notifyInvisibleForms_1200_normal1 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + + console.log(`FMS_notifyInvisibleForms_1200_normal1 featureAbility.startAbility end`); + console.log(`FMS_notifyInvisibleForms_1200_normal1 end`); + } + + function onStateCallBack(err, data) { + console.info("!!!====>FMS_notifyInvisibleForms_1200 onStateCallBack data:====>" + JSON.stringify(data)); + expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); + expect(data.data).assertEqual("0"); + commonEvent.unsubscribe(subscriberOnState, unSubscribeOnStateCallback) + console.info("!!!====>FMS_notifyInvisibleForms_1200 onStateCallBack formId1:====>" + formId1); + console.info("!!!====>FMS_notifyInvisibleForms_1200 onStateCallBack formId2:====>" + formId2); + console.info("!!!====>FMS_notifyInvisibleForms_1200 onStateCallBack onSupplyCount:====>" + onSupplyCount); + if (formId1 && formId2 && onSupplyCount == 2) { + let commonEventPublishData = { + data: formId1 + }; + commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); + let commonEventPublishData2 = { + data: formId2 + }; + commonEvent.publish(deleteForm_Event, commonEventPublishData2, delPublishCallBack); + } + } + function unSubscribeOnStateCallback() { + console.debug("====>FMS_notifyInvisibleForms_1200 unSubscribeOnStateCallback CallBack====>"); + } + + async function onAcquiredCallBack_Normal2(err, data) { + console.info("!!!====>FMS_notifyInvisibleForms_1200 onAcquiredCallBack_Normal2 data:====>" + JSON.stringify(data)); + expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent"); + commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallBack_Normal2); + formId2 = data.data; + + commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { + console.debug("====>FMS_notifyInvisibleForms_1200 onStateFormEvent Subscriber====>"); + subscriberOnState = data; + await commonEvent.subscribe(subscriberOnState, onStateCallBack); + }); + + console.log(`FMS_notifyInvisibleForms_1200 featureAbility.startAbility start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "Form_Js001", + "bundle" : "com.form.formsystemtestservicea.hmservice", + "ability" : "com.form.formsystemtestservicea.hmservice.FormAbility", + "moduleName" : "entry", + "temporary" : false, + "stateForm" : "invisible", + "stateIds" : [formId1, formId2], + "isCreate" : true + } + } + }).then((res: any) => { + console.log(`FMS_notifyInvisibleForms_1200 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_notifyInvisibleForms_1200 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_notifyInvisibleForms_1200 featureAbility.startAbility end`); + } + function unSubscribeOnAcquiredCallBack_Normal2() { + console.debug("====>FMS_notifyInvisibleForms_1200 unSubscribeOnAcquiredCallBack_Normal2====>"); + } + async function FMS_notifyInvisibleForms_1200_normal2() { + commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => { + console.debug("====>FMS_notifyInvisibleForms_1200_normal2 Create OnAcquired Subscriber====>"); + subscriberOnAcquired = data; + await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack_Normal2); + }); + + console.log(`FMS_notifyInvisibleForms_1200_normal2 featureAbility.startAbility start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "Form_Js001", + "bundle" : "com.form.formsystemtestserviceb.hmservice", + "ability" : "com.form.formsystemtestserviceb.hmservice.FormAbility", + "moduleName" : "entry", + "temporary" : false, + "isCreate" : true + } + } + }).then((res: any) => { + console.log(`FMS_notifyInvisibleForms_1200_normal2 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_notifyInvisibleForms_1200_normal2 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + + console.log(`FMS_notifyInvisibleForms_1200_normal2 featureAbility.startAbility end`); + } + function unSubscribeSupplyCallback() { + console.debug("====>FMS_notifyInvisibleForms_1200 unSubscribeSupplyCallback====>"); + } + function onSupplyCallBack(err, data) { + if (data.parameters.kind == "onVisibilityChange") { + expect(data.event).assertEqual("FMS_FormSupply_commonEvent"); + console.debug("====>FMS_notifyInvisibleForms_1200 onSupplyCallBack====>" + JSON.stringify(data)); + let parameters = JSON.parse(data.parameters.parameters); + if(parameters[formId1]) { + expect(parameters[formId1]).assertEqual(2); + } + if(parameters[formId2]) { + expect(parameters[formId2]).assertEqual(2); + } + + onSupplyCount++; + if (onSupplyCount == 2) { + commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback); + } + if (formId1 && formId2) { + let commonEventPublishData = { + data: formId1 + }; + commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); + let commonEventPublishData2 = { + data: formId2 + }; + commonEvent.publish(deleteForm_Event, commonEventPublishData2, delPublishCallBack); + } + } + } + commonEvent.createSubscriber(onSupplyEvent).then(async (data) => { + console.debug("====>FMS_notifyInvisibleForms_1200 onSupplyEvent Subscriber====>"); + subscriberSupply = data; + await commonEvent.subscribe(subscriberSupply, onSupplyCallBack); + }); + FMS_notifyInvisibleForms_1200_normal1(); + }); + /** + * @tc.number: FMS_notifyInvisibleForms_1300 + * @tc.name: When formVisibleNotify is true in config.json, + * the form provider will be pulled when the card is invisible. + * @tc.desc: 1.The form user calls the invisible notification interface. + * 2.Verify the result of the invisible notification interface. + */ + it(`FMS_notifyInvisibleForms_1300`, 0, async (done) => { + console.info(`FMS_notifyInvisibleForms_1300 start`); + let subscriberInvisible; + let subscriberSupply; + let hostFormId; + let providerFormId; + let counter = 0; + + const delPublishCallback = (err, data) => { + console.info("!!!====>FMS_notifyInvisibleForms_1300 delPublishCallback====>"); + setTimeout(() => { + expect(hostFormId).assertEqual(providerFormId); + console.info('FMS_notifyInvisibleForms_1300 delPublishCallback end'); + console.info(`FMS_notifyInvisibleForms_1300 end`); + done(); + }, 1000); + } + + const onSupplyCallback = (err, data) => { + if (data.parameters.kind != "onVisibilityChange") { + return; + } + console.debug("====>FMS_notifyInvisibleForms_1300 onSupplyCallback data:====>" + JSON.stringify(data)); + providerFormId = Object.keys(JSON.parse(data.parameters.parameters))[0]; + const visibilityStatus = JSON.parse(data.parameters.parameters)[providerFormId]; + + expect(visibilityStatus).assertEqual(2); + commonEvent.unsubscribe(subscriberSupply, () => { + console.info("====>FMS_notifyInvisibleForms_1300 unSubscribeSupplyCallback====>"); + }); + if (++counter == 2) { + const commonEventPublishData = { + data: providerFormId + }; + commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallback); + } + } + + const onInvisibleCallback = (err, data) => { + if (data.parameters.kind != "invisible") { + return; + } + console.debug("====>FMS_notifyInvisibleForms_1300 onInvisibleCallback data:====>" + JSON.stringify(data)); + hostFormId = data.parameters.formId; + + expect(data.data).assertEqual("0"); + commonEvent.unsubscribe(subscriberInvisible, () => { + console.info("====>FMS_notifyInvisibleForms_1300 unSubscribeOnInvisibleCallback====>"); + }); + if (++counter == 2) { + const commonEventPublishData = { + data: hostFormId + }; + commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallback); + } + } + + commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { + console.info("====>FMS_notifyInvisibleForms_1300 onStateFormEvent Invisible Subscriber====>"); + subscriberInvisible = data; + await commonEvent.subscribe(subscriberInvisible, onInvisibleCallback); + }); + commonEvent.createSubscriber(onSupplyEvent).then(async (data) => { + console.info("====>FMS_notifyInvisibleForms_1300 onSupplyEvent Subscriber====>"); + subscriberSupply = data; + await commonEvent.subscribe(subscriberSupply, onSupplyCallback); + }); + + console.info(`FMS_notifyInvisibleForms_1300 featureAbility.startAbility start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId": "0", + "name": "Form_Js001", + "bundle": "com.form.formsystemtestservicef.hmservice", + "ability": "com.form.formsystemtestservicef.hmservice.FormAbility", + "moduleName": "entry", + "temporary": false, + "stateForm": "invisible", + "stateIds": ["self"], + "isCreate": true + } + } + }).then((res: any) => { + console.debug(`FMS_notifyInvisibleForms_1300 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.debug(`FMS_notifyInvisibleForms_1300 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + }); + + /** + * @tc.number: FMS_notifyInvisibleForms_1400 + * @tc.name: Use -1 form Id and created 2 form card Id notify the form to be invisible. + * @tc.desc: 1.The form user calls the visible notification interface. + * 2.Verify the result of the visible notification interface. + */ + it(`FMS_notifyInvisibleForms_1400`, 0, async (done) => { + console.log(`FMS_notifyInvisibleForms_1400 start`); + let subscriberOnAcquired; + let subscriberSupply; + let formIds = new Array(); + let retFormId; + let formId1; + let formId2; + let count = 0; + + function unSubscribeSupplyCallback() { + console.debug("====>FMS_notifyInvisibleForms_1400 unSubscribeSupplyCallback====>"); + } + function delPublishCallBack1(err, data) { + console.info("!!!====>FMS_notifyInvisibleForms_1400 delPublishCallBack1====>" + JSON.stringify(data)); + setTimeout(function () { + console.info('FMS_notifyInvisibleForms_1400 delPublishCallBack1 end'); + console.log(`FMS_notifyInvisibleForms_1400 end`); + }, 1000); + } + function delPublishCallBack2(err, data) { + console.info("!!!====>FMS_notifyInvisibleForms_1400 delPublishCallBack2====>" + JSON.stringify(data)); + setTimeout(function () { + console.info('FMS_notifyInvisibleForms_1400 delPublishCallBack2 end'); + console.log(`FMS_notifyInvisibleForms_1400 end`); + done(); + }, 1000); + } + + function onSupplyCallBack(err, data) { + if (data.parameters.kind == "onVisibilityChange") { + expect(data.event).assertEqual("FMS_FormSupply_commonEvent"); + console.debug("====>FMS_notifyInvisibleForms_1400 onSupplyCallBack====>" + JSON.stringify(data)); + + let retFormId = Object.keys(JSON.parse(data.parameters.parameters))[0]; + const visibilityStatus = JSON.parse(data.parameters.parameters)[retFormId]; + expect(formIds.includes(retFormId)).assertTrue(); + expect(visibilityStatus).assertEqual(2); + + ++count; + if (count == 2) { + console.debug("====>FMS_notifyInvisibleForms_1400 OK====>"); + commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback); + + let commonEventPublishData1 = { + data: formIds[0] + }; + commonEvent.publish(deleteForm_Event, commonEventPublishData1, delPublishCallBack1); + let commonEventPublishData2 = { + data: formIds[1] + }; + commonEvent.publish(deleteForm_Event, commonEventPublishData2, delPublishCallBack2); + } + } + } + + async function onSecondAcquiredCallBack(err, data) { + expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent"); + commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeSupplyCallback); + console.debug("====>FMS_notifyInvisibleForms_1400 onSecondAcquiredCallBack====>" + JSON.stringify(data)); + formIds.push(data.data); + formIds.push("-1"); + console.debug("====>FMS_notifyInvisibleForms_1400 formIds====>" + formIds); + + commonEvent.createSubscriber(onSupplyEvent).then(async (data) => { + console.debug("====>FMS_notifyInvisibleForms_1400 onSupplyEvent Subscriber====>"); + subscriberSupply = data; + await commonEvent.subscribe(subscriberSupply, onSupplyCallBack); + }); + + console.log(`FMS_notifyInvisibleForms_1400 featureAbility.startAbility notifyInVisible start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "name", + "bundle" : "bundle", + "ability" : "ability", + "moduleName" : "entry", + "temporary" : false, + "stateForm" : "invisible", + "stateIds" : formIds, + "isCreate" : false + } + } + }).then((res: any) => { + console.log(`FMS_notifyInvisibleForms_1400 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_notifyInvisibleForms_1400 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_notifyInvisibleForms_1400 featureAbility.startAbility notifyInVisible end`); + } + + async function onFirstAcquiredCallBack(err, data) { + expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent"); + commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeSupplyCallback); + console.debug("====>FMS_notifyInvisibleForms_1400 onFirstAcquiredCallBack====>" + JSON.stringify(data)); + formIds.push(data.data); + + commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => { + console.debug("====>FMS_notifyInvisibleForms_1400 onAcquiredForm_Event Subscriber====>"); + subscriberOnAcquired = data; + await commonEvent.subscribe(subscriberOnAcquired, onSecondAcquiredCallBack); + }); + + console.log(`FMS_notifyInvisibleForms_1400 featureAbility.startAbility serviceb start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "Form_Js001", + "bundle" : "com.form.formsystemtestserviceb.hmservice", + "ability" : "com.form.formsystemtestserviceb.hmservice.FormAbility", + "moduleName" : "entry", + "temporary" : false, + "isCreate" : true + } + } + }).then((res: any) => { + console.log(`FMS_notifyInvisibleForms_1400 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_notifyInvisibleForms_1400 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_notifyInvisibleForms_1400 featureAbility.startAbility serviceb end`); + } + + commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => { + console.debug("====>FMS_notifyInvisibleForms_1400 onAcquiredForm_Event Subscriber====>"); + subscriberOnAcquired = data; + await commonEvent.subscribe(subscriberOnAcquired, onFirstAcquiredCallBack); + }); + console.log(`FMS_notifyInvisibleForms_1400 featureAbility.startAbility servicea start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "Form_Js001", + "bundle" : "com.form.formsystemtestservicea.hmservice", + "ability" : "com.form.formsystemtestservicea.hmservice.FormAbility", + "moduleName" : "entry", + "temporary" : false, + "isCreate" : true + } + } + }).then((res: any) => { + console.log(`FMS_notifyInvisibleForms_1400 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_notifyInvisibleForms_1400 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_notifyInvisibleForms_1400 featureAbility.startAbility servicea end`); + }); + /** + * @tc.number: FMS_notifyInvisibleForms_1500 + * @tc.name: The size of invisible form ids in the notification form array exceeds 32. + * @tc.desc: 1. Failed to invoke the invisibility interface (parameter error). + */ + it(`FMS_notifyInvisibleForms_1500`, 0, async (done) => { + console.log(`FMS_notifyInvisibleForms_1500 start`); + let subscriberOnState; + let formId; + + function onStateCallBack(err, data) { + console.info("!!!====>FMS_notifyInvisibleForms_1500 onStateCallBack data:====>" + JSON.stringify(data)); + expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); + expect(data.data != "0").assertEqual(true); + commonEvent.unsubscribe(subscriberOnState, unSubscribeOnStateCallback) + + setTimeout(function () { + console.info('FMS_notifyInvisibleForms_1500 delPublishCallBack end'); + console.log(`FMS_notifyInvisibleForms_1500 end`); + done(); + }, 100) + } + function unSubscribeOnStateCallback() { + console.debug("====>FMS_notifyInvisibleForms_1500 unSubscribeOnStateCallback CallBack====>"); + } + + commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { + console.debug("====>FMS_notifyInvisibleForms_1500 onStateFormEvent Subscriber====>"); + subscriberOnState = data; + await commonEvent.subscribe(subscriberOnState, onStateCallBack); + }); + console.log(`FMS_notifyInvisibleForms_1500 featureAbility.startAbility start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "Form_Js001", + "bundle" : "com.form.formsystemtestservicea.hmservice", + "ability" : "com.form.formsystemtestservicea.hmservice.FormAbility", + "moduleName" : "entry", + "temporary" : false, + "stateForm" : "invisible", + "stateIds" : [ + "1","2","3","4","5","6","7","8","9","10","11","12","13","14", + "15","16","17","18","19","20","21","22","23","24","25","26", + "27","28","29","30","31","32","33" + ], + "isCreate" : false + } + } + }).then((res: any) => { + console.log(`FMS_notifyInvisibleForms_1500 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_notifyInvisibleForms_1500 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_notifyInvisibleForms_1500 featureAbility.startAbility end`); + }); + }); +} diff --git a/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/ets/MainAbility/test/List.test.ets b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/ets/MainAbility/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..6a25dbcbbd793c88e53430e39e5a434fcca648d7 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/ets/MainAbility/test/List.test.ets @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import test from './FmsFormStateNotifyInvisible2.test.ets'; + +export default function testsuite() { + test(); +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..3c18b675c9487847c521511cecb69a29dc08821c --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "forminvisiblestatetest" + }, + { + "name": "description_mainability", + "value": "ETS_Empty Ability" + } + ] +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible2/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible2/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyinvisible2/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyvisible/BUILD.gn b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyvisible/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..b80127f2497c2480664e4d036fcf3460e2fa314d --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyvisible/BUILD.gn @@ -0,0 +1,32 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("FormStateNotifyVisibleTest") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":hjs_demo_js_assets", + ":hjs_demo_resources", + ] + ets2abc = true + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "FormStateNotifyVisibleTest" +} +ohos_js_assets("hjs_demo_js_assets") { + source_dir = "./entry/src/main/ets/MainAbility" +} +ohos_resources("hjs_demo_resources") { + sources = [ "./entry/src/main/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyvisible/Test.json b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyvisible/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..cd0cf86a5266ba1e60636165a0fe8fdf7835dd8d --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyvisible/Test.json @@ -0,0 +1,29 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "300000", + "package": "com.ohos.st.formstatenotifyvisibletest", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "FormStateNotifyVisibleTest.hap", + "FormSystemHostF.hap", + "FormSystemHostG.hap", + "FormSystemHostNoPerm.hap", + "FormSupplyAppA.hap", + "FormSupplyAppB.hap", + "FormSupplyAppD.hap", + "FormSupplyAppE.hap", + "FormSupplyAppF.hap", + "FormSupplyAppG.hap", + "FormSupplyAppH.hap", + "FormSupplyAppNS.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} diff --git a/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/config.json b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..1cfc6433edfb38ab9242708257892ac06db07db2 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/config.json @@ -0,0 +1,150 @@ +{ + "app": { + "bundleName": "com.ohos.st.formstatenotifyvisibletest", + "vendor": "ohos", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 7, + "releaseType": "Release", + "target": 7 + } + }, + "deviceConfig": {}, + "module": { + "package": "com.ohos.st.formstatenotifyvisibletest", + "name": ".FormStateSTApp", + "mainAbility": ".MainAbility", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": false + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "visible": true, + "name": ".MainAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:description_mainability", + "label": "$string:entry_MainAbility", + "type": "page", + "launchType": "standard" + } + ], + "defPermissions": [ + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormDelete_commonEvent" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormOnAcquired_commonEvent" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormOnError_commonEvent" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormOnDeleted_commonEvent" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormOnState_commonEvent" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "FMS_FormSupply_commonEvent" + } + ], + "reqPermissions": [ + { + "name": "FMS_FormOnAcquired_commonEvent", + "reason": "need use onAcquired commonEvent" + }, + { + "name": "FMS_FormDelete_commonEvent", + "reason": "need use delete commonEvent" + }, + { + "name": "FMS_FormOnError_commonEvent", + "reason": "need use OnError commonEvent" + }, + { + "name": "FMS_FormOnDeleted_commonEvent", + "reason": "need use OnDeleted commonEvent" + }, + { + "name": "FMS_FormOnState_commonEvent", + "reason": "need use OnState commonEvent" + }, + { + "name": "FMS_FormSupply_commonEvent", + "reason": "need use FormSupply commonEvent" + }, + { + "name": "ohos.permission.INSTALL_BUNDLE", + "reason": "need use ohos.permission.INSTALL_BUNDLE" + }, + { + "name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + }, + { + "name":"ohos.permission.CHANGE_ABILITY_ENABLED_STATE", + "reason":"need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE" + }, + { + "name":"ohos.permission.REMOVE_CACHE_FILES", + "reason":"need use ohos.permission.REMOVE_CACHE_FILES" + }, + { + "name":"ohos.permission.LISTEN_BUNDLE_CHANGE", + "reason":"need use ohos.permission.LISTEN_BUNDLE_CHANGE" + }, + { + "name":"ohos.permission.CLEAN_BACKGROUND_PROCESSES", + "reason":"need use ohos.permission.CLEAN_BACKGROUND_PROCESSES" + } + ], + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/ets/MainAbility/app.ets b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..83dd3d4f89d10e36cf17e9a1f7dba026f14c088b --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,23 @@ +/* + * 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. + */ + +export default { + onCreate() { + console.info('[FormComponent] Application onCreate') + }, + onDestroy() { + console.info('[FormComponent] Application onDestroy') + }, +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/ets/MainAbility/model/FormViewModel.ets b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/ets/MainAbility/model/FormViewModel.ets new file mode 100644 index 0000000000000000000000000000000000000000..462affde744956c2f7db057285fb6356d3fd475e --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/ets/MainAbility/model/FormViewModel.ets @@ -0,0 +1,131 @@ +/* + * 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 formManager from '@ohos.ability.formmanager'; +import bundleManager from '@ohos.bundle'; + +export default class FormViewModel { + private static sFormViewModel: FormViewModel = null; + + public static getInstance(): FormViewModel { + if (FormViewModel.sFormViewModel == null) { + FormViewModel.sFormViewModel = new FormViewModel(); + } + return FormViewModel.sFormViewModel; + } + + public async requestForm(formId: string) { + formManager.requestForm(formId) + .then((data) => { + console.info( '[FormComponent] requestForm result:' + data); + }); + } + + public async deleteCard(formId: string) { + formManager.deleteForm(formId) + .then((data) => { + console.info('[FormComponent] deleteForm result:' + data); + }); + } + + public async releaseCard(formId: string) { + formManager.releaseForm(formId) + .then((data) => { + console.info('[FormComponent] releaseForm result:' + data); + }); + } + + public async castTempToNormal(formId: string) { + formManager.castTempForm(formId) + .then((data) => { + console.info('[FormComponent] castTempToNormal result:' + data); + }); + } + + public async enableCard(formId: string) { + formManager.enableFormsUpdate([formId]) + .then((data) => { + console.info('[FormComponent] enableFormsUpdate result:' + data); + }); + } + + public async disableCard(formId: string) { + formManager.disableFormsUpdate([formId]) + .then((data) => { + console.info('[FormComponent] disableCard result:' + data); + }); + } + + public async changeCardVisible(formId: string, isVisible: boolean) { + if (isVisible) { + formManager.notifyVisibleForms([formId]) + .then((data) => { + console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible); + }); + } else { + formManager.notifyInvisibleForms([formId]) + .then((data) => { + console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible); + }); + } + } + + public async isFmsReady() { + formManager.isSystemReady() + .then((data) => { + console.info('[FormComponent] isFmsReady result:' + data); + }); + } + + public async getAllFormsInfo() { + console.info("[FormComponent] getAllFormsInfo start"); + formManager.getAllFormsInfo() + .then((data) => { + console.info('[FormComponent] getAllFormsInfo result:' + JSON.stringify(data)); + }) + .catch((err) => { + console.info('[FormComponent] getAllFormsInfo error:' + JSON.stringify(err)); + }); + console.info("[FormComponent] getAllFormsInfo end"); + } + + public async getFormsInfoByApp(bundle: string) { + formManager.getFormsInfo(bundle) + .then((data) => { + console.info('[FormComponent] getFormsInfoByApp result:' + JSON.stringify(data)); + }); + } + + public async getFormsInfoByModule(bundle: string, moduleName: string) { + formManager.getFormsInfo(bundle, moduleName) + .then((data) => { + console.info('[FormComponent] getFormsInfoByModule result:' + JSON.stringify(data)); + }); + } + + public async clearFormUserCache() { + bundleManager.cleanBundleCacheFiles('com.ohos.myapplicationform') + .then((data) => { + console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data)); + }); + } + + public async clearFormProviderCache(bundle: string) { + bundleManager.cleanBundleCacheFiles(bundle) + .then((data) => { + console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data)); + }); + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/ets/MainAbility/pages/index.ets b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..07cb76f5af58c6f15b68bfaa8a7402c4a5c9252f --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,68 @@ +/* + * 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. + */ + +// @ts-nocheck +import featureAbility from "@ohos.ability.featureAbility"; +import file from '@system.file'; +import { Core, ExpectExtend, ReportExtend } from "deccjsunit/index.ets"; +import testsuite from "../test/List.test.ets"; + +@Entry +@Component +struct Index { + + aboutToAppear() { + + console.info("[FormComponent] start run testcase!!!!"); + + featureAbility.getWant() + .then((want: any) => { + console.info('[FormComponent] Operation successful. Data: ' + JSON.stringify(want)); + const core = Core.getInstance(); + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }); + core.addService('expect', expectExtend); + const reportExtend = new ReportExtend(file); + core.addService('report', reportExtend); + core.init(); + core.subscribeEvent('task', reportExtend); + const configService = core.getDefaultService('config'); + want.parameters['timeout'] = 10000; + console.info('[FormComponent] parameters---->' + JSON.stringify(want.parameters)); + configService.setConfig(want.parameters); + testsuite(); + core.execute(); + }) + .catch((error: any) => { + console.error('[FormComponent] Operation failed. Cause: ' + JSON.stringify(error)); + }) + } + + build() { + Flex({ + direction: FlexDirection.Column, + alignItems: ItemAlign.Center, + justifyContent: FlexAlign.Center + }) { + Text('Fms Main Ability Test') + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + .height('100%') + } +} + diff --git a/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/ets/MainAbility/test/FmsFormStateNotifyVisible.test.ets b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/ets/MainAbility/test/FmsFormStateNotifyVisible.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..6c49e42c40497c5fbe045b5a1241ca3d5aa70aa0 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/ets/MainAbility/test/FmsFormStateNotifyVisible.test.ets @@ -0,0 +1,1626 @@ +/* + * 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 featureAbility from "@ohos.ability.featureAbility"; +import commonEvent from '@ohos.commonEvent'; +import { beforeAll, describe, expect, it } from "deccjsunit/index.ets"; + +var onErrorForm_Event = { + events: ["FMS_FormOnError_commonEvent"], +}; +var onAcquiredForm_Event = { + events: ["FMS_FormOnAcquired_commonEvent"], +}; + +var onDeletedFormEvent = { + events: ["FMS_FormOnDeleted_commonEvent"], +}; + +var onStateFormEvent = { + events: ["FMS_FormOnState_commonEvent"], +}; + +var onSupplyEvent = { + events: ["FMS_FormSupply_commonEvent"], +}; + +var deleteForm_Event = "FMS_FormDelete_commonEvent"; + +export default function test() { + describe(`FmsStateFormTest`, () => { + + beforeAll(async (done) => { + done(); + }) + + /** + * @tc.number: FMS_notifyVisibleForms_0200 + * @tc.name: The form user does not have permission. + * @tc.desc: 1.The form user calls the visible notification interface. + * 2.Verify the result of the visible notification interface. + */ + it(`FMS_notifyVisibleForms_0200`, 0, async (done) => { + console.log(`FMS_notifyVisibleForms_0200 start`); + let subscriberOnState; + + function onStateCallBack(err, data) { + console.info("!!!====>FMS_notifyVisibleForms_0200 onStateCallBack data:====>" + JSON.stringify(data)); + expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); + expect(data.data).assertEqual("2"); + commonEvent.unsubscribe(subscriberOnState, unsubscribeOnStateCallBack); + setTimeout(function () { + console.info('FMS_notifyVisibleForms_0200 onStateCallBack end'); + console.log(`FMS_notifyVisibleForms_0200 end`); + done(); + }, 1000) + } + function unsubscribeOnStateCallBack() { + console.debug("====>FMS_notifyVisibleForms_0200 unsubscribeOnStateCallBack====>"); + } + + commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { + console.debug("====>FMS_notifyVisibleForms_0200 onStateFormEvent Subscriber====>"); + subscriberOnState = data; + await commonEvent.subscribe(subscriberOnState, onStateCallBack); + }); + + console.log(`FMS_notifyVisibleForms_0200 featureAbility.startAbility again start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostnoperm", + abilityName: "com.ohos.st.formsystemhostnoperm.MainAbility", + parameters: { + "formId" : "0", + "name" : "Form_Js001", + "bundle" : "com.form.formsystemtestservicea.hmservice", + "ability" : "com.form.formsystemtestservicea.hmservice.FormAbility", + "moduleName" : "entry", + "temporary" : false, + "stateForm" : "visible", + "stateIds" : ["1"], + "isCreate" : false + } + } + }).then((res: any) => { + console.log(`FMS_notifyVisibleForms_0200 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_notifyVisibleForms_0200 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_notifyVisibleForms_0200 featureAbility.startAbility again end`); + }); + /** + * @tc.number: FMS_notifyVisibleForms_0300 + * @tc.name: The length of the formId list is 0 (no formId) + * @tc.desc: 1.The form user calls the visible notification interface. + * 2.Verify the result of the visible notification interface. + */ + it(`FMS_notifyVisibleForms_0300`, 0, async (done) => { + console.log(`FMS_notifyVisibleForms_0300 start`); + let subscriberOnState; + let formId; + + function onStateCallBack(err, data) { + console.info("!!!====>FMS_notifyVisibleForms_0300 onStateCallBack data:====>" + JSON.stringify(data)); + expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); + expect(data.data).assertEqual("7"); + commonEvent.unsubscribe(subscriberOnState, unSubscribeOnStateCallback); + + setTimeout(function () { + console.info('FMS_notifyVisibleForms_0300 delPublishCallBack end'); + console.log(`FMS_notifyVisibleForms_0300 end`); + done(); + }, 100) + } + function unSubscribeOnStateCallback() { + console.debug("====>FMS_notifyVisibleForms_0300 unSubscribeOnStateCallback CallBack====>"); + } + + commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { + console.debug("====>FMS_notifyVisibleForms_0300 onStateFormEvent Subscriber====>"); + subscriberOnState = data; + await commonEvent.subscribe(subscriberOnState, onStateCallBack); + }); + console.log(`FMS_notifyVisibleForms_0300 featureAbility.startAbility start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "Form_Js001", + "bundle" : "com.form.formsystemtestservicea.hmservice", + "ability" : "com.form.formsystemtestservicea.hmservice.FormAbility", + "moduleName" : "entry", + "temporary" : false, + "stateForm" : "visible", + "stateIds" : [], + "isCreate" : false + } + } + }).then((res: any) => { + console.log(`FMS_notifyVisibleForms_0300 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_notifyVisibleForms_0300 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_notifyVisibleForms_0300 featureAbility.startAbility end`); + }); + /** + * @tc.number: FMS_notifyVisibleForms_0400 + * @tc.name: formID id is error(formID < 0) + * @tc.desc: 1.The form user calls the visible notification interface. + * 2.Verify the result of the visible notification interface. + */ + it(`FMS_notifyVisibleForms_0400`, 0, async (done) => { + console.log(`FMS_notifyVisibleForms_0400 start`); + let subscriberOnState; + let formId; + function onStateCallBack(err, data) { + console.info("!!!====>FMS_notifyVisibleForms_0400 onStateCallBack data:====>" + JSON.stringify(data)); + expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); + expect(data.data).assertEqual("0"); + commonEvent.unsubscribe(subscriberOnState, unSubscribeOnStateCallback) + + setTimeout(function () { + console.info('FMS_notifyVisibleForms_0400 delPublishCallBack end'); + console.log(`FMS_notifyVisibleForms_0400 end`); + done(); + }, 100) + } + function unSubscribeOnStateCallback() { + console.debug("====>FMS_notifyVisibleForms_0400 unSubscribeOnStateCallback CallBack====>"); + } + + commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { + console.debug("====>FMS_notifyVisibleForms_0400 onStateFormEvent Subscriber====>"); + subscriberOnState = data; + await commonEvent.subscribe(subscriberOnState, onStateCallBack); + }); + console.log(`FMS_notifyVisibleForms_0400 featureAbility.startAbility start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "Form_Js001", + "bundle" : "com.form.formsystemtestservicea.hmservice", + "ability" : "com.form.formsystemtestservicea.hmservice.FormAbility", + "moduleName" : "entry", + "temporary" : false, + "stateForm" : "visible", + "stateIds" : ["-1"], + "isCreate" : false + } + } + }).then((res: any) => { + console.log(`FMS_notifyVisibleForms_0400 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_notifyVisibleForms_0400 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_notifyVisibleForms_0400 featureAbility.startAbility end`); + }); + /** + * @tc.number: FMS_notifyVisibleForms_0500 + * @tc.name: formID id is error(formID == 0) + * @tc.desc: 1.The form user calls the visible notification interface. + * 2.Verify the result of the visible notification interface. + */ + it(`FMS_notifyVisibleForms_0500`, 0, async (done) => { + console.log(`FMS_notifyVisibleForms_0500 start`); + let subscriberOnState; + let formId; + + function onStateCallBack(err, data) { + console.info("!!!====>FMS_notifyVisibleForms_0500 onStateCallBack data:====>" + JSON.stringify(data)); + expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); + expect(data.data).assertEqual("0"); + commonEvent.unsubscribe(subscriberOnState, unSubscribeOnStateCallback) + + setTimeout(function () { + console.info('FMS_notifyVisibleForms_0500 delPublishCallBack end'); + console.log(`FMS_notifyVisibleForms_0500 end`); + done(); + }, 100); + } + function unSubscribeOnStateCallback() { + console.debug("====>FMS_notifyVisibleForms_0500 unSubscribeOnStateCallback CallBack====>"); + } + + commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { + console.debug("====>FMS_notifyVisibleForms_0500 onStateFormEvent Subscriber====>"); + subscriberOnState = data; + await commonEvent.subscribe(subscriberOnState, onStateCallBack); + }); + console.log(`FMS_notifyVisibleForms_0500 featureAbility.startAbility start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "Form_Js001", + "bundle" : "com.form.formsystemtestservicea.hmservice", + "ability" : "com.form.formsystemtestservicea.hmservice.FormAbility", + "moduleName" : "entry", + "temporary" : false, + "stateForm" : "visible", + "stateIds" : ["0"], + "isCreate" : false + } + } + }).then((res: any) => { + console.log(`FMS_notifyVisibleForms_0500 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_notifyVisibleForms_0500 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_notifyVisibleForms_0500 featureAbility.startAbility end`); + }); + /** + * @tc.number: FMS_notifyVisibleForms_0600 + * @tc.name: formID id is error because formId is not self + * @tc.desc: 1.The form user calls the visible notification interface. + * 2.Verify the result of the visible notification interface. + */ + it(`FMS_notifyVisibleForms_0600`, 0, async (done) => { + console.log(`FMS_notifyVisibleForms_0600 start`); + let subscriberOnState; + let subscriberOnAcquired; + let formId; + + function delPublishCallBack() { + console.info("!!!====>FMS_notifyVisibleForms_0600 delPublishCallBack====>"); + setTimeout(function () { + console.info('FMS_notifyVisibleForms_0600 delPublishCallBack end'); + console.log(`FMS_notifyVisibleForms_0600 end`); + done(); + }, 1000); + } + + function onStateCallBack(err, data) { + console.info("!!!====>FMS_notifyVisibleForms_0600 onStateCallBack data:====>" + JSON.stringify(data)); + expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); + expect(data.data).assertEqual("0"); + commonEvent.unsubscribe(subscriberOnState, unsubscribeOnStateCallback); + let commonEventPublishData = { + data: formId + }; + commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); + } + function unsubscribeOnStateCallback() { + console.debug("====>FMS_notifyVisibleForms_0600 unsubscribeOnStateCallback====>"); + } + function unSubscribeOnAcquiredCallback() { + console.debug("====>FMS_notifyVisibleForms_0600 OnAcquired UnSubscribe CallBack====>"); + } + async function onAcquiredCallBack(err, data) { + console.info("!!!====>FMS_notifyVisibleForms_0600 onAcquiredCallBack data:====>" + JSON.stringify(data)); + expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent"); + commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallback) + formId = data.data; + commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { + console.debug("====>FMS_notifyVisibleForms_0600 onStateFormEvent Subscriber====>"); + subscriberOnState = data; + await commonEvent.subscribe(subscriberOnState, onStateCallBack); + }); + + console.log(`FMS_notifyVisibleForms_0600 featureAbility.startAbility again start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "Form_Js001", + "bundle" : "com.form.formsystemtestservicea.hmservice", + "ability" : "com.form.formsystemtestservicea.hmservice.FormAbility", + "moduleName" : "entry", + "temporary" : false, + "stateForm" : "visible", + "stateIds" : [formId], + "isCreate" : false + } + } + }).then((res: any) => { + console.log(`FMS_notifyVisibleForms_0600 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_notifyVisibleForms_0600 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_notifyVisibleForms_0600 featureAbility.startAbility again end`); + } + + commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => { + console.debug("====>FMS_notifyVisibleForms_0600 Create OnAcquired Subscriber====>"); + subscriberOnAcquired = data; + await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack); + }); + console.log(`FMS_notifyVisibleForms_0600 featureAbility.startAbility start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostf", + abilityName: "com.ohos.st.formsystemhostf.MainAbility", + parameters: { + "formId" : "0", + "name" : "Form_Js001", + "bundle" : "com.form.formsystemtestservicea.hmservice", + "ability" : "com.form.formsystemtestservicea.hmservice.FormAbility", + "moduleName" : "entry", + "temporary" : false, + "isCreate" : true + } + } + }).then((res: any) => { + console.log(`FMS_notifyVisibleForms_0600 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_notifyVisibleForms_0600 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_notifyVisibleForms_0600 featureAbility.startAbility end`); + }); + /** + * @tc.number: FMS_notifyVisibleForms_0700 + * @tc.name: Form ID error (FormID does not exist) + * @tc.desc: 1.The form user calls the visible notification interface. + * 2.Verify the result of the visible notification interface. + */ + it(`FMS_notifyVisibleForms_0700`, 0, async (done) => { + console.log(`FMS_notifyVisibleForms_0700 start`); + let subscriberOnState; + let formId; + + function onStateCallBack(err, data) { + console.info("!!!====>FMS_notifyVisibleForms_0700 onStateCallBack data:====>" + JSON.stringify(data)); + expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); + expect(data.data).assertEqual("0"); + commonEvent.unsubscribe(subscriberOnState, unSubscribeOnStateCallback); + + setTimeout(function () { + console.info('FMS_notifyVisibleForms_0700 onStateCallBack end'); + console.log(`FMS_notifyVisibleForms_0700 end`); + done(); + }, 100); + } + function unSubscribeOnStateCallback() { + console.debug("====>FMS_notifyVisibleForms_0700 unSubscribeOnStateCallback CallBack====>"); + } + function unSubscribeDeletedCallback() { + console.debug("====>FMS_notifyVisibleForms_0700 unSubscribeDeletedCallback CallBack====>"); + } + + commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { + console.debug("====>FMS_notifyVisibleForms_0700 onStateFormEvent Subscriber====>"); + subscriberOnState = data; + await commonEvent.subscribe(subscriberOnState, onStateCallBack); + }); + + console.log(`FMS_notifyVisibleForms_0700 featureAbility.startAbility again start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "Form_Js001", + "bundle" : "com.form.formsystemtestservicea.hmservice", + "ability" : "com.form.formsystemtestservicea.hmservice.FormAbility", + "moduleName" : "entry", + "temporary" : false, + "stateForm" : "visible", + "stateIds" : ["123456789"], + "isCreate" : false + } + } + }).then((res: any) => { + console.log(`FMS_notifyVisibleForms_0700 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_notifyVisibleForms_0700 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_notifyVisibleForms_0700 featureAbility.startAbility again end`); + }); + /** + * @tc.number: FMS_notifyVisibleForms_1000 + * @tc.name: The form provider is the system application and config When form visiblenotify is true, + * the form provider can be notified that the form is visible. + * @tc.desc: 1.The form user calls the visible notification interface. + * 2.Verify the result of the visible notification interface. + */ + it(`FMS_notifyVisibleForms_1000`, 0, async (done) => { + console.log(`FMS_notifyVisibleForms_1000 start`); + let subscriberInvisible; + let subscriberVisible; + let subscriberSupply; + let supplyFlag = false; + let formIdInvisible; + let formIdVisible; + let onSupplyCount = 0; + + function unSubscribeSupplyCallback() { + console.debug("====>FMS_notifyVisibleForms_1000 unSubscribeSupplyCallback====>"); + } + function delPublishCallBack(err, data) { + console.info("!!!====>FMS_notifyVisibleForms_1000 delPublishCallBack====>"); + setTimeout(function () { + console.info('FMS_notifyVisibleForms_1000 delPublishCallBack end'); + console.log(`FMS_notifyVisibleForms_1000 end`); + done(); + }, 1000); + } + + function onSupplyCallBack(err, data) { + if (data.parameters.kind == "onVisibilityChange") { + expect(data.event).assertEqual("FMS_FormSupply_commonEvent"); + console.debug("====>FMS_notifyVisibleForms_1000 onSupplyCallBack====>" + JSON.stringify(data)); + onSupplyCount++; + if (onSupplyCount == 2) { + commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback); + } + if (formIdInvisible && formIdVisible) { + let commonEventPublishData = { + data: formIdInvisible + }; + commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); + } + } + } + + function onVisibleCallBack(err, data) { + console.info("!!!====>FMS_notifyVisibleForms_1000 onVisibleCallBack data:====>" + JSON.stringify(data)); + expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); + expect(data.data).assertEqual("0"); + formIdVisible = data.parameters.formId; + commonEvent.unsubscribe(subscriberVisible, unSubscribeOnVisibleCallback); + if (formIdInvisible && formIdVisible && onSupplyCount == 2) { + let commonEventPublishData = { + data: formIdInvisible + }; + commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); + } + } + function unSubscribeOnVisibleCallback() { + console.debug("====>FMS_notifyVisibleForms_1000 unSubscribeOnVisibleCallback CallBack====>"); + } + function unSubscribeOnInvisibleCallback(){ + console.debug("====>FMS_notifyVisibleForms_1000 unSubscribeOnInvisibleCallback CallBack====>"); + } + async function OnInvisibleCallBack(err, data) { + console.info("!!!====>FMS_notifyVisibleForms_1000 OnInvisibleCallBack data:====>" + JSON.stringify(data)); + expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); + expect(data.data).assertEqual("0"); + commonEvent.unsubscribe(subscriberInvisible, unSubscribeOnInvisibleCallback) + formIdInvisible = data.parameters.formId; + commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { + console.debug("====>FMS_notifyVisibleForms_1000 B onStateFormEvent Subscriber====>"); + subscriberVisible = data; + await commonEvent.subscribe(subscriberVisible, onVisibleCallBack); + }); + + console.log(`FMS_notifyVisibleForms_1000 featureAbility.startAbility again start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "Form_Js001", + "bundle" : "com.form.formsystemtestservicea.hmservice", + "ability" : "com.form.formsystemtestservicea.hmservice.FormAbility", + "moduleName" : "entry", + "temporary" : false, + "stateForm" : "visible", + "stateIds" : [formIdInvisible], + "isCreate" : false + } + } + }).then((res: any) => { + console.log(`FMS_notifyVisibleForms_1000 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_notifyVisibleForms_1000 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_notifyVisibleForms_1000 featureAbility.startAbility again end`); + } + + commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { + console.debug("====>FMS_notifyVisibleForms_1300 onStateFormEvent Invisible Subscriber====>"); + subscriberInvisible = data; + await commonEvent.subscribe(subscriberInvisible, OnInvisibleCallBack); + }); + commonEvent.createSubscriber(onSupplyEvent).then(async (data) => { + console.debug("====>FMS_notifyVisibleForms_1300 onSupplyEvent Subscriber====>"); + subscriberSupply = data; + await commonEvent.subscribe(subscriberSupply, onSupplyCallBack); + }); + console.log(`FMS_notifyVisibleForms_1000 featureAbility.startAbility start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "Form_Js001", + "bundle" : "com.form.formsystemtestservicea.hmservice", + "ability" : "com.form.formsystemtestservicea.hmservice.FormAbility", + "moduleName" : "entry", + "temporary" : false, + "stateForm" : "invisible", + "stateIds" : ["self"], + "isCreate" : true + } + } + }).then((res: any) => { + console.log(`FMS_notifyVisibleForms_1000 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_notifyVisibleForms_1000 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_notifyVisibleForms_1000 featureAbility.startAbility end`); + }); + /** + * @tc.number: FMS_notifyVisibleForms_1100 + * @tc.name: Use 0 and created form card Id notify the form to be visible. + * @tc.desc: 1.The form user calls the visible notification interface. + * 2.Verify the result of the visible notification interface. + */ + it(`FMS_notifyVisibleForms_1100`, 0, async (done) => { + console.log(`FMS_notifyVisibleForms_1100 start`); + let subscriberSupply; + let subscriberOnVisible; + let assertFormId; + + function unSubscribeSupplyCallback() { + console.debug("====>FMS_notifyVisibleForms_1100 unSubscribeSupplyCallback====>"); + } + function delPublishCallBack(err, data) { + console.info("!!!====>FMS_notifyVisibleForms_1100 delPublishCallBack====>" + JSON.stringify(data)); + setTimeout(function () { + console.info('FMS_notifyVisibleForms_1100 delPublishCallBack end'); + console.log(`FMS_notifyVisibleForms_1100 end`); + done(); + }, 1000); + } + function onSupplyCallBack(err, data) { + if (data.parameters.kind == "onVisibilityChange") { + expect(data.event).assertEqual("FMS_FormSupply_commonEvent"); + commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback); + console.debug("====>FMS_notifyVisibleForms_1100 onSupplyCallBack====>" + JSON.stringify(data)); + let formId = Object.keys(JSON.parse(data.parameters.parameters))[0]; + const visibilityStatus = JSON.parse(data.parameters.parameters)[formId]; + expect(formId).assertEqual(assertFormId); + expect(visibilityStatus).assertEqual(1); + + let commonEventPublishData = { + data: formId + }; + commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); + } + } + + function unSubscribeOnVisibleCallback() { + console.debug("====>FMS_notifyVisibleForms_1100 unSubscribeOnVisibleCallback CallBack====>"); + } + + function onVisibleCallBack(err, data) { + if (data.parameters.kind != "visible") { + return; + } + console.info("!!!====>FMS_notifyVisibleForms_1100 onVisibleCallBack data:====>" + JSON.stringify(data)); + expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); + expect(data.data).assertEqual("0"); + assertFormId = data.parameters.formId; + + commonEvent.unsubscribe(subscriberOnVisible, unSubscribeOnVisibleCallback); + } + commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { + console.debug("====>FMS_notifyVisibleForms_1100 onStateFormEvent Visible Subscriber====>"); + subscriberOnVisible = data; + await commonEvent.subscribe(subscriberOnVisible, onVisibleCallBack); + }); + commonEvent.createSubscriber(onSupplyEvent).then(async (data) => { + console.debug("====>FMS_notifyVisibleForms_1100 onSupplyEvent Subscriber====>"); + subscriberSupply = data; + await commonEvent.subscribe(subscriberSupply, onSupplyCallBack); + }); + console.log(`FMS_notifyVisibleForms_1100 featureAbility.startAbility start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "Form_Js001", + "bundle" : "com.form.formsystemtestservicea.hmservice", + "ability" : "com.form.formsystemtestservicea.hmservice.FormAbility", + "moduleName" : "entry", + "temporary" : false, + "stateForm" : "visible", + "stateIds" : ["self", "0"], + "isCreate" : true + } + } + }).then((res: any) => { + console.log(`FMS_notifyVisibleForms_1100 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_notifyVisibleForms_1100 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_notifyVisibleForms_1100 featureAbility.startAbility end`); + }); + + /** + * @tc.number: FMS_notifyVisibleForms_1200 + * @tc.name: When the form provider is not a system application, notify the form to be visible + * and do not pull up the form provider. + * @tc.desc: 1.The form user calls the visible notification interface. + * 2.Verify the result of the visible notification interface. + */ + it(`FMS_notifyVisibleForms_1200`, 0, async (done) => { + console.log(`FMS_notifyVisibleForms_1200 start`); + let subscriberOnVisible; + let subscriberOnSupply; + + function delPublishCallBack(err, data) { + console.info("!!!====>FMS_notifyVisibleForms_1200 delPublishCallBack====>" + JSON.stringify(data)); + setTimeout(function () { + console.info('FMS_notifyVisibleForms_1200 delPublishCallBack end'); + console.log(`FMS_notifyVisibleForms_1200 end`); + done(); + }, 1000); + } + + function unSubscribeOnVisibleCallback() { + console.debug("====>FMS_notifyVisibleForms_1200 unSubscribeOnVisibleCallback CallBack====>"); + } + function unSubscribeSupplyCallback() { + console.debug("====>FMS_notifyVisibleForms_1200 unSubscribeSupplyCallback CallBack====>"); + } + function onVisibleCallBack(err, data) { + if (data.parameters.kind != "visible") { + return; + } + console.info("!!!====>FMS_notifyVisibleForms_1200 onVisibleCallBack data:====>" + JSON.stringify(data)); + expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); + expect(data.data).assertEqual("0"); + + setTimeout(function () { + commonEvent.unsubscribe(subscriberOnVisible, unSubscribeOnVisibleCallback); + commonEvent.unsubscribe(subscriberOnSupply, unSubscribeSupplyCallback); + + let commonEventPublishData = { + data: data.parameters.formId + }; + commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); + }, 2000); + } + function onSupplyEventCallBack(err, data) { + if (data.parameters.kind != "onVisibilityChange") { + return; + } + expect(data.event).assertEqual("FMS_FormSupply_commonEvent"); + commonEvent.unsubscribe(subscriberOnSupply, unSubscribeSupplyCallback); + console.debug("====>FMS_notifyVisibleForms_1200 onSupplyEventCallBack====>" + JSON.stringify(data)); + console.log(`FMS_notifyVisibleForms_1200 error`); + expect().assertFail(); + } + commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { + console.debug("====>FMS_notifyVisibleForms_1200 onStateFormEvent Visible Subscriber====>"); + subscriberOnVisible = data; + await commonEvent.subscribe(subscriberOnVisible, onVisibleCallBack); + }); + commonEvent.createSubscriber(onSupplyEvent).then(async (data) => { + console.debug("====>FMS_notifyVisibleForms_1200 onSupplyEvent Visible Subscriber====>"); + subscriberOnSupply = data; + await commonEvent.subscribe(subscriberOnSupply, onSupplyEventCallBack); + }); + console.log(`FMS_notifyVisibleForms_1200 featureAbility.startAbility start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "Form_Js001", + "bundle" : "com.form.formsystemtestservicenotsysapp.hmservice", + "ability" : "com.form.formsystemtestservicenotsysapp.hmservice.FormAbility", + "moduleName" : "entry", + "temporary" : false, + "stateForm" : "visible", + "stateIds" : ["self"], + "isCreate" : true + } + } + }).then((res: any) => { + console.log(`FMS_notifyVisibleForms_1200 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_notifyVisibleForms_1200 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_notifyVisibleForms_1200 featureAbility.startAbility end`); + }); + + /** + * @tc.number: FMS_notifyVisibleForms_1300 + * @tc.name: Provider onVisibleChange can not be called when formVisibleNotify is false. + * @tc.desc: 1.The form user calls the visible notification interface. + * 2.Verify the result of the onVisibleChange interface. + */ + it(`FMS_notifyVisibleForms_1300`, 0, async (done) => { + console.log(`FMS_notifyVisibleForms_1300 start`); + let subscriberOnVisible; + + function delPublishCallBack(err, data) { + console.info("!!!====>FMS_notifyVisibleForms_1300 delPublishCallBack====>" + JSON.stringify(data)); + setTimeout(function () { + console.info('FMS_notifyVisibleForms_1300 delPublishCallBack end'); + console.log(`FMS_notifyVisibleForms_1300 end`); + done(); + }, 1000); + } + + function unSubscribeOnVisibleCallback() { + console.debug("====>FMS_notifyVisibleForms_1300 unSubscribeOnVisibleCallback CallBack====>"); + } + function OnVisibleCallBack(err, data) { + if (data.parameters.kind != "visible") { + return; + } + console.info("!!!====>FMS_notifyVisibleForms_1300 OnVisibleCallBack data:====>" + JSON.stringify(data)); + expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); + expect(data.data).assertEqual("0"); + + commonEvent.unsubscribe(subscriberOnVisible, unSubscribeOnVisibleCallback); + + let commonEventPublishData = { + data: data.parameters.formId + }; + commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); + } + commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { + console.debug("====>FMS_notifyVisibleForms_1300 onStateFormEvent Visible Subscriber====>"); + subscriberOnVisible = data; + await commonEvent.subscribe(subscriberOnVisible, OnVisibleCallBack); + }); + console.log(`FMS_notifyVisibleForms_1300 featureAbility.startAbility start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "Form_Js001", + "bundle" : "com.form.formsystemtestserviced.hmservice", + "ability" : "com.form.formsystemtestserviced.hmservice.FormAbility", + "moduleName" : "entry", + "temporary" : false, + "stateForm" : "visible", + "stateIds" : ["self"], + "isCreate" : true + } + } + }).then((res: any) => { + console.log(`FMS_notifyVisibleForms_1300 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_notifyVisibleForms_1300 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_notifyVisibleForms_1300 featureAbility.startAbility end`); + }); + /** + * @tc.number: FMS_notifyVisibleForms_1400 + * @tc.name: formVisibleNotify in config.json is true, + * it can notify the form provider that the form is not visible. + * @tc.desc: 1. The card is created successfully. + * 2. The visibility interface is successfully invoked. + * The visibility notification of form provider A is triggered, + * and the formId is the same as that of the created formId. + */ + it(`FMS_notifyVisibleForms_1400`, 0, async (done) => { + console.log(`FMS_notifyVisibleForms_1400 start`); + let subscriberOnAcquired; + let subscriberOnState; + let subscriberSupply; + let supplyFlag = false; + let formId1; + let formId2; + let delCount = 0; + let onSupplyCount = 0; + + function delPublishCallBack() { + console.info("!!!====>FMS_notifyVisibleForms_1400 delPublishCallBack====>"); + delCount++; + if (delCount == 2) { + setTimeout(function () { + commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback); + if (supplyFlag) { + expect().assertFail(); + } + console.info('FMS_notifyVisibleForms_1400 delPublishCallBack end'); + console.info('FMS_notifyVisibleForms_1400 end'); + done(); + }, 1000); + } + } + function onAcquiredCallBack_Normal1(err, data) { + console.info("!!!====>FMS_notifyVisibleForms_1400 onAcquiredCallBack_Normal1 data:====>" + JSON.stringify(data)); + expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent"); + commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallBack_Normal1) + formId1 = data.data; + + FMS_notifyVisibleForms_1400_normal2(); + } + function unSubscribeOnAcquiredCallBack_Normal1() { + console.debug("====>FMS_notifyVisibleForms_1400 unSubscribeOnAcquiredCallBack_Normal1 CallBack====>"); + } + + async function FMS_notifyVisibleForms_1400_normal1() { + console.log(`FMS_notifyVisibleForms_1400_normal1 start`); + commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => { + console.debug("====>FMS_notifyVisibleForms_1400_normal1 Create OnAcquired Subscriber====>"); + subscriberOnAcquired = data; + await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack_Normal1); + }); + + console.log(`FMS_notifyVisibleForms_1400_normal1 featureAbility.startAbility start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "Form_Js001", + "bundle" : "com.form.formsystemtestservicea.hmservice", + "ability" : "com.form.formsystemtestservicea.hmservice.FormAbility", + "moduleName" : "entry", + "temporary" : false, + "isCreate" : true + } + } + }).then((res: any) => { + console.log(`FMS_notifyVisibleForms_1400_normal1 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_notifyVisibleForms_1400_normal1 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + + console.log(`FMS_notifyVisibleForms_1400_normal1 featureAbility.startAbility end`); + console.log(`FMS_notifyVisibleForms_1400_normal1 end`); + } + + function onStateCallBack(err, data) { + console.info("!!!====>FMS_notifyVisibleForms_1400 onStateCallBack data:====>" + JSON.stringify(data)); + expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); + expect(data.data).assertEqual("0"); + commonEvent.unsubscribe(subscriberOnState, unSubscribeOnStateCallback) + console.info("!!!====>FMS_notifyVisibleForms_1400 onStateCallBack formId1:====>" + formId1); + console.info("!!!====>FMS_notifyVisibleForms_1400 onStateCallBack formId2:====>" + formId2); + console.info("!!!====>FMS_notifyVisibleForms_1400 onStateCallBack onSupplyCount:====>" + onSupplyCount); + if (formId1 && formId2 && onSupplyCount == 1) { + let commonEventPublishData = { + data: formId1 + }; + commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); + let commonEventPublishData2 = { + data: formId2 + }; + commonEvent.publish(deleteForm_Event, commonEventPublishData2, delPublishCallBack); + } + } + function unSubscribeOnStateCallback() { + console.debug("====>FMS_notifyVisibleForms_1400 unSubscribeOnStateCallback CallBack====>"); + } + + async function onAcquiredCallBack_Normal2(err, data) { + console.info("!!!====>FMS_notifyVisibleForms_1400 onAcquiredCallBack_Normal2 data:====>" + JSON.stringify(data)); + expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent"); + commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallBack_Normal2); + formId2 = data.data; + + commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { + console.debug("====>FMS_notifyVisibleForms_1400 onStateFormEvent Subscriber====>"); + subscriberOnState = data; + await commonEvent.subscribe(subscriberOnState, onStateCallBack); + }); + + console.log(`FMS_notifyVisibleForms_1400 featureAbility.startAbility start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "Form_Js001", + "bundle" : "com.form.formsystemtestservicea.hmservice", + "ability" : "com.form.formsystemtestservicea.hmservice.FormAbility", + "moduleName" : "entry", + "temporary" : false, + "stateForm" : "visible", + "stateIds" : [formId1,formId2], + "isCreate" : true + } + } + }).then((res: any) => { + console.log(`FMS_notifyVisibleForms_1400 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_notifyVisibleForms_1400 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_notifyVisibleForms_1400 featureAbility.startAbility end`); + } + function unSubscribeOnAcquiredCallBack_Normal2() { + console.debug("====>FMS_notifyVisibleForms_1400 unSubscribeOnAcquiredCallBack_Normal2====>"); + } + async function FMS_notifyVisibleForms_1400_normal2() { + commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => { + console.debug("====>FMS_notifyVisibleForms_1400_normal2 Create OnAcquired Subscriber====>"); + subscriberOnAcquired = data; + await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack_Normal2); + }); + + console.log(`FMS_notifyVisibleForms_1400_normal2 featureAbility.startAbility start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "Form_Js001", + "bundle" : "com.form.formsystemtestserviced.hmservice", + "ability" : "com.form.formsystemtestserviced.hmservice.FormAbility", + "moduleName" : "entry", + "temporary" : false, + "isCreate" : true + } + } + }).then((res: any) => { + console.log(`FMS_notifyVisibleForms_1400_normal2 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_notifyVisibleForms_1400_normal2 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + + console.log(`FMS_notifyVisibleForms_1400_normal2 featureAbility.startAbility end`); + } + function unSubscribeSupplyCallback() { + console.debug("====>FMS_notifyVisibleForms_1400 unSubscribeSupplyCallback====>"); + } + function onSupplyCallBack(err, data) { + if (data.parameters.kind == "onVisibilityChange") { + expect(data.event).assertEqual("FMS_FormSupply_commonEvent"); + console.debug("====>FMS_notifyVisibleForms_1400 onSupplyCallBack====>" + JSON.stringify(data)); + let parameters = JSON.parse(data.parameters.parameters); + if(parameters[formId1]) { + expect(parameters[formId1]).assertEqual(1); + } + if(parameters[formId2]) { + expect(parameters[formId2]).assertEqual(1); + } + + onSupplyCount++; + if (onSupplyCount == 2) { + supplyFlag = true; + commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback); + } + + if (formId1 && formId2) { + let commonEventPublishData = { + data: formId1 + }; + commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); + let commonEventPublishData2 = { + data: formId2 + }; + commonEvent.publish(deleteForm_Event, commonEventPublishData2, delPublishCallBack); + } + } + } + commonEvent.createSubscriber(onSupplyEvent).then(async (data) => { + console.debug("====>FMS_notifyVisibleForms_1400 onSupplyEvent Subscriber====>"); + subscriberSupply = data; + await commonEvent.subscribe(subscriberSupply, onSupplyCallBack); + }); + FMS_notifyVisibleForms_1400_normal1(); + }); + /** + * @tc.number: FMS_notifyVisibleForms_1500 + * @tc.name: Created provider A and B form card, notify the form to be visible 3times. + * @tc.desc: 1.The form user calls the visible notification interface. + * 2.Verify the result of the visible notification interface. + */ + it(`FMS_notifyVisibleForms_1500`, 0, async (done) => { + console.log(`FMS_notifyVisibleForms_1500 start`); + let subscriberOnAcquired; + let subscriberSupply; + let formIds = new Array(); + let retFormId; + let count = 0; + + function unSubscribeSupplyCallback() { + console.debug("====>FMS_notifyVisibleForms_1500 unSubscribeSupplyCallback====>"); + } + function delPublishCallBack1(err, data) { + console.info("!!!====>FMS_notifyVisibleForms_1500 delPublishCallBack1====>" + JSON.stringify(data)); + setTimeout(function () { + console.info('FMS_notifyVisibleForms_1500 delPublishCallBack1 end'); + console.log(`FMS_notifyVisibleForms_1500 end`); + }, 1000); + } + function delPublishCallBack2(err, data) { + console.info("!!!====>FMS_notifyVisibleForms_1500 delPublishCallBack2====>" + JSON.stringify(data)); + setTimeout(function () { + console.info('FMS_notifyVisibleForms_1500 delPublishCallBack2 end'); + console.log(`FMS_notifyVisibleForms_1500 end`); + done(); + }, 1000); + } + + function onInVisibleSupplyCallBack(err, data) { + if (data.parameters.kind == "onVisibilityChange") { + expect(data.event).assertEqual("FMS_FormSupply_commonEvent"); + console.debug("====>FMS_notifyVisibleForms_1500 onInVisibleSupplyCallBack====>" + JSON.stringify(data)); + + let retFormId = Object.keys(JSON.parse(data.parameters.parameters))[0]; + const visibilityStatus = JSON.parse(data.parameters.parameters)[retFormId]; + expect(formIds.includes(retFormId)).assertTrue(); + expect(visibilityStatus).assertEqual(2); + + ++count; + if (count == 12) { + commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback); + let commonEventPublishData1 = { + data: formIds[0] + }; + commonEvent.publish(deleteForm_Event, commonEventPublishData1, delPublishCallBack1); + let commonEventPublishData2 = { + data: formIds[1] + }; + commonEvent.publish(deleteForm_Event, commonEventPublishData2, delPublishCallBack2); + } + } + } + + async function onVisibleSupplyCallBack(err, data) { + if (data.parameters.kind == "onVisibilityChange") { + expect(data.event).assertEqual("FMS_FormSupply_commonEvent"); + console.debug("====>FMS_notifyVisibleForms_1500 onVisibleSupplyCallBack====>" + JSON.stringify(data)); + + let retFormId = Object.keys(JSON.parse(data.parameters.parameters))[0]; + const visibilityStatus = JSON.parse(data.parameters.parameters)[retFormId]; + expect(formIds.includes(retFormId)).assertTrue(); + expect(visibilityStatus).assertEqual(1); + + ++count; + if (count == 6) { + commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback); + commonEvent.createSubscriber(onSupplyEvent).then(async (data) => { + console.debug("====>FMS_notifyVisibleForms_1500 onSupplyEvent Subscriber====>"); + subscriberSupply = data; + await commonEvent.subscribe(subscriberSupply, onInVisibleSupplyCallBack); + }); + console.log(`FMS_notifyVisibleForms_1500 featureAbility.startAbility notifyInvisible start`); + for (var i = 0; i < 3; i++) { + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "stateForm": "invisible", + "stateIds": formIds, + "isCreate": false + } + } + }).then((res: any) => { + console.log(`FMS_notifyVisibleForms_1500 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_notifyVisibleForms_1500 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + } + console.log(`FMS_notifyVisibleForms_1500 featureAbility.startAbility notifyInvisible end`); + } + } + } + + async function onAcquiredCallBack2(err, data) { + expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent"); + commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeSupplyCallback); + console.debug("====>FMS_notifyVisibleForms_1500 onAcquiredCallBack2====>" + JSON.stringify(data)); + formIds.push(data.data); + console.debug("====>FMS_notifyVisibleForms_1500 formIds====>" + formIds); + + commonEvent.createSubscriber(onSupplyEvent).then(async (data) => { + console.debug("====>FMS_notifyVisibleForms_1500 onSupplyEvent Subscriber====>"); + subscriberSupply = data; + await commonEvent.subscribe(subscriberSupply, onVisibleSupplyCallBack); + }); + + console.log(`FMS_notifyVisibleForms_1500 featureAbility.startAbility notifyVisible start`); + for (var i = 0; i < 3; i++) { + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "stateForm": "visible", + "stateIds": formIds, + "isCreate": false + } + } + }).then((res: any) => { + console.log(`FMS_notifyVisibleForms_1500 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_notifyVisibleForms_1500 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + } + console.log(`FMS_notifyVisibleForms_1500 featureAbility.startAbility notifyVisible end`); + } + + async function onAcquiredCallBack1(err, data) { + expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent"); + commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeSupplyCallback); + console.debug("====>FMS_notifyVisibleForms_1500 onAcquiredCallBack1====>" + JSON.stringify(data)); + formIds.push(data.data); + console.debug("====>FMS_notifyVisibleForms_1500 formIds====>" + JSON.stringify(formIds)); + + commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => { + console.debug("====>FMS_notifyVisibleForms_1500 onAcquiredForm_Event Subscriber====>"); + subscriberOnAcquired = data; + await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack2); + }); + + console.log(`FMS_notifyVisibleForms_1500 featureAbility.startAbility serviceb start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "Form_Js001", + "bundle" : "com.form.formsystemtestserviceb.hmservice", + "ability" : "com.form.formsystemtestserviceb.hmservice.FormAbility", + "moduleName" : "entry", + "temporary" : false, + "isCreate" : true + } + } + }).then((res: any) => { + console.log(`FMS_notifyVisibleForms_1500 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_notifyVisibleForms_1500 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_notifyVisibleForms_1500 featureAbility.startAbility serviceb end`); + } + + commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => { + console.debug("====>FMS_notifyVisibleForms_1500 onAcquiredForm_Event Subscriber====>"); + subscriberOnAcquired = data; + await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack1); + }); + console.log(`FMS_notifyVisibleForms_1500 featureAbility.startAbility servicea start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "Form_Js001", + "bundle" : "com.form.formsystemtestservicea.hmservice", + "ability" : "com.form.formsystemtestservicea.hmservice.FormAbility", + "moduleName" : "entry", + "temporary" : false, + "isCreate" : true + } + } + }).then((res: any) => { + console.log(`FMS_notifyVisibleForms_1500 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_notifyVisibleForms_1500 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_notifyVisibleForms_1500 featureAbility.startAbility servicea end`); + }); + + /** + * @tc.number: FMS_notifyVisibleForms_1600 + * @tc.name: Use -1 and created form card Id notify the form to be visible. + * @tc.desc: 1.The form user calls the visible notification interface. + * 2.Verify the result of the visible notification interface. + */ + it(`FMS_notifyVisibleForms_1600`, 0, async (done) => { + console.log(`FMS_notifyVisibleForms_1600 start`); + let subscriberOnAcquired; + let subscriberSupply; + let formIds = new Array(); + let retFormId; + let count = 0; + + function unSubscribeSupplyCallback() { + console.debug("====>FMS_notifyVisibleForms_1600 unSubscribeSupplyCallback====>"); + } + function delPublishCallBack1(err, data) { + console.info("!!!====>FMS_notifyVisibleForms_1600 delPublishCallBack1====>" + JSON.stringify(data)); + setTimeout(function () { + console.info('FMS_notifyVisibleForms_1600 delPublishCallBack1 end'); + console.log(`FMS_notifyVisibleForms_1600 end`); + }, 1000); + } + function delPublishCallBack2(err, data) { + console.info("!!!====>FMS_notifyVisibleForms_1600 delPublishCallBack2====>" + JSON.stringify(data)); + setTimeout(function () { + console.info('FMS_notifyVisibleForms_1600 delPublishCallBack2 end'); + console.log(`FMS_notifyVisibleForms_1600 end`); + done(); + }, 1000); + } + + function onSupplyCallBack(err, data) { + if (data.parameters.kind == "onVisibilityChange") { + expect(data.event).assertEqual("FMS_FormSupply_commonEvent"); + console.debug("====>FMS_notifyVisibleForms_1600 onSupplyCallBack====>" + JSON.stringify(data)); + + let retFormId = Object.keys(JSON.parse(data.parameters.parameters))[0]; + const visibilityStatus = JSON.parse(data.parameters.parameters)[retFormId]; + expect(formIds.includes(retFormId)).assertTrue(); + expect(visibilityStatus).assertEqual(1); + + ++count; + if (count == 2) { + console.debug("====>FMS_notifyVisibleForms_1600 OK====>"); + commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback); + + let commonEventPublishData1 = { + data: formIds[0] + }; + commonEvent.publish(deleteForm_Event, commonEventPublishData1, delPublishCallBack1); + let commonEventPublishData2 = { + data: formIds[1] + }; + commonEvent.publish(deleteForm_Event, commonEventPublishData2, delPublishCallBack2); + } + } + } + + async function onSecondAcquiredCallBack(err, data) { + expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent"); + commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeSupplyCallback); + console.debug("====>FMS_notifyVisibleForms_1600 onSecondAcquiredCallBack====>" + JSON.stringify(data)); + formIds.push(data.data); + formIds.push("-1"); + console.debug("====>FMS_notifyVisibleForms_1600 formIds====>" + formIds); + + commonEvent.createSubscriber(onSupplyEvent).then(async (data) => { + console.debug("====>FMS_notifyVisibleForms_1600 onSupplyEvent Subscriber====>"); + subscriberSupply = data; + await commonEvent.subscribe(subscriberSupply, onSupplyCallBack); + }); + + console.log(`FMS_notifyVisibleForms_1600 featureAbility.startAbility notifyVisible start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "name", + "bundle" : "bundle", + "ability" : "ability", + "moduleName" : "entry", + "temporary" : false, + "stateForm" : "visible", + "stateIds" : formIds, + "isCreate" : false + } + } + }).then((res: any) => { + console.log(`FMS_notifyVisibleForms_1600 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_notifyVisibleForms_1600 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_notifyVisibleForms_1600 featureAbility.startAbility notifyVisible end`); + } + + async function onFirstAcquiredCallBack(err, data) { + expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent"); + commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeSupplyCallback); + console.debug("====>FMS_notifyVisibleForms_1600 onFirstAcquiredCallBack====>" + JSON.stringify(data)); + formIds.push(data.data); + + commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => { + console.debug("====>FMS_notifyVisibleForms_1600 onAcquiredForm_Event Subscriber====>"); + subscriberOnAcquired = data; + await commonEvent.subscribe(subscriberOnAcquired, onSecondAcquiredCallBack); + }); + + console.log(`FMS_notifyVisibleForms_1600 featureAbility.startAbility serviceb start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "Form_Js001", + "bundle" : "com.form.formsystemtestserviceb.hmservice", + "ability" : "com.form.formsystemtestserviceb.hmservice.FormAbility", + "moduleName" : "entry", + "temporary" : false, + "isCreate" : true + } + } + }).then((res: any) => { + console.log(`FMS_notifyVisibleForms_1600 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_notifyVisibleForms_1600 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_notifyVisibleForms_1600 featureAbility.startAbility serviceb end`); + } + + commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => { + console.debug("====>FMS_notifyVisibleForms_1600 onAcquiredForm_Event Subscriber====>"); + subscriberOnAcquired = data; + await commonEvent.subscribe(subscriberOnAcquired, onFirstAcquiredCallBack); + }); + console.log(`FMS_notifyVisibleForms_1600 featureAbility.startAbility servicea start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "Form_Js001", + "bundle" : "com.form.formsystemtestservicea.hmservice", + "ability" : "com.form.formsystemtestservicea.hmservice.FormAbility", + "moduleName" : "entry", + "temporary" : false, + "isCreate" : true + } + } + }).then((res: any) => { + console.log(`FMS_notifyVisibleForms_1600 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_notifyVisibleForms_1600 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_notifyVisibleForms_1600 featureAbility.startAbility servicea end`); + }); + + /** + * @tc.number: FMS_notifyVisibleForms_1700 + * @tc.name: Use -1 and created form card Id notify the form to be visible. + * @tc.desc: 1.The form user calls the visible notification interface. + * 2.Verify the result of the visible notification interface. + */ + it(`FMS_notifyVisibleForms_1700`, 0, async (done) => { + console.log(`FMS_notifyVisibleForms_1700 start`); + let subscriberVisible; + let subscriberSupply; + + function unSubscribeSupplyCallback() { + console.debug("====>FMS_notifyVisibleForms_1700 unSubscribeSupplyCallback====>"); + } + + function delPublishCallBack(err, data) { + console.info("!!!====>FMS_notifyVisibleForms_1700 delPublishCallBack====>" + JSON.stringify(data)); + setTimeout(function () { + console.info('FMS_notifyVisibleForms_1700 delPublishCallBack end'); + console.log(`FMS_notifyVisibleForms_1700 end`); + done(); + }, 1000); + } + + function onFormVisibleCallBack(err, data) { + expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); + commonEvent.unsubscribe(subscriberVisible, unSubscribeSupplyCallback); + console.debug("====>FMS_notifyVisibleForms_1700 onFirstAcquiredCallBack====>" + JSON.stringify(data)); + expect(data.parameters.kind).assertEqual("visible"); + expect(data.data).assertEqual("0"); + + setTimeout(function () { + let commonEventPublishData = { + data: data.parameters.formId + }; + commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); + }, 2000); + } + + function onFormSupplyCallBack(err, data) { + expect(data.event).assertEqual("FMS_FormSupply_commonEvent"); + commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback); + console.debug("====>FMS_notifyVisibleForms_1700 onFormSupplyCallBack====>" + JSON.stringify(data)); + if (data.parameters.kind == "onVisibilityChange") { + console.debug("====>FMS_notifyVisibleForms_1700 error"); + expect().assertFail(); + } + } + + commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { + console.debug("====>FMS_notifyVisibleForms_1700 onStateFormEvent Subscriber====>"); + subscriberVisible = data; + await commonEvent.subscribe(subscriberVisible, onFormVisibleCallBack); + }); + + commonEvent.createSubscriber(onSupplyEvent).then(async (data) => { + console.debug("====>FMS_notifyVisibleForms_1700 onStateFormEvent Subscriber====>"); + subscriberSupply = data; + await commonEvent.subscribe(subscriberSupply, onFormSupplyCallBack); + }); + + console.log(`FMS_notifyVisibleForms_1700 featureAbility.startAbility servicea start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostf", + abilityName: "com.ohos.st.formsystemhostf.MainAbility", + parameters: { + "formId" : "0", + "name" : "Form_Js001", + "bundle" : "com.form.formsystemtestservicea.hmservice", + "ability" : "com.form.formsystemtestservicea.hmservice.FormAbility", + "moduleName" : "entry", + "temporary" : false, + "isCreate" : true, + "isStartOtherApp" : true, + "otherAppState" : "visible" + } + } + }).then((res: any) => { + console.log(`FMS_notifyVisibleForms_1700 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_notifyVisibleForms_1700 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_notifyVisibleForms_1700 featureAbility.startAbility servicea end`); + }); + + /** + * @tc.number: FMS_notifyVisibleForms_1800 + * @tc.name: When formVisibleNotify is true in config.json, + * the form provider will be pulled when the card is visible. + * @tc.desc: 1.The form user calls the visible notification interface. + * 2.Verify the result of the visible notification interface. + */ + it(`FMS_notifyVisibleForms_1800`, 0, async (done) => { + console.info(`FMS_notifyVisibleForms_1800 start`); + let subscriberVisible; + let subscriberSupply; + let hostFormId; + let providerFormId; + let counter = 0; + + const delPublishCallback = (err, data) => { + console.info("!!!====>FMS_notifyVisibleForms_1800 delPublishCallback====>"); + setTimeout(() => { + expect(hostFormId).assertEqual(providerFormId); + console.info('FMS_notifyVisibleForms_1800 delPublishCallback end'); + console.info(`FMS_notifyVisibleForms_1800 end`); + done(); + }, 1000); + } + + const onSupplyCallback = (err, data) => { + if (data.parameters.kind != "onVisibilityChange") { + return; + } + console.debug("====>FMS_notifyVisibleForms_1800 onSupplyCallback data:====>" + JSON.stringify(data)); + providerFormId = Object.keys(JSON.parse(data.parameters.parameters))[0]; + const visibilityStatus = JSON.parse(data.parameters.parameters)[providerFormId]; + + expect(visibilityStatus).assertEqual(1); + commonEvent.unsubscribe(subscriberSupply, () => { + console.info("====>FMS_notifyVisibleForms_1800 unSubscribeSupplyCallback====>"); + }); + if (++counter == 2) { + const commonEventPublishData = { + data: providerFormId + }; + commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallback); + } + } + + const onVisibleCallback = (err, data) => { + if (data.parameters.kind != "visible") { + return; + } + console.debug("====>FMS_notifyVisibleForms_1800 onVisibleCallback data:====>" + JSON.stringify(data)); + hostFormId = data.parameters.formId; + + expect(data.data).assertEqual("0"); + commonEvent.unsubscribe(subscriberVisible, () => { + console.info("====>FMS_notifyVisibleForms_1800 unSubscribeOnVisibleCallback====>"); + }); + if (++counter == 2) { + const commonEventPublishData = { + data: hostFormId + }; + commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallback); + } + } + + commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { + console.info("====>FMS_notifyVisibleForms_1800 onStateFormEvent Visible Subscriber====>"); + subscriberVisible = data; + await commonEvent.subscribe(subscriberVisible, onVisibleCallback); + }); + commonEvent.createSubscriber(onSupplyEvent).then(async (data) => { + console.info("====>FMS_notifyVisibleForms_1800 onSupplyEvent Subscriber====>"); + subscriberSupply = data; + await commonEvent.subscribe(subscriberSupply, onSupplyCallback); + }); + + console.info(`FMS_notifyVisibleForms_1800 featureAbility.startAbility start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId": "0", + "name": "Form_Js001", + "bundle": "com.form.formsystemtestservicef.hmservice", + "ability": "com.form.formsystemtestservicef.hmservice.FormAbility", + "moduleName": "entry", + "temporary": false, + "stateForm": "visible", + "stateIds": ["self"], + "isCreate": true + } + } + }).then((res: any) => { + console.debug(`FMS_notifyVisibleForms_1800 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.debug(`FMS_notifyVisibleForms_1800 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + }); + /** + * @tc.number: FMS_notifyVisibleForms_1900 + * @tc.name: The size of visible form ids in the notification form array exceeds 32. + * @tc.desc: 1. Failed to invoke the visibility interface (parameter error). + */ + it(`FMS_notifyVisibleForms_1900`, 0, async (done) => { + console.log(`FMS_notifyVisibleForms_1900 start`); + let subscriberOnState; + let formId; + function onStateCallBack(err, data) { + console.info("!!!====>FMS_notifyVisibleForms_1900 onStateCallBack data:====>" + JSON.stringify(data)); + expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); + expect(data.data != "0").assertEqual(true); + commonEvent.unsubscribe(subscriberOnState, unSubscribeOnStateCallback) + + setTimeout(function () { + console.info('FMS_notifyVisibleForms_1900 delPublishCallBack end'); + console.log(`FMS_notifyVisibleForms_1900 end`); + done(); + }, 100); + } + function unSubscribeOnStateCallback() { + console.debug("====>FMS_notifyVisibleForms_1900 unSubscribeOnStateCallback CallBack====>"); + } + + commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { + console.debug("====>FMS_notifyVisibleForms_1900 onStateFormEvent Subscriber====>"); + subscriberOnState = data; + await commonEvent.subscribe(subscriberOnState, onStateCallBack); + }); + console.log(`FMS_notifyVisibleForms_1900 featureAbility.startAbility start`); + await featureAbility.startAbility({ + want: { + bundleName: "com.ohos.st.formsystemhostg", + abilityName: "com.ohos.st.formsystemhostg.MainAbility", + parameters: { + "formId" : "0", + "name" : "Form_Js001", + "bundle" : "com.form.formsystemtestservicea.hmservice", + "ability" : "com.form.formsystemtestservicea.hmservice.FormAbility", + "moduleName" : "entry", + "temporary" : false, + "stateForm" : "visible", + "stateIds" : [ + "1","2","3","4","5","6","7","8","9","10","11","12","13","14", + "15","16","17","18","19","20","21","22","23","24","25","26", + "27","28","29","30","31","32","33" + ], + "isCreate" : false + } + } + }).then((res: any) => { + console.log(`FMS_notifyVisibleForms_1900 featureAbility.startAbilityhost res: ${JSON.stringify(res)}`); + }).catch((err: any) => { + console.log(`FMS_notifyVisibleForms_1900 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); + }); + console.log(`FMS_notifyVisibleForms_1900 featureAbility.startAbility end`); + }); + }); +} diff --git a/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/ets/MainAbility/test/List.test.ets b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/ets/MainAbility/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..b460da51fb9f2a3aae604d8f4daf384e8ac1b379 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/ets/MainAbility/test/List.test.ets @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import test from './FmsFormStateNotifyVisible.test.ets'; + +export default function testsuite() { + test(); +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..708abba6f8b1c683196824cb151e76550121524c --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "formvisiblestatetest" + }, + { + "name": "description_mainability", + "value": "ETS_Empty Ability" + } + ] +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyvisible/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyvisible/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formsystemtest_ets/formstatetest_notifyvisible/signature/openharmony_sx.p7b differ