提交 45f8d31d 编写于 作者: C chengxingzhen

Add form fuzz test

Signed-off-by: Nchengxingzhen <chengxingzhen@huawei.com>
上级 7e76bf46
...@@ -17,15 +17,7 @@ group("formmanager") { ...@@ -17,15 +17,7 @@ group("formmanager") {
testonly = true testonly = true
if (is_standard_system) { if (is_standard_system) {
deps = [ deps = [
# "formsystemtesthost/actsformfuzztest:ActsFormFuzzTest", "formsystemtest_ets/formfuzztest:FormFuzzTest",
# "formsystemtesthost/actsformsoneandonetest:ActsFormsOneAndOneTest",
# "formsystemtesthost/actsformsoneandtwotest:ActsFormsOneAndTwoTest",
# "formsystemtesthost/actsformszeroandonetest:ActsFormsZeroAndOneTest",
# "formsystemtesthost/actsformszerotest:ActsFormsZeroTest",
# "formsystemtestservice/formsystemtestservicea:ActsFormSystemTestServiceA",
# "formsystemtestservice/formsystemtestserviceb:ActsFormSystemTestServiceB",
# "formsystemtestservice/formsystemtestservicec:ActsFormSystemTestServiceC",
# "formsystemtestservice/formsystemtestserviced:ActsFormSystemTestServiceD",
] ]
} }
} }
# Copyright (c) 2021 Huawei Device Co., Ltd. # Copyright (C) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
# You may obtain a copy of the License at # You may obtain a copy of the License at
...@@ -13,17 +13,18 @@ ...@@ -13,17 +13,18 @@
import("//test/xts/tools/build/suite.gni") import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsFormFuzzTest") { ohos_js_hap_suite("FormFuzzTest") {
hap_profile = "./entry/src/main/config.json" hap_profile = "./entry/src/main/config.json"
deps = [ deps = [
":hjs_demo_js_assets", ":hjs_demo_js_assets",
":hjs_demo_resources", ":hjs_demo_resources",
] ]
ets2abc = true
certificate_profile = "./signature/openharmony_sx.p7b" certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsFormFuzzTest" hap_name = "FormFuzzTest"
} }
ohos_js_assets("hjs_demo_js_assets") { ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/js/default" source_dir = "./entry/src/main/ets/MainAbility"
} }
ohos_resources("hjs_demo_resources") { ohos_resources("hjs_demo_resources") {
sources = [ "./entry/src/main/resources" ] sources = [ "./entry/src/main/resources" ]
......
...@@ -2,14 +2,14 @@ ...@@ -2,14 +2,14 @@
"description": "Configuration for hjunit demo Tests", "description": "Configuration for hjunit demo Tests",
"driver": { "driver": {
"type": "JSUnitTest", "type": "JSUnitTest",
"test-timeout": "420000", "test-timeout": "600000",
"package": "com.example.formfuzztest", "package": "com.ohos.st.formfuzztest",
"shell-timeout": "600000" "shell-timeout": "60000"
}, },
"kits": [ "kits": [
{ {
"test-file-name": [ "test-file-name": [
"ActsFormFuzzTest.hap" "FormFuzzTest.hap"
], ],
"type": "AppInstallKit", "type": "AppInstallKit",
"cleanup-apps": true "cleanup-apps": true
......
{ {
"app": { "app": {
"bundleName": "com.example.formfuzztest", "bundleName": "com.ohos.st.formfuzztest",
"vendor": "example", "vendor": "ohos",
"version": { "version": {
"code": 1, "code": 1000000,
"name": "1.0" "name": "1.0.0"
}, },
"apiVersion": { "apiVersion": {
"compatible": 5, "compatible": 9,
"target": 5, "releaseType": "Release",
"releaseType": "Beta1" "target": 9
} }
}, },
"deviceConfig": {}, "deviceConfig": {},
"module": { "module": {
"package": "com.example.formfuzztest", "package": "com.ohos.st.formfuzztest",
"name": ".MyApplication", "name": ".FormFuzzSTApp",
"mainAbility": "com.example.formfuzztest.MainAbility", "mainAbility": ".MainAbility",
"deviceType": [ "deviceType": [
"phone" "phone"
], ],
...@@ -39,9 +39,10 @@ ...@@ -39,9 +39,10 @@
} }
], ],
"visible": true, "visible": true,
"name": "com.example.formfuzztest.MainAbility", "name": ".MainAbility",
"srcLanguage": "ets",
"icon": "$media:icon", "icon": "$media:icon",
"description": "$string:mainability_description", "description": "$string:description_mainability",
"label": "$string:entry_MainAbility", "label": "$string:entry_MainAbility",
"type": "page", "type": "page",
"launchType": "standard" "launchType": "standard"
...@@ -49,64 +50,93 @@ ...@@ -49,64 +50,93 @@
], ],
"defPermissions": [ "defPermissions": [
{ {
"name": "com.permission.CAMERA", "availableScope": [],
"grantMode": "system_grant", "grantMode": "system_grant",
"availableScope": ["signature"], "name": "FMS_FormDelete_commonEvent"
"label": "$string:testFormA",
"description": "CAMERA permission in detail"
}, },
{ {
"name": "ohos.permission.REQUIRE_FORM", "availableScope": [],
"grantMode": "system_grant", "grantMode": "system_grant",
"label": "$string:testForm", "name": "FMS_FormOnAcquired_commonEvent"
"description": "REQUIRE_FORM permission in detail" },
{
"availableScope": [],
"grantMode": "system_grant",
"name": "FMS_FormOnError_commonEvent"
},
{
"availableScope": [],
"grantMode": "system_grant",
"name": "FMS_FormCast_commonEvent"
},
{
"availableScope": [],
"grantMode": "system_grant",
"name": "FMS_FormSupply_commonEvent"
} }
], ],
"reqPermissions": [ "reqPermissions": [
{ {
"name": "ohos.permission.REQUIRE_FORM", "name": "FMS_FormOnAcquired_commonEvent",
"reason": "require form", "reason": "need use onAcquired commonEvent"
"usedScene": { },
"ability": [ {
".MainAbility" "name": "FMS_FormDelete_commonEvent",
], "reason": "need use delete commonEvent"
"when": "always" },
} {
"name": "FMS_FormOnError_commonEvent",
"reason": "need use OnError commonEvent"
},
{
"name": "FMS_FormCast_commonEvent",
"reason": "need use castFrom commonEvent"
},
{
"name": "FMS_FormSupply_commonEvent",
"reason": "need use FormSupply commonEvent"
}, },
{ {
"name": "ohos.permission.INSTALL_BUNDLE", "name": "ohos.permission.INSTALL_BUNDLE",
"reason": "need use ohos.permission.INSTALL_BUNDLE" "reason": "need use ohos.permission.INSTALL_BUNDLE"
}, },
{ {
"name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
"reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" "reason": "need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
}, },
{ {
"name":"ohos.permission.CHANGE_ABILITY_ENABLED_STATE", "name": "ohos.permission.CHANGE_ABILITY_ENABLED_STATE",
"reason":"need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE" "reason": "need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE"
}, },
{ {
"name":"ohos.permission.REMOVE_CACHE_FILES", "name": "ohos.permission.REMOVE_CACHE_FILES",
"reason":"need use ohos.permission.REMOVE_CACHE_FILES" "reason": "need use ohos.permission.REMOVE_CACHE_FILES"
}, },
{ {
"name":"ohos.permission.LISTEN_BUNDLE_CHANGE", "name": "ohos.permission.LISTEN_BUNDLE_CHANGE",
"reason":"need use ohos.permission.LISTEN_BUNDLE_CHANGE" "reason": "need use ohos.permission.LISTEN_BUNDLE_CHANGE"
}, },
{ {
"name":"ohos.permission.REQUIRE_FORM", "name": "ohos.permission.CLEAN_BACKGROUND_PROCESSES",
"reason":"need use ohos.permission.REQUIRE_FORM" "reason": "need use ohos.permission.CLEAN_BACKGROUND_PROCESSES"
},
{
"name": "ohos.permission.REQUIRE_FORM"
} }
], ],
"js": [ "js": [
{ {
"mode": {
"syntax": "ets",
"type": "pageAbility"
},
"pages": [ "pages": [
"pages/index/index" "pages/index"
], ],
"name": "default", "name": ".MainAbility",
"window": { "window": {
"designWidth": 720, "designWidth": 720,
"autoDesignWidth": true "autoDesignWidth": false
} }
} }
] ]
......
...@@ -15,9 +15,9 @@ ...@@ -15,9 +15,9 @@
export default { export default {
onCreate() { onCreate() {
console.info('AceApplication onCreate'); console.info('Application onCreate');
}, },
onDestroy() { onDestroy() {
console.info('AceApplication onDestroy'); console.info('Application onDestroy');
} },
}; };
...@@ -13,39 +13,52 @@ ...@@ -13,39 +13,52 @@
* limitations under the License. * limitations under the License.
*/ */
import app from '@system.app' import featureAbility from "@ohos.ability.featureAbility";
import file from '@system.file' import file from '@system.file';
import router from '@system.router' import { Core, ExpectExtend, ReportExtend } from 'deccjsunit/index.ets';
import device from '@system.device' import testsuite from "../test/List.test.ets";
import {Core, ExpectExtend, ReportExtend} from 'deccjsunit/index'
const injectRef = Object.getPrototypeOf(global) || global @Entry
injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') @Component
struct Index {
private componentName: string = `FormSystemFuzzTest`;
export default { aboutToAppear() {
data: { console.info(`${this.componentName} start run testcase!!!!`);
title: ""
}, featureAbility.getWant()
onInit() { .then((want: any) => {
this.title = "FMS Fuzz Test"; console.info(`${this.componentName} Operation successful. Data: ${JSON.stringify(want)}`);
}, const core = Core.getInstance();
onShow() {
console.info('onShow finish')
const core = Core.getInstance()
const expectExtend = new ExpectExtend({ const expectExtend = new ExpectExtend({
'id': 'extend' 'id': 'extend'
});
core.addService('expect', expectExtend);
const reportExtend = new ReportExtend(file);
core.addService('report', reportExtend);
core.init();
core.subscribeEvent('task', reportExtend);
const configService = core.getDefaultService('config');
configService.setConfig(want.parameters);
testsuite();
core.execute();
})
.catch((error: any) => {
console.error(`${this.componentName} Operation failed. Cause: ${JSON.stringify(error)}`);
}) })
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') build() {
core.execute() Flex({
console.info('onShow end') direction: FlexDirection.Column,
}, alignItems: ItemAlign.Center,
onReady() { justifyContent: FlexAlign.Center
}, }) {
Text(`${this.componentName}`)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
.height('100%')
}
} }
/*
* 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 formHost from '@ohos.application.formHost';
import { describe, expect, it } from 'deccjsunit/index.ets';
import { DATA_TYPE_LIST, getFuzzData } from './getParam.ets';
export const castTempFormFuzzTest = (describeName, filterParameter) => {
const ERR_ADD_INVALID_PARAM_CODE = 7;
const ERR_ADD_INVALID_PARAM = `invalid input parameter during form operation`;
describe(`${describeName}`, () => {
const callbackName = `FMS_fuzzTest_casttempform`;
const promiseName = `FMS_fuzzTest_casttempform`;
const length = DATA_TYPE_LIST.length;
for (let i = 0; i < length; ++i) {
const tcNumber = `0${(i + 1) * 100}`;
/**
* @tc.name fuzzTest
* @tc.number FMS_fuzzTest_casttempform_0100 ~ FMS_fuzzTest_casttempform_0800
* @tc.desc Check whether the castTempForm interface can pass the fuzzy test (by AsyncCallback)
*/
it(`${callbackName}_${tcNumber}`, filterParameter, async (done) => {
const dataType = DATA_TYPE_LIST[i];
const formId = getFuzzData(dataType);
console.log(`${callbackName} ${tcNumber} formId typeof: ${typeof formId}`);
try {
formHost.castTempForm(formId, (error, data) => {
console.log(`${callbackName} ${tcNumber} castTempForm data: ${JSON.stringify(data)} error: ${JSON.stringify(error)}`);
expect(data).assertUndefined();
expect(error.code).assertEqual(ERR_ADD_INVALID_PARAM_CODE);
expect(error.message).assertEqual(ERR_ADD_INVALID_PARAM);
done();
});
} catch (error) {
console.log(`${callbackName} ${tcNumber} exception caught: ${JSON.stringify(error)}`);
console.log(`${callbackName} ${tcNumber} should not reach here`);
expect().assertFail();
}
});
}
for (let i = 0; i < length; ++i) {
let tcNumber: any = (i + 1 + length) * 100;
tcNumber = tcNumber < 1000 ? `0${tcNumber}` : tcNumber;
/**
* @tc.name fuzzTest
* @tc.number FMS_fuzzTest_casttempform_0900 ~ FMS_fuzzTest_casttempform_1600
* @tc.desc Check whether the castTempForm interface can pass the fuzzy test (by Promise)
*/
it(`${promiseName}_${tcNumber}`, filterParameter, async (done) => {
const dataType = DATA_TYPE_LIST[i];
const formId = getFuzzData(dataType);
console.log(`${promiseName} ${tcNumber} ${describeName} formId typeof: ${typeof formId}`);
try {
const data = await formHost.castTempForm(formId);
console.log(`${promiseName} ${tcNumber} castTempForm data: ${JSON.stringify(data)}`);
console.log(`${promiseName} ${tcNumber} should not reach here`);
expect().assertFail();
} catch (error) {
console.log(`${promiseName} ${tcNumber} exception caught: ${JSON.stringify(error)}`);
expect(error.code).assertEqual(ERR_ADD_INVALID_PARAM_CODE);
expect(error.message).assertEqual(ERR_ADD_INVALID_PARAM);
done();
}
});
}
});
};
/*
* 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 formHost from '@ohos.application.formHost';
import { describe, expect, it } from 'deccjsunit/index.ets';
import { DATA_TYPE_LIST, getFuzzData } from './getParam.ets';
export const deleteFormFuzzTest = (describeName, filterParameter) => {
const ERR_ADD_INVALID_PARAM_CODE = 7;
const ERR_ADD_INVALID_PARAM = `invalid input parameter during form operation`;
describe(`${describeName}`, () => {
const callbackName = `FMS_fuzzTest_deleteform`;
const promiseName = `FMS_fuzzTest_deleteform`;
const length = DATA_TYPE_LIST.length;
for (let i = 0; i < length; ++i) {
const tcNumber = `0${(i + 1) * 100}`;
/**
* @tc.name fuzzTest
* @tc.number FMS_fuzzTest_deleteform_0100 ~ FMS_fuzzTest_deleteform_0800
* @tc.desc Check whether the deleteForm interface can pass the fuzzy test (by AsyncCallback)
*/
it(`${callbackName}_${tcNumber}`, filterParameter, async (done) => {
const dataType = DATA_TYPE_LIST[i];
const formId = getFuzzData(dataType);
console.log(`${callbackName} ${tcNumber} formId typeof: ${typeof formId}`);
try {
formHost.deleteForm(formId, (error, data) => {
console.log(`${callbackName} ${tcNumber} deleteForm data: ${JSON.stringify(data)} error: ${JSON.stringify(error)}`);
expect(data).assertUndefined();
expect(error.code).assertEqual(ERR_ADD_INVALID_PARAM_CODE);
expect(error.message).assertEqual(ERR_ADD_INVALID_PARAM);
done();
});
} catch (error) {
console.log(`${callbackName} ${tcNumber} exception caught: ${JSON.stringify(error)}`);
console.log(`${callbackName} ${tcNumber} should not reach here`);
expect().assertFail();
}
});
}
for (let i = 0; i < length; ++i) {
let tcNumber: any = (i + 1 + length) * 100;
tcNumber = tcNumber < 1000 ? `0${tcNumber}` : tcNumber;
/**
* @tc.name fuzzTest
* @tc.number FMS_fuzzTest_deleteform_0900 ~ FMS_fuzzTest_deleteform_1600
* @tc.desc Check whether the deleteForm interface can pass the fuzzy test (by Promise)
*/
it(`${promiseName}_${tcNumber}`, filterParameter, async (done) => {
const dataType = DATA_TYPE_LIST[i];
const formId = getFuzzData(dataType);
console.log(`${promiseName} ${tcNumber} ${describeName} formId typeof: ${typeof formId}`);
try {
const data = await formHost.deleteForm(formId);
console.log(`${promiseName} ${tcNumber} deleteForm data: ${JSON.stringify(data)}`);
console.log(`${promiseName} ${tcNumber} should not reach here`);
expect().assertFail();
} catch (error) {
console.log(`${promiseName} ${tcNumber} exception caught: ${JSON.stringify(error)}`);
expect(error.code).assertEqual(ERR_ADD_INVALID_PARAM_CODE);
expect(error.message).assertEqual(ERR_ADD_INVALID_PARAM);
done();
}
});
}
});
};
/*
* 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 formHost from '@ohos.application.formHost';
import { describe, expect, it } from 'deccjsunit/index.ets';
import { DATA_TYPE_LIST, getFuzzData } from './getParam.ets';
export const disableFormsUpdateFuzzTest = (describeName, filterParameter) => {
const ERR_ADD_INVALID_PARAM_CODE = 7;
const ERR_ADD_INVALID_PARAM = `invalid input parameter during form operation`;
describe(`${describeName}`, () => {
const callbackName = `FMS_fuzzTest_disable`;
const promiseName = `FMS_fuzzTest_disable`;
const length = DATA_TYPE_LIST.length;
for (let i = 0; i < length; ++i) {
const tcNumber = `0${(i + 1) * 100}`;
/**
* @tc.name fuzzTest
* @tc.number FMS_fuzzTest_disable_0100 ~ FMS_fuzzTest_disable_0800
* @tc.desc Check whether the disableFormsUpdate interface can pass the fuzzy test (by AsyncCallback)
*/
it(`${callbackName}_${tcNumber}`, filterParameter, async (done) => {
const dataType = DATA_TYPE_LIST[i];
const formIds = getFuzzData(dataType);
console.log(`${callbackName} ${tcNumber} formIds typeof: ${typeof formIds}`);
try {
formHost.disableFormsUpdate(formIds, (error, data) => {
console.log(`${callbackName} ${tcNumber} disableFormsUpdate data: ${JSON.stringify(data)} error: ${JSON.stringify(error)}`);
expect(data).assertUndefined();
expect(error.code).assertEqual(ERR_ADD_INVALID_PARAM_CODE);
expect(error.message).assertEqual(ERR_ADD_INVALID_PARAM);
done();
});
} catch (error) {
console.log(`${callbackName} ${tcNumber} exception caught: ${JSON.stringify(error)}`);
console.log(`${callbackName} ${tcNumber} should not reach here`);
expect().assertFail();
}
});
}
for (let i = 0; i < length; ++i) {
let tcNumber: any = (i + 1 + length) * 100;
tcNumber = tcNumber < 1000 ? `0${tcNumber}` : tcNumber;
/**
* @tc.name fuzzTest
* @tc.number FMS_fuzzTest_disable_0900 ~ FMS_fuzzTest_disable_1600
* @tc.desc Check whether the disableFormsUpdate interface can pass the fuzzy test (by Promise)
*/
it(`${promiseName}_${tcNumber}`, filterParameter, async (done) => {
const dataType = DATA_TYPE_LIST[i];
const formIds = getFuzzData(dataType);
console.log(`${promiseName} ${tcNumber} ${describeName} formIds typeof: ${typeof formIds}`);
try {
const data = await formHost.disableFormsUpdate(formIds);
console.log(`${promiseName} ${tcNumber} disableFormsUpdate data: ${JSON.stringify(data)}`);
console.log(`${promiseName} ${tcNumber} should not reach here`);
expect().assertFail();
} catch (error) {
console.log(`${promiseName} ${tcNumber} exception caught: ${JSON.stringify(error)}`);
expect(error.code).assertEqual(ERR_ADD_INVALID_PARAM_CODE);
expect(error.message).assertEqual(ERR_ADD_INVALID_PARAM);
done();
}
});
}
});
};
/*
* 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 formHost from '@ohos.application.formHost';
import { describe, expect, it } from 'deccjsunit/index.ets';
import { DATA_TYPE_LIST, getFuzzData } from './getParam.ets';
export const enableFormsUpdateFuzzTest = (describeName, filterParameter) => {
const ERR_ADD_INVALID_PARAM_CODE = 7;
const ERR_ADD_INVALID_PARAM = `invalid input parameter during form operation`;
describe(`${describeName}`, () => {
const callbackName = `FMS_fuzzTest_enable`;
const promiseName = `FMS_fuzzTest_enable`;
const length = DATA_TYPE_LIST.length;
for (let i = 0; i < length; ++i) {
const tcNumber = `0${(i + 1) * 100}`;
/**
* @tc.name fuzzTest
* @tc.number FMS_fuzzTest_enable_0100 ~ FMS_fuzzTest_enable_0800
* @tc.desc Check whether the enableFormsUpdate interface can pass the fuzzy test (by AsyncCallback)
*/
it(`${callbackName}_${tcNumber}`, filterParameter, async (done) => {
const dataType = DATA_TYPE_LIST[i];
const formIds = getFuzzData(dataType);
console.log(`${callbackName} ${tcNumber} formIds typeof: ${typeof formIds}`);
try {
formHost.enableFormsUpdate(formIds, (error, data) => {
console.log(`${callbackName} ${tcNumber} enableFormsUpdate data: ${JSON.stringify(data)} error: ${JSON.stringify(error)}`);
expect(data).assertUndefined();
expect(error.code).assertEqual(ERR_ADD_INVALID_PARAM_CODE);
expect(error.message).assertEqual(ERR_ADD_INVALID_PARAM);
done();
});
} catch (error) {
console.log(`${callbackName} ${tcNumber} exception caught: ${JSON.stringify(error)}`);
console.log(`${callbackName} ${tcNumber} should not reach here`);
expect().assertFail();
}
});
}
for (let i = 0; i < length; ++i) {
let tcNumber: any = (i + 1 + length) * 100;
tcNumber = tcNumber < 1000 ? `0${tcNumber}` : tcNumber;
/**
* @tc.name fuzzTest
* @tc.number FMS_fuzzTest_enable_0900 ~ FMS_fuzzTest_enable_1600
* @tc.desc Check whether the enableFormsUpdate interface can pass the fuzzy test (by Promise)
*/
it(`${promiseName}_${tcNumber}`, filterParameter, async (done) => {
const dataType = DATA_TYPE_LIST[i];
const formIds = getFuzzData(dataType);
console.log(`${promiseName} ${tcNumber} ${describeName} formIds typeof: ${typeof formIds}`);
try {
const data = await formHost.enableFormsUpdate(formIds);
console.log(`${promiseName} ${tcNumber} enableFormsUpdate data: ${JSON.stringify(data)}`);
console.log(`${promiseName} ${tcNumber} should not reach here`);
expect().assertFail();
} catch (error) {
console.log(`${promiseName} ${tcNumber} exception caught: ${JSON.stringify(error)}`);
expect(error.code).assertEqual(ERR_ADD_INVALID_PARAM_CODE);
expect(error.message).assertEqual(ERR_ADD_INVALID_PARAM);
done();
}
});
}
});
};
/*
* 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 formHost from '@ohos.application.formHost';
import { describe, expect, it } from 'deccjsunit/index.ets';
import { DATA_TYPE_LIST, getFuzzData } from './getParam.ets';
export const getFormsInfoFuzzTest = (describeName, filterParameter) => {
const ERR_GET_BUNDLE_FAILED_CODE = 5;
const ERR_GET_BUNDLE_FAILED = `failed to obtain the bundle information`;
const ERR_ADD_INVALID_PARAM_CODE = 7;
const ERR_ADD_INVALID_PARAM = `invalid input parameter during form operation`;
describe(`${describeName}`, () => {
const callbackName = `FMS_fuzzTest_getinfobundle`;
const promiseName = `FMS_fuzzTest_getinfobundle`;
const length = DATA_TYPE_LIST.length;
for (let i = 0; i < length; ++i) {
const tcNumber = `0${(i + 1) * 100}`;
/**
* @tc.name fuzzTest
* @tc.number FMS_fuzzTest_getinfobundle_0100 ~ FMS_fuzzTest_getinfobundle_0800
* @tc.desc Check whether the getFormsInfo interface can pass the fuzzy test (by AsyncCallback)
*/
it(`${callbackName}_${tcNumber}`, filterParameter, async (done) => {
const dataType = DATA_TYPE_LIST[i];
const bundleName = getFuzzData(dataType);
console.log(`${callbackName} ${tcNumber} bundleName typeof: ${typeof bundleName}`);
try {
formHost.getFormsInfo(bundleName, (error, data) => {
console.log(`${callbackName} ${tcNumber} getFormsInfo data: ${JSON.stringify(data)} error: ${JSON.stringify(error)}`);
expect(data).assertUndefined();
if (`STRING` === dataType) {
expect(error.code).assertEqual(ERR_GET_BUNDLE_FAILED_CODE);
expect(error.message).assertEqual(ERR_GET_BUNDLE_FAILED);
} else {
expect(error.code).assertEqual(ERR_ADD_INVALID_PARAM_CODE);
expect(error.message).assertEqual(ERR_ADD_INVALID_PARAM);
}
done();
});
} catch (error) {
console.log(`${callbackName} ${tcNumber} exception caught: ${JSON.stringify(error)}`);
console.log(`${callbackName} ${tcNumber} should not reach here`);
expect().assertFail();
}
});
}
for (let i = 0; i < length; ++i) {
let tcNumber: any = (i + 1 + length) * 100;
tcNumber = tcNumber < 1000 ? `0${tcNumber}` : tcNumber;
/**
* @tc.name fuzzTest
* @tc.number FMS_fuzzTest_getinfobundle_0900 ~ FMS_fuzzTest_getinfobundle_1600
* @tc.desc Check whether the getFormsInfo interface can pass the fuzzy test (by Promise)
*/
it(`${promiseName}_${tcNumber}`, filterParameter, async (done) => {
const dataType = DATA_TYPE_LIST[i];
const bundleName = getFuzzData(dataType);
console.log(`${promiseName} ${tcNumber} ${describeName} bundleName typeof: ${typeof bundleName}`);
try {
const data = await formHost.getFormsInfo(bundleName);
console.log(`${promiseName} ${tcNumber} getFormsInfo data: ${JSON.stringify(data)}`);
console.log(`${promiseName} ${tcNumber} should not reach here`);
expect().assertFail();
} catch (error) {
console.log(`${promiseName} ${tcNumber} exception caught: ${JSON.stringify(error)}`);
if (`STRING` === dataType) {
expect(error.code).assertEqual(ERR_GET_BUNDLE_FAILED_CODE);
expect(error.message).assertEqual(ERR_GET_BUNDLE_FAILED);
} else {
expect(error.code).assertEqual(ERR_ADD_INVALID_PARAM_CODE);
expect(error.message).assertEqual(ERR_ADD_INVALID_PARAM);
}
done();
}
});
}
});
describe(`${describeName}`, () => {
const callbackName = `FMS_fuzzTest_getinfomodule`;
const promiseName = `FMS_fuzzTest_getinfomodule`;
const length = DATA_TYPE_LIST.length;
for (let i = 0; i < length; ++i) {
const tcNumber = `0${(i + 1) * 100}`;
/**
* @tc.name fuzzTest
* @tc.number FMS_fuzzTest_getinfomodule_0100 ~ FMS_fuzzTest_getinfomodule_0800
* @tc.desc Check whether the getFormsInfo interface can pass the fuzzy test (by AsyncCallback)
*/
it(`${callbackName}_${tcNumber}`, filterParameter, async (done) => {
const dataType = DATA_TYPE_LIST[i];
const bundleName = getFuzzData(dataType);
const moduleName = `com.test.module_name_${tcNumber}`;
console.log(`${callbackName} ${tcNumber} bundleName typeof: ${typeof bundleName}`);
console.log(`${callbackName} ${tcNumber} moduleName typeof: ${typeof moduleName}`);
try {
formHost.getFormsInfo(bundleName, moduleName, (error, data) => {
console.log(`${callbackName} ${tcNumber} getFormsInfo data: ${JSON.stringify(data)} error: ${JSON.stringify(error)}`);
expect(data).assertUndefined();
if (`STRING` === dataType) {
expect(error.code).assertEqual(ERR_GET_BUNDLE_FAILED_CODE);
expect(error.message).assertEqual(ERR_GET_BUNDLE_FAILED);
} else {
expect(error.code).assertEqual(ERR_ADD_INVALID_PARAM_CODE);
expect(error.message).assertEqual(ERR_ADD_INVALID_PARAM);
}
done();
});
} catch (error) {
console.log(`${callbackName} ${tcNumber} exception caught: ${JSON.stringify(error)}`);
console.log(`${callbackName} ${tcNumber} should not reach here`);
expect().assertFail();
}
});
}
for (let i = 0; i < length; ++i) {
let tcNumber: any = (i + 1 + length) * 100;
tcNumber = tcNumber < 1000 ? `0${tcNumber}` : tcNumber;
/**
* @tc.name fuzzTest
* @tc.number FMS_fuzzTest_getinfomodule_0900 ~ FMS_fuzzTest_getinfomodule_1600
* @tc.desc Check whether the getFormsInfo interface can pass the fuzzy test (by Promise)
*/
it(`${promiseName}_${tcNumber}`, filterParameter, async (done) => {
const dataType = DATA_TYPE_LIST[i];
const bundleName = getFuzzData(dataType);
const moduleName = `com.test.module_name_${tcNumber}`;
console.log(`${promiseName} ${tcNumber} ${describeName} bundleName typeof: ${typeof bundleName}`);
console.log(`${promiseName} ${tcNumber} ${describeName} moduleName typeof: ${typeof moduleName}`);
try {
const data = await formHost.getFormsInfo(bundleName, moduleName);
console.log(`${promiseName} ${tcNumber} getFormsInfo data: ${JSON.stringify(data)}`);
console.log(`${promiseName} ${tcNumber} should not reach here`);
expect().assertFail();
} catch (error) {
console.log(`${promiseName} ${tcNumber} exception caught: ${JSON.stringify(error)}`);
if (`STRING` === dataType) {
expect(error.code).assertEqual(ERR_GET_BUNDLE_FAILED_CODE);
expect(error.message).assertEqual(ERR_GET_BUNDLE_FAILED);
} else {
expect(error.code).assertEqual(ERR_ADD_INVALID_PARAM_CODE);
expect(error.message).assertEqual(ERR_ADD_INVALID_PARAM);
}
done();
}
});
}
for (let i = 0; i < length; ++i) {
const tcNumber: any = (i + 1 + length * 2) * 100;
/**
* @tc.name fuzzTest
* @tc.number FMS_fuzzTest_getinfomodule_1700 ~ FMS_fuzzTest_getinfomodule_2400
* @tc.desc Check whether the getFormsInfo interface can pass the fuzzy test (by AsyncCallback)
*/
it(`${callbackName}_${tcNumber}`, filterParameter, async (done) => {
const dataType = DATA_TYPE_LIST[i];
const bundleName = `com.test.bundle_name_${tcNumber}`;
const moduleName = getFuzzData(dataType);
console.log(`${callbackName} ${tcNumber} bundleName typeof: ${typeof bundleName}`);
console.log(`${callbackName} ${tcNumber} moduleName typeof: ${typeof moduleName}`);
try {
formHost.getFormsInfo(bundleName, moduleName, (error, data) => {
console.log(`${callbackName} ${tcNumber} getFormsInfo data: ${JSON.stringify(data)} error: ${JSON.stringify(error)}`);
expect(data).assertUndefined();
if (`STRING` === dataType) {
expect(error.code).assertEqual(ERR_GET_BUNDLE_FAILED_CODE);
expect(error.message).assertEqual(ERR_GET_BUNDLE_FAILED);
} else {
expect(error.code).assertEqual(ERR_ADD_INVALID_PARAM_CODE);
expect(error.message).assertEqual(ERR_ADD_INVALID_PARAM);
}
done();
});
} catch (error) {
console.log(`${callbackName} ${tcNumber} exception caught: ${JSON.stringify(error)}`);
console.log(`${callbackName} ${tcNumber} should not reach here`);
expect().assertFail();
}
});
}
for (let i = 0; i < length; ++i) {
const tcNumber: any = (i + 1 + length * 3) * 100;
/**
* @tc.name fuzzTest
* @tc.number FMS_fuzzTest_getinfomodule_2500 ~ FMS_fuzzTest_getinfomodule_3200
* @tc.desc Check whether the getFormsInfo interface can pass the fuzzy test (by Promise)
*/
it(`${promiseName}_${tcNumber}`, filterParameter, async (done) => {
const dataType = DATA_TYPE_LIST[i];
const bundleName = `com.test.bundle_name_${tcNumber}`;
const moduleName = getFuzzData(dataType);
console.log(`${promiseName} ${tcNumber} ${describeName} bundleName typeof: ${typeof bundleName}`);
console.log(`${promiseName} ${tcNumber} ${describeName} moduleName typeof: ${typeof moduleName}`);
try {
const data = await formHost.getFormsInfo(bundleName, moduleName);
console.log(`${promiseName} ${tcNumber} getFormsInfo data: ${JSON.stringify(data)}`);
console.log(`${promiseName} ${tcNumber} should not reach here`);
expect().assertFail();
} catch (error) {
console.log(`${promiseName} ${tcNumber} exception caught: ${JSON.stringify(error)}`);
if (`STRING` === dataType) {
expect(error.code).assertEqual(ERR_GET_BUNDLE_FAILED_CODE);
expect(error.message).assertEqual(ERR_GET_BUNDLE_FAILED);
} else {
expect(error.code).assertEqual(ERR_ADD_INVALID_PARAM_CODE);
expect(error.message).assertEqual(ERR_ADD_INVALID_PARAM);
}
done();
}
});
}
})
};
/*
* 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 { castTempFormFuzzTest } from './CastTempFormFuzz.test.ets';
import { deleteFormFuzzTest } from './DeleteFormFuzz.test.ets';
import { disableFormsUpdateFuzzTest } from './DisableFormsUpdateFuzz.test.ets';
import { enableFormsUpdateFuzzTest } from './EnableFormsUpdateFuzz.test.ets';
import { getFormsInfoFuzzTest } from './GetFormsInfoFuzz.test.ets';
import { notifyInvisibleFormsFuzzTest } from './NotifyInvisibleFormsFuzz.test.ets';
import { notifyVisibleFormsFuzzTest } from './NotifyVisibleFormsFuzz.test.ets';
import { releaseFormFuzzTest } from './ReleaseFormFuzz.test.ets';
import { requestFormFuzzTest } from './RequestFormFuzz.test.ets';
import { setFormNextRefreshTimeFuzzTest } from './SetFormNextRefreshTimeFuzz.test.ets';
import { updateFormFuzzTest } from './UpdateFormFuzz.test.ets';
export default function testsuite() {
// FMS_fuzzTest_deleteform
deleteFormFuzzTest(`DeleteFormFuzzTest`, 0);
// FMS_fuzzTest_releaseform
releaseFormFuzzTest(`ReleaseFormFuzzTest`, 0);
// FMS_fuzzTest_casttempform
castTempFormFuzzTest(`CastTempFormFuzzTest`, 0);
// FMS_fuzzTest_invisible
notifyVisibleFormsFuzzTest(`NotifyVisibleFormsFuzzTest`, 0);
// FMS_fuzzTest_visible
notifyInvisibleFormsFuzzTest(`NotifyInvisibleFormsFuzzTest`, 0);
// FMS_fuzzTest_requestform
requestFormFuzzTest(`RequestFormFuzzTest`, 0);
// FMS_fuzzTest_updateform
updateFormFuzzTest(`UpdateFormFuzzTest`, 0);
// FMS_fuzzTest_setnexttime
setFormNextRefreshTimeFuzzTest(`SetFormNextRefreshTimeFuzzTest`, 0);
// FMS_fuzzTest_enable
enableFormsUpdateFuzzTest(`EnableFormsUpdateFuzzTest`, 0);
// FMS_fuzzTest_disable
disableFormsUpdateFuzzTest(`DisableFormsUpdateFuzzTest`, 0);
// FMS_fuzzTest_getinfobundle
// FMS_fuzzTest_getinfomodule
getFormsInfoFuzzTest(`GetFormsInfoFuzzTest`, 0);
}
/*
* 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 formHost from '@ohos.application.formHost';
import { describe, expect, it } from 'deccjsunit/index.ets';
import { DATA_TYPE_LIST, getFuzzData } from './getParam.ets';
export const notifyInvisibleFormsFuzzTest = (describeName, filterParameter) => {
const ERR_ADD_INVALID_PARAM_CODE = 7;
const ERR_ADD_INVALID_PARAM = `invalid input parameter during form operation`;
describe(`${describeName}`, () => {
const callbackName = `FMS_fuzzTest_invisible`;
const promiseName = `FMS_fuzzTest_invisible`;
const length = DATA_TYPE_LIST.length;
for (let i = 0; i < length; ++i) {
const tcNumber = `0${(i + 1) * 100}`;
/**
* @tc.name fuzzTest
* @tc.number FMS_fuzzTest_invisible_0100 ~ FMS_fuzzTest_invisible_0800
* @tc.desc Check whether the notifyInvisibleForms interface can pass the fuzzy test (by AsyncCallback)
*/
it(`${callbackName}_${tcNumber}`, filterParameter, async (done) => {
const dataType = DATA_TYPE_LIST[i];
const formIds = getFuzzData(dataType);
console.log(`${callbackName} ${tcNumber} formIds typeof: ${typeof formIds}`);
try {
formHost.notifyInvisibleForms(formIds, (error, data) => {
console.log(`${callbackName} ${tcNumber} notifyInvisibleForms data: ${JSON.stringify(data)} error: ${JSON.stringify(error)}`);
expect(data).assertUndefined();
expect(error.code).assertEqual(ERR_ADD_INVALID_PARAM_CODE);
expect(error.message).assertEqual(ERR_ADD_INVALID_PARAM);
done();
});
} catch (error) {
console.log(`${callbackName} ${tcNumber} exception caught: ${JSON.stringify(error)}`);
console.log(`${callbackName} ${tcNumber} should not reach here`);
expect().assertFail();
}
});
}
for (let i = 0; i < length; ++i) {
let tcNumber: any = (i + 1 + length) * 100;
tcNumber = tcNumber < 1000 ? `0${tcNumber}` : tcNumber;
/**
* @tc.name fuzzTest
* @tc.number FMS_fuzzTest_invisible_0900 ~ FMS_fuzzTest_invisible_1600
* @tc.desc Check whether the notifyInvisibleForms interface can pass the fuzzy test (by Promise)
*/
it(`${promiseName}_${tcNumber}`, filterParameter, async (done) => {
const dataType = DATA_TYPE_LIST[i];
const formIds = getFuzzData(dataType);
console.log(`${promiseName} ${tcNumber} ${describeName} formIds typeof: ${typeof formIds}`);
try {
const data = await formHost.notifyInvisibleForms(formIds);
console.log(`${promiseName} ${tcNumber} notifyInvisibleForms data: ${JSON.stringify(data)}`);
console.log(`${promiseName} ${tcNumber} should not reach here`);
expect().assertFail();
} catch (error) {
console.log(`${promiseName} ${tcNumber} exception caught: ${JSON.stringify(error)}`);
expect(error.code).assertEqual(ERR_ADD_INVALID_PARAM_CODE);
expect(error.message).assertEqual(ERR_ADD_INVALID_PARAM);
done();
}
});
}
});
};
/*
* 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 formHost from '@ohos.application.formHost';
import { describe, expect, it } from 'deccjsunit/index.ets';
import { DATA_TYPE_LIST, getFuzzData } from './getParam.ets';
export const notifyVisibleFormsFuzzTest = (describeName, filterParameter) => {
const ERR_ADD_INVALID_PARAM_CODE = 7;
const ERR_ADD_INVALID_PARAM = `invalid input parameter during form operation`;
describe(`${describeName}`, () => {
const callbackName = `FMS_fuzzTest_visible`;
const promiseName = `FMS_fuzzTest_visible`;
const length = DATA_TYPE_LIST.length;
for (let i = 0; i < length; ++i) {
const tcNumber = `0${(i + 1) * 100}`;
/**
* @tc.name fuzzTest
* @tc.number FMS_fuzzTest_visible_0100 ~ FMS_fuzzTest_visible_0800
* @tc.desc Check whether the notifyVisibleForms interface can pass the fuzzy test (by AsyncCallback)
*/
it(`${callbackName}_${tcNumber}`, filterParameter, async (done) => {
const dataType = DATA_TYPE_LIST[i];
const formIds = getFuzzData(dataType);
console.log(`${callbackName} ${tcNumber} formIds typeof: ${typeof formIds}`);
try {
formHost.notifyVisibleForms(formIds, (error, data) => {
console.log(`${callbackName} ${tcNumber} notifyVisibleForms data: ${JSON.stringify(data)} error: ${JSON.stringify(error)}`);
expect(data).assertUndefined();
expect(error.code).assertEqual(ERR_ADD_INVALID_PARAM_CODE);
expect(error.message).assertEqual(ERR_ADD_INVALID_PARAM);
done();
});
} catch (error) {
console.log(`${callbackName} ${tcNumber} exception caught: ${JSON.stringify(error)}`);
console.log(`${callbackName} ${tcNumber} should not reach here`);
expect().assertFail();
}
});
}
for (let i = 0; i < length; ++i) {
let tcNumber: any = (i + 1 + length) * 100;
tcNumber = tcNumber < 1000 ? `0${tcNumber}` : tcNumber;
/**
* @tc.name fuzzTest
* @tc.number FMS_fuzzTest_visible_0900 ~ FMS_fuzzTest_visible_1600
* @tc.desc Check whether the notifyVisibleForms interface can pass the fuzzy test (by Promise)
*/
it(`${promiseName}_${tcNumber}`, filterParameter, async (done) => {
const dataType = DATA_TYPE_LIST[i];
const formIds = getFuzzData(dataType);
console.log(`${promiseName} ${tcNumber} ${describeName} formIds typeof: ${typeof formIds}`);
try {
const data = await formHost.notifyVisibleForms(formIds);
console.log(`${promiseName} ${tcNumber} notifyVisibleForms data: ${JSON.stringify(data)}`);
console.log(`${promiseName} ${tcNumber} should not reach here`);
expect().assertFail();
} catch (error) {
console.log(`${promiseName} ${tcNumber} exception caught: ${JSON.stringify(error)}`);
expect(error.code).assertEqual(ERR_ADD_INVALID_PARAM_CODE);
expect(error.message).assertEqual(ERR_ADD_INVALID_PARAM);
done();
}
});
}
});
};
/*
* 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 formHost from '@ohos.application.formHost';
import { describe, expect, it } from 'deccjsunit/index.ets';
import { DATA_TYPE_LIST, getFuzzData } from './getParam.ets';
export const releaseFormFuzzTest = (describeName, filterParameter) => {
const ERR_COMMON_CODE = 1;
const ERR_COMMON = `internal error`;
const ERR_ADD_INVALID_PARAM_CODE = 7;
const ERR_ADD_INVALID_PARAM = `invalid input parameter during form operation`;
const ERR_NOT_EXIST_ID_CODE = 9;
const ERR_NOT_EXIST_ID = `the ID of the form to be operated does not exist`;
describe(`${describeName}`, () => {
const callbackName = `FMS_fuzzTest_releaseform`;
const promiseName = `FMS_fuzzTest_releaseform`;
const length = DATA_TYPE_LIST.length;
for (let i = 0; i < length; ++i) {
const tcNumber = `0${(i + 1) * 100}`;
/**
* @tc.name fuzzTest
* @tc.number FMS_fuzzTest_releaseform_0100 ~ FMS_fuzzTest_releaseform_0800
* @tc.desc Check whether the releaseForm interface can pass the fuzzy test (by AsyncCallback)
*/
it(`${callbackName}_${tcNumber}`, filterParameter, async (done) => {
const dataType = DATA_TYPE_LIST[i];
const formId = getFuzzData(dataType);
console.log(`${callbackName} ${tcNumber} formId typeof: ${typeof formId}`);
try {
formHost.releaseForm(formId, (error, data) => {
console.log(`${callbackName} ${tcNumber} releaseForm data: ${JSON.stringify(data)} error: ${JSON.stringify(error)}`);
expect(data).assertUndefined();
expect(error.code).assertEqual(ERR_ADD_INVALID_PARAM_CODE);
expect(error.message).assertEqual(ERR_ADD_INVALID_PARAM);
done();
});
} catch (error) {
console.log(`${callbackName} ${tcNumber} exception caught: ${JSON.stringify(error)}`);
console.log(`${callbackName} ${tcNumber} should not reach here`);
expect().assertFail();
}
});
}
for (let i = 0; i < length; ++i) {
let tcNumber: any = (i + 1 + length) * 100;
tcNumber = tcNumber < 1000 ? `0${tcNumber}` : tcNumber;
/**
* @tc.name fuzzTest
* @tc.number FMS_fuzzTest_releaseform_0900 ~ FMS_fuzzTest_releaseform_1600
* @tc.desc Check whether the releaseForm interface can pass the fuzzy test (by Promise)
*/
it(`${promiseName}_${tcNumber}`, filterParameter, async (done) => {
const dataType = DATA_TYPE_LIST[i];
const formId = getFuzzData(dataType);
console.log(`${promiseName} ${tcNumber} ${describeName} formId typeof: ${typeof formId}`);
try {
const data = await formHost.releaseForm(formId);
console.log(`${promiseName} ${tcNumber} releaseForm data: ${JSON.stringify(data)}`);
console.log(`${promiseName} ${tcNumber} should not reach here`);
expect().assertFail();
} catch (error) {
console.log(`${promiseName} ${tcNumber} exception caught: ${JSON.stringify(error)}`);
if (`STRING` === dataType) {
expect(error.code).assertEqual(ERR_ADD_INVALID_PARAM_CODE);
expect(error.message).assertEqual(ERR_ADD_INVALID_PARAM);
} else {
expect(error.code).assertEqual(ERR_ADD_INVALID_PARAM_CODE);
expect(error.message).assertEqual(ERR_ADD_INVALID_PARAM);
}
done();
}
});
}
for (let i = 0; i < length; ++i) {
const tcNumber: any = (i + 1 + length * 2) * 100;
/**
* @tc.name fuzzTest
* @tc.number FMS_fuzzTest_releaseform_1700 ~ FMS_fuzzTest_releaseform_2400
* @tc.desc Check whether the releaseForm interface can pass the fuzzy test (by AsyncCallback)
*/
it(`${callbackName}_${tcNumber}`, filterParameter, async (done) => {
const dataType = DATA_TYPE_LIST[i];
const formId = getFuzzData(dataType);
const isReleaseCache = true;
console.log(`${callbackName} ${tcNumber} formId typeof: ${typeof formId}`);
console.log(`${callbackName} ${tcNumber} isReleaseCache typeof: ${typeof isReleaseCache}`);
try {
formHost.releaseForm(formId, isReleaseCache, (error, data) => {
console.log(`${callbackName} ${tcNumber} releaseForm data: ${JSON.stringify(data)} error: ${JSON.stringify(error)}`);
expect(data).assertUndefined();
expect(error.code).assertEqual(ERR_ADD_INVALID_PARAM_CODE);
expect(error.message).assertEqual(ERR_ADD_INVALID_PARAM);
done();
});
} catch (error) {
console.log(`${callbackName} ${tcNumber} exception caught: ${JSON.stringify(error)}`);
console.log(`${callbackName} ${tcNumber} should not reach here`);
expect().assertFail();
}
});
}
for (let i = 0; i < length; ++i) {
const tcNumber: any = (i + 1 + length * 3) * 100;
/**
* @tc.name fuzzTest
* @tc.number FMS_fuzzTest_releaseform_2500 ~ FMS_fuzzTest_releaseform_3200
* @tc.desc Check whether the releaseForm interface can pass the fuzzy test (by Promise)
*/
it(`${promiseName}_${tcNumber}`, filterParameter, async (done) => {
const dataType = DATA_TYPE_LIST[i];
const formId = getFuzzData(dataType);
const isReleaseCache = true;
console.log(`${promiseName} ${tcNumber} ${describeName} formId typeof: ${typeof formId}`);
console.log(`${promiseName} ${tcNumber} ${describeName} isReleaseCache typeof: ${typeof isReleaseCache}`);
try {
const data = await formHost.releaseForm(formId, isReleaseCache);
console.log(`${promiseName} ${tcNumber} releaseForm data: ${JSON.stringify(data)}`);
console.log(`${promiseName} ${tcNumber} should not reach here`);
expect().assertFail();
} catch (error) {
console.log(`${promiseName} ${tcNumber} exception caught: ${JSON.stringify(error)}`);
if (`STRING` === dataType) {
expect(error.code).assertEqual(ERR_ADD_INVALID_PARAM_CODE);
expect(error.message).assertEqual(ERR_ADD_INVALID_PARAM);
} else {
expect(error.code).assertEqual(ERR_ADD_INVALID_PARAM_CODE);
expect(error.message).assertEqual(ERR_ADD_INVALID_PARAM);
}
done();
}
});
}
for (let i = 0; i < length; ++i) {
const tcNumber: any = (i + 1 + length * 4) * 100;
/**
* @tc.name fuzzTest
* @tc.number FMS_fuzzTest_releaseform_3300 ~ FMS_fuzzTest_releaseform_4000
* @tc.desc Check whether the releaseForm interface can pass the fuzzy test (by AsyncCallback)
*/
it(`${callbackName}_${tcNumber}`, filterParameter, async (done) => {
const dataType = DATA_TYPE_LIST[i];
const formId = `${tcNumber}`;
const isReleaseCache = getFuzzData(dataType);
console.log(`${callbackName} ${tcNumber} formId typeof: ${typeof formId}`);
console.log(`${callbackName} ${tcNumber} isReleaseCache typeof: ${typeof isReleaseCache}`);
try {
formHost.releaseForm(formId, isReleaseCache, (error, data) => {
console.log(`${callbackName} ${tcNumber} releaseForm data: ${JSON.stringify(data)} error: ${JSON.stringify(error)}`);
expect(data).assertUndefined();
if (`BOOLEAN` === dataType) {
expect(error.code).assertEqual(ERR_NOT_EXIST_ID_CODE);
expect(error.message).assertEqual(ERR_NOT_EXIST_ID);
} else {
expect(error.code).assertEqual(ERR_COMMON_CODE);
expect(error.message).assertEqual(ERR_COMMON);
}
done();
});
} catch (error) {
console.log(`${callbackName} ${tcNumber} exception caught: ${JSON.stringify(error)}`);
console.log(`${callbackName} ${tcNumber} should not reach here`);
expect().assertFail();
}
});
}
for (let i = 0; i < length; ++i) {
const tcNumber: any = (i + 1 + length * 5) * 100;
/**
* @tc.name fuzzTest
* @tc.number FMS_fuzzTest_releaseform_4100 ~ FMS_fuzzTest_releaseform_4800
* @tc.desc Check whether the releaseForm interface can pass the fuzzy test (by Promise)
*/
it(`${promiseName}_${tcNumber}`, filterParameter, async (done) => {
const dataType = DATA_TYPE_LIST[i];
const formId = `${tcNumber}`;
const isReleaseCache = getFuzzData(dataType);
console.log(`${promiseName} ${tcNumber} ${describeName} formId typeof: ${typeof formId}`);
console.log(`${promiseName} ${tcNumber} ${describeName} isReleaseCache typeof: ${typeof isReleaseCache}`);
try {
const data = await formHost.releaseForm(formId, isReleaseCache);
console.log(`${promiseName} ${tcNumber} releaseForm data: ${JSON.stringify(data)}`);
console.log(`${promiseName} ${tcNumber} should not reach here`);
expect().assertFail();
} catch (error) {
console.log(`${promiseName} ${tcNumber} exception caught: ${JSON.stringify(error)}`);
if (`BOOLEAN` === dataType) {
expect(error.code).assertEqual(ERR_NOT_EXIST_ID_CODE);
expect(error.message).assertEqual(ERR_NOT_EXIST_ID);
} else {
expect(error.code).assertEqual(ERR_COMMON_CODE);
expect(error.message).assertEqual(ERR_COMMON);
}
done();
}
});
}
});
};
/*
* 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 formHost from '@ohos.application.formHost';
import { describe, expect, it } from 'deccjsunit/index.ets';
import { DATA_TYPE_LIST, getFuzzData } from './getParam.ets';
export const requestFormFuzzTest = (describeName, filterParameter) => {
const ERR_ADD_INVALID_PARAM_CODE = 7;
const ERR_ADD_INVALID_PARAM = `invalid input parameter during form operation`;
describe(`${describeName}`, () => {
const callbackName = `FMS_fuzzTest_requestform`;
const promiseName = `FMS_fuzzTest_requestform`;
const length = DATA_TYPE_LIST.length;
for (let i = 0; i < length; ++i) {
const tcNumber = `0${(i + 1) * 100}`;
/**
* @tc.name fuzzTest
* @tc.number FMS_fuzzTest_requestform_0100 ~ FMS_fuzzTest_requestform_0800
* @tc.desc Check whether the requestForm interface can pass the fuzzy test (by AsyncCallback)
*/
it(`${callbackName}_${tcNumber}`, filterParameter, async (done) => {
const dataType = DATA_TYPE_LIST[i];
const formId = getFuzzData(dataType);
console.log(`${callbackName} ${tcNumber} formId typeof: ${typeof formId}`);
try {
formHost.requestForm(formId, (error, data) => {
console.log(`${callbackName} ${tcNumber} requestForm data: ${JSON.stringify(data)} error: ${JSON.stringify(error)}`);
expect(data).assertUndefined();
expect(error.code).assertEqual(ERR_ADD_INVALID_PARAM_CODE);
expect(error.message).assertEqual(ERR_ADD_INVALID_PARAM);
done();
});
} catch (error) {
console.log(`${callbackName} ${tcNumber} exception caught: ${JSON.stringify(error)}`);
console.log(`${callbackName} ${tcNumber} should not reach here`);
expect().assertFail();
}
});
}
for (let i = 0; i < length; ++i) {
let tcNumber: any = (i + 1 + length) * 100;
tcNumber = tcNumber < 1000 ? `0${tcNumber}` : tcNumber;
/**
* @tc.name fuzzTest
* @tc.number FMS_fuzzTest_requestform_0900 ~ FMS_fuzzTest_requestform_1600
* @tc.desc Check whether the requestForm interface can pass the fuzzy test (by Promise)
*/
it(`${promiseName}_${tcNumber}`, filterParameter, async (done) => {
const dataType = DATA_TYPE_LIST[i];
const formId = getFuzzData(dataType);
console.log(`${promiseName} ${tcNumber} ${describeName} formId typeof: ${typeof formId}`);
try {
const data = await formHost.requestForm(formId);
console.log(`${promiseName} ${tcNumber} requestForm data: ${JSON.stringify(data)}`);
console.log(`${promiseName} ${tcNumber} should not reach here`);
expect().assertFail();
} catch (error) {
console.log(`${promiseName} ${tcNumber} exception caught: ${JSON.stringify(error)}`);
expect(error.code).assertEqual(ERR_ADD_INVALID_PARAM_CODE);
expect(error.message).assertEqual(ERR_ADD_INVALID_PARAM);
done();
}
});
}
});
};
/*
* 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 formProvider from '@ohos.application.formProvider';
import { describe, expect, it } from 'deccjsunit/index.ets';
import { DATA_TYPE_LIST, getFuzzData } from './getParam.ets';
export const setFormNextRefreshTimeFuzzTest = (describeName, filterParameter) => {
const ERR_COMMON_CODE = 1;
const ERR_COMMON = `internal error`;
const ERR_ADD_INVALID_PARAM_CODE = 7;
const ERR_ADD_INVALID_PARAM = `invalid input parameter during form operation`;
const ERR_NOT_EXIST_ID_CODE = 9;
const ERR_NOT_EXIST_ID = `the ID of the form to be operated does not exist`;
describe(`${describeName}`, () => {
const callbackName = `FMS_fuzzTest_setnexttime`;
const promiseName = `FMS_fuzzTest_setnexttime`;
const length = DATA_TYPE_LIST.length;
for (let i = 0; i < length; ++i) {
const tcNumber = `0${(i + 1) * 100}`;
/**
* @tc.name fuzzTest
* @tc.number FMS_fuzzTest_setnexttime_0100 ~ FMS_fuzzTest_setnexttime_0800
* @tc.desc Check whether the setFormNextRefreshTime interface can pass the fuzzy test (by AsyncCallback)
*/
it(`${callbackName}_${tcNumber}`, filterParameter, async (done) => {
const dataType = DATA_TYPE_LIST[i];
const formId = getFuzzData(dataType);
const nextTime = 5;
console.log(`${callbackName} ${tcNumber} formId typeof: ${typeof formId}`);
console.log(`${callbackName} ${tcNumber} nextTime typeof: ${typeof nextTime}`);
try {
formProvider.setFormNextRefreshTime(formId, nextTime, (error, data) => {
console.log(`${callbackName} ${tcNumber} setFormNextRefreshTime data: ${JSON.stringify(data)} error: ${JSON.stringify(error)}`);
expect(data).assertUndefined();
expect(error.code).assertEqual(ERR_ADD_INVALID_PARAM_CODE);
expect(error.message).assertEqual(ERR_ADD_INVALID_PARAM);
done();
});
} catch (error) {
console.log(`${callbackName} ${tcNumber} exception caught: ${JSON.stringify(error)}`);
console.log(`${callbackName} ${tcNumber} should not reach here`);
expect().assertFail();
}
});
}
for (let i = 0; i < length; ++i) {
let tcNumber: any = (i + 1 + length) * 100;
tcNumber = tcNumber < 1000 ? `0${tcNumber}` : tcNumber;
/**
* @tc.name fuzzTest
* @tc.number FMS_fuzzTest_setnexttime_0900 ~ FMS_fuzzTest_setnexttime_1600
* @tc.desc Check whether the setFormNextRefreshTime interface can pass the fuzzy test (by Promise)
*/
it(`${promiseName}_${tcNumber}`, filterParameter, async (done) => {
const dataType = DATA_TYPE_LIST[i];
const formId = getFuzzData(dataType);
const nextTime = 5;
console.log(`${promiseName} ${tcNumber} formId typeof: ${typeof formId}`);
console.log(`${promiseName} ${tcNumber} nextTime typeof: ${typeof nextTime}`);
try {
const data = await formProvider.setFormNextRefreshTime(formId, nextTime);
console.log(`${promiseName} ${tcNumber} setFormNextRefreshTime data: ${JSON.stringify(data)}`);
console.log(`${promiseName} ${tcNumber} should not reach here`);
expect().assertFail();
} catch (error) {
console.log(`${promiseName} ${tcNumber} exception caught: ${JSON.stringify(error)}`);
expect(error.code).assertEqual(ERR_ADD_INVALID_PARAM_CODE);
expect(error.message).assertEqual(ERR_ADD_INVALID_PARAM);
done();
}
});
}
for (let i = 0; i < length; ++i) {
const tcNumber: any = (i + 1 + length * 2) * 100;
/**
* @tc.name fuzzTest
* @tc.number FMS_fuzzTest_setnexttime_1700 ~ FMS_fuzzTest_setnexttime_2400
* @tc.desc Check whether the setFormNextRefreshTime interface can pass the fuzzy test (by AsyncCallback)
*/
it(`${callbackName}_${tcNumber}`, filterParameter, async (done) => {
const dataType = DATA_TYPE_LIST[i];
const formId = `${tcNumber}`;
const nextTime = getFuzzData(dataType);
console.log(`${callbackName} ${tcNumber} formId typeof: ${typeof formId}`);
console.log(`${callbackName} ${tcNumber} nextTime typeof: ${typeof nextTime}`);
try {
formProvider.setFormNextRefreshTime(formId, nextTime, (error, data) => {
console.log(`${callbackName} ${tcNumber} setFormNextRefreshTime data: ${JSON.stringify(data)} error: ${JSON.stringify(error)}`);
expect(data).assertUndefined();
if (`NUMBER` === dataType) {
if (ERR_NOT_EXIST_ID_CODE === error.code) {
expect(error.message).assertEqual(ERR_NOT_EXIST_ID);
} else if (ERR_ADD_INVALID_PARAM_CODE === error.code) {
expect(error.message).assertEqual(ERR_ADD_INVALID_PARAM);
} else {
console.log(`${callbackName} ${tcNumber} should not reach here`);
expect().assertFail();
}
} else {
expect(error.code).assertEqual(ERR_COMMON_CODE);
expect(error.message).assertEqual(ERR_COMMON);
}
done();
});
} catch (error) {
console.log(`${callbackName} ${tcNumber} exception caught: ${JSON.stringify(error)}`);
console.log(`${callbackName} ${tcNumber} should not reach here`);
expect().assertFail();
}
});
}
for (let i = 0; i < length; ++i) {
const tcNumber: any = (i + 1 + length * 3) * 100;
/**
* @tc.name fuzzTest
* @tc.number FMS_fuzzTest_setnexttime_2500 ~ FMS_fuzzTest_setnexttime_3200
* @tc.desc Check whether the setFormNextRefreshTime interface can pass the fuzzy test (by Promise)
*/
it(`${promiseName}_${tcNumber}`, filterParameter, async (done) => {
const dataType = DATA_TYPE_LIST[i];
const formId = `${tcNumber}`;
const nextTime = getFuzzData(dataType);
console.log(`${promiseName} ${tcNumber} formId typeof: ${typeof formId}`);
console.log(`${promiseName} ${tcNumber} nextTime typeof: ${typeof nextTime}`);
try {
const data = await formProvider.setFormNextRefreshTime(formId, nextTime);
console.log(`${promiseName} ${tcNumber} setFormNextRefreshTime data: ${JSON.stringify(data)}`);
console.log(`${promiseName} ${tcNumber} should not reach here`);
expect().assertFail();
} catch (error) {
console.log(`${promiseName} ${tcNumber} exception caught: ${JSON.stringify(error)}`);
if (`NUMBER` === dataType) {
if (ERR_NOT_EXIST_ID_CODE === error.code) {
expect(error.message).assertEqual(ERR_NOT_EXIST_ID);
} else if (ERR_ADD_INVALID_PARAM_CODE === error.code) {
expect(error.message).assertEqual(ERR_ADD_INVALID_PARAM);
} else {
console.log(`${promiseName} ${tcNumber} should not reach here`);
expect().assertFail();
}
} else {
expect(error.code).assertEqual(ERR_COMMON_CODE);
expect(error.message).assertEqual(ERR_COMMON);
}
done();
}
});
}
});
};
/*
* 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 formProvider from '@ohos.application.formProvider';
import { describe, expect, it } from 'deccjsunit/index.ets';
import { DATA_TYPE_LIST, getFuzzData } from './getParam.ets';
export const updateFormFuzzTest = (describeName, filterParameter) => {
const ERR_ADD_INVALID_PARAM_CODE = 7;
const ERR_ADD_INVALID_PARAM = `invalid input parameter during form operation`;
describe(`${describeName}`, () => {
const callbackName = `FMS_fuzzTest_updateform`;
const promiseName = `FMS_fuzzTest_updateform`;
const length = DATA_TYPE_LIST.length;
for (let i = 0; i < length; ++i) {
const tcNumber = `0${(i + 1) * 100}`;
/**
* @tc.name fuzzTest
* @tc.number FMS_fuzzTest_updateform_0100 ~ FMS_fuzzTest_updateform_0800
* @tc.desc Check whether the updateForm interface can pass the fuzzy test (by AsyncCallback)
*/
it(`${callbackName}_${tcNumber}`, filterParameter, async (done) => {
const dataType = DATA_TYPE_LIST[i];
const formId = getFuzzData(dataType);
const formBindingData = {};
console.log(`${callbackName} ${tcNumber} formId typeof: ${typeof formId}`);
console.log(`${callbackName} ${tcNumber} formBindingData typeof: ${typeof formBindingData}`);
try {
formProvider.updateForm(formId, formBindingData, (error, data) => {
console.log(`${callbackName} ${tcNumber} updateForm data: ${JSON.stringify(data)} error: ${JSON.stringify(error)}`);
expect(data).assertUndefined();
expect(error.code).assertEqual(ERR_ADD_INVALID_PARAM_CODE);
expect(error.message).assertEqual(ERR_ADD_INVALID_PARAM);
done();
});
} catch (error) {
console.log(`${callbackName} ${tcNumber} exception caught: ${JSON.stringify(error)}`);
console.log(`${callbackName} ${tcNumber} should not reach here`);
expect().assertFail();
}
});
}
for (let i = 0; i < length; ++i) {
let tcNumber: any = (i + 1 + length) * 100;
tcNumber = tcNumber < 1000 ? `0${tcNumber}` : tcNumber;
/**
* @tc.name fuzzTest
* @tc.number FMS_fuzzTest_updateform_0900 ~ FMS_fuzzTest_updateform_1600
* @tc.desc Check whether the updateForm interface can pass the fuzzy test (by Promise)
*/
it(`${promiseName}_${tcNumber}`, filterParameter, async (done) => {
const dataType = DATA_TYPE_LIST[i];
const formId = getFuzzData(dataType);
const formBindingData = {};
console.log(`${promiseName} ${tcNumber} formId typeof: ${typeof formId}`);
console.log(`${promiseName} ${tcNumber} formBindingData typeof: ${typeof formBindingData}`);
try {
const data = await formProvider.updateForm(formId, formBindingData);
console.log(`${promiseName} ${tcNumber} updateForm data: ${JSON.stringify(data)}`);
console.log(`${promiseName} ${tcNumber} should not reach here`);
expect().assertFail();
} catch (error) {
console.log(`${promiseName} ${tcNumber} exception caught: ${JSON.stringify(error)}`);
expect(error.code).assertEqual(ERR_ADD_INVALID_PARAM_CODE);
expect(error.message).assertEqual(ERR_ADD_INVALID_PARAM);
done();
}
});
}
for (let i = 0; i < length; ++i) {
const tcNumber: any = (i + 1 + length * 2) * 100;
/**
* @tc.name fuzzTest
* @tc.number FMS_fuzzTest_updateform_1700 ~ FMS_fuzzTest_updateform_2400
* @tc.desc Check whether the updateForm interface can pass the fuzzy test (by AsyncCallback)
*/
it(`${callbackName}_${tcNumber}`, filterParameter, async (done) => {
const dataType = DATA_TYPE_LIST[i];
const formId = `${tcNumber}`;
const formBindingData = getFuzzData(dataType);
console.log(`${callbackName} ${tcNumber} formId typeof: ${typeof formId}`);
console.log(`${callbackName} ${tcNumber} formBindingData typeof: ${typeof formBindingData}`);
try {
formProvider.updateForm(formId, formBindingData, (error, data) => {
console.log(`${callbackName} ${tcNumber} updateForm data: ${JSON.stringify(data)} error: ${JSON.stringify(error)}`);
expect(data).assertUndefined();
expect(error.code).assertEqual(ERR_ADD_INVALID_PARAM_CODE);
expect(error.message).assertEqual(ERR_ADD_INVALID_PARAM);
done();
});
} catch (error) {
console.log(`${callbackName} ${tcNumber} exception caught: ${JSON.stringify(error)}`);
console.log(`${callbackName} ${tcNumber} should not reach here`);
expect().assertFail();
}
});
}
for (let i = 0; i < length; ++i) {
const tcNumber: any = (i + 1 + length * 3) * 100;
/**
* @tc.name fuzzTest
* @tc.number FMS_fuzzTest_updateform_2500 ~ FMS_fuzzTest_updateform_3200
* @tc.desc Check whether the updateForm interface can pass the fuzzy test (by Promise)
*/
it(`${promiseName}_${tcNumber}`, filterParameter, async (done) => {
const dataType = DATA_TYPE_LIST[i];
const formId = `${tcNumber}`;
const formBindingData = getFuzzData(dataType);
console.log(`${promiseName} ${tcNumber} formId typeof: ${typeof formId}`);
console.log(`${promiseName} ${tcNumber} formBindingData typeof: ${typeof formBindingData}`);
try {
const data = await formProvider.updateForm(formId, formBindingData);
console.log(`${promiseName} ${tcNumber} updateForm data: ${JSON.stringify(data)}`);
console.log(`${promiseName} ${tcNumber} should not reach here`);
expect().assertFail();
} catch (error) {
console.log(`${promiseName} ${tcNumber} exception caught: ${JSON.stringify(error)}`);
expect(error.code).assertEqual(ERR_ADD_INVALID_PARAM_CODE);
expect(error.message).assertEqual(ERR_ADD_INVALID_PARAM);
done();
}
});
}
});
};
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
export const REPEAT_COUNT = 2; export const REPEAT_COUNT = 2;
export const DATA_TYPE_LIST = ['ARRAY', 'NUMBER', 'BOOLEAN', 'FUNCTION', 'STRING', 'OBJECT', 'NULL', 'UNDEFINED'];
var RANDOM_BEGIN_POSITION = 0; var RANDOM_BEGIN_POSITION = 0;
var RANDOM_BEGIN_POSITION_A = 2; var RANDOM_BEGIN_POSITION_A = 2;
var STRING_RANDOM_LENGTH = 2064; var STRING_RANDOM_LENGTH = 2064;
...@@ -39,14 +41,13 @@ function getIntegerRandom(iStart, iEnd) { ...@@ -39,14 +41,13 @@ function getIntegerRandom(iStart, iEnd) {
} }
// return string random, the string length is: [0, 2064) // return string random, the string length is: [0, 2064)
const stringTest = function() { const stringTest = function () {
// string // string
var res = ""; var res = '';
// string length // string length
var iNumber = getIntegerRandom(RANDOM_BEGIN_POSITION, STRING_RANDOM_LENGTH); var iNumber = getIntegerRandom(RANDOM_BEGIN_POSITION, STRING_RANDOM_LENGTH);
for(var iAsciiToChar = RANDOM_BEGIN_POSITION; iAsciiToChar < iNumber ; iAsciiToChar ++) { for (var iAsciiToChar = RANDOM_BEGIN_POSITION; iAsciiToChar < iNumber; iAsciiToChar++) {
var iNumberString = getIntegerRandom(RANDOM_BEGIN_POSITION, RANDOM_BEGIN_POSITION_A); var iNumberString = getIntegerRandom(RANDOM_BEGIN_POSITION, RANDOM_BEGIN_POSITION_A);
switch (iNumberString) { switch (iNumberString) {
...@@ -63,51 +64,50 @@ const stringTest = function() { ...@@ -63,51 +64,50 @@ const stringTest = function() {
// get ascii [a-z] // get ascii [a-z]
iNumber = getIntegerRandom(STRING_RANDOM_LENGTH_E, STRING_RANDOM_LENGTH_F); iNumber = getIntegerRandom(STRING_RANDOM_LENGTH_E, STRING_RANDOM_LENGTH_F);
break; break;
} }
// from ascii to char // from ascii to char
var asciiToChar = String.fromCharCode(iNumber); var asciiToChar = String.fromCharCode(iNumber);
res += asciiToChar; res += asciiToChar;
} }
console.log("The stringTest of this fuzzTest random:" + res); console.log('The stringTest of this fuzzTest random:' + res);
return res; return res;
}; };
// return number random, the number length is: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER] // return number random, the number length is: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER]
const numberTest = function() { const numberTest = function () {
console.log("The numberTest of this fuzzTest random" ); const res = getIntegerRandom(Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER + 1);
return getIntegerRandom(Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER + 1); console.log('The numberTest of this fuzzTest random:' + res);
return res;
}; };
// return boolean random, the boolean value is: 0->(false), 1->(true) // return boolean random, the boolean value is: 0->(false), 1->(true)
const booleanTest = function() { const booleanTest = function () {
console.log("The booleanTest of this fuzzTest random" ); console.log('The booleanTest of this fuzzTest random');
return Boolean(getIntegerRandom(RANDOM_BEGIN_POSITION, BOOLEAN_RANDOM_LENGTH)); return Boolean(getIntegerRandom(RANDOM_BEGIN_POSITION, BOOLEAN_RANDOM_LENGTH));
}; };
// null // null
const nullTest = function() { const nullTest = function () {
console.log("The nullTest of this fuzzTest random" ); console.log('The nullTest of this fuzzTest random');
return null; return null;
}; };
// undefined // undefined
const undefinedTest = function() { const undefinedTest = function () {
console.log("The undefinedTest of this fuzzTest random" ); console.log('The undefinedTest of this fuzzTest random');
return undefined; return undefined;
}; };
// return array random, the array value is: string,number,bool // return array random, the array value is: string,number,bool
const arrayTest = function() { const arrayTest = function () {
var arrValue = []; var arrValue = [];
// array length // array length
var iNumber = getIntegerRandom(RANDOM_BEGIN_POSITION, ARRAY_RANDOM_LENGTH); var iNumber = getIntegerRandom(RANDOM_BEGIN_POSITION, ARRAY_RANDOM_LENGTH);
for(var iArrNumber = 0; iArrNumber < iNumber ; iArrNumber ++) { for (var iArrNumber = 0; iArrNumber < iNumber; iArrNumber++) {
// string,number,bool // string,number,bool
iNumber = getIntegerRandom(RANDOM_BEGIN_POSITION, ARRAY_RANDOM_TYPE_LENGTH); iNumber = getIntegerRandom(RANDOM_BEGIN_POSITION, ARRAY_RANDOM_TYPE_LENGTH);
switch(iNumber) { switch (iNumber) {
case 0: case 0:
arrValue[iArrNumber] = stringTest(); arrValue[iArrNumber] = stringTest();
break; break;
...@@ -121,29 +121,51 @@ const arrayTest = function() { ...@@ -121,29 +121,51 @@ const arrayTest = function() {
arrValue[iArrNumber] = ''; arrValue[iArrNumber] = '';
} }
} }
console.log("The arrayTest of this fuzzTest random:" + arrValue); console.log('The arrayTest of this fuzzTest random:' + arrValue);
return arrValue; return arrValue;
}; };
// return objectTest random, the objectTest value is: null, not null // return objectTest random, the objectTest value is: null, not null
const objectTest = function() { const objectTest = function () {
var objectA = {}; var objectA = {};
var objectb = {id : 'objectTest'}; var objectb = { id: 'objectTest' };
var objectB = Object.create(objectb); var objectB = Object.create(objectb);
console.log("The objectTest of this fuzzTest random" ); console.log('The objectTest of this fuzzTest random');
return getIntegerRandom(RANDOM_BEGIN_POSITION, OBJECT_RANDOM_LENGTH) ? objectA: objectB; return getIntegerRandom(RANDOM_BEGIN_POSITION, OBJECT_RANDOM_LENGTH) ? objectA : objectB;
}; };
// return functionTest random, the functionTest value is: null, not null // return functionTest random, the functionTest value is: null, not null
const functionTest = function() { const functionTest = function () {
var functionA = {}; var functionA = {};
var functionB = {id:"functionTest"}; var functionB = { id: 'functionTest' };
console.log("The functionTest of this fuzzTest random" ); console.log('The functionTest of this fuzzTest random');
return getIntegerRandom(RANDOM_BEGIN_POSITION, FUNCTION_RANDOM_LENGTH) ? functionA: functionB; return getIntegerRandom(RANDOM_BEGIN_POSITION, FUNCTION_RANDOM_LENGTH) ? functionA : functionB;
}; };
export { // return fuzz data
stringTest, numberTest, booleanTest, nullTest, undefinedTest, objectTest, arrayTest, functionTest const getFuzzData = (datatype: string) => {
} switch (datatype) {
\ No newline at end of file case 'ARRAY':
return arrayTest();
case 'BOOLEAN':
return booleanTest();
case 'FUNCTION':
return functionTest();
case 'NULL':
return nullTest();
case 'NUMBER':
return numberTest();
case 'OBJECT':
return objectTest();
case 'STRING':
return stringTest();
case 'UNDEFINED':
return undefinedTest();
default:
return stringTest();
}
};
export { getFuzzData, stringTest, numberTest, booleanTest, nullTest, undefinedTest, objectTest, arrayTest, functionTest };
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
"string": [ "string": [
{ {
"name": "entry_MainAbility", "name": "entry_MainAbility",
"value": "B_fms" "value": "formsttest"
}, },
{ {
"name": "mainability_description", "name": "description_mainability",
"value": "JS_Empty Ability" "value": "ETS_Empty Ability"
} }
] ]
} }
\ 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');
}
};
.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.
*/
require('./FormFuzzArray.test.js')
require('./FormFuzzBool.test.js')
require('./FormFuzzFunction.test.js')
require('./FormFuzzNull.test.js')
require('./FormFuzzNum.test.js')
require('./FormFuzzObject.test.js')
require('./FormFuzzString.test.js')
require('./FormFuzzUndefined.test.js')
{
"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
# 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("ActsFormsOneAndOneTest") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsFormsOneAndOneTest"
}
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"
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册