未验证 提交 b641e47f 编写于 作者: O openharmony_ci 提交者: Gitee

!7370 多模子系统用例整改

Merge pull request !7370 from 岳鑫瑶/cherry-pick-1675238942
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium' import { Hypium } from '@ohos/hypium'
import testsuite from '../test/ListMultimodalinput.test' import testsuite from '../test/List.test'
export default { export default {
onCreate() { onCreate() {
......
...@@ -15,8 +15,8 @@ ...@@ -15,8 +15,8 @@
import inputDevice from '@ohos.multimodalInput.inputDevice'; import inputDevice from '@ohos.multimodalInput.inputDevice';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestType, Size, Level } from '@ohos/hypium' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestType, Size, Level } from '@ohos/hypium'
export default function MultimodalInput_Device_test() { export default function InputDevice_test() {
describe('MultimodalInput_Device_test', function () { describe('InputDevice_test', function () {
const errCode = { const errCode = {
COMMON_PARAMETER_CODE: 401 COMMON_PARAMETER_CODE: 401
...@@ -30,8 +30,8 @@ export default function MultimodalInput_Device_test() { ...@@ -30,8 +30,8 @@ export default function MultimodalInput_Device_test() {
} }
// 参数正确,返回一个数组 // 参数正确,返回一个数组
it("InputDevice_getDeviceIds_test-01", 0, async function (done) { it("InputDevice_getDeviceIds_test_01", 0, async function (done) {
console.info(`InputDevice_getDeviceIds_test-01 enter`); console.info(`InputDevice_getDeviceIds_test_01 enter`);
try { try {
inputDevice.getDeviceIds((err, data) => { inputDevice.getDeviceIds((err, data) => {
if (err) { if (err) {
...@@ -39,53 +39,53 @@ export default function MultimodalInput_Device_test() { ...@@ -39,53 +39,53 @@ export default function MultimodalInput_Device_test() {
} else { } else {
expect(data).assertInstanceOf('Array'); expect(data).assertInstanceOf('Array');
} }
console.info(`InputDevice_getDeviceIds_test-01 exit`); console.info(`InputDevice_getDeviceIds_test_01 exit`);
done(); done();
}) })
} catch (error) { } catch (error) {
console.info(`InputDevice_getDeviceIds_test-01 error`); console.info(`InputDevice_getDeviceIds_test_01 error`);
expect(false).assertTrue(); expect(false).assertTrue();
done(); done();
} }
}) })
// 参数正确,判断一种或多种设备 // 参数正确,判断一种或多种设备
it("InputDevice_getDeviceIds_test-02", 0, async function (done) { it("InputDevice_getDeviceIds_test_02", 0, async function (done) {
console.info(`InputDevice_getDeviceIds_test-02 enter`); console.info(`InputDevice_getDeviceIds_test_02 enter`);
try { try {
inputDevice.getDeviceIds((err, data) => { inputDevice.getDeviceIds((err, data) => {
console.info(`InputDevice_getDeviceIds_test-02 err:${JSON.stringify(err)}`); console.info(`InputDevice_getDeviceIds_test_02 err:${JSON.stringify(err)}`);
console.info(`InputDevice_getDeviceIds_test-02 data:${JSON.stringify(data)}`); console.info(`InputDevice_getDeviceIds_test_02 data:${JSON.stringify(data)}`);
if (err) { if (err) {
expect(false).assertTrue(); expect(false).assertTrue();
} else { } else {
expect(data.length > 0).assertTrue(); expect(data.length > 0).assertTrue();
} }
console.info(`InputDevice_getDeviceIds_test-02 exit`); console.info(`InputDevice_getDeviceIds_test_02 exit`);
done(); done();
}) })
} catch (error) { } catch (error) {
console.info(`InputDevice_getDeviceIds_test-02 error`); console.info(`InputDevice_getDeviceIds_test_02 error`);
expect(false).assertTrue(); expect(false).assertTrue();
done(); done();
} }
}) })
// 参数类型错误 // 参数类型错误
it("InputDevice_getDeviceIds_test-03", 0, async function (done) { it("InputDevice_getDeviceIds_test_03", 0, async function (done) {
console.info(`InputDevice_getDeviceIds_test-03 enter`); console.info(`InputDevice_getDeviceIds_test_03 enter`);
try { try {
inputDevice.getDeviceIds(-1); inputDevice.getDeviceIds(-1);
} catch (error) { } catch (error) {
expect(error.message).assertEqual("GetDeviceIds: \"The first parameter type is wrong\""); expect(error.message).assertEqual("GetDeviceIds: \"The first parameter type is wrong\"");
} }
console.info(`InputDevice_getDeviceIds_test-03 exit`); console.info(`InputDevice_getDeviceIds_test_03 exit`);
done(); done();
}) })
// 参数数量错误 // 参数数量错误
it("InputDevice_getDeviceIds_test-04", 0, async function (done) { it("InputDevice_getDeviceIds_test_04", 0, async function (done) {
console.info(`InputDevice_getDeviceIds_test-04 enter`); console.info(`InputDevice_getDeviceIds_test_04 enter`);
try { try {
inputDevice.getDeviceIds(-1, (err, data) => { inputDevice.getDeviceIds(-1, (err, data) => {
console.info(data); console.info(data);
...@@ -93,25 +93,25 @@ export default function MultimodalInput_Device_test() { ...@@ -93,25 +93,25 @@ export default function MultimodalInput_Device_test() {
} catch (error) { } catch (error) {
expect(error.message).assertEqual("GetDeviceIds: \"too many parameters\""); expect(error.message).assertEqual("GetDeviceIds: \"too many parameters\"");
} }
console.info(`InputDevice_getDeviceIds_test-04 exit`); console.info(`InputDevice_getDeviceIds_test_04 exit`);
done(); done();
}) })
// 无效的设备id // 无效的设备id
it("InputDevice_getDevice_test-01", 0, async function (done) { it("InputDevice_getDevice_test_01", 0, async function (done) {
console.info(`InputDevice_getDevice_test-01 enter`); console.info(`InputDevice_getDevice_test_01 enter`);
try { try {
inputDevice.getDevice(-1, (err, data) => { inputDevice.getDevice(-1, (err, data) => {
if (err) { if (err) {
expect(false).assertTrue(); expect(false).assertTrue();
console.info(`InputDevice_getDevice_test-01 ${JSON.stringify(err)}`); console.info(`InputDevice_getDevice_test_01 ${JSON.stringify(err)}`);
} else { } else {
expect(JSON.stringify(data) !== "{}").assertTrue(); expect(JSON.stringify(data) !== "{}").assertTrue();
} }
console.info(`InputDevice_getDevice_test-01 exit`); console.info(`InputDevice_getDevice_test_01 exit`);
}) })
} catch (error) { } catch (error) {
console.info(`InputDevice_getDevice_test-01 error`); console.info(`InputDevice_getDevice_test_01 error`);
expect(false).assertTrue(); expect(false).assertTrue();
} finally { } finally {
done(); done();
...@@ -119,21 +119,21 @@ export default function MultimodalInput_Device_test() { ...@@ -119,21 +119,21 @@ export default function MultimodalInput_Device_test() {
}) })
// 参数正常,返回值正常 // 参数正常,返回值正常
it("InputDevice_getDevice_test-02", 0, async function (done) { it("InputDevice_getDevice_test_02", 0, async function (done) {
console.info(`InputDevice_getDevice_test-02 enter`); console.info(`InputDevice_getDevice_test_02 enter`);
try { try {
inputDevice.getDeviceIds(async (err, data) => { inputDevice.getDeviceIds(async (err, data) => {
console.info(`InputDevice_getDeviceIds_test-02 err:${JSON.stringify(err)}`); console.info(`InputDevice_getDeviceIds_test_02 err:${JSON.stringify(err)}`);
console.info(`InputDevice_getDeviceIds_test-02 data:${JSON.stringify(data)}`); console.info(`InputDevice_getDeviceIds_test_02 data:${JSON.stringify(data)}`);
if (err) { if (err) {
expect(false).assertTrue(); expect(false).assertTrue();
} else { } else {
for (let i = 0; i < data.length; i++) { for (let i = 0; i < data.length; i++) {
console.info(`InputDevice_getDevice_test-02 for`); console.info(`InputDevice_getDevice_test_02 for`);
await getDevicePromise(data[i]) await getDevicePromise(data[i])
} }
function getDevicePromise(data) { function getDevicePromise(data) {
console.info(`InputDevice_getDevice_test-02 getDevicePromise`) console.info(`InputDevice_getDevice_test_02 getDevicePromise`)
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
inputDevice.getDevice(data, (err, res) => { inputDevice.getDevice(data, (err, res) => {
console.info(`getDevice:data =${JSON.stringify(data)}`); console.info(`getDevice:data =${JSON.stringify(data)}`);
...@@ -150,7 +150,7 @@ export default function MultimodalInput_Device_test() { ...@@ -150,7 +150,7 @@ export default function MultimodalInput_Device_test() {
expect(res.phys).assertInstanceOf('String'); expect(res.phys).assertInstanceOf('String');
expect(res.uniq).assertInstanceOf('String'); expect(res.uniq).assertInstanceOf('String');
expect(res).assertInstanceOf('Object'); expect(res).assertInstanceOf('Object');
console.info(`InputDevice_getDevice_test-02 getDevice expect res`); console.info(`InputDevice_getDevice_test_02 getDevice expect res`);
for (let j = 0; j < res.axisRanges.length; j++) { for (let j = 0; j < res.axisRanges.length; j++) {
expect(res.axisRanges[j].source == 'keyboard' || res.axisRanges[j].source == 'mouse' expect(res.axisRanges[j].source == 'keyboard' || res.axisRanges[j].source == 'mouse'
|| res.axisRanges[j].source == 'touchpad' || res.axisRanges[j].source == 'touchscreen' || res.axisRanges[j].source == 'touchpad' || res.axisRanges[j].source == 'touchscreen'
...@@ -172,19 +172,19 @@ export default function MultimodalInput_Device_test() { ...@@ -172,19 +172,19 @@ export default function MultimodalInput_Device_test() {
}) })
} }
} }
console.info(`InputDevice_getDevice_test-02 exit`); console.info(`InputDevice_getDevice_test_02 exit`);
done(); done();
}); });
} catch (error) { } catch (error) {
console.info(`InputDevice_getDevice_test-02 error`); console.info(`InputDevice_getDevice_test_02 error`);
expect(false).assertTrue(); expect(false).assertTrue();
done(); done();
} }
}) })
// 参数正常,返回值正常 // 参数正常,返回值正常
it("InputDevice_supportKeys_test-01", 0, async function (done) { it("InputDevice_supportKeys_test_01", 0, async function (done) {
console.info(`InputDevice_supportKeys_test-01 enter`); console.info(`InputDevice_supportKeys_test_01 enter`);
try { try {
inputDevice.getDeviceIds((err, data) => { inputDevice.getDeviceIds((err, data) => {
if (err) { if (err) {
...@@ -196,19 +196,19 @@ export default function MultimodalInput_Device_test() { ...@@ -196,19 +196,19 @@ export default function MultimodalInput_Device_test() {
}); });
} }
} }
console.info(`InputDevice_supportKeys_test-01 exit`); console.info(`InputDevice_supportKeys_test_01 exit`);
done(); done();
}); });
} catch (error) { } catch (error) {
console.info(`InputDevice_supportKeys_test-01 error`); console.info(`InputDevice_supportKeys_test_01 error`);
expect(false).assertTrue(); expect(false).assertTrue();
done(); done();
} }
}) })
// 第二个参数异常 // 第二个参数异常
it("InputDevice_supportKeys_test-02", 0, async function (done) { it("InputDevice_supportKeys_test_02", 0, async function (done) {
console.info(`InputDevice_supportKeys_test-02 enter`); console.info(`InputDevice_supportKeys_test_02 enter`);
try { try {
inputDevice.supportKeys(0, 2022, (err, res) => { inputDevice.supportKeys(0, 2022, (err, res) => {
console.info(res); console.info(res);
...@@ -216,13 +216,13 @@ export default function MultimodalInput_Device_test() { ...@@ -216,13 +216,13 @@ export default function MultimodalInput_Device_test() {
} catch (error) { } catch (error) {
expect(error.message).assertEqual("Parameter error. The type of keys must be array."); expect(error.message).assertEqual("Parameter error. The type of keys must be array.");
} }
console.info(`InputDevice_supportKeys_test-02 exit`); console.info(`InputDevice_supportKeys_test_02 exit`);
done(); done();
}) })
// 参数正常 // 参数正常
it("InputDevice_getKeyboardType_test-01", 0, async function (done) { it("InputDevice_getKeyboardType_test_01", 0, async function (done) {
console.info(`InputDevice_getKeyboardType_test-01 enter`); console.info(`InputDevice_getKeyboardType_test_01 enter`);
try { try {
inputDevice.getDeviceIds((err, data) => { inputDevice.getDeviceIds((err, data) => {
if (err) { if (err) {
...@@ -234,31 +234,31 @@ export default function MultimodalInput_Device_test() { ...@@ -234,31 +234,31 @@ export default function MultimodalInput_Device_test() {
}); });
} }
} }
console.info(`InputDevice_getKeyboardType_test-01 exit`); console.info(`InputDevice_getKeyboardType_test_01 exit`);
done(); done();
}); });
} catch (error) { } catch (error) {
console.info(`InputDevice_getKeyboardType_test-01 error`); console.info(`InputDevice_getKeyboardType_test_01 error`);
expect(false).assertTrue(); expect(false).assertTrue();
done(); done();
} }
}) })
//参数异常 //参数异常
it("InputDevice_getKeyboardType_test-02", 0, async function (done) { it("InputDevice_getKeyboardType_test_02", 0, async function (done) {
console.info(`InputDevice_getKeyboardType_test-02 enter`); console.info(`InputDevice_getKeyboardType_test_02 enter`);
try { try {
inputDevice.getKeyboardType(-1); inputDevice.getKeyboardType(-1);
} catch (error) { } catch (error) {
expect(error.message).assertEqual("Invalid input device id"); expect(error.message).assertEqual("Invalid input device id");
} }
console.info(`InputDevice_getKeyboardType_test-02 exit`); console.info(`InputDevice_getKeyboardType_test_02 exit`);
done(); done();
}); });
// 参数正常 // 参数正常
it("InputDevice_getKeyboardType_test-03", 0, async function (done) { it("InputDevice_getKeyboardType_test_03", 0, async function (done) {
console.info(`InputDevice_getKeyboardType_test-03 enter`); console.info(`InputDevice_getKeyboardType_test_03 enter`);
try { try {
inputDevice.getDeviceIds((err, data) => { inputDevice.getDeviceIds((err, data) => {
if (err) { if (err) {
...@@ -268,16 +268,16 @@ export default function MultimodalInput_Device_test() { ...@@ -268,16 +268,16 @@ export default function MultimodalInput_Device_test() {
inputDevice.getKeyboardType(data[i]).then((res) => { inputDevice.getKeyboardType(data[i]).then((res) => {
expect(res).assertInstanceOf('Number'); expect(res).assertInstanceOf('Number');
}).catch((err) => { }).catch((err) => {
console.info(`InputDevice_getKeyboardType_test-03 failed, err=${JSON.stringify(err)}`); console.info(`InputDevice_getKeyboardType_test_03 failed, err=${JSON.stringify(err)}`);
expect(false).assertTrue(); expect(false).assertTrue();
}); });
} }
} }
console.info(`InputDevice_getKeyboardType_test-03 exit`); console.info(`InputDevice_getKeyboardType_test_03 exit`);
done(); done();
}); });
} catch (error) { } catch (error) {
console.info(`InputDevice_getKeyboardType_test-03 error`); console.info(`InputDevice_getKeyboardType_test_03 error`);
expect(false).assertTrue(); expect(false).assertTrue();
done(); done();
} }
...@@ -461,7 +461,7 @@ export default function MultimodalInput_Device_test() { ...@@ -461,7 +461,7 @@ export default function MultimodalInput_Device_test() {
* @tc.name MultimodalInputDevice_GetDeviceList_test * @tc.name MultimodalInputDevice_GetDeviceList_test
* @tc.desc inputdevice interface getDeviceList test * @tc.desc inputdevice interface getDeviceList test
*/ */
it("InputDevice_getDeviceList_test-01", 0, async function (done) { it("InputDevice_getDeviceList_test_01", 0, async function (done) {
console.info(`InputDevice_getDeviceList_async_test enter`); console.info(`InputDevice_getDeviceList_async_test enter`);
try { try {
inputDevice.getDeviceList((err, data) => { inputDevice.getDeviceList((err, data) => {
...@@ -485,7 +485,7 @@ export default function MultimodalInput_Device_test() { ...@@ -485,7 +485,7 @@ export default function MultimodalInput_Device_test() {
* @tc.name MultimodalInputDevice_GetDeviceList_test * @tc.name MultimodalInputDevice_GetDeviceList_test
* @tc.desc inputdevice interface getDeviceList test * @tc.desc inputdevice interface getDeviceList test
*/ */
it("InputDevice_getDeviceList_test-02", 0, async function (done) { it("InputDevice_getDeviceList_test_02", 0, async function (done) {
console.info(`InputDevice_getDeviceList_promise_test enter`); console.info(`InputDevice_getDeviceList_promise_test enter`);
try { try {
inputDevice.getDeviceList().then(data => { inputDevice.getDeviceList().then(data => {
...@@ -505,7 +505,7 @@ export default function MultimodalInput_Device_test() { ...@@ -505,7 +505,7 @@ export default function MultimodalInput_Device_test() {
* @tc.name MultimodalInputDevice_GetDeviceInfo_test * @tc.name MultimodalInputDevice_GetDeviceInfo_test
* @tc.desc inputdevice interface getDeviceInfo test * @tc.desc inputdevice interface getDeviceInfo test
*/ */
it("InputDevice_getDeviceInfo_test-01", 0, async function (done) { it("InputDevice_getDeviceInfo_test_01", 0, async function (done) {
console.info(`InputDevice_getDeviceInfo_async_test enter`); console.info(`InputDevice_getDeviceInfo_async_test enter`);
try { try {
await inputDevice.getDeviceList().then((data) => { await inputDevice.getDeviceList().then((data) => {
...@@ -557,12 +557,12 @@ export default function MultimodalInput_Device_test() { ...@@ -557,12 +557,12 @@ export default function MultimodalInput_Device_test() {
done() done()
}) })
} catch (err) { } catch (err) {
console.info(`InputDevice_getDeviceInfo_test-01 inputDevice.getDeviceInfo ${JSON.stringify(err)}`); console.info(`InputDevice_getDeviceInfo_test_01 inputDevice.getDeviceInfo ${JSON.stringify(err)}`);
expect(false).assertTrue(); expect(false).assertTrue();
} }
}) })
} catch (err) { } catch (err) {
console.info(`InputDevice_getDeviceInfo_test-01 inputDevice.getDeviceList ${JSON.stringify(err)}`); console.info(`InputDevice_getDeviceInfo_test_01 inputDevice.getDeviceList ${JSON.stringify(err)}`);
expect(false).assertTrue(); expect(false).assertTrue();
} }
console.info(`InputDevice_getDeviceInfo_async_test exit`); console.info(`InputDevice_getDeviceInfo_async_test exit`);
...@@ -573,7 +573,7 @@ export default function MultimodalInput_Device_test() { ...@@ -573,7 +573,7 @@ export default function MultimodalInput_Device_test() {
* @tc.name MultimodalInputDevice_GetDeviceInfo_test * @tc.name MultimodalInputDevice_GetDeviceInfo_test
* @tc.desc inputdevice interface getDeviceInfo test * @tc.desc inputdevice interface getDeviceInfo test
*/ */
it("InputDevice_getDeviceInfo_test-02", 0, async function (done) { it("InputDevice_getDeviceInfo_test_02", 0, async function (done) {
console.info(`InputDevice_getDeviceInfo_promise_test enter`); console.info(`InputDevice_getDeviceInfo_promise_test enter`);
try { try {
inputDevice.getDeviceList().then((data) => { inputDevice.getDeviceList().then((data) => {
......
...@@ -13,11 +13,11 @@ ...@@ -13,11 +13,11 @@
* limitations under the License. * limitations under the License.
*/ */
import MultimodalInput_Device_test from './InputDevice.test.js' import InputDevice_test from './InputDevice.test.js'
import MultimodalInput_KeyCode_test from './MultimodalInput_KeyCode.test.js' import MultimodalInput_KeyCode_test from './MultimodalInput_KeyCode.test.js'
import MultimodalInput_Pointer_test from './Pointer.test.js' import Pointer_test from './Pointer.test.js'
export default function testsuite() { export default function testsuite() {
MultimodalInput_Device_test() InputDevice_test()
MultimodalInput_KeyCode_test() MultimodalInput_KeyCode_test()
MultimodalInput_Pointer_test() Pointer_test()
} }
\ No newline at end of file
...@@ -16,8 +16,8 @@ ...@@ -16,8 +16,8 @@
import pointer from '@ohos.multimodalInput.pointer' import pointer from '@ohos.multimodalInput.pointer'
import window from '@ohos.window' import window from '@ohos.window'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestType, Size, Level } from '@ohos/hypium' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestType, Size, Level } from '@ohos/hypium'
export default function MultimodalInput_Pointer_test() { export default function Pointer_test() {
describe('MultimodalInput_Pointer_test', function () { describe('Pointer_test', function () {
const errCode = { const errCode = {
COMMON_PARAMETER_CODE: 401 COMMON_PARAMETER_CODE: 401
......
...@@ -24,7 +24,7 @@ import { Touch, TouchEvent } from '@ohos.multimodalInput.touchEvent' ...@@ -24,7 +24,7 @@ import { Touch, TouchEvent } from '@ohos.multimodalInput.touchEvent'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestType, Size, Level } from '@ohos/hypium' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestType, Size, Level } from '@ohos/hypium'
export default function MultimodalInputEventTypeTest() { export default function MultimodalInputEventTypeTest() {
describe('MultimodalInput_test', function () { describe('MultimodalInputEventTypeTest', function () {
it('MultimodalInput_KeyEventTypeTest_0010', 0, function () { it('MultimodalInput_KeyEventTypeTest_0010', 0, function () {
console.info(`MultimodalInput_KeyEventTypeTest_0010 enter`); console.info(`MultimodalInput_KeyEventTypeTest_0010 enter`);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册