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

!8732 修改off借口,错误类型抛异常,undefined和null正常执行

Merge pull request !8732 from ZhaoMinghui/zmh_0524
......@@ -297,13 +297,15 @@ describe("SensorJsTest_sensor_39", function () {
* @tc.name: newAccelerometer_SensorJsTest012
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("newAccelerometer_SensorJsTest012", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) {
console.info('---------newAccelerometer_SensorJsTest012--------------');
sensor.on(sensor.SensorId.ACCELEROMETER, callback);
setTimeout(()=>{
it("newAccelerometer_SensorJsTest025", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, function (done) {
try {
sensor.off(sensor.SensorId.ACCELEROMETER, 5);
} catch (error) {
console.info('newAccelerometer_SensorJsTest025 error:'+error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE)
expect(error.message).assertEqual(PARAMETER_ERROR_MSG)
done();
}, 1000);
}
})
/*
......
......@@ -370,25 +370,13 @@ describe("SensorJsTest_sensor_41", function () {
* @tc.name: newAmbient_Light_SensorJsTest012
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("newAmbient_Light_SensorJsTest012", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
console.info('---------newAmbient_Light_SensorJsTest012--------------');
try{
sensor.getSingleSensor(sensor.SensorId.AMBIENT_LIGHT,(error, data) => {
if (error) {
console.info('newAmbient_Light_SensorJsTest012 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.on(sensor.SensorId.AMBIENT_LIGHT, callback);
setTimeout(()=>{
sensor.off(sensor.SensorId.AMBIENT_LIGHT, 5);
done();
}, 500);
}
})
} catch (error) {
console.info('newAmbient_Light_SensorJsTest012 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
it("newAmbient_Light_SensorJsTest025", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
try {
sensor.off(sensor.SensorId.AMBIENT_LIGHT, 5);
} catch (error) {
console.info('newAmbient_Light_SensorJsTest025 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE)
expect(error.message).assertEqual(PARAMETER_ERROR_MSG)
done();
}
})
......
......@@ -371,25 +371,13 @@ describe("SensorJsTest_sensor_53", function () {
* @tc.name: newBarometer_SensorJsTest012
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("newBarometer_SensorJsTest012", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
console.info('---------newBarometer_SensorJsTest012--------------');
try{
sensor.getSingleSensor(sensor.SensorId.BAROMETER,(error, data) => {
if (error) {
console.info('newBarometer_SensorJsTest012 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.on(sensor.SensorId.BAROMETER, callback);
setTimeout(()=>{
sensor.off(sensor.SensorId.BAROMETER, 5);
done();
}, 500);
}
})
} catch (error) {
console.info('newBarometer_SensorJsTest012 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
it("newBarometer_SensorJsTest025", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
try {
sensor.off(sensor.SensorId.BAROMETER, 5);
} catch (error) {
console.info('newBarometer_SensorJsTest025 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE)
expect(error.message).assertEqual(PARAMETER_ERROR_MSG)
done();
}
})
......
......@@ -401,24 +401,17 @@ describe("SensorJsTest_sensor_42", function () {
})
/*
* @tc.number:SUB_SensorsSystem_NEWGRAVITY_JsTest_0130
* @tc.name: newGravity_SensorJsTest013
* @tc.desc: Functional Use Cases
*/
it("newGravity_SensorJsTest013", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
console.info('---------newGravity_SensorJsTest013--------------');
try{
sensor.getSingleSensor(sensor.SensorId.GRAVITY,(error, data) => {
sensor.on(sensor.SensorId.GRAVITY, callback);
setTimeout(()=>{
sensor.off(sensor.SensorId.GRAVITY, 5);
done();
}, 500);
})
} catch (error) {
console.info('newGravity_SensorJsTest013 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
* @tc.number:SUB_SensorsSystem_GRAVITY_JSTest_0250
* @tc.name: newGravity_SensorJsTest025
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("newGravity_SensorJsTest025", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
try {
sensor.off(sensor.SensorId.GRAVITY, 5);
} catch (error) {
console.info('newGravity_SensorJsTest025 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE)
expect(error.message).assertEqual(PARAMETER_ERROR_MSG)
done();
}
})
......
......@@ -382,25 +382,13 @@ describe("SensorJsTest_sensor_43", function () {
* @tc.name: newGravity_SensorJsTest012
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("newGravity_SensorJsTest012", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
console.info('---------newGravity_SensorJsTest012--------------');
try{
sensor.getSingleSensor(sensor.SensorId.GYROSCOPE,(error, data) => {
if (error) {
console.info('newGravity_SensorJsTest012 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.on(sensor.SensorId.GYROSCOPE, callback);
setTimeout(()=>{
sensor.off(sensor.SensorId.GYROSCOPE, 5);
done();
}, 500);
}
})
} catch (error) {
console.info('newGravity_SensorJsTest012 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
it("newGyroScope_SensorJsTest025", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
try {
sensor.off(sensor.SensorId.GYROSCOPE, 5);
} catch (error) {
console.info('newGyroScope_SensorJsTest025 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE)
expect(error.message).assertEqual(PARAMETER_ERROR_MSG)
done();
}
})
......
......@@ -370,25 +370,13 @@ describe("SensorJsTest_sensor_45", function () {
* @tc.name: newHall_SensorJsTest012
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("newHall_SensorJsTest012", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
console.info('---------newHall_SensorJsTest012--------------');
try{
sensor.getSingleSensor(sensor.SensorId.HALL,(error, data) => {
if (error) {
console.info('newHall_SensorJsTest012 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.on(sensor.SensorId.HALL, callback);
setTimeout(()=>{
sensor.off(sensor.SensorId.HALL, 5);
done();
}, 500);
}
})
} catch (error) {
console.info('newHall_SensorJsTest012 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
it("newHall_SensorJsTest025", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
try {
sensor.off(sensor.SensorId.HALL, 5);
} catch (error) {
console.info('newHall_SensorJsTest025 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE)
expect(error.message).assertEqual(PARAMETER_ERROR_MSG)
done();
}
})
......
......@@ -405,20 +405,13 @@ describe("SensorJsTest_sensor_37", function () {
* @tc.name: newMagneticField_SensorJsTest013
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("newMagneticField_SensorJsTest013", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
console.info('---------newMagneticField_SensorJsTest013--------------');
try{
sensor.getSingleSensor(sensor.SensorId.MAGNETIC_FIELD,(error, data) => {
sensor.on(sensor.SensorId.MAGNETIC_FIELD, callback);
setTimeout(()=>{
sensor.off(sensor.SensorId.MAGNETIC_FIELD, 5);
done();
}, 500);
})
} catch (error) {
console.info('newMagneticField_SensorJsTest013 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
it("newMagneticField_SensorJsTest025", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
try {
sensor.off(sensor.SensorId.MAGNETIC_FIELD, 5);
} catch (error) {
console.info('newMagneticField_SensorJsTest025 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE)
expect(error.message).assertEqual(PARAMETER_ERROR_MSG)
done();
}
})
......
......@@ -382,25 +382,13 @@ describe("SensorJsTest_sensor_48", function () {
* @tc.name: newOrientating_SensorJsTest012
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("newOrientating_SensorJsTest012", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
console.info('---------newOrientating_SensorJsTest012--------------');
try{
sensor.getSingleSensor(sensor.SensorId.ORIENTATION,(error, data) => {
if (error) {
console.info('newOrientating_SensorJsTest012 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.on(sensor.SensorId.ORIENTATION, callback);
setTimeout(()=>{
sensor.off(sensor.SensorId.ORIENTATION, 5);
done();
}, 500);
}
})
} catch (error) {
console.info('newOrientating_SensorJsTest012 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
it("newOrientating_SensorJsTest025", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
try {
sensor.off(sensor.SensorId.ORIENTATION, 5);
} catch (error) {
console.info('newOrientating_SensorJsTest025 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE)
expect(error.message).assertEqual(PARAMETER_ERROR_MSG)
done();
}
})
......
......@@ -696,7 +696,7 @@ describe("SensorJsTest_sensor_57", function () {
* @tc.name: newPedometerDetection_SensorJsTest015
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("newPedometerDetection_SensorJsTest015", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
it("newPedometerDetection_SensorJsTest015", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------newPedometerDetection_SensorJsTest015---------------------------');
let atManager = abilityAccessCtrl.createAtManager();
await atManager.grantUserGrantedPermission(tokenID, permissionNameUser,
......@@ -710,19 +710,16 @@ describe("SensorJsTest_sensor_57", function () {
done();
}
try {
sensor.on(sensor.SensorId.PEDOMETER_DETECTION, callback);
setTimeout(() => {
sensor.off(sensor.SensorId.PEDOMETER_DETECTION, 5);
done();
}, 4000);
sensor.off(sensor.SensorId.PEDOMETER_DETECTION,5);
} catch (error) {
console.error('newPedometerDetection_SensorJsTest015 On fail, errorCode:' +JSON.stringify(error));
expect(false).assertTrue();
console.error('newPedometerDetection_SensorJsTest015 Off fail, errorCode:' +JSON.stringify(error));
expect(error.code).assertEqual(PARAMETER_ERROR_CODE)
expect(error.message).assertEqual(PARAMETER_ERROR_MSG)
done();
}
});
} catch (error) {
console.error('newPedometerDetection_SensorJsTest015 Sensor is not support');
console.error('newPedometerDetection_SensorJsTest015 Sensor is not support'+error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
......
......@@ -387,25 +387,13 @@ describe("SensorJsTest_sensor_49", function () {
* @tc.name: newRotatingVector_SensorJsTest012
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("newRotatingVector_SensorJsTest012", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
console.info('---------newRotatingVector_SensorJsTest012--------------');
try{
sensor.getSingleSensor(sensor.SensorId.ROTATION_VECTOR,(error, data) => {
if (error) {
console.info('newRotatingVector_SensorJsTest012 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.on(sensor.SensorId.ROTATION_VECTOR, callback);
setTimeout(()=>{
sensor.off(sensor.SensorId.ROTATION_VECTOR, 5);
done();
}, 500);
}
})
} catch (error) {
console.info('newRotatingVector_SensorJsTest012 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
it("newRotatingVector_SensorJsTest025", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
try {
sensor.off(sensor.SensorId.ROTATION_VECTOR, 5);
} catch (error) {
console.info('newRotatingVector_SensorJsTest025 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE)
expect(error.message).assertEqual(PARAMETER_ERROR_MSG)
done();
}
})
......
......@@ -696,7 +696,7 @@ describe("SensorJsTest_sensor_17", function () {
* @tc.name: PedometerDetection_SensorJsTest015
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("PedometerDetection_SensorJsTest015", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
it("PedometerDetection_SensorJsTest015", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------PedometerDetection_SensorJsTest015---------------------------');
let atManager = abilityAccessCtrl.createAtManager();
await atManager.grantUserGrantedPermission(tokenID, permissionNameUser,
......@@ -710,19 +710,16 @@ describe("SensorJsTest_sensor_17", function () {
done();
}
try {
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback);
setTimeout(() => {
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, 5);
done();
}, 4000);
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION,5);
} catch (error) {
console.error('PedometerDetection_SensorJsTest015 On fail, errorCode:' +JSON.stringify(error));
expect(false).assertTrue();
console.error('PedometerDetection_SensorJsTest015 Off fail, errorCode:' +JSON.stringify(error));
expect(error.code).assertEqual(PARAMETER_ERROR_CODE)
expect(error.message).assertEqual(PARAMETER_ERROR_MSG)
done();
}
});
} catch (error) {
console.error('PedometerDetection_SensorJsTest015 Sensor is not support');
console.error('PedometerDetection_SensorJsTest015 Sensor is not support'+error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册