diff --git a/multimodalinput/input_js_standard/signature/openharmony_sx.p7b b/multimodalinput/input_js_standard/signature/openharmony_sx.p7b index c6ec68bf297fb2a1bb16af585bcfdf8677cd196d..220615e314c43ade0bbef2479466993289bbe51a 100644 Binary files a/multimodalinput/input_js_standard/signature/openharmony_sx.p7b and b/multimodalinput/input_js_standard/signature/openharmony_sx.p7b differ diff --git a/multimodalinput/input_js_standard/src/main/js/test/InputDevice.test.js b/multimodalinput/input_js_standard/src/main/js/test/InputDevice.test.js index 41e4ef6514cd7d0fb07188ae661af0835ab67ea4..9908485c87d213bee6fda63de47954228dd27009 100644 --- a/multimodalinput/input_js_standard/src/main/js/test/InputDevice.test.js +++ b/multimodalinput/input_js_standard/src/main/js/test/InputDevice.test.js @@ -19,18 +19,18 @@ export default function MultimodalInput_Device_test() { describe('MultimodalInput_Device_test', function () { const errCode = { - COMMON_PARAMETER_CODE : 401 + 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.` + 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 () { + it('inputDevice::getDeviceIds_test-01', 0, async function (done) { console.info(`inputDevice::getDeviceIds_test-01 enter`); try { inputDevice.getDeviceIds((err, data) => { @@ -40,33 +40,39 @@ export default function MultimodalInput_Device_test() { expect(data).assertInstanceOf('Array'); } console.info(`inputDevice::getDeviceIds_test-01 exit`); + done(); }) } catch (error) { console.info(`inputDevice::getDeviceIds_test-01 error`); expect(false).assertTrue(); + done(); } }) // 参数正确,判断一种或多种设备 - it("inputDevice::getDeviceIds_test-02", 0, function () { + it("inputDevice::getDeviceIds_test-02", 0, async function (done) { console.info(`inputDevice::getDeviceIds_test-02 enter`); try { inputDevice.getDeviceIds((err, data) => { + console.info(`inputDevice::getDeviceIds_test-02 err:${JSON.stringify(err)}`); + console.info(`inputDevice::getDeviceIds_test-02 data:${JSON.stringify(data)}`); if (err) { expect(false).assertTrue(); } else { expect(data.length > 0).assertTrue(); } console.info(`inputDevice::getDeviceIds_test-02 exit`); + done(); }) } catch (error) { console.info(`inputDevice::getDeviceIds_test-02 error`); expect(false).assertTrue(); + done(); } }) // 参数类型错误 - it("inputDevice::getDeviceIds_test-03", 0, function () { + it("inputDevice::getDeviceIds_test-03", 0, async function (done) { console.info(`inputDevice::getDeviceIds_test-03 enter`); try { inputDevice.getDeviceIds(-1); @@ -74,10 +80,11 @@ export default function MultimodalInput_Device_test() { expect(error.message).assertEqual("GetDeviceIds: \"The first parameter type is wrong\""); } console.info(`inputDevice::getDeviceIds_test-03 exit`); + done(); }) // 参数数量错误 - it("inputDevice::getDeviceIds_test-04", 0, function () { + it("inputDevice::getDeviceIds_test-04", 0, async function (done) { console.info(`inputDevice::getDeviceIds_test-04 enter`); try { inputDevice.getDeviceIds(-1, (err, data) => { @@ -87,10 +94,11 @@ export default function MultimodalInput_Device_test() { expect(error.message).assertEqual("GetDeviceIds: \"too many parameters\""); } console.info(`inputDevice::getDeviceIds_test-04 exit`); + done(); }) // 无效的设备id - it("inputDevice::getDevice_test-01", 0, function () { + it("inputDevice::getDevice_test-01", 0, async function (done) { console.info(`inputDevice::getDevice_test-01 enter`); try { inputDevice.getDevice(-1, (err, data) => { @@ -105,62 +113,77 @@ export default function MultimodalInput_Device_test() { } catch (error) { console.info(`inputDevice::getDevice_test-01 error`); expect(false).assertTrue(); + } finally { + done(); } }) // 参数正常,返回值正常 - it("inputDevice::getDevice_test-02", 0, function () { + it("inputDevice::getDevice_test-02", 0, async function (done) { console.info(`inputDevice::getDevice_test-02 enter`); try { - inputDevice.getDeviceIds((err, data) => { + inputDevice.getDeviceIds(async (err, data) => { + console.info(`inputDevice::getDeviceIds_test-02 err:${JSON.stringify(err)}`); + console.info(`inputDevice::getDeviceIds_test-02 data:${JSON.stringify(data)}`); if (err) { expect(false).assertTrue(); } else { - let arr = []; for (let i = 0; i < data.length; i++) { - inputDevice.getDevice(data[i], (err, res) => { - console.info(`getDevice:data ${JSON.stringify(data)}`); - arr = Object.keys(res); - expect(res.id).assertInstanceOf('Number'); - expect(res.name).assertInstanceOf('String'); - expect(res.sources).assertInstanceOf('Array'); - expect(res.axisRanges).assertInstanceOf('Array'); - expect(res.bus).assertInstanceOf('Number'); - expect(res.product).assertInstanceOf('Number'); - expect(res.vendor).assertInstanceOf('Number'); - expect(res.version).assertInstanceOf('Number'); - expect(res.phys).assertInstanceOf('String'); - expect(res.uniq).assertInstanceOf('String'); - expect(res).assertInstanceOf('Object'); - for (let j = 0; j < res.axisRanges.length; j++) { - 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 == 'joystick' || res.axisRanges[j].source == 'trackball').assertTrue(); - expect(res.axisRanges[j].axis == 'touchMajor' || res.axisRanges[j].axis == 'touchMinor' - || res.axisRanges[j].axis == 'orientation' || res.axisRanges[j].axis == 'x' - || res.axisRanges[j].axis == 'y' || res.axisRanges[j].axis == 'pressure' - || res.axisRanges[j].axis == 'toolMinor' || res.axisRanges[j].axis == 'touchMajor' - || res.axisRanges[j].axis == 'NULL').assertTrue(); - expect(res.axisRanges[j].max).assertInstanceOf('Number'); - expect(res.axisRanges[j]).assertInstanceOf('AxisRange'); - expect(res.axisRanges[j].min).assertInstanceOf('Number'); - expect(res.axisRanges[j].fuzz).assertInstanceOf('Number'); - expect(res.axisRanges[j].flat).assertInstanceOf('Number'); - expect(res.axisRanges[j].resolution).assertInstanceOf('Number'); - } + console.info(`inputDevice::getDevice_test-02 for`); + await getDevicePromise(data[i]) + } + function getDevicePromise(data) { + console.info(`inputDevice::getDevice_test-02 getDevicePromise`) + return new Promise((resolve, reject) => { + inputDevice.getDevice(data, (err, res) => { + console.info(`getDevice:data =${JSON.stringify(data)}`); + console.info(`getDevice:res =${JSON.stringify(res)}`); + let arr = Object.keys(res); + expect(res.id).assertInstanceOf('Number'); + expect(res.name).assertInstanceOf('String'); + expect(res.sources).assertInstanceOf('Array'); + expect(res.axisRanges).assertInstanceOf('Array'); + expect(res.bus).assertInstanceOf('Number'); + expect(res.product).assertInstanceOf('Number'); + expect(res.vendor).assertInstanceOf('Number'); + expect(res.version).assertInstanceOf('Number'); + expect(res.phys).assertInstanceOf('String'); + expect(res.uniq).assertInstanceOf('String'); + expect(res).assertInstanceOf('Object'); + console.info(`inputDevice::getDevice_test-02 getDevice expect res`); + for (let j = 0; j < res.axisRanges.length; j++) { + 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 == 'joystick' || res.axisRanges[j].source == 'trackball').assertTrue(); + expect(res.axisRanges[j].axis == 'touchMajor' || res.axisRanges[j].axis == 'touchMinor' + || res.axisRanges[j].axis == 'orientation' || res.axisRanges[j].axis == 'x' + || res.axisRanges[j].axis == 'y' || res.axisRanges[j].axis == 'pressure' + || res.axisRanges[j].axis == 'toolMinor' || res.axisRanges[j].axis == 'touchMajor' + || res.axisRanges[j].axis == 'NULL').assertTrue(); + expect(res.axisRanges[j].max).assertInstanceOf('Number'); + expect(res.axisRanges[j]).assertInstanceOf('Object'); + expect(res.axisRanges[j].min).assertInstanceOf('Number'); + expect(res.axisRanges[j].fuzz).assertInstanceOf('Number'); + expect(res.axisRanges[j].flat).assertInstanceOf('Number'); + expect(res.axisRanges[j].resolution).assertInstanceOf('Number'); + } + resolve(res); + }) }) } } console.info(`inputDevice::getDevice_test-02 exit`); + done(); }); } catch (error) { console.info(`inputDevice::getDevice_test-02 error`); expect(false).assertTrue(); + done(); } }) // 参数正常,返回值正常 - it("inputDevice::supportKeys_test-01", 0, function () { + it("inputDevice::supportKeys_test-01", 0, async function (done) { console.info(`inputDevice::supportKeys_test-01 enter`); try { inputDevice.getDeviceIds((err, data) => { @@ -174,15 +197,17 @@ export default function MultimodalInput_Device_test() { } } console.info(`inputDevice::supportKeys_test-01 exit`); + done(); }); } catch (error) { console.info(`inputDevice::supportKeys_test-01 error`); expect(false).assertTrue(); + done(); } }) // 第二个参数异常 - it("inputDevice::supportKeys_test-02", 0, function () { + it("inputDevice::supportKeys_test-02", 0, async function (done) { console.info(`inputDevice::supportKeys_test-02 enter`); try { inputDevice.supportKeys(0, 2022, (err, res) => { @@ -192,10 +217,11 @@ export default function MultimodalInput_Device_test() { expect(error.message).assertEqual("Parameter error. The type of keys must be array."); } console.info(`inputDevice::supportKeys_test-02 exit`); + done(); }) // 参数正常 - it("inputDevice::getKeyboardType_test-01", 0, function () { + it("inputDevice::getKeyboardType_test-01", 0, async function (done) { console.info(`inputDevice::getKeyboardType_test-01 enter`); try { inputDevice.getDeviceIds((err, data) => { @@ -209,15 +235,17 @@ export default function MultimodalInput_Device_test() { } } console.info(`inputDevice::getKeyboardType_test-01 exit`); + done(); }); } catch (error) { console.info(`inputDevice::getKeyboardType_test-01 error`); expect(false).assertTrue(); + done(); } }) //参数异常 - it("inputDevice::getKeyboardType_test-02", 0, function () { + it("inputDevice::getKeyboardType_test-02", 0, async function (done) { console.info(`inputDevice::getKeyboardType_test-02 enter`); try { inputDevice.getKeyboardType(-1); @@ -225,10 +253,11 @@ export default function MultimodalInput_Device_test() { expect(error.message).assertEqual("Invalid input device id"); } console.info(`inputDevice::getKeyboardType_test-02 exit`); + done(); }); // 参数正常 - it("inputDevice::getKeyboardType_test-03", 0, function () { + it("inputDevice::getKeyboardType_test-03", 0, async function (done) { console.info(`inputDevice::getKeyboardType_test-03 enter`); try { inputDevice.getDeviceIds((err, data) => { @@ -245,10 +274,12 @@ export default function MultimodalInput_Device_test() { } } console.info(`inputDevice::getKeyboardType_test-03 exit`); + done(); }); } catch (error) { console.info(`inputDevice::getKeyboardType_test-03 error`); expect(false).assertTrue(); + done(); } }) @@ -354,7 +385,7 @@ export default function MultimodalInput_Device_test() { * @tc.name MultimodalInputDevice_getDevice_Promise_test * @tc.desc inputdevice interface getDevice test */ - it("MultimodalInputDevice_getDevice_Promise_test", 0, function () { + it("MultimodalInputDevice_getDevice_Promise_test", 0, async function (done) { console.info(`MultimodalInputDevice_getDevice_Promise_test enter`); try { inputDevice.getDevice(-1).then(data => { @@ -369,6 +400,7 @@ export default function MultimodalInput_Device_test() { expect(false).assertTrue(); } console.info(`MultimodalInputDevice_getDeviceIds_Promise_test exit`); + done(); }) /** @@ -376,7 +408,7 @@ export default function MultimodalInput_Device_test() { * @tc.name MultimodalInputDevice_on_test * @tc.desc inputdevice interface getDevice test */ - it("MultimodalInputDevice_on_test", 0, function () { + it("MultimodalInputDevice_on_test", 0, async function (done) { console.info(`MultimodalInputDevice_on_test enter`); try { let isPhysicalKeyboardExist = true; @@ -398,6 +430,7 @@ export default function MultimodalInput_Device_test() { expect(false).assertTrue(); } console.info(`MultimodalInputDevice_on_test exit`); + done(); }) /** @@ -405,12 +438,12 @@ export default function MultimodalInput_Device_test() { * @tc.name MultimodalInputDevice_off_test * @tc.desc inputdevice interface getDevice test */ - it("MultimodalInputDevice_off_test", 0, function () { + it("MultimodalInputDevice_off_test", 0, async function (done) { console.info(`MultimodalInputDevice_off_test enter`); function listener(data) { console.info("type: " + data.type + ", deviceId: " + data.deviceId); expect(data.type == 'add' || data.type == 'remove').assertTrue(); - expect(data).assertInstanceOf('DeviceListener'); + expect(data).assertInstanceOf('Object'); } // 单独取消listener的监听。 try { @@ -420,6 +453,7 @@ export default function MultimodalInput_Device_test() { expect(false).assertTrue(); } console.info(`MultimodalInputDevice_off_test exit`); + done(); }) /** @@ -427,7 +461,7 @@ export default function MultimodalInput_Device_test() { * @tc.name MultimodalInputDevice_GetDeviceList_test * @tc.desc inputdevice interface getDeviceList test */ - it('inputDevice::getDeviceList_test-01', 0, function () { + it('inputDevice::getDeviceList_test-01', 0, async function (done) { console.info(`inputDevice::getDeviceList_async_test enter`); try { inputDevice.getDeviceList((err, data) => { @@ -437,9 +471,11 @@ export default function MultimodalInput_Device_test() { expect(data).assertInstanceOf('Array'); } console.info(`inputDevice::getDeviceList_async_test exit`); + done(); }) } catch (err) { expect(false).assertTrue(); + done(); } }) @@ -449,7 +485,7 @@ export default function MultimodalInput_Device_test() { * @tc.name MultimodalInputDevice_GetDeviceList_test * @tc.desc inputdevice interface getDeviceList test */ - it('inputDevice::getDeviceList_test-02', 0, function () { + it('inputDevice::getDeviceList_test-02', 0, async function (done) { console.info(`inputDevice::getDeviceList_promise_test enter`); try { inputDevice.getDeviceList().then(data => { @@ -461,6 +497,7 @@ export default function MultimodalInput_Device_test() { expect(false).assertTrue(); } console.info(`inputDevice::getDeviceList_promise_test exit`); + done(); }) /** @@ -468,18 +505,23 @@ export default function MultimodalInput_Device_test() { * @tc.name MultimodalInputDevice_GetDeviceInfo_test * @tc.desc inputdevice interface getDeviceInfo test */ - it('inputDevice::getDeviceInfo_test-01', 0, function () { + it('inputDevice::getDeviceInfo_test-01', 0, async function (done) { console.info(`inputDevice::getDeviceInfo_async_test enter`); try { - inputDevice.getDeviceList().then((data) => { + await inputDevice.getDeviceList().then((data) => { + console.info(`getDeviceInfo:data assertInstanceOf Array` + typeof (data)); expect(data).assertInstanceOf('Array'); - if (data.length() <= 0) { + console.info(`getDeviceInfo:data assertInstanceOf Array end ${data.length}`); + if (data.length <= 0) { + done() return; } try { inputDevice.getDeviceInfo(data[0], (err, res) => { + console.info(`getDeviceInfo:data enter`); if (err) { expect(false).assertTrue(); + done() return; } let arr = []; @@ -506,18 +548,21 @@ export default function MultimodalInput_Device_test() { || res.axisRanges[j].axis == 'toolMinor' || res.axisRanges[j].axis == 'touchMajor' || res.axisRanges[j].axis == 'NULL').assertTrue(); expect(res.axisRanges[j].max).assertInstanceOf('Number'); - expect(res.axisRanges[j]).assertInstanceOf('AxisRange'); + expect(res.axisRanges[j]).assertInstanceOf('Object'); expect(res.axisRanges[j].min).assertInstanceOf('Number'); expect(res.axisRanges[j].fuzz).assertInstanceOf('Number'); expect(res.axisRanges[j].flat).assertInstanceOf('Number'); expect(res.axisRanges[j].resolution).assertInstanceOf('Number'); } + done() }) } catch (err) { + console.info(`inputDevice::getDeviceInfo_test-01 inputDevice.getDeviceInfo ${JSON.stringify(err)}`); expect(false).assertTrue(); } }) } catch (err) { + console.info(`inputDevice::getDeviceInfo_test-01 inputDevice.getDeviceList ${JSON.stringify(err)}`); expect(false).assertTrue(); } console.info(`inputDevice::getDeviceInfo_async_test exit`); @@ -528,12 +573,12 @@ export default function MultimodalInput_Device_test() { * @tc.name MultimodalInputDevice_GetDeviceInfo_test * @tc.desc inputdevice interface getDeviceInfo test */ - it('inputDevice::getDeviceInfo_test-02', 0, function () { + it('inputDevice::getDeviceInfo_test-02', 0, async function (done) { console.info(`inputDevice::getDeviceInfo_promise_test enter`); try { inputDevice.getDeviceList().then((data) => { expect(data).assertInstanceOf('Array'); - if (data.length() <= 0) { + if (data.length <= 0) { return; } try { @@ -562,7 +607,7 @@ export default function MultimodalInput_Device_test() { || res.axisRanges[j].axis == 'toolMinor' || res.axisRanges[j].axis == 'touchMajor' || res.axisRanges[j].axis == 'NULL').assertTrue(); expect(res.axisRanges[j].max).assertInstanceOf('Number'); - expect(res.axisRanges[j]).assertInstanceOf('AxisRange'); + expect(res.axisRanges[j]).assertInstanceOf('Object'); expect(res.axisRanges[j].min).assertInstanceOf('Number'); expect(res.axisRanges[j].fuzz).assertInstanceOf('Number'); expect(res.axisRanges[j].flat).assertInstanceOf('Number'); @@ -579,6 +624,7 @@ export default function MultimodalInput_Device_test() { expect(false).assertTrue(); } console.info(`inputDevice::getDeviceInfo_promise_test exit`); + done(); }) /** @@ -586,7 +632,7 @@ export default function MultimodalInput_Device_test() { * @tc.name MultimodalInputDevice_GetkeyboardType_Exception_test_01 * @tc.desc inputdevice interface getKeyboardType exception test */ - it("MultimodalInputDevice_GetkeyboardType_Exception_test_01", 0, function () { + it("MultimodalInputDevice_GetkeyboardType_Exception_test_01", 0, async function (done) { console.info(`MultimodalInputDevice_GetkeyboardType_Exception_test_01 enter`); try { inputDevice.getKeyboardType(); @@ -596,6 +642,7 @@ export default function MultimodalInput_Device_test() { expect(error.message).assertEqual(errMsg.PARAMETER_COUNT_MSG); } console.info("MultimodalInputDevice_GetkeyboardType_Exception_test_01 exit"); + done(); }) /** @@ -603,7 +650,7 @@ export default function MultimodalInput_Device_test() { * @tc.name MultimodalInputDevice_GetkeyboardType_Exception_test_02 * @tc.desc inputdevice interface getKeyboardType exception test */ - it("MultimodalInputDevice_GetkeyboardType_Exception_test_02", 0, function () { + it("MultimodalInputDevice_GetkeyboardType_Exception_test_02", 0, async function (done) { console.info("MultimodalInputDevice_GetkeyboardType_Exception_test_02 enter"); try { inputDevice.getKeyboardType(`id`).then((data) => { @@ -619,6 +666,7 @@ export default function MultimodalInput_Device_test() { expect(error.message).assertEqual(errMsg.PARAMETER_DEVICEID_TYPE_MSG); } console.info("MultimodalInputDevice_GetkeyboardType_Exception_test_02 exit"); + done(); }) /** @@ -626,7 +674,7 @@ export default function MultimodalInput_Device_test() { * @tc.name MultimodalInputDevice_SupportKeys_Exception_test_01 * @tc.desc inputdevice interface supportKeys exception test */ - it("MultimodalInputDevice_SupportKeys_Exception_test_01", 0, function () { + it("MultimodalInputDevice_SupportKeys_Exception_test_01", 0, async function (done) { console.info("MultimodalInputDevice_SupportKeys_Exception_test_01 enter"); try { inputDevice.supportKeys((error, data) => { @@ -644,6 +692,7 @@ export default function MultimodalInput_Device_test() { expect(error.message).assertEqual(errMsg.PARAMETER_COUNT_MSG); } console.info("MultimodalInputDevice_SupportKeys_Exception_test_01 exit"); + done(); }) /** @@ -651,7 +700,7 @@ export default function MultimodalInput_Device_test() { * @tc.name MultimodalInputDevice_SupportKeys_Exception_test_02 * @tc.desc inputdevice interface supportKeys exception test */ - it("MultimodalInputDevice_SupportKeys_Exception_test_02", 0, function () { + it("MultimodalInputDevice_SupportKeys_Exception_test_02", 0, async function (done) { console.info("MultimodalInputDevice_SupportKeys_Exception_test_02 enter"); try { inputDevice.supportKeys(`id`, [17, 22, 2055], (error, data) => { @@ -669,6 +718,7 @@ export default function MultimodalInput_Device_test() { expect(error.message).assertEqual(errMsg.PARAMETER_DEVICEID_TYPE_MSG); } console.info("MultimodalInputDevice_SupportKeys_Exception_test_02 exit"); + done(); }) /** @@ -676,7 +726,7 @@ export default function MultimodalInput_Device_test() { * @tc.name MultimodalInputDevice_GetDeviceInfo_Exception_test_01 * @tc.desc inputdevice interface getDeviceInfo exception test */ - it("MultimodalInputDevice_GetDeviceInfo_Exception_test_01", 0, function () { + it("MultimodalInputDevice_GetDeviceInfo_Exception_test_01", 0, async function (done) { console.info("MultimodalInputDevice_GetDeviceInfo_Exception_test_01 enter"); try { inputDevice.getDeviceInfo(); @@ -686,6 +736,7 @@ export default function MultimodalInput_Device_test() { expect(error.message).assertEqual(errMsg.PARAMETER_COUNT_MSG); } console.info("MultimodalInputDevice_GetDeviceInfo_Exception_test_01 exit"); + done(); }) /** @@ -693,7 +744,7 @@ export default function MultimodalInput_Device_test() { * @tc.name MultimodalInputDevice_GetDeviceInfo_Exception_test_02 * @tc.desc inputdevice interface getDeviceInfo exception test */ - it("MultimodalInputDevice_GetDeviceInfo_Exception_test_02", 0, function () { + it("MultimodalInputDevice_GetDeviceInfo_Exception_test_02", 0, async function (done) { console.info("MultimodalInputDevice_GetDeviceInfo_Exception_test_02 enter"); try { inputDevice.getDeviceList().then((data) => { @@ -719,6 +770,7 @@ export default function MultimodalInput_Device_test() { expect(false).assertTrue(); } console.info("MultimodalInputDevice_GetDeviceInfo_Exception_test_02 exit"); + done(); }) /** @@ -726,7 +778,7 @@ export default function MultimodalInput_Device_test() { * @tc.name MultimodalInputDevice_GetDeviceList_Exception_test * @tc.desc inputdevice interface getDeviceList exception test */ - it("MultimodalInputDevice_GetDeviceList_Exception_test", 0, function () { + it("MultimodalInputDevice_GetDeviceList_Exception_test", 0, async function (done) { console.info("MultimodalInputDevice_GetDeviceList_Exception_test enter"); try { inputDevice.getDeviceList(null); @@ -736,6 +788,7 @@ export default function MultimodalInput_Device_test() { expect(error.message).assertEqual(errMsg.PARAMETER_CALLBACK_TYPE_MSG); } console.info(`MultimodalInputDevice_GetDeviceList_Exception_test exit`); + done(); }) /** @@ -743,7 +796,7 @@ export default function MultimodalInput_Device_test() { * @tc.name MultimodalInputDevice_On_Exception_test * @tc.desc inputdevice interface on test */ - it("MultimodalInputDevice_On_Exception_test", 0, function () { + it("MultimodalInputDevice_On_Exception_test", 0, async function (done) { console.info(`MultimodalInputDevice_On_Exception_test enter`); try { inputDevice.on(); @@ -769,6 +822,7 @@ export default function MultimodalInput_Device_test() { expect(error.message).assertEqual(errMsg.PARAMETER_TYPE_MSG); } console.info(`MultimodalInputDevice_On_Exception_test exit`); + done(); }) /** @@ -776,7 +830,7 @@ export default function MultimodalInput_Device_test() { * @tc.name MultimodalInputDevice_Off_Exception_test * @tc.desc inputdevice interface off test */ - it("MultimodalInputDevice_Off_Exception_test", 0, function () { + it("MultimodalInputDevice_Off_Exception_test", 0, async function (done) { console.info(`MultimodalInputDevice_Off_Exception_test enter`); try { inputDevice.off(); @@ -794,6 +848,7 @@ export default function MultimodalInput_Device_test() { expect(error.message).assertEqual(errMsg.PARAMETER_LISTENER_TYPE_MSG); } console.info(`MultimodalInputDevice_Off_Exception_test exit`); + done(); }) }) } diff --git a/multimodalinput/input_js_standard/src/main/js/test/ListMultimodalinput.test.js b/multimodalinput/input_js_standard/src/main/js/test/ListMultimodalinput.test.js index 06be094a875a982a329bcea8132e0b7472a1bcdc..bb38b398234512402d84e9e028faf44d0a5d51d4 100644 --- a/multimodalinput/input_js_standard/src/main/js/test/ListMultimodalinput.test.js +++ b/multimodalinput/input_js_standard/src/main/js/test/ListMultimodalinput.test.js @@ -17,7 +17,7 @@ import MultimodalInput_Device_test from './InputDevice.test.js' import MultimodalInput_KeyCode_test from './MultimodalInputKey_Code.test.js' import MultimodalInput_Pointer_test from './Pointer.test.js' export default function testsuite() { - MultimodalInput_Device_test() - MultimodalInput_KeyCode_test() - MultimodalInput_Pointer_test() + MultimodalInput_Device_test() + MultimodalInput_KeyCode_test() + MultimodalInput_Pointer_test() } \ No newline at end of file diff --git a/multimodalinput/input_js_standard/src/main/js/test/Pointer.test.js b/multimodalinput/input_js_standard/src/main/js/test/Pointer.test.js index 96a7a6d154db0ef699271f9077eb44248216dedb..63a2bf47c10211c5f609a98adb6fd59fd68345e9 100644 --- a/multimodalinput/input_js_standard/src/main/js/test/Pointer.test.js +++ b/multimodalinput/input_js_standard/src/main/js/test/Pointer.test.js @@ -20,18 +20,18 @@ export default function MultimodalInput_Pointer_test() { describe('MultimodalInput_Pointer_test', function () { const errCode = { - COMMON_PARAMETER_CODE : 401 + 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.` + 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 () { + it('MultimodalInput_Pointer_test::PointerVisibleTest_001', 0, async function (done) { console.info(`MultimodalInput_Pointer_test::SetPointerVisibleTest_001 enter`); try { pointer.setPointerVisible(false, (err, data) => { @@ -39,7 +39,7 @@ export default function MultimodalInput_Pointer_test() { console.info(`MultimodalInput_Pointer_test::SetPointerVisibleTest_001 failed, err=${JSON.stringify(err)}`); expect(false).assertTrue(); } else { - console.info(`MultimodalInput_Pointer_test::SetPointerVisibleTest_001 success. data=${JSON.stringify(data)}`); + console.info(`MultimodalInput_Pointer_test::SetPointerVisibleTest_001 success_1. data=${JSON.stringify(data)}`); expect(true).assertTrue(); } }); @@ -48,9 +48,10 @@ export default function MultimodalInput_Pointer_test() { expect(false).assertTrue(); } try { - pointer.isPointerVisible().then(data => { - console.info(`MultimodalInput_Pointer_test::PointerVisibleTest_001 success, data=${JSON.stringify(data)}`); + await pointer.isPointerVisible().then(data => { + console.info(`MultimodalInput_Pointer_test::PointerVisibleTest_001 success_2, data=${JSON.stringify(data)}`); expect(data == false).assertTrue(); + done(); }).catch((err) => { console.info(`MultimodalInput_Pointer_test::PointerVisibleTest_001 failed, err=${JSON.stringify(err)}`); expect(false).assertTrue(); @@ -62,11 +63,11 @@ export default function MultimodalInput_Pointer_test() { console.info(`MultimodalInput_Pointer_test::PointerVisibleTest_001 exit`); }) - it('MultimodalInput_Pointer_test::PointerVisibleTest_002', 0, function () { + it('MultimodalInput_Pointer_test::PointerVisibleTest_002', 0, async function (done) { console.info(`MultimodalInput_Pointer_test::PointerVisibleTest_002 enter`); try { - pointer.setPointerVisible(true).then(data => { - console.info(`MultimodalInput_Pointer_test::PointerVisibleTest_002 success, data=${JSON.stringify(data)}`); + await pointer.setPointerVisible(true).then(data => { + console.info(`MultimodalInput_Pointer_test::PointerVisibleTest_002 success_1, data=${JSON.stringify(data)}`); expect(true).assertTrue(); }).catch((err) => { console.info(`MultimodalInput_Pointer_test::PointerVisibleTest_002 failed, err=${JSON.stringify(err)}`); @@ -82,8 +83,9 @@ export default function MultimodalInput_Pointer_test() { console.info(`MultimodalInput_Pointer_test::PointerVisibleTest_002 failed, err=${JSON.stringify(err)}`); expect(false).assertTrue(); } else { - console.info(`MultimodalInput_Pointer_test::PointerVisibleTest_002 success, data=${JSON.stringify(data)}`); + console.info(`MultimodalInput_Pointer_test::PointerVisibleTest_002 success_2, data=${JSON.stringify(data)}`); expect(data == true).assertTrue(); + done(); } }); } catch (error) { @@ -93,173 +95,175 @@ 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 () { + it('MultimodalInput_Pointer_test::SetPointerStyle_001', 0, async function (done) { console.info(`SetPointerStyle_001 enter`); - window.getTopWindow((err, data) => { - if (err) { - console.info(`SetPointerStyle_001 failed, err=${JSON.stringify(err)}`); - expect(false).assertTrue(); - } - var windowClass = data; - windowClass.getProperties((err, data) => { - if (err) { - console.info(`SetPointerStyle_001 failed, err=${JSON.stringify(err)}`); - expect(false).assertTrue(); - } - try { - var windowId = data.id; - pointer.setPointerStyle(windowId, 4).then(() => { - expect(true).assertTrue(); - console.info(`SetPointerStyle_001 success`); - }).catch((err) => { - expect(false).assertTrue(); + function getPropertiesPromise(windowClass) { + return new Promise((resolve, reject) => { + windowClass.getProperties(async (err, data) => { + if (err && err.code != 0) { console.info(`SetPointerStyle_001 failed, err=${JSON.stringify(err)}`); - }); - } catch (error) { - console.info(`SetPointerStyle_001 error`); - expect(false).assertTrue(); - } + expect(false).assertTrue(); + } + try { + var windowId = data.id; + await pointer.setPointerStyle(windowId, 4).then(() => { + expect(true).assertTrue(); + console.info(`SetPointerStyle_001 success`); + resolve(); + }).catch((err) => { + expect(false).assertTrue(); + console.info(`SetPointerStyle_001 failed_1, err=${JSON.stringify(err)}`); + }); + } catch (error) { + console.info(`SetPointerStyle_001 error`); + expect(false).assertTrue(); + reject(error); + } + }) }) + } + window.getTopWindow(async (err, data) => { + console.info(`case:SetPointerStyle_001 enter`); + var windowClass = data; + if (err && err.code != 0) { + console.info(`case:SetPointerStyle_001,getTopWindow failed, err=${JSON.stringify(err)}`); + return; + } + console.info(`case:SetPointerStyle_001 ===========`); + await getPropertiesPromise(data); + console.info(`case:SetPointerStyle_001 exit`); + done(); }) }) - it('MultimodalInput_Pointer_test::SetPointerStyle_002', 0, function () { + + it('MultimodalInput_Pointer_test::SetPointerStyle_002', 0, async function (done) { console.info(`SetPointerStyle_002 enter`); - window.getTopWindow((err, data) => { + function getPropertiesPromise(windowClass) { + return new Promise((resolve, reject) => { + windowClass.getProperties((err, data) => { + if (err && err.code != 0) { + console.info(`SetPointerStyle_002 failed, err=${JSON.stringify(err)}`); + expect(false).assertTrue(); + } + try { + var windowId = data.id; + pointer.setPointerStyle(windowId, 4, (err) => { + if (err) { + console.info(`SetPointerStyle_002 failed_1, err=${JSON.stringify(err)}`); + expect(false).assertTrue(); + } else { + console.info(`SetPointerStyle_002 success`); + expect(true).assertTrue(); + resolve(); + } + }); + } catch (error) { + console.info(`SetPointerStyle_002 error`); + expect(false).assertTrue(); + reject(error); + } + }) + }) + } + window.getTopWindow(async (err, data) => { + console.info(`case:SetPointerStyle_002 enter`); var windowClass = data; - if (err) { - console.info(`SetPointerStyle_002 failed, err=${JSON.stringify(err)}`); - expect(false).assertTrue(); + if (err && err.code != 0) { + console.info(`case:SetPointerStyle_002,getTopWindow failed, err=${JSON.stringify(err)}`); + return; } - windowClass.getProperties((err, data) => { - if (err) { - console.info(`SetPointerStyle_002 failed, err=${JSON.stringify(err)}`); - expect(false).assertTrue(); - } - try { - var windowId = data.id; - pointer.setPointerStyle(windowId, 4, (err) => { - if (err) { - console.info(`SetPointerStyle_002 failed, err=${JSON.stringify(err)}`); - expect(false).assertTrue(); - } else { - console.info(`SetPointerStyle_002 success`); - expect(true).assertTrue(); - } - }); - } catch (error) { - console.info(`SetPointerStyle_002 error`); - expect(false).assertTrue(); - } - }) + console.info(`case:SetPointerStyle_002 ===========`); + await getPropertiesPromise(data); + console.info(`case:SetPointerStyle_002 exit`); + done(); }) }) - it('MultimodalInput_Pointer_test::GetPointerStyle_001', 0, function () { + it('MultimodalInput_Pointer_test::GetPointerStyle_001', 0, async function (done) { console.info(`GetPointerStyle_001 enter`); - window.getTopWindow((err, data) => { - if (err) { - console.info(`GetPointerStyle_001 failed, err=${JSON.stringify(err)}`); - expect(false).assertTrue(); - } - var windowClass = data; - windowClass.getProperties((err, data) => { - if (err) { - console.info(`GetPointerStyle_001 failed, err=${JSON.stringify(err)}`); - expect(false).assertTrue(); - } - var windowId = data.id; - try { - pointer.getPointerStyle(windowId).then((data) => { - console.info(`GetPointerStyle_001 success, data=${JSON.stringify(data)}`); - expect(data).assertTrue('Number'); - }).catch((err) => { + function getPropertiesPromise(windowClass) { + return new Promise((resolve, reject) => { + windowClass.getProperties(async (err, data) => { + if (err && err.code != 0) { console.info(`GetPointerStyle_001 failed, err=${JSON.stringify(err)}`); expect(false).assertTrue(); - }); - } catch (error) { - console.info(`GetPointerStyle_001 error`); - expect(false).assertTrue(); - } + } + try { + var windowId = data.id; + await pointer.getPointerStyle(windowId).then((data) => { + console.info(`GetPointerStyle_001 success, data=${JSON.stringify(data)}`); + expect(typeof (data)).assertEqual("number"); + resolve(); + }).catch((err) => { + console.info(`GetPointerStyle_001 failed_1, err=${JSON.stringify(err)}`); + expect(false).assertTrue(); + }); + } catch (error) { + console.info(`GetPointerStyle_001 error`); + expect(false).assertTrue(); + reject(error); + } + }) }) + } + window.getTopWindow(async (err, data) => { + console.info(`case:GetPointerStyle_001 enter`); + var windowClass = data; + if (err && err.code != 0) { + console.info(`case:GetPointerStyle_001,getTopWindow failed, err=${JSON.stringify(err)}`); + return; + } + console.info(`case:GetPointerStyle_001 ===========`); + await getPropertiesPromise(data); + console.info(`case:GetPointerStyle_001 exit`); + done(); }) }) - it('MultimodalInput_Pointer_test::GetPointerStyle_002', 0, function () { + it('MultimodalInput_Pointer_test::GetPointerStyle_002', 0, async function (done) { + console.info(`GetPointerStyle_002 enter`); - window.getTopWindow((err, data) => { - if (err) { - console.info(`GetPointerStyle_002 failed, err=${JSON.stringify(err)}`); - expect(false).assertTrue(); - } - var windowClass = data; - windowClass.getProperties((err, data) => { - if (err) { - console.info(`GetPointerStyle_002 failed, err=${JSON.stringify(err)}`); - expect(false).assertTrue(); - } - try { - var windowId = data.id; - pointer.getPointerStyle(windowId, (err, data) => { - if (err) { - console.info(`GetPointerStyle_002 failed, err=${JSON.stringify(err)}`); - expect(false).assertTrue(); - } else { - console.info(`GetPointerStyle_002 success, data=${JSON.stringify(data)}`); - expect(data).assertTrue('Number'); - } - }); - } catch (error) { - console.info(`GetPointerStyle_002 error`); - expect(false).assertTrue(); - } + function getPropertiesPromise(windowClass) { + return new Promise((resolve, reject) => { + windowClass.getProperties((err, data) => { + if (err && err.code != 0) { + console.info(`GetPointerStyle_002 failed, err=${JSON.stringify(err)}`); + reject(); + } + try { + var windowId = data.id; + pointer.getPointerStyle(windowId, (err, data) => { + if (err) { + console.info(`GetPointerStyle_002 failed_1, err=${JSON.stringify(err)}`); + expect(false).assertTrue(); + reject(); + } else { + console.info(`GetPointerStyle_002 success, data=` + typeof (data)); + expect(data).assertInstanceOf('Number'); + resolve(); + } + }) + } catch (error) { + console.info(`GetPointerStyle_002 error=${JSON.stringify(error)}`); + expect(false).assertTrue(); + reject(error); + } + }) }) + } + window.getTopWindow(async (err, data) => { + console.info(`case:GetPointerStyle_002 enter`); + var windowClass = data; + if (err && err.code != 0) { + console.info(`case:GetPointerStyle_002,getTopWindow failed, err=${JSON.stringify(err)}`); + done(); + return; + } + console.info(`case:GetPointerStyle_002 ===========`); + await getPropertiesPromise(data); + console.info(`case:GetPointerStyle_002 exit`); + done(); }) }) @@ -387,16 +391,15 @@ export default function MultimodalInput_Pointer_test() { * @tc.name MultimodalInputDevice_PointerVisibleTest_Exception_Test_001 * @tc.desc Pointer interface PointerVisible exception test */ - it('MultimodalInputDevice_PointerVisibleTest_Exception_Test_001', 0, function () { + it('MultimodalInputDevice_PointerVisibleTest_Exception_Test_001', 0, async function (done) { console.info(`MultimodalInputDevice_PointerVisibleTest_Exception_Test_001 enter`); try { - pointer.setPointerVisible(); + await 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) { @@ -404,8 +407,9 @@ export default function MultimodalInput_Pointer_test() { expect(false).assertTrue(); } else { console.info(`PointerVisibleTest_Exception_Test_001 success`); - expect(data).assertInstanceOf('Bool'); + expect(data).assertInstanceOf('Boolean'); } + done(); }); } catch (error) { console.info(`PointerVisibleTest_Exception_Test_001: ${JSON.stringify(error, [`code`, `message`])}`); @@ -418,7 +422,7 @@ export default function MultimodalInput_Pointer_test() { * @tc.name MultimodalInputDevice_PointerVisibleTest_Exception_Test_002 * @tc.desc Pointer interface PointerVisible exception test */ - it('MultimodalInputDevice_PointerVisibleTest_Exception_Test_002', 0, function () { + it('MultimodalInputDevice_PointerVisibleTest_Exception_Test_002', 0, async function (done) { console.info(`MultimodalInputDevice_PointerVisibleTest_Exception_Test_002 enter`); try { pointer.setPointerVisible(`state`, (error, data) => { @@ -437,73 +441,14 @@ export default function MultimodalInput_Pointer_test() { } try { - pointer.isPointerVisible(null); + await 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`); + done(); }) /** @@ -511,10 +456,10 @@ export default function MultimodalInput_Pointer_test() { * @tc.name MultimodalInputDevice_PointerStyleTest_Exception_Test_001 * @tc.desc Pointer interface PointerStyle exception test */ - it('MultimodalInputDevice_PointerStyleTest_Exception_Test_001', 0, function () { + it('MultimodalInputDevice_PointerStyleTest_Exception_Test_001', 0, async function (done) { console.info(`MultimodalInputDevice_PointerStyleTest_Exception_Test_001 enter`); try { - pointer.setPointerStyle(10, 10, null); + await 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); @@ -522,7 +467,7 @@ export default function MultimodalInput_Pointer_test() { } try { - pointer.getPointerStyle(10, null).then((data) => { + await pointer.getPointerStyle(10, null).then((data) => { console.info(`PointerStyleTest_Exception_Test_001 success`); expect(true).assertTrue(); }, (error) => { @@ -535,6 +480,7 @@ export default function MultimodalInput_Pointer_test() { expect(error.message).assertEqual(errMsg.PARAMETER_CALLBACK_TYPE_MSG); } console.info(`MultimodalInputDevice_PointerStyleTest_Exception_Test_001 exit`); + done(); }) /** @@ -542,10 +488,10 @@ export default function MultimodalInput_Pointer_test() { * @tc.name MultimodalInputDevice_PointerStyleTest_Exception_Test_002 * @tc.desc Pointer interface PointerStyle exception test */ - it('MultimodalInputDevice_PointerStyleTest_Exception_Test_002', 0, function () { + it('MultimodalInputDevice_PointerStyleTest_Exception_Test_002', 0, async function (done) { console.info(`MultimodalInputDevice_PointerStyleTest_Exception_Test_002 enter`); try { - pointer.setPointerStyle().then((data) => { + await pointer.setPointerStyle().then((data) => { console.info(`PointerStyleTest_Exception_Test_002 success`); expect(true).assertTrue(); }, (error) => { @@ -559,13 +505,14 @@ export default function MultimodalInput_Pointer_test() { } try { - pointer.getPointerStyle(); + await 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`); + done(); }) }) } \ No newline at end of file