diff --git a/ability/ability_runtime/formmanager/BUILD.gn b/ability/ability_runtime/formmanager/BUILD.gn index 55074a49c81eeb9393d99d9c839ff90284c81594..a1e24c1a084c17bf6e323a8a9ca817785cf391fb 100644 --- a/ability/ability_runtime/formmanager/BUILD.gn +++ b/ability/ability_runtime/formmanager/BUILD.gn @@ -16,6 +16,9 @@ import("//test/xts/tools/build/suite.gni") group("formmanager") { testonly = true if (is_standard_system) { - deps = [ "fa:formmanager" ] + deps = [ + "fa:formmanager", + "stage:stage" + ] } } diff --git a/ability/ability_runtime/formmanager/stage/BUILD.gn b/ability/ability_runtime/formmanager/stage/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..d056fa5be31d30f22689f49e28874dbf92af81bf --- /dev/null +++ b/ability/ability_runtime/formmanager/stage/BUILD.gn @@ -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. + +import("//test/xts/tools/build/suite.gni") + +group("stage") { + testonly = true + if (is_standard_system) { + deps = [ + "actsformprovidergetformsinfo:actsformprovidergetformsinfo", + ] + } +} diff --git a/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/AppScope/app.json b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..e9769c6c80e7ad01006f5e1825dff57caeffe0ce --- /dev/null +++ b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/AppScope/app.json @@ -0,0 +1,20 @@ +{ + "app": { + "bundleName": "com.example.getformsinfotest", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "debug": false, + "icon": "$media:app_icon", + "label": "$string:app_name", + "distributedNotificationEnabled": true, + "keepAlive": true, + "singleUser": true, + "minAPIVersion": 9, + "targetAPIVersion": 9, + "car": { + "apiCompatibleVersion": 9, + "singleUser": false + } + } +} diff --git a/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/AppScope/resources/base/element/string.json b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..ac5664ba0d684140ecdccc3f329814071131d247 --- /dev/null +++ b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "GetFormsInfoTest" + } + ] +} diff --git a/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/AppScope/resources/base/media/app_icon.png b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/AppScope/resources/base/media/app_icon.png differ diff --git a/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/BUILD.gn b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..f07159f051916985a24ef03b076914b1fafb703e --- /dev/null +++ b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/BUILD.gn @@ -0,0 +1,25 @@ +# 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") + +group("actsformprovidergetformsinfo") { + testonly = true + if (is_standard_system) { + deps = [ + "entry:ActsFormProviderGetFormsInfoTest", + "module1:ActsFormProviderGetFormsInfoModule1", + "module2:ActsFormProviderGetFormsInfoModule2" + ] + } +} diff --git a/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/entry/BUILD.gn b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/entry/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..1035e5deb46c1470c49714288c3cd53cdba07772 --- /dev/null +++ b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/entry/BUILD.gn @@ -0,0 +1,40 @@ +# 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("ActsFormProviderGetFormsInfoTest") { + hap_profile = "src/main/module.json" + deps = [ + ":actsformprovidergetformsinfotest_js_assets", + ":actsformprovidergetformsinfotest_resources", + ] + certificate_profile = "../signature/openharmony_sx.p7b" + hap_name = "ActsFormProviderGetFormsInfoTest" +} + +ohos_app_scope("actsformprovidergetformsinfotest_app_profile") { + app_profile = "../AppScope/app.json" + sources = [ "../AppScope/resources" ] +} + +ohos_js_assets("actsformprovidergetformsinfotest_js_assets") { + ets2abc = true + source_dir = "src/main/ets" +} + +ohos_resources("actsformprovidergetformsinfotest_resources") { + sources = [ "src/main/resources" ] + deps = [ ":actsformprovidergetformsinfotest_app_profile" ] + hap_profile = "src/main/module.json" +} diff --git a/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/entry/Test.json b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/entry/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..6503a2cd3caf33ef4686d0efe2a16a4ea1586515 --- /dev/null +++ b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/entry/Test.json @@ -0,0 +1,20 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "180000", + "package": "com.example.getformsinfotest", + "shell-timeout": "600000" + }, + "kits": [ + { + "test-file-name": [ + "ActsFormProviderGetFormsInfoTest.hap", + "ActsFormProviderGetFormsInfoModule1.hap", + "ActsFormProviderGetFormsInfoModule2.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} diff --git a/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/entry/src/main/ets/Application/AbilityStage.ts b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..6ceb0c290ae831a45143a5e2b42d4351f2fc3d7e --- /dev/null +++ b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/entry/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import AbilityStage from "@ohos.application.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("[Demo] MyAbilityStage onCreate") + } +} \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..92e4e8922723c781776d205b211d999c61e96725 --- /dev/null +++ b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import Ability from '@ohos.application.Ability' + +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + console.log("[Demo] MainAbility onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + console.log("[Demo] MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("[Demo] MainAbility onWindowStageCreate") + + windowStage.setUIContent(this.context, "pages/index", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("[Demo] MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("[Demo] MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("[Demo] MainAbility onBackground") + } +}; diff --git a/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/entry/src/main/ets/pages/index.ets b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/entry/src/main/ets/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..20b5fbfd6ab842ac1a73152fe59d4f20010af359 --- /dev/null +++ b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/entry/src/main/ets/pages/index.ets @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import file from '@system.file'; +import { Core, ExpectExtend, InstrumentLog, ReportExtend } from "deccjsunit/index" +import List from '../test/List.test' + +@Entry +@Component +struct Index { + @State message: string = 'Hello World' + + aboutToAppear() { + console.info("start run testcase!!!!") + 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() + globalThis.abilityWant.parameters.timeout = 10000; + core.subscribeEvent('task', reportExtend) + const configService = core.getDefaultService('config') + configService.setConfig(globalThis.abilityWant.parameters); + List() + core.execute() + } + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/entry/src/main/ets/test/GetFormsInfoTest.test.ets b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/entry/src/main/ets/test/GetFormsInfoTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..1dd8ff6fd4af6730b8d6af4ff07e387b0a26c164 --- /dev/null +++ b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/entry/src/main/ets/test/GetFormsInfoTest.test.ets @@ -0,0 +1,404 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'hypium/index' +import formProvider from '@ohos.application.formProvider'; +import formInfo from '@ohos.application.formInfo'; +import formError from '@ohos.application.formError'; + +let module1FormInfo: formInfo.FormInfo = { + bundleName: "com.example.getformsinfotest", + moduleName: "module1", + abilityName: "FormAbility", + name: "module1_widget", + description: "This is a service widget.", + type:1, + jsComponentName: "", + colorMode: -1, + isDefault: true, + updateEnabled: true, + formVisibleNotify: true, + relatedBundleName : "com.example.getformsinfotest", + scheduledUpdateTime: "10:30", + formConfigAbility: "ability://xxxxx", + updateDuration: 1, + defaultDimension:2, + supportDimensions:[2], + customizeData: {} +} + +let module2FormInfo: formInfo.FormInfo = { + bundleName: "com.example.getformsinfotest", + moduleName: "module2", + abilityName: "FormAbility", + name: "module2_widget", + description: "This is a service widget.", + type:1, + jsComponentName: "", + colorMode: -1, + isDefault: true, + updateEnabled: true, + formVisibleNotify: true, + relatedBundleName : "com.example.getformsinfotest", + scheduledUpdateTime: "10:30", + formConfigAbility: "ability://xxxxx", + updateDuration: 1, + defaultDimension:2, + supportDimensions:[2], + customizeData: {} +} + +var expectResult = Array(); +expectResult.push(module1FormInfo); +expectResult.push(module2FormInfo); + +export default function abilityTest() { + describe('ProviderGetFormsInfoTest', function () { + /** + * @tc.number: SUB_AA_OpenHarmony_ProviderGetForsInfo_0100 + * @tc.name: SUB_AA_OpenHarmony_ProviderGetForsInfo_0100 + * @tc.desc: #1: getFormsInfo(callback) + */ + it('SUB_AA_OpenHarmony_ProviderGetForsInfo_0100', 0, async function (done) { + console.info("SUB_AA_OpenHarmony_ProviderGetForsInfo_0100"); + formProvider.getFormsInfo((err, value) => { + console.info("formProvider::GetFormsInfoTest err: " + JSON.stringify(err)); + console.info("formProvider::GetFormsInfoTest value: " + JSON.stringify(value)); + expect(err.code).assertEqual(0); + expect(value.length).assertEqual(2); + checkResultArray(expectResult, value) + done(); + }); + }); + + /** + * @tc.number: SUB_AA_OpenHarmony_ProviderGetForsInfo_0200 + * @tc.name: SUB_AA_OpenHarmony_ProviderGetForsInfo_0200 + * @tc.desc: #2 getFormsInfo(filter, undefined) # Have no idea how to test it. + */ + it('SUB_AA_OpenHarmony_ProviderGetForsInfo_0200', 0, async function (done) { + console.info("SUB_AA_OpenHarmony_ProviderGetForsInfo_0200"); + const filter : formInfo.FormInfoFilter = { + moduleName : "module1" + }; + try { + formProvider.getFormsInfo(filter, undefined); + } catch(err) { + expect().assertFail(); + } + done(); + }); + + /** + * @tc.number: SUB_AA_OpenHarmony_ProviderGetForsInfo_0300 + * @tc.name: SUB_AA_OpenHarmony_ProviderGetForsInfo_0300 + * @tc.desc: #3 getFormsInfo() + */ + it('SUB_AA_OpenHarmony_ProviderGetForsInfo_0300', 0, async function (done) { + console.info("SUB_AA_OpenHarmony_ProviderGetForsInfo_0300"); + formProvider.getFormsInfo().then((value) => { + expect(value.length).assertEqual(2); + checkResultArray(expectResult, value); + }).catch((err) => { + console.info('formProvider::GetFormsInfoTest failed' + JSON.stringify(err)); + expect().assertFail(); + }) + done(); + }); + + /** + * @tc.number: SUB_AA_OpenHarmony_ProviderGetForsInfo_0400 + * @tc.name: SUB_AA_OpenHarmony_ProviderGetForsInfo_0400 + * @tc.desc: #4 getFormsInfo(undefined, callback) + */ + it('SUB_AA_OpenHarmony_ProviderGetForsInfo_0400', 0, async function (done) { + console.info("SUB_AA_OpenHarmony_ProviderGetForsInfo_0400"); + formProvider.getFormsInfo(undefined, function(err, value) { + console.info("formProvider::GetFormsInfoTest err: " + JSON.stringify(err)); + console.info("formProvider::GetFormsInfoTest value: " + JSON.stringify(value)); + expect(err.code).assertEqual(formError.FormError.ERR_ADD_INVALID_PARAM); + done(); + }); + }); + + /** + * @tc.number: SUB_AA_OpenHarmony_ProviderGetForsInfo_0500 + * @tc.name: SUB_AA_OpenHarmony_ProviderGetForsInfo_0500 + * @tc.desc: #5 getFormsInfo(filter, callback) where filter = {} + */ + it('SUB_AA_OpenHarmony_ProviderGetForsInfo_0500', 0, async function (done) { + console.info("SUB_AA_OpenHarmony_getFormsInfo_0105"); + const filter : formInfo.FormInfoFilter = {}; + formProvider.getFormsInfo(filter, function(err, value) { + console.info("formProvider::GetFormsInfoTest: " + JSON.stringify(err)); + console.info("formProvider::GetFormsInfoTest: " + JSON.stringify(value)); + expect(err.code).assertEqual(0); + expect(value.length).assertEqual(2); + checkResultArray(expectResult, value); + done(); + }); + }); + + /** + * @tc.number: SUB_AA_OpenHarmony_ProviderGetForsInfo_0600 + * @tc.name: SUB_AA_OpenHarmony_ProviderGetForsInfo_0600 + * @tc.desc: #6 getFormsInfo(filter, callback) where moduleName = "" + */ + it('SUB_AA_OpenHarmony_ProviderGetForsInfo_0600', 0, async function (done) { + console.info("SUB_AA_OpenHarmony_ProviderGetForsInfo_0600"); + const filter : formInfo.FormInfoFilter = { + moduleName: "" + }; + formProvider.getFormsInfo(filter, function(err, value) { + console.info("formProvider::GetFormsInfoTest err: " + JSON.stringify(err)); + console.info("formProvider::GetFormsInfoTest value: " + JSON.stringify(value)); + expect(err.code).assertEqual(0); + expect(value.length).assertEqual(2); + checkResultArray(expectResult, value); + done(); + }); + }); + + /** + * @tc.number: SUB_AA_OpenHarmony_ProviderGetForsInfo_0700 + * @tc.name: SUB_AA_OpenHarmony_ProviderGetForsInfo_0700 + * @tc.desc: #7 getFormsInfo(filter, callback) where moduleName = undefined + */ + it('SUB_AA_OpenHarmony_ProviderGetForsInfo_0700', 0, async function (done) { + console.info("SUB_AA_OpenHarmony_ProviderGetForsInfo_0700"); + const filter : formInfo.FormInfoFilter = { + moduleName: undefined + }; + formProvider.getFormsInfo(filter, function(err, value) { + console.info("formProvider::GetFormsInfoTest err: " + JSON.stringify(err)); + console.info("formProvider::GetFormsInfoTest value: " + JSON.stringify(value)); + expect(err.code).assertEqual(formError.FormError.ERR_ADD_INVALID_PARAM); + done(); + }); + }); + + /** + * @tc.number: SUB_AA_OpenHarmony_ProviderGetForsInfo_0800 + * @tc.name: SUB_AA_OpenHarmony_ProviderGetForsInfo_0800 + * @tc.desc: #8 getFormsInfo(filter, callback) where moduleName = "HelloWorld" which doesn't exist + */ + it('SUB_AA_OpenHarmony_ProviderGetForsInfo_0800', 0, async function (done) { + console.info("SUB_AA_OpenHarmony_ProviderGetForsInfo_0800"); + const filter : formInfo.FormInfoFilter = { + moduleName: "HelloWorld" + }; + formProvider.getFormsInfo(filter, function(err, value) { + console.info("formProvider::GetFormsInfoTest err: " + JSON.stringify(err)); + console.info("formProvider::GetFormsInfoTest value: " + JSON.stringify(value)); + expect(err.code).assertEqual(0); + expect(value.length).assertEqual(0); + done(); + }); + }); + + /** + * @tc.number: SUB_AA_OpenHarmony_ProviderGetForsInfo_0900 + * @tc.name: SUB_AA_OpenHarmony_ProviderGetForsInfo_0900 + * @tc.desc: #9 getFormsInfo(filter, callback) where moduleName = "module1" which does exist + */ + it('SUB_AA_OpenHarmony_ProviderGetForsInfo_0900', 0, async function (done) { + console.info("SUB_AA_OpenHarmony_ProviderGetForsInfo_0900"); + const filter : formInfo.FormInfoFilter = { + moduleName: "module1" + }; + formProvider.getFormsInfo(filter, function(err, value) { + console.info("formProvider::GetFormsInfoTest err: " + JSON.stringify(err)); + console.info("formProvider::GetFormsInfoTest value: " + JSON.stringify(value)); + expect(err.code).assertEqual(0); + expect(value.length).assertEqual(1); + checkResult(module1FormInfo, value[0]); + done(); + }); + }); + /** + * @tc.number: SUB_AA_OpenHarmony_ProviderGetForsInfo_1000 + * @tc.name: SUB_AA_OpenHarmony_ProviderGetForsInfo_1000 + * @tc.desc: #10 getFormsInfo(filter, callback) where moduleName = "entry" exists but has no forms. + */ + it('SUB_AA_OpenHarmony_ProviderGetForsInfo_1000', 0, async function (done) { + console.info("SUB_AA_OpenHarmony_ProviderGetForsInfo_1000"); + const filter : formInfo.FormInfoFilter = { + moduleName: "entry" + }; + formProvider.getFormsInfo(filter, function(err, value) { + console.info("formProvider::GetFormsInfoTest err: " + JSON.stringify(err)); + console.info("formProvider::GetFormsInfoTest value: " + JSON.stringify(value)); + expect(err.code).assertEqual(0); + expect(value.length).assertEqual(0); + done(); + }); + }); + + /** + * @tc.number: SUB_AA_OpenHarmony_ProviderGetForsInfo_1200 + * @tc.name: SUB_AA_OpenHarmony_ProviderGetForsInfo_1200 + * @tc.desc: #12 getFormsInfo(filter) where filter = {} + */ + it('SUB_AA_OpenHarmony_ProviderGetForsInfo_1200', 0, async function (done) { + console.info("SUB_AA_OpenHarmony_ProviderGetForsInfo_1200"); + const filter : formInfo.FormInfoFilter = {}; + await formProvider.getFormsInfo(filter).then((value) => { + expect(value.length).assertEqual(2); + checkResultArray(expectResult, value); + }).catch((err) => { + console.info('formProvider::GetFormsInfoTest failed' + JSON.stringify(err)); + expect().assertFail(); + }) + done(); + }); + + /** + * @tc.number: SUB_AA_OpenHarmony_ProviderGetForsInfo_1300 + * @tc.name: SUB_AA_OpenHarmony_ProviderGetForsInfo_1300 + * @tc.desc: #13 getFormsInfo(filter) where moduleName = "" + */ + it('SUB_AA_OpenHarmony_ProviderGetForsInfo_1300', 0, async function (done) { + console.info("SUB_AA_OpenHarmony_ProviderGetForsInfo_1300"); + const filter : formInfo.FormInfoFilter = { + moduleName: "" + }; + await formProvider.getFormsInfo(filter).then((value) => { + expect(value.length).assertEqual(2); + checkResultArray(expectResult, value); + }).catch((err) => { + console.info('formProvider::GetFormsInfoTest failed' + JSON.stringify(err)); + expect().assertFail(); + }) + done(); + }); + + /** + * @tc.number: SUB_AA_OpenHarmony_ProviderGetForsInfo_1400 + * @tc.name: SUB_AA_OpenHarmony_ProviderGetForsInfo_1400 + * @tc.desc: #14 getFormsInfo(filter) where moduleName = undefined + */ + it('SUB_AA_OpenHarmony_ProviderGetForsInfo_1400', 0, async function (done) { + console.info("SUB_AA_OpenHarmony_ProviderGetForsInfo_1400"); + const filter : formInfo.FormInfoFilter = { + moduleName: undefined + }; + formProvider.getFormsInfo(filter).then((value) => { + expect().assertFail(); + }).catch((err) => { + console.info('formProvider::GetFormsInfoTest failed' + JSON.stringify(err)); + expect(err.code).assertEqual(formError.FormError.ERR_ADD_INVALID_PARAM); + }) + done(); + }); + + /** + * @tc.number: SUB_AA_OpenHarmony_ProviderGetForsInfo_1500 + * @tc.name: SUB_AA_OpenHarmony_ProviderGetForsInfo_1500 + * @tc.desc: #15 getFormsInfo(filter) where moduleName = "HelloWorld" which doesn't exist + */ + it('SUB_AA_OpenHarmony_ProviderGetForsInfo_1500', 0, async function (done) { + console.info("SUB_AA_OpenHarmony_ProviderGetForsInfo_1500"); + const filter : formInfo.FormInfoFilter = { + moduleName: "HelloWorld" + }; + await formProvider.getFormsInfo(filter).then((value) => { + expect(value.length).assertEqual(0); + }).catch((err) => { + console.info('formProvider::GetFormsInfoTest failed' + JSON.stringify(err)); + expect().assertFail(); + }) + done(); + }); + /** + * @tc.number: SUB_AA_OpenHarmony_ProviderGetForsInfo_1600 + * @tc.name: SUB_AA_OpenHarmony_ProviderGetForsInfo_1600 + * @tc.desc: #16 getFormsInfo(filter) where moduleName = "module1" which does exist + */ + it('SUB_AA_OpenHarmony_ProviderGetForsInfo_1600', 0, async function (done) { + console.info("SUB_AA_OpenHarmony_ProviderGetForsInfo_1600"); + const filter : formInfo.FormInfoFilter = { + moduleName: "module1" + }; + await formProvider.getFormsInfo(filter).then((value) => { + expect(value.length).assertEqual(1); + checkResult(module1FormInfo, value[0]) + }).catch((err) => { + console.info('formProvider::GetFormsInfoTest failed' + JSON.stringify(err)); + expect().assertFail(); + }) + done(); + }); + /** + * @tc.number: SUB_AA_OpenHarmony_ProviderGetForsInfo_1700 + * @tc.name: SUB_AA_OpenHarmony_ProviderGetForsInfo_1700 + * @tc.desc: #17 getFormsInfo(filter) where moduleName = "entry" which exists but has no forms + */ + it('SUB_AA_OpenHarmony_ProviderGetForsInfo_1700', 0, async function (done) { + console.info("SUB_AA_OpenHarmony_ProviderGetForsInfo_1700"); + const filter : formInfo.FormInfoFilter = { + moduleName: "entry" + }; + formProvider.getFormsInfo(filter).then((value) => { + expect(value.length).assertEqual(0); + }).catch((err) => { + console.info('formProvider::GetFormsInfoTest failed' + JSON.stringify(err)); + expect().assertFail(); + }) + done(); + }); + }) + + function checkResultArray(expectInfos: Array, result:Array) { + console.info("formProvider::GetForsInfoTest checkResultArray"); + for (var index = 0; index < expectInfos.length; index++) { + console.info("formProvider::GetForsInfoTest checkResul index is " + index); + checkResult(expectInfos[index], result[index]) + } + } + + function checkResult(expectInfo: formInfo.FormInfo, result: formInfo.FormInfo) { + console.info("formProvider::GetFormsInfoTest: bundleName expect " + expectInfo.bundleName); + expect(expectInfo.bundleName).assertEqual(result.bundleName); + console.info("formProvider::GetFormsInfoTest: abilityName expect " + expectInfo.abilityName); + expect(expectInfo.abilityName).assertEqual(result.abilityName); + console.info("formProvider::GetFormsInfoTest: name expect " + expectInfo.name); + expect(expectInfo.name).assertEqual(result.name); + console.info("formProvider::GetFormsInfoTest: description expect " + expectInfo.description); + expect(expectInfo.description).assertEqual(result.description); + console.info("formProvider::GetFormsInfoTest: type expect " + expectInfo.type); + expect(expectInfo.type).assertEqual(result.type); + console.info("formProvider::GetFormsInfoTest: jsComponentName expect " + expectInfo.jsComponentName); + expect(expectInfo.jsComponentName).assertEqual(result.jsComponentName); + console.info("formProvider::GetFormsInfoTest: colorMode expect " + expectInfo.colorMode); + expect(expectInfo.colorMode).assertEqual(result.colorMode); + console.info("formProvider::GetFormsInfoTest: isDefault expect " + expectInfo.isDefault); + expect(expectInfo.isDefault).assertEqual(result.isDefault); + console.info("formProvider::GetFormsInfoTest: formVisibleNotify expect " + expectInfo.formVisibleNotify); + expect(expectInfo.formVisibleNotify).assertEqual(result.formVisibleNotify); + console.info("formProvider::GetFormsInfoTest: relatedBundleName expect " + expectInfo.relatedBundleName); + expect(expectInfo.relatedBundleName).assertEqual(result.relatedBundleName); + console.info("formProvider::GetFormsInfoTest: scheduledUpdateTime expect " + expectInfo.scheduledUpdateTime); + expect(expectInfo.scheduledUpdateTime).assertEqual(result.scheduledUpdateTime); + console.info("formProvider::GetFormsInfoTest: formConfigAbility expect " + expectInfo.formConfigAbility); + expect(expectInfo.formConfigAbility).assertEqual(result.formConfigAbility); + console.info("formProvider::GetFormsInfoTest: updateDuration expect " + expectInfo.updateDuration); + expect(expectInfo.updateDuration).assertEqual(result.updateDuration); + console.info("formProvider::GetFormsInfoTest: defaultDimension expect " + expectInfo.defaultDimension); + expect(expectInfo.defaultDimension).assertEqual(result.defaultDimension); + console.info("formProvider::GetFormsInfoTest: supportDimensions expect " + JSON.stringify(expectInfo.supportDimensions)); + expect(JSON.stringify(expectInfo.supportDimensions)).assertEqual(JSON.stringify(result.supportDimensions)); + console.info("formProvider::GetFormsInfoTest: customizeData expect " + JSON.stringify(expectInfo.customizeData)); + expect(JSON.stringify(expectInfo.customizeData)).assertEqual(JSON.stringify(result.customizeData)); + } +} \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/entry/src/main/ets/test/List.test.ets b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/entry/src/main/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..c30653241c90e033e05413170a6756cf4c46e68a --- /dev/null +++ b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/entry/src/main/ets/test/List.test.ets @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import getFormsInfoTest from './GetFormsInfoTest.test' + +export default function testsuite() { + getFormsInfoTest() +} \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/entry/src/main/module.json b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..4e4edfed85bdc47418e18ccd4d35b889376248cb --- /dev/null +++ b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/entry/src/main/module.json @@ -0,0 +1,38 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:entry_desc", + "mainElement": "MainAbility", + "deviceTypes": [ + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "uiSyntax": "ets", + "abilities": [ + { + "name": "com.example.getformsinfotest.MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:MainAbility_desc", + "icon": "$media:icon", + "label": "$string:MainAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:white", + "visible": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ] + } +} \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/entry/src/main/resources/base/element/color.json b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..1bbc9aa9617e97c45440e1d3d66afc1154837012 --- /dev/null +++ b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "white", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..490210a3908f47722dc942d49dacc98b97669a5f --- /dev/null +++ b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "entry_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/entry/src/main/resources/base/profile/main_pages.json b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..feec276e105eeb8d621c20aaf838f318b0a94150 --- /dev/null +++ b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/index" + ] +} diff --git a/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module1/BUILD.gn b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module1/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..c65abb0e3bc5de32e4f9f5805ac1b245c3c5e5c6 --- /dev/null +++ b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module1/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_hap("ActsFormProviderGetFormsInfoModule1") { + hap_name = "ActsFormProviderGetFormsInfoModule1" + hap_profile = "src/main/module.json" + subsystem_name = XTS_SUITENAME + final_hap_path = + "${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/testcases/${hap_name}.hap" + testonly = true + deps = [ + ":actsformprovidergetformsinfomodule1_js_assets", + ":actsformprovidergetformsinfomodule1_resources", + ] + ets2abc = true + certificate_profile = "../signature/openharmony_sx.p7b" +} + +ohos_app_scope("actsformprovidergetformsinfomodule1_app_profile") { + app_profile = "../AppScope/app.json" + sources = [ "../AppScope/resources" ] +} + +ohos_js_assets("actsformprovidergetformsinfomodule1_js_assets") { + source_dir = "src/main/ets" +} + +ohos_resources("actsformprovidergetformsinfomodule1_resources") { + sources = [ "src/main/resources" ] + deps = [ ":actsformprovidergetformsinfomodule1_app_profile" ] + hap_profile = "src/main/module.json" +} diff --git a/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module1/src/main/ets/Application/AbilityStage.ts b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module1/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..6ceb0c290ae831a45143a5e2b42d4351f2fc3d7e --- /dev/null +++ b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module1/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import AbilityStage from "@ohos.application.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("[Demo] MyAbilityStage onCreate") + } +} \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module1/src/main/ets/FormAbility/FormAbility.ts b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module1/src/main/ets/FormAbility/FormAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..2748635acfe5697f7a153fc0e98ea255714c84c7 --- /dev/null +++ b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module1/src/main/ets/FormAbility/FormAbility.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import FormExtension from '@ohos.application.FormExtension'; +import formBindingData from '@ohos.application.formBindingData'; +import formInfo from '@ohos.application.formInfo'; + +export default class FormAbility extends FormExtension { + onCreate(want) { + // Called to return a FormBindingData object. + let formData = {}; + return formBindingData.createFormBindingData(formData); + } + + onCastToNormal(formId) { + // Called when the form provider is notified that a temporary form is successfully + // converted to a normal form. + } + + onUpdate(formId) { + // Called to notify the form provider to update a specified form. + } + + onVisibilityChange(newStatus) { + // Called when the form provider receives form events from the system. + } + + onEvent(formId, message) { + // Called when a specified message event defined by the form provider is triggered. + } + + onDestroy(formId) { + // Called to notify the form provider that a specified form has been destroyed. + } + + onAcquireFormState(want) { + // Called to return a {@link FormState} object. + return formInfo.FormState.READY; + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module1/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module1/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..92e4e8922723c781776d205b211d999c61e96725 --- /dev/null +++ b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module1/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import Ability from '@ohos.application.Ability' + +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + console.log("[Demo] MainAbility onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + console.log("[Demo] MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("[Demo] MainAbility onWindowStageCreate") + + windowStage.setUIContent(this.context, "pages/index", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("[Demo] MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("[Demo] MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("[Demo] MainAbility onBackground") + } +}; diff --git a/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module1/src/main/ets/pages/index.ets b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module1/src/main/ets/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..a3361dc31925163a44aa2ed457be90de88aae2d5 --- /dev/null +++ b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module1/src/main/ets/pages/index.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct Index { + @State message: string = 'Hello World' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module1/src/main/js/module1_widget/pages/index/index.css b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module1/src/main/js/module1_widget/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..b52e9bfa91f56e9c07e00384da135250752a03cc --- /dev/null +++ b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module1/src/main/js/module1_widget/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/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module1/src/main/js/module1_widget/pages/index/index.hml b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module1/src/main/js/module1_widget/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..b01936fb18990555228d425ea5860c785862aa50 --- /dev/null +++ b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module1/src/main/js/module1_widget/pages/index/index.hml @@ -0,0 +1,7 @@ +
+
+
+ {{title}} +
+
+
\ No newline at end of file diff --git a/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module1/src/main/js/module1_widget/pages/index/index.json b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module1/src/main/js/module1_widget/pages/index/index.json new file mode 100644 index 0000000000000000000000000000000000000000..1c9e2ce993cf9193502ea0a014beb511aac12a73 --- /dev/null +++ b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module1/src/main/js/module1_widget/pages/index/index.json @@ -0,0 +1,6 @@ +{ + "actions": {}, + "data": { + "title": "Hello World" + } +} \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module1/src/main/module.json b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module1/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..eff67c9014c6839a115b47acac8826b8c3b1a6a3 --- /dev/null +++ b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module1/src/main/module.json @@ -0,0 +1,43 @@ +{ + "module": { + "name": "module1", + "type": "feature", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:module1_desc", + "mainElement": "MainAbility", + "deviceTypes": [ + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "uiSyntax": "ets", + "abilities": [ + { + "name": "MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:MainAbility_desc", + "icon": "$media:icon", + "label": "$string:MainAbility_label", + "visible": true, + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:white" + } + ], + "extensionAbilities": [ + { + "name": "FormAbility", + "srcEntrance": "./ets/FormAbility/FormAbility.ts", + "label": "$string:form_FormAbility_label", + "description": "$string:form_FormAbility_desc", + "type": "form", + "metadata": [ + { + "name": "ohos.extension.form", + "resource": "$profile:form_config" + } + ] + } + ] + } +} \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module1/src/main/resources/base/element/color.json b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module1/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..1bbc9aa9617e97c45440e1d3d66afc1154837012 --- /dev/null +++ b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module1/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "white", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module1/src/main/resources/base/element/string.json b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module1/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..6630ff50f7b9943d819fb23c7bc3d484e6876084 --- /dev/null +++ b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module1/src/main/resources/base/element/string.json @@ -0,0 +1,24 @@ +{ + "string": [ + { + "name": "module1_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "form_FormAbility_desc", + "value": "form_description" + }, + { + "name": "form_FormAbility_label", + "value": "form_label" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module1/src/main/resources/base/media/icon.png b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module1/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module1/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module1/src/main/resources/base/profile/form_config.json b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module1/src/main/resources/base/profile/form_config.json new file mode 100644 index 0000000000000000000000000000000000000000..6f59c1f9cc4522bfd7ce1e306e3540e237f8fed1 --- /dev/null +++ b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module1/src/main/resources/base/profile/form_config.json @@ -0,0 +1,24 @@ +{ + "forms": [ + { + "name": "module1_widget", + "description": "This is a service widget.", + "src": "./js/module1_widget/pages/index/index", + "window": { + "designWidth": 720, + "autoDesignWidth": true + }, + "colorMode": "auto", + "isDefault": true, + "updateEnabled": true, + "scheduledUpdateTime": "10:30", + "updateDuration": 1, + "defaultDimension": "2*2", + "supportDimensions": [ + "2*2" + ], + "formConfigAbility": "ability://xxxxx", + "formVisibleNotify":true + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module1/src/main/resources/base/profile/main_pages.json b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module1/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..feec276e105eeb8d621c20aaf838f318b0a94150 --- /dev/null +++ b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module1/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/index" + ] +} diff --git a/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module2/BUILD.gn b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module2/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..f522129fc485cb9230af41ed77b9f0b811a3a544 --- /dev/null +++ b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module2/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_hap("ActsFormProviderGetFormsInfoModule2") { + hap_name = "ActsFormProviderGetFormsInfoModule2" + hap_profile = "src/main/module.json" + subsystem_name = XTS_SUITENAME + final_hap_path = + "${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/testcases/${hap_name}.hap" + testonly = true + deps = [ + ":actsformprovidergetformsinfomodule2_js_assets", + ":actsformprovidergetformsinfomodule2_resources", + ] + ets2abc = true + certificate_profile = "../signature/openharmony_sx.p7b" +} + +ohos_app_scope("actsformprovidergetformsinfomodule2_app_profile") { + app_profile = "../AppScope/app.json" + sources = [ "../AppScope/resources" ] +} + +ohos_js_assets("actsformprovidergetformsinfomodule2_js_assets") { + source_dir = "src/main/ets" +} + +ohos_resources("actsformprovidergetformsinfomodule2_resources") { + sources = [ "src/main/resources" ] + deps = [ ":actsformprovidergetformsinfomodule2_app_profile" ] + hap_profile = "src/main/module.json" +} diff --git a/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module2/src/main/ets/Application/AbilityStage.ts b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module2/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..6ceb0c290ae831a45143a5e2b42d4351f2fc3d7e --- /dev/null +++ b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module2/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import AbilityStage from "@ohos.application.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("[Demo] MyAbilityStage onCreate") + } +} \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module2/src/main/ets/FormAbility/FormAbility.ts b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module2/src/main/ets/FormAbility/FormAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..2748635acfe5697f7a153fc0e98ea255714c84c7 --- /dev/null +++ b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module2/src/main/ets/FormAbility/FormAbility.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import FormExtension from '@ohos.application.FormExtension'; +import formBindingData from '@ohos.application.formBindingData'; +import formInfo from '@ohos.application.formInfo'; + +export default class FormAbility extends FormExtension { + onCreate(want) { + // Called to return a FormBindingData object. + let formData = {}; + return formBindingData.createFormBindingData(formData); + } + + onCastToNormal(formId) { + // Called when the form provider is notified that a temporary form is successfully + // converted to a normal form. + } + + onUpdate(formId) { + // Called to notify the form provider to update a specified form. + } + + onVisibilityChange(newStatus) { + // Called when the form provider receives form events from the system. + } + + onEvent(formId, message) { + // Called when a specified message event defined by the form provider is triggered. + } + + onDestroy(formId) { + // Called to notify the form provider that a specified form has been destroyed. + } + + onAcquireFormState(want) { + // Called to return a {@link FormState} object. + return formInfo.FormState.READY; + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module2/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module2/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..92e4e8922723c781776d205b211d999c61e96725 --- /dev/null +++ b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module2/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import Ability from '@ohos.application.Ability' + +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + console.log("[Demo] MainAbility onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + console.log("[Demo] MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("[Demo] MainAbility onWindowStageCreate") + + windowStage.setUIContent(this.context, "pages/index", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("[Demo] MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("[Demo] MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("[Demo] MainAbility onBackground") + } +}; diff --git a/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module2/src/main/ets/pages/index.ets b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module2/src/main/ets/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..a3361dc31925163a44aa2ed457be90de88aae2d5 --- /dev/null +++ b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module2/src/main/ets/pages/index.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct Index { + @State message: string = 'Hello World' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module2/src/main/js/module2widget/pages/index/index.css b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module2/src/main/js/module2widget/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..b52e9bfa91f56e9c07e00384da135250752a03cc --- /dev/null +++ b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module2/src/main/js/module2widget/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/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module2/src/main/js/module2widget/pages/index/index.hml b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module2/src/main/js/module2widget/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..b01936fb18990555228d425ea5860c785862aa50 --- /dev/null +++ b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module2/src/main/js/module2widget/pages/index/index.hml @@ -0,0 +1,7 @@ +
+
+
+ {{title}} +
+
+
\ No newline at end of file diff --git a/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module2/src/main/js/module2widget/pages/index/index.json b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module2/src/main/js/module2widget/pages/index/index.json new file mode 100644 index 0000000000000000000000000000000000000000..1c9e2ce993cf9193502ea0a014beb511aac12a73 --- /dev/null +++ b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module2/src/main/js/module2widget/pages/index/index.json @@ -0,0 +1,6 @@ +{ + "actions": {}, + "data": { + "title": "Hello World" + } +} \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module2/src/main/module.json b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module2/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..00feac3a5bc2cc319eea8cf86f4482579260e78b --- /dev/null +++ b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module2/src/main/module.json @@ -0,0 +1,43 @@ +{ + "module": { + "name": "module2", + "type": "feature", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:module2_desc", + "mainElement": "MainAbility", + "deviceTypes": [ + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "uiSyntax": "ets", + "abilities": [ + { + "name": "MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:MainAbility_desc", + "icon": "$media:icon", + "label": "$string:MainAbility_label", + "visible": true, + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:white" + } + ], + "extensionAbilities": [ + { + "name": "FormAbility", + "srcEntrance": "./ets/FormAbility/FormAbility.ts", + "label": "$string:form_FormAbility_label", + "description": "$string:form_FormAbility_desc", + "type": "form", + "metadata": [ + { + "name": "ohos.extension.form", + "resource": "$profile:form_config" + } + ] + } + ] + } +} \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module2/src/main/resources/base/element/color.json b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module2/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..1bbc9aa9617e97c45440e1d3d66afc1154837012 --- /dev/null +++ b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module2/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "white", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module2/src/main/resources/base/element/string.json b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module2/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..ac7b921d30525eb5254eac805b0d235d36a9bb19 --- /dev/null +++ b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module2/src/main/resources/base/element/string.json @@ -0,0 +1,24 @@ +{ + "string": [ + { + "name": "module2_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "form_FormAbility_desc", + "value": "form_description" + }, + { + "name": "form_FormAbility_label", + "value": "form_label" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module2/src/main/resources/base/media/icon.png b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module2/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module2/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module2/src/main/resources/base/profile/form_config.json b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module2/src/main/resources/base/profile/form_config.json new file mode 100644 index 0000000000000000000000000000000000000000..c00498c97aecd42feb344526900b7a65ccf3d419 --- /dev/null +++ b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module2/src/main/resources/base/profile/form_config.json @@ -0,0 +1,24 @@ +{ + "forms": [ + { + "name": "module2_widget", + "description": "This is a service widget.", + "src": "./js/module2widget/pages/index/index", + "window": { + "designWidth": 720, + "autoDesignWidth": true + }, + "colorMode": "auto", + "isDefault": true, + "updateEnabled": true, + "scheduledUpdateTime": "10:30", + "updateDuration": 1, + "defaultDimension": "2*2", + "supportDimensions": [ + "2*2" + ], + "formConfigAbility": "ability://xxxxx", + "formVisibleNotify":true + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module2/src/main/resources/base/profile/main_pages.json b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module2/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..feec276e105eeb8d621c20aaf838f318b0a94150 --- /dev/null +++ b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module2/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/index" + ] +} diff --git a/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/signature/openharmony_sx.p7b b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/signature/openharmony_sx.p7b differ