提交 ac258bd9 编写于 作者: L lidanyang16

<lidanyang16@huawei.com>

Signed-off-by: Nlidanyang16 <lidanyang16@huawei.com>
上级 f6a8aa49
...@@ -48,7 +48,10 @@ describe("VibratorJsTest", function () { ...@@ -48,7 +48,10 @@ describe("VibratorJsTest", function () {
console.info('afterEach caled') console.info('afterEach caled')
}) })
var errMessages = ['Param number is invalid', 'Wrong argument type. function expected', 'Wrong argument type', 'Wrong argument number'] let errMessages = ['Param number is invalid', 'Wrong argument type. function expected',
'Wrong argument type', 'Wrong argument number']
let errMessage;
/* /*
* @tc.name:VibratorJsTest0001 * @tc.name:VibratorJsTest0001
...@@ -62,7 +65,6 @@ describe("VibratorJsTest", function () { ...@@ -62,7 +65,6 @@ describe("VibratorJsTest", function () {
mode: 'long', mode: 'long',
success: function () { success: function () {
console.info("VibratorJsTest0001 success"); console.info("VibratorJsTest0001 success");
expect(true).assertTrue();
done(); done();
}, },
fail: function (data, code) { fail: function (data, code) {
...@@ -87,7 +89,6 @@ describe("VibratorJsTest", function () { ...@@ -87,7 +89,6 @@ describe("VibratorJsTest", function () {
mode: 'short', mode: 'short',
success: function () { success: function () {
console.info("VibratorJsTest0002 success"); console.info("VibratorJsTest0002 success");
expect(true).assertTrue();
done(); done();
}, },
fail: function (data, code) { fail: function (data, code) {
...@@ -112,7 +113,6 @@ describe("VibratorJsTest", function () { ...@@ -112,7 +113,6 @@ describe("VibratorJsTest", function () {
mode: 'short', mode: 'short',
success: function () { success: function () {
console.info("VibratorJsTest0003 success"); console.info("VibratorJsTest0003 success");
expect(true).assertTrue();
done(); done();
}, },
fail: function (data, code) { fail: function (data, code) {
...@@ -134,7 +134,6 @@ describe("VibratorJsTest", function () { ...@@ -134,7 +134,6 @@ describe("VibratorJsTest", function () {
mode: 'short', mode: 'short',
success: function () { success: function () {
console.info("VibratorJsTest0004 success"); console.info("VibratorJsTest0004 success");
expect(true).assertTrue();
done(); done();
}, },
}); });
...@@ -151,7 +150,6 @@ describe("VibratorJsTest", function () { ...@@ -151,7 +150,6 @@ describe("VibratorJsTest", function () {
vibrator.vibrate({ vibrator.vibrate({
success: function () { success: function () {
console.info("VibratorJsTest0005 success"); console.info("VibratorJsTest0005 success");
expect(true).assertTrue();
done(); done();
}, },
fail: function (data, code) { fail: function (data, code) {
...@@ -174,7 +172,6 @@ describe("VibratorJsTest", function () { ...@@ -174,7 +172,6 @@ describe("VibratorJsTest", function () {
inInvalid: 2, inInvalid: 2,
success: function () { success: function () {
console.info("VibratorJsTest0006 success"); console.info("VibratorJsTest0006 success");
expect(true).assertTrue();
done(); done();
}, },
fail: function (data, code) { fail: function (data, code) {
...@@ -202,7 +199,7 @@ describe("VibratorJsTest", function () { ...@@ -202,7 +199,7 @@ describe("VibratorJsTest", function () {
}, },
}, 25); }, 25);
} catch (error) { } catch (error) {
var errMessage = error.toString().slice(39); errMessage = error.toString().slice(39);
console.info('VibratorJsTest0007 error:' + error); console.info('VibratorJsTest0007 error:' + error);
expect(errMessage).assertEqual(errMessages[0]); expect(errMessage).assertEqual(errMessages[0]);
done(); done();
...@@ -221,26 +218,22 @@ describe("VibratorJsTest", function () { ...@@ -221,26 +218,22 @@ describe("VibratorJsTest", function () {
mode: 'short', mode: 'short',
success: function () { success: function () {
console.info("VibratorJsTest0008 success"); console.info("VibratorJsTest0008 success");
expect(true).assertTrue();
}, },
fail: function (data, code) { fail: function (data, code) {
console.error('VibratorJsTest0008 failed. Code: ' + code + '; Data: ' + data); console.error('VibratorJsTest0008 failed. Code: ' + code + '; Data: ' + data);
expect(false).assertTrue(); expect(false).assertTrue();
}, },
}); });
vibrator.vibrate({ vibrator.vibrate({
mode: 'short', mode: 'short',
success: function () { success: function () {
console.info("VibratorJsTest0008_1 success"); console.info("VibratorJsTest0008_1 success");
expect(true).assertTrue();
}, },
fail: function (data, code) { fail: function (data, code) {
console.error('VibratorJsTest0008_1 failed. Code: ' + code + '; Data: ' + data); console.error('VibratorJsTest0008_1 failed. Code: ' + code + '; Data: ' + data);
expect(false).assertTrue(); expect(false).assertTrue();
}, },
}); });
setTimeout(() => { setTimeout(() => {
done(); done();
}, 500); }, 500);
...@@ -258,7 +251,7 @@ describe("VibratorJsTest", function () { ...@@ -258,7 +251,7 @@ describe("VibratorJsTest", function () {
vibrator.vibrate('xxx', done); vibrator.vibrate('xxx', done);
} catch (error) { } catch (error) {
console.info('VibratorJsTest0009 error:' + error); console.info('VibratorJsTest0009 error:' + error);
var errMessage = error.toString().slice(68); errMessage = error.toString().slice(68);
expect(errMessage).assertEqual(errMessages[1]); expect(errMessage).assertEqual(errMessages[1]);
done(); done();
} }
...@@ -275,7 +268,7 @@ describe("VibratorJsTest", function () { ...@@ -275,7 +268,7 @@ describe("VibratorJsTest", function () {
try { try {
vibrator.vibrate(done); vibrator.vibrate(done);
} catch (error) { } catch (error) {
var errMessage = error.toString().slice(7); errMessage = error.toString().slice(7);
console.info('VibratorJsTest0010 error:' + error); console.info('VibratorJsTest0010 error:' + error);
expect(errMessage).assertEqual(errMessages[2]); expect(errMessage).assertEqual(errMessages[2]);
done(); done();
...@@ -301,7 +294,7 @@ describe("VibratorJsTest", function () { ...@@ -301,7 +294,7 @@ describe("VibratorJsTest", function () {
}, function () { }, function () {
}, 25); }, 25);
} catch (error) { } catch (error) {
var errMessage = error.toString().slice(39); errMessage = error.toString().slice(39);
console.info('VibratorJsTest0011 error:' + error); console.info('VibratorJsTest0011 error:' + error);
expect(errMessage).assertEqual(errMessages[3]); expect(errMessage).assertEqual(errMessages[3]);
done(); done();
......
/*
* 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 sensor from '@ohos.sensor'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'
describe("SensorJsTest", function () {
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')
})
/*
* @tc.number: SUB_SensorsSystem_Hall_JSTest_0010
* @tc.name: SensorHallJSTest001
* @tc.desc:verify app info is not null
*/
it("SUB_SensorsSystem_Hall_JSTest_0010", 0, async function (done) {
console.info('----------------------SUB_SensorsSystem_Hall_JSTest_0010---------------------------');
function offPromise() {
return new Promise((resolve, reject) => {
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_HALL, (error) => {
if (error) {
console.info('SensorHallJSTest001 off error');
expect(false).assertTrue();
console.info('setTimeout ..start')
setTimeout((err) => {
reject(err);
}, 500);
} else {
console.info('SensorHallJSTest001 off success');
expect(true).assertTrue();
setTimeout(() => {
resolve();
}, 500);
}
}, 1000)
})
}
let promise = new Promise((resolve, reject) => {
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HALL, function (error, data) {
if (error) {
console.info('SensorHallJSTest001 on error');
expect(false).assertTrue();
setTimeout((err) => {
reject(err);
}, 500);
} else {
console.info('SensorHallJSTest001 on success status: ' + data.status);
expect(typeof (data.status)).assertEqual("number");
setTimeout(() => {
resolve();
}, 500);
}
});
})
await promise.then(() => {
return offPromise();
}, () => {
console.info("SensorHallJSTest001 reject");
})
done();
})
/*
* @tc.number: SUB_SensorsSystem_Hall_JSTest_0050
* @tc.name: SensorHallJSTest005
* @tc.desc:verify app info is not null
*/
it("SUB_SensorsSystem_Hall_JSTest_0050", 0, async function (done) {
function onceSensorCallback(error, data) {
if (error) {
console.info('SensorHallJSTest005 once error');
expect(false).assertTrue();
} else {
console.info('SensorHallJSTest005 once success status: ' + data.status);
expect(typeof (data.status)).assertEqual("number");
}
setTimeout(() => {
done();
}, 500);
}
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HALL, onceSensorCallback);
})
})
...@@ -31,7 +31,7 @@ describe("SensorJsTest", function () { ...@@ -31,7 +31,7 @@ describe("SensorJsTest", function () {
} }
beforeAll(function () { beforeAll(function () {
/* /*
* @tc.setup: setup invoked before all testcases * @tc.setup: setup invoked before all testcases
*/ */
...@@ -64,6 +64,7 @@ describe("SensorJsTest", function () { ...@@ -64,6 +64,7 @@ describe("SensorJsTest", function () {
let errMessages = ['The number of parameters is not valid', 'Should subscribe first', let errMessages = ['The number of parameters is not valid', 'Should subscribe first',
'string is not defined']; 'string is not defined'];
let errMessage; let errMessage;
/* /*
...@@ -106,13 +107,11 @@ describe("SensorJsTest", function () { ...@@ -106,13 +107,11 @@ describe("SensorJsTest", function () {
*/ */
it("Accelerometer_SensorJsTest003", 0, async function (done) { it("Accelerometer_SensorJsTest003", 0, async function (done) {
console.info('----------------------Accelerometer_SensorJsTest003---------------------------'); console.info('----------------------Accelerometer_SensorJsTest003---------------------------');
function onSensorCallback(data) { function onSensorCallback(data) {
console.info('Accelerometer_SensorJsTest003 on error'); console.info('Accelerometer_SensorJsTest003 on error');
expect(false).assertTrue(); expect(false).assertTrue();
done(); done();
} }
try { try {
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, onSensorCallback, { 'interval': 100000000 }, 5); sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, onSensorCallback, { 'interval': 100000000 }, 5);
} catch (error) { } catch (error) {
...@@ -146,13 +145,11 @@ describe("SensorJsTest", function () { ...@@ -146,13 +145,11 @@ describe("SensorJsTest", function () {
*/ */
it("Accelerometer_SensorJsTest005", 0, async function (done) { it("Accelerometer_SensorJsTest005", 0, async function (done) {
console.info('----------------------Accelerometer_SensorJsTest005---------------------------'); console.info('----------------------Accelerometer_SensorJsTest005---------------------------');
function onceSensorCallback(data) { function onceSensorCallback(data) {
console.info('Accelerometer_SensorJsTest005 on error'); console.info('Accelerometer_SensorJsTest005 on error');
expect(false).assertTrue(); expect(false).assertTrue();
done(); done();
} }
try { try {
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, onceSensorCallback, 5); sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, onceSensorCallback, 5);
} catch (error) { } catch (error) {
...@@ -189,13 +186,11 @@ describe("SensorJsTest", function () { ...@@ -189,13 +186,11 @@ describe("SensorJsTest", function () {
*/ */
it("Accelerometer_SensorJsTest007", 0, async function (done) { it("Accelerometer_SensorJsTest007", 0, async function (done) {
console.info('----------------------Accelerometer_SensorJsTest007---------------------------'); console.info('----------------------Accelerometer_SensorJsTest007---------------------------');
function onSensorCallback(data) { function onSensorCallback(data) {
console.info('Accelerometer_SensorJsTest007 on error'); console.info('Accelerometer_SensorJsTest007 on error');
expect(false).assertTrue(); expect(false).assertTrue();
done(); done();
} }
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, onSensorCallback); sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, onSensorCallback);
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, onSensorCallback); sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, onSensorCallback);
setTimeout(() => { setTimeout(() => {
...@@ -212,13 +207,11 @@ describe("SensorJsTest", function () { ...@@ -212,13 +207,11 @@ describe("SensorJsTest", function () {
*/ */
it("Accelerometer_SensorJsTest008", 0, async function (done) { it("Accelerometer_SensorJsTest008", 0, async function (done) {
console.info('----------------------Accelerometer_SensorJsTest008---------------------------'); console.info('----------------------Accelerometer_SensorJsTest008---------------------------');
function onSensorCallback(data) { function onSensorCallback(data) {
console.info('Accelerometer_SensorJsTest008 on error'); console.info('Accelerometer_SensorJsTest008 on error');
expect(false).assertTrue(); expect(false).assertTrue();
done(); done();
} }
try { try {
sensor.off(1000000, onSensorCallback); sensor.off(1000000, onSensorCallback);
} catch (error) { } catch (error) {
......
/*
* 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 sensor from '@ohos.sensor'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'
describe("SensorJsTest", function () {
function callback(data) {
console.info("callback" + JSON.stringify(data));
expect(typeof (data.intensity)).assertEqual("number");
}
function callback2(data) {
console.info("callback2" + JSON.stringify(data));
expect(typeof (data.intensity)).assertEqual("number");
}
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')
})
let errMessages = ['The number of parameters is not valid', 'Should subscribe first',
'string is not defined'];
let errMessage;
/*
* @tc.name:Ambient_Light_SensorJsTest001
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it("Ambient_Light_SensorJsTest001", 0, async function (done) {
console.info('----------------------Ambient_Light_SensorJsTest001---------------------------');
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback);
setTimeout(() => {
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT);
done();
}, 1500);
})
/*
* @tc.name:Ambient_Light_SensorJsTest002
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it("Ambient_Light_SensorJsTest002", 0, async function (done) {
console.info('----------------------Ambient_Light_SensorJsTest002---------------------------');
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback, { 'interval': 100000000 });
setTimeout(() => {
console.info('----------------------Ambient_Light_SensorJsTest002 off in---------------------------');
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT);
console.info('----------------------Ambient_Light_SensorJsTest002 off end---------------------------');
done();
}, 1500);
})
/*
* @tc.name:Ambient_Light_SensorJsTest003
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it("Ambient_Light_SensorJsTest003", 0, async function (done) {
console.info('----------------------Ambient_Light_SensorJsTest003---------------------------');
function onSensorCallback(data) {
console.info('Ambient_Light_SensorJsTest003 on error');
expect(false).assertTrue();
done();
}
try {
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, onSensorCallback, { 'interval': 100000000 }, 5);
} catch (error) {
console.info("Ambient_Light_SensorJsTest003 error:" + error);
errMessage = error.toString().slice(12, 49);
console.info('Ambient_Light_SensorJsTest003 errMessage:' + errMessage);
expect(errMessage).assertEqual(errMessages[0]);
done();
}
})
/*
* @tc.name:Ambient_Light_SensorJsTest004
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it("Ambient_Light_SensorJsTest004", 0, async function (done) {
console.info('----------------------Ambient_Light_SensorJsTest004---------------------------');
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback);
setTimeout(() => {
expect(true).assertTrue();
done();
}, 500);
})
/*
* @tc.name:Ambient_Light_SensorJsTest005
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it("Ambient_Light_SensorJsTest005", 0, async function (done) {
console.info('----------------------Ambient_Light_SensorJsTest005---------------------------');
function onceSensorCallback(data) {
console.info('Ambient_Light_SensorJsTest005 on error');
expect(false).assertTrue();
done();
}
try {
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, onceSensorCallback, 5);
} catch (error) {
console.info("Ambient_Light_SensorJsTest005 error:" + error);
errMessage = error.toString().slice(14, 51);
console.info('Ambient_Light_SensorJsTest005 errMessage:' + errMessage);
expect(errMessage).assertEqual(errMessages[0]);
done();
}
})
/*
* @tc.name:Ambient_Light_SensorJsTest006
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it("Ambient_Light_SensorJsTest006", 0, async function (done) {
console.info('----------------------Ambient_Light_SensorJsTest006---------------------------');
try {
sensor.off(string, "");
} catch (error) {
console.info("Ambient_Light_SensorJsTest006 error:" + error);
errMessage = error.toString().slice(16, 40);
console.info('Ambient_Light_SensorJsTest006 errMessage:' + errMessage);
expect(errMessage).assertEqual(errMessages[2]);
done();
}
})
/*
* @tc.name:Ambient_Light_SensorJsTest007
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it("Ambient_Light_SensorJsTest007", 0, async function (done) {
console.info('----------------------Ambient_Light_SensorJsTest007---------------------------');
function onSensorCallback(data) {
console.info('Ambient_Light_SensorJsTest007 on error');
expect(false).assertTrue();
done();
}
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, onSensorCallback);
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, onSensorCallback);
setTimeout(() => {
expect(true).assertTrue();
done();
}, 500);
})
/*
* @tc.name:Ambient_Light_SensorJsTest008
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it("Ambient_Light_SensorJsTest008", 0, async function (done) {
console.info('----------------------Ambient_Light_SensorJsTest008---------------------------');
function onSensorCallback(data) {
console.info('Ambient_Light_SensorJsTest008 on error');
expect(false).assertTrue();
done();
}
try {
sensor.off(1000000, onSensorCallback);
} catch (error) {
console.info("Ambient_Light_SensorJsTest008 error:" + error);
errMessage = error.toString().slice(13, 35);
console.info('Ambient_Light_SensorJsTest008 errMessage:' + errMessage);
expect(errMessage).assertEqual(errMessages[1]);
done();
}
})
/*
* @tc.name:Ambient_Light_SensorJsTest009
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it("Ambient_Light_SensorJsTest009", 0, async function (done) {
console.info('----------------------Ambient_Light_SensorJsTest009---------------------------');
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback);
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback2);
setTimeout(() => {
console.info('----------------------Ambient_Light_SensorJsTest009 off in---------------------------');
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT);
console.info('----------------------Ambient_Light_SensorJsTest009 off end---------------------------');
done();
}, 2000);
})
/*
* @tc.name:Ambient_Light_SensorJsTest010
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it("Ambient_Light_SensorJsTest010", 0, async function (done) {
console.info('----------------------Ambient_Light_SensorJsTest010---------------------------');
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback);
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback2);
setTimeout(() => {
console.info('----------------------Ambient_Light_SensorJsTest010 off in---------------------------');
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback);
console.info('----------------------Ambient_Light_SensorJsTest010 off end---------------------------');
}, 1000);
setTimeout(() => {
console.info('----------------------Ambient_Light_SensorJsTest010 off in---------------------------');
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback2);
console.info('----------------------Ambient_Light_SensorJsTest010 off end---------------------------');
done();
}, 2000);
})
/*
* @tc.name:Ambient_Light_SensorJsTest011
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it("Ambient_Light_SensorJsTest011", 0, async function (done) {
console.info('----------------------Ambient_Light_SensorJsTest011---------------------------');
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback, { 'interval': 100000000 });
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback2);
setTimeout(() => {
console.info('----------------------Ambient_Light_SensorJsTest011 off in---------------------------');
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT);
console.info('----------------------Ambient_Light_SensorJsTest011 off end---------------------------');
done();
}, 1000);
})
/*
* @tc.name:Ambient_Light_SensorJsTest012
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it("Ambient_Light_SensorJsTest012", 0, async function (done) {
console.info('----------------------Ambient_Light_SensorJsTest012---------------------------');
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(() => {
console.info('----------------------Ambient_Light_SensorJsTest012 off in---------------------------');
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback);
console.info('----------------------Ambient_Light_SensorJsTest012 off end---------------------------');
}, 500);
setTimeout(() => {
console.info('----------------------Ambient_Light_SensorJsTest012 off in---------------------------');
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback2);
console.info('----------------------Ambient_Light_SensorJsTest012 off end---------------------------');
done();
}, 1000);
})
/*
* @tc.name:Ambient_Light_SensorJsTest013
* @tc.desc:verify app info is not null
* @tc.type: FUNC
* @tc.require: Issue Number
*/
it("Ambient_Light_SensorJsTest013", 0, async function (done) {
console.info('----------------------Ambient_Light_SensorJsTest013---------------------------');
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(() => {
console.info('----------------------Ambient_Light_SensorJsTest013 off in---------------------------');
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT);
console.info('----------------------Ambient_Light_SensorJsTest013 off end---------------------------');
done();
}, 1000);
})
})
\ No newline at end of file
...@@ -64,6 +64,7 @@ describe("SensorJsTest", function () { ...@@ -64,6 +64,7 @@ describe("SensorJsTest", function () {
let errMessages = ['The number of parameters is not valid', 'Should subscribe first', let errMessages = ['The number of parameters is not valid', 'Should subscribe first',
'string is not defined']; 'string is not defined'];
let errMessage; let errMessage;
/* /*
...@@ -106,13 +107,11 @@ describe("SensorJsTest", function () { ...@@ -106,13 +107,11 @@ describe("SensorJsTest", function () {
*/ */
it("GYROSCOPE_SensorJsTest003", 0, async function (done) { it("GYROSCOPE_SensorJsTest003", 0, async function (done) {
console.info('----------------------GYROSCOPE_SensorJsTest003---------------------------'); console.info('----------------------GYROSCOPE_SensorJsTest003---------------------------');
function onSensorCallback(data) { function onSensorCallback(data) {
console.info('GYROSCOPE_SensorJsTest003 on error'); console.info('GYROSCOPE_SensorJsTest003 on error');
expect(false).assertTrue(); expect(false).assertTrue();
done(); done();
} }
try { try {
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, onSensorCallback, { 'interval': 100000000 }, 5); sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, onSensorCallback, { 'interval': 100000000 }, 5);
} catch (error) { } catch (error) {
...@@ -146,13 +145,11 @@ describe("SensorJsTest", function () { ...@@ -146,13 +145,11 @@ describe("SensorJsTest", function () {
*/ */
it("GYROSCOPE_SensorJsTest005", 0, async function (done) { it("GYROSCOPE_SensorJsTest005", 0, async function (done) {
console.info('----------------------GYROSCOPE_SensorJsTest005---------------------------'); console.info('----------------------GYROSCOPE_SensorJsTest005---------------------------');
function onceSensorCallback(data) { function onceSensorCallback(data) {
console.info('GYROSCOPE_SensorJsTest005 on error'); console.info('GYROSCOPE_SensorJsTest005 on error');
expect(false).assertTrue(); expect(false).assertTrue();
done(); done();
} }
try { try {
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, onceSensorCallback, 5); sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, onceSensorCallback, 5);
} catch (error) { } catch (error) {
......
...@@ -60,6 +60,7 @@ describe("SensorJsTest", function () { ...@@ -60,6 +60,7 @@ describe("SensorJsTest", function () {
let errMessages = ['The number of parameters is not valid', 'Should subscribe first', let errMessages = ['The number of parameters is not valid', 'Should subscribe first',
'string is not defined']; 'string is not defined'];
let errMessage; let errMessage;
/* /*
...@@ -102,13 +103,11 @@ describe("SensorJsTest", function () { ...@@ -102,13 +103,11 @@ describe("SensorJsTest", function () {
*/ */
it("Hall_SensorJsTest003", 0, async function (done) { it("Hall_SensorJsTest003", 0, async function (done) {
console.info('----------------------Hall_SensorJsTest003---------------------------'); console.info('----------------------Hall_SensorJsTest003---------------------------');
function onSensorCallback(data) { function onSensorCallback(data) {
console.info('Hall_SensorJsTest003 on error'); console.info('Hall_SensorJsTest003 on error');
expect(false).assertTrue(); expect(false).assertTrue();
done(); done();
} }
try { try {
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HALL, onSensorCallback, { 'interval': 100000000 }, 5); sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HALL, onSensorCallback, { 'interval': 100000000 }, 5);
} catch (error) { } catch (error) {
...@@ -204,7 +203,6 @@ describe("SensorJsTest", function () { ...@@ -204,7 +203,6 @@ describe("SensorJsTest", function () {
expect(false).assertTrue(); expect(false).assertTrue();
done(); done();
} }
try { try {
sensor.off(1000000, onSensorCallback); sensor.off(1000000, onSensorCallback);
} catch (error) { } catch (error) {
......
...@@ -50,6 +50,7 @@ describe("SensorJsTest", function () { ...@@ -50,6 +50,7 @@ describe("SensorJsTest", function () {
let errMessages = ['The number of parameters is not valid', 'Wrong argument type, function expected', let errMessages = ['The number of parameters is not valid', 'Wrong argument type, function expected',
'Wrong argument type, should be object'] 'Wrong argument type, should be object']
let errMessage; let errMessage;
/* /*
......
...@@ -16,7 +16,7 @@ import sensor from '@system.sensor' ...@@ -16,7 +16,7 @@ import sensor from '@system.sensor'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'
describe("SensorJsTest", function () { describe("SensorJsTest", function () {
beforeAll(function () { beforeAll(function () {
/* /*
* @tc.setup: setup invoked before all testcases * @tc.setup: setup invoked before all testcases
...@@ -48,7 +48,10 @@ describe("SensorJsTest", function () { ...@@ -48,7 +48,10 @@ describe("SensorJsTest", function () {
console.info('afterEach caled') console.info('afterEach caled')
}) })
var errMessages = ['The number of parameters is not valid', 'Wrong argument type, should be object', 'UnsubscribeSensor failed']; let errMessages = ['The number of parameters is not valid', 'Wrong argument type, should be object',
'UnsubscribeSensor failed'];
let errMessage;
/* /*
* @tc.name:subscribeAccelerometer_SensorJsTest001 * @tc.name:subscribeAccelerometer_SensorJsTest001
...@@ -71,7 +74,6 @@ describe("SensorJsTest", function () { ...@@ -71,7 +74,6 @@ describe("SensorJsTest", function () {
expect(false).assertTrue(); expect(false).assertTrue();
}, },
}); });
setTimeout(() => { setTimeout(() => {
try { try {
sensor.unsubscribeAccelerometer(); sensor.unsubscribeAccelerometer();
...@@ -107,7 +109,6 @@ describe("SensorJsTest", function () { ...@@ -107,7 +109,6 @@ describe("SensorJsTest", function () {
expect(false).assertTrue(); expect(false).assertTrue();
}, },
}); });
setTimeout(() => { setTimeout(() => {
try { try {
sensor.unsubscribeAccelerometer(); sensor.unsubscribeAccelerometer();
...@@ -181,7 +182,7 @@ describe("SensorJsTest", function () { ...@@ -181,7 +182,7 @@ describe("SensorJsTest", function () {
}, },
}, 25); }, 25);
} catch (error) { } catch (error) {
var errMessage = error.toString().slice(19, 56); errMessage = error.toString().slice(19, 56);
console.info('subscribeAccelerometer_SensorJsTest004 error:' + error); console.info('subscribeAccelerometer_SensorJsTest004 error:' + error);
expect(errMessage).assertEqual(errMessages[0]); expect(errMessage).assertEqual(errMessages[0]);
done(); done();
...@@ -212,7 +213,7 @@ describe("SensorJsTest", function () { ...@@ -212,7 +213,7 @@ describe("SensorJsTest", function () {
}, function () { }, function () {
}, 25); }, 25);
} catch (error) { } catch (error) {
var errMessage = error.toString().slice(19, 56); errMessage = error.toString().slice(19, 56);
console.info('subscribeAccelerometer_SensorJsTest005 error:' + error); console.info('subscribeAccelerometer_SensorJsTest005 error:' + error);
expect(errMessage).assertEqual(errMessages[0]); expect(errMessage).assertEqual(errMessages[0]);
done(); done();
...@@ -280,7 +281,7 @@ describe("SensorJsTest", function () { ...@@ -280,7 +281,7 @@ describe("SensorJsTest", function () {
try { try {
sensor.subscribeAccelerometer(); sensor.subscribeAccelerometer();
} catch (error) { } catch (error) {
var errMessage = error.toString().slice(19, 56); errMessage = error.toString().slice(19, 56);
console.info('subscribeAccelerometer_SensorJsTest007 error:' + error); console.info('subscribeAccelerometer_SensorJsTest007 error:' + error);
expect(errMessage).assertEqual(errMessages[0]); expect(errMessage).assertEqual(errMessages[0]);
done(); done();
...@@ -298,7 +299,7 @@ describe("SensorJsTest", function () { ...@@ -298,7 +299,7 @@ describe("SensorJsTest", function () {
try { try {
sensor.subscribeAccelerometer('xxx'); sensor.subscribeAccelerometer('xxx');
} catch (error) { } catch (error) {
var errMessage = error.toString().slice(19, 56); errMessage = error.toString().slice(19, 56);
console.info('subscribeAccelerometer_SensorJsTest008 error:' + error); console.info('subscribeAccelerometer_SensorJsTest008 error:' + error);
expect(errMessage).assertEqual(errMessages[1]); expect(errMessage).assertEqual(errMessages[1]);
done(); done();
...@@ -316,7 +317,7 @@ describe("SensorJsTest", function () { ...@@ -316,7 +317,7 @@ describe("SensorJsTest", function () {
try { try {
sensor.unsubscribeAccelerometer('xxx'); sensor.unsubscribeAccelerometer('xxx');
} catch (error) { } catch (error) {
var errMessage = error.toString().slice(21, 58); errMessage = error.toString().slice(21, 58);
console.info('subscribeAccelerometer_SensorJsTest009 error:' + error); console.info('subscribeAccelerometer_SensorJsTest009 error:' + error);
expect(errMessage).assertEqual(errMessages[0]); expect(errMessage).assertEqual(errMessages[0]);
done(); done();
...@@ -358,7 +359,7 @@ describe("SensorJsTest", function () { ...@@ -358,7 +359,7 @@ describe("SensorJsTest", function () {
try { try {
sensor.unsubscribeAccelerometer(); sensor.unsubscribeAccelerometer();
} catch (error) { } catch (error) {
var errMessage = error.toString().slice(21, 45); errMessage = error.toString().slice(21, 45);
console.info('subscribeAccelerometer_SensorJsTest011 error:' + error); console.info('subscribeAccelerometer_SensorJsTest011 error:' + error);
expect(errMessage).assertEqual(errMessages[2]); expect(errMessage).assertEqual(errMessages[2]);
done(); done();
...@@ -430,12 +431,10 @@ describe("SensorJsTest", function () { ...@@ -430,12 +431,10 @@ describe("SensorJsTest", function () {
expect(false).assertTrue(); expect(false).assertTrue();
}, },
}); });
try { try {
sensor.unsubscribeAccelerometer(); sensor.unsubscribeAccelerometer();
} catch (error) { } catch (error) {
console.info('subscribeAccelerometer_SensorJsTest014_unsubscribeAccelerometer error' + error); console.info('subscribeAccelerometer_SensorJsTest014_unsubscribeAccelerometer error' + error);
expect(true).assertTrue();
} }
setTimeout(() => { setTimeout(() => {
expect(true).assertTrue(); expect(true).assertTrue();
......
...@@ -49,7 +49,8 @@ describe("SensorJsTest", function () { ...@@ -49,7 +49,8 @@ describe("SensorJsTest", function () {
}) })
let errMessages = ['The number of parameters is not valid', 'UnsubscribeSensor failed', let errMessages = ['The number of parameters is not valid', 'UnsubscribeSensor failed',
'Wrong argument type, should be object']; 'Wrong argument type, should be object'];
let errMessage; let errMessage;
/* /*
...@@ -83,7 +84,6 @@ describe("SensorJsTest", function () { ...@@ -83,7 +84,6 @@ describe("SensorJsTest", function () {
}, 1000); }, 1000);
}) })
/* /*
* @tc.name:subscribeBarometer_SensorJsTest002 * @tc.name:subscribeBarometer_SensorJsTest002
* @tc.desc:verify app info is not null * @tc.desc:verify app info is not null
...@@ -221,7 +221,6 @@ describe("SensorJsTest", function () { ...@@ -221,7 +221,6 @@ describe("SensorJsTest", function () {
expect(code).assertEqual(1001); expect(code).assertEqual(1001);
}, },
}); });
setTimeout(() => { setTimeout(() => {
try { try {
sensor.unsubscribeBarometer(); sensor.unsubscribeBarometer();
...@@ -246,7 +245,7 @@ describe("SensorJsTest", function () { ...@@ -246,7 +245,7 @@ describe("SensorJsTest", function () {
try { try {
sensor.unsubscribeBarometer(); sensor.unsubscribeBarometer();
} catch (error) { } catch (error) {
var errMessage = error.toString().slice(21, 45); errMessage = error.toString().slice(21, 45);
console.info('subscribeBarometer_SensorJsTest008 error:' + error); console.info('subscribeBarometer_SensorJsTest008 error:' + error);
expect(errMessage).assertEqual(errMessages[1]); expect(errMessage).assertEqual(errMessages[1]);
done(); done();
...@@ -271,7 +270,6 @@ describe("SensorJsTest", function () { ...@@ -271,7 +270,6 @@ describe("SensorJsTest", function () {
expect(code).assertEqual(1001); expect(code).assertEqual(1001);
}, },
}); });
try { try {
sensor.unsubscribeBarometer(); sensor.unsubscribeBarometer();
} catch (error) { } catch (error) {
......
...@@ -50,6 +50,7 @@ describe("SensorJsTest", function () { ...@@ -50,6 +50,7 @@ describe("SensorJsTest", function () {
let errMessages = ['The number of parameters is not valid', 'UnsubscribeSensor failed', let errMessages = ['The number of parameters is not valid', 'UnsubscribeSensor failed',
'Wrong argument type, should be object']; 'Wrong argument type, should be object'];
let errMessage; let errMessage;
/* /*
...@@ -125,7 +126,6 @@ describe("SensorJsTest", function () { ...@@ -125,7 +126,6 @@ describe("SensorJsTest", function () {
expect(typeof (data.direction)).assertEqual("number"); expect(typeof (data.direction)).assertEqual("number");
}, },
}); });
setTimeout(() => { setTimeout(() => {
try { try {
sensor.unsubscribeCompass(); sensor.unsubscribeCompass();
...@@ -250,7 +250,6 @@ describe("SensorJsTest", function () { ...@@ -250,7 +250,6 @@ describe("SensorJsTest", function () {
expect(false).assertTrue(); expect(false).assertTrue();
}, },
}); });
setTimeout(() => { setTimeout(() => {
try { try {
sensor.unsubscribeCompass(); sensor.unsubscribeCompass();
...@@ -301,12 +300,10 @@ describe("SensorJsTest", function () { ...@@ -301,12 +300,10 @@ describe("SensorJsTest", function () {
expect(false).assertTrue(); expect(false).assertTrue();
}, },
}); });
try { try {
sensor.unsubscribeCompass(); sensor.unsubscribeCompass();
} catch (error) { } catch (error) {
console.info('subscribeLight_SensorJsTest010_unsubscribeLight error' + error); console.info('subscribeLight_SensorJsTest010_unsubscribeLight error' + error);
expect(true).assertTrue();
} }
setTimeout(() => { setTimeout(() => {
expect(true).assertTrue(); expect(true).assertTrue();
......
...@@ -49,9 +49,10 @@ describe("SensorJsTest", function () { ...@@ -49,9 +49,10 @@ describe("SensorJsTest", function () {
}) })
let errMessages = ['The number of parameters is not valid', 'Wrong argument type, should be object', let errMessages = ['The number of parameters is not valid', 'Wrong argument type, should be object',
'UnsubscribeSensor failed']; 'UnsubscribeSensor failed'];
let errMessage; let errMessage;
/* /*
* @tc.name:subscribeDeviceOrientation_SensorJsTest001 * @tc.name:subscribeDeviceOrientation_SensorJsTest001
* @tc.desc:verify app info is not null * @tc.desc:verify app info is not null
...@@ -437,7 +438,6 @@ describe("SensorJsTest", function () { ...@@ -437,7 +438,6 @@ describe("SensorJsTest", function () {
sensor.unsubscribeDeviceOrientation(); sensor.unsubscribeDeviceOrientation();
} catch (error) { } catch (error) {
console.info('subscribeDeviceOrientation_SensorJsTest014_unsubscribeDeviceOrientation error' + error); console.info('subscribeDeviceOrientation_SensorJsTest014_unsubscribeDeviceOrientation error' + error);
expect(true).assertTrue();
} }
setTimeout(() => { setTimeout(() => {
expect(true).assertTrue(); expect(true).assertTrue();
......
...@@ -48,7 +48,10 @@ describe("SensorJsTest", function () { ...@@ -48,7 +48,10 @@ describe("SensorJsTest", function () {
console.info('afterEach caled') console.info('afterEach caled')
}) })
var errMessages = ['The number of parameters is not valid', 'Wrong argument type, should be object', 'UnsubscribeSensor failed']; let errMessages = ['The number of parameters is not valid',
'Wrong argument type, should be object', 'UnsubscribeSensor failed'];
let errMessage;
/* /*
* @tc.name:subscribeGyroscope_SensorJsTest001 * @tc.name:subscribeGyroscope_SensorJsTest001
...@@ -71,7 +74,6 @@ describe("SensorJsTest", function () { ...@@ -71,7 +74,6 @@ describe("SensorJsTest", function () {
expect(false).assertTrue(); expect(false).assertTrue();
}, },
}); });
setTimeout(() => { setTimeout(() => {
try { try {
sensor.unsubscribeGyroscope(); sensor.unsubscribeGyroscope();
...@@ -107,7 +109,6 @@ describe("SensorJsTest", function () { ...@@ -107,7 +109,6 @@ describe("SensorJsTest", function () {
expect(false).assertTrue(); expect(false).assertTrue();
}, },
}); });
setTimeout(() => { setTimeout(() => {
try { try {
sensor.unsubscribeGyroscope(); sensor.unsubscribeGyroscope();
...@@ -229,7 +230,7 @@ describe("SensorJsTest", function () { ...@@ -229,7 +230,7 @@ describe("SensorJsTest", function () {
}, },
}, 25); }, 25);
} catch (error) { } catch (error) {
var errMessage = error.toString().slice(19, 56); errMessage = error.toString().slice(19, 56);
console.info('subscribeGyroscope_SensorJsTest006 error:' + error); console.info('subscribeGyroscope_SensorJsTest006 error:' + error);
expect(errMessage).assertEqual(errMessages[0]); expect(errMessage).assertEqual(errMessages[0]);
done(); done();
...@@ -260,7 +261,7 @@ describe("SensorJsTest", function () { ...@@ -260,7 +261,7 @@ describe("SensorJsTest", function () {
}, function () { }, function () {
}, 25); }, 25);
} catch (error) { } catch (error) {
var errMessage = error.toString().slice(19, 56); errMessage = error.toString().slice(19, 56);
console.info('subscribeGyroscope_SensorJsTest007 error:' + error); console.info('subscribeGyroscope_SensorJsTest007 error:' + error);
expect(errMessage).assertEqual(errMessages[0]); expect(errMessage).assertEqual(errMessages[0]);
done(); done();
...@@ -288,7 +289,6 @@ describe("SensorJsTest", function () { ...@@ -288,7 +289,6 @@ describe("SensorJsTest", function () {
expect(false).assertTrue(); expect(false).assertTrue();
}, },
}); });
sensor.subscribeGyroscope({ sensor.subscribeGyroscope({
interval: 'normal', interval: 'normal',
success: function (data) { success: function (data) {
...@@ -302,7 +302,6 @@ describe("SensorJsTest", function () { ...@@ -302,7 +302,6 @@ describe("SensorJsTest", function () {
expect(false).assertTrue(); expect(false).assertTrue();
}, },
}); });
setTimeout(() => { setTimeout(() => {
try { try {
sensor.unsubscribeGyroscope(); sensor.unsubscribeGyroscope();
...@@ -328,7 +327,7 @@ describe("SensorJsTest", function () { ...@@ -328,7 +327,7 @@ describe("SensorJsTest", function () {
try { try {
sensor.subscribeGyroscope(); sensor.subscribeGyroscope();
} catch (error) { } catch (error) {
var errMessage = error.toString().slice(19, 56); errMessage = error.toString().slice(19, 56);
console.info('subscribeGyroscope_SensorJsTest009 error:' + error); console.info('subscribeGyroscope_SensorJsTest009 error:' + error);
expect(errMessage).assertEqual(errMessages[0]); expect(errMessage).assertEqual(errMessages[0]);
done(); done();
...@@ -346,7 +345,7 @@ describe("SensorJsTest", function () { ...@@ -346,7 +345,7 @@ describe("SensorJsTest", function () {
try { try {
sensor.subscribeGyroscope('xxx'); sensor.subscribeGyroscope('xxx');
} catch (error) { } catch (error) {
var errMessage = error.toString().slice(19, 56); errMessage = error.toString().slice(19, 56);
console.info('subscribeGyroscope_SensorJsTest010 error:' + error); console.info('subscribeGyroscope_SensorJsTest010 error:' + error);
expect(errMessage).assertEqual(errMessages[1]); expect(errMessage).assertEqual(errMessages[1]);
done(); done();
...@@ -364,7 +363,7 @@ describe("SensorJsTest", function () { ...@@ -364,7 +363,7 @@ describe("SensorJsTest", function () {
try { try {
sensor.unsubscribeGyroscope(); sensor.unsubscribeGyroscope();
} catch (error) { } catch (error) {
var errMessage = error.toString().slice(21, 45); errMessage = error.toString().slice(21, 45);
console.info('subscribeGyroscope_SensorJsTest011 error:' + error); console.info('subscribeGyroscope_SensorJsTest011 error:' + error);
expect(errMessage).assertEqual(errMessages[2]); expect(errMessage).assertEqual(errMessages[2]);
done(); done();
...@@ -382,7 +381,7 @@ describe("SensorJsTest", function () { ...@@ -382,7 +381,7 @@ describe("SensorJsTest", function () {
try { try {
sensor.unsubscribeGyroscope('xxx'); sensor.unsubscribeGyroscope('xxx');
} catch (error) { } catch (error) {
var errMessage = error.toString().slice(21, 58); errMessage = error.toString().slice(21, 58);
console.info('subscribeGyroscope_SensorJsTest012 error:' + error); console.info('subscribeGyroscope_SensorJsTest012 error:' + error);
expect(errMessage).assertEqual(errMessages[0]); expect(errMessage).assertEqual(errMessages[0]);
done(); done();
...@@ -431,12 +430,10 @@ describe("SensorJsTest", function () { ...@@ -431,12 +430,10 @@ describe("SensorJsTest", function () {
expect(false).assertTrue(); expect(false).assertTrue();
}, },
}); });
try { try {
sensor.unsubscribeGyroscope(); sensor.unsubscribeGyroscope();
} catch (error) { } catch (error) {
console.info('subscribeAccelerometer_SensorJsTest014_unsubscribeAccelerometer error' + error); console.info('subscribeAccelerometer_SensorJsTest014_unsubscribeAccelerometer error' + error);
expect(false).assertTrue();
} }
setTimeout(() => { setTimeout(() => {
expect(true).assertTrue(); expect(true).assertTrue();
......
...@@ -50,6 +50,7 @@ describe("SensorJsTest", function () { ...@@ -50,6 +50,7 @@ describe("SensorJsTest", function () {
let errMessages = ['The number of parameters is not valid', 'UnsubscribeSensor failed', let errMessages = ['The number of parameters is not valid', 'UnsubscribeSensor failed',
'Wrong argument type, should be object']; 'Wrong argument type, should be object'];
let errMessage; let errMessage;
/* /*
...@@ -220,7 +221,6 @@ describe("SensorJsTest", function () { ...@@ -220,7 +221,6 @@ describe("SensorJsTest", function () {
expect(code).assertEqual(1001); expect(code).assertEqual(1001);
}, },
}); });
setTimeout(() => { setTimeout(() => {
try { try {
sensor.unsubscribeHeartRate(); sensor.unsubscribeHeartRate();
......
...@@ -48,7 +48,10 @@ describe("SensorJsTest", function () { ...@@ -48,7 +48,10 @@ describe("SensorJsTest", function () {
console.info('afterEach caled') console.info('afterEach caled')
}) })
var errMessages = ['The number of parameters is not valid', 'UnsubscribeSensor failed', 'Wrong argument type, should be object']; let errMessages = ['The number of parameters is not valid', 'UnsubscribeSensor failed',
'Wrong argument type, should be object'];
let errMessage;
/* /*
* @tc.name:subscribeLight_SensorJsTest001 * @tc.name:subscribeLight_SensorJsTest001
...@@ -57,7 +60,7 @@ describe("SensorJsTest", function () { ...@@ -57,7 +60,7 @@ describe("SensorJsTest", function () {
* @tc.require: SR000H0ALK, AR000H0ALM * @tc.require: SR000H0ALK, AR000H0ALM
*/ */
it("subscribeLight_SensorJsTest001", 0, function (done) { it("subscribeLight_SensorJsTest001", 0, function (done) {
console.info('----------------------subscribeLight_SensorJsTest001---------------------------'); console.info('----------------------subscribeLight_SensorJsTest001---------------------------');
sensor.subscribeLight({ sensor.subscribeLight({
success: function (data) { success: function (data) {
console.info("subscribeLight_SensorJsTest001 success:" + JSON.stringify(data)); console.info("subscribeLight_SensorJsTest001 success:" + JSON.stringify(data));
...@@ -68,7 +71,6 @@ describe("SensorJsTest", function () { ...@@ -68,7 +71,6 @@ describe("SensorJsTest", function () {
expect(false).assertTrue(); expect(false).assertTrue();
}, },
}); });
setTimeout(() => { setTimeout(() => {
try { try {
sensor.unsubscribeLight(); sensor.unsubscribeLight();
...@@ -90,7 +92,7 @@ describe("SensorJsTest", function () { ...@@ -90,7 +92,7 @@ describe("SensorJsTest", function () {
* @tc.require: SR000H0ALK, AR000H0ALM * @tc.require: SR000H0ALK, AR000H0ALM
*/ */
it("subscribeLight_SensorJsTest002", 0, function (done) { it("subscribeLight_SensorJsTest002", 0, function (done) {
console.info('----------------------subscribeLight_SensorJsTest002---------------------------'); console.info('----------------------subscribeLight_SensorJsTest002---------------------------');
try { try {
sensor.subscribeLight({ sensor.subscribeLight({
success: function (data) { success: function (data) {
...@@ -103,28 +105,27 @@ describe("SensorJsTest", function () { ...@@ -103,28 +105,27 @@ describe("SensorJsTest", function () {
}, },
}, 25); }, 25);
} catch (error) { } catch (error) {
var errMessage = error.toString().slice(19, 56); errMessage = error.toString().slice(19, 56);
console.info('subscribeLight_SensorJsTest002 error:' + error); console.info('subscribeLight_SensorJsTest002 error:' + error);
expect(errMessage).assertEqual(errMessages[0]); expect(errMessage).assertEqual(errMessages[0]);
done(); done();
} }
}) })
/* /*
* @tc.name:subscribeLight_SensorJsTest003 * @tc.name:subscribeLight_SensorJsTest003
* @tc.desc:verify app info is not null * @tc.desc:verify app info is not null
* @tc.type: FUNC * @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM * @tc.require: SR000H0ALK, AR000H0ALM
*/ */
it("subscribeLight_SensorJsTest003", 0, function (done) { it("subscribeLight_SensorJsTest003", 0, function (done) {
console.info('----------------------subscribeLight_SensorJsTest003---------------------------'); console.info('----------------------subscribeLight_SensorJsTest003---------------------------');
sensor.subscribeLight({ sensor.subscribeLight({
success: function (data) { success: function (data) {
console.info("subscribeLight_SensorJsTest003 success:" + JSON.stringify(data)); console.info("subscribeLight_SensorJsTest003 success:" + JSON.stringify(data));
expect(typeof (data.intensity)).assertEqual("number"); expect(typeof (data.intensity)).assertEqual("number");
}, },
}); });
setTimeout(() => { setTimeout(() => {
try { try {
sensor.unsubscribeLight(); sensor.unsubscribeLight();
...@@ -146,7 +147,7 @@ describe("SensorJsTest", function () { ...@@ -146,7 +147,7 @@ describe("SensorJsTest", function () {
* @tc.require: SR000H0ALK, AR000H0ALM * @tc.require: SR000H0ALK, AR000H0ALM
*/ */
it("subscribeLight_SensorJsTest004", 0, function (done) { it("subscribeLight_SensorJsTest004", 0, function (done) {
console.info('----------------------subscribeLight_SensorJsTest004---------------------------'); console.info('----------------------subscribeLight_SensorJsTest004---------------------------');
try { try {
sensor.subscribeLight({ sensor.subscribeLight({
success: function (data) { success: function (data) {
...@@ -160,7 +161,7 @@ describe("SensorJsTest", function () { ...@@ -160,7 +161,7 @@ describe("SensorJsTest", function () {
}, function () { }, function () {
}, 25); }, 25);
} catch (error) { } catch (error) {
var errMessage = error.toString().slice(19, 56); errMessage = error.toString().slice(19, 56);
console.info('subscribeLight_SensorJsTest004 error:' + error); console.info('subscribeLight_SensorJsTest004 error:' + error);
expect(errMessage).assertEqual(errMessages[0]); expect(errMessage).assertEqual(errMessages[0]);
done(); done();
...@@ -178,7 +179,7 @@ describe("SensorJsTest", function () { ...@@ -178,7 +179,7 @@ describe("SensorJsTest", function () {
try { try {
sensor.unsubscribeLight('xxx'); sensor.unsubscribeLight('xxx');
} catch (error) { } catch (error) {
var errMessage = error.toString().slice(21, 58); errMessage = error.toString().slice(21, 58);
console.info('subscribeLight_SensorJsTest005 error:' + error); console.info('subscribeLight_SensorJsTest005 error:' + error);
expect(errMessage).assertEqual(errMessages[0]); expect(errMessage).assertEqual(errMessages[0]);
done(); done();
...@@ -196,7 +197,7 @@ describe("SensorJsTest", function () { ...@@ -196,7 +197,7 @@ describe("SensorJsTest", function () {
try { try {
sensor.subscribeLight(); sensor.subscribeLight();
} catch (error) { } catch (error) {
var errMessage = error.toString().slice(19, 56); errMessage = error.toString().slice(19, 56);
console.info('subscribeLight_SensorJsTest006 error:' + error); console.info('subscribeLight_SensorJsTest006 error:' + error);
expect(errMessage).assertEqual(errMessages[0]); expect(errMessage).assertEqual(errMessages[0]);
done(); done();
...@@ -214,7 +215,7 @@ describe("SensorJsTest", function () { ...@@ -214,7 +215,7 @@ describe("SensorJsTest", function () {
try { try {
sensor.subscribeLight('xxx'); sensor.subscribeLight('xxx');
} catch (error) { } catch (error) {
var errMessage = error.toString().slice(19, 56); errMessage = error.toString().slice(19, 56);
console.info('subscribeLight_SensorJsTest007 error:' + error); console.info('subscribeLight_SensorJsTest007 error:' + error);
expect(errMessage).assertEqual(errMessages[2]); expect(errMessage).assertEqual(errMessages[2]);
done(); done();
...@@ -228,7 +229,7 @@ describe("SensorJsTest", function () { ...@@ -228,7 +229,7 @@ describe("SensorJsTest", function () {
* @tc.require: SR000H0ALK, AR000H0ALM * @tc.require: SR000H0ALK, AR000H0ALM
*/ */
it("subscribeLight_SensorJsTest008", 0, function (done) { it("subscribeLight_SensorJsTest008", 0, function (done) {
console.info('----------------------subscribeLight_SensorJsTest008---------------------------'); console.info('----------------------subscribeLight_SensorJsTest008---------------------------');
sensor.subscribeLight({ sensor.subscribeLight({
success: function (data) { success: function (data) {
console.info("subscribeLight_SensorJsTest008 success:" + JSON.stringify(data)); console.info("subscribeLight_SensorJsTest008 success:" + JSON.stringify(data));
...@@ -249,7 +250,6 @@ describe("SensorJsTest", function () { ...@@ -249,7 +250,6 @@ describe("SensorJsTest", function () {
expect(false).assertTrue(); expect(false).assertTrue();
}, },
}); });
setTimeout(() => { setTimeout(() => {
try { try {
sensor.unsubscribeLight(); sensor.unsubscribeLight();
...@@ -275,7 +275,7 @@ describe("SensorJsTest", function () { ...@@ -275,7 +275,7 @@ describe("SensorJsTest", function () {
try { try {
sensor.unsubscribeLight(); sensor.unsubscribeLight();
} catch (error) { } catch (error) {
var errMessage = error.toString().slice(21,45); errMessage = error.toString().slice(21, 45);
console.info('subscribeLight_SensorJsTest009 error:' + error); console.info('subscribeLight_SensorJsTest009 error:' + error);
expect(errMessage).assertEqual(errMessages[1]); expect(errMessage).assertEqual(errMessages[1]);
done(); done();
...@@ -289,7 +289,7 @@ describe("SensorJsTest", function () { ...@@ -289,7 +289,7 @@ describe("SensorJsTest", function () {
* @tc.require: SR000H0ALK, AR000H0ALM * @tc.require: SR000H0ALK, AR000H0ALM
*/ */
it("subscribeLight_SensorJsTest010", 0, function (done) { it("subscribeLight_SensorJsTest010", 0, function (done) {
console.info('----------------------subscribeLight_SensorJsTest010---------------------------'); console.info('----------------------subscribeLight_SensorJsTest010---------------------------');
sensor.subscribeLight({ sensor.subscribeLight({
success: function (data) { success: function (data) {
console.info("subscribeLight_SensorJsTest010 success:" + JSON.stringify(data)); console.info("subscribeLight_SensorJsTest010 success:" + JSON.stringify(data));
...@@ -300,12 +300,10 @@ describe("SensorJsTest", function () { ...@@ -300,12 +300,10 @@ describe("SensorJsTest", function () {
expect(false).assertTrue(); expect(false).assertTrue();
}, },
}); });
try { try {
sensor.unsubscribeLight(); sensor.unsubscribeLight();
} catch (error) { } catch (error) {
console.info('subscribeLight_SensorJsTest008_unsubscribeLight error' + error); console.info('subscribeLight_SensorJsTest008_unsubscribeLight error' + error);
expect(true).assertTrue();
} }
setTimeout(() => { setTimeout(() => {
expect(true).assertTrue(); expect(true).assertTrue();
......
...@@ -50,6 +50,7 @@ describe("SensorJsTest", function () { ...@@ -50,6 +50,7 @@ describe("SensorJsTest", function () {
let errMessages = ['The number of parameters is not valid', 'UnsubscribeSensor failed', let errMessages = ['The number of parameters is not valid', 'UnsubscribeSensor failed',
'Wrong argument type, should be object']; 'Wrong argument type, should be object'];
let errMessage; let errMessage;
/* /*
...@@ -210,7 +211,6 @@ describe("SensorJsTest", function () { ...@@ -210,7 +211,6 @@ describe("SensorJsTest", function () {
expect(code).assertEqual(1001); expect(code).assertEqual(1001);
}, },
}); });
sensor.subscribeOnBodyState({ sensor.subscribeOnBodyState({
success: function (data) { success: function (data) {
console.info("subscribeOnBodyState_SensorJsTest007_1 success:" + JSON.stringify(data)); console.info("subscribeOnBodyState_SensorJsTest007_1 success:" + JSON.stringify(data));
...@@ -221,7 +221,6 @@ describe("SensorJsTest", function () { ...@@ -221,7 +221,6 @@ describe("SensorJsTest", function () {
expect(code).assertEqual(1001); expect(code).assertEqual(1001);
}, },
}); });
setTimeout(() => { setTimeout(() => {
try { try {
sensor.unsubscribeOnBodyState(); sensor.unsubscribeOnBodyState();
...@@ -271,7 +270,6 @@ describe("SensorJsTest", function () { ...@@ -271,7 +270,6 @@ describe("SensorJsTest", function () {
expect(code).assertEqual(1001); expect(code).assertEqual(1001);
}, },
}); });
try { try {
sensor.unsubscribeOnBodyState(); sensor.unsubscribeOnBodyState();
} catch (error) { } catch (error) {
......
...@@ -49,34 +49,35 @@ describe("SensorJsTest", function () { ...@@ -49,34 +49,35 @@ describe("SensorJsTest", function () {
}) })
let errMessages = ['The number of parameters is not valid', 'UnsubscribeSensor failed', let errMessages = ['The number of parameters is not valid', 'UnsubscribeSensor failed',
'Wrong argument type, should be object']; 'Wrong argument type, should be object'];
let errMessage; let errMessage;
/* /*
* @tc.name:subscribeProximity_SensorJsTest001 * @tc.name:subscribeProximity_SensorJsTest001
* @tc.desc:verify app info is not null * @tc.desc:verify app info is not null
* @tc.type: FUNC * @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM * @tc.require: SR000H0ALK, AR000H0ALM
*/ */
it("subscribeProximity_SensorJsTest001", 0, async function (done) { it("subscribeProximity_SensorJsTest001", 0, async function (done) {
console.info('----------------------subscribeProximity_SensorJsTest001---------------------------'); console.info('----------------------subscribeProximity_SensorJsTest001---------------------------');
sensor.subscribeProximity({ sensor.subscribeProximity({
success: function(data) { success: function (data) {
console.info("subscribeProximity_SensorJsTest001 success" + JSON.stringify(data)); console.info("subscribeProximity_SensorJsTest001 success" + JSON.stringify(data));
expect(typeof(data.distance)).assertEqual("number"); expect(typeof (data.distance)).assertEqual("number");
}, },
fail: function(data, code) { fail: function (data, code) {
console.error('subscribeProximity_SensorJsTest001 failed. Code: ' + code + '; Data: ' + data); console.error('subscribeProximity_SensorJsTest001 failed. Code: ' + code + '; Data: ' + data);
expect(code).assertEqual(1001); expect(code).assertEqual(1001);
}, },
}); });
setTimeout(()=>{ setTimeout(() => {
try { try {
sensor.unsubscribeProximity(); sensor.unsubscribeProximity();
} catch (error) { } catch (error) {
console.info(error); console.info(error);
} }
setTimeout(()=>{ setTimeout(() => {
expect(true).assertTrue(); expect(true).assertTrue();
done(); done();
}, 500); }, 500);
...@@ -90,7 +91,7 @@ describe("SensorJsTest", function () { ...@@ -90,7 +91,7 @@ describe("SensorJsTest", function () {
* @tc.require: SR000H0ALK, AR000H0ALM * @tc.require: SR000H0ALK, AR000H0ALM
*/ */
it("subscribeProximity_SensorJsTest002", 0, function (done) { it("subscribeProximity_SensorJsTest002", 0, function (done) {
console.info('----------------------subscribeProximity_SensorJsTest002---------------------------'); console.info('----------------------subscribeProximity_SensorJsTest002---------------------------');
try { try {
sensor.subscribeProximity({ sensor.subscribeProximity({
success: function (data) { success: function (data) {
...@@ -117,7 +118,7 @@ describe("SensorJsTest", function () { ...@@ -117,7 +118,7 @@ describe("SensorJsTest", function () {
* @tc.require: SR000H0ALK, AR000H0ALM * @tc.require: SR000H0ALK, AR000H0ALM
*/ */
it("subscribeProximity_SensorJsTest003", 0, function (done) { it("subscribeProximity_SensorJsTest003", 0, function (done) {
console.info('----------------------subscribeProximity_SensorJsTest003---------------------------'); console.info('----------------------subscribeProximity_SensorJsTest003---------------------------');
try { try {
sensor.subscribeProximity({ sensor.subscribeProximity({
success: function (data) { success: function (data) {
...@@ -199,7 +200,7 @@ describe("SensorJsTest", function () { ...@@ -199,7 +200,7 @@ describe("SensorJsTest", function () {
* @tc.require: SR000H0ALK, AR000H0ALM * @tc.require: SR000H0ALK, AR000H0ALM
*/ */
it("subscribeProximity_SensorJsTest007", 0, function (done) { it("subscribeProximity_SensorJsTest007", 0, function (done) {
console.info('----------------------subscribeProximity_SensorJsTest007---------------------------'); console.info('----------------------subscribeProximity_SensorJsTest007---------------------------');
sensor.subscribeProximity({ sensor.subscribeProximity({
success: function (data) { success: function (data) {
console.info("subscribeProximity_SensorJsTest007 success:" + JSON.stringify(data)); console.info("subscribeProximity_SensorJsTest007 success:" + JSON.stringify(data));
...@@ -220,7 +221,6 @@ describe("SensorJsTest", function () { ...@@ -220,7 +221,6 @@ describe("SensorJsTest", function () {
expect(code).assertEqual(1001); expect(code).assertEqual(1001);
}, },
}); });
setTimeout(() => { setTimeout(() => {
try { try {
sensor.unsubscribeProximity(); sensor.unsubscribeProximity();
...@@ -245,7 +245,7 @@ describe("SensorJsTest", function () { ...@@ -245,7 +245,7 @@ describe("SensorJsTest", function () {
try { try {
sensor.unsubscribeProximity(); sensor.unsubscribeProximity();
} catch (error) { } catch (error) {
errMessage = error.toString().slice(21,45); errMessage = error.toString().slice(21, 45);
console.info('subscribeProximity_SensorJsTest008 error:' + error); console.info('subscribeProximity_SensorJsTest008 error:' + error);
expect(errMessage).assertEqual(errMessages[1]); expect(errMessage).assertEqual(errMessages[1]);
done(); done();
...@@ -259,7 +259,7 @@ describe("SensorJsTest", function () { ...@@ -259,7 +259,7 @@ describe("SensorJsTest", function () {
* @tc.require: SR000H0ALK, AR000H0ALM * @tc.require: SR000H0ALK, AR000H0ALM
*/ */
it("subscribeProximity_SensorJsTest009", 0, function (done) { it("subscribeProximity_SensorJsTest009", 0, function (done) {
console.info('----------------------subscribeProximity_SensorJsTest009---------------------------'); console.info('----------------------subscribeProximity_SensorJsTest009---------------------------');
sensor.subscribeProximity({ sensor.subscribeProximity({
success: function (data) { success: function (data) {
console.info("subscribeProximity_SensorJsTest009 success:" + JSON.stringify(data)); console.info("subscribeProximity_SensorJsTest009 success:" + JSON.stringify(data));
...@@ -270,7 +270,6 @@ describe("SensorJsTest", function () { ...@@ -270,7 +270,6 @@ describe("SensorJsTest", function () {
expect(code).assertEqual(1001); expect(code).assertEqual(1001);
}, },
}); });
try { try {
sensor.unsubscribeProximity(); sensor.unsubscribeProximity();
} catch (error) { } catch (error) {
......
...@@ -49,34 +49,35 @@ describe("SensorJsTest", function () { ...@@ -49,34 +49,35 @@ describe("SensorJsTest", function () {
}) })
let errMessages = ['The number of parameters is not valid', 'UnsubscribeSensor failed', let errMessages = ['The number of parameters is not valid', 'UnsubscribeSensor failed',
'Wrong argument type, should be object']; 'Wrong argument type, should be object'];
let errMessage; let errMessage;
/* /*
* @tc.name:subscribeStepCounter_SensorJsTest001 * @tc.name:subscribeStepCounter_SensorJsTest001
* @tc.desc:verify app info is not null * @tc.desc:verify app info is not null
* @tc.type: FUNC * @tc.type: FUNC
* @tc.require: SR000H0ALK, AR000H0ALM * @tc.require: SR000H0ALK, AR000H0ALM
*/ */
it("subscribeStepCounter_SensorJsTest001", 0, async function (done) { it("subscribeStepCounter_SensorJsTest001", 0, async function (done) {
console.info('----------------------subscribeStepCounter_SensorJsTest001---------------------------'); console.info('----------------------subscribeStepCounter_SensorJsTest001---------------------------');
sensor.subscribeStepCounter({ sensor.subscribeStepCounter({
success: function(data) { success: function (data) {
console.info("subscribeStepCounter_SensorJsTest001 success" + JSON.stringify(data)); console.info("subscribeStepCounter_SensorJsTest001 success" + JSON.stringify(data));
expect(typeof(data.steps)).assertEqual("number"); expect(typeof (data.steps)).assertEqual("number");
}, },
fail: function(data, code) { fail: function (data, code) {
console.error('subscribeStepCounter_SensorJsTest001 failed. Code: ' + code + '; Data: ' + data); console.error('subscribeStepCounter_SensorJsTest001 failed. Code: ' + code + '; Data: ' + data);
expect(code).assertEqual(1001); expect(code).assertEqual(1001);
}, },
}); });
setTimeout(()=>{ setTimeout(() => {
try { try {
sensor.unsubscribeStepCounter(); sensor.unsubscribeStepCounter();
} catch (error) { } catch (error) {
console.info('subscribeStepCounter_SensorJsTest001_unsubscribeStepCounter error ' + error); console.info('subscribeStepCounter_SensorJsTest001_unsubscribeStepCounter error ' + error);
} }
setTimeout(()=>{ setTimeout(() => {
expect(true).assertTrue(); expect(true).assertTrue();
done(); done();
}, 500); }, 500);
...@@ -90,7 +91,7 @@ describe("SensorJsTest", function () { ...@@ -90,7 +91,7 @@ describe("SensorJsTest", function () {
* @tc.require: SR000H0ALK, AR000H0ALM * @tc.require: SR000H0ALK, AR000H0ALM
*/ */
it("subscribeStepCounter_SensorJsTest002", 0, function (done) { it("subscribeStepCounter_SensorJsTest002", 0, function (done) {
console.info('----------------------subscribeStepCounter_SensorJsTest002---------------------------'); console.info('----------------------subscribeStepCounter_SensorJsTest002---------------------------');
try { try {
sensor.subscribeStepCounter({ sensor.subscribeStepCounter({
success: function (data) { success: function (data) {
...@@ -117,7 +118,7 @@ describe("SensorJsTest", function () { ...@@ -117,7 +118,7 @@ describe("SensorJsTest", function () {
* @tc.require: SR000H0ALK, AR000H0ALM * @tc.require: SR000H0ALK, AR000H0ALM
*/ */
it("subscribeStepCounter_SensorJsTest003", 0, function (done) { it("subscribeStepCounter_SensorJsTest003", 0, function (done) {
console.info('----------------------subscribeStepCounter_SensorJsTest003---------------------------'); console.info('----------------------subscribeStepCounter_SensorJsTest003---------------------------');
try { try {
sensor.subscribeStepCounter({ sensor.subscribeStepCounter({
success: function (data) { success: function (data) {
...@@ -128,7 +129,8 @@ describe("SensorJsTest", function () { ...@@ -128,7 +129,8 @@ describe("SensorJsTest", function () {
console.error('subscribeStepCounter_SensorJsTest003 failed. Code: ' + code + '; Data: ' + data); console.error('subscribeStepCounter_SensorJsTest003 failed. Code: ' + code + '; Data: ' + data);
expect(code).assertEqual(1001); expect(code).assertEqual(1001);
}, },
}, function () {}, 25); }, function () {
}, 25);
} catch (error) { } catch (error) {
errMessage = error.toString().slice(19, 56); errMessage = error.toString().slice(19, 56);
console.info('subscribeStepCounter_SensorJsTest003 error:' + error); console.info('subscribeStepCounter_SensorJsTest003 error:' + error);
...@@ -198,7 +200,7 @@ describe("SensorJsTest", function () { ...@@ -198,7 +200,7 @@ describe("SensorJsTest", function () {
* @tc.require: SR000H0ALK, AR000H0ALM * @tc.require: SR000H0ALK, AR000H0ALM
*/ */
it("subscribeStepCounter_SensorJsTest007", 0, function (done) { it("subscribeStepCounter_SensorJsTest007", 0, function (done) {
console.info('----------------------subscribeStepCounter_SensorJsTest007---------------------------'); console.info('----------------------subscribeStepCounter_SensorJsTest007---------------------------');
sensor.subscribeStepCounter({ sensor.subscribeStepCounter({
success: function (data) { success: function (data) {
console.info("subscribeStepCounter_SensorJsTest007 success:" + JSON.stringify(data)); console.info("subscribeStepCounter_SensorJsTest007 success:" + JSON.stringify(data));
...@@ -219,7 +221,6 @@ describe("SensorJsTest", function () { ...@@ -219,7 +221,6 @@ describe("SensorJsTest", function () {
expect(code).assertEqual(1001); expect(code).assertEqual(1001);
}, },
}); });
setTimeout(() => { setTimeout(() => {
try { try {
sensor.unsubscribeStepCounter(); sensor.unsubscribeStepCounter();
...@@ -244,7 +245,7 @@ describe("SensorJsTest", function () { ...@@ -244,7 +245,7 @@ describe("SensorJsTest", function () {
try { try {
sensor.unsubscribeStepCounter(); sensor.unsubscribeStepCounter();
} catch (error) { } catch (error) {
errMessage = error.toString().slice(21,45); errMessage = error.toString().slice(21, 45);
console.info('subscribeStepCounter_SensorJsTest008 error:' + error); console.info('subscribeStepCounter_SensorJsTest008 error:' + error);
expect(errMessage).assertEqual(errMessages[1]); expect(errMessage).assertEqual(errMessages[1]);
done(); done();
...@@ -258,7 +259,7 @@ describe("SensorJsTest", function () { ...@@ -258,7 +259,7 @@ describe("SensorJsTest", function () {
* @tc.require: SR000H0ALK, AR000H0ALM * @tc.require: SR000H0ALK, AR000H0ALM
*/ */
it("subscribeStepCounter_SensorJsTest009", 0, function (done) { it("subscribeStepCounter_SensorJsTest009", 0, function (done) {
console.info('----------------------subscribeStepCounter_SensorJsTest009---------------------------'); console.info('----------------------subscribeStepCounter_SensorJsTest009---------------------------');
sensor.subscribeStepCounter({ sensor.subscribeStepCounter({
success: function (data) { success: function (data) {
console.info("subscribeStepCounter_SensorJsTest009 success:" + JSON.stringify(data)); console.info("subscribeStepCounter_SensorJsTest009 success:" + JSON.stringify(data));
...@@ -269,7 +270,6 @@ describe("SensorJsTest", function () { ...@@ -269,7 +270,6 @@ describe("SensorJsTest", function () {
expect(code).assertEqual(1001); expect(code).assertEqual(1001);
}, },
}); });
try { try {
sensor.unsubscribeStepCounter(); sensor.unsubscribeStepCounter();
} catch (error) { } catch (error) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册