提交 7936ce4b 编写于 作者: L lidanyang16

<lidanyang16@huawei.com>

Signed-off-by: Nlidanyang16 <lidanyang16@huawei.com>
上级 a8a1c50e
......@@ -13,7 +13,7 @@
import("//build/ohos_var.gni")
group("sensor") {
group("sensors") {
testonly = true
if (is_standard_system) {
deps = [
......
......@@ -15,8 +15,10 @@
import VibratorJsTest_misc_1 from './Vibrator_old.test.js'
import VibratorJsTest_misc_2 from './Vibrator_new_common.test.js'
import VibratorJsTest_misc_3 from './Vibrator_newSupplement_common.test.js'
import VibratorJsTest_misc_6 from './Vibrator_newSupportTest.js'
export default function testsuite() {
VibratorJsTest_misc_1()
VibratorJsTest_misc_2()
VibratorJsTest_misc_3()
VibratorJsTest_misc_6()
}
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import vibrator from '@ohos.vibrator'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestType, Size, Level } from '@ohos/hypium'
export default function VibratorJsTest_misc_6() {
describe("VibratorJsTest_misc_6", function () {
var g_execute = true;
let EFFECT_ID = "haptic.clock.timer";
let INVALID_EFFECT_ID = "xxx";
beforeAll(function () {
/*
* @tc.setup: setup invoked before all testcases
*/
console.info('beforeAll caled')
})
afterAll(function () {
/*
* @tc.teardown: teardown invoked after all testcases
*/
console.info('afterAll caled')
})
beforeEach(function () {
/*
* @tc.setup: setup invoked before each testcases
*/
console.info('beforeEach caled')
})
afterEach(function () {
/*
* @tc.teardown: teardown invoked after each testcases
*/
console.info('afterEach caled')
vibrator.stop("preset");
vibrator.stop("time");
console.info('afterEach called')
})
const OPERATION_FAIL_CODE = 14600101;
const PERMISSION_ERROR_CODE = 201;
const PARAMETER_ERROR_CODE = 401;
const OPERATION_FAIL_MSG = 'Device operation failed.'
const PERMISSION_ERROR_MSG = 'Permission denied.'
const PARAMETER_ERROR_MSG = 'The parameter invalid.'
/*
* @tc.name:VibratorJsTest069
* @tc.desc:Verification results of the incorrect parameters of the test interface.
* @tc.number:SUB_SensorSystem_Vibrator_JsTest_0790
*/
it("VibratorJsTest069", 0, async function (done) {
vibrator.isSupportEffect(INVALID_EFFECT_ID, (error, state) => {
if (error) {
console.info('VibratorJsTest069 error');
expect(false).assertTrue();
} else {
console.info('VibratorJsTest069 success');
expect(!state).assertTrue();
done();
}
});
})
/*
* @tc.name:VibratorJsTest070
* @tc.desc:Verification results of the incorrect parameters of the test interface.
* @tc.number:SUB_SensorSystem_Vibrator_JsTest_0800
*/
it("VibratorJsTest070", 0, async function (done) {
let isSupport = false;
function vibratePromise() {
return new Promise((resolve, reject) => {
if (isSupport) {
vibrator.startVibration({
type: "preset",
effectId: EFFECT_ID,
count: 1,
}, {
usage: "unknown"
}, (error)=>{
if (error) {
expect(false).assertTrue();
reject(error);
} else {
expect(true).assertTrue();
resolve();
}
});
} else {
resolve();
}
})
}
function stopPromise() {
return new Promise((resolve, reject) => {
if (isSupport) {
vibrator.stopVibration((error) => {
if (error) {
expect(false).assertTrue();
reject(error);
} else {
expect(true).assertTrue();
resolve();
}
});
} else {
resolve();
}
})
}
let isSupportPromise = new Promise((resolve, reject) => {
vibrator.isSupportEffect(EFFECT_ID, (error, state) => {
if (error) {
expect(false).assertTrue();
reject(error);
} else {
expect(true).assertTrue();
isSupport = state;
resolve();
}
});
})
await isSupportPromise.then(() =>{
return vibratePromise();
}).then(() =>{
return stopPromise();
}).catch((error)=>{
expect(false).assertTrue();
})
done();
})
/*
* @tc.name:VibratorJsTest071
* @tc.desc:Verification results of the incorrect parameters of the test interface.
* @tc.number:SUB_SensorSystem_Vibrator_JsTest_0810
*/
it("VibratorJsTest071", 0, async function (done) {
try {
vibrator.isSupportEffect(123, (error, state) => {
console.info("VibratorJsTest071 should not in this method");
expect(false).assertTrue();
done();
});
} catch (error) {
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.name:VibratorJsTest072
* @tc.desc:Verification results of the incorrect parameters of the test interface.
* @tc.number:SUB_SensorSystem_Vibrator_JsTest_0820
*/
it("VibratorJsTest072", 0, async function (done) {
try {
vibrator.isSupportEffect();
} catch (error) {
console.info("VibratorJsTest072 error in :" + error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.name:VibratorJsTest073
* @tc.desc:Verification results of the incorrect parameters of the test interface.
* @tc.number:SUB_SensorSystem_Vibrator_JsTest_0830
*/
it("VibratorJsTest073", 0, async function (done) {
await vibrator.isSupportEffect(INVALID_EFFECT_ID).then((state) => {
expect(!state).assertTrue();
}, (error) => {
expect(false).assertTrue();
});
done();
})
/*
* @tc.name:VibratorJsTest073
* @tc.desc:Verification results of the incorrect parameters of the test interface.
* @tc.number:SUB_SensorSystem_Vibrator_JsTest_0830
*/
it("VibratorJsTest073", 0, async function (done) {
let isSupport = false;
function vibratePromise() {
return new Promise((resolve, reject) => {
if (isSupport) {
vibrator.startVibration({
type: "preset",
effectId: EFFECT_ID,
count: 1,
}, {
usage: "unknown"
}, (error)=>{
if (error) {
expect(false).assertTrue();
reject(error);
} else {
expect(true).assertTrue();
resolve();
}
});
} else {
resolve();
}
})
}
function stopPromise() {
return new Promise((resolve, reject) => {
if (isSupport) {
vibrator.stopVibration((error) => {
if (error) {
expect(false).assertTrue();
reject(error);
} else {
expect(true).assertTrue();
resolve();
}
});
} else {
resolve();
}
})
}
let isSupportPromise = new Promise((resolve, reject) => {
vibrator.isSupportEffect(EFFECT_ID).then((state) => {
expect(true).assertTrue();
isSupport = state;
resolve();
}, (error) => {
expect(false).assertTrue();
reject(error);
});
})
await isSupportPromise.then(() =>{
return vibratePromise();
}).then(() =>{
return stopPromise();
}).catch((error)=>{
expect(false).assertTrue();
})
done();
})
/*
* @tc.name:VibratorJsTest074
* @tc.desc:Verification results of the incorrect parameters of the test interface.
* @tc.number:SUB_SensorSystem_Vibrator_JsTest_0840
*/
it("VibratorJsTest074", 0, async function (done) {
try {
vibrator.isSupportEffect(123).then((state) => {
expect(false).assertTrue();
done();
}, (error) => {
expect(false).assertTrue();
done();
});
} catch (error) {
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.name:VibratorJsTest075
* @tc.desc:Verification results of the incorrect parameters of the test interface.
* @tc.number:SUB_SensorSystem_Vibrator_JsTest_0850
*/
it("VibratorJsTest075", 0, async function (done) {
try {
vibrator.isSupportEffect().then((state) => {
expect(false).assertTrue();
}, (error) => {
expect(true).assertTrue();
done()
});
} catch (error) {
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
})}
......@@ -16,18 +16,61 @@ import SystemParameterTest from './SensorOnOffTest.test.js'
import SensorJsTest_sensor_2 from './SensorGeomagneticTest.test.js'
import SensorJsTest_sensor_1 from './SensorGeneralalgorithm.test.js'
import SensorJsTest_sensor_60 from './SensorOnOffTest.test_newSensorGeomagnetic.js'
import SensorJsTest_sensor_35 from './SensorOnOffTest.test_newGetSensorList.js'
import SensorJsTest_sensor_36 from './SensorOnOffTest.test_newGetSingleSensor.js'
import SensorJsTest_sensor_3 from './SensorOnOffTest.test_oldAccelerometer.js'
import SensorJsTest_sensor_25 from './Subscribe_subscribeAccelerometer.js'
import SensorJsTest_sensor_39 from './SensorOnOffTest.test_newAccelerometer.js'
import SensorJsTest_sensor_43 from './SensorOnOffTest.test_newGyroScope.js'
import SensorJsTest_sensor_5 from './SensorOnOffTest.test_oldGyroScope.js'
import SensorJsTest_sensor_29 from './Subscribe_subscribeGyroscope.js'
import SensorJsTest_sensor_41 from './SensorOnOffTest.test_newAmbient_Light.js'
import SensorJsTest_sensor_4 from './SensorOnOffTest.test_oldAmbient_light.js'
import SensorJsTest_sensor_31 from './Subscribe_subscribeLight.js'
import SensorJsTest_sensor_42 from './SensorOnOffTest.test_newGravity.js'
import SensorJsTest_sensor_9 from './SensorOnOffTest.test_oldGravity.js'
import SensorJsTest_sensor_37 from './SensorOnOffTest.test_newMagneticField.js'
import SensorJsTest_sensor_15 from './SensorOnOffTest.test_oldMagneticField.js'
import SensorJsTest_sensor_49 from './SensorOnOffTest.test_newRotatingVector.js'
import SensorJsTest_sensor_20 from './SensorOnOffTest.test_oldRotatingVector.js'
import SensorJsTest_sensor_45 from './SensorOnOffTest.test_newHall.js'
import SensorJsTest_sensor_7 from './SensorOnOffTest.test_oldHall.js'
import SensorJsTest_sensor_48 from './SensorOnOffTest.test_newOrientating.js'
import SensorJsTest_sensor_16 from './SensorOnOffTest.test_oldOrientating.js'
import SensorJsTest_sensor_27 from './Subscribe_subscribeDeviceOrientation.js'
import SensorJsTest_sensor_53 from './SensorOnOffTest.test_newBarometer.js'
import SensorJsTest_sensor_8 from './SensorOnOffTest.test_oldBarometer.js'
import SensorJsTest_sensor_26 from './Subscribe_subscribeBarometer.js'
export default function testsuite() {
SensorJsTest_sensor_1()
SensorJsTest_sensor_2()
SensorJsTest_sensor_60()
SystemParameterTest()
SensorJsTest_sensor_3()
SensorJsTest_sensor_25()
SensorJsTest_sensor_39()
SensorJsTest_sensor_43()
SystemParameterTest()
SensorJsTest_sensor_2()
SensorJsTest_sensor_1()
SensorJsTest_sensor_60()
SensorJsTest_sensor_35()
SensorJsTest_sensor_36()
SensorJsTest_sensor_3()
SensorJsTest_sensor_25()
SensorJsTest_sensor_39()
SensorJsTest_sensor_43()
SensorJsTest_sensor_5()
SensorJsTest_sensor_29()
SensorJsTest_sensor_41()
SensorJsTest_sensor_4()
SensorJsTest_sensor_31()
SensorJsTest_sensor_42()
SensorJsTest_sensor_9()
SensorJsTest_sensor_37()
SensorJsTest_sensor_15()
SensorJsTest_sensor_49()
SensorJsTest_sensor_20()
SensorJsTest_sensor_45()
SensorJsTest_sensor_7()
SensorJsTest_sensor_48()
SensorJsTest_sensor_16()
SensorJsTest_sensor_27()
SensorJsTest_sensor_53()
SensorJsTest_sensor_8()
SensorJsTest_sensor_26()
}
......@@ -74,11 +74,25 @@ describe("SensorJsTest_sensor_41", function () {
*/
it("newAmbient_Light_SensorJsTest014", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
console.info('---------newAmbient_Light_SensorJsTest014--------------');
try{
sensor.getSingleSensor(sensor.SensorId.AMBIENT_LIGHT,(error, data) => {
if (error) {
console.info('newAmbient_Light_SensorJsTest014 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.on(sensor.SensorId.AMBIENT_LIGHT, callback);
setTimeout(()=>{
sensor.off(sensor.SensorId.AMBIENT_LIGHT);
done();
}, 500);
}
})
} catch (error) {
console.info('newAmbient_Light_SensorJsTest014 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
......@@ -109,6 +123,12 @@ describe("SensorJsTest_sensor_41", function () {
*/
it("newAmbient_Light_SensorJsTest016", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('---------newAmbient_Light_SensorJsTest016--------------');
try{
sensor.getSingleSensor(sensor.SensorId.AMBIENT_LIGHT,(error, data) => {
if (error) {
console.info('newAmbient_Light_SensorJsTest016 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.on(sensor.SensorId.AMBIENT_LIGHT, callback, {'interval': 100000000});
setTimeout(()=>{
console.info('---------newAmbient_Light_SensorJsTest016 off in--------------');
......@@ -116,6 +136,14 @@ describe("SensorJsTest_sensor_41", function () {
console.info('---------newAmbient_Light_SensorJsTest016 off end--------------');
done();
}, 500);
}
})
} catch (error) {
console.info('newAmbient_Light_SensorJsTest016 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
......@@ -129,21 +157,28 @@ describe("SensorJsTest_sensor_41", function () {
console.info('newAmbient_Light_SensorJsTest017 callback in');
expect(typeof (data.intensity)).assertEqual("number");
expect(typeof (data.timestamp)).assertEqual("number");
done();
}
try {
try{
sensor.getSingleSensor(sensor.SensorId.AMBIENT_LIGHT,(error, data) => {
if (error) {
console.info('newAmbient_Light_SensorJsTest017 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.on(sensor.SensorId.AMBIENT_LIGHT, onSensorCallback, {'interval': 100000000}, 5);
} catch (error) {
console.info("newAmbient_Light_SensorJsTest017 error:" +error);
expect(false).assertTrue();
done();
}
setTimeout(()=>{
console.info('---------newAmbient_Light_SensorJsTest017 off in--------------');
sensor.off(sensor.SensorId.AMBIENT_LIGHT);
console.info('---------newAmbient_Light_SensorJsTest017 off end--------------');
done();
}, 500);
}
})
} catch (error) {
console.info("newAmbient_Light_SensorJsTest017 Device does not support! ");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
......@@ -152,11 +187,25 @@ describe("SensorJsTest_sensor_41", function () {
* @tc.desc: Once Normal Subscription Scenario Use Case
*/
it("newAmbient_Light_SensorJsTest018", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
try{
sensor.getSingleSensor(sensor.SensorId.AMBIENT_LIGHT,(error, data) => {
if (error) {
console.info('newAmbient_Light_SensorJsTest018 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.once(sensor.SensorId.AMBIENT_LIGHT, callback);
setTimeout(()=>{
expect(true).assertTrue();
done();
}, 500);
}
})
} catch (error) {
console.info("newAmbient_Light_SensorJsTest018 Device does not support! ");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
......@@ -193,10 +242,18 @@ describe("SensorJsTest_sensor_41", function () {
done();
}
try{
sensor.getSingleSensor(sensor.SensorId.AMBIENT_LIGHT,(error, data) => {
if (error) {
console.info('newAmbient_Light_SensorJsTest020 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.once(sensor.SensorId.AMBIENT_LIGHT, onceSensorCallback, 5);
}
})
} catch (error) {
console.info('newAmbient_Light_SensorJsTest020 error:' +error);
expect(false).assertTrue();
console.info("newAmbient_Light_SensorJsTest020 error:" +error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
......@@ -210,7 +267,7 @@ describe("SensorJsTest_sensor_41", function () {
try {
sensor.off(invalid, callback);
} catch (error) {
console.info('newAmbient_Light_SensorJsTest021 error:' +error);
console.info('newAmbient_Light_SensorJsTest021 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE)
expect(error.message).assertEqual(PARAMETER_ERROR_MSG)
done();
......@@ -228,12 +285,26 @@ describe("SensorJsTest_sensor_41", function () {
expect(false).assertTrue();
done();
}
try{
sensor.getSingleSensor(sensor.SensorId.AMBIENT_LIGHT,(error, data) => {
if (error) {
console.info('newAmbient_Light_SensorJsTest022 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.on(sensor.SensorId.AMBIENT_LIGHT, onSensorCallback);
sensor.off(sensor.SensorId.AMBIENT_LIGHT, onSensorCallback);
setTimeout(()=>{
expect(true).assertTrue();
done();
}, 500);
}
})
} catch (error) {
console.info("newAmbient_Light_SensorJsTest022 error:" +error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
......@@ -262,6 +333,12 @@ describe("SensorJsTest_sensor_41", function () {
* @tc.desc:Call interface multiple times
*/
it("newAmbient_Light_SensorJsTest024", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
try{
sensor.getSingleSensor(sensor.SensorId.AMBIENT_LIGHT,(error, data) => {
if (error) {
console.info('newAmbient_Light_SensorJsTest024 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.on(sensor.SensorId.AMBIENT_LIGHT, (data)=>{
console.info("newAmbient_Light_SensorJsTest024 callback: " + JSON.stringify(data));
expect(typeof (data.intensity)).assertEqual("number");
......@@ -278,6 +355,14 @@ describe("SensorJsTest_sensor_41", function () {
console.info('---------newAmbient_Light_SensorJsTest024 off end--------------');
done();
}, 1000);
}
})
} catch (error) {
console.info("newAmbient_Light_SensorJsTest024 Device does not support! ");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
......@@ -289,7 +374,7 @@ describe("SensorJsTest_sensor_41", function () {
try {
sensor.off(sensor.SensorId.AMBIENT_LIGHT, 5);
} catch (error) {
console.info('newAmbient_Light_SensorJsTest025 error:'+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();
......@@ -303,6 +388,12 @@ describe("SensorJsTest_sensor_41", function () {
*/
it("newAmbient_Light_SensorJsTest026", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('---------newAmbient_Light_SensorJsTest026--------------');
try{
sensor.getSingleSensor(sensor.SensorId.AMBIENT_LIGHT,(error, data) => {
if (error) {
console.info('newAmbient_Light_SensorJsTest024 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.on(sensor.SensorId.AMBIENT_LIGHT, (data)=>{
console.info("newAmbient_Light_SensorJsTest026 callback: " + JSON.stringify(data));
expect(typeof (data.intensity)).assertEqual("number");
......@@ -319,6 +410,14 @@ describe("SensorJsTest_sensor_41", function () {
console.info('---------newAmbient_Light_SensorJsTest026 off end--------------');
done();
}, 1000);
}
})
} catch (error) {
console.info("newAmbient_Light_SensorJsTest026 Device does not support! ");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
......@@ -328,6 +427,12 @@ describe("SensorJsTest_sensor_41", function () {
*/
it("newAmbient_Light_SensorJsTest027", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('---------newAmbient_Light_SensorJsTest027--------------');
try{
sensor.getSingleSensor(sensor.SensorId.AMBIENT_LIGHT,(error, data) => {
if (error) {
console.info('newAmbient_Light_SensorJsTest024 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.on(sensor.SensorId.AMBIENT_LIGHT, (data)=>{
console.info("newAmbient_Light_SensorJsTest027 callback: " + JSON.stringify(data));
expect(typeof (data.intensity)).assertEqual("number");
......@@ -337,6 +442,7 @@ describe("SensorJsTest_sensor_41", function () {
console.info("newAmbient_Light_SensorJsTest027 callback2: " + JSON.stringify(data));
expect(typeof (data.intensity)).assertEqual("number");
expect(typeof (data.timestamp)).assertEqual("number");
expect(typeof (data.timestamp)).assertEqual("number");
}, {'interval': 100000000});
setTimeout(()=>{
console.info('---------newAmbient_Light_SensorJsTest027 off in--------------');
......@@ -344,6 +450,14 @@ describe("SensorJsTest_sensor_41", function () {
console.info('---------newAmbient_Light_SensorJsTest027 off end--------------');
done();
}, 1000);
}
})
} catch (error) {
console.info("newAmbient_Light_SensorJsTest027 Device does not support! ");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
......@@ -356,7 +470,7 @@ describe("SensorJsTest_sensor_41", function () {
try {
sensor.on();
} catch (error) {
console.info("newAmbient_Light_SensorJsTest028 error:" +error);
console.info("newAmbient_Light_SensorJsTest028_on error:" +error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
......@@ -364,7 +478,7 @@ describe("SensorJsTest_sensor_41", function () {
try {
sensor.once();
} catch (error) {
console.info("newAmbient_Light_SensorJsTest028 error:" +error);
console.info("newAmbient_Light_SensorJsTest028_once error:" +error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
......@@ -372,7 +486,7 @@ describe("SensorJsTest_sensor_41", function () {
try {
sensor.off();
} catch (error) {
console.info("newAmbient_Light_SensorJsTest028 error:" +error);
console.info("newAmbient_Light_SensorJsTest028_off error:" +error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
......@@ -386,6 +500,12 @@ describe("SensorJsTest_sensor_41", function () {
*/
it("newAmbient_Light_SensorJsTest029", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------newAmbient_Light_SensorJsTest029--------------');
try{
sensor.getSingleSensor(sensor.SensorId.AMBIENT_LIGHT,(error, data) => {
if (error) {
console.info('newAmbient_Light_SensorJsTest029 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.on(sensor.SensorId.AMBIENT_LIGHT, callback);
sensor.on(sensor.SensorId.AMBIENT_LIGHT, callback2);
setTimeout(() => {
......@@ -403,6 +523,14 @@ describe("SensorJsTest_sensor_41", function () {
console.info('----------------------newAmbient_Light_SensorJsTest029 off end--------------');
done();
}, 1000);
}
})
} catch (error) {
console.info("newAmbient_Light_SensorJsTest029 Device does not support! ");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
......@@ -412,6 +540,12 @@ describe("SensorJsTest_sensor_41", function () {
*/
it("newAmbient_Light_SensorJsTest030", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------newAmbient_Light_SensorJsTest030--------------');
try{
sensor.getSingleSensor(sensor.SensorId.AMBIENT_LIGHT,(error, data) => {
if (error) {
console.info('newAmbient_Light_SensorJsTest029 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.on(sensor.SensorId.AMBIENT_LIGHT, callback, { 'interval': 100000000 });
sensor.on(sensor.SensorId.AMBIENT_LIGHT, callback2, { 'interval': 100000000 });
setTimeout(() => {
......@@ -430,5 +564,80 @@ describe("SensorJsTest_sensor_41", function () {
console.info('----------------------newAmbient_Light_SensorJsTest030_2 off end--------------');
done();
}, 1000);
}
})
} catch (error) {
console.info("newAmbient_Light_SensorJsTest030 Device does not support! ");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number: SUB_SensorsSystem_AMBIENT_LIGHT_JSTest_0310
* @tc.name: newAmbient_Light_SensorJsTest031
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("newAmbient_Light_SensorJsTest031", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------newAmbient_Light_SensorJsTest031--------------');
try{
sensor.getSingleSensor(sensor.SensorId.AMBIENT_LIGHT,(error, data) => {
if (error) {
console.info('newAmbient_Light_SensorJsTest031 error');
} else {
expect(typeof(data)).assertEqual("object");
console.info('----------------------newAmbient_Light_SensorJsTest031 off in--------------');
try{
sensor.off(-1, callback);
console.info('----------------------newAmbient_Light_SensorJsTest031 off end--------------');
} catch (error) {
console.info("newAmbient_Light_SensorJsTest031 error:" + error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
}
})
} catch (error) {
console.info("newAmbient_Light_SensorJsTest031 Device does not support! ");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number: SUB_SensorsSystem_AMBIENT_LIGHT_JSTest_0320
* @tc.name: newAmbient_Light_SensorJsTest032
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("newAmbient_Light_SensorJsTest032", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------newAmbient_Light_SensorJsTest032--------------');
try{
sensor.getSingleSensor(sensor.SensorId.AMBIENT_LIGHT,(error, data) => {
if (error) {
console.info('newAmbient_Light_SensorJsTest032 error');
} else {
try {
sensor.on(sensor.SensorId.AMBIENT_LIGHT, callback, {'interval': -100000000});
console.info('----------------------newAmbient_Light_SensorJsTest032 off in---------------------------');
sensor.off(sensor.SensorId.AMBIENT_LIGHT);
console.info('----------------------newAmbient_Light_SensorJsTest032 off end---------------------------');
done();
} catch (error) {
console.info('newAmbient_Light_SensorJsTest032 On fail, errCode:' + error.code + ' ,msg:' + error.message);
expect(error.code).assertEqual(SERVICE_EXCEPTION_CODE);
expect(error.message).assertEqual(SERVICE_EXCEPTION_MSG);
done();
}
}
})
} catch (error) {
console.info("newAmbient_Light_SensorJsTest032 Device does not support! ");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
})}
......@@ -78,11 +78,48 @@ describe("SensorJsTest_sensor_42", function () {
*/
it("newGravity_SensorJsTest014", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
console.info('---------newGravity_SensorJsTest014--------------');
try{
sensor.getSingleSensor(sensor.SensorId.GRAVITY,(error, data) => {
sensor.on(sensor.SensorId.GRAVITY, callback);
setTimeout(()=>{
sensor.off(sensor.SensorId.GRAVITY);
done();
}, 500);
})
} catch (error) {
console.info('newGravity_SensorJsTest014 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number:SUB_SensorsSystem_GRAVITY_JSTest_0150
* @tc.name: newGravity_SensorJsTest015
* @tc.desc: Illegal ID passed in
*/
it("newGravity_SensorJsTest015", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('---------newGravity_SensorJsTest015--------------');
try{
sensor.getSingleSensor(sensor.SensorId.GRAVITY,(error, data) => {
if (error) {
console.info('newGravity_SensorJsTest014 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.on(sensor.SensorId.GRAVITY, callback);
setTimeout(()=>{
sensor.off(sensor.SensorId.GRAVITY);
done();
}, 500);
}
})
} catch (error) {
console.info('newGravity_SensorJsTest014 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
......@@ -113,6 +150,12 @@ describe("SensorJsTest_sensor_42", function () {
*/
it("newGravity_SensorJsTest016", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('---------newGravity_SensorJsTest016--------------');
try{
sensor.getSingleSensor(sensor.SensorId.GRAVITY,(error, data) => {
if (error) {
console.info('newGravity_SensorJsTest016 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.on(sensor.SensorId.GRAVITY, callback, {'interval': 100000000});
setTimeout(()=>{
console.info('---------newGravity_SensorJsTest016 off in--------------');
......@@ -120,6 +163,14 @@ describe("SensorJsTest_sensor_42", function () {
console.info('---------newGravity_SensorJsTest016 off end--------------');
done();
}, 500);
}
})
} catch (error) {
console.info('newGravity_SensorJsTest016 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
......@@ -136,19 +187,27 @@ describe("SensorJsTest_sensor_42", function () {
expect(typeof (data.z)).assertEqual("number");
expect(typeof (data.timestamp)).assertEqual("number");
}
try {
try{
sensor.getSingleSensor(sensor.SensorId.GRAVITY,(error, data) => {
if (error) {
console.info('newGravity_SensorJsTest017 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.on(sensor.SensorId.GRAVITY, onSensorCallback, {'interval': 100000000}, 5);
} catch (error) {
console.info("newGravity_SensorJsTest017 error:" +error);
expect(false).assertTrue();
done();
}
setTimeout(()=>{
console.info('---------newGravity_SensorJsTest017 off in--------------');
sensor.off(sensor.SensorId.GRAVITY);
console.info('---------newGravity_SensorJsTest017 off end--------------');
done();
}, 500);
}
})
} catch (error) {
console.info("newGravity_SensorJsTest017 Device does not support! ");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
......@@ -157,11 +216,25 @@ describe("SensorJsTest_sensor_42", function () {
* @tc.desc: Once Normal Subscription Scenario Use Case
*/
it("newGravity_SensorJsTest018", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
try{
sensor.getSingleSensor(sensor.SensorId.GRAVITY,(error, data) => {
if (error) {
console.info('newGravity_SensorJsTest018 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.once(sensor.SensorId.GRAVITY, callback);
setTimeout(()=>{
expect(true).assertTrue();
done();
}, 500);
}
})
} catch (error) {
console.info("newGravity_SensorJsTest018 Device does not support! ");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
......@@ -200,10 +273,18 @@ describe("SensorJsTest_sensor_42", function () {
done();
}
try{
sensor.getSingleSensor(sensor.SensorId.GRAVITY,(error, data) => {
if (error) {
console.info('newGravity_SensorJsTest020 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.once(sensor.SensorId.GRAVITY, onceSensorCallback, 5);
}
})
} catch (error) {
console.info('newGravity_SensorJsTest020 error:' +error);
expect(false).assertTrue();
console.info("newGravity_SensorJsTest020 error:" +error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
......@@ -217,7 +298,7 @@ describe("SensorJsTest_sensor_42", function () {
try {
sensor.off(invalid, callback);
} catch (error) {
console.info('newGravity_SensorJsTest021 error:' +error);
console.info('newGravity_SensorJsTest021 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE)
expect(error.message).assertEqual(PARAMETER_ERROR_MSG)
done();
......@@ -235,12 +316,26 @@ describe("SensorJsTest_sensor_42", function () {
expect(false).assertTrue();
done();
}
try{
sensor.getSingleSensor(sensor.SensorId.GRAVITY,(error, data) => {
if (error) {
console.info('newGravity_SensorJsTest022 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.on(sensor.SensorId.GRAVITY, onSensorCallback);
sensor.off(sensor.SensorId.GRAVITY, onSensorCallback);
setTimeout(()=>{
expect(true).assertTrue();
done();
}, 500);
}
})
} catch (error) {
console.info("newGravity_SensorJsTest022 error:" +error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
......@@ -269,6 +364,12 @@ describe("SensorJsTest_sensor_42", function () {
* @tc.desc:Call interface multiple times
*/
it("newGravity_SensorJsTest024", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
try{
sensor.getSingleSensor(sensor.SensorId.GRAVITY,(error, data) => {
if (error) {
console.info('newGravity_SensorJsTest024 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.on(sensor.SensorId.GRAVITY, (data)=>{
console.info("newGravity_SensorJsTest024 callback: " + JSON.stringify(data));
expect(typeof (data.x)).assertEqual("number");
......@@ -289,6 +390,14 @@ describe("SensorJsTest_sensor_42", function () {
console.info('---------newGravity_SensorJsTest024 off end--------------');
done();
}, 1000);
}
})
} catch (error) {
console.info("newGravity_SensorJsTest024 Device does not support! ");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
......@@ -300,7 +409,7 @@ describe("SensorJsTest_sensor_42", function () {
try {
sensor.off(sensor.SensorId.GRAVITY, 5);
} catch (error) {
console.info('newGravity_SensorJsTest025 error:'+error);
console.info('newGravity_SensorJsTest025 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE)
expect(error.message).assertEqual(PARAMETER_ERROR_MSG)
done();
......@@ -314,6 +423,12 @@ describe("SensorJsTest_sensor_42", function () {
*/
it("newGravity_SensorJsTest026", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('---------newGravity_SensorJsTest026--------------');
try{
sensor.getSingleSensor(sensor.SensorId.GRAVITY,(error, data) => {
if (error) {
console.info('newGravity_SensorJsTest024 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.on(sensor.SensorId.GRAVITY, (data)=>{
console.info("newGravity_SensorJsTest026 callback: " + JSON.stringify(data));
expect(typeof (data.x)).assertEqual("number");
......@@ -334,6 +449,14 @@ describe("SensorJsTest_sensor_42", function () {
console.info('---------newGravity_SensorJsTest026 off end--------------');
done();
}, 1000);
}
})
} catch (error) {
console.info("newGravity_SensorJsTest026 Device does not support! ");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
......@@ -343,6 +466,12 @@ describe("SensorJsTest_sensor_42", function () {
*/
it("newGravity_SensorJsTest027", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('---------newGravity_SensorJsTest027--------------');
try{
sensor.getSingleSensor(sensor.SensorId.GRAVITY,(error, data) => {
if (error) {
console.info('newGravity_SensorJsTest024 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.on(sensor.SensorId.GRAVITY, (data)=>{
console.info("newGravity_SensorJsTest027 callback: " + JSON.stringify(data));
expect(typeof (data.x)).assertEqual("number");
......@@ -363,6 +492,14 @@ describe("SensorJsTest_sensor_42", function () {
console.info('---------newGravity_SensorJsTest027 off end--------------');
done();
}, 1000);
}
})
} catch (error) {
console.info("newGravity_SensorJsTest027 Device does not support! ");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
......@@ -375,7 +512,7 @@ describe("SensorJsTest_sensor_42", function () {
try {
sensor.on();
} catch (error) {
console.info("newGravity_SensorJsTest028 error:" +error);
console.info("newGravity_SensorJsTest028_on error:" +error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
......@@ -383,7 +520,7 @@ describe("SensorJsTest_sensor_42", function () {
try {
sensor.once();
} catch (error) {
console.info("newGravity_SensorJsTest028 error:" +error);
console.info("newGravity_SensorJsTest028_once error:" +error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
......@@ -391,7 +528,7 @@ describe("SensorJsTest_sensor_42", function () {
try {
sensor.off();
} catch (error) {
console.info("newGravity_SensorJsTest028 error:" +error);
console.info("newGravity_SensorJsTest028_off error:" +error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
......@@ -405,6 +542,12 @@ describe("SensorJsTest_sensor_42", function () {
*/
it("newGravity_SensorJsTest029", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------newGravity_SensorJsTest029--------------');
try{
sensor.getSingleSensor(sensor.SensorId.GRAVITY,(error, data) => {
if (error) {
console.info('newGravity_SensorJsTest029 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.on(sensor.SensorId.GRAVITY, callback);
sensor.on(sensor.SensorId.GRAVITY, callback2);
setTimeout(() => {
......@@ -422,6 +565,14 @@ describe("SensorJsTest_sensor_42", function () {
console.info('----------------------newGravity_SensorJsTest029 off end--------------');
done();
}, 1000);
}
})
} catch (error) {
console.info("newGravity_SensorJsTest029 Device does not support! ");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
......@@ -431,6 +582,12 @@ describe("SensorJsTest_sensor_42", function () {
*/
it("newGravity_SensorJsTest030", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------newGravity_SensorJsTest030--------------');
try{
sensor.getSingleSensor(sensor.SensorId.GRAVITY,(error, data) => {
if (error) {
console.info('newGravity_SensorJsTest029 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.on(sensor.SensorId.GRAVITY, callback, { 'interval': 100000000 });
sensor.on(sensor.SensorId.GRAVITY, callback2, { 'interval': 100000000 });
setTimeout(() => {
......@@ -449,5 +606,80 @@ describe("SensorJsTest_sensor_42", function () {
console.info('----------------------newGravity_SensorJsTest030_2 off end--------------');
done();
}, 1000);
}
})
} catch (error) {
console.info("newGravity_SensorJsTest030 Device does not support! ");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number: SUB_SensorsSystem_GRAVITY_JSTest_0310
* @tc.name: newGravity_SensorJsTest031
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("newGravity_SensorJsTest031", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------newGravity_SensorJsTest031--------------');
try{
sensor.getSingleSensor(sensor.SensorId.GRAVITY,(error, data) => {
if (error) {
console.info('newGravity_SensorJsTest031 error');
} else {
expect(typeof(data)).assertEqual("object");
console.info('----------------------newGravity_SensorJsTest031 off in--------------');
try{
sensor.off(-1, callback);
console.info('----------------------newGravity_SensorJsTest031 off end--------------');
} catch (error) {
console.info("newGravity_SensorJsTest031 error:" + error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
}
})
} catch (error) {
console.info("newGravity_SensorJsTest031 Device does not support! ");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number: SUB_SensorsSystem_GRAVITY_JSTest_0320
* @tc.name: newGravity_SensorJsTest032
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("newGravity_SensorJsTest032", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------newGravity_SensorJsTest032--------------');
try{
sensor.getSingleSensor(sensor.SensorId.GRAVITY,(error, data) => {
if (error) {
console.info('newGravity_SensorJsTest032 error');
} else {
try {
sensor.on(sensor.SensorId.GRAVITY, callback, {'interval': -100000000});
console.info('----------------------newGravity_SensorJsTest032 off in---------------------------');
sensor.off(sensor.SensorId.GRAVITY);
console.info('----------------------newGravity_SensorJsTest032 off end---------------------------');
done();
} catch (error) {
console.info('newGravity_SensorJsTest032 On fail, errCode:' + error.code + ' ,msg:' + error.message);
expect(error.code).assertEqual(SERVICE_EXCEPTION_CODE);
expect(error.message).assertEqual(SERVICE_EXCEPTION_MSG);
done();
}
}
})
} catch (error) {
console.info("newGravity_SensorJsTest032 Device does not support! ");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
})}
......@@ -92,7 +92,7 @@ describe("SensorJsTest_sensor_43", function () {
}
})
} catch (error) {
console.info('newGyroScope_SensorJsTest014 Device does not support');
console.info('newGyroScope_SensorJsTest014 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
......@@ -143,7 +143,7 @@ describe("SensorJsTest_sensor_43", function () {
}
})
} catch (error) {
console.info('newGyroScope_SensorJsTest016 Device does not support');
console.info('newGyroScope_SensorJsTest016 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
......@@ -180,7 +180,7 @@ describe("SensorJsTest_sensor_43", function () {
}
})
} catch (error) {
console.info("newGyroScope_SensorJsTest017 Device does not support");
console.info("newGyroScope_SensorJsTest017 Device does not support! ");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
......@@ -207,7 +207,7 @@ describe("SensorJsTest_sensor_43", function () {
}
})
} catch (error) {
console.info("newGyroScope_SensorJsTest018 Device does not support");
console.info("newGyroScope_SensorJsTest018 Device does not support! ");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
......@@ -275,7 +275,7 @@ describe("SensorJsTest_sensor_43", function () {
try {
sensor.off(invalid, callback);
} catch (error) {
console.info('newGyroScope_SensorJsTest021 Device does not support');
console.info('newGyroScope_SensorJsTest021 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE)
expect(error.message).assertEqual(PARAMETER_ERROR_MSG)
done();
......@@ -370,7 +370,7 @@ describe("SensorJsTest_sensor_43", function () {
}
})
} catch (error) {
console.info("newGyroScope_SensorJsTest024 Device does not support");
console.info("newGyroScope_SensorJsTest024 Device does not support! ");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
......@@ -386,7 +386,7 @@ describe("SensorJsTest_sensor_43", function () {
try {
sensor.off(sensor.SensorId.GYROSCOPE, 5);
} catch (error) {
console.info('newGyroScope_SensorJsTest025 Device does not support');
console.info('newGyroScope_SensorJsTest025 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE)
expect(error.message).assertEqual(PARAMETER_ERROR_MSG)
done();
......@@ -429,7 +429,7 @@ describe("SensorJsTest_sensor_43", function () {
}
})
} catch (error) {
console.info("newGyroScope_SensorJsTest026 Device does not support");
console.info("newGyroScope_SensorJsTest026 Device does not support! ");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
......@@ -472,7 +472,7 @@ describe("SensorJsTest_sensor_43", function () {
}
})
} catch (error) {
console.info("newGyroScope_SensorJsTest027 Device does not support");
console.info("newGyroScope_SensorJsTest027 Device does not support! ");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
......@@ -545,7 +545,7 @@ describe("SensorJsTest_sensor_43", function () {
}
})
} catch (error) {
console.info("newGyroScope_SensorJsTest029 Device does not support");
console.info("newGyroScope_SensorJsTest029 Device does not support! ");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
......@@ -586,7 +586,7 @@ describe("SensorJsTest_sensor_43", function () {
}
})
} catch (error) {
console.info("newGyroScope_SensorJsTest030 Device does not support");
console.info("newGyroScope_SensorJsTest030 Device does not support! ");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
......@@ -619,7 +619,7 @@ describe("SensorJsTest_sensor_43", function () {
}
})
} catch (error) {
console.info("newGyroScope_SensorJsTest031 Device does not support");
console.info("newGyroScope_SensorJsTest031 Device does not support! ");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
......@@ -653,7 +653,7 @@ describe("SensorJsTest_sensor_43", function () {
}
})
} catch (error) {
console.info("newGyroScope_SensorJsTest032 Device does not support");
console.info("newGyroScope_SensorJsTest032 Device does not support! ");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
......
......@@ -78,11 +78,48 @@ describe("SensorJsTest_sensor_37", function () {
*/
it("newMagneticField_SensorJsTest014", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
console.info('---------newMagneticField_SensorJsTest014--------------');
try{
sensor.getSingleSensor(sensor.SensorId.MAGNETIC_FIELD,(error, data) => {
sensor.on(sensor.SensorId.MAGNETIC_FIELD, callback);
setTimeout(()=>{
sensor.off(sensor.SensorId.MAGNETIC_FIELD);
done();
}, 500);
})
} catch (error) {
console.info('newMagneticField_SensorJsTest014 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number:SUB_SensorsSystem_MAGNETIC_FIELD_JSTest_0150
* @tc.name: newMagneticField_SensorJsTest015
* @tc.desc: Illegal ID passed in
*/
it("newMagneticField_SensorJsTest014", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
console.info('---------newMagneticField_SensorJsTest014--------------');
try{
sensor.getSingleSensor(sensor.SensorId.MAGNETIC_FIELD,(error, data) => {
if (error) {
console.info('newMagneticField_SensorJsTest014 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.on(sensor.SensorId.MAGNETIC_FIELD, callback);
setTimeout(()=>{
sensor.off(sensor.SensorId.MAGNETIC_FIELD);
done();
}, 500);
}
})
} catch (error) {
console.info('newMagneticField_SensorJsTest014 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
......@@ -113,6 +150,12 @@ describe("SensorJsTest_sensor_37", function () {
*/
it("newMagneticField_SensorJsTest016", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('---------newMagneticField_SensorJsTest016--------------');
try{
sensor.getSingleSensor(sensor.SensorId.MAGNETIC_FIELD,(error, data) => {
if (error) {
console.info('newMagneticField_SensorJsTest016 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.on(sensor.SensorId.MAGNETIC_FIELD, callback, {'interval': 100000000});
setTimeout(()=>{
console.info('---------newMagneticField_SensorJsTest016 off in--------------');
......@@ -120,6 +163,14 @@ describe("SensorJsTest_sensor_37", function () {
console.info('---------newMagneticField_SensorJsTest016 off end--------------');
done();
}, 500);
}
})
} catch (error) {
console.info('newMagneticField_SensorJsTest016 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
......@@ -136,19 +187,27 @@ describe("SensorJsTest_sensor_37", function () {
expect(typeof (data.z)).assertEqual("number");
expect(typeof (data.timestamp)).assertEqual("number");
}
try {
try{
sensor.getSingleSensor(sensor.SensorId.MAGNETIC_FIELD,(error, data) => {
if (error) {
console.info('newMagneticField_SensorJsTest017 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.on(sensor.SensorId.MAGNETIC_FIELD, onSensorCallback, {'interval': 100000000}, 5);
} catch (error) {
console.info("newMagneticField_SensorJsTest017 error:" +error);
expect(false).assertTrue();
done();
}
setTimeout(()=>{
console.info('---------newMagneticField_SensorJsTest017 off in--------------');
sensor.off(sensor.SensorId.MAGNETIC_FIELD);
console.info('---------newMagneticField_SensorJsTest017 off end--------------');
done();
}, 500);
}
})
} catch (error) {
console.info("newMagneticField_SensorJsTest017 Device does not support! ");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
......@@ -157,11 +216,25 @@ describe("SensorJsTest_sensor_37", function () {
* @tc.desc: Once Normal Subscription Scenario Use Case
*/
it("newMagneticField_SensorJsTest018", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
try{
sensor.getSingleSensor(sensor.SensorId.MAGNETIC_FIELD,(error, data) => {
if (error) {
console.info('newMagneticField_SensorJsTest018 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.once(sensor.SensorId.MAGNETIC_FIELD, callback);
setTimeout(()=>{
expect(true).assertTrue();
done();
}, 500);
}
})
} catch (error) {
console.info("newMagneticField_SensorJsTest018 Device does not support! ");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
......@@ -200,10 +273,18 @@ describe("SensorJsTest_sensor_37", function () {
done();
}
try{
sensor.getSingleSensor(sensor.SensorId.MAGNETIC_FIELD,(error, data) => {
if (error) {
console.info('newMagneticField_SensorJsTest020 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.once(sensor.SensorId.MAGNETIC_FIELD, onceSensorCallback, 5);
}
})
} catch (error) {
console.info('newMagneticField_SensorJsTest020 error:' +error);
expect(false).assertTrue();
console.info("newMagneticField_SensorJsTest020 error:" +error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
......@@ -217,7 +298,7 @@ describe("SensorJsTest_sensor_37", function () {
try {
sensor.off(invalid, callback);
} catch (error) {
console.info('newMagneticField_SensorJsTest021 error:' +error);
console.info('newMagneticField_SensorJsTest021 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE)
expect(error.message).assertEqual(PARAMETER_ERROR_MSG)
done();
......@@ -235,12 +316,26 @@ describe("SensorJsTest_sensor_37", function () {
expect(false).assertTrue();
done();
}
try{
sensor.getSingleSensor(sensor.SensorId.MAGNETIC_FIELD,(error, data) => {
if (error) {
console.info('newMagneticField_SensorJsTest022 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.on(sensor.SensorId.MAGNETIC_FIELD, onSensorCallback);
sensor.off(sensor.SensorId.MAGNETIC_FIELD, onSensorCallback);
setTimeout(()=>{
expect(true).assertTrue();
done();
}, 500);
}
})
} catch (error) {
console.info("newMagneticField_SensorJsTest022 error:" +error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
......@@ -269,6 +364,12 @@ describe("SensorJsTest_sensor_37", function () {
* @tc.desc:Call interface multiple times
*/
it("newMagneticField_SensorJsTest024", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
try{
sensor.getSingleSensor(sensor.SensorId.MAGNETIC_FIELD,(error, data) => {
if (error) {
console.info('newMagneticField_SensorJsTest024 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.on(sensor.SensorId.MAGNETIC_FIELD, (data)=>{
console.info("newMagneticField_SensorJsTest024 callback: " + JSON.stringify(data));
expect(typeof (data.x)).assertEqual("number");
......@@ -289,6 +390,14 @@ describe("SensorJsTest_sensor_37", function () {
console.info('---------newMagneticField_SensorJsTest024 off end--------------');
done();
}, 1000);
}
})
} catch (error) {
console.info("newMagneticField_SensorJsTest024 Device does not support! ");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
......@@ -300,7 +409,7 @@ describe("SensorJsTest_sensor_37", function () {
try {
sensor.off(sensor.SensorId.MAGNETIC_FIELD, 5);
} catch (error) {
console.info('newMagneticField_SensorJsTest025 error:'+error);
console.info('newMagneticField_SensorJsTest025 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE)
expect(error.message).assertEqual(PARAMETER_ERROR_MSG)
done();
......@@ -314,6 +423,12 @@ describe("SensorJsTest_sensor_37", function () {
*/
it("newMagneticField_SensorJsTest026", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('---------newMagneticField_SensorJsTest026--------------');
try{
sensor.getSingleSensor(sensor.SensorId.MAGNETIC_FIELD,(error, data) => {
if (error) {
console.info('newMagneticField_SensorJsTest024 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.on(sensor.SensorId.MAGNETIC_FIELD, (data)=>{
console.info("newMagneticField_SensorJsTest026 callback: " + JSON.stringify(data));
expect(typeof (data.x)).assertEqual("number");
......@@ -334,6 +449,14 @@ describe("SensorJsTest_sensor_37", function () {
console.info('---------newMagneticField_SensorJsTest026 off end--------------');
done();
}, 1000);
}
})
} catch (error) {
console.info("newMagneticField_SensorJsTest026 Device does not support! ");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
......@@ -343,6 +466,12 @@ describe("SensorJsTest_sensor_37", function () {
*/
it("newMagneticField_SensorJsTest027", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('---------newMagneticField_SensorJsTest027--------------');
try{
sensor.getSingleSensor(sensor.SensorId.MAGNETIC_FIELD,(error, data) => {
if (error) {
console.info('newMagneticField_SensorJsTest024 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.on(sensor.SensorId.MAGNETIC_FIELD, (data)=>{
console.info("newMagneticField_SensorJsTest027 callback: " + JSON.stringify(data));
expect(typeof (data.x)).assertEqual("number");
......@@ -363,6 +492,14 @@ describe("SensorJsTest_sensor_37", function () {
console.info('---------newMagneticField_SensorJsTest027 off end--------------');
done();
}, 1000);
}
})
} catch (error) {
console.info("newMagneticField_SensorJsTest027 Device does not support! ");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
......@@ -375,7 +512,7 @@ describe("SensorJsTest_sensor_37", function () {
try {
sensor.on();
} catch (error) {
console.info("newMagneticField_SensorJsTest028 error:" +error);
console.info("newMagneticField_SensorJsTest028_on error:" +error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
......@@ -383,7 +520,7 @@ describe("SensorJsTest_sensor_37", function () {
try {
sensor.once();
} catch (error) {
console.info("newMagneticField_SensorJsTest028 error:" +error);
console.info("newMagneticField_SensorJsTest028_once error:" +error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
......@@ -391,7 +528,7 @@ describe("SensorJsTest_sensor_37", function () {
try {
sensor.off();
} catch (error) {
console.info("newMagneticField_SensorJsTest028 error:" +error);
console.info("newMagneticField_SensorJsTest028_off error:" +error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
......@@ -405,6 +542,12 @@ describe("SensorJsTest_sensor_37", function () {
*/
it("newMagneticField_SensorJsTest029", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------newMagneticField_SensorJsTest029--------------');
try{
sensor.getSingleSensor(sensor.SensorId.MAGNETIC_FIELD,(error, data) => {
if (error) {
console.info('newMagneticField_SensorJsTest029 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.on(sensor.SensorId.MAGNETIC_FIELD, callback);
sensor.on(sensor.SensorId.MAGNETIC_FIELD, callback2);
setTimeout(() => {
......@@ -422,6 +565,14 @@ describe("SensorJsTest_sensor_37", function () {
console.info('----------------------newMagneticField_SensorJsTest029 off end--------------');
done();
}, 1000);
}
})
} catch (error) {
console.info("newMagneticField_SensorJsTest029 Device does not support! ");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
......@@ -431,6 +582,12 @@ describe("SensorJsTest_sensor_37", function () {
*/
it("newMagneticField_SensorJsTest030", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------newMagneticField_SensorJsTest030--------------');
try{
sensor.getSingleSensor(sensor.SensorId.MAGNETIC_FIELD,(error, data) => {
if (error) {
console.info('newMagneticField_SensorJsTest029 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.on(sensor.SensorId.MAGNETIC_FIELD, callback, { 'interval': 100000000 });
sensor.on(sensor.SensorId.MAGNETIC_FIELD, callback2, { 'interval': 100000000 });
setTimeout(() => {
......@@ -449,5 +606,80 @@ describe("SensorJsTest_sensor_37", function () {
console.info('----------------------newMagneticField_SensorJsTest030_2 off end--------------');
done();
}, 1000);
}
})
} catch (error) {
console.info("newMagneticField_SensorJsTest030 Device does not support! ");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number: SUB_SensorsSystem_MAGNETIC_FIELD_JSTest_0310
* @tc.name: newMagneticField_SensorJsTest031
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("newMagneticField_SensorJsTest031", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------newMagneticField_SensorJsTest031--------------');
try{
sensor.getSingleSensor(sensor.SensorId.MAGNETIC_FIELD,(error, data) => {
if (error) {
console.info('newMagneticField_SensorJsTest031 error');
} else {
expect(typeof(data)).assertEqual("object");
console.info('----------------------newMagneticField_SensorJsTest031 off in--------------');
try{
sensor.off(-1, callback);
console.info('----------------------newMagneticField_SensorJsTest031 off end--------------');
} catch (error) {
console.info("newMagneticField_SensorJsTest031 error:" + error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
}
})
} catch (error) {
console.info("newMagneticField_SensorJsTest031 Device does not support! ");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number: SUB_SensorsSystem_MAGNETIC_FIELD_JSTest_0320
* @tc.name: newMagneticField_SensorJsTest032
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("newMagneticField_SensorJsTest032", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------newMagneticField_SensorJsTest032--------------');
try{
sensor.getSingleSensor(sensor.SensorId.MAGNETIC_FIELD,(error, data) => {
if (error) {
console.info('newMagneticField_SensorJsTest032 error');
} else {
try {
sensor.on(sensor.SensorId.MAGNETIC_FIELD, callback, {'interval': -100000000});
console.info('----------------------newMagneticField_SensorJsTest032 off in---------------------------');
sensor.off(sensor.SensorId.MAGNETIC_FIELD);
console.info('----------------------newMagneticField_SensorJsTest032 off end---------------------------');
done();
} catch (error) {
console.info('newMagneticField_SensorJsTest032 On fail, errCode:' + error.code + ' ,msg:' + error.message);
expect(error.code).assertEqual(SERVICE_EXCEPTION_CODE);
expect(error.message).assertEqual(SERVICE_EXCEPTION_MSG);
done();
}
}
})
} catch (error) {
console.info("newMagneticField_SensorJsTest032 Device does not support! ");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
})}
......@@ -78,12 +78,25 @@ describe("SensorJsTest_sensor_48", function () {
*/
it("newOrientating_SensorJsTest014", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
console.info('---------newOrientating_SensorJsTest014--------------');
try{
sensor.getSingleSensor(sensor.SensorId.ORIENTATION,(error, data) => {
if (error) {
console.info('newOrientating_SensorJsTest014 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.on(sensor.SensorId.ORIENTATION, callback);
setTimeout(()=>{
sensor.off(sensor.SensorId.ORIENTATION);
sensor.off(sensor.SensorId.ORIENTATION);
done();
}, 500);
}
})
} catch (error) {
console.info('newOrientating_SensorJsTest014 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
......@@ -113,7 +126,13 @@ describe("SensorJsTest_sensor_48", function () {
* @tc.desc: For normal scenarios
*/
it("newOrientating_SensorJsTest016", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('---------SensorJsTest003--------------');
console.info('---------newOrientating_SensorJsTest016--------------');
try{
sensor.getSingleSensor(sensor.SensorId.ORIENTATION,(error, data) => {
if (error) {
console.info('newOrientating_SensorJsTest016 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.on(sensor.SensorId.ORIENTATION, callback, {'interval': 100000000});
setTimeout(()=>{
console.info('---------newOrientating_SensorJsTest016 off in--------------');
......@@ -121,6 +140,14 @@ describe("SensorJsTest_sensor_48", function () {
console.info('---------newOrientating_SensorJsTest016 off end--------------');
done();
}, 500);
}
})
} catch (error) {
console.info('newOrientating_SensorJsTest016 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
......@@ -137,19 +164,27 @@ describe("SensorJsTest_sensor_48", function () {
expect(typeof(data.alpha)).assertEqual("number");
expect(typeof (data.timestamp)).assertEqual("number");
}
try {
try{
sensor.getSingleSensor(sensor.SensorId.ORIENTATION,(error, data) => {
if (error) {
console.info('newOrientating_SensorJsTest017 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.on(sensor.SensorId.ORIENTATION, onSensorCallback, {'interval': 100000000}, 5);
} catch (error) {
console.info("newOrientating_SensorJsTest017 error:" +error);
expect(false).assertTrue();
done();
}
setTimeout(()=>{
console.info('---------newOrientating_SensorJsTest017 off in--------------');
sensor.off(sensor.SensorId.ORIENTATION);
console.info('---------newOrientating_SensorJsTest017 off end--------------');
done();
}, 500);
}
})
} catch (error) {
console.info("newOrientating_SensorJsTest017 Device does not support! ");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
......@@ -158,11 +193,25 @@ describe("SensorJsTest_sensor_48", function () {
* @tc.desc: Once Normal Subscription Scenario Use Case
*/
it("newOrientating_SensorJsTest018", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
try{
sensor.getSingleSensor(sensor.SensorId.ORIENTATION,(error, data) => {
if (error) {
console.info('newOrientating_SensorJsTest018 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.once(sensor.SensorId.ORIENTATION, callback);
setTimeout(()=>{
expect(true).assertTrue();
done();
}, 500);
}
})
} catch (error) {
console.info("newOrientating_SensorJsTest018 Device does not support! ");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
......@@ -201,10 +250,18 @@ describe("SensorJsTest_sensor_48", function () {
done();
}
try{
sensor.getSingleSensor(sensor.SensorId.ORIENTATION,(error, data) => {
if (error) {
console.info('newOrientating_SensorJsTest020 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.once(sensor.SensorId.ORIENTATION, onceSensorCallback, 5);
}
})
} catch (error) {
console.info('newOrientating_SensorJsTest020 error:' +error);
expect(false).assertTrue();
console.info("newOrientating_SensorJsTest020 error:" +error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
......@@ -218,7 +275,7 @@ describe("SensorJsTest_sensor_48", function () {
try {
sensor.off(invalid, callback);
} catch (error) {
console.info('newOrientating_SensorJsTest021 error:' +error);
console.info('newOrientating_SensorJsTest021 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE)
expect(error.message).assertEqual(PARAMETER_ERROR_MSG)
done();
......@@ -236,12 +293,26 @@ describe("SensorJsTest_sensor_48", function () {
expect(false).assertTrue();
done();
}
try{
sensor.getSingleSensor(sensor.SensorId.ORIENTATION,(error, data) => {
if (error) {
console.info('newOrientating_SensorJsTest022 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.on(sensor.SensorId.ORIENTATION, onSensorCallback);
sensor.off(sensor.SensorId.ORIENTATION, onSensorCallback);
setTimeout(()=>{
expect(true).assertTrue();
done();
}, 500);
}
})
} catch (error) {
console.info("newOrientating_SensorJsTest022 error:" +error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
......@@ -270,6 +341,12 @@ describe("SensorJsTest_sensor_48", function () {
* @tc.desc:Call interface multiple times
*/
it("newOrientating_SensorJsTest024", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
try{
sensor.getSingleSensor(sensor.SensorId.ORIENTATION,(error, data) => {
if (error) {
console.info('newOrientating_SensorJsTest024 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.on(sensor.SensorId.ORIENTATION, (data)=>{
console.info("newOrientating_SensorJsTest024 callback: " + JSON.stringify(data));
expect(typeof(data.beta)).assertEqual("number");
......@@ -290,6 +367,14 @@ describe("SensorJsTest_sensor_48", function () {
console.info('---------newOrientating_SensorJsTest024 off end--------------');
done();
}, 1000);
}
})
} catch (error) {
console.info("newOrientating_SensorJsTest024 Device does not support! ");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
......@@ -301,7 +386,7 @@ describe("SensorJsTest_sensor_48", function () {
try {
sensor.off(sensor.SensorId.ORIENTATION, 5);
} catch (error) {
console.info('newOrientating_SensorJsTest025 error:'+error);
console.info('newOrientating_SensorJsTest025 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE)
expect(error.message).assertEqual(PARAMETER_ERROR_MSG)
done();
......@@ -315,6 +400,12 @@ describe("SensorJsTest_sensor_48", function () {
*/
it("newOrientating_SensorJsTest026", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('---------newOrientating_SensorJsTest026--------------');
try{
sensor.getSingleSensor(sensor.SensorId.ORIENTATION,(error, data) => {
if (error) {
console.info('newOrientating_SensorJsTest024 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.on(sensor.SensorId.ORIENTATION, (data)=>{
console.info("newOrientating_SensorJsTest026 callback: " + JSON.stringify(data));
expect(typeof(data.beta)).assertEqual("number");
......@@ -335,6 +426,14 @@ describe("SensorJsTest_sensor_48", function () {
console.info('---------newOrientating_SensorJsTest026 off end--------------');
done();
}, 1000);
}
})
} catch (error) {
console.info("newOrientating_SensorJsTest026 Device does not support! ");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
......@@ -344,6 +443,12 @@ describe("SensorJsTest_sensor_48", function () {
*/
it("newOrientating_SensorJsTest027", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('---------newOrientating_SensorJsTest027--------------');
try{
sensor.getSingleSensor(sensor.SensorId.ORIENTATION,(error, data) => {
if (error) {
console.info('newOrientating_SensorJsTest024 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.on(sensor.SensorId.ORIENTATION, (data)=>{
console.info("newOrientating_SensorJsTest027 callback: " + JSON.stringify(data));
expect(typeof(data.beta)).assertEqual("number");
......@@ -364,6 +469,14 @@ describe("SensorJsTest_sensor_48", function () {
console.info('---------newOrientating_SensorJsTest027 off end--------------');
done();
}, 1000);
}
})
} catch (error) {
console.info("newOrientating_SensorJsTest027 Device does not support! ");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
......@@ -376,7 +489,7 @@ describe("SensorJsTest_sensor_48", function () {
try {
sensor.on();
} catch (error) {
console.info("newOrientating_SensorJsTest028 error:" +error);
console.info("newOrientating_SensorJsTest028_on error:" +error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
......@@ -384,7 +497,7 @@ describe("SensorJsTest_sensor_48", function () {
try {
sensor.once();
} catch (error) {
console.info("newOrientating_SensorJsTest028 error:" +error);
console.info("newOrientating_SensorJsTest028_once error:" +error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
......@@ -392,7 +505,7 @@ describe("SensorJsTest_sensor_48", function () {
try {
sensor.off();
} catch (error) {
console.info("newOrientating_SensorJsTest028 error:" +error);
console.info("newOrientating_SensorJsTest028_off error:" +error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
......@@ -406,6 +519,12 @@ describe("SensorJsTest_sensor_48", function () {
*/
it("newOrientating_SensorJsTest029", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------newOrientating_SensorJsTest029--------------');
try{
sensor.getSingleSensor(sensor.SensorId.ORIENTATION,(error, data) => {
if (error) {
console.info('newOrientating_SensorJsTest029 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.on(sensor.SensorId.ORIENTATION, callback);
sensor.on(sensor.SensorId.ORIENTATION, callback2);
setTimeout(() => {
......@@ -423,6 +542,14 @@ describe("SensorJsTest_sensor_48", function () {
console.info('----------------------newOrientating_SensorJsTest029 off end--------------');
done();
}, 1000);
}
})
} catch (error) {
console.info("newOrientating_SensorJsTest029 Device does not support! ");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
......@@ -432,6 +559,12 @@ describe("SensorJsTest_sensor_48", function () {
*/
it("newOrientating_SensorJsTest030", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------newOrientating_SensorJsTest030--------------');
try{
sensor.getSingleSensor(sensor.SensorId.ORIENTATION,(error, data) => {
if (error) {
console.info('newOrientating_SensorJsTest029 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.on(sensor.SensorId.ORIENTATION, callback, { 'interval': 100000000 });
sensor.on(sensor.SensorId.ORIENTATION, callback2, { 'interval': 100000000 });
setTimeout(() => {
......@@ -450,5 +583,80 @@ describe("SensorJsTest_sensor_48", function () {
console.info('----------------------newOrientating_SensorJsTest030_2 off end--------------');
done();
}, 1000);
}
})
} catch (error) {
console.info("newOrientating_SensorJsTest030 Device does not support! ");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number: SUB_SensorsSystem_ORIENTATION_JSTest_0310
* @tc.name: newOrientating_SensorJsTest031
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("newOrientating_SensorJsTest031", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------newOrientating_SensorJsTest031--------------');
try{
sensor.getSingleSensor(sensor.SensorId.ORIENTATION,(error, data) => {
if (error) {
console.info('newOrientating_SensorJsTest031 error');
} else {
expect(typeof(data)).assertEqual("object");
console.info('----------------------newOrientating_SensorJsTest031 off in--------------');
try{
sensor.off(-1, callback);
console.info('----------------------newOrientating_SensorJsTest031 off end--------------');
} catch (error) {
console.info("newOrientating_SensorJsTest031 error:" + error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
}
})
} catch (error) {
console.info("newOrientating_SensorJsTest031 Device does not support! ");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number: SUB_SensorsSystem_ORIENTATION_JSTest_0320
* @tc.name: newOrientating_SensorJsTest032
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("newOrientating_SensorJsTest032", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------newOrientating_SensorJsTest032--------------');
try{
sensor.getSingleSensor(sensor.SensorId.ORIENTATION,(error, data) => {
if (error) {
console.info('newOrientating_SensorJsTest032 error');
} else {
try {
sensor.on(sensor.SensorId.ORIENTATION, callback, {'interval': -100000000});
console.info('----------------------newOrientating_SensorJsTest032 off in---------------------------');
sensor.off(sensor.SensorId.ORIENTATION);
console.info('----------------------newOrientating_SensorJsTest032 off end---------------------------');
done();
} catch (error) {
console.info('newOrientating_SensorJsTest032 On fail, errCode:' + error.code + ' ,msg:' + error.message);
expect(error.code).assertEqual(SERVICE_EXCEPTION_CODE);
expect(error.message).assertEqual(SERVICE_EXCEPTION_MSG);
done();
}
}
})
} catch (error) {
console.info("newOrientating_SensorJsTest032 Device does not support! ");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
})}
......@@ -61,8 +61,11 @@ describe("SensorJsTest_sensor_4", function () {
console.info('afterEach caled')
})
const PARAMETER_ERROR_CODE = 401
const PARAMETER_ERROR_MSG = 'The parameter invalid.'
const SERVICE_EXCEPTION_CODE = 14500101
const SERVICE_EXCEPTION_MSG = 'Service exception.'
let errMessages = ['string is not defined','The parameter invalid'];
let errMessage;
/*
......@@ -72,12 +75,21 @@ describe("SensorJsTest_sensor_4", function () {
*/
it("Ambient_Light_SensorJsTest001", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
console.info('----------------------Ambient_Light_SensorJsTest001---------------------------');
try{
sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT,(error, data) => {
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback);
setTimeout(() => {
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT);
done();
}, 500);
})
} catch (error) {
console.info('Ambient_Light_SensorJsTest001 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number: SUB_SensorsSystem_Ambient_Light_JSTest_0020
......@@ -86,6 +98,8 @@ describe("SensorJsTest_sensor_4", function () {
*/
it("Ambient_Light_SensorJsTest002", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------Ambient_Light_SensorJsTest002---------------------------');
try{
sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT,(error, data) => {
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback, { 'interval': 100000000 });
setTimeout(() => {
console.info('----------------------Ambient_Light_SensorJsTest002 off in---------------------------');
......@@ -94,6 +108,13 @@ describe("SensorJsTest_sensor_4", function () {
done();
}, 500);
})
} catch (error) {
console.info('Ambient_Light_SensorJsTest002 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number: SUB_SensorsSystem_Ambient_Light_JSTest_0030
......@@ -108,12 +129,15 @@ describe("SensorJsTest_sensor_4", function () {
expect(typeof (data.timestamp)).assertEqual("number");
done();
}
try {
try{
sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT,(error, data) => {
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, onSensorCallback, { 'interval': 100000000 }, 5);
})
} catch (error) {
console.info("Ambient_Light_SensorJsTest003 error:" + error);
console.info('Ambient_Light_SensorJsTest003 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
......@@ -124,12 +148,21 @@ describe("SensorJsTest_sensor_4", function () {
*/
it("Ambient_Light_SensorJsTest004", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------Ambient_Light_SensorJsTest004---------------------------');
try{
sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT,(error, data) => {
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback);
setTimeout(() => {
expect(true).assertTrue();
done();
}, 500);
})
} catch (error) {
console.info('Ambient_Light_SensorJsTest004 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number: SUB_SensorsSystem_Ambient_Light_JSTest_0050
......@@ -144,12 +177,20 @@ describe("SensorJsTest_sensor_4", function () {
expect(typeof (data.timestamp)).assertEqual("number");
done();
}
try{
sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT,(error, data) => {
try {
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, onceSensorCallback, 5);
} catch (error) {
console.info("Ambient_Light_SensorJsTest005 error:" + error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
}
})
} catch (error) {
console.info('Ambient_Light_SensorJsTest005 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
......@@ -161,6 +202,8 @@ describe("SensorJsTest_sensor_4", function () {
*/
it("Ambient_Light_SensorJsTest006", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------Ambient_Light_SensorJsTest006---------------------------');
try{
sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT,(error, data) => {
try {
sensor.off(string, "");
} catch (error) {
......@@ -170,6 +213,13 @@ describe("SensorJsTest_sensor_4", function () {
done();
}
})
} catch (error) {
console.info('Ambient_Light_SensorJsTest006 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number: SUB_SensorsSystem_Ambient_Light_JSTest_0070
......@@ -183,6 +233,8 @@ describe("SensorJsTest_sensor_4", function () {
expect(false).assertTrue();
done();
}
try{
sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT,(error, data) => {
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, onSensorCallback);
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, onSensorCallback);
setTimeout(() => {
......@@ -190,6 +242,13 @@ describe("SensorJsTest_sensor_4", function () {
done();
}, 500);
})
} catch (error) {
console.info('Ambient_Light_SensorJsTest007 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number: SUB_SensorsSystem_Ambient_Light_JSTest_0080
......@@ -202,6 +261,8 @@ describe("SensorJsTest_sensor_4", function () {
console.info('Ambient_Light_SensorJsTest008 on error');
expect(false).assertTrue();
}
try{
sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT,(error, data) => {
try {
sensor.off(1000000, onSensorCallback);
} catch (error) {
......@@ -211,6 +272,13 @@ describe("SensorJsTest_sensor_4", function () {
done();
}
})
} catch (error) {
console.info('Ambient_Light_SensorJsTest008 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number: SUB_SensorsSystem_Ambient_Light_JSTest_0090
......@@ -219,6 +287,8 @@ describe("SensorJsTest_sensor_4", function () {
*/
it("Ambient_Light_SensorJsTest009", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------Ambient_Light_SensorJsTest009---------------------------');
try{
sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT,(error, data) => {
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback);
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback2);
setTimeout(() => {
......@@ -228,6 +298,13 @@ describe("SensorJsTest_sensor_4", function () {
done();
}, 1000);
})
} catch (error) {
console.info('Ambient_Light_SensorJsTest009 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number: SUB_SensorsSystem_Ambient_Light_JSTest_0100
......@@ -236,6 +313,8 @@ describe("SensorJsTest_sensor_4", function () {
*/
it("Ambient_Light_SensorJsTest010", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------Ambient_Light_SensorJsTest010---------------------------');
try{
sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT,(error, data) => {
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback);
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback2);
setTimeout(() => {
......@@ -254,6 +333,13 @@ describe("SensorJsTest_sensor_4", function () {
done();
}, 1000);
})
} catch (error) {
console.info('Ambient_Light_SensorJsTest010 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number: SUB_SensorsSystem_Ambient_Light_JSTest_0110
......@@ -262,6 +348,8 @@ describe("SensorJsTest_sensor_4", function () {
*/
it("Ambient_Light_SensorJsTest011", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------Ambient_Light_SensorJsTest011---------------------------');
try{
sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT,(error, data) => {
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback, { 'interval': 100000000 });
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback2);
setTimeout(() => {
......@@ -271,14 +359,23 @@ describe("SensorJsTest_sensor_4", function () {
done();
}, 1000);
})
} catch (error) {
console.info('Ambient_Light_SensorJsTest011 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number: SUB_SensorsSystem_Ambient_Light_JSTest_0120
* @tc.name: Ambient_Light_SensorJsTest012
* @tc.name:Ambient_Light_SensorJsTest012
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("Ambient_Light_SensorJsTest012", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------Ambient_Light_SensorJsTest012---------------------------');
try{
sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT,(error, data) => {
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback, { 'interval': 100000000 });
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback2, { 'interval': 100000000 });
setTimeout(() => {
......@@ -298,14 +395,23 @@ describe("SensorJsTest_sensor_4", function () {
done();
}, 1000);
})
} catch (error) {
console.info('Ambient_Light_SensorJsTest012 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number: SUB_SensorsSystem_Ambient_Light_JSTest_0130
* @tc.name: Ambient_Light_SensorJsTest013
* @tc.name:Ambient_Light_SensorJsTest013
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("Ambient_Light_SensorJsTest013", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------Ambient_Light_SensorJsTest013---------------------------');
try{
sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT,(error, data) => {
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback, { 'interval': 100000000 });
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback2, { 'interval': 100000000 });
setTimeout(() => {
......@@ -315,4 +421,11 @@ describe("SensorJsTest_sensor_4", function () {
done();
}, 1000);
})
} catch (error) {
console.info('Ambient_Light_SensorJsTest013 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
})}
......@@ -67,8 +67,8 @@ describe("SensorJsTest_sensor_8", function () {
const SERVICE_EXCEPTION_CODE = 14500101
const SERVICE_EXCEPTION_MSG = 'Service exception.'
let invalid = -1;
let errMessages = ['ReferenceError: string is not defined','TypeError: is not callable','ReferenceError: xxx is not defined']
let errMessage
let errMessages = ['string is not defined','The parameter invalid'];
let errMessage;
/*
* @tc.number:SUB_SensorsSystem_BAROMETER_JSTest_0010
......@@ -76,19 +76,21 @@ describe("SensorJsTest_sensor_8", function () {
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("Barometer_SensorJsTest001", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
console.info('--------Barometer_SensorJsTest001--------');
try {
console.info('----------------------Barometer_SensorJsTest001---------------------------');
try{
sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER,(error, data) => {
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, callback);
setTimeout(() => {
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER);
done();
}, 500);
})
} catch (error) {
console.info("Barometer_SensorJsTest001 error:" + error);
console.info('Barometer_SensorJsTest001 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
setTimeout(() => {
expect(true).assertTrue();
done();
}, 500);
})
/*
......@@ -97,11 +99,19 @@ describe("SensorJsTest_sensor_8", function () {
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("Barometer_SensorJsTest002", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('--------Barometer_SensorJsTest002--------');
try {
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER ,callback, { 'interval': 100000000 });
console.info('----------------------Barometer_SensorJsTest002---------------------------');
try{
sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER,(error, data) => {
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, callback, { 'interval': 100000000 });
setTimeout(() => {
console.info('----------------------Barometer_SensorJsTest002 off in---------------------------');
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER);
console.info('----------------------Barometer_SensorJsTest002 off end---------------------------');
done();
}, 500);
})
} catch (error) {
console.info("Barometer_SensorJsTest002 error:" + error);
console.info('Barometer_SensorJsTest002 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
......@@ -114,16 +124,19 @@ describe("SensorJsTest_sensor_8", function () {
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("Barometer_SensorJsTest003", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('--------Barometer_SensorJsTest003--------');
console.info('----------------------Barometer_SensorJsTest003---------------------------');
function onSensorCallback(data) {
console.info('Barometer_SensorJsTest003 on error');
expect(typeof (data.pressure)).assertEqual("number");
expect(typeof (data.timestamp)).assertEqual("number");
done();
}
try {
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER,
onSensorCallback, { 'interval': 100000000 }, 5);
try{
sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER,(error, data) => {
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, onSensorCallback, { 'interval': 100000000 }, 5);
})
} catch (error) {
console.info("Barometer_SensorJsTest003 error:" + error);
console.info('Barometer_SensorJsTest003 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
......@@ -136,11 +149,17 @@ describe("SensorJsTest_sensor_8", function () {
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("Barometer_SensorJsTest004", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('--------Barometer_SensorJsTest004--------');
console.info('----------------------Barometer_SensorJsTest004---------------------------');
try{
sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER,(error, data) => {
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, callback);
setTimeout(() => {
expect(true).assertTrue();
done();
}, 500);
})
} catch (error) {
console.info("Barometer_SensorJsTest004 error:" + error);
console.info('Barometer_SensorJsTest004 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
......@@ -153,18 +172,27 @@ describe("SensorJsTest_sensor_8", function () {
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("Barometer_SensorJsTest005", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('--------Barometer_SensorJsTest005--------');
console.info('----------------------Barometer_SensorJsTest005---------------------------');
function onceSensorCallback(data) {
console.info('Barometer_SensorJsTest005 on error');
expect(typeof (data.pressure)).assertEqual("number");
expect(typeof (data.timestamp)).assertEqual("number");
done();
}
try{
sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER,(error, data) => {
try {
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, onceSensorCallback, 5);
} catch (error) {
console.info("Barometer_SensorJsTest005 error:" + error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
}
})
} catch (error) {
console.info('Barometer_SensorJsTest005 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
......@@ -175,17 +203,25 @@ describe("SensorJsTest_sensor_8", function () {
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("Barometer_SensorJsTest006", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('--------Barometer_SensorJsTest006--------');
console.info('----------------------Barometer_SensorJsTest006---------------------------');
try{
sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER,(error, data) => {
try {
sensor.off(string, "");
} catch (error) {
errMessage
console.info("Barometer_SensorJsTest006 error:" + error);
errMessage = error.toString();
errMessage = error.toString().slice(16, 40);
expect(errMessage).assertEqual(errMessages[0]);
done();
}
})
} catch (error) {
console.info('Barometer_SensorJsTest006 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number: SUB_SensorsSystem_BAROMETER_JSTest_0070
......@@ -193,16 +229,23 @@ describe("SensorJsTest_sensor_8", function () {
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("Barometer_SensorJsTest007", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('--------Barometer_SensorJsTest007--------');
console.info('----------------------Barometer_SensorJsTest007---------------------------');
function onSensorCallback(data) {
console.info('Barometer_SensorJsTest007 on error');
expect(typeof (data.pressure)).assertEqual("number");
expect(false).assertTrue();
done();
}
try {
try{
sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER,(error, data) => {
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, onSensorCallback);
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER);
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, onSensorCallback);
setTimeout(() => {
expect(true).assertTrue();
done();
}, 500);
})
} catch (error) {
console.info("Barometer_SensorJsTest007 error:" + error);
console.info('Barometer_SensorJsTest007 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
......@@ -215,15 +258,24 @@ describe("SensorJsTest_sensor_8", function () {
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("Barometer_SensorJsTest008", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('--------Barometer_SensorJsTest008--------');
console.info('----------------------Barometer_SensorJsTest008---------------------------');
function onSensorCallback(data) {
console.info('Barometer_SensorJsTest008 on error');
expect(typeof (data.pressure)).assertEqual("number");
expect(false).assertTrue();
}
try{
sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER,(error, data) => {
try {
sensor.off(1000000, onSensorCallback);
} catch (error) {
console.info("Barometer_SensorJsTest008 error:" + error);
errMessage = error.toString().slice(7, 28);
expect(errMessage).assertEqual(errMessages[1]);
done();
}
})
} catch (error) {
console.info('Barometer_SensorJsTest008 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
......@@ -236,15 +288,20 @@ describe("SensorJsTest_sensor_8", function () {
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("Barometer_SensorJsTest009", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('--------Barometer_SensorJsTest009--------');
function onSensorCallback(data) {
console.info('Barometer_SensorJsTest009 on error');
expect(typeof (data.pressure)).assertEqual("number");
}
try {
sensor.off(invalid, onSensorCallback);
console.info('----------------------Barometer_SensorJsTest009---------------------------');
try{
sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER,(error, data) => {
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, callback);
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, callback2);
setTimeout(() => {
console.info('----------------------Barometer_SensorJsTest009 off in---------------------------');
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER);
console.info('----------------------Barometer_SensorJsTest009 off end---------------------------');
done();
}, 1000);
})
} catch (error) {
console.info("Barometer_SensorJsTest009 error:" + error);
console.info('Barometer_SensorJsTest009 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
......@@ -257,17 +314,31 @@ describe("SensorJsTest_sensor_8", function () {
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("Barometer_SensorJsTest010", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('--------Barometer_SensorJsTest010--------');
function onSensorCallback(data) {
console.info('Barometer_SensorJsTest010 on error');
expect(typeof (data.pressure)).assertEqual("number");
}
console.info('----------------------Barometer_SensorJsTest010---------------------------');
try{
sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER,(error, data) => {
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, callback);
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, callback2);
setTimeout(() => {
console.info('----------------------Barometer_SensorJsTest010 off in---------------------------');
try {
sensor.xxx(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, onSensorCallback);
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, callback);
} catch (error) {
console.info("Barometer_SensorJsTest010 error:" + error);
errMessage = error.toString();
expect(errMessage).assertEqual(errMessages[1]);
}
console.info('----------------------Barometer_SensorJsTest010 off end---------------------------');
}, 500);
setTimeout(() => {
console.info('----------------------Barometer_SensorJsTest010 off in---------------------------');
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, callback2);
console.info('----------------------Barometer_SensorJsTest010 off end---------------------------');
done();
}, 1000);
})
} catch (error) {
console.info('Barometer_SensorJsTest010 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
......@@ -278,17 +349,84 @@ describe("SensorJsTest_sensor_8", function () {
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("Barometer_SensorJsTest011", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('--------Barometer_SensorJsTest011--------');
function onSensorCallback(data) {
console.info('Barometer_SensorJsTest011 on error');
expect(typeof (data.pressure)).assertEqual("number");
console.info('----------------------Barometer_SensorJsTest011---------------------------');
try{
sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER,(error, data) => {
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, callback, { 'interval': 100000000 });
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, callback2);
setTimeout(() => {
console.info('----------------------Barometer_SensorJsTest011 off in---------------------------');
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER);
console.info('----------------------Barometer_SensorJsTest011 off end---------------------------');
done();
}, 1000);
})
} catch (error) {
console.info('Barometer_SensorJsTest011 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number: SUB_SensorsSystem_BAROMETER_JSTest_0120
* @tc.name:Barometer_SensorJsTest012
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("Barometer_SensorJsTest012", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------Barometer_SensorJsTest012---------------------------');
try{
sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER,(error, data) => {
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, callback, { 'interval': 100000000 });
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, callback2, { 'interval': 100000000 });
setTimeout(() => {
console.info('----------------------Barometer_SensorJsTest012 off in---------------------------');
try {
xxx.on(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, onSensorCallback);
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, callback);
} catch (error) {
console.info("Barometer_SensorJsTest011 error:" + error);
errMessage = error.toString();
expect(errMessage).assertEqual(errMessages[2]);
console.info("Barometer_SensorJsTest012 error:" + error);
}
console
console.info('----------------------Barometer_SensorJsTest012 off end---------------------------');
}, 500);
setTimeout(() => {
console.info('----------------------Barometer_SensorJsTest012 off in---------------------------');
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, callback2);
console.info('----------------------Barometer_SensorJsTest012 off end---------------------------');
done();
}, 1000);
})
} catch (error) {
console.info('Barometer_SensorJsTest012 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number: SUB_SensorsSystem_BAROMETER_JSTest_0130
* @tc.name:Barometer_SensorJsTest013
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("Barometer_SensorJsTest013", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------Barometer_SensorJsTest013---------------------------');
try{
sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER,(error, data) => {
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, callback, { 'interval': 100000000 });
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, callback2, { 'interval': 100000000 });
setTimeout(() => {
console.info('----------------------Barometer_SensorJsTest013 off in---------------------------');
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER);
console.info('----------------------Barometer_SensorJsTest013 off end---------------------------');
done();
}, 1000);
})
} catch (error) {
console.info('Barometer_SensorJsTest013 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
......
......@@ -65,8 +65,11 @@ describe("SensorJsTest_sensor_9", function () {
console.info('afterEach caled')
})
const PARAMETER_ERROR_CODE = 401
const PARAMETER_ERROR_MSG = 'The parameter invalid.'
const SERVICE_EXCEPTION_CODE = 14500101
const SERVICE_EXCEPTION_MSG = 'Service exception.'
let errMessages = ['string is not defined','The parameter invalid'];
let errMessage;
/*
......@@ -76,20 +79,31 @@ describe("SensorJsTest_sensor_9", function () {
*/
it("Gravity_SensorJsTest001", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
console.info('----------------------Gravity_SensorJsTest001---------------------------');
try{
sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY,(error, data) => {
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback);
setTimeout(() => {
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY);
done();
}, 500);
})
} catch (error) {
console.info('Gravity_SensorJsTest001 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number: SUB_SensorsSystem_GRAVITY_JsTest_0020
* @tc.number: SUB_SensorsSystem_GRAVITY_JSTest_0020
* @tc.name: Gravity_SensorJsTest002
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("Gravity_SensorJsTest002", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------Gravity_SensorJsTest002---------------------------');
try{
sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY,(error, data) => {
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback, { 'interval': 100000000 });
setTimeout(() => {
console.info('----------------------Gravity_SensorJsTest002 off in---------------------------');
......@@ -98,9 +112,16 @@ describe("SensorJsTest_sensor_9", function () {
done();
}, 500);
})
} catch (error) {
console.info('Gravity_SensorJsTest002 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number: SUB_SensorsSystem_GRAVITY_JsTest_0030
* @tc.number: SUB_SensorsSystem_GRAVITY_JSTest_0030
* @tc.name: Gravity_SensorJsTest003
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
......@@ -114,31 +135,43 @@ describe("SensorJsTest_sensor_9", function () {
expect(typeof (data.timestamp)).assertEqual("number");
done();
}
try {
try{
sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY,(error, data) => {
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, onSensorCallback, { 'interval': 100000000 }, 5);
})
} catch (error) {
console.info("Gravity_SensorJsTest003 error:" + error);
console.info('Gravity_SensorJsTest003 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number: SUB_SensorsSystem_GRAVITY_JsTest_0040
* @tc.number: SUB_SensorsSystem_GRAVITY_JSTest_0040
* @tc.name: Gravity_SensorJsTest004
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("Gravity_SensorJsTest004", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------Gravity_SensorJsTest004---------------------------');
try{
sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY,(error, data) => {
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback);
setTimeout(() => {
expect(true).assertTrue();
done();
}, 500);
})
} catch (error) {
console.info('Gravity_SensorJsTest004 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number: SUB_SensorsSystem_GRAVITY_JsTest_0050
* @tc.number: SUB_SensorsSystem_GRAVITY_JSTest_0050
* @tc.name: Gravity_SensorJsTest005
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
......@@ -152,23 +185,33 @@ describe("SensorJsTest_sensor_9", function () {
expect(typeof (data.timestamp)).assertEqual("number");
done();
}
try{
sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY,(error, data) => {
try {
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, onceSensorCallback, 5);
} catch (error) {
console.info("Gravity_SensorJsTest005 error:" + error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
}
})
} catch (error) {
console.info('Gravity_SensorJsTest005 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number: SUB_SensorsSystem_GRAVITY_JsTest_0060
* @tc.number: SUB_SensorsSystem_GRAVITY_JSTest_0060
* @tc.name: Gravity_SensorJsTest006
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("Gravity_SensorJsTest006", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------Gravity_SensorJsTest006---------------------------');
try{
sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY,(error, data) => {
try {
sensor.off(string, "");
} catch (error) {
......@@ -178,9 +221,16 @@ describe("SensorJsTest_sensor_9", function () {
done();
}
})
} catch (error) {
console.info('Gravity_SensorJsTest006 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number: SUB_SensorsSystem_GRAVITY_JsTest_0070
* @tc.number: SUB_SensorsSystem_GRAVITY_JSTest_0070
* @tc.name: Gravity_SensorJsTest007
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
......@@ -191,6 +241,8 @@ describe("SensorJsTest_sensor_9", function () {
expect(false).assertTrue();
done();
}
try{
sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY,(error, data) => {
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, onSensorCallback);
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, onSensorCallback);
setTimeout(() => {
......@@ -198,9 +250,16 @@ describe("SensorJsTest_sensor_9", function () {
done();
}, 500);
})
} catch (error) {
console.info('Gravity_SensorJsTest007 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number: SUB_SensorsSystem_GRAVITY_JsTest_0080
* @tc.number: SUB_SensorsSystem_GRAVITY_JSTest_0080
* @tc.name: Gravity_SensorJsTest008
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
......@@ -210,6 +269,8 @@ describe("SensorJsTest_sensor_9", function () {
console.info('Gravity_SensorJsTest008 on error');
expect(false).assertTrue();
}
try{
sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY,(error, data) => {
try {
sensor.off(1000000, onSensorCallback);
} catch (error) {
......@@ -219,14 +280,23 @@ describe("SensorJsTest_sensor_9", function () {
done();
}
})
} catch (error) {
console.info('Gravity_SensorJsTest008 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number: SUB_SensorsSystem_GRAVITY_JsTest_0090
* @tc.number: SUB_SensorsSystem_GRAVITY_JSTest_0090
* @tc.name: Gravity_SensorJsTest009
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("Gravity_SensorJsTest009", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------Gravity_SensorJsTest009---------------------------');
try{
sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY,(error, data) => {
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback);
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback2);
setTimeout(() => {
......@@ -236,14 +306,23 @@ describe("SensorJsTest_sensor_9", function () {
done();
}, 1000);
})
} catch (error) {
console.info('Gravity_SensorJsTest009 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number: SUB_SensorsSystem_GRAVITY_JsTest_0100
* @tc.number: SUB_SensorsSystem_GRAVITY_JSTest_0100
* @tc.name: Gravity_SensorJsTest010
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("Gravity_SensorJsTest010", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------Gravity_SensorJsTest010---------------------------');
try{
sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY,(error, data) => {
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback);
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback2);
setTimeout(() => {
......@@ -262,14 +341,23 @@ describe("SensorJsTest_sensor_9", function () {
done();
}, 1000);
})
} catch (error) {
console.info('Gravity_SensorJsTest010 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number: SUB_SensorsSystem_GRAVITY_JsTest_0110
* @tc.number: SUB_SensorsSystem_GRAVITY_JSTest_0110
* @tc.name: Gravity_SensorJsTest011
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("Gravity_SensorJsTest011", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------Gravity_SensorJsTest011---------------------------');
try{
sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY,(error, data) => {
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback, { 'interval': 100000000 });
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback2);
setTimeout(() => {
......@@ -279,14 +367,23 @@ describe("SensorJsTest_sensor_9", function () {
done();
}, 1000);
})
} catch (error) {
console.info('Gravity_SensorJsTest011 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number: SUB_SensorsSystem_GRAVITY_JsTest_0120
* @tc.name: Gravity_SensorJsTest012
* @tc.number: SUB_SensorsSystem_GRAVITY_JSTest_0120
* @tc.name:Gravity_SensorJsTest012
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("Gravity_SensorJsTest012", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------Gravity_SensorJsTest012---------------------------');
try{
sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY,(error, data) => {
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback, { 'interval': 100000000 });
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback2, { 'interval': 100000000 });
setTimeout(() => {
......@@ -306,14 +403,23 @@ describe("SensorJsTest_sensor_9", function () {
done();
}, 1000);
})
} catch (error) {
console.info('Gravity_SensorJsTest012 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number: SUB_SensorsSystem_GRAVITY_JsTest_0130
* @tc.name: Gravity_SensorJsTest013
* @tc.number: SUB_SensorsSystem_GRAVITY_JSTest_0130
* @tc.name:Gravity_SensorJsTest013
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("Gravity_SensorJsTest013", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------Gravity_SensorJsTest013---------------------------');
try{
sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY,(error, data) => {
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback, { 'interval': 100000000 });
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback2, { 'interval': 100000000 });
setTimeout(() => {
......@@ -323,4 +429,11 @@ describe("SensorJsTest_sensor_9", function () {
done();
}, 1000);
})
} catch (error) {
console.info('Gravity_SensorJsTest013 Device does not support! ');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
})}
......@@ -31,7 +31,7 @@ _all_test_packages = [
"${ACTS_ROOT}/inputmethod:inputmethod",
"${ACTS_ROOT}/powermgr:powermgr",
"${ACTS_ROOT}/startup:startup",
"${ACTS_ROOT}/sensors:sensor",
"${ACTS_ROOT}/sensors:sensors",
"${ACTS_ROOT}/distributeddatamgr:pasteboard",
"${ACTS_ROOT}/distributeddatamgr:distributeddatamgr",
"${ACTS_ROOT}/graphic:graphic",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册