提交 de348c47 编写于 作者: Y yuexinyao1

yuexinyao1@huawei.com

Signed-off-by: Nyuexinyao1 <yuexinyao1@huawei.com>
上级 f5599a7f
...@@ -19,18 +19,18 @@ export default function MultimodalInput_Device_test() { ...@@ -19,18 +19,18 @@ export default function MultimodalInput_Device_test() {
describe('MultimodalInput_Device_test', function () { describe('MultimodalInput_Device_test', function () {
const errCode = { const errCode = {
COMMON_PARAMETER_CODE : 401 COMMON_PARAMETER_CODE: 401
} }
const errMsg = { const errMsg = {
PARAMETER_COUNT_MSG : `Parameter count error`, PARAMETER_COUNT_MSG: `Parameter count error`,
PARAMETER_TYPE_MSG : `Parameter error. The type of type must be string.`, 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_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_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_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`); console.info(`inputDevice::getDeviceIds_test-01 enter`);
try { try {
inputDevice.getDeviceIds((err, data) => { inputDevice.getDeviceIds((err, data) => {
...@@ -40,33 +40,39 @@ export default function MultimodalInput_Device_test() { ...@@ -40,33 +40,39 @@ export default function MultimodalInput_Device_test() {
expect(data).assertInstanceOf('Array'); expect(data).assertInstanceOf('Array');
} }
console.info(`inputDevice::getDeviceIds_test-01 exit`); console.info(`inputDevice::getDeviceIds_test-01 exit`);
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();
} }
}) })
// 参数正确,判断一种或多种设备 // 参数正确,判断一种或多种设备
it("inputDevice::getDeviceIds_test-02", 0, function () { 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 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();
}) })
} 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();
} }
}) })
// 参数类型错误 // 参数类型错误
it("inputDevice::getDeviceIds_test-03", 0, function () { 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);
...@@ -74,10 +80,11 @@ export default function MultimodalInput_Device_test() { ...@@ -74,10 +80,11 @@ export default function MultimodalInput_Device_test() {
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();
}) })
// 参数数量错误 // 参数数量错误
it("inputDevice::getDeviceIds_test-04", 0, function () { 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) => {
...@@ -87,10 +94,11 @@ export default function MultimodalInput_Device_test() { ...@@ -87,10 +94,11 @@ export default function MultimodalInput_Device_test() {
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();
}) })
// 无效的设备id // 无效的设备id
it("inputDevice::getDevice_test-01", 0, function () { 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) => {
...@@ -105,62 +113,77 @@ export default function MultimodalInput_Device_test() { ...@@ -105,62 +113,77 @@ export default function MultimodalInput_Device_test() {
} 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 {
done();
} }
}) })
// 参数正常,返回值正常 // 参数正常,返回值正常
it("inputDevice::getDevice_test-02", 0, function () { 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((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) { if (err) {
expect(false).assertTrue(); expect(false).assertTrue();
} else { } else {
let arr = [];
for (let i = 0; i < data.length; i++) { for (let i = 0; i < data.length; i++) {
inputDevice.getDevice(data[i], (err, res) => { console.info(`inputDevice::getDevice_test-02 for`);
console.info(`getDevice:data ${JSON.stringify(data)}`); await getDevicePromise(data[i])
arr = Object.keys(res); }
expect(res.id).assertInstanceOf('Number'); function getDevicePromise(data) {
expect(res.name).assertInstanceOf('String'); console.info(`inputDevice::getDevice_test-02 getDevicePromise`)
expect(res.sources).assertInstanceOf('Array'); return new Promise((resolve, reject) => {
expect(res.axisRanges).assertInstanceOf('Array'); inputDevice.getDevice(data, (err, res) => {
expect(res.bus).assertInstanceOf('Number'); console.info(`getDevice:data =${JSON.stringify(data)}`);
expect(res.product).assertInstanceOf('Number'); console.info(`getDevice:res =${JSON.stringify(res)}`);
expect(res.vendor).assertInstanceOf('Number'); let arr = Object.keys(res);
expect(res.version).assertInstanceOf('Number'); expect(res.id).assertInstanceOf('Number');
expect(res.phys).assertInstanceOf('String'); expect(res.name).assertInstanceOf('String');
expect(res.uniq).assertInstanceOf('String'); expect(res.sources).assertInstanceOf('Array');
expect(res).assertInstanceOf('Object'); expect(res.axisRanges).assertInstanceOf('Array');
for (let j = 0; j < res.axisRanges.length; j++) { expect(res.bus).assertInstanceOf('Number');
expect(res.axisRanges[j].source == 'keyboard' || res.axisRanges[j].source == 'mouse' expect(res.product).assertInstanceOf('Number');
|| res.axisRanges[j].source == 'touchpad' || res.axisRanges[j].source == 'touchscreen' expect(res.vendor).assertInstanceOf('Number');
|| res.axisRanges[j].source == 'joystick' || res.axisRanges[j].source == 'trackball').assertTrue(); expect(res.version).assertInstanceOf('Number');
expect(res.axisRanges[j].axis == 'touchMajor' || res.axisRanges[j].axis == 'touchMinor' expect(res.phys).assertInstanceOf('String');
|| res.axisRanges[j].axis == 'orientation' || res.axisRanges[j].axis == 'x' expect(res.uniq).assertInstanceOf('String');
|| res.axisRanges[j].axis == 'y' || res.axisRanges[j].axis == 'pressure' expect(res).assertInstanceOf('Object');
|| res.axisRanges[j].axis == 'toolMinor' || res.axisRanges[j].axis == 'touchMajor' console.info(`inputDevice::getDevice_test-02 getDevice expect res`);
|| res.axisRanges[j].axis == 'NULL').assertTrue(); for (let j = 0; j < res.axisRanges.length; j++) {
expect(res.axisRanges[j].max).assertInstanceOf('Number'); expect(res.axisRanges[j].source == 'keyboard' || res.axisRanges[j].source == 'mouse'
expect(res.axisRanges[j]).assertInstanceOf('AxisRange'); || res.axisRanges[j].source == 'touchpad' || res.axisRanges[j].source == 'touchscreen'
expect(res.axisRanges[j].min).assertInstanceOf('Number'); || res.axisRanges[j].source == 'joystick' || res.axisRanges[j].source == 'trackball').assertTrue();
expect(res.axisRanges[j].fuzz).assertInstanceOf('Number'); expect(res.axisRanges[j].axis == 'touchMajor' || res.axisRanges[j].axis == 'touchMinor'
expect(res.axisRanges[j].flat).assertInstanceOf('Number'); || res.axisRanges[j].axis == 'orientation' || res.axisRanges[j].axis == 'x'
expect(res.axisRanges[j].resolution).assertInstanceOf('Number'); || 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`); console.info(`inputDevice::getDevice_test-02 exit`);
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();
} }
}) })
// 参数正常,返回值正常 // 参数正常,返回值正常
it("inputDevice::supportKeys_test-01", 0, function () { 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) => {
...@@ -174,15 +197,17 @@ export default function MultimodalInput_Device_test() { ...@@ -174,15 +197,17 @@ export default function MultimodalInput_Device_test() {
} }
} }
console.info(`inputDevice::supportKeys_test-01 exit`); console.info(`inputDevice::supportKeys_test-01 exit`);
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();
} }
}) })
// 第二个参数异常 // 第二个参数异常
it("inputDevice::supportKeys_test-02", 0, function () { 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) => {
...@@ -192,10 +217,11 @@ export default function MultimodalInput_Device_test() { ...@@ -192,10 +217,11 @@ export default function MultimodalInput_Device_test() {
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();
}) })
// 参数正常 // 参数正常
it("inputDevice::getKeyboardType_test-01", 0, function () { 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) => {
...@@ -209,15 +235,17 @@ export default function MultimodalInput_Device_test() { ...@@ -209,15 +235,17 @@ export default function MultimodalInput_Device_test() {
} }
} }
console.info(`inputDevice::getKeyboardType_test-01 exit`); console.info(`inputDevice::getKeyboardType_test-01 exit`);
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();
} }
}) })
//参数异常 //参数异常
it("inputDevice::getKeyboardType_test-02", 0, function () { 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);
...@@ -225,10 +253,11 @@ export default function MultimodalInput_Device_test() { ...@@ -225,10 +253,11 @@ export default function MultimodalInput_Device_test() {
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();
}); });
// 参数正常 // 参数正常
it("inputDevice::getKeyboardType_test-03", 0, function () { 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) => {
...@@ -245,10 +274,12 @@ export default function MultimodalInput_Device_test() { ...@@ -245,10 +274,12 @@ export default function MultimodalInput_Device_test() {
} }
} }
console.info(`inputDevice::getKeyboardType_test-03 exit`); console.info(`inputDevice::getKeyboardType_test-03 exit`);
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();
} }
}) })
...@@ -354,7 +385,7 @@ export default function MultimodalInput_Device_test() { ...@@ -354,7 +385,7 @@ export default function MultimodalInput_Device_test() {
* @tc.name MultimodalInputDevice_getDevice_Promise_test * @tc.name MultimodalInputDevice_getDevice_Promise_test
* @tc.desc inputdevice interface getDevice 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`); console.info(`MultimodalInputDevice_getDevice_Promise_test enter`);
try { try {
inputDevice.getDevice(-1).then(data => { inputDevice.getDevice(-1).then(data => {
...@@ -369,6 +400,7 @@ export default function MultimodalInput_Device_test() { ...@@ -369,6 +400,7 @@ export default function MultimodalInput_Device_test() {
expect(false).assertTrue(); expect(false).assertTrue();
} }
console.info(`MultimodalInputDevice_getDeviceIds_Promise_test exit`); console.info(`MultimodalInputDevice_getDeviceIds_Promise_test exit`);
done();
}) })
/** /**
...@@ -376,7 +408,7 @@ export default function MultimodalInput_Device_test() { ...@@ -376,7 +408,7 @@ export default function MultimodalInput_Device_test() {
* @tc.name MultimodalInputDevice_on_test * @tc.name MultimodalInputDevice_on_test
* @tc.desc inputdevice interface getDevice 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`); console.info(`MultimodalInputDevice_on_test enter`);
try { try {
let isPhysicalKeyboardExist = true; let isPhysicalKeyboardExist = true;
...@@ -398,6 +430,7 @@ export default function MultimodalInput_Device_test() { ...@@ -398,6 +430,7 @@ export default function MultimodalInput_Device_test() {
expect(false).assertTrue(); expect(false).assertTrue();
} }
console.info(`MultimodalInputDevice_on_test exit`); console.info(`MultimodalInputDevice_on_test exit`);
done();
}) })
/** /**
...@@ -405,12 +438,12 @@ export default function MultimodalInput_Device_test() { ...@@ -405,12 +438,12 @@ export default function MultimodalInput_Device_test() {
* @tc.name MultimodalInputDevice_off_test * @tc.name MultimodalInputDevice_off_test
* @tc.desc inputdevice interface getDevice 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`); console.info(`MultimodalInputDevice_off_test enter`);
function listener(data) { function listener(data) {
console.info("type: " + data.type + ", deviceId: " + data.deviceId); console.info("type: " + data.type + ", deviceId: " + data.deviceId);
expect(data.type == 'add' || data.type == 'remove').assertTrue(); expect(data.type == 'add' || data.type == 'remove').assertTrue();
expect(data).assertInstanceOf('DeviceListener'); expect(data).assertInstanceOf('Object');
} }
// 单独取消listener的监听。 // 单独取消listener的监听。
try { try {
...@@ -420,6 +453,7 @@ export default function MultimodalInput_Device_test() { ...@@ -420,6 +453,7 @@ export default function MultimodalInput_Device_test() {
expect(false).assertTrue(); expect(false).assertTrue();
} }
console.info(`MultimodalInputDevice_off_test exit`); console.info(`MultimodalInputDevice_off_test exit`);
done();
}) })
/** /**
...@@ -427,7 +461,7 @@ export default function MultimodalInput_Device_test() { ...@@ -427,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, function () { 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) => {
...@@ -437,9 +471,11 @@ export default function MultimodalInput_Device_test() { ...@@ -437,9 +471,11 @@ export default function MultimodalInput_Device_test() {
expect(data).assertInstanceOf('Array'); expect(data).assertInstanceOf('Array');
} }
console.info(`inputDevice::getDeviceList_async_test exit`); console.info(`inputDevice::getDeviceList_async_test exit`);
done();
}) })
} catch (err) { } catch (err) {
expect(false).assertTrue(); expect(false).assertTrue();
done();
} }
}) })
...@@ -449,7 +485,7 @@ export default function MultimodalInput_Device_test() { ...@@ -449,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, function () { 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 => {
...@@ -461,6 +497,7 @@ export default function MultimodalInput_Device_test() { ...@@ -461,6 +497,7 @@ export default function MultimodalInput_Device_test() {
expect(false).assertTrue(); expect(false).assertTrue();
} }
console.info(`inputDevice::getDeviceList_promise_test exit`); console.info(`inputDevice::getDeviceList_promise_test exit`);
done();
}) })
/** /**
...@@ -468,18 +505,23 @@ export default function MultimodalInput_Device_test() { ...@@ -468,18 +505,23 @@ 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, function () { 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 {
inputDevice.getDeviceList().then((data) => { await inputDevice.getDeviceList().then((data) => {
console.info(`getDeviceInfo:data assertInstanceOf Array` + typeof (data));
expect(data).assertInstanceOf('Array'); expect(data).assertInstanceOf('Array');
if (data.length() <= 0) { console.info(`getDeviceInfo:data assertInstanceOf Array end ${data.length}`);
if (data.length <= 0) {
done()
return; return;
} }
try { try {
inputDevice.getDeviceInfo(data[0], (err, res) => { inputDevice.getDeviceInfo(data[0], (err, res) => {
console.info(`getDeviceInfo:data enter`);
if (err) { if (err) {
expect(false).assertTrue(); expect(false).assertTrue();
done()
return; return;
} }
let arr = []; let arr = [];
...@@ -506,18 +548,21 @@ export default function MultimodalInput_Device_test() { ...@@ -506,18 +548,21 @@ export default function MultimodalInput_Device_test() {
|| res.axisRanges[j].axis == 'toolMinor' || res.axisRanges[j].axis == 'touchMajor' || res.axisRanges[j].axis == 'toolMinor' || res.axisRanges[j].axis == 'touchMajor'
|| res.axisRanges[j].axis == 'NULL').assertTrue(); || res.axisRanges[j].axis == 'NULL').assertTrue();
expect(res.axisRanges[j].max).assertInstanceOf('Number'); 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].min).assertInstanceOf('Number');
expect(res.axisRanges[j].fuzz).assertInstanceOf('Number'); expect(res.axisRanges[j].fuzz).assertInstanceOf('Number');
expect(res.axisRanges[j].flat).assertInstanceOf('Number'); expect(res.axisRanges[j].flat).assertInstanceOf('Number');
expect(res.axisRanges[j].resolution).assertInstanceOf('Number'); expect(res.axisRanges[j].resolution).assertInstanceOf('Number');
} }
done()
}) })
} catch (err) { } catch (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)}`);
expect(false).assertTrue(); expect(false).assertTrue();
} }
console.info(`inputDevice::getDeviceInfo_async_test exit`); console.info(`inputDevice::getDeviceInfo_async_test exit`);
...@@ -528,12 +573,12 @@ export default function MultimodalInput_Device_test() { ...@@ -528,12 +573,12 @@ 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, function () { 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) => {
expect(data).assertInstanceOf('Array'); expect(data).assertInstanceOf('Array');
if (data.length() <= 0) { if (data.length <= 0) {
return; return;
} }
try { try {
...@@ -562,7 +607,7 @@ export default function MultimodalInput_Device_test() { ...@@ -562,7 +607,7 @@ export default function MultimodalInput_Device_test() {
|| res.axisRanges[j].axis == 'toolMinor' || res.axisRanges[j].axis == 'touchMajor' || res.axisRanges[j].axis == 'toolMinor' || res.axisRanges[j].axis == 'touchMajor'
|| res.axisRanges[j].axis == 'NULL').assertTrue(); || res.axisRanges[j].axis == 'NULL').assertTrue();
expect(res.axisRanges[j].max).assertInstanceOf('Number'); 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].min).assertInstanceOf('Number');
expect(res.axisRanges[j].fuzz).assertInstanceOf('Number'); expect(res.axisRanges[j].fuzz).assertInstanceOf('Number');
expect(res.axisRanges[j].flat).assertInstanceOf('Number'); expect(res.axisRanges[j].flat).assertInstanceOf('Number');
...@@ -579,6 +624,7 @@ export default function MultimodalInput_Device_test() { ...@@ -579,6 +624,7 @@ export default function MultimodalInput_Device_test() {
expect(false).assertTrue(); expect(false).assertTrue();
} }
console.info(`inputDevice::getDeviceInfo_promise_test exit`); console.info(`inputDevice::getDeviceInfo_promise_test exit`);
done();
}) })
/** /**
...@@ -586,7 +632,7 @@ export default function MultimodalInput_Device_test() { ...@@ -586,7 +632,7 @@ export default function MultimodalInput_Device_test() {
* @tc.name MultimodalInputDevice_GetkeyboardType_Exception_test_01 * @tc.name MultimodalInputDevice_GetkeyboardType_Exception_test_01
* @tc.desc inputdevice interface getKeyboardType exception test * @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`); console.info(`MultimodalInputDevice_GetkeyboardType_Exception_test_01 enter`);
try { try {
inputDevice.getKeyboardType(); inputDevice.getKeyboardType();
...@@ -596,6 +642,7 @@ export default function MultimodalInput_Device_test() { ...@@ -596,6 +642,7 @@ export default function MultimodalInput_Device_test() {
expect(error.message).assertEqual(errMsg.PARAMETER_COUNT_MSG); expect(error.message).assertEqual(errMsg.PARAMETER_COUNT_MSG);
} }
console.info("MultimodalInputDevice_GetkeyboardType_Exception_test_01 exit"); console.info("MultimodalInputDevice_GetkeyboardType_Exception_test_01 exit");
done();
}) })
/** /**
...@@ -603,7 +650,7 @@ export default function MultimodalInput_Device_test() { ...@@ -603,7 +650,7 @@ export default function MultimodalInput_Device_test() {
* @tc.name MultimodalInputDevice_GetkeyboardType_Exception_test_02 * @tc.name MultimodalInputDevice_GetkeyboardType_Exception_test_02
* @tc.desc inputdevice interface getKeyboardType exception test * @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"); console.info("MultimodalInputDevice_GetkeyboardType_Exception_test_02 enter");
try { try {
inputDevice.getKeyboardType(`id`).then((data) => { inputDevice.getKeyboardType(`id`).then((data) => {
...@@ -619,6 +666,7 @@ export default function MultimodalInput_Device_test() { ...@@ -619,6 +666,7 @@ export default function MultimodalInput_Device_test() {
expect(error.message).assertEqual(errMsg.PARAMETER_DEVICEID_TYPE_MSG); expect(error.message).assertEqual(errMsg.PARAMETER_DEVICEID_TYPE_MSG);
} }
console.info("MultimodalInputDevice_GetkeyboardType_Exception_test_02 exit"); console.info("MultimodalInputDevice_GetkeyboardType_Exception_test_02 exit");
done();
}) })
/** /**
...@@ -626,7 +674,7 @@ export default function MultimodalInput_Device_test() { ...@@ -626,7 +674,7 @@ export default function MultimodalInput_Device_test() {
* @tc.name MultimodalInputDevice_SupportKeys_Exception_test_01 * @tc.name MultimodalInputDevice_SupportKeys_Exception_test_01
* @tc.desc inputdevice interface supportKeys exception test * @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"); console.info("MultimodalInputDevice_SupportKeys_Exception_test_01 enter");
try { try {
inputDevice.supportKeys((error, data) => { inputDevice.supportKeys((error, data) => {
...@@ -644,6 +692,7 @@ export default function MultimodalInput_Device_test() { ...@@ -644,6 +692,7 @@ export default function MultimodalInput_Device_test() {
expect(error.message).assertEqual(errMsg.PARAMETER_COUNT_MSG); expect(error.message).assertEqual(errMsg.PARAMETER_COUNT_MSG);
} }
console.info("MultimodalInputDevice_SupportKeys_Exception_test_01 exit"); console.info("MultimodalInputDevice_SupportKeys_Exception_test_01 exit");
done();
}) })
/** /**
...@@ -651,7 +700,7 @@ export default function MultimodalInput_Device_test() { ...@@ -651,7 +700,7 @@ export default function MultimodalInput_Device_test() {
* @tc.name MultimodalInputDevice_SupportKeys_Exception_test_02 * @tc.name MultimodalInputDevice_SupportKeys_Exception_test_02
* @tc.desc inputdevice interface supportKeys exception test * @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"); console.info("MultimodalInputDevice_SupportKeys_Exception_test_02 enter");
try { try {
inputDevice.supportKeys(`id`, [17, 22, 2055], (error, data) => { inputDevice.supportKeys(`id`, [17, 22, 2055], (error, data) => {
...@@ -669,6 +718,7 @@ export default function MultimodalInput_Device_test() { ...@@ -669,6 +718,7 @@ export default function MultimodalInput_Device_test() {
expect(error.message).assertEqual(errMsg.PARAMETER_DEVICEID_TYPE_MSG); expect(error.message).assertEqual(errMsg.PARAMETER_DEVICEID_TYPE_MSG);
} }
console.info("MultimodalInputDevice_SupportKeys_Exception_test_02 exit"); console.info("MultimodalInputDevice_SupportKeys_Exception_test_02 exit");
done();
}) })
/** /**
...@@ -676,7 +726,7 @@ export default function MultimodalInput_Device_test() { ...@@ -676,7 +726,7 @@ export default function MultimodalInput_Device_test() {
* @tc.name MultimodalInputDevice_GetDeviceInfo_Exception_test_01 * @tc.name MultimodalInputDevice_GetDeviceInfo_Exception_test_01
* @tc.desc inputdevice interface getDeviceInfo exception test * @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"); console.info("MultimodalInputDevice_GetDeviceInfo_Exception_test_01 enter");
try { try {
inputDevice.getDeviceInfo(); inputDevice.getDeviceInfo();
...@@ -686,6 +736,7 @@ export default function MultimodalInput_Device_test() { ...@@ -686,6 +736,7 @@ export default function MultimodalInput_Device_test() {
expect(error.message).assertEqual(errMsg.PARAMETER_COUNT_MSG); expect(error.message).assertEqual(errMsg.PARAMETER_COUNT_MSG);
} }
console.info("MultimodalInputDevice_GetDeviceInfo_Exception_test_01 exit"); console.info("MultimodalInputDevice_GetDeviceInfo_Exception_test_01 exit");
done();
}) })
/** /**
...@@ -693,7 +744,7 @@ export default function MultimodalInput_Device_test() { ...@@ -693,7 +744,7 @@ export default function MultimodalInput_Device_test() {
* @tc.name MultimodalInputDevice_GetDeviceInfo_Exception_test_02 * @tc.name MultimodalInputDevice_GetDeviceInfo_Exception_test_02
* @tc.desc inputdevice interface getDeviceInfo exception test * @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"); console.info("MultimodalInputDevice_GetDeviceInfo_Exception_test_02 enter");
try { try {
inputDevice.getDeviceList().then((data) => { inputDevice.getDeviceList().then((data) => {
...@@ -719,6 +770,7 @@ export default function MultimodalInput_Device_test() { ...@@ -719,6 +770,7 @@ export default function MultimodalInput_Device_test() {
expect(false).assertTrue(); expect(false).assertTrue();
} }
console.info("MultimodalInputDevice_GetDeviceInfo_Exception_test_02 exit"); console.info("MultimodalInputDevice_GetDeviceInfo_Exception_test_02 exit");
done();
}) })
/** /**
...@@ -726,7 +778,7 @@ export default function MultimodalInput_Device_test() { ...@@ -726,7 +778,7 @@ export default function MultimodalInput_Device_test() {
* @tc.name MultimodalInputDevice_GetDeviceList_Exception_test * @tc.name MultimodalInputDevice_GetDeviceList_Exception_test
* @tc.desc inputdevice interface 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"); console.info("MultimodalInputDevice_GetDeviceList_Exception_test enter");
try { try {
inputDevice.getDeviceList(null); inputDevice.getDeviceList(null);
...@@ -736,6 +788,7 @@ export default function MultimodalInput_Device_test() { ...@@ -736,6 +788,7 @@ export default function MultimodalInput_Device_test() {
expect(error.message).assertEqual(errMsg.PARAMETER_CALLBACK_TYPE_MSG); expect(error.message).assertEqual(errMsg.PARAMETER_CALLBACK_TYPE_MSG);
} }
console.info(`MultimodalInputDevice_GetDeviceList_Exception_test exit`); console.info(`MultimodalInputDevice_GetDeviceList_Exception_test exit`);
done();
}) })
/** /**
...@@ -743,7 +796,7 @@ export default function MultimodalInput_Device_test() { ...@@ -743,7 +796,7 @@ export default function MultimodalInput_Device_test() {
* @tc.name MultimodalInputDevice_On_Exception_test * @tc.name MultimodalInputDevice_On_Exception_test
* @tc.desc inputdevice interface on 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`); console.info(`MultimodalInputDevice_On_Exception_test enter`);
try { try {
inputDevice.on(); inputDevice.on();
...@@ -769,6 +822,7 @@ export default function MultimodalInput_Device_test() { ...@@ -769,6 +822,7 @@ export default function MultimodalInput_Device_test() {
expect(error.message).assertEqual(errMsg.PARAMETER_TYPE_MSG); expect(error.message).assertEqual(errMsg.PARAMETER_TYPE_MSG);
} }
console.info(`MultimodalInputDevice_On_Exception_test exit`); console.info(`MultimodalInputDevice_On_Exception_test exit`);
done();
}) })
/** /**
...@@ -776,7 +830,7 @@ export default function MultimodalInput_Device_test() { ...@@ -776,7 +830,7 @@ export default function MultimodalInput_Device_test() {
* @tc.name MultimodalInputDevice_Off_Exception_test * @tc.name MultimodalInputDevice_Off_Exception_test
* @tc.desc inputdevice interface off 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`); console.info(`MultimodalInputDevice_Off_Exception_test enter`);
try { try {
inputDevice.off(); inputDevice.off();
...@@ -794,6 +848,7 @@ export default function MultimodalInput_Device_test() { ...@@ -794,6 +848,7 @@ export default function MultimodalInput_Device_test() {
expect(error.message).assertEqual(errMsg.PARAMETER_LISTENER_TYPE_MSG); expect(error.message).assertEqual(errMsg.PARAMETER_LISTENER_TYPE_MSG);
} }
console.info(`MultimodalInputDevice_Off_Exception_test exit`); console.info(`MultimodalInputDevice_Off_Exception_test exit`);
done();
}) })
}) })
} }
...@@ -17,7 +17,7 @@ import MultimodalInput_Device_test from './InputDevice.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_KeyCode_test from './MultimodalInputKey_Code.test.js'
import MultimodalInput_Pointer_test from './Pointer.test.js' import MultimodalInput_Pointer_test from './Pointer.test.js'
export default function testsuite() { export default function testsuite() {
MultimodalInput_Device_test() MultimodalInput_Device_test()
MultimodalInput_KeyCode_test() MultimodalInput_KeyCode_test()
MultimodalInput_Pointer_test() MultimodalInput_Pointer_test()
} }
\ No newline at end of file
...@@ -20,18 +20,18 @@ export default function MultimodalInput_Pointer_test() { ...@@ -20,18 +20,18 @@ export default function MultimodalInput_Pointer_test() {
describe('MultimodalInput_Pointer_test', function () { describe('MultimodalInput_Pointer_test', function () {
const errCode = { const errCode = {
COMMON_PARAMETER_CODE : 401 COMMON_PARAMETER_CODE: 401
} }
const errMsg = { const errMsg = {
PARAMETER_COUNT_MSG : `Parameter count error`, PARAMETER_COUNT_MSG: `Parameter count error`,
PARAMETER_TYPE_MSG : `Parameter error. The type of type must be string.`, 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_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_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_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_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`); console.info(`MultimodalInput_Pointer_test::SetPointerVisibleTest_001 enter`);
try { try {
pointer.setPointerVisible(false, (err, data) => { pointer.setPointerVisible(false, (err, data) => {
...@@ -39,7 +39,7 @@ export default function MultimodalInput_Pointer_test() { ...@@ -39,7 +39,7 @@ export default function MultimodalInput_Pointer_test() {
console.info(`MultimodalInput_Pointer_test::SetPointerVisibleTest_001 failed, err=${JSON.stringify(err)}`); console.info(`MultimodalInput_Pointer_test::SetPointerVisibleTest_001 failed, err=${JSON.stringify(err)}`);
expect(false).assertTrue(); expect(false).assertTrue();
} else { } 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(); expect(true).assertTrue();
} }
}); });
...@@ -48,9 +48,10 @@ export default function MultimodalInput_Pointer_test() { ...@@ -48,9 +48,10 @@ export default function MultimodalInput_Pointer_test() {
expect(false).assertTrue(); expect(false).assertTrue();
} }
try { try {
pointer.isPointerVisible().then(data => { await pointer.isPointerVisible().then(data => {
console.info(`MultimodalInput_Pointer_test::PointerVisibleTest_001 success, data=${JSON.stringify(data)}`); console.info(`MultimodalInput_Pointer_test::PointerVisibleTest_001 success_2, data=${JSON.stringify(data)}`);
expect(data == false).assertTrue(); expect(data == false).assertTrue();
done();
}).catch((err) => { }).catch((err) => {
console.info(`MultimodalInput_Pointer_test::PointerVisibleTest_001 failed, err=${JSON.stringify(err)}`); console.info(`MultimodalInput_Pointer_test::PointerVisibleTest_001 failed, err=${JSON.stringify(err)}`);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -62,11 +63,11 @@ export default function MultimodalInput_Pointer_test() { ...@@ -62,11 +63,11 @@ export default function MultimodalInput_Pointer_test() {
console.info(`MultimodalInput_Pointer_test::PointerVisibleTest_001 exit`); 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`); console.info(`MultimodalInput_Pointer_test::PointerVisibleTest_002 enter`);
try { try {
pointer.setPointerVisible(true).then(data => { await pointer.setPointerVisible(true).then(data => {
console.info(`MultimodalInput_Pointer_test::PointerVisibleTest_002 success, data=${JSON.stringify(data)}`); console.info(`MultimodalInput_Pointer_test::PointerVisibleTest_002 success_1, data=${JSON.stringify(data)}`);
expect(true).assertTrue(); expect(true).assertTrue();
}).catch((err) => { }).catch((err) => {
console.info(`MultimodalInput_Pointer_test::PointerVisibleTest_002 failed, err=${JSON.stringify(err)}`); console.info(`MultimodalInput_Pointer_test::PointerVisibleTest_002 failed, err=${JSON.stringify(err)}`);
...@@ -82,8 +83,9 @@ export default function MultimodalInput_Pointer_test() { ...@@ -82,8 +83,9 @@ export default function MultimodalInput_Pointer_test() {
console.info(`MultimodalInput_Pointer_test::PointerVisibleTest_002 failed, err=${JSON.stringify(err)}`); console.info(`MultimodalInput_Pointer_test::PointerVisibleTest_002 failed, err=${JSON.stringify(err)}`);
expect(false).assertTrue(); expect(false).assertTrue();
} else { } 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(); expect(data == true).assertTrue();
done();
} }
}); });
} catch (error) { } catch (error) {
...@@ -93,173 +95,175 @@ export default function MultimodalInput_Pointer_test() { ...@@ -93,173 +95,175 @@ export default function MultimodalInput_Pointer_test() {
console.info(`MultimodalInput_Pointer_test::PointerVisibleTest_002 exit`); console.info(`MultimodalInput_Pointer_test::PointerVisibleTest_002 exit`);
}) })
it('MultimodalInput_Pointer_test::PointerSpeedTest_001', 0, function () { it('MultimodalInput_Pointer_test::SetPointerStyle_001', 0, async function (done) {
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`); console.info(`SetPointerStyle_001 enter`);
window.getTopWindow((err, data) => { function getPropertiesPromise(windowClass) {
if (err) { return new Promise((resolve, reject) => {
console.info(`SetPointerStyle_001 failed, err=${JSON.stringify(err)}`); windowClass.getProperties(async (err, data) => {
expect(false).assertTrue(); if (err && err.code != 0) {
}
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();
console.info(`SetPointerStyle_001 failed, err=${JSON.stringify(err)}`); console.info(`SetPointerStyle_001 failed, err=${JSON.stringify(err)}`);
}); expect(false).assertTrue();
} catch (error) { }
console.info(`SetPointerStyle_001 error`); try {
expect(false).assertTrue(); 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`); 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; var windowClass = data;
if (err) { if (err && err.code != 0) {
console.info(`SetPointerStyle_002 failed, err=${JSON.stringify(err)}`); console.info(`case:SetPointerStyle_002,getTopWindow failed, err=${JSON.stringify(err)}`);
expect(false).assertTrue(); return;
} }
windowClass.getProperties((err, data) => { console.info(`case:SetPointerStyle_002 ===========`);
if (err) { await getPropertiesPromise(data);
console.info(`SetPointerStyle_002 failed, err=${JSON.stringify(err)}`); console.info(`case:SetPointerStyle_002 exit`);
expect(false).assertTrue(); done();
}
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();
}
})
}) })
}) })
it('MultimodalInput_Pointer_test::GetPointerStyle_001', 0, function () { it('MultimodalInput_Pointer_test::GetPointerStyle_001', 0, async function (done) {
console.info(`GetPointerStyle_001 enter`); console.info(`GetPointerStyle_001 enter`);
window.getTopWindow((err, data) => { function getPropertiesPromise(windowClass) {
if (err) { return new Promise((resolve, reject) => {
console.info(`GetPointerStyle_001 failed, err=${JSON.stringify(err)}`); windowClass.getProperties(async (err, data) => {
expect(false).assertTrue(); if (err && err.code != 0) {
}
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) => {
console.info(`GetPointerStyle_001 failed, err=${JSON.stringify(err)}`); console.info(`GetPointerStyle_001 failed, err=${JSON.stringify(err)}`);
expect(false).assertTrue(); expect(false).assertTrue();
}); }
} catch (error) { try {
console.info(`GetPointerStyle_001 error`); var windowId = data.id;
expect(false).assertTrue(); 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`); console.info(`GetPointerStyle_002 enter`);
window.getTopWindow((err, data) => { function getPropertiesPromise(windowClass) {
if (err) { return new Promise((resolve, reject) => {
console.info(`GetPointerStyle_002 failed, err=${JSON.stringify(err)}`); windowClass.getProperties((err, data) => {
expect(false).assertTrue(); if (err && err.code != 0) {
} console.info(`GetPointerStyle_002 failed, err=${JSON.stringify(err)}`);
var windowClass = data; reject();
windowClass.getProperties((err, data) => { }
if (err) { try {
console.info(`GetPointerStyle_002 failed, err=${JSON.stringify(err)}`); var windowId = data.id;
expect(false).assertTrue(); pointer.getPointerStyle(windowId, (err, data) => {
} if (err) {
try { console.info(`GetPointerStyle_002 failed_1, err=${JSON.stringify(err)}`);
var windowId = data.id; expect(false).assertTrue();
pointer.getPointerStyle(windowId, (err, data) => { reject();
if (err) { } else {
console.info(`GetPointerStyle_002 failed, err=${JSON.stringify(err)}`); console.info(`GetPointerStyle_002 success, data=` + typeof (data));
expect(false).assertTrue(); expect(data).assertInstanceOf('Number');
} else { resolve();
console.info(`GetPointerStyle_002 success, data=${JSON.stringify(data)}`); }
expect(data).assertTrue('Number'); })
} } catch (error) {
}); console.info(`GetPointerStyle_002 error=${JSON.stringify(error)}`);
} catch (error) { expect(false).assertTrue();
console.info(`GetPointerStyle_002 error`); reject(error);
expect(false).assertTrue(); }
} })
}) })
}
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() { ...@@ -387,16 +391,15 @@ export default function MultimodalInput_Pointer_test() {
* @tc.name MultimodalInputDevice_PointerVisibleTest_Exception_Test_001 * @tc.name MultimodalInputDevice_PointerVisibleTest_Exception_Test_001
* @tc.desc Pointer interface PointerVisible exception test * @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`); console.info(`MultimodalInputDevice_PointerVisibleTest_Exception_Test_001 enter`);
try { try {
pointer.setPointerVisible(); await pointer.setPointerVisible();
} catch (error) { } catch (error) {
console.info(`PointerVisibleTest_Exception_Test_001: ${JSON.stringify(error, [`code`, `message`])}`); console.info(`PointerVisibleTest_Exception_Test_001: ${JSON.stringify(error, [`code`, `message`])}`);
expect(error.code).assertEqual(errCode.COMMON_PARAMETER_CODE); expect(error.code).assertEqual(errCode.COMMON_PARAMETER_CODE);
expect(error.message).assertEqual(errMsg.PARAMETER_VISIBLE_TYPE_MSG); expect(error.message).assertEqual(errMsg.PARAMETER_VISIBLE_TYPE_MSG);
} }
try { try {
pointer.isPointerVisible((error, data) => { pointer.isPointerVisible((error, data) => {
if (error) { if (error) {
...@@ -404,8 +407,9 @@ export default function MultimodalInput_Pointer_test() { ...@@ -404,8 +407,9 @@ export default function MultimodalInput_Pointer_test() {
expect(false).assertTrue(); expect(false).assertTrue();
} else { } else {
console.info(`PointerVisibleTest_Exception_Test_001 success`); console.info(`PointerVisibleTest_Exception_Test_001 success`);
expect(data).assertInstanceOf('Bool'); expect(data).assertInstanceOf('Boolean');
} }
done();
}); });
} catch (error) { } catch (error) {
console.info(`PointerVisibleTest_Exception_Test_001: ${JSON.stringify(error, [`code`, `message`])}`); console.info(`PointerVisibleTest_Exception_Test_001: ${JSON.stringify(error, [`code`, `message`])}`);
...@@ -418,7 +422,7 @@ export default function MultimodalInput_Pointer_test() { ...@@ -418,7 +422,7 @@ export default function MultimodalInput_Pointer_test() {
* @tc.name MultimodalInputDevice_PointerVisibleTest_Exception_Test_002 * @tc.name MultimodalInputDevice_PointerVisibleTest_Exception_Test_002
* @tc.desc Pointer interface PointerVisible exception test * @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`); console.info(`MultimodalInputDevice_PointerVisibleTest_Exception_Test_002 enter`);
try { try {
pointer.setPointerVisible(`state`, (error, data) => { pointer.setPointerVisible(`state`, (error, data) => {
...@@ -437,73 +441,14 @@ export default function MultimodalInput_Pointer_test() { ...@@ -437,73 +441,14 @@ export default function MultimodalInput_Pointer_test() {
} }
try { try {
pointer.isPointerVisible(null); await pointer.isPointerVisible(null);
} catch (error) { } catch (error) {
console.info(`PointerVisibleTest_Exception_Test_002: ${JSON.stringify(error, [`code`, `message`])}`); console.info(`PointerVisibleTest_Exception_Test_002: ${JSON.stringify(error, [`code`, `message`])}`);
expect(error.code).assertEqual(errCode.COMMON_PARAMETER_CODE); expect(error.code).assertEqual(errCode.COMMON_PARAMETER_CODE);
expect(error.message).assertEqual(errMsg.PARAMETER_CALLBACK_TYPE_MSG); expect(error.message).assertEqual(errMsg.PARAMETER_CALLBACK_TYPE_MSG);
} }
console.info(`MultimodalInputDevice_PointerVisibleTest_Exception_Test_002 exit`); console.info(`MultimodalInputDevice_PointerVisibleTest_Exception_Test_002 exit`);
}) done();
/**
* @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`);
}) })
/** /**
...@@ -511,10 +456,10 @@ export default function MultimodalInput_Pointer_test() { ...@@ -511,10 +456,10 @@ export default function MultimodalInput_Pointer_test() {
* @tc.name MultimodalInputDevice_PointerStyleTest_Exception_Test_001 * @tc.name MultimodalInputDevice_PointerStyleTest_Exception_Test_001
* @tc.desc Pointer interface PointerStyle exception test * @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`); console.info(`MultimodalInputDevice_PointerStyleTest_Exception_Test_001 enter`);
try { try {
pointer.setPointerStyle(10, 10, null); await pointer.setPointerStyle(10, 10, null);
} catch (error) { } catch (error) {
console.info(`PointerStyleTest_Exception_Test_001: ${JSON.stringify(error, [`code`, `message`])}`); console.info(`PointerStyleTest_Exception_Test_001: ${JSON.stringify(error, [`code`, `message`])}`);
expect(error.code).assertEqual(errCode.COMMON_PARAMETER_CODE); expect(error.code).assertEqual(errCode.COMMON_PARAMETER_CODE);
...@@ -522,7 +467,7 @@ export default function MultimodalInput_Pointer_test() { ...@@ -522,7 +467,7 @@ export default function MultimodalInput_Pointer_test() {
} }
try { try {
pointer.getPointerStyle(10, null).then((data) => { await pointer.getPointerStyle(10, null).then((data) => {
console.info(`PointerStyleTest_Exception_Test_001 success`); console.info(`PointerStyleTest_Exception_Test_001 success`);
expect(true).assertTrue(); expect(true).assertTrue();
}, (error) => { }, (error) => {
...@@ -535,6 +480,7 @@ export default function MultimodalInput_Pointer_test() { ...@@ -535,6 +480,7 @@ export default function MultimodalInput_Pointer_test() {
expect(error.message).assertEqual(errMsg.PARAMETER_CALLBACK_TYPE_MSG); expect(error.message).assertEqual(errMsg.PARAMETER_CALLBACK_TYPE_MSG);
} }
console.info(`MultimodalInputDevice_PointerStyleTest_Exception_Test_001 exit`); console.info(`MultimodalInputDevice_PointerStyleTest_Exception_Test_001 exit`);
done();
}) })
/** /**
...@@ -542,10 +488,10 @@ export default function MultimodalInput_Pointer_test() { ...@@ -542,10 +488,10 @@ export default function MultimodalInput_Pointer_test() {
* @tc.name MultimodalInputDevice_PointerStyleTest_Exception_Test_002 * @tc.name MultimodalInputDevice_PointerStyleTest_Exception_Test_002
* @tc.desc Pointer interface PointerStyle exception test * @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`); console.info(`MultimodalInputDevice_PointerStyleTest_Exception_Test_002 enter`);
try { try {
pointer.setPointerStyle().then((data) => { await pointer.setPointerStyle().then((data) => {
console.info(`PointerStyleTest_Exception_Test_002 success`); console.info(`PointerStyleTest_Exception_Test_002 success`);
expect(true).assertTrue(); expect(true).assertTrue();
}, (error) => { }, (error) => {
...@@ -559,13 +505,14 @@ export default function MultimodalInput_Pointer_test() { ...@@ -559,13 +505,14 @@ export default function MultimodalInput_Pointer_test() {
} }
try { try {
pointer.getPointerStyle(); await pointer.getPointerStyle();
} catch (error) { } catch (error) {
console.info(`PointerStyleTest_Exception_Test_002: ${JSON.stringify(error, [`code`, `message`])}`); console.info(`PointerStyleTest_Exception_Test_002: ${JSON.stringify(error, [`code`, `message`])}`);
expect(error.code).assertEqual(errCode.COMMON_PARAMETER_CODE); expect(error.code).assertEqual(errCode.COMMON_PARAMETER_CODE);
expect(error.message).assertEqual(errMsg.PARAMETER_WINDOWID_TYPE_MSG); expect(error.message).assertEqual(errMsg.PARAMETER_WINDOWID_TYPE_MSG);
} }
console.info(`MultimodalInputDevice_PointerStyleTest_Exception_Test_002 exit`); console.info(`MultimodalInputDevice_PointerStyleTest_Exception_Test_002 exit`);
done();
}) })
}) })
} }
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册