提交 4caefaff 编写于 作者: Z zhaoyuan17@huawei.com
上级 8a1964c1
......@@ -17,6 +17,7 @@ group("formmanager") {
testonly = true
if (is_standard_system) {
deps = [
"formsystemtesthost/FormFuzzTest:FormFuzzTest",
"formsystemtesthost/getallformsinfo:GetAllFormsInfo",
"formsystemtestservice/formsystemtestservicea:ActsFormSystemTestServiceA",
]
......
# 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"
}
{
"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"
]
}
]
}
{
"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
/*
* 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');
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
}
}
\ No newline at end of file
.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;
}
}
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
</div>
/*
* 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() {
},
}
/*
* 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
/*
* 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
/*
* 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
{
"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
......@@ -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
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册