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

!5937 xts代码优化

Merge pull request !5937 from mayunteng/master
...@@ -16,12 +16,13 @@ ...@@ -16,12 +16,13 @@
import inputDevice from '@ohos.multimodalInput.inputDevice'; import inputDevice from '@ohos.multimodalInput.inputDevice';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestType, Size, Level } from '@ohos/hypium' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestType, Size, Level } from '@ohos/hypium'
export default function MultimodalInput_Device_test() { export default function MultimodalInput_Device_test() {
describe('MultimodalInput_Device_test', function () { describe('MultimodalInput_Device_test', function () {
// 参数正确,返回一个数组 // 参数正确,返回一个数组
it('inputDevice::getDeviceIds_test-01', 0, function () { it('inputDevice::getDeviceIds_test-01', 0, function () {
console.info(`inputDevice::getDeviceIds_test-01 enter`); console.info(`inputDevice::getDeviceIds_test-01 enter`);
inputDevice.getDeviceIds((data, err) => { try {
inputDevice.getDeviceIds((err, data) => {
if (err) { if (err) {
expect(false).assertTrue(); expect(false).assertTrue();
} else { } else {
...@@ -29,12 +30,17 @@ describe('MultimodalInput_Device_test', function () { ...@@ -29,12 +30,17 @@ describe('MultimodalInput_Device_test', function () {
} }
console.info(`inputDevice::getDeviceIds_test-01 exit`); console.info(`inputDevice::getDeviceIds_test-01 exit`);
}) })
} catch (error) {
console.info(`inputDevice::getDeviceIds_test-01 error`);
expect(false).assertTrue();
}
}) })
// 参数正确,判断一种或多种设备 // 参数正确,判断一种或多种设备
it("inputDevice::getDeviceIds_test-02", 0, function () { it("inputDevice::getDeviceIds_test-02", 0, function () {
console.info(`inputDevice::getDeviceIds_test-02 enter`); console.info(`inputDevice::getDeviceIds_test-02 enter`);
inputDevice.getDeviceIds((data, err) => { try {
inputDevice.getDeviceIds((err, data) => {
if (err) { if (err) {
expect(false).assertTrue(); expect(false).assertTrue();
} else { } else {
...@@ -42,6 +48,10 @@ describe('MultimodalInput_Device_test', function () { ...@@ -42,6 +48,10 @@ describe('MultimodalInput_Device_test', function () {
} }
console.info(`inputDevice::getDeviceIds_test-02 exit`); console.info(`inputDevice::getDeviceIds_test-02 exit`);
}) })
} catch (error) {
console.info(`inputDevice::getDeviceIds_test-02 error`);
expect(false).assertTrue();
}
}) })
// 参数类型错误 // 参数类型错误
...@@ -59,7 +69,7 @@ describe('MultimodalInput_Device_test', function () { ...@@ -59,7 +69,7 @@ describe('MultimodalInput_Device_test', function () {
it("inputDevice::getDeviceIds_test-04", 0, function () { it("inputDevice::getDeviceIds_test-04", 0, function () {
console.info(`inputDevice::getDeviceIds_test-04 enter`); console.info(`inputDevice::getDeviceIds_test-04 enter`);
try { try {
inputDevice.getDeviceIds(-1, (data) => { inputDevice.getDeviceIds(-1, (err, data) => {
console.info(data); console.info(data);
}); });
} catch (error) { } catch (error) {
...@@ -71,7 +81,8 @@ describe('MultimodalInput_Device_test', function () { ...@@ -71,7 +81,8 @@ describe('MultimodalInput_Device_test', function () {
// 无效的设备id // 无效的设备id
it("inputDevice::getDevice_test-01", 0, function () { it("inputDevice::getDevice_test-01", 0, function () {
console.info(`inputDevice::getDevice_test-01 enter`); console.info(`inputDevice::getDevice_test-01 enter`);
inputDevice.getDevice(-1, (data, err) => { try {
inputDevice.getDevice(-1, (err, data) => {
if (err) { if (err) {
expect(false).assertTrue(); expect(false).assertTrue();
console.info(`inputDevice::getDevice_test-01 ${JSON.stringify(err)}`); console.info(`inputDevice::getDevice_test-01 ${JSON.stringify(err)}`);
...@@ -80,18 +91,23 @@ describe('MultimodalInput_Device_test', function () { ...@@ -80,18 +91,23 @@ describe('MultimodalInput_Device_test', function () {
} }
console.info(`inputDevice::getDevice_test-01 exit`); console.info(`inputDevice::getDevice_test-01 exit`);
}) })
} catch (error) {
console.info(`inputDevice::getDevice_test-01 error`);
expect(false).assertTrue();
}
}) })
// 参数正常,返回值正常 // 参数正常,返回值正常
it("inputDevice::getDevice_test-02", 0, function () { it("inputDevice::getDevice_test-02", 0, function () {
console.info(`inputDevice::getDevice_test-02 enter`); console.info(`inputDevice::getDevice_test-02 enter`);
inputDevice.getDeviceIds((data, err) => { try {
inputDevice.getDeviceIds((err, data) => {
if (err) { if (err) {
expect(false).assertTrue(); expect(false).assertTrue();
} else { } else {
let arr = []; let arr = [];
for (let i = 0; i < data.length; i++) { for (let i = 0; i < data.length; i++) {
inputDevice.getDevice(data[i], (res, err) => { inputDevice.getDevice(data[i], (err, res) => {
console.info(`getDevice:data ${JSON.stringify(data)}`); console.info(`getDevice:data ${JSON.stringify(data)}`);
arr = Object.keys(res); arr = Object.keys(res);
expect(res.id).assertInstanceOf('Number'); expect(res.id).assertInstanceOf('Number');
...@@ -105,7 +121,7 @@ describe('MultimodalInput_Device_test', function () { ...@@ -105,7 +121,7 @@ describe('MultimodalInput_Device_test', function () {
expect(res.phys).assertInstanceOf('String'); expect(res.phys).assertInstanceOf('String');
expect(res.uniq).assertInstanceOf('String'); expect(res.uniq).assertInstanceOf('String');
expect(res).assertInstanceOf('Object'); expect(res).assertInstanceOf('Object');
for(let j = 0;j < res.axisRanges.length; j++ ){ for (let j = 0; j < res.axisRanges.length; j++) {
expect(res.axisRanges[j].source == 'keyboard' || res.axisRanges[j].source == 'mouse' expect(res.axisRanges[j].source == 'keyboard' || res.axisRanges[j].source == 'mouse'
|| res.axisRanges[j].source == 'touchpad' || res.axisRanges[j].source == 'touchscreen' || res.axisRanges[j].source == 'touchpad' || res.axisRanges[j].source == 'touchscreen'
|| res.axisRanges[j].source == 'joystick' || res.axisRanges[j].source == 'trackball').assertTrue(); || res.axisRanges[j].source == 'joystick' || res.axisRanges[j].source == 'trackball').assertTrue();
...@@ -126,30 +142,39 @@ describe('MultimodalInput_Device_test', function () { ...@@ -126,30 +142,39 @@ describe('MultimodalInput_Device_test', function () {
} }
console.info(`inputDevice::getDevice_test-02 exit`); console.info(`inputDevice::getDevice_test-02 exit`);
}); });
} catch (error) {
console.info(`inputDevice::getDevice_test-02 error`);
expect(false).assertTrue();
}
}) })
// 参数正常,返回值正常 // 参数正常,返回值正常
it("inputDevice::supportKeys_test-01", 0, function () { it("inputDevice::supportKeys_test-01", 0, function () {
console.info(`inputDevice::supportKeys_test-01 enter`); console.info(`inputDevice::supportKeys_test-01 enter`);
inputDevice.getDeviceIds((data, err) => { try {
inputDevice.getDeviceIds((err, data) => {
if (err) { if (err) {
expect(false).assertTrue(); expect(false).assertTrue();
} else { } else {
for (let i = 0; i < data.length; ++i) { for (let i = 0; i < data.length; ++i) {
inputDevice.supportKeys(data[i], [17, 22, 2055], (res, err) => { inputDevice.supportKeys(data[i], [17, 22, 2055], (err, res) => {
expect(res).assertInstanceOf('Array'); expect(res).assertInstanceOf('Array');
}); });
} }
} }
console.info(`inputDevice::supportKeys_test-01 exit`); console.info(`inputDevice::supportKeys_test-01 exit`);
}); });
} catch (error) {
console.info(`inputDevice::supportKeys_test-01 error`);
expect(false).assertTrue();
}
}) })
// 第二个参数异常 // 第二个参数异常
it("inputDevice::supportKeys_test-02", 0, function () { it("inputDevice::supportKeys_test-02", 0, function () {
console.info(`inputDevice::supportKeys_test-02 enter`); console.info(`inputDevice::supportKeys_test-02 enter`);
try { try {
inputDevice.supportKeys(0, 2022, (res) => { inputDevice.supportKeys(0, 2022, (err, res) => {
console.info(res); console.info(res);
}); });
} catch (error) { } catch (error) {
...@@ -161,18 +186,23 @@ describe('MultimodalInput_Device_test', function () { ...@@ -161,18 +186,23 @@ describe('MultimodalInput_Device_test', function () {
// 参数正常 // 参数正常
it("inputDevice::getKeyboardType_test-01", 0, function () { it("inputDevice::getKeyboardType_test-01", 0, function () {
console.info(`inputDevice::getKeyboardType_test-01 enter`); console.info(`inputDevice::getKeyboardType_test-01 enter`);
inputDevice.getDeviceIds((data, err) => { try {
inputDevice.getDeviceIds((err, data) => {
if (err) { if (err) {
expect(false).assertTrue(); expect(false).assertTrue();
} else { } else {
for (let i = 0; i < data.length; ++i) { for (let i = 0; i < data.length; ++i) {
inputDevice.getKeyboardType(data[i], (res, err) => { inputDevice.getKeyboardType(data[i], (err, res) => {
expect(res).assertInstanceOf('Number'); expect(res).assertInstanceOf('Number');
}); });
} }
} }
console.info(`inputDevice::getKeyboardType_test-01 exit`); console.info(`inputDevice::getKeyboardType_test-01 exit`);
}); });
} catch (error) {
console.info(`inputDevice::getKeyboardType_test-01 error`);
expect(false).assertTrue();
}
}) })
//参数异常 //参数异常
...@@ -189,18 +219,26 @@ describe('MultimodalInput_Device_test', function () { ...@@ -189,18 +219,26 @@ describe('MultimodalInput_Device_test', function () {
// 参数正常 // 参数正常
it("inputDevice::getKeyboardType_test-03", 0, function () { it("inputDevice::getKeyboardType_test-03", 0, function () {
console.info(`inputDevice::getKeyboardType_test-03 enter`); console.info(`inputDevice::getKeyboardType_test-03 enter`);
inputDevice.getDeviceIds((data, err) => { try {
inputDevice.getDeviceIds((err, data) => {
if (err) { if (err) {
expect(false).assertTrue(); expect(false).assertTrue();
} else { } else {
for (let i = 0; i < data.length; ++i) { for (let i = 0; i < data.length; ++i) {
inputDevice.getKeyboardType(data[i]).then((res) => { inputDevice.getKeyboardType(data[i]).then((res) => {
expect(res).assertInstanceOf('Number'); expect(res).assertInstanceOf('Number');
}).catch((err) => {
console.info(`inputDevice::getKeyboardType_test-03 failed, err=${JSON.stringify(err)}`);
expect(false).assertTrue();
}); });
} }
} }
console.info(`inputDevice::getKeyboardType_test-03 exit`); console.info(`inputDevice::getKeyboardType_test-03 exit`);
}); });
} catch (error) {
console.info(`inputDevice::getKeyboardType_test-03 error`);
expect(false).assertTrue();
}
}) })
/** /**
...@@ -274,22 +312,30 @@ describe('MultimodalInput_Device_test', function () { ...@@ -274,22 +312,30 @@ describe('MultimodalInput_Device_test', function () {
*/ */
it("MultimodalInputDevice_getDeviceIds_Promise_test", 0, async function (done) { it("MultimodalInputDevice_getDeviceIds_Promise_test", 0, async function (done) {
console.info(`MultimodalInputDevice_getDeviceIds_Promise_test enter`); console.info(`MultimodalInputDevice_getDeviceIds_Promise_test enter`);
inputDevice.getDeviceIds().then((data, err) => { try {
if (err) { inputDevice.getDeviceIds().then(data => {
console.info(`MultimodalInputDevice_getDeviceIds_Promise_test err`);
expect(false).assertTrue();
done();
} else {
console.info(`MultimodalInputDevice_getDeviceIds_Promise_test data`); console.info(`MultimodalInputDevice_getDeviceIds_Promise_test data`);
for (let i = 0; i < data.length; ++i) { for (let i = 0; i < data.length; ++i) {
inputDevice.supportKeys(data[i], [17, 22, 2055]).then((res, err) => { inputDevice.supportKeys(data[i], [17, 22, 2055]).then(res => {
console.info(`MultimodalInputDevice_getDeviceIds_Promise_test res`);
expect(res).assertInstanceOf('Array'); expect(res).assertInstanceOf('Array');
}).catch((err) => {
console.info(`MultimodalInputDevice_getDeviceIds_Promise_test failed, err=${JSON.stringify(err)}`);
expect(false).assertTrue();
}); });
} }
done(); done();
}).catch((err) => {
console.info(`MultimodalInputDevice_getDeviceIds_Promise_test failed, err=${JSON.stringify(err)}`);
expect(false).assertTrue();
done();
});
} catch (error) {
console.info(`MultimodalInputDevice_getDeviceIds_Promise_test error`);
expect(false).assertTrue();
done();
} }
console.info(`MultimodalInputDevice_getDeviceIds_Promise_test exit`); console.info(`MultimodalInputDevice_getDeviceIds_Promise_test exit`);
});
}) })
/** /**
...@@ -299,17 +345,19 @@ describe('MultimodalInput_Device_test', function () { ...@@ -299,17 +345,19 @@ describe('MultimodalInput_Device_test', function () {
*/ */
it("MultimodalInputDevice_getDevice_Promise_test", 0, function () { it("MultimodalInputDevice_getDevice_Promise_test", 0, function () {
console.info(`MultimodalInputDevice_getDevice_Promise_test enter`); console.info(`MultimodalInputDevice_getDevice_Promise_test enter`);
inputDevice.getDevice(-1).then((data, err) => { try {
if (err) { inputDevice.getDevice(-1).then(data => {
console.info(`MultimodalInputDevice_getDevice_Promise_test err`);
expect(false).assertTrue();
console.info(`MultimodalInputDevice_getDevice_Promise_test ${JSON.stringify(err)}`);
} else {
console.info(`MultimodalInputDevice_getDevice_Promise_test data`); console.info(`MultimodalInputDevice_getDevice_Promise_test data`);
expect(JSON.stringify(data) !== "{}").assertTrue(); expect(JSON.stringify(data) !== "{}").assertTrue();
} }).catch((err) => {
console.info(`MultimodalInputDevice_getDevice_Promise_test exit`); console.info(`MultimodalInputDevice_getDevice_Promise_test err`);
expect(false).assertTrue();
}); });
} catch (error) {
console.info(`MultimodalInputDevice_getDeviceIds_Promise_test error`);
expect(false).assertTrue();
}
console.info(`MultimodalInputDevice_getDeviceIds_Promise_test exit`);
}) })
/** /**
...@@ -319,11 +367,12 @@ describe('MultimodalInput_Device_test', function () { ...@@ -319,11 +367,12 @@ describe('MultimodalInput_Device_test', function () {
*/ */
it("MultimodalInputDevice_on_test", 0, function () { it("MultimodalInputDevice_on_test", 0, function () {
console.info(`MultimodalInputDevice_on_test enter`); console.info(`MultimodalInputDevice_on_test enter`);
try {
let isPhysicalKeyboardExist = true; let isPhysicalKeyboardExist = true;
inputDevice.on("change", (data) => { inputDevice.on("change", (data) => {
console.info("type: " + data.type + ", deviceId: " + data.deviceId); console.info("MultimodalInputDevice_on_test type: " + data.type + ", deviceId: " + data.deviceId);
inputDevice.getKeyboardType(data.deviceId, (err, ret) => { inputDevice.getKeyboardType(data.deviceId, (err, ret) => {
console.info("The keyboard type of the device is: " + ret); console.info("MultimodalInputDevice_on_test The keyboard type of the device is: " + ret);
if (ret == inputDevice.KeyboardType.ALPHABETIC_KEYBOARD && data.type == 'add') { if (ret == inputDevice.KeyboardType.ALPHABETIC_KEYBOARD && data.type == 'add') {
// 监听物理键盘已连接。 // 监听物理键盘已连接。
isPhysicalKeyboardExist = true; isPhysicalKeyboardExist = true;
...@@ -333,6 +382,10 @@ describe('MultimodalInput_Device_test', function () { ...@@ -333,6 +382,10 @@ describe('MultimodalInput_Device_test', function () {
} }
}); });
}); });
} catch (error) {
console.info(`MultimodalInputDevice_on_test error`);
expect(false).assertTrue();
}
console.info(`MultimodalInputDevice_on_test exit`); console.info(`MultimodalInputDevice_on_test exit`);
}) })
...@@ -345,11 +398,16 @@ describe('MultimodalInput_Device_test', function () { ...@@ -345,11 +398,16 @@ describe('MultimodalInput_Device_test', function () {
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('DeviceListener');
} }
// 单独取消listener的监听。 // 单独取消listener的监听。
try {
inputDevice.off("change", listener); inputDevice.off("change", listener);
} catch (error) {
console.info(`MultimodalInputDevice_on_test error`);
expect(false).assertTrue();
}
console.info(`MultimodalInputDevice_off_test exit`); console.info(`MultimodalInputDevice_off_test exit`);
}) })
...@@ -427,7 +485,7 @@ describe('MultimodalInput_Device_test', function () { ...@@ -427,7 +485,7 @@ describe('MultimodalInput_Device_test', function () {
expect(res.phys).assertInstanceOf('String'); expect(res.phys).assertInstanceOf('String');
expect(res.uniq).assertInstanceOf('String'); expect(res.uniq).assertInstanceOf('String');
expect(res).assertInstanceOf('Object'); expect(res).assertInstanceOf('Object');
for(let j = 0;j < res.axisRanges.length; j++ ){ for (let j = 0; j < res.axisRanges.length; j++) {
expect(res.axisRanges[j].source == 'keyboard' || res.axisRanges[j].source == 'mouse' expect(res.axisRanges[j].source == 'keyboard' || res.axisRanges[j].source == 'mouse'
|| res.axisRanges[j].source == 'touchpad' || res.axisRanges[j].source == 'touchscreen' || res.axisRanges[j].source == 'touchpad' || res.axisRanges[j].source == 'touchscreen'
|| res.axisRanges[j].source == 'joystick' || res.axisRanges[j].source == 'trackball').assertTrue(); || res.axisRanges[j].source == 'joystick' || res.axisRanges[j].source == 'trackball').assertTrue();
...@@ -483,7 +541,7 @@ describe('MultimodalInput_Device_test', function () { ...@@ -483,7 +541,7 @@ describe('MultimodalInput_Device_test', function () {
expect(res.phys).assertInstanceOf('String'); expect(res.phys).assertInstanceOf('String');
expect(res.uniq).assertInstanceOf('String'); expect(res.uniq).assertInstanceOf('String');
expect(res).assertInstanceOf('Object'); expect(res).assertInstanceOf('Object');
for(let j = 0;j < res.axisRanges.length; j++ ){ for (let j = 0; j < res.axisRanges.length; j++) {
expect(res.axisRanges[j].source == 'keyboard' || res.axisRanges[j].source == 'mouse' expect(res.axisRanges[j].source == 'keyboard' || res.axisRanges[j].source == 'mouse'
|| res.axisRanges[j].source == 'touchpad' || res.axisRanges[j].source == 'touchscreen' || res.axisRanges[j].source == 'touchpad' || res.axisRanges[j].source == 'touchscreen'
|| res.axisRanges[j].source == 'joystick' || res.axisRanges[j].source == 'trackball').assertTrue(); || res.axisRanges[j].source == 'joystick' || res.axisRanges[j].source == 'trackball').assertTrue();
...@@ -511,5 +569,5 @@ describe('MultimodalInput_Device_test', function () { ...@@ -511,5 +569,5 @@ describe('MultimodalInput_Device_test', function () {
} }
console.info(`inputDevice::getDeviceInfo_promise_test exit`); console.info(`inputDevice::getDeviceInfo_promise_test exit`);
}) })
}) })
} }
...@@ -13,13 +13,11 @@ ...@@ -13,13 +13,11 @@
* limitations under the License. * limitations under the License.
*/ */
import MultimodalInput_Device_test from './InputDevice.test.js' 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
...@@ -12,12 +12,12 @@ ...@@ -12,12 +12,12 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import inputkeyCode from '@ohos.multimodalInput.keyCode'; import inputkeyCode from '@ohos.multimodalInput.keyCode';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestType, Size, Level } from '@ohos/hypium' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestType, Size, Level } from '@ohos/hypium'
export default function MultimodalInput_KeyCode_test() { export default function MultimodalInput_KeyCode_test() {
describe('MultimodalInput_KeyCode_test', function () { describe('MultimodalInput_KeyCode_test', function () {
it('Multimodalinput_KeyCode_test::SUB_MMI_KeyCodeTest_0010', 0, function () { it('Multimodalinput_KeyCode_test::SUB_MMI_KeyCodeTest_0010', 0, function () {
console.info(`Multimodalinput_KeyCode_test::SUB_MMI_KeyCodeTest_0010 enter`); console.info(`Multimodalinput_KeyCode_test::SUB_MMI_KeyCodeTest_0010 enter`);
...@@ -2658,6 +2658,5 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestT ...@@ -2658,6 +2658,5 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestT
console.info(`Multimodalinput_KeyCode_test::SUB_MMI_KeyCodeTest_348 exit`); console.info(`Multimodalinput_KeyCode_test::SUB_MMI_KeyCodeTest_348 exit`);
}) })
}) })
} }
...@@ -16,43 +16,56 @@ ...@@ -16,43 +16,56 @@
import pointer from '@ohos.multimodalInput.pointer' import pointer from '@ohos.multimodalInput.pointer'
import window from '@ohos.window' import window from '@ohos.window'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestType, Size, Level } from '@ohos/hypium' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestType, Size, Level } from '@ohos/hypium'
export default function MultimodalInput_Pointer_test() { export default function MultimodalInput_Pointer_test() {
describe('MultimodalInput_Pointer_test', function () { describe('MultimodalInput_Pointer_test', function () {
it('MultimodalInput_Pointer_test::PointerVisibleTest_001', 0, function () { it('MultimodalInput_Pointer_test::PointerVisibleTest_001', 0, function () {
console.info(`MultimodalInput_Pointer_test::SetPointerVisibleTest_001 enter`); console.info(`MultimodalInput_Pointer_test::SetPointerVisibleTest_001 enter`);
var callback = function (err, data) { try {
pointer.setPointerVisible(false, (err, data) => {
if (err) { if (err) {
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`); console.info(`MultimodalInput_Pointer_test::SetPointerVisibleTest_001 success. data=${JSON.stringify(data)}`);
expect(true).assertTrue(); expect(true).assertTrue();
} }
}; });
pointer.setPointerVisible(false, callback); } catch (error) {
console.info(`MultimodalInput_Pointer_test::SetPointerVisibleTest_001 error`);
expect(false).assertTrue();
}
try {
pointer.isPointerVisible().then(data => { pointer.isPointerVisible().then(data => {
console.info(`MultimodalInput_Pointer_test::PointerVisibleTest_001 success, data=${JSON.stringify(data)}`); console.info(`MultimodalInput_Pointer_test::PointerVisibleTest_001 success, data=${JSON.stringify(data)}`);
expect(data == false).assertTrue(); expect(data == false).assertTrue();
}, 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();
}); });
} catch (error) {
console.info(`MultimodalInput_Pointer_test::SetPointerVisibleTest_001 error`);
expect(false).assertTrue();
}
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, function () {
console.info(`MultimodalInput_Pointer_test::PointerVisibleTest_002 enter`); console.info(`MultimodalInput_Pointer_test::PointerVisibleTest_002 enter`);
try {
pointer.setPointerVisible(true).then(data => { 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, data=${JSON.stringify(data)}`);
expect(true).assertTrue(); expect(true).assertTrue();
}, 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)}`);
expect(false).assertTrue(); expect(false).assertTrue();
}); });
} catch (error) {
var callback = function (err, data) { console.info(`MultimodalInput_Pointer_test::PointerVisibleTest_002 error`);
expect(false).assertTrue();
}
try {
pointer.isPointerVisible((err, data) => {
if (err) { if (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)}`);
expect(false).assertTrue(); expect(false).assertTrue();
...@@ -60,8 +73,11 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestT ...@@ -60,8 +73,11 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestT
console.info(`MultimodalInput_Pointer_test::PointerVisibleTest_002 success, data=${JSON.stringify(data)}`); console.info(`MultimodalInput_Pointer_test::PointerVisibleTest_002 success, data=${JSON.stringify(data)}`);
expect(data == true).assertTrue(); expect(data == true).assertTrue();
} }
}; });
pointer.isPointerVisible(callback); } catch (error) {
console.info(`MultimodalInput_Pointer_test::PointerVisibleTest_002 error`);
expect(false).assertTrue();
}
console.info(`MultimodalInput_Pointer_test::PointerVisibleTest_002 exit`); console.info(`MultimodalInput_Pointer_test::PointerVisibleTest_002 exit`);
}) })
...@@ -78,14 +94,19 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestT ...@@ -78,14 +94,19 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestT
console.info(`SetPointerStyle_001 failed, err=${JSON.stringify(err)}`); console.info(`SetPointerStyle_001 failed, err=${JSON.stringify(err)}`);
expect(false).assertTrue(); expect(false).assertTrue();
} }
try {
var windowId = data.id; var windowId = data.id;
pointer.setPointerStyle(windowId, 4).then(() => { pointer.setPointerStyle(windowId, 4).then(() => {
expect(true).assertTrue(); expect(true).assertTrue();
console.info(`SetPointerStyle_001 success`); console.info(`SetPointerStyle_001 success`);
}).catch((err) => { }).catch((err) => {
expect(false).assertTrue(); expect(false).assertTrue();
console.info("promise::catch", err); console.info(`SetPointerStyle_001 failed, err=${JSON.stringify(err)}`);
}); });
} catch (error) {
console.info(`SetPointerStyle_001 error`);
expect(false).assertTrue();
}
}) })
}) })
}) })
...@@ -103,6 +124,7 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestT ...@@ -103,6 +124,7 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestT
console.info(`SetPointerStyle_002 failed, err=${JSON.stringify(err)}`); console.info(`SetPointerStyle_002 failed, err=${JSON.stringify(err)}`);
expect(false).assertTrue(); expect(false).assertTrue();
} }
try {
var windowId = data.id; var windowId = data.id;
pointer.setPointerStyle(windowId, 4, (err) => { pointer.setPointerStyle(windowId, 4, (err) => {
if (err) { if (err) {
...@@ -113,6 +135,10 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestT ...@@ -113,6 +135,10 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestT
expect(true).assertTrue(); expect(true).assertTrue();
} }
}); });
} catch (error) {
console.info(`SetPointerStyle_002 error`);
expect(false).assertTrue();
}
}) })
}) })
}) })
...@@ -131,13 +157,18 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestT ...@@ -131,13 +157,18 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestT
expect(false).assertTrue(); expect(false).assertTrue();
} }
var windowId = data.id; var windowId = data.id;
try {
pointer.getPointerStyle(windowId).then((data) => { pointer.getPointerStyle(windowId).then((data) => {
console.info(`GetPointerStyle_001 success, data=${JSON.stringify(data)}`); console.info(`GetPointerStyle_001 success, data=${JSON.stringify(data)}`);
expect(data).assertTrue('Number'); expect(data).assertTrue('Number');
}).catch((err) => { }).catch((err) => {
console.info("promise::catch", err); console.info(`GetPointerStyle_001 failed, err=${JSON.stringify(err)}`);
expect(false).assertTrue(); expect(false).assertTrue();
}); });
} catch (error) {
console.info(`GetPointerStyle_001 error`);
expect(false).assertTrue();
}
}) })
}) })
}) })
...@@ -155,6 +186,7 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestT ...@@ -155,6 +186,7 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestT
console.info(`GetPointerStyle_002 failed, err=${JSON.stringify(err)}`); console.info(`GetPointerStyle_002 failed, err=${JSON.stringify(err)}`);
expect(false).assertTrue(); expect(false).assertTrue();
} }
try {
var windowId = data.id; var windowId = data.id;
pointer.getPointerStyle(windowId, (err, data) => { pointer.getPointerStyle(windowId, (err, data) => {
if (err) { if (err) {
...@@ -165,6 +197,10 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestT ...@@ -165,6 +197,10 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestT
expect(data).assertTrue('Number'); expect(data).assertTrue('Number');
} }
}); });
} catch (error) {
console.info(`GetPointerStyle_002 error`);
expect(false).assertTrue();
}
}) })
}) })
}) })
...@@ -287,5 +323,5 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestT ...@@ -287,5 +323,5 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestT
console.info('MultimodalInput_Pointer_test::Pointer_MIDDLE_BTN_NORTH_SOUTH_WEST_EAST_test = ' + pointer.PointerStyle.MIDDLE_BTN_NORTH_SOUTH_WEST_EAST); console.info('MultimodalInput_Pointer_test::Pointer_MIDDLE_BTN_NORTH_SOUTH_WEST_EAST_test = ' + pointer.PointerStyle.MIDDLE_BTN_NORTH_SOUTH_WEST_EAST);
expect(pointer.PointerStyle.MIDDLE_BTN_NORTH_SOUTH_WEST_EAST == 38).assertTrue(); expect(pointer.PointerStyle.MIDDLE_BTN_NORTH_SOUTH_WEST_EAST == 38).assertTrue();
}) })
}) })
} }
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册