diff --git a/aafwk/aafwk_standard/formmanager/BUILD.gn b/aafwk/aafwk_standard/formmanager/BUILD.gn old mode 100644 new mode 100755 index 7db3d2d4e4689d8ffbababb239f4fceb95786ed7..9aec75efaf9a281fc549d391111d976c9ab44fda --- a/aafwk/aafwk_standard/formmanager/BUILD.gn +++ b/aafwk/aafwk_standard/formmanager/BUILD.gn @@ -17,6 +17,7 @@ group("formmanager") { testonly = true if (is_standard_system) { deps = [ + "formsystemtesthost/FormFuzzTest:FormFuzzTest", "formsystemtesthost/getallformsinfo:GetAllFormsInfo", "formsystemtestservice/formsystemtestservicea:ActsFormSystemTestServiceA", ] diff --git a/aafwk/aafwk_standard/formmanager/formsystemtesthost/FormFuzzTest/BUILD.gn b/aafwk/aafwk_standard/formmanager/formsystemtesthost/FormFuzzTest/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..c90113119fa64ec3e2262f0558f69481db079868 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formsystemtesthost/FormFuzzTest/BUILD.gn @@ -0,0 +1,31 @@ +# 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("FormFuzzTest") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":hjs_demo_js_assets", + ":hjs_demo_resources", + ] + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "FormFuzzTest" +} +ohos_js_assets("hjs_demo_js_assets") { + source_dir = "./entry/src/main/js/default" +} +ohos_resources("hjs_demo_resources") { + sources = [ "./entry/src/main/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/aafwk/aafwk_standard/formmanager/formsystemtesthost/FormFuzzTest/Test.json b/aafwk/aafwk_standard/formmanager/formsystemtesthost/FormFuzzTest/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..49e7fd17e4f2ee1ab0518e52e74589a56d4ee788 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formsystemtesthost/FormFuzzTest/Test.json @@ -0,0 +1,38 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "240000", + "package": "com.example.formfuzztest", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "FormFuzzTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, + { + "type": "ShellKit", + "run-command": [ + "remount", + "mkdir /system/vendor" + ] + }, + { + "type": "PushKit", + "push": [ + "FormFuzzTest.hap->/data/FormFuzzTest.hap" + ] + + }, + { + "type": "ShellKit", + "run-command": [ + "chmod 644 /system/vendor/*.hap" + ] + } + ] +} diff --git a/aafwk/aafwk_standard/formmanager/formsystemtesthost/FormFuzzTest/entry/src/main/config.json b/aafwk/aafwk_standard/formmanager/formsystemtesthost/FormFuzzTest/entry/src/main/config.json new file mode 100755 index 0000000000000000000000000000000000000000..547d41e6b81f48a282d534c46e5af6a85e7472b8 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formsystemtesthost/FormFuzzTest/entry/src/main/config.json @@ -0,0 +1,90 @@ +{ + "app": { + "bundleName": "com.example.formfuzztest", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 5, + "target": 5, + "releaseType": "Beta1" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.formfuzztest", + "name": ".MyApplication", + "mainAbility": "com.example.formfuzztest.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": "com.example.formfuzztest.MainAbility", + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "$string:entry_MainAbility", + "type": "page", + "launchType": "standard" + } + ], + "defPermissions": [ + { + "name": "com.permission.CAMERA", + "grantMode": "system_grant", + "availableScope": ["signature"], + "label": "$string:testFormA", + "description": "CAMERA permission in detail" + }, + { + "name": "ohos.permission.REQUIRE_FORM", + "grantMode": "system_grant", + "label": "$string:testForm", + "description": "REQUIRE_FORM permission in detail" + } + ], + "reqPermissions": [ + { + "name": "ohos.permission.REQUIRE_FORM", + "reason": "require form", + "usedScene": { + "ability": [ + ".MainAbility" + ], + "when": "always" + } + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": true + } + } + ] + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formsystemtesthost/FormFuzzTest/entry/src/main/js/default/app.js b/aafwk/aafwk_standard/formmanager/formsystemtesthost/FormFuzzTest/entry/src/main/js/default/app.js new file mode 100755 index 0000000000000000000000000000000000000000..4b241cccbaa71f0c5cbd9e7dc437a0feb224c7d5 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formsystemtesthost/FormFuzzTest/entry/src/main/js/default/app.js @@ -0,0 +1,22 @@ +/* + * 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('AceApplication onCreate'); + }, + onDestroy() { + console.info('AceApplication onDestroy'); + } +}; diff --git a/aafwk/aafwk_standard/formmanager/formsystemtesthost/FormFuzzTest/entry/src/main/js/default/common/images/Wallpaper.png b/aafwk/aafwk_standard/formmanager/formsystemtesthost/FormFuzzTest/entry/src/main/js/default/common/images/Wallpaper.png new file mode 100755 index 0000000000000000000000000000000000000000..60d4841a80eb20c63de74306cb7f8350d6a85c48 Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formsystemtesthost/FormFuzzTest/entry/src/main/js/default/common/images/Wallpaper.png differ diff --git a/aafwk/aafwk_standard/formmanager/formsystemtesthost/FormFuzzTest/entry/src/main/js/default/common/images/bg-tv.jpg b/aafwk/aafwk_standard/formmanager/formsystemtesthost/FormFuzzTest/entry/src/main/js/default/common/images/bg-tv.jpg new file mode 100755 index 0000000000000000000000000000000000000000..86fc07358eea5c1474bc833fca07c6d4d8698a89 Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formsystemtesthost/FormFuzzTest/entry/src/main/js/default/common/images/bg-tv.jpg differ diff --git a/aafwk/aafwk_standard/formmanager/formsystemtesthost/FormFuzzTest/entry/src/main/js/default/i18n/en-US.json b/aafwk/aafwk_standard/formmanager/formsystemtesthost/FormFuzzTest/entry/src/main/js/default/i18n/en-US.json new file mode 100755 index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formsystemtesthost/FormFuzzTest/entry/src/main/js/default/i18n/en-US.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formsystemtesthost/FormFuzzTest/entry/src/main/js/default/i18n/zh-CN.json b/aafwk/aafwk_standard/formmanager/formsystemtesthost/FormFuzzTest/entry/src/main/js/default/i18n/zh-CN.json new file mode 100755 index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formsystemtesthost/FormFuzzTest/entry/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formsystemtesthost/FormFuzzTest/entry/src/main/js/default/pages/index/index.css b/aafwk/aafwk_standard/formmanager/formsystemtesthost/FormFuzzTest/entry/src/main/js/default/pages/index/index.css new file mode 100755 index 0000000000000000000000000000000000000000..0a66102a6f5e70198f774f5fbf658e36c25cc235 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formsystemtesthost/FormFuzzTest/entry/src/main/js/default/pages/index/index.css @@ -0,0 +1,44 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 40px; + color: #000000; + opacity: 0.9; +} + +@media screen and (device-type: tablet) and (orientation: landscape) { + .title { + font-size: 100px; + } +} + +@media screen and (device-type: wearable) { + .title { + font-size: 28px; + color: #FFFFFF; + } +} + +@media screen and (device-type: tv) { + .container { + background-image: url("/common/images/Wallpaper.png"); + background-size: cover; + background-repeat: no-repeat; + background-position: center; + } + + .title { + font-size: 100px; + color: #FFFFFF; + } +} + +@media screen and (device-type: phone) and (orientation: landscape) { + .title { + font-size: 60px; + } +} diff --git a/aafwk/aafwk_standard/formmanager/formsystemtesthost/FormFuzzTest/entry/src/main/js/default/pages/index/index.hml b/aafwk/aafwk_standard/formmanager/formsystemtesthost/FormFuzzTest/entry/src/main/js/default/pages/index/index.hml new file mode 100755 index 0000000000000000000000000000000000000000..f64b040a5ae394dbaa5e185e1ecd4f4556b92184 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formsystemtesthost/FormFuzzTest/entry/src/main/js/default/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + {{ $t('strings.hello') }} {{ title }} + +
diff --git a/aafwk/aafwk_standard/formmanager/formsystemtesthost/FormFuzzTest/entry/src/main/js/default/pages/index/index.js b/aafwk/aafwk_standard/formmanager/formsystemtesthost/FormFuzzTest/entry/src/main/js/default/pages/index/index.js new file mode 100755 index 0000000000000000000000000000000000000000..e3b6a650c7607506316405b7242b92bb6ff3715e --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formsystemtesthost/FormFuzzTest/entry/src/main/js/default/pages/index/index.js @@ -0,0 +1,51 @@ +/* + * 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 app from '@system.app' +import file from '@system.file' +import router from '@system.router' +import device from '@system.device' +import {Core, ExpectExtend, ReportExtend} from 'deccjsunit/index' + +const injectRef = Object.getPrototypeOf(global) || global +injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') + +export default { + data: { + title: "" + }, + onInit() { + this.title = "FMS Fuzz Test"; + }, + onShow() { + console.info('onShow finish') + const core = Core.getInstance() + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }) + const reportExtend = new ReportExtend(file) + core.addService('expect', expectExtend) + core.addService('report', reportExtend) + core.init() + const configService = core.getDefaultService('config') + configService.setConfig(this) + + require('../../../test/List.test') + core.execute() + console.info('onShow end') + }, + onReady() { + }, +} diff --git a/aafwk/aafwk_standard/formmanager/formsystemtesthost/FormFuzzTest/entry/src/main/js/test/FormFuzzTest.test.js b/aafwk/aafwk_standard/formmanager/formsystemtesthost/FormFuzzTest/entry/src/main/js/test/FormFuzzTest.test.js new file mode 100755 index 0000000000000000000000000000000000000000..421edc06dd46d89e33411ae21d981d15ec76ec90 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formsystemtesthost/FormFuzzTest/entry/src/main/js/test/FormFuzzTest.test.js @@ -0,0 +1,505 @@ +/* + * 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' +import {parameterValue, stringTest, numberTest, booleanTest, + nullTest, undefinedTest, objectTest, arrayTest, functionTest} from './getParam.js' + +const TIMEOUT = 2000; +describe('formFuzzTest', function () { + console.log("formFuzzTest===start"); + + /** + * @tc.name fuzzTest + * @tc.number FMS_fuzzTest_0200 + * @tc.desc Check whether the deleteForm interface can pass the fuzzy test (by AsyncCallback) + */ + it('FMS_fuzzTest_0200_callback', 0, async function (done) { + console.log("FMS_fuzzTest_0200_callback deleteForm begin"); + + var formId = parameterValue(); + console.log("FMS_fuzzTest_0200_callback deleteForm formId typeof:"+ typeof(formId)); + + try{ + formManager.deleteForm( + formId, // formId: number>0 ok + (err,data) => { + console.log("FMS_fuzzTest_0200_callback async::callbak return!!!") + console.log("FMS_fuzzTest_0200_callback async::sucess data:" + data); + console.log("FMS_fuzzTest_0200_callback async::error err:" + err); + expect(err).assertEqual(1); + done(); + } + ); + } catch (e) { + console.log("FMS_fuzzTest_0200_callback Exception caught:" + e); + expect(0).assertEqual(0); + } + + console.log("FMS_fuzzTest_0200_callback deleteForm end"); + done(); + setTimeout(function () { + console.info('=====================FMS_fuzzTest_0200_callback==================end'); + }, TIMEOUT) + }) + + /** + * @tc.name fuzzTest + * @tc.number FMS_fuzzTest_0200 + * @tc.desc Check whether the deleteForm interface can pass the fuzzy test (by Promise) + */ + it('FMS_fuzzTest_0200_promise', 0, async function (done) { + console.log("FMS_fuzzTest_0200_promise deleteForm begin"); + + var formId = parameterValue(); + console.log("FMS_fuzzTest_0200_promise deleteForm formId typeof:"+ typeof(formId)); + + var retResult; + try{ + retResult = await Promise.all(await formManager.deleteForm(formId)); // formId: number>0 ok + console.log("FMS_fuzzTest_0200_promise async::sucess retResult:" + retResult); + expect(retResult).assertEqual(1); + done(); + } catch (e) { + console.log("FMS_fuzzTest_0200_promise Exception caught:" + e); + expect(0).assertEqual(0); + } + + console.log("FMS_fuzzTest_0200_promise deleteForm end"); + done(); + setTimeout(function () { + console.info('=====================FMS_fuzzTest_0200_promise==================end'); + }, TIMEOUT) + }) + + /** + * @tc.name fuzzTest + * @tc.number FMS_fuzzTest_0300 + * @tc.desc Check whether the releaseForm interface can pass the fuzzy test (by AsyncCallback) + */ + it('FMS_fuzzTest_0300_param_01_callback', 0, async function (done) { + console.log("FMS_fuzzTest_0300_param_01_callback releaseForm begin"); + + var formId = parameterValue(); + console.log("FMS_fuzzTest_0300_param_01_callback releaseForm formId typeof:"+ typeof(formId)); + + var isReleaseCache = booleanTest(); + console.log("FMS_fuzzTest_0300_param_01_callback releaseForm isReleaseCache typeof:"+ typeof(isReleaseCache)); + + try{ + formManager.releaseForm( + formId, // formId: number>0 ok + isReleaseCache, // isReleaseCache: boolean ok + (err,data) => { + console.log("FMS_fuzzTest_0300_param_01_callback async::callbak return!!!") + console.log("FMS_fuzzTest_0300_param_01_callback async::sucess data:" + data); + console.log("FMS_fuzzTest_0300_param_01_callback async::error err:" + err); + expect(err).assertEqual(1); + done(); + } + ); + } catch (e) { + console.log("FMS_fuzzTest_0300_param_01_callback Exception caught:" + e); + expect(0).assertEqual(0); + } + + console.log("FMS_fuzzTest_0300_param_01_callback releaseForm end"); + done(); + setTimeout(function () { + console.info('=====================FMS_fuzzTest_0300_param_01_callback==================end'); + }, TIMEOUT) + }) + + /** + * @tc.name fuzzTest + * @tc.number FMS_fuzzTest_0300 + * @tc.desc Check whether the releaseForm interface can pass the fuzzy test (by Promise) + */ + it('FMS_fuzzTest_0300_param_01_promise', 0, async function (done) { + console.log("FMS_fuzzTest_0300_param_01_promise releaseForm begin"); + + var formId = parameterValue(); + console.log("FMS_fuzzTest_0300_param_01_promise releaseForm formId typeof:"+ typeof(formId)); + + var isReleaseCache = booleanTest(); + console.log("FMS_fuzzTest_0300_param_01_promise releaseForm isReleaseCache typeof:"+ typeof(isReleaseCache)); + + var retResult; + try{ + // formId: number>0 ok, isReleaseCache: boolean + retResult = await Promise.all(await formManager.releaseForm(formId, isReleaseCache)); + console.log("FMS_fuzzTest_0300_param_01_promise async::sucess retResult:" + retResult); + expect(retResult).assertEqual(1); + done(); + } catch (e) { + console.log("FMS_fuzzTest_0300_param_01_promise Exception caught:" + e); + expect(0).assertEqual(0); + } + + console.log("FMS_fuzzTest_0300_param_01_promise releaseForm end"); + done(); + setTimeout(function () { + console.info('=====================FMS_fuzzTest_0300_param_01_promise==================end'); + }, TIMEOUT) + }) + + /** + * @tc.name fuzzTest + * @tc.number FMS_fuzzTest_0300 + * @tc.desc Check whether the releaseForm interface can pass the fuzzy test (by AsyncCallback) + */ + it('FMS_fuzzTest_0300_param_02_callback', 0, async function (done) { + console.log("FMS_fuzzTest_0300_param_02_callback releaseForm begin"); + + var formId = stringTest(); + console.log("FMS_fuzzTest_0300_param_02_callback releaseForm formId typeof:"+ typeof(formId) + + ",formId:" + formId); + + var isReleaseCache = parameterValue(); + console.log("FMS_fuzzTest_0300_param_02_callback releaseForm isReleaseCache typeof:"+ typeof(isReleaseCache)); + + try{ + formManager.releaseForm( + formId, // formId: number>0 ok + isReleaseCache, // isReleaseCache: boolean ok + (err,data) => { + console.log("FMS_fuzzTest_0300_param_02_callback async::callbak return!!!") + console.log("FMS_fuzzTest_0300_param_02_callback async::sucess data:" + data); + console.log("FMS_fuzzTest_0300_param_02_callback async::error err:" + err); + expect(err).assertEqual(1); + done(); + } + + ); + } catch (e) { + console.log("FMS_fuzzTest_0300_param_02_callback Exception caught:" + e); + expect(0).assertEqual(0); + } + + console.log("FMS_fuzzTest_0300_param_02_callback releaseForm end"); + done(); + setTimeout(function () { + console.info('=====================FMS_fuzzTest_0300_param_02_callback==================end'); + }, TIMEOUT) + }) + + /** + * @tc.name fuzzTest + * @tc.number FMS_fuzzTest_0300 + * @tc.desc Check whether the releaseForm interface can pass the fuzzy test (by Promise) + */ + it('FMS_fuzzTest_0300_param_02_promise', 0, async function (done) { + console.log("FMS_fuzzTest_0300_param_02_promise releaseForm begin"); + + var formId = stringTest(); + console.log("FMS_fuzzTest_0300_param_02_promise releaseForm formId typeof:"+ typeof(formId) + + ",formId:" + formId); + + var isReleaseCache = parameterValue(); + console.log("FMS_fuzzTest_0300_param_02_promise releaseForm isReleaseCache typeof:"+ typeof(isReleaseCache)); + + var retResult; + try{ + // formId: number>0 ok, isReleaseCache: boolean + retResult = await Promise.all(await formManager.releaseForm(formId, isReleaseCache)); + console.log("FMS_fuzzTest_0300_param_02_promise async::sucess retResult:" + retResult); + expect(retResult).assertEqual(1); + done(); + } catch (e) { + console.log("FMS_fuzzTest_0300_param_02_promise Exception caught:" + e); + expect(0).assertEqual(0); + } + + console.log("FMS_fuzzTest_0300_param_02_promise releaseForm end"); + done(); + setTimeout(function () { + console.info('=====================FMS_fuzzTest_0300_param_02_promise==================end'); + }, TIMEOUT) + }) + + /** + * @tc.name fuzzTest + * @tc.number FMS_fuzzTest_1200 + * @tc.desc Check whether the getAllFormsInfo interface can pass the fuzzy test (by AsyncCallback) + */ + it('FMS_fuzzTest_1200_callback', 0, async function (done) { + console.log("FMS_fuzzTest_1200_callback getAllFormsInfo begin"); + + var testParam = parameterValue(); + console.log("FMS_fuzzTest_1200_callback getAllFormsInfo formIds typeof:"+ typeof(testParam)); + + try{ + formManager.getAllFormsInfo( + testParam, // formIds: array ok + (err,data) => { + console.log("FMS_fuzzTest_1200_callback async::callbak return!!!") + console.log("FMS_fuzzTest_1200_callback async::sucess data:" + data); + console.log("FMS_fuzzTest_1200_callback async::error err:" + err); + expect(err).assertEqual(1); + done(); + } + ); + } catch (e) { + console.log("FMS_fuzzTest_1200_callback Exception caught:" + e); + expect(0).assertEqual(0); + } + + console.log("FMS_fuzzTest_1200_callback getAllFormsInfo end"); + done(); + setTimeout(function () { + console.info('=====================FMS_fuzzTest_1200_callback==================end'); + }, TIMEOUT) + }) + + /** + * @tc.name fuzzTest + * @tc.number FMS_fuzzTest_1200 + * @tc.desc Check whether the getAllFormsInfo interface can pass the fuzzy test (by Promise) + */ + it('FMS_fuzzTest_1200_promise', 0, async function (done) { + console.log("FMS_fuzzTest_1200_promise getAllFormsInfo begin"); + + var testParam = parameterValue(); + console.log("FMS_fuzzTest_1200_promise getAllFormsInfo formIds typeof:"+ typeof(testParam)); + + var retResult; + try{ + retResult = await Promise.all(await formManager.getAllFormsInfo(testParam)); + console.log("FMS_fuzzTest_1200_promise async::sucess retResult:" + retResult); + expect(retResult).assertEqual(1); + done(); + } catch (e) { + console.log("FMS_fuzzTest_1200_promise Exception caught:" + e); + expect(0).assertEqual(0); + } + + console.log("FMS_fuzzTest_1200_promise getAllFormsInfo end"); + done(); + setTimeout(function () { + console.info('=====================FMS_fuzzTest_1200_promise==================end'); + }, TIMEOUT) + }) + + /** + * @tc.name fuzzTest + * @tc.number FMS_fuzzTest_1300 + * @tc.desc Check whether the form configuration information query interface of the specified package + * can pass the fuzzy test (by AsyncCallback) + */ + it('FMS_fuzzTest_1300_callback', 0, async function (done) { + console.log("FMS_fuzzTest_1300_callback getFormsInfoByApp begin"); + + var bundleName = parameterValue(); + console.log("FMS_fuzzTest_1300_callback getFormsInfoByApp bundleName typeof:"+ typeof(bundleName)); + + try{ + formManager.getFormsInfo( + bundleName, // bundleName string + (err,data) => { + console.log("FMS_fuzzTest_1300_callback async::callbak return!!!") + console.log("FMS_fuzzTest_1300_callback async::sucess data:" + data); + console.log("FMS_fuzzTest_1300_callback async::error err:" + err); + expect(err).assertEqual(1); + done(); + } + ); + } catch (e) { + console.log("FMS_fuzzTest_1300_callback Exception caught:" + e); + expect(0).assertEqual(0); + } + + console.log("FMS_fuzzTest_1300_callback getFormsInfoByApp end"); + done(); + setTimeout(function () { + console.info('=====================FMS_fuzzTest_1300_callback==================end'); + }, TIMEOUT) + }) + + /** + * @tc.name fuzzTest + * @tc.number FMS_fuzzTest_1300 + * @tc.desc Check whether the form configuration information query interface of the specified package + * can pass the fuzzy test (by Promise) + */ + it('FMS_fuzzTest_1300_promise', 0, async function (done) { + console.log("FMS_fuzzTest_1300_promise getFormsInfoByApp begin"); + + var bundleName = parameterValue(); + console.log("FMS_fuzzTest_1300_promise getFormsInfoByApp bundleName typeof:"+ typeof(bundleName)); + + var retResult; + try{ + retResult = await Promise.all(await formManager.getFormsInfo(bundleName)); + console.log("FMS_fuzzTest_1300_promise async::sucess retResult:" + retResult); + expect(retResult).assertEqual(1); + done(); + } catch (e) { + console.log("FMS_fuzzTest_1300_promise Exception caught:" + e); + expect(0).assertEqual(0); + } + + console.log("FMS_fuzzTest_1300_promise getFormsInfoByApp end"); + done(); + setTimeout(function () { + console.info('=====================FMS_fuzzTest_1300_promise==================end'); + }, TIMEOUT) + }) + + /** + * @tc.name fuzzTest + * @tc.number FMS_fuzzTest_1400 + * @tc.desc Check whether the form configuration information query interface of the specified module + * can pass the fuzzy test (by AsyncCallback) + */ + it('FMS_fuzzTest_1400_param_01_callback', 0, async function (done) { + console.log("FMS_fuzzTest_1400_param_01_callback getFormsInfoByModule begin"); + + var bundleName = parameterValue(); + console.log("FMS_fuzzTest_1400_param_01_callback getFormsInfoByModule bundleName typeof:"+ typeof(bundleName)); + + var moduleName = stringTest(); + console.log("FMS_fuzzTest_1400_param_01_callback getFormsInfoByModule moduleName typeof:"+ typeof(moduleName)); + + try{ + formManager.getFormsInfo( + bundleName, // bundleName string + moduleName,// moduleName string + (err,data) => { + console.log("FMS_fuzzTest_1400_param_01_callback async::callbak return!!!") + console.log("FMS_fuzzTest_1400_param_01_callback async::sucess data:" + data); + console.log("FMS_fuzzTest_1400_param_01_callback async::error err:" + err); + expect(err).assertEqual(1); + done(); + } + ); + } catch (e) { + console.log("FMS_fuzzTest_1400_param_01_callback Exception caught:" + e); + expect(0).assertEqual(0); + } + + console.log("FMS_fuzzTest_1400_param_01_callback getFormsInfoByModule end"); + done(); + setTimeout(function () { + console.info('=====================FMS_fuzzTest_1400_param_01_callback==================end'); + }, TIMEOUT) + }) + + /** + * @tc.name fuzzTest + * @tc.number FMS_fuzzTest_1400 + * @tc.desc Check whether the form configuration information query interface of the specified module + * can pass the fuzzy test (by Promise) + */ + it('FMS_fuzzTest_1400_param_01_promise', 0, async function (done) { + console.log("FMS_fuzzTest_1400_param_01_promise getFormsInfoByModule begin"); + + var bundleName = parameterValue(); + console.log("FMS_fuzzTest_1400_param_01_promise getFormsInfoByModule bundleName typeof:"+ typeof(bundleName)); + + var moduleName = stringTest(); + console.log("FMS_fuzzTest_1400_param_01_promise getFormsInfoByModule moduleName typeof:"+ typeof(moduleName)); + + var retResult; + try{ + retResult = await Promise.all(await formManager.getFormsInfo(bundleName, moduleName)); + console.log("FMS_fuzzTest_1400_param_01_promise async::sucess retResult:" + retResult); + expect(retResult).assertEqual(1); + done(); + } catch (e) { + console.log("FMS_fuzzTest_1400_param_01_promise Exception caught:" + e); + expect(0).assertEqual(0); + } + + console.log("FMS_fuzzTest_1400_param_01_promise getFormsInfoByModule end"); + done(); + setTimeout(function () { + console.info('=====================FMS_fuzzTest_1400_param_01_promise==================end'); + }, TIMEOUT) + }) + + /** + * @tc.name fuzzTest + * @tc.number FMS_fuzzTest_1400 + * @tc.desc Check whether the form configuration information query interface of the specified module + * can pass the fuzzy test (by AsyncCallback) + */ + it('FMS_fuzzTest_1400_param_02_callback', 0, async function (done) { + console.log("FMS_fuzzTest_1400_param_02_callback getFormsInfoByModule begin"); + + var bundleName = stringTest(); + console.log("FMS_fuzzTest_1400_param_02_callback getFormsInfoByModule bundleName typeof:"+ typeof(bundleName)); + + var moduleName = parameterValue(); + console.log("FMS_fuzzTest_1400_param_02_callback getFormsInfoByModule moduleName typeof:"+ typeof(moduleName)); + + try{ + formManager.getFormsInfo( + bundleName, // bundleName string + moduleName, // moduleName string + (err,data) => { + console.log("FMS_fuzzTest_1400_param_02_callback async::callbak return!!!") + console.log("FMS_fuzzTest_1400_param_02_callback async::sucess data:" + data); + console.log("FMS_fuzzTest_1400_param_02_callback async::error err:" + err); + expect(err).assertEqual(1); + done(); + } + ); + } catch (e) { + console.log("FMS_fuzzTest_1400_param_02_callback Exception caught:" + e); + expect(0).assertEqual(0); + } + + console.log("FMS_fuzzTest_1400_param_02_callback getFormsInfoByModule end"); + done(); + setTimeout(function () { + console.info('=====================FMS_fuzzTest_1400_param_02_callback==================end'); + }, TIMEOUT) + }) + + /** + * @tc.name fuzzTest + * @tc.number FMS_fuzzTest_1400 + * @tc.desc Check whether the form configuration information query interface of the specified module + * can pass the fuzzy test (by Promise) + */ + it('FMS_fuzzTest_1400_param_02_promise', 0, async function (done) { + console.log("FMS_fuzzTest_1400_param_02_promise getFormsInfoByModule begin"); + + var bundleName = stringTest(); + console.log("FMS_fuzzTest_1400_param_02_promise getFormsInfoByModule bundleName typeof:"+ typeof(bundleName)); + + var moduleName = parameterValue(); + console.log("FMS_fuzzTest_1400_param_02_promise getFormsInfoByModule moduleName typeof:"+ typeof(moduleName)); + + var retResult; + try{ + retResult = await Promise.all(await formManager.getFormsInfo(bundleName, moduleName)); + console.log("FMS_fuzzTest_1400_param_02_promise async::sucess retResult:" + retResult); + expect(retResult).assertEqual(1); + done(); + } catch (e) { + console.log("FMS_fuzzTest_1400_param_02_promise Exception caught:" + e); + expect(0).assertEqual(0); + } + + console.log("FMS_fuzzTest_1400_param_02_promise getFormsInfoByModule end"); + done(); + setTimeout(function () { + console.info('=====================FMS_fuzzTest_1400_param_02_promise==================end'); + }, TIMEOUT) + }) + +}) \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formsystemtesthost/FormFuzzTest/entry/src/main/js/test/List.test.js b/aafwk/aafwk_standard/formmanager/formsystemtesthost/FormFuzzTest/entry/src/main/js/test/List.test.js new file mode 100755 index 0000000000000000000000000000000000000000..ae0ba3f5175a63778a30fa9d3f6076cfe55bd8bf --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formsystemtesthost/FormFuzzTest/entry/src/main/js/test/List.test.js @@ -0,0 +1,16 @@ +/* + * 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. + */ + +require('./FormFuzzTest.test.js') \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formsystemtesthost/FormFuzzTest/entry/src/main/js/test/getParam.js b/aafwk/aafwk_standard/formmanager/formsystemtesthost/FormFuzzTest/entry/src/main/js/test/getParam.js new file mode 100755 index 0000000000000000000000000000000000000000..874626e178a28c3317fd9eaafbec95ce98fb1039 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formsystemtesthost/FormFuzzTest/entry/src/main/js/test/getParam.js @@ -0,0 +1,202 @@ +/* + * 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. + */ +var RANDOM_BEGIN_POSITION = 0; +var RANDOM_BEGIN_POSITION_A = 2; +var STRING_RANDOM_LENGTH = 2064; +var ASCII_RANDOM_LENGTH = 256; +var BOOLEAN_RANDOM_LENGTH = 2; +var ARRAY_RANDOM_LENGTH = 10; +var ARRAY_RANDOM_TYPE_LENGTH = 3; +var OBJECT_RANDOM_LENGTH = 2; +var FUNCTION_RANDOM_LENGTH = 2; + +//string ascii +var STRING_RANDOM_LENGTH_A = 48; +var STRING_RANDOM_LENGTH_B = 58; +var STRING_RANDOM_LENGTH_C = 65; +var STRING_RANDOM_LENGTH_D = 91; +var STRING_RANDOM_LENGTH_E = 97; +var STRING_RANDOM_LENGTH_F = 122; + +// Return integer random, the range is: [iStart, iEnd) +function getIntegerRandom(iStart, iEnd) { + var decimal = iStart + (iEnd - iStart) * Math.random(); + return Math.floor(decimal); +} + +// return string random, the string length is: [0, 2064) +const stringTest = function() { + // string + var res = ""; + + // string length + var iNumber = getIntegerRandom(RANDOM_BEGIN_POSITION, STRING_RANDOM_LENGTH); + for(var iAsciiToChar = RANDOM_BEGIN_POSITION; iAsciiToChar < iNumber ; iAsciiToChar ++) { + + var iNumberString = getIntegerRandom(RANDOM_BEGIN_POSITION, RANDOM_BEGIN_POSITION_A); + + switch (iNumberString) { + case 0: + // get ascii [0-9] + iNumber = getIntegerRandom(STRING_RANDOM_LENGTH_A, STRING_RANDOM_LENGTH_B); + break; + case 1: + // get ascii [A-Z] + iNumber = getIntegerRandom(STRING_RANDOM_LENGTH_C, STRING_RANDOM_LENGTH_D); + break; + case 2: + default: + // get ascii [a-z] + iNumber = getIntegerRandom(STRING_RANDOM_LENGTH_E, STRING_RANDOM_LENGTH_F); + break; + + } + // from ascii to char + var asciiToChar = String.fromCharCode(iNumber); + res += asciiToChar; + } + return res; +} + +// return number random, the number length is: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER] +const numberTest = function() { + return getIntegerRandom(Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER + 1); +} + +// return boolean random, the boolean value is: 0->(false), 1->(true) +const booleanTest = function() { + return getIntegerRandom(RANDOM_BEGIN_POSITION, BOOLEAN_RANDOM_LENGTH); +} + +// null +const nullTest = function() { + return null; +} + +// undefinedTest +const undefinedTest = function() { + return undefined; +} + +// return array random, the array value is: string,number,bool +const arrayTest = function() { + var arrValue = []; + + // array length + var iNumber = getIntegerRandom(RANDOM_BEGIN_POSITION, ARRAY_RANDOM_LENGTH); + for(var iArrNumber = 0; iArrNumber < iNumber ; iArrNumber ++) { + + // string,number,bool + iNumber = getIntegerRandom(RANDOM_BEGIN_POSITION, ARRAY_RANDOM_TYPE_LENGTH); + switch(iNumber) { + case 0: + arrValue[iArrNumber] = stringTest(); + break; + case 1: + arrValue[iArrNumber] = numberTest(); + break; + case 2: + arrValue[iArrNumber] = booleanTest(); + break; + default: + arrValue[iArrNumber] = ''; + } + } + return arrValue; +} + +// return objectTest random, the objectTest value is: null, not null +const objectTest = function() { + var objectA = Object.create(null); + var objectB = Object.create("objectTest"); + + return getIntegerRandom(RANDOM_BEGIN_POSITION, OBJECT_RANDOM_LENGTH) ? objectA: objectB; +} + +// return functionTest random, the functionTest value is: null, not null +const functionTest = function() { + var functionA = {}; + var functionB = {id:"functionTest"}; + + return getIntegerRandom(RANDOM_BEGIN_POSITION, FUNCTION_RANDOM_LENGTH) ? functionA: functionB; +} + +// get parameter value from: string, number, bool, null, undefined, object, array, function +const parameterValue = function() { + + var fuzzConfigData = [ + {"name":"string", "paramWeight":25}, + {"name":"number", "paramWeight":45}, + {"name":"boolean", "paramWeight":50}, + {"name":"null", "paramWeight":52}, + {"name":"undefined", "paramWeight":54}, + {"name":"object", "paramWeight":62}, + {"name":"array", "paramWeight":92}, + {"name":"function", "paramWeight":100}, + ] + + var weightSum = fuzzConfigData[fuzzConfigData.length - 1].paramWeight; + console.log("The weight sum of this fuzzTest:" + weightSum); + + var paramValue = ''; + var iNumber = getIntegerRandom(RANDOM_BEGIN_POSITION, weightSum); + console.log("The iNumber of this fuzzTest random:" + iNumber); + + for(var iFuzzDataNumber = 0; iFuzzDataNumber < fuzzConfigData.length; iFuzzDataNumber ++) { + + if((iFuzzDataNumber == 0 && + iNumber < fuzzConfigData[iFuzzDataNumber].paramWeight) || + (iNumber < fuzzConfigData[iFuzzDataNumber].paramWeight && + iNumber > fuzzConfigData[iFuzzDataNumber - 1].paramWeight) ) { + console.log("The name of this fuzzTest random:" + fuzzConfigData[iFuzzDataNumber].name); + switch(fuzzConfigData[iFuzzDataNumber].name) { + case "string": + paramValue = stringTest(); + break; + case "number": + paramValue = numberTest(); + break; + case "boolean": + paramValue = booleanTest(); + break; + case "null": + paramValue = nullTest(); + break; + case "undefined": + paramValue = undefinedTest(); + break; + case "object": + paramValue = objectTest(); + break; + case "array": + paramValue = arrayTest(); + break; + case "function": + paramValue = functionTest(); + break; + default: + paramValue = ''; + break; + } + } + } + + console.log("The paramValue of this fuzzTest random:" + paramValue); + return paramValue; +} + +export { + parameterValue, stringTest, numberTest, booleanTest, nullTest, undefinedTest, objectTest, arrayTest, functionTest +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formsystemtesthost/FormFuzzTest/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/formmanager/formsystemtesthost/FormFuzzTest/entry/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..f34a4a596cd58f236fd1b7bafc9c924af5bd82f0 --- /dev/null +++ b/aafwk/aafwk_standard/formmanager/formsystemtesthost/FormFuzzTest/entry/src/main/resources/base/element/string.json @@ -0,0 +1,21 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "fuzztest" + }, + { + "name": "mainability_description", + "value": "JS_Empty Ability" + }, + { + "name": "testForm", + "value": "REQUIRE_FORM permission" + }, + { + "name": "testFormA", + "value": "CAMERA permission" + } + + ] +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/formmanager/formsystemtesthost/FormFuzzTest/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/formmanager/formsystemtesthost/FormFuzzTest/entry/src/main/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formsystemtesthost/FormFuzzTest/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/formmanager/formsystemtesthost/FormFuzzTest/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/formmanager/formsystemtesthost/FormFuzzTest/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..9be1e98fa4c0c28ca997ed660112fa16b194f0f5 Binary files /dev/null and b/aafwk/aafwk_standard/formmanager/formsystemtesthost/FormFuzzTest/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/formmanager/formsystemtestservice/formsystemtestservicea/src/main/config.json b/aafwk/aafwk_standard/formmanager/formsystemtestservice/formsystemtestservicea/src/main/config.json old mode 100644 new mode 100755 index 9d5f0f2534801641f90bec81c2efba05a2b96191..2f1fcebedcd7e14b5c22cfca929fdf3318ac8ecf --- a/aafwk/aafwk_standard/formmanager/formsystemtestservice/formsystemtestservicea/src/main/config.json +++ b/aafwk/aafwk_standard/formmanager/formsystemtestservice/formsystemtestservicea/src/main/config.json @@ -57,7 +57,7 @@ "updateEnabled": true, "scheduledUpdateTime": "10:30", "jsComponentName": "card", - "formVisibleNotify" : true, + "formVisibleNotify" : false, "metaData": { "customizeData": [ { @@ -78,7 +78,7 @@ "updateEnabled": true, "updateDuration": 1, "jsComponentName": "card", - "formVisibleNotify" : true, + "formVisibleNotify" : false, "metaData": { "customizeData": [ { @@ -104,4 +104,4 @@ } ] } -} \ No newline at end of file +}