diff --git a/multimodalinput/input_js_standard/src/main/js/default/test/InputDevice.test.js b/multimodalinput/input_js_standard/src/main/js/default/test/InputDevice.test.js index 32e4647778fbf1bed36b4e468f80ea2cc3acb525..a8fcb99a1662a14a1da87d659dd5f2a90a4ac385 100644 --- a/multimodalinput/input_js_standard/src/main/js/default/test/InputDevice.test.js +++ b/multimodalinput/input_js_standard/src/main/js/default/test/InputDevice.test.js @@ -14,22 +14,41 @@ */ import inputDevice from '@ohos.multimodalInput.inputDevice'; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' +import { + describe, + beforeAll, + beforeEach, + afterEach, + afterAll, + it, + expect +} from 'deccjsunit/index' describe('MultimodalInput_test', function () { + // 参数正确,返回一个数组 it('inputDevice::getDeviceIds_test-01', 0, function () { console.log(`inputDevice::getDeviceIds_test-01 enter`); - inputDevice.getDeviceIds((obj) => { - if (!obj) { - console.log(`inputDevice::getDeviceIds_test-01 error:${JSON.stringify(obj)}`) - expect(false).assertTrue(); - } else { - console.log(`inputDevice::getDeviceIds_test-01 success:${JSON.stringify(obj)}`); - expect(obj).assertInstanceOf('Array'); - } - console.log(`inputDevice::getDeviceIds_test-01 exit`); + inputDevice.getDeviceIds((data, err) => { + if (err) { + expect(false).assertTrue(); + } else { + expect(data).assertInstanceOf('Array'); + } + console.log(`inputDevice::getDeviceIds_test-01 exit`); }) -}) + }) -}) + // 参数正确,判断一种或多种设备 + it("inputDevice::getDeviceIds_test-02", 0, function () { + console.log(`inputDevice::getDeviceIds_test-02 enter`); + inputDevice.getDeviceIds((data, err) => { + if (err) { + expect(false).assertTrue(); + } else { + expect(data.length > 0).assertTure(); + } + console.log(`inputDevice::getDeviceIds_test-02 exit`); + }) + }) +}) \ No newline at end of file