提交 d7d899b3 编写于 作者: M mayunteng_1

Add multimodal input xts cases

Signed-off-by: Nmayunteng_1 <mayunteng@huawei.com>
Change-Id: I9651434d5f16392d75d7ea61f0a47f36fbe41aa8
上级 63fc2591
......@@ -18,6 +18,17 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestT
export default function MultimodalInput_Device_test() {
describe('MultimodalInput_Device_test', function () {
const errCode = {
COMMON_PARAMETER_CODE : 401
}
const errMsg = {
PARAMETER_COUNT_MSG : `Parameter count error`,
PARAMETER_TYPE_MSG : `Parameter error. The type of type must be string.`,
PARAMETER_DEVICEID_TYPE_MSG : `Parameter error. The type of deviceId must be number.`,
PARAMETER_LISTENER_TYPE_MSG : `Parameter error. The type of listener must be function.`,
PARAMETER_CALLBACK_TYPE_MSG : `Parameter error. The type of callback must be function.`
}
// 参数正确,返回一个数组
it('inputDevice::getDeviceIds_test-01', 0, function () {
console.info(`inputDevice::getDeviceIds_test-01 enter`);
......@@ -211,7 +222,7 @@ export default function MultimodalInput_Device_test() {
try {
inputDevice.getKeyboardType(-1);
} catch (error) {
expect(error.message).assertEqual("getKeyboardType: \"The second parameter type is wrong\"");
expect(error.message).assertEqual("Invalid input device id");
}
console.info(`inputDevice::getKeyboardType_test-02 exit`);
});
......@@ -569,5 +580,220 @@ export default function MultimodalInput_Device_test() {
}
console.info(`inputDevice::getDeviceInfo_promise_test exit`);
})
/**
* @tc.number MultimodalInputDevice_js_0150
* @tc.name MultimodalInputDevice_GetkeyboardType_Exception_test_01
* @tc.desc inputdevice interface getKeyboardType exception test
*/
it("MultimodalInputDevice_GetkeyboardType_Exception_test_01", 0, function () {
console.info(`MultimodalInputDevice_GetkeyboardType_Exception_test_01 enter`);
try {
inputDevice.getKeyboardType();
} catch (error) {
console.info(`GetkeyboardType_Exception_test_01: ${JSON.stringify(error, [`code`, `message`])}`);
expect(error.code).assertEqual(errCode.COMMON_PARAMETER_CODE);
expect(error.message).assertEqual(errMsg.PARAMETER_COUNT_MSG);
}
console.info("MultimodalInputDevice_GetkeyboardType_Exception_test_01 exit");
})
/**
* @tc.number MultimodalInputDevice_js_0160
* @tc.name MultimodalInputDevice_GetkeyboardType_Exception_test_02
* @tc.desc inputdevice interface getKeyboardType exception test
*/
it("MultimodalInputDevice_GetkeyboardType_Exception_test_02", 0, function () {
console.info("MultimodalInputDevice_GetkeyboardType_Exception_test_02 enter");
try {
inputDevice.getKeyboardType(`id`).then((data) => {
console.info(`GetkeyboardType_Exception_test_02 success`);
expect(true).assertTrue();
}, (error) => {
console.info(`GetkeyboardType_Exception_test_02 failed, err=${JSON.stringify(error)}`);
expect(false).assertTrue();
});
} catch (error) {
console.info(`GetkeyboardType_Exception_test_02: ${JSON.stringify(error, [`code`, `message`])}`);
expect(error.code).assertEqual(errCode.COMMON_PARAMETER_CODE);
expect(error.message).assertEqual(errMsg.PARAMETER_DEVICEID_TYPE_MSG);
}
console.info("MultimodalInputDevice_GetkeyboardType_Exception_test_02 exit");
})
/**
* @tc.number MultimodalInputDevice_js_0170
* @tc.name MultimodalInputDevice_SupportKeys_Exception_test_01
* @tc.desc inputdevice interface supportKeys exception test
*/
it("MultimodalInputDevice_SupportKeys_Exception_test_01", 0, function () {
console.info("MultimodalInputDevice_SupportKeys_Exception_test_01 enter");
try {
inputDevice.supportKeys((error, data) => {
if (error) {
console.info(`SupportKeys_Exception_test_01 failed, err=${JSON.stringify(error)}`);
expect(false).assertTrue();
} else {
console.info(`SupportKeys_Exception_test_01 success`);
expect(true).assertTrue();
}
})
} catch (error) {
console.info(`SupportKeys_Exception_test_01: ${JSON.stringify(error, [`code`, `message`])}`);
expect(error.code).assertEqual(errCode.COMMON_PARAMETER_CODE);
expect(error.message).assertEqual(errMsg.PARAMETER_COUNT_MSG);
}
console.info("MultimodalInputDevice_SupportKeys_Exception_test_01 exit");
})
/**
* @tc.number MultimodalInputDevice_js_0180
* @tc.name MultimodalInputDevice_SupportKeys_Exception_test_02
* @tc.desc inputdevice interface supportKeys exception test
*/
it("MultimodalInputDevice_SupportKeys_Exception_test_02", 0, function () {
console.info("MultimodalInputDevice_SupportKeys_Exception_test_02 enter");
try {
inputDevice.supportKeys(`id`, [17, 22, 2055], (error, data) => {
if (error) {
console.info(`SupportKeys_Exception_test_02 failed, err=${JSON.stringify(error)}`);
expect(false).assertTrue();
} else {
console.info(`SupportKeys_Exception_test_02 success`);
expect(true).assertTrue();
}
})
} catch (error) {
console.info(`SupportKeys_Exception_test_02: ${JSON.stringify(error, [`code`, `message`])}`);
expect(error.code).assertEqual(errCode.COMMON_PARAMETER_CODE);
expect(error.message).assertEqual(errMsg.PARAMETER_DEVICEID_TYPE_MSG);
}
console.info("MultimodalInputDevice_SupportKeys_Exception_test_02 exit");
})
/**
* @tc.number MultimodalInputDevice_js_0190
* @tc.name MultimodalInputDevice_GetDeviceInfo_Exception_test_01
* @tc.desc inputdevice interface getDeviceInfo exception test
*/
it("MultimodalInputDevice_GetDeviceInfo_Exception_test_01", 0, function () {
console.info("MultimodalInputDevice_GetDeviceInfo_Exception_test_01 enter");
try {
inputDevice.getDeviceInfo();
} catch (error) {
console.info(`GetDeviceInfo_Exception_test_01: ${JSON.stringify(error, [`code`, `message`])}`);
expect(error.code).assertEqual(errCode.COMMON_PARAMETER_CODE);
expect(error.message).assertEqual(errMsg.PARAMETER_COUNT_MSG);
}
console.info("MultimodalInputDevice_GetDeviceInfo_Exception_test_01 exit");
})
/**
* @tc.number MultimodalInputDevice_js_0200
* @tc.name MultimodalInputDevice_GetDeviceInfo_Exception_test_02
* @tc.desc inputdevice interface getDeviceInfo exception test
*/
it("MultimodalInputDevice_GetDeviceInfo_Exception_test_02", 0, function () {
console.info("MultimodalInputDevice_GetDeviceInfo_Exception_test_02 enter");
try {
inputDevice.getDeviceList().then((data) => {
expect(data).assertInstanceOf('Array');
if (data.length <= 0) {
return;
}
try {
inputDevice.getDeviceInfo(`data[0]`).then((res) => {
console.info(`GetDeviceInfo_Exception_test_02 success`);
expect(true).assertTrue();
}).catch(error => {
console.info(`GetDeviceInfo_Exception_test_02 failed, err=${JSON.stringify(error)}`);
expect(false).assertTrue();
});
} catch (error) {
console.info(`GetDeviceInfo_Exception_test_02: ${JSON.stringify(error, [`code`, `message`])}`);
expect(error.code).assertEqual(errCode.COMMON_PARAMETER_CODE);
expect(error.message).assertEqual(errMsg.PARAMETER_DEVICEID_TYPE_MSG);
}
})
} catch (error) {
expect(false).assertTrue();
}
console.info("MultimodalInputDevice_GetDeviceInfo_Exception_test_02 exit");
})
/**
* @tc.number MultimodalInputDevice_js_0210
* @tc.name MultimodalInputDevice_GetDeviceList_Exception_test
* @tc.desc inputdevice interface getDeviceList exception test
*/
it("MultimodalInputDevice_GetDeviceList_Exception_test", 0, function () {
console.info("MultimodalInputDevice_GetDeviceList_Exception_test enter");
try {
inputDevice.getDeviceList(null);
} catch (error) {
console.info(`GetDeviceList_Exception_test_01: ${JSON.stringify(error, [`code`, `message`])}`);
expect(error.code).assertEqual(errCode.COMMON_PARAMETER_CODE);
expect(error.message).assertEqual(errMsg.PARAMETER_CALLBACK_TYPE_MSG);
}
console.info(`MultimodalInputDevice_GetDeviceList_Exception_test exit`);
})
/**
* @tc.number MultimodalInputDevice_js_0220
* @tc.name MultimodalInputDevice_On_Exception_test
* @tc.desc inputdevice interface on test
*/
it("MultimodalInputDevice_On_Exception_test", 0, function () {
console.info(`MultimodalInputDevice_On_Exception_test enter`);
try {
inputDevice.on();
} catch (error) {
console.info(`On_Exception_test: ${JSON.stringify(error, [`code`, `message`])}`);
expect(error.code).assertEqual(errCode.COMMON_PARAMETER_CODE);
expect(error.message).assertEqual(errMsg.PARAMETER_COUNT_MSG);
}
try {
inputDevice.on(-1, (data) => {
if (error) {
console.info(`On_Exception_test failed, err=${JSON.stringify(error)}`);
expect(false).assertTrue();
} else {
console.info(`On_Exception_test success`);
expect(true).assertTrue();
}
});
} catch (error) {
console.info(`On_Exception_test: ${JSON.stringify(error, [`code`, `message`])}`);
expect(error.code).assertEqual(errCode.COMMON_PARAMETER_CODE);
expect(error.message).assertEqual(errMsg.PARAMETER_TYPE_MSG);
}
console.info(`MultimodalInputDevice_On_Exception_test exit`);
})
/**
* @tc.number MultimodalInputDevice_js_0230
* @tc.name MultimodalInputDevice_Off_Exception_test
* @tc.desc inputdevice interface off test
*/
it("MultimodalInputDevice_Off_Exception_test", 0, function () {
console.info(`MultimodalInputDevice_Off_Exception_test enter`);
try {
inputDevice.off();
} catch (error) {
console.info(`Off_Exception_test: ${JSON.stringify(error, [`code`, `message`])}`);
expect(error.code).assertEqual(errCode.COMMON_PARAMETER_CODE);
expect(error.message).assertEqual(errMsg.PARAMETER_COUNT_MSG);
}
try {
inputDevice.off('change', null);
} catch (error) {
console.info(`Off_Exception_test: ${JSON.stringify(error, [`code`, `message`])}`);
expect(error.code).assertEqual(errCode.COMMON_PARAMETER_CODE);
expect(error.message).assertEqual(errMsg.PARAMETER_LISTENER_TYPE_MSG);
}
console.info(`MultimodalInputDevice_Off_Exception_test exit`);
})
})
}
......@@ -19,6 +19,18 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestT
export default function MultimodalInput_Pointer_test() {
describe('MultimodalInput_Pointer_test', function () {
const errCode = {
COMMON_PARAMETER_CODE : 401
}
const errMsg = {
PARAMETER_COUNT_MSG : `Parameter count error`,
PARAMETER_TYPE_MSG : `Parameter error. The type of type must be string.`,
PARAMETER_VISIBLE_TYPE_MSG : `Parameter error. The type of visible must be boolean.`,
PARAMETER_SPEED_TYPE_MSG : `Parameter error. The type of speed must be number.`,
PARAMETER_WINDOWID_TYPE_MSG : `Parameter error. The type of windowId must be number.`,
PARAMETER_CALLBACK_TYPE_MSG : `Parameter error. The type of callback must be function.`
}
it('MultimodalInput_Pointer_test::PointerVisibleTest_001', 0, function () {
console.info(`MultimodalInput_Pointer_test::SetPointerVisibleTest_001 enter`);
try {
......@@ -81,6 +93,52 @@ export default function MultimodalInput_Pointer_test() {
console.info(`MultimodalInput_Pointer_test::PointerVisibleTest_002 exit`);
})
it('MultimodalInput_Pointer_test::PointerSpeedTest_001', 0, function () {
console.info(`MultimodalInput_Pointer_test::PointerSpeedTest_001 enter`);
var callback = function (err, data) {
if (err) {
console.info(`MultimodalInput_Pointer_test::SetPointerSpeedTest_001 failed, err=${JSON.stringify(err)}`);
expect(false).assertTrue();
} else {
console.info(`MultimodalInput_Pointer_test::SetPointerSpeedTest_001 success`);
expect(true).assertTrue();
}
};
pointer.setPointerSpeed(10, callback);
pointer.getPointerSpeed().then((data) => {
console.info(`MultimodalInput_Pointer_test::GetPointerSpeedTest_001 success, data=${JSON.stringify(data)}`);
expect(data == 10).assertTrue();
}, (err) => {
console.info(`MultimodalInput_Pointer_test::GetPointerSpeedTest_001 failed, err=${JSON.stringify(err)}`);
expect(false).assertTrue();
});
console.info(`MultimodalInput_Pointer_test::PointerSpeedTest_001 exit`);
})
it('MultimodalInput_Pointer_test::PointerSpeedTest_002', 0, function () {
console.info(`MultimodalInput_Pointer_test::PointerSpeedTest_002 enter`);
pointer.setPointerSpeed(10).then(data => {
console.info(`MultimodalInput_Pointer_test::SetPointerSpeedTest_002 success, data=${JSON.stringify(data)}`);
expect(true).assertTrue();
}, (err) => {
console.info(`MultimodalInput_Pointer_test::SetPointerSpeedTest_002 failed, err=${JSON.stringify(err)}`);
expect(false).assertTrue();
});
var callback = function (err, data) {
if (err) {
console.info(`MultimodalInput_Pointer_test::GetPointerSpeedTest_002 failed, err=${JSON.stringify(err)}`);
expect(false).assertTrue();
} else {
console.info(`MultimodalInput_Pointer_test::GetPointerSpeedTest_002 success, data=${JSON.stringify(data)}`);
expect(data == 10).assertTrue();
}
};
pointer.getPointerSpeed(callback);
console.info(`MultimodalInput_Pointer_test::PointerSpeedTest_002 exit`);
})
it('MultimodalInput_Pointer_test::SetPointerStyle_001', 0, function () {
console.info(`SetPointerStyle_001 enter`);
window.getTopWindow((err, data) => {
......@@ -323,5 +381,191 @@ export default function MultimodalInput_Pointer_test() {
console.info('MultimodalInput_Pointer_test::Pointer_MIDDLE_BTN_NORTH_SOUTH_WEST_EAST_test = ' + pointer.PointerStyle.MIDDLE_BTN_NORTH_SOUTH_WEST_EAST);
expect(pointer.PointerStyle.MIDDLE_BTN_NORTH_SOUTH_WEST_EAST == 38).assertTrue();
})
/**
* @tc.number MultimodalInputPointer_Test_001
* @tc.name MultimodalInputDevice_PointerVisibleTest_Exception_Test_001
* @tc.desc Pointer interface PointerVisible exception test
*/
it('MultimodalInputDevice_PointerVisibleTest_Exception_Test_001', 0, function () {
console.info(`MultimodalInputDevice_PointerVisibleTest_Exception_Test_001 enter`);
try {
pointer.setPointerVisible();
} catch (error) {
console.info(`PointerVisibleTest_Exception_Test_001: ${JSON.stringify(error, [`code`, `message`])}`);
expect(error.code).assertEqual(errCode.COMMON_PARAMETER_CODE);
expect(error.message).assertEqual(errMsg.PARAMETER_VISIBLE_TYPE_MSG);
}
try {
pointer.isPointerVisible((error, data) => {
if (error) {
console.info(`PointerVisibleTest_Exception_Test_001 failed, err=${JSON.stringify(error)}`);
expect(false).assertTrue();
} else {
console.info(`PointerVisibleTest_Exception_Test_001 success`);
expect(data).assertInstanceOf('Bool');
}
});
} catch (error) {
console.info(`PointerVisibleTest_Exception_Test_001: ${JSON.stringify(error, [`code`, `message`])}`);
}
console.info(`MultimodalInputDevice_PointerVisibleTest_Exception_Test_001 exit`);
})
/**
* @tc.number MultimodalInputPointer_Test_002
* @tc.name MultimodalInputDevice_PointerVisibleTest_Exception_Test_002
* @tc.desc Pointer interface PointerVisible exception test
*/
it('MultimodalInputDevice_PointerVisibleTest_Exception_Test_002', 0, function () {
console.info(`MultimodalInputDevice_PointerVisibleTest_Exception_Test_002 enter`);
try {
pointer.setPointerVisible(`state`, (error, data) => {
if (error) {
console.info(`PointerVisibleTest_Exception_Test_002 failed, err=${JSON.stringify(error)}`);
expect(false).assertTrue();
} else {
console.info(`PointerVisibleTest_Exception_Test_002 success`);
expect(true).assertTrue();
}
});
} catch (error) {
console.info(`PointerVisibleTest_Exception_Test_002: ${JSON.stringify(error, [`code`, `message`])}`);
expect(error.code).assertEqual(errCode.COMMON_PARAMETER_CODE);
expect(error.message).assertEqual(errMsg.PARAMETER_VISIBLE_TYPE_MSG);
}
try {
pointer.isPointerVisible(null);
} catch (error) {
console.info(`PointerVisibleTest_Exception_Test_002: ${JSON.stringify(error, [`code`, `message`])}`);
expect(error.code).assertEqual(errCode.COMMON_PARAMETER_CODE);
expect(error.message).assertEqual(errMsg.PARAMETER_CALLBACK_TYPE_MSG);
}
console.info(`MultimodalInputDevice_PointerVisibleTest_Exception_Test_002 exit`);
})
/**
* @tc.number MultimodalInputPointer_Test_003
* @tc.name MultimodalInputDevice_PointerSpeedTest_Exception_Test_001
* @tc.desc Pointer interface PointerSpeed exception test
*/
it('MultimodalInputDevice_PointerSpeedTest_Exception_Test_001', 0, function () {
console.info(`MultimodalInputDevice_PointerSpeedTest_Exception_Test_001 enter`);
try {
pointer.setPointerSpeed(10, null);
} catch (error) {
console.info(`PointerSpeedTest_Exception_Test_001: ${JSON.stringify(error, [`code`, `message`])}`);
expect(error.code).assertEqual(errCode.COMMON_PARAMETER_CODE);
expect(error.message).assertEqual(errMsg.PARAMETER_CALLBACK_TYPE_MSG);
}
try {
pointer.getPointerSpeed().then((error, data) => {
console.info(`PointerSpeedTest_Exception_Test_001 success`);
expect(data).assertInstanceOf('Number');
}, (error) => {
console.info(`PointerSpeedTest_Exception_Test_001 failed, err=${JSON.stringify(error)}`);
expect(false).assertTrue();
});
} catch (error) {
console.info(`PointerSpeedTest_Exception_Test_001: ${JSON.stringify(error, [`code`, `message`])}`);
}
console.info(`MultimodalInputDevice_PointerSpeedTest_Exception_Test_001 exit`);
})
/**
* @tc.number MultimodalInputPointer_Test_004
* @tc.name MultimodalInputDevice_PointerSpeedTest_Exception_Test_002
* @tc.desc Pointer interface PointerSpeed exception test
*/
it('MultimodalInputDevice_PointerSpeedTest_Exception_Test_002', 0, function () {
console.info(`MultimodalInputDevice_PointerSpeedTest_Exception_Test_002 enter`);
try {
pointer.setPointerSpeed().then((data) => {
console.info(`PointerSpeedTest_Exception_Test_002 success`);
expect(true).assertTrue();
}, (error) => {
console.info(`PointerSpeedTest_Exception_Test_002 failed, err=${JSON.stringify(error)}`);
expect(false).assertTrue();
});
} catch (error) {
console.info(`PointerSpeedTest_Exception_Test_002: ${JSON.stringify(error, [`code`, `message`])}`);
expect(error.code).assertEqual(errCode.COMMON_PARAMETER_CODE);
expect(error.message).assertEqual(errMsg.PARAMETER_SPEED_TYPE_MSG);
}
try {
pointer.getPointerSpeed(null);
} catch (error) {
console.info(`PointerSpeedTest_Exception_Test_002: ${JSON.stringify(error, [`code`, `message`])}`);
expect(error.code).assertEqual(errCode.COMMON_PARAMETER_CODE);
expect(error.message).assertEqual(errMsg.PARAMETER_CALLBACK_TYPE_MSG);
}
console.info(`MultimodalInputDevice_PointerSpeedTest_Exception_Test_002 exit`);
})
/**
* @tc.number MultimodalInputPointer_Test_005
* @tc.name MultimodalInputDevice_PointerStyleTest_Exception_Test_001
* @tc.desc Pointer interface PointerStyle exception test
*/
it('MultimodalInputDevice_PointerStyleTest_Exception_Test_001', 0, function () {
console.info(`MultimodalInputDevice_PointerStyleTest_Exception_Test_001 enter`);
try {
pointer.setPointerStyle(10, 10, null);
} catch (error) {
console.info(`PointerStyleTest_Exception_Test_001: ${JSON.stringify(error, [`code`, `message`])}`);
expect(error.code).assertEqual(errCode.COMMON_PARAMETER_CODE);
expect(error.message).assertEqual(errMsg.PARAMETER_CALLBACK_TYPE_MSG);
}
try {
pointer.getPointerStyle(10, null).then((data) => {
console.info(`PointerStyleTest_Exception_Test_001 success`);
expect(true).assertTrue();
}, (error) => {
console.info(`PointerStyleTest_Exception_Test_001 failed, err=${JSON.stringify(error)}`);
expect(false).assertTrue();
});
} catch (error) {
console.info(`PointerStyleTest_Exception_Test_001: ${JSON.stringify(error, [`code`, `message`])}`);
expect(error.code).assertEqual(errCode.COMMON_PARAMETER_CODE);
expect(error.message).assertEqual(errMsg.PARAMETER_CALLBACK_TYPE_MSG);
}
console.info(`MultimodalInputDevice_PointerStyleTest_Exception_Test_001 exit`);
})
/**
* @tc.number MultimodalInputPointer_Test_006
* @tc.name MultimodalInputDevice_PointerStyleTest_Exception_Test_002
* @tc.desc Pointer interface PointerStyle exception test
*/
it('MultimodalInputDevice_PointerStyleTest_Exception_Test_002', 0, function () {
console.info(`MultimodalInputDevice_PointerStyleTest_Exception_Test_002 enter`);
try {
pointer.setPointerStyle().then((data) => {
console.info(`PointerStyleTest_Exception_Test_002 success`);
expect(true).assertTrue();
}, (error) => {
console.info(`PointerStyleTest_Exception_Test_002 failed, err=${JSON.stringify(error)}`);
expect(false).assertTrue();
});
} catch (error) {
console.info(`PointerStyleTest_Exception_Test_002 success`);
expect(error.code).assertEqual(errCode.COMMON_PARAMETER_CODE);
expect(error.message).assertEqual(errMsg.PARAMETER_WINDOWID_TYPE_MSG);
}
try {
pointer.getPointerStyle();
} catch (error) {
console.info(`PointerStyleTest_Exception_Test_002: ${JSON.stringify(error, [`code`, `message`])}`);
expect(error.code).assertEqual(errCode.COMMON_PARAMETER_CODE);
expect(error.message).assertEqual(errMsg.PARAMETER_WINDOWID_TYPE_MSG);
}
console.info(`MultimodalInputDevice_PointerStyleTest_Exception_Test_002 exit`);
})
})
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册