提交 26d50831 编写于 作者: L logic42

add multimodalinput and powermgr and sensors testcase for 3.1release

Signed-off-by: Nlogic42 <wanglong108@huawei.com>
上级 37372617
...@@ -28,87 +28,155 @@ describe('MultimodalInput_test', function () { ...@@ -28,87 +28,155 @@ describe('MultimodalInput_test', function () {
// 参数正确,返回一个数组 // 参数正确,返回一个数组
it('inputDevice::getDeviceIds_test-01', 0, function () { it('inputDevice::getDeviceIds_test-01', 0, function () {
console.log(`inputDevice::getDeviceIds_test-01 enter`); console.info(`inputDevice::getDeviceIds_test-01 enter`);
inputDevice.getDeviceIds((data, err) => { inputDevice.getDeviceIds((err, data) => {
if (err) { if (err) {
expect(false).assertTrue(); expect(false).assertTrue();
} else { } else {
expect(data).assertInstanceOf('Array'); 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 () { it("inputDevice::getDeviceIds_test-02", 0, function () {
console.log(`inputDevice::getDeviceIds_test-02 enter`); console.info(`inputDevice::getDeviceIds_test-02 enter`);
inputDevice.getDeviceIds((data, err) => { inputDevice.getDeviceIds((err, data) => {
if (err) { if (err) {
expect(false).assertTrue(); expect(false).assertTrue();
} else { } else {
expect(data.length > 0).assertTure(); 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 () { it("inputDevice::getDevice_test-01", 0, function () {
console.log(`inputDevice::getDevice_test-03 enter`); console.info(`inputDevice::getDevice_test-03 enter`);
inputDevice.getDevice(-1, (data, err) => { inputDevice.getDevice(-1, (err, data) => {
if (err) { if (err) {
expect(false).assertTrue(); expect(false).assertTrue();
console.log(`inputDevice::getDevice_test-03 ${JSON.stringify(err)}`); console.info(`inputDevice::getDevice_test-03 ${JSON.stringify(err)}`);
} else { } else {
expect(JSON.stringify(data) !== "{}").assertTrue(); 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 () { it("inputDevice::getDevice_test-02", 0, function () {
console.log(`inputDevice::getDevice_test-04 enter`); console.info(`inputDevice::getDevice_test-04 enter`);
inputDevice.getDeviceIds((data, err) => { 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], (res, err) => {
console.log(`getDevice:data_i ${JSON.stringify(data[i])}`) console.info(`getDevice:data_i ${JSON.stringify(data[i])}`)
console.log(`getDevice:data ${JSON.stringify(data)}`) console.info(`getDevice:data ${JSON.stringify(data)}`)
console.log(`getDevice:err ${JSON.stringify(err)}`) console.info(`getDevice:err ${JSON.stringify(err)}`)
arr = Object.keys(res); arr = Object.keys(res);
}) })
expect(arr.length > 0).assertTrue(); 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 () { it("inputDevice::getDevice_test03", 0, async function () {
console.log(`inputDevice::getDevice_test-04 enter`); console.info(`inputDevice::getDevice_test-04 enter`);
inputDevice.getDeviceIds((data, err) => { await inputDevice.getDeviceIds((err, data) => {
if (err) { if (err) {
expect(false).assertTrue(); expect(false).assertTrue();
done();
} 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], (res, err) => {
console.log(`getDevice:data_i ${JSON.stringify(data[i])}`) console.info(`getDevice:data_i ${JSON.stringify(data[i])}`)
console.log(`getDevice:data ${JSON.stringify(data)}`) console.info(`getDevice:data ${JSON.stringify(data)}`)
console.log(`getDevice:err ${JSON.stringify(err)}`) console.info(`getDevice:err ${JSON.stringify(err)}`)
arr = Object.keys(res); arr = Object.keys(res);
expect(data[i].id).assertInstanceOf('number'); expect(res).assertInstanceOf('InputDeviceData');
expect(data[i].sources).assertInstanceOf('string'); expect(res.id).assertInstanceOf('number');
expect(data[i].name).assertInstanceOf('Array'); expect(res.sources).assertInstanceOf('string');
expect(data[i].axisRanges).assertInstanceOf('Array'); 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(); 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();
}
}); });
}) })
}) })
...@@ -23,6 +23,7 @@ describe('appInfoTest_thermal4', function () { ...@@ -23,6 +23,7 @@ describe('appInfoTest_thermal4', function () {
console.log("*************Thermal API Test Begin*************"); console.log("*************Thermal API Test Begin*************");
test14(); test14();
test15(); test15();
test16();
}) })
function test14() { function test14() {
...@@ -67,3 +68,23 @@ function test15() { ...@@ -67,3 +68,23 @@ function test15() {
}) })
}) })
} }
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
...@@ -866,6 +866,25 @@ describe("SensorJsTest_sensor5", function () { ...@@ -866,6 +866,25 @@ describe("SensorJsTest_sensor5", function () {
console.info("SensorJsTest_101 end") 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.name: SensorJsTest_102
* @tc.desc: Verfication results of the incorrect parameters of test interface. * @tc.desc: Verfication results of the incorrect parameters of test interface.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册