From 26d50831eb5fc038389989192be68c4a7acbef7b Mon Sep 17 00:00:00 2001 From: logic42 Date: Thu, 21 Jul 2022 02:28:44 +0000 Subject: [PATCH] add multimodalinput and powermgr and sensors testcase for 3.1release Signed-off-by: logic42 --- .../main/js/default/test/InputDevice.test.js | 122 ++++++++++++++---- .../js/default/test/thermal_unittest.test.js | 21 +++ .../test/SensorGeneralalgorithm.test.js | 19 +++ 3 files changed, 135 insertions(+), 27 deletions(-) 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 ee234e025..343935133 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 @@ -28,87 +28,155 @@ describe('MultimodalInput_test', function () { // 参数正确,返回一个数组 it('inputDevice::getDeviceIds_test-01', 0, function () { - console.log(`inputDevice::getDeviceIds_test-01 enter`); - inputDevice.getDeviceIds((data, err) => { + console.info(`inputDevice::getDeviceIds_test-01 enter`); + inputDevice.getDeviceIds((err, data) => { if (err) { expect(false).assertTrue(); } else { expect(data).assertInstanceOf('Array'); } - console.log(`inputDevice::getDeviceIds_test-01 exit`); + console.info(`inputDevice::getDeviceIds_test-01 exit`); }) }) // 参数正确,判断一种或多种设备 it("inputDevice::getDeviceIds_test-02", 0, function () { - console.log(`inputDevice::getDeviceIds_test-02 enter`); - inputDevice.getDeviceIds((data, err) => { + console.info(`inputDevice::getDeviceIds_test-02 enter`); + inputDevice.getDeviceIds((err, data) => { if (err) { expect(false).assertTrue(); } else { expect(data.length > 0).assertTure(); } - console.log(`inputDevice::getDeviceIds_test-02 exit`); + console.info(`inputDevice::getDeviceIds_test-02 exit`); }) }) it("inputDevice::getDevice_test-01", 0, function () { - console.log(`inputDevice::getDevice_test-03 enter`); - inputDevice.getDevice(-1, (data, err) => { + console.info(`inputDevice::getDevice_test-03 enter`); + inputDevice.getDevice(-1, (err, data) => { if (err) { expect(false).assertTrue(); - console.log(`inputDevice::getDevice_test-03 ${JSON.stringify(err)}`); + console.info(`inputDevice::getDevice_test-03 ${JSON.stringify(err)}`); } else { expect(JSON.stringify(data) !== "{}").assertTrue(); } - console.log(`inputDevice::getDevice_test-03 exit`); + console.info(`inputDevice::getDevice_test-03 exit`); }) }) // 参数正常,返回值正常 it("inputDevice::getDevice_test-02", 0, function () { - console.log(`inputDevice::getDevice_test-04 enter`); - inputDevice.getDeviceIds((data, err) => { + console.info(`inputDevice::getDevice_test-04 enter`); + inputDevice.getDeviceIds((err, data) => { if (err) { expect(false).assertTrue(); } else { let arr = []; for (let i = 0; i < data.length; i++) { inputDevice.getDevice(data[i], (res, err) => { - console.log(`getDevice:data_i ${JSON.stringify(data[i])}`) - console.log(`getDevice:data ${JSON.stringify(data)}`) - console.log(`getDevice:err ${JSON.stringify(err)}`) + console.info(`getDevice:data_i ${JSON.stringify(data[i])}`) + console.info(`getDevice:data ${JSON.stringify(data)}`) + console.info(`getDevice:err ${JSON.stringify(err)}`) arr = Object.keys(res); }) expect(arr.length > 0).assertTrue(); } } - console.log(`inputDevice::getDevice_test-04 exit`); + console.info(`inputDevice::getDevice_test-04 exit`); }); }) - it("inputDevice::getDevice_test03", 0, function () { - console.log(`inputDevice::getDevice_test-04 enter`); - inputDevice.getDeviceIds((data, err) => { + it("inputDevice::getDevice_test03", 0, async function () { + console.info(`inputDevice::getDevice_test-04 enter`); + await inputDevice.getDeviceIds((err, data) => { if (err) { expect(false).assertTrue(); + done(); } else { let arr = []; for (let i = 0; i < data.length; i++) { inputDevice.getDevice(data[i], (res, err) => { - console.log(`getDevice:data_i ${JSON.stringify(data[i])}`) - console.log(`getDevice:data ${JSON.stringify(data)}`) - console.log(`getDevice:err ${JSON.stringify(err)}`) + console.info(`getDevice:data_i ${JSON.stringify(data[i])}`) + console.info(`getDevice:data ${JSON.stringify(data)}`) + console.info(`getDevice:err ${JSON.stringify(err)}`) arr = Object.keys(res); - expect(data[i].id).assertInstanceOf('number'); - expect(data[i].sources).assertInstanceOf('string'); - expect(data[i].name).assertInstanceOf('Array'); - expect(data[i].axisRanges).assertInstanceOf('Array'); + expect(res).assertInstanceOf('InputDeviceData'); + expect(res.id).assertInstanceOf('number'); + expect(res.sources).assertInstanceOf('string'); + expect(res.name).assertInstanceOf('Array'); + expect(res.axisRanges).assertInstanceOf('Array'); + for (let j = 0; j < res.sources.length; j++) { + expect(res.sources[j]).assertInstanceOf('SourceType'); + expect(res.sources[j] == 'keyboard' || res.sources[j] == 'mouse' || + res.sources[j] == 'touchpad' || res.sources[j] == 'touchscreen' || + res.sources[j] == 'joystick' || res.sources[j] == 'trackball').assertTrue(); + } + for (let k = 0; k < res.axisRanges.length; k++) { + expect(res.axisRanges[i]).assertInstanceOf('AxisRange'); + expect(res.axisRanges[i].source).assertInstanceOf('SourceType'); + expect(res.axisRanges[i].axis).assertInstanceOf('AxisType'); + expect(res.axisRanges[i].axis == 'NULL').assertTrue(); + expect(res.axisRanges[i].max).assertInstanceOf('number'); + expect(res.axisRanges[i].min).assertInstanceOf('number'); + } }) expect(arr.length > 0).assertTrue(); } } - console.log(`inputDevice::getDevice_test-04 exit`); + console.info(`inputDevice::getDevice_test-04 exit`); + }); + }) + + /** + * @tc.number MultimodalInputDevice_js_0070 + * @tc.name MultimodalInputDevice_getDeviceIds_Promise_test + * @tc.desc inputdevice interface getDeviceIds & supportKeys test + */ + it("MultimodalInputDevice_getDeviceIds_Promise_test", 0, async function () { + console.info(`inputDevice::supportKeys_test-01 enter`); + await inputDevice.getDeviceIds().then((data) => { + console.info(`getDevice:data ${JSON.stringify(data)}`) + for (let i = 0; i < data.length; ++i) { + inputDevice.getDevice(data[i]).then((res) => { + console.info(`getDevice:data_i ${JSON.stringify(data[i])}`) + console.info(`getDevice:res ${JSON.stringify(res)}`) + arr = Object.keys(res); + expect(res.id).assertInstanceOf('number'); + expect(res.sources).assertInstanceOf('string'); + expect(res.name).assertInstanceOf('Array'); + expect(res.axisRanges).assertInstanceOf('Array'); + for (let j = 0; j < res.sources.length; j++) { + expect(res.sources[j]).assertInstanceOf('SourceType'); + expect(res.sources[j] == 'keyboard' || res.sources[j] == 'mouse' || + res.sources[j] == 'touchpad' || res.sources[j] == 'touchscreen' || + res.sources[j] == 'joystick' || res.sources[j] == 'trackball').assertTrue(); + } + for (let k = 0; k < res.axisRanges.length; k++) { + expect(res.axisRanges[i]).assertInstanceOf('AxisRange'); + expect(res.axisRanges[i].source).assertInstanceOf('SourceType'); + expect(res.axisRanges[i].axis).assertInstanceOf('AxisType'); + expect(res.axisRanges[i].axis == 'NULL').assertTrue(); + expect(res.axisRanges[i].max).assertInstanceOf('number'); + expect(res.axisRanges[i].min).assertInstanceOf('number'); + } + done(); + }, (err) => { + if (err) { + expect(false).assertTrue(); + console.info(`getDevice:err ${JSON.stringify(err)}`) + done(); + } + }) + } + done(); + console.info(`inputDevice::supportKeys_test-01 exit`); + }, (err) => { + if (err) { + expect(false).assertTrue(); + console.info(`getDevice:err ${JSON.stringify(err)}`) + done(); + } }); }) }) diff --git a/powermgr/powermgrthermal/src/main/js/default/test/thermal_unittest.test.js b/powermgr/powermgrthermal/src/main/js/default/test/thermal_unittest.test.js index eb3527274..5146ec947 100644 --- a/powermgr/powermgrthermal/src/main/js/default/test/thermal_unittest.test.js +++ b/powermgr/powermgrthermal/src/main/js/default/test/thermal_unittest.test.js @@ -23,6 +23,7 @@ describe('appInfoTest_thermal4', function () { console.log("*************Thermal API Test Begin*************"); test14(); test15(); + test16(); }) function test14() { @@ -66,4 +67,24 @@ function test15() { }, MSEC_1000 * 4); }) }) +} + +function test16() { + + /* @tc.number thermal_manager_js_013 + * @tc.name Thermal_013 + * @tc.desc Thermal acquisition kit + */ + it('Thermal_016', 0, function () { + console.info("Thermal level is: " + thermal.ThermalLevel.COOL + thermal.ThermalLevel.NORMAL + + thermal.ThermalLevel.WARM + thermal.ThermalLevel.HOT + thermal.ThermalLevel.OVERHEATED + + thermal.ThermalLevel.WARNING + thermal.ThermalLevel.EMERGENCY); + expect(thermal.ThermalLevel.COOL == 0).assertTrue(); + expect(thermal.ThermalLevel.NORMAL == 1).assertTrue(); + expect(thermal.ThermalLevel.WARM == 2).assertTrue(); + expect(thermal.ThermalLevel.HOT == 3).assertTrue(); + expect(thermal.ThermalLevel.OVERHEATED == 4).assertTrue(); + expect(thermal.ThermalLevel.WARNING == 5).assertTrue(); + expect(thermal.ThermalLevel.EMERGENCY == 6).assertTrue(); + }) } \ No newline at end of file diff --git a/sensors/sensor_standard/src/main/js/default/test/SensorGeneralalgorithm.test.js b/sensors/sensor_standard/src/main/js/default/test/SensorGeneralalgorithm.test.js index a5e75d64a..190e22e7e 100755 --- a/sensors/sensor_standard/src/main/js/default/test/SensorGeneralalgorithm.test.js +++ b/sensors/sensor_standard/src/main/js/default/test/SensorGeneralalgorithm.test.js @@ -866,6 +866,25 @@ describe("SensorJsTest_sensor5", function () { console.info("SensorJsTest_101 end") }) + /* + * @tc.name: SensorJsTest_101 + * @tc.desc: Verfication results of the incorrect parameters of test interface. + */ + it('SensorJsTest_1011', 0, async function (done) { + console.info('SensorJsTest_1011 start') + await sensor.getGeomagneticDip([1, 2, 3, 4, 5, 6, 7, 8, 9]).then((data) => { + console.info("SensorJsTest_1011" + data) + expect(data).assertEqual(getGeomagneticDipResult[0]) + done() + console.info('SensorJsTest_1011' + 'length:' + data.length); + }, (error) => { + console.info('SensorJsTest_1011 failed'); + expect(false).assertTrue(); + done() + }) + console.info("SensorJsTest_1011 end") + }) + /* * @tc.name: SensorJsTest_102 * @tc.desc: Verfication results of the incorrect parameters of test interface. -- GitLab