提交 d9a456ef 编写于 作者: L lidanyang16

<lidanyang16@huawei.com>

Signed-off-by: Nlidanyang16 <lidanyang16@huawei.com>
上级 15ef0a2f
...@@ -21,7 +21,10 @@ ...@@ -21,7 +21,10 @@
"power-shell wakeup", "power-shell wakeup",
"uinput -T -m 594 2117 594 864 400", "uinput -T -m 594 2117 594 864 400",
"power-shell setmode 602" "power-shell setmode 602"
] ],
"teardown-command":[
"power-shell setmode 600"
]
} }
] ]
} }
\ No newline at end of file
...@@ -21,7 +21,10 @@ ...@@ -21,7 +21,10 @@
"power-shell wakeup", "power-shell wakeup",
"uinput -T -m 594 2117 594 864 400", "uinput -T -m 594 2117 594 864 400",
"power-shell setmode 602" "power-shell setmode 602"
] ],
"teardown-command":[
"power-shell setmode 600"
]
} }
] ]
} }
\ No newline at end of file
...@@ -16,6 +16,7 @@ import SystemParameterTest from './SensorOnOffTest.test.js' ...@@ -16,6 +16,7 @@ import SystemParameterTest from './SensorOnOffTest.test.js'
import SensorJsTest_sensor_2 from './SensorGeomagneticTest.test.js' import SensorJsTest_sensor_2 from './SensorGeomagneticTest.test.js'
import SensorJsTest_sensor_1 from './SensorGeneralalgorithm.test.js' import SensorJsTest_sensor_1 from './SensorGeneralalgorithm.test.js'
import SensorJsTest_sensor_60 from './SensorOnOffTest.test_newSensorGeomagnetic.test.js' import SensorJsTest_sensor_60 from './SensorOnOffTest.test_newSensorGeomagnetic.test.js'
import SensorJsTest_sensor_38 from './SensorOnOffTest.test_newSensorGeomagneticOptions.test.js'
import SensorJsTest_sensor_35 from './SensorOnOffTest.test_newGetSensorList.test.js' import SensorJsTest_sensor_35 from './SensorOnOffTest.test_newGetSensorList.test.js'
import SensorJsTest_sensor_36 from './SensorOnOffTest.test_newGetSingleSensor.test.js' import SensorJsTest_sensor_36 from './SensorOnOffTest.test_newGetSingleSensor.test.js'
import SensorJsTest_sensor_3 from './SensorOnOffTest.test_oldAccelerometer.test.js' import SensorJsTest_sensor_3 from './SensorOnOffTest.test_oldAccelerometer.test.js'
...@@ -43,12 +44,15 @@ import SensorJsTest_sensor_8 from './SensorOnOffTest.test_oldBarometer.test.js' ...@@ -43,12 +44,15 @@ import SensorJsTest_sensor_8 from './SensorOnOffTest.test_oldBarometer.test.js'
import SensorJsTest_sensor_26 from './Subscribe_subscribeBarometer.test.js' import SensorJsTest_sensor_26 from './Subscribe_subscribeBarometer.test.js'
import SensorJsTest_sensor_57 from './SensorOnOffTest.test_newPedometer_Detection.test.js' import SensorJsTest_sensor_57 from './SensorOnOffTest.test_newPedometer_Detection.test.js'
import SensorJsTest_sensor_17 from './SensorOnOffTest.test_oldPedometer_Detection.test.js' import SensorJsTest_sensor_17 from './SensorOnOffTest.test_oldPedometer_Detection.test.js'
import SensorJsTest_sensor_56 from './SensorOnOffTest.test_newPedometer.test.js'
import SensorJsTest_sensor_18 from './SensorOnOffTest.test_oldPedometer.test.js'
export default function testsuite() { export default function testsuite() {
SystemParameterTest() SystemParameterTest()
SensorJsTest_sensor_2() SensorJsTest_sensor_2()
SensorJsTest_sensor_1() SensorJsTest_sensor_1()
SensorJsTest_sensor_60() SensorJsTest_sensor_60()
SensorJsTest_sensor_38()
SensorJsTest_sensor_35() SensorJsTest_sensor_35()
SensorJsTest_sensor_36() SensorJsTest_sensor_36()
SensorJsTest_sensor_3() SensorJsTest_sensor_3()
...@@ -76,4 +80,6 @@ export default function testsuite() { ...@@ -76,4 +80,6 @@ export default function testsuite() {
SensorJsTest_sensor_26() SensorJsTest_sensor_26()
SensorJsTest_sensor_57() SensorJsTest_sensor_57()
SensorJsTest_sensor_17() SensorJsTest_sensor_17()
SensorJsTest_sensor_56()
SensorJsTest_sensor_18()
} }
...@@ -1095,11 +1095,147 @@ describe("SensorJsTest_sensor_1", function () { ...@@ -1095,11 +1095,147 @@ describe("SensorJsTest_sensor_1", function () {
done() done()
}); });
}) })
/*
* @tc.name:SensorJsTest_111
* @tc.desc:Verification results of the incorrect parameters of the test interface.
* @tc.number:SUB_SensorsSystem_GeneralAlgorithm_JsTest_0440
*/
it("SensorJsTest_111", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('SensorJsTest_111 start')
try {
sensor.getGeomagneticDip().then((data)=>{
console.info("SensorJsTest_111 data:" + data)
expect(false).assertfalse()
done()
}, (error)=>{
console.info("SensorJsTest_111 error:" + error)
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done()
})
} catch(error) {
console.info("SensorJsTest_111 catch error:" + error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
console.info("SensorJsTest_111 end")
})
/*
* @tc.name:SensorJsTest_112
* @tc.desc:Verification results of the incorrect parameters of the test interface.
* @tc.number:SUB_SensorsSystem_GeneralAlgorithm_JsTest_0450
*/
it("SensorJsTest_112", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('SensorJsTest_112 start')
try {
sensor.getGeomagneticDip(-1).then((data)=>{
console.info("SensorJsTest_112 data:" + data)
expect(false).assertfalse()
done()
}, (error)=>{
console.info("SensorJsTest_112 error:" + error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done()
})
} catch(error) {
console.info("SensorJsTest_112 catch error:" + error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
console.info("SensorJsTest_112 end")
})
/*
* @tc.name:SensorJsTest_113
* @tc.desc:Verification results of the incorrect parameters of the test interface.
* @tc.number:SUB_SensorsSystem_GeneralAlgorithm_JsTest_0460
*/
it("SensorJsTest_113", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('SensorJsTest_113 start')
try {
sensor.getGeomagneticDip([1, 0, 0, 0, 1, 0, 0, 0, 1]).then((data)=>{
console.info("SensorJsTest_113 data:" + data)
expect(data).assertEqual(0);
done()
}, (error)=>{
console.info("SensorJsTest_113 error:" + error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done()
})
} catch(error) {
console.info("SensorJsTest_113 catch error:" + error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
console.info("SensorJsTest_113 end")
})
}) /*
* @tc.name:SensorJsTest_114
* @tc.desc:Verification results of the incorrect parameters of the test interface.
* @tc.number:SUB_SensorsSystem_GeneralAlgorithm_JsTest_0470
*/
it("SensorJsTest_114", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('SensorJsTest_114 start')
let inclinationMatrix = [
1, 0, 0, 1,
0, 1, 0, 0,
0, 0, 1, 0,
1, 0, 0, 0
]
try {
sensor.getGeomagneticDip(inclinationMatrix).then((data)=>{
console.info("SensorJsTest_114 data:" + data)
expect(data).assertEqual(0);
done()
}, (error)=>{
console.info("SensorJsTest_114 error:" + error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done()
})
} catch(error) {
console.info("SensorJsTest_114 catch error:" + error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
console.info("SensorJsTest_114 end")
})
} /*
* @tc.name:SensorJsTest_115
* @tc.desc:Verification results of the incorrect parameters of the test interface.
* @tc.number:SUB_SensorsSystem_GeneralAlgorithm_JsTest_0460
*/
it("SensorJsTest_115", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('SensorJsTest_115 start')
try {
sensor.getGeomagneticDip([1, 0, 0, 0, 1, 0, 0, 0, 1], (error, data) => {
if (error) {
console.info("SensorJsTest_115 error:" + error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done()
} else {
console.info("SensorJsTest_115 data:" + data)
expect(data).assertEqual(0);
done()
}
})
} catch(error) {
console.info("SensorJsTest_115 catch error:" + error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
console.info("SensorJsTest_115 end")
})
})}
...@@ -12,11 +12,46 @@ ...@@ -12,11 +12,46 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
import bundle from '@ohos.bundle'
import osAccount from '@ohos.account.osAccount'
import sensor from '@ohos.sensor' import sensor from '@ohos.sensor'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestType, Size, Level } from '@ohos/hypium' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestType, Size, Level } from '@ohos/hypium'
export default function SensorJsTest_sensor_56() { export default function SensorJsTest_sensor_56() {
let PermissionFlag = {
PERMISSION_USER_SET:1,
PERMISSION_USER_FIXED:2,
PERMISSION_SYSTEM_FIXED:4
}
const PERMISSION_DENIED_CODE = 201
const PARAMETER_ERROR_CODE = 401
const SERVICE_EXCEPTION_CODE = 14500101
const SERVICE_EXCEPTION_MSG = 'Service exception.'
const PARAMETER_ERROR_MSG = 'The parameter invalid.'
const PERMISSION_DENIED_MSG = 'Permission denied.'
let tokenID = undefined
let permissionNameUser = 'ohos.permission.ACTIVITY_MOTION'
async function grantPerm(){
try {
let accountManager = osAccount.getAccountManager();
let userId = await accountManager.getOsAccountLocalIdFromProcess();
console.info("SensorJsTest_sensor_56 userId:"+userId)
console.info("============SensorJsTest_sensor_56 grant Permission start ============")
var appInfo = await bundle.getApplicationInfo('ohos.acts.sensors.sensor.function', 0, userId);
tokenID = appInfo.accessTokenId;
console.log('SensorJsTest_sensor_56 accessTokenId:' + appInfo.accessTokenId + ', name:' + appInfo.name +
' ,bundleName:' + appInfo.process)
var atManager = abilityAccessCtrl.createAtManager();
var result = await atManager.grantUserGrantedPermission(tokenID, permissionNameUser,
PermissionFlag.PERMISSION_SYSTEM_FIXED)
console.info('SensorJsTest_sensor_56 successful. result: ' + JSON.stringify(result));
console.info("============SensorJsTest_sensor_56 grant Permission end ============")
} catch(error) {
console.error('SensorJsTest_sensor_56 exception in, msg:' + JSON.stringify(error))
}
}
describe("SensorJsTest_sensor_56", function () { describe("SensorJsTest_sensor_56", function () {
function callback(data) { function callback(data) {
console.info("callback" + JSON.stringify(data)); console.info("callback" + JSON.stringify(data));
...@@ -28,12 +63,13 @@ describe("SensorJsTest_sensor_56", function () { ...@@ -28,12 +63,13 @@ describe("SensorJsTest_sensor_56", function () {
expect(typeof (data.steps)).assertEqual("number"); expect(typeof (data.steps)).assertEqual("number");
} }
beforeAll(function () { beforeAll(async function(done) {
/* /*
* @tc.setup: setup invoked before all testcases * @tc.setup: setup invoked before all testcases
*/ */
console.info('beforeAll called') console.info('beforeAll called')
await grantPerm();
done();
}) })
afterAll(function () { afterAll(function () {
...@@ -42,6 +78,13 @@ describe("SensorJsTest_sensor_56", function () { ...@@ -42,6 +78,13 @@ describe("SensorJsTest_sensor_56", function () {
* @tc.teardown: teardown invoked after all testcases * @tc.teardown: teardown invoked after all testcases
*/ */
console.info('afterAll called') console.info('afterAll called')
let atManager = abilityAccessCtrl.createAtManager();
atManager.revokeUserGrantedPermission(tokenID, permissionNameUser,
PermissionFlag.PERMISSION_SYSTEM_FIXED)
.catch((error) => {
console.info('SensorJsTest_sensor_56 error:' + JSON.stringify(error));
expect(error.code).assertEqual(ERR_NOT_HAVE_PERMISSION);
})
}) })
beforeEach(function () { beforeEach(function () {
...@@ -59,236 +102,778 @@ describe("SensorJsTest_sensor_56", function () { ...@@ -59,236 +102,778 @@ describe("SensorJsTest_sensor_56", function () {
*/ */
console.info('afterEach called') console.info('afterEach called')
}) })
const PARAMETER_ERROR_CODE = 401
const PARAMETER_ERROR_MSG = 'The parameter invalid.'
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
/* /*
* @tc.number:SUB_SensorsSystem_PEDOMETER_JSTest_0120 * @tc.number:SUB_SensorsSystem_NEWPEDOMETER_JSTest_0010
* @tc.name: newPedometer_SensorJsTest012 * @tc.name: newPedometer_SensorJsTest001
* @tc.desc:Verification results of the incorrect parameters of the test interface * @tc.desc:Verification results of the incorrect parameters of the test interface
*/ */
it("newPedometer_SensorJsTest012", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { it("newPedometer_SensorJsTest001", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
console.info('--------newPedometer_SensorJsTest012--------'); console.info('----------------------newPedometer_SensorJsTest001---------------------------');
try { try {
sensor.on(sensor.SensorId.PEDOMETER, callback); sensor.getSingleSensor(sensor.SensorId.PEDOMETER, (error, data) => {
if (error) {
console.error('newPedometer_SensorJsTest001 getSingleSensor fail:' +JSON.stringify(error));
expect(false).assertTrue();
done();
}
try {
sensor.on(sensor.SensorId.PEDOMETER, callback);
setTimeout(() => {
sensor.off(sensor.SensorId.PEDOMETER);
done();
}, 4000);
} catch (error) {
console.error('newPedometer_SensorJsTest001 On fail, errorCode:' +JSON.stringify(error));
expect(false).assertTrue();
done();
}
});
} catch (error) {
console.error('newPedometer_SensorJsTest001 Sensor is not support');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number: SUB_SensorsSystem_NEWPEDOMETER_JSTest_0020
* @tc.name: newPedometer_SensorJsTest002
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("newPedometer_SensorJsTest002", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------newPedometer_SensorJsTest002---------------------------');
try {
sensor.getSingleSensor(sensor.SensorId.PEDOMETER, (error, data) => {
if (error) {
console.error('newPedometer_SensorJsTest002 getSingleSensor fail:' +JSON.stringify(error));
expect(false).assertTrue();
done();
}
try {
sensor.on(sensor.SensorId.PEDOMETER, 5);
} catch (error) {
console.error('newPedometer_SensorJsTest002 On fail, errorCode:' +JSON.stringify(error));
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
});
} catch (error) {
console.error('newPedometer_SensorJsTest002 Sensor is not support');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number: SUB_SensorsSystem_NEWPEDOMETER_JSTest_0030
* @tc.name: newPedometer_SensorJsTest003
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("newPedometer_SensorJsTest003", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------newPedometer_SensorJsTest003---------------------------');
try {
sensor.getSingleSensor(sensor.SensorId.PEDOMETER, (error, data) => {
if (error) {
console.error('newPedometer_SensorJsTest003 getSingleSensor fail:' +JSON.stringify(error));
expect(false).assertTrue();
done();
}
try {
sensor.once(sensor.SensorId.PEDOMETER, callback);
setTimeout(() => {
expect(true).assertTrue();
done();
}, 4000);
} catch (error) {
console.error('newPedometer_SensorJsTest003 Once fail, errorCode:' +JSON.stringify(error));
expect(false).assertTrue();
done();
}
});
} catch (error) {
console.error('newPedometer_SensorJsTest003 Sensor is not support');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number: SUB_SensorsSystem_NEWPEDOMETER_JSTest_0040
* @tc.name: newPedometer_SensorJsTest004
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("newPedometer_SensorJsTest004", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------newPedometer_SensorJsTest004---------------------------');
try {
sensor.getSingleSensor(sensor.SensorId.PEDOMETER, (error, data) => {
if (error) {
console.error('newPedometer_SensorJsTest004 getSingleSensor fail:' +JSON.stringify(error));
expect(false).assertTrue();
done();
}
try {
sensor.once(sensor.SensorId.PEDOMETER, callback, 5);
setTimeout(() => {
expect(true).assertTrue();
done();
}, 4000);
} catch (error) {
console.error('newPedometer_SensorJsTest004 Once fail, errorCode:' +JSON.stringify(error));
expect(false).assertTrue();
done();
}
});
} catch (error) {
console.error('newPedometer_SensorJsTest004 Sensor is not support');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number: SUB_SensorsSystem_NEWPEDOMETER_JSTest_0050
* @tc.name: newPedometer_SensorJsTest005
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("newPedometer_SensorJsTest005", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------newPedometer_SensorJsTest005---------------------------');
try {
sensor.getSingleSensor(sensor.SensorId.PEDOMETER, (error, data) => {
if (error) {
console.error('newPedometer_SensorJsTest005 getSingleSensor fail:' +JSON.stringify(error));
expect(false).assertTrue();
done();
}
try {
sensor.once(sensor.SensorId.PEDOMETER, 5);
} catch (error) {
console.error('newPedometer_SensorJsTest005 On fail, errorCode:' +JSON.stringify(error));
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
});
} catch (error) {
console.error('newPedometer_SensorJsTest005 Sensor is not support');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number: SUB_SensorsSystem_NEWPEDOMETER_JSTest_0060
* @tc.name: newPedometer_SensorJsTest006
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("newPedometer_SensorJsTest006", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------newPedometer_SensorJsTest006---------------------------');
try {
sensor.getSingleSensor(sensor.SensorId.PEDOMETER, (error, data) => {
if (error) {
console.error('newPedometer_SensorJsTest006 getSingleSensor fail:' +JSON.stringify(error));
expect(false).assertTrue();
done();
}
try {
sensor.off(-1, callback);
} catch (error) {
expect(error.code).assertEqual(PARAMETER_ERROR_CODE)
expect(error.message).assertEqual(PARAMETER_ERROR_MSG)
done();
}
});
} catch (error) {
console.error('newPedometer_SensorJsTest006 Sensor is not support');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number: SUB_SensorsSystem_NEWPEDOMETER_JSTest_0070
* @tc.name: newPedometer_SensorJsTest007
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("newPedometer_SensorJsTest007", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------newPedometer_SensorJsTest007---------------------------');
try {
sensor.getSingleSensor(sensor.SensorId.PEDOMETER, (error, data) => {
if (error) {
console.error('newPedometer_SensorJsTest007 getSingleSensor fail:' +JSON.stringify(error));
expect(false).assertTrue();
done();
}
try {
sensor.on(sensor.SensorId.PEDOMETER, callback);
sensor.on(sensor.SensorId.PEDOMETER, callback2);
setTimeout(()=>{
sensor.off(sensor.SensorId.PEDOMETER);
done();
}, 4000);
} catch (error) {
console.error('newPedometer_SensorJsTest007 On fail, errorCode:' +JSON.stringify(error));
expect(false).assertTrue();
done();
}
});
} catch (error) {
console.error('newPedometer_SensorJsTest007 Sensor is not support');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number: SUB_SensorsSystem_NEWPEDOMETER_JSTest_0080
* @tc.name: newPedometer_SensorJsTest008
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("newPedometer_SensorJsTest008", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------newPedometer_SensorJsTest008---------------------------');
try {
sensor.getSingleSensor(sensor.SensorId.PEDOMETER, (error, data) => {
if (error) {
console.error('newPedometer_SensorJsTest008 getSingleSensor fail:' +JSON.stringify(error));
expect(false).assertTrue();
done();
}
try {
sensor.on(sensor.SensorId.PEDOMETER, callback);
sensor.on(sensor.SensorId.PEDOMETER, callback2);
setTimeout(() => {
sensor.off(sensor.SensorId.PEDOMETER, callback);
}, 4000);
setTimeout(() => {
sensor.off(sensor.SensorId.PEDOMETER, callback2);
done();
}, 4000);
} catch (error) {
console.error('newPedometer_SensorJsTest008 On fail, errorCode:' +JSON.stringify(error));
expect(false).assertTrue();
done();
}
});
} catch (error) {
console.error('newPedometer_SensorJsTest008 Sensor is not support');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number: SUB_SensorsSystem_NEWPEDOMETER_JSTest_0090
* @tc.name: newPedometer_SensorJsTest009
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("newPedometer_SensorJsTest009", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------newPedometer_SensorJsTest009---------------------------');
try {
sensor.getSingleSensor(sensor.SensorId.PEDOMETER, (error, data) => {
if (error) {
console.error('newPedometer_SensorJsTest009 getSingleSensor fail:' +JSON.stringify(error));
expect(false).assertTrue();
done();
}
try {
sensor.on(sensor.SensorId.PEDOMETER, callback);
sensor.once(sensor.SensorId.PEDOMETER, callback2);
setTimeout(() => {
sensor.off(sensor.SensorId.PEDOMETER);
done();
}, 4000);
} catch (error) {
console.error('newPedometer_SensorJsTest009 On fail, errorCode:' +JSON.stringify(error));
expect(false).assertTrue();
done();
}
});
} catch (error) {
console.error('newPedometer_SensorJsTest009 Sensor is not support');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number: SUB_SensorsSystem_NEWPEDOMETER_JSTest_0100
* @tc.name: newPedometer_SensorJsTest010
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("newPedometer_SensorJsTest010", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------newPedometer_SensorJsTest010---------------------------');
try {
sensor.getSingleSensor(sensor.SensorId.PEDOMETER, (error, data) => {
if (error) {
console.error('newPedometer_SensorJsTest010 getSingleSensor fail:' +JSON.stringify(error));
expect(false).assertTrue();
done();
}
try {
sensor.on(sensor.SensorId.PEDOMETER, callback);
setTimeout(() => {
done();
}, 4000);
} catch (error) {
console.error('newPedometer_SensorJsTest010 On fail, errorCode:' +JSON.stringify(error));
expect(error.code).assertEqual(PERMISSION_DENIED_CODE);
expect(error.message).assertEqual(PERMISSION_DENIED_MSG);
done();
}
});
} catch (error) { } catch (error) {
console.info("newPedometer_SensorJsTest012 error:" + error); console.error('newPedometer_SensorJsTest010 Sensor is not support');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG); expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done(); done();
} }
setTimeout(() => { })
expect(true).assertTrue();
done(); /*
}, 500); * @tc.number: SUB_SensorsSystem_NEWPEDOMETER_JSTest_0110
* @tc.name: newPedometer_SensorJsTest011
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("newPedometer_SensorJsTest011", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('--------newPedometer_SensorJsTest011--------');
let errorMessage = ""
let errorMessages = "ReferenceError: xxx is not defined"
try {
sensor.getSingleSensor(sensor.SensorId.PEDOMETER, (error, data) => {
if (error) {
console.error('newPedometer_SensorJsTest011 getSingleSensor fail:' +JSON.stringify(error));
expect(false).assertTrue();
done();
}
try {
function onSensorCallback(data) {
console.info('newPedometer_SensorJsTest011 on error');
expect(typeof (data.steps)).assertEqual("number");
}
try {
xxx.on(sensor.SensorId.PEDOMETER, onSensorCallback);
} catch (error) {
console.info("newPedometer_SensorJsTest011 error:" + error);
errorMessage = error.toString();
expect(errorMessage).assertEqual(errorMessages);
done();
}
} catch (error) {
console.error('newPedometer_SensorJsTest011 On fail, errorCode:' +JSON.stringify(error));
expect(false).assertTrue();
done();
}
});
} catch (error) {
console.error('newPedometer_SensorJsTest011 Sensor is not support'+error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
}) })
/* /*
* @tc.number: SUB_SensorsSystem_PEDOMETER_JSTest_0130 * @tc.number:SUB_SensorsSystem_NEWPEDOMETER_JSTest_0120
* @tc.name: newPedometer_SensorJsTest012
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("newPedometer_SensorJsTest012", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('--------newPedometer_SensorJsTest012--------');
try {
sensor.getSingleSensor(sensor.SensorId.PEDOMETER, (error, data) => {
if (error) {
console.error('newPedometer_SensorJsTest012 getSingleSensor fail:' +JSON.stringify(error));
expect(false).assertTrue();
done();
}
try {
sensor.on(sensor.SensorId.PEDOMETER, callback, {'interval': 100000000});
setTimeout(() => {
sensor.off(sensor.SensorId.PEDOMETER);
done();
}, 4000);
} catch (error) {
console.error('newPedometer_SensorJsTest012 catch error:' +JSON.stringify(error));
expect(false).assertTrue();
done();
}
});
} catch (error) {
console.error('newPedometer_SensorJsTest012 Sensor is not support'+error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number:SUB_SensorsSystem_NEWPEDOMETER_JSTest_0130
* @tc.name: newPedometer_SensorJsTest013 * @tc.name: newPedometer_SensorJsTest013
* @tc.desc:Verification results of the incorrect parameters of the test interface * @tc.desc:Verification results of the incorrect parameters of the test interface
*/ */
it("newPedometer_SensorJsTest013", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { it("newPedometer_SensorJsTest013", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('--------newPedometer_SensorJsTest013--------'); console.info('--------newPedometer_SensorJsTest013--------');
try { try {
sensor.on(sensor.SensorId.PEDOMETER ,callback, { 'interval': 100000000 }); sensor.getSingleSensor(sensor.SensorId.PEDOMETER, (error, data) => {
} catch (error) { if (error) {
console.info("newPedometer_SensorJsTest013 error:" + error); console.error('newPedometer_SensorJsTest013 getSingleSensor fail:' +JSON.stringify(error));
expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(false).assertTrue();
expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done();
done(); }
} try {
sensor.on(sensor.SensorId.PEDOMETER, callback, {'interval': 100000000}, 5);
setTimeout(() => {
sensor.off(sensor.SensorId.PEDOMETER);
done();
}, 4000);
} catch (error) {
console.error('newPedometer_SensorJsTest013 On fail, errorCode:' +JSON.stringify(error));
expect(false).assertTrue();
done();
}
});
} catch (error) {
console.error('newPedometer_SensorJsTest013 Sensor is not support'+error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
}) })
/* /*
* @tc.number: SUB_SensorsSystem_PEDOMETER_JSTest_0140 * @tc.number:SUB_SensorsSystem_NEWPEDOMETER_JSTest_0140
* @tc.name: newPedometer_SensorJsTest014 * @tc.name: newPedometer_SensorJsTest014
* @tc.desc:Verification results of the incorrect parameters of the test interface * @tc.desc:Verification results of the incorrect parameters of the test interface
*/ */
it("newPedometer_SensorJsTest014", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { it("newPedometer_SensorJsTest014", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('--------newPedometer_SensorJsTest014--------'); console.info('--------newPedometer_SensorJsTest014--------');
function onSensorCallback(data) { try {
console.info('newPedometer_SensorJsTest014 on error'); sensor.getSingleSensor(sensor.SensorId.PEDOMETER, (error, data) => {
expect(typeof (data.steps)).assertEqual("number"); if (error) {
} console.error('newPedometer_SensorJsTest014 getSingleSensor fail:' +JSON.stringify(error));
try { expect(false).assertTrue();
sensor.on(sensor.SensorId.PEDOMETER, done();
onSensorCallback, { 'interval': 100000000 }, 5); }
} catch (error) { try {
console.info("newPedometer_SensorJsTest014 error:" + error); function onSensorCallback(data) {
expect(error.code).assertEqual(PARAMETER_ERROR_CODE); console.info('newPedometer_SensorJsTest014 callback:'+JSON.stringify(data));
expect(error.message).assertEqual(PARAMETER_ERROR_MSG); expect(typeof(data.steps)).assertEqual('number');
done(); }
} sensor.on(sensor.SensorId.PEDOMETER, onSensorCallback, {'interval': 100000000});
}) setTimeout(() => {
sensor.off(sensor.SensorId.PEDOMETER);
/* done();
* @tc.number: SUB_SensorsSystem_PEDOMETER_JSTest_0150 }, 4000);
} catch (error) {
console.error('newPedometer_SensorJsTest014 On fail:' +JSON.stringify(error));
expect(false).assertTrue();
done();
}
});
} catch (error) {
console.error('newPedometer_SensorJsTest014 Sensor is not support'+error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number:SUB_SensorsSystem_NEWPEDOMETER_JSTest_0150
* @tc.name: newPedometer_SensorJsTest015 * @tc.name: newPedometer_SensorJsTest015
* @tc.desc:Verification results of the incorrect parameters of the test interface * @tc.desc:Verification results of the incorrect parameters of the test interface
*/ */
it("newPedometer_SensorJsTest015", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { it("newPedometer_SensorJsTest015", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('--------newPedometer_SensorJsTest015--------'); console.info('----------------------newPedometer_SensorJsTest015---------------------------');
try{ try {
sensor.once(sensor.SensorId.PEDOMETER, callback); sensor.getSingleSensor(sensor.SensorId.PEDOMETER, (error, data) => {
} catch (error) { if (error) {
console.info("newPedometer_SensorJsTest015 error:" + error); console.error('newPedometer_SensorJsTest015 getSingleSensor fail:' +JSON.stringify(error));
expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(false).assertTrue();
expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done();
done(); }
} try {
sensor.off(sensor.SensorId.PEDOMETER,5);
} catch (error) {
console.error('newPedometer_SensorJsTest015 Off fail, errorCode:' +JSON.stringify(error));
expect(error.code).assertEqual(PARAMETER_ERROR_CODE)
expect(error.message).assertEqual(PARAMETER_ERROR_MSG)
done();
}
});
} catch (error) {
console.error('newPedometer_SensorJsTest015 Sensor is not support'+error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
}) })
/* /*
* @tc.number: SUB_SensorsSystem_PEDOMETER_JSTest_0160 * @tc.number:SUB_SensorsSystem_NEWPEDOMETER_JSTest_0160
* @tc.name: newPedometer_SensorJsTest016 * @tc.name: newPedometer_SensorJsTest016
* @tc.desc:Verification results of the incorrect parameters of the test interface * @tc.desc:Verification results of the incorrect parameters of the test interface
*/ */
it("newPedometer_SensorJsTest016", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { it("newPedometer_SensorJsTest016", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('--------newPedometer_SensorJsTest016--------'); console.info('--------newPedometer_SensorJsTest016--------');
function onceSensorCallback(data) { try {
console.info('newPedometer_SensorJsTest016 on error'); sensor.getSingleSensor(sensor.SensorId.PEDOMETER, (error, data) => {
expect(typeof (data.steps)).assertEqual("number"); if (error) {
} console.error('newPedometer_SensorJsTest016 getSingleSensor fail:' +JSON.stringify(error));
try { expect(false).assertTrue();
sensor.once(sensor.SensorId.PEDOMETER, onceSensorCallback, 5); done();
} catch (error) { }
console.info("newPedometer_SensorJsTest016 error:" + error); try {
expect(error.code).assertEqual(PARAMETER_ERROR_CODE); sensor.on(sensor.SensorId.PEDOMETER, (data)=>{
expect(error.message).assertEqual(PARAMETER_ERROR_MSG); console.info("newPedometer_SensorJsTest016 callback: " + JSON.stringify(data));
done(); expect(typeof(data.steps)).assertEqual('number');
} expect(typeof (data.timestamp)).assertEqual("number");
}) }, {'interval': 100000000});
sensor.on(sensor.SensorId.PEDOMETER, (data)=>{
console.info("newPedometer_SensorJsTest016 callback2: " + JSON.stringify(data));
expect(typeof(data.steps)).assertEqual('number');
expect(typeof (data.timestamp)).assertEqual("number");
});
setTimeout(()=>{
sensor.off(sensor.SensorId.PEDOMETER);
done();
}, 4000);
} catch (error) {
console.error('newPedometer_SensorJsTest016 Off fail, errorCode:' +JSON.stringify(error));
expect(error.code).assertEqual(PARAMETER_ERROR_CODE)
expect(error.message).assertEqual(PARAMETER_ERROR_MSG)
done();
}
});
} catch (error) {
console.error('newPedometer_SensorJsTest016 Sensor is not support'+error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/* /*
* @tc.number: SUB_SensorsSystem_PEDOMETER_JSTest_0170 * @tc.number:SUB_SensorsSystem_NEWPEDOMETER_JSTest_0170
* @tc.name: newPedometer_SensorJsTest017 * @tc.name: newPedometer_SensorJsTest017
* @tc.desc:Verification results of the incorrect parameters of the test interface * @tc.desc:Verification results of the incorrect parameters of the test interface
*/ */
it("newPedometer_SensorJsTest017", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { it("newPedometer_SensorJsTest017", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('--------newPedometer_SensorJsTest017--------'); console.info('--------newPedometer_SensorJsTest017--------');
try { try {
sensor.off(string, ""); sensor.getSingleSensor(sensor.SensorId.PEDOMETER, (error, data) => {
} catch (error) { if (error) {
errMessage console.error('newPedometer_SensorJsTest017 getSingleSensor fail:' +JSON.stringify(error));
console.info("newPedometer_SensorJsTest017 error:" + error); expect(false).assertTrue();
errMessage = error.toString(); done();
expect(errMessage).assertEqual(errMessages[0]); }
done(); try {
} sensor.on(sensor.SensorId.PEDOMETER, (data)=>{
console.info("newPedometer_SensorJsTest017 callback: " + JSON.stringify(data));
expect(typeof(data.steps)).assertEqual('number');
expect(typeof (data.timestamp)).assertEqual("number");
}, {'interval': -100000000});
} catch (error) {
console.error('newPedometer_SensorJsTest017 On fail, errorCode:' +JSON.stringify(error));
expect(error.code).assertEqual(SERVICE_EXCEPTION_CODE);
expect(error.message).assertEqual(SERVICE_EXCEPTION_MSG);
done();
}
});
} catch (error) {
console.error('newPedometer_SensorJsTest017 Sensor is not support'+error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
}) })
/* /*
* @tc.number: SUB_SensorsSystem_PEDOMETER_JSTest_0180 * @tc.number:SUB_SensorsSystem_NEWPEDOMETER_JSTest_0180
* @tc.name: newPedometer_SensorJsTest018 * @tc.name: newPedometer_SensorJsTest018
* @tc.desc:Verification results of the incorrect parameters of the test interface * @tc.desc:Verification results of the incorrect parameters of the test interface
*/ */
it("newPedometer_SensorJsTest018", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { it("newPedometer_SensorJsTest018", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
console.info('--------newPedometer_SensorJsTest018--------'); console.info('----------------------newPedometer_SensorJsTest018---------------------------');
function onSensorCallback(data) { try {
console.info('newPedometer_SensorJsTest018 on error'); sensor.getSingleSensor(sensor.SensorId.PEDOMETER, (error, data) => {
expect(typeof (data.steps)).assertEqual("number"); if (error) {
} console.error('newPedometer_SensorJsTest018 getSingleSensor fail:' +JSON.stringify(error));
try { expect(false).assertTrue();
sensor.on(sensor.SensorId.PEDOMETER, onSensorCallback); done();
sensor.off(sensor.SensorId.PEDOMETER); }
try {
sensor.on(sensor.SensorId.PEDOMETER, callback, { 'interval': undefined });
setTimeout(() => {
sensor.off(sensor.SensorId.PEDOMETER);
done();
}, 4000);
} catch (error) {
console.error('newPedometer_SensorJsTest018 On fail, errorCode:' +JSON.stringify(error));
expect(false).assertTrue();
done();
}
});
} catch (error) { } catch (error) {
console.info("newPedometer_SensorJsTest018 error:" + error); console.error('newPedometer_SensorJsTest018 Sensor is not support');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG); expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done(); done();
} }
}) })
/* /*
* @tc.number: SUB_SensorsSystem_PEDOMETER_JSTest_0190 * @tc.number: SUB_SensorsSystem_NEWPEDOMETER_JSTest_0190
* @tc.name: newPedometer_SensorJsTest019 * @tc.name: newPedometer_SensorJsTest019
* @tc.desc:Verification results of the incorrect parameters of the test interface * @tc.desc:Verification results of the incorrect parameters of the test interface
*/ */
it("newPedometer_SensorJsTest019", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { it("newPedometer_SensorJsTest019", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('--------newPedometer_SensorJsTest019--------'); console.info('----------------------newPedometer_SensorJsTest019---------------------------');
function onSensorCallback(data) { try {
console.info('newPedometer_SensorJsTest019 on error'); sensor.getSingleSensor(sensor.SensorId.PEDOMETER, (error, data) => {
expect(typeof (data.steps)).assertEqual("number"); if (error) {
} console.error('newPedometer_SensorJsTest019 getSingleSensor fail:' +JSON.stringify(error));
try { expect(false).assertTrue();
sensor.off(1000000, onSensorCallback); done();
} catch (error) { }
console.info("newPedometer_SensorJsTest019 error:" + error); try {
expect(error.code).assertEqual(PARAMETER_ERROR_CODE); sensor.on(sensor.SensorId.PEDOMETER, callback, { 'interval': undefined });
expect(error.message).assertEqual(PARAMETER_ERROR_MSG); sensor.on(sensor.SensorId.PEDOMETER, callback2, { 'interval': undefined });
done(); setTimeout(()=>{
} sensor.off(sensor.SensorId.PEDOMETER);
done();
}, 4000);
} catch (error) {
console.error('newPedometer_SensorJsTest019 On fail, errorCode:' +JSON.stringify(error));
expect(false).assertTrue();
done();
}
});
} catch (error) {
console.error('newPedometer_SensorJsTest019 Sensor is not support');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
}) })
/* /*
* @tc.number: SUB_SensorsSystem_PEDOMETER_JSTest_0200 * @tc.number: SUB_SensorsSystem_NEWPEDOMETER_JSTest_0200
* @tc.name: newPedometer_SensorJsTest020 * @tc.name: newPedometer_SensorJsTest020
* @tc.desc:Verification results of the incorrect parameters of the test interface * @tc.desc:Verification results of the incorrect parameters of the test interface
*/ */
it("newPedometer_SensorJsTest020", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { it("newPedometer_SensorJsTest020", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('--------newPedometer_SensorJsTest020--------'); console.info('----------------------newPedometer_SensorJsTest020---------------------------');
function onSensorCallback(data) { try {
console.info('newPedometer_SensorJsTest020 on error'); sensor.getSingleSensor(sensor.SensorId.PEDOMETER, (error, data) => {
expect(typeof (data.steps)).assertEqual("number"); if (error) {
} console.error('newPedometer_SensorJsTest020 getSingleSensor fail:' +JSON.stringify(error));
try { expect(false).assertTrue();
sensor.off(invalid, onSensorCallback); done();
} catch (error) { }
console.info("newPedometer_SensorJsTest020 error:" + error); try {
expect(error.code).assertEqual(PARAMETER_ERROR_CODE); sensor.on(sensor.SensorId.PEDOMETER, callback, { 'interval': null });
expect(error.message).assertEqual(PARAMETER_ERROR_MSG); sensor.on(sensor.SensorId.PEDOMETER, callback2, { 'interval': null });
done(); setTimeout(() => {
} sensor.off(sensor.SensorId.PEDOMETER, callback);
}, 4000);
setTimeout(() => {
sensor.off(sensor.SensorId.PEDOMETER, callback2);
done();
}, 4000);
} catch (error) {
console.error('newPedometer_SensorJsTest020 On fail, errorCode:' +JSON.stringify(error));
expect(false).assertTrue();
done();
}
});
} catch (error) {
console.error('newPedometer_SensorJsTest020 Sensor is not support');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
}) })
/* /*
* @tc.number: SUB_SensorsSystem_PEDOMETER_JSTest_0210 * @tc.number: SUB_SensorsSystem_NEWPEDOMETER_JSTest_0210
* @tc.name: newPedometer_SensorJsTest021 * @tc.name: newPedometer_SensorJsTest021
* @tc.desc:Verification results of the incorrect parameters of the test interface * @tc.desc:Verification results of the incorrect parameters of the test interface
*/ */
it("newPedometer_SensorJsTest021", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { it("newPedometer_SensorJsTest021", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('--------newPedometer_SensorJsTest021--------'); console.info('----------------------newPedometer_SensorJsTest021---------------------------');
function onSensorCallback(data) { try {
console.info('newPedometer_SensorJsTest021 on error'); sensor.getSingleSensor(sensor.SensorId.PEDOMETER, (error, data) => {
expect(typeof (data.steps)).assertEqual("number"); if (error) {
} console.error('newPedometer_SensorJsTest021 getSingleSensor fail:' +JSON.stringify(error));
try { expect(false).assertTrue();
sensor.xxx(sensor.SensorId.PEDOMETER, onSensorCallback); done();
} catch (error) { }
console.info("newPedometer_SensorJsTest021 error:" + error); try {
errMessage = error.toString(); sensor.on(sensor.SensorId.PEDOMETER, callback);
expect(errMessage).assertEqual(errMessages[1]); try{
done(); sensor.on(sensor.SensorId.PEDOMETER, callback, undefined);
} } catch(error){
console.info('newPedometer_SensorJsTest021 Repeat subscription'+error);
}
setTimeout(() => {
sensor.off(sensor.SensorId.PEDOMETER);
done();
}, 4000);
} catch (error) {
console.error('newPedometer_SensorJsTest021 On fail, errorCode:' +JSON.stringify(error));
expect(false).assertTrue();
done();
}
});
} catch (error) {
console.error('newPedometer_SensorJsTest021 Sensor is not support');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
}) })
/* /*
* @tc.number: SUB_SensorsSystem_PEDOMETER_JSTest_0220 * @tc.number: SUB_SensorsSystem_NEWPEDOMETER_JSTest_0220
* @tc.name: newPedometer_SensorJsTest022 * @tc.name: newPedometer_SensorJsTest022
* @tc.desc:Verification results of the incorrect parameters of the test interface * @tc.desc:Verification results of the incorrect parameters of the test interface
*/ */
it("newPedometer_SensorJsTest022", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { it("newPedometer_SensorJsTest022", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('--------newPedometer_SensorJsTest022--------'); try {
function onSensorCallback(data) { sensor.getSingleSensor(sensor.SensorId.PEDOMETER, (error, data) => {
console.info('newPedometer_SensorJsTest022 on error'); if (error) {
expect(typeof (data.steps)).assertEqual("number"); console.error('newPedometer_SensorJsTest022 getSingleSensor fail:' +JSON.stringify(error));
} expect(false).assertTrue();
try { done();
xxx.on(sensor.SensorId.PEDOMETER, onSensorCallback); }
} catch (error) { try {
console.info("newPedometer_SensorJsTest022 error:" + error); sensor.on(sensor.SensorId.PEDOMETER, callback);
errMessage = error.toString(); setTimeout(() => {
expect(errMessage).assertEqual(errMessages[2]); sensor.off(sensor.SensorId.PEDOMETER, null);
done(); done();
} }, 4000);
} catch (error) {
console.error('newPedometer_SensorJsTest022 catch error:' +JSON.stringify(error));
expect(false).assertTrue();
done();
}
});
} catch (error) {
console.error('newPedometer_SensorJsTest022 Sensor is not support'+error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
}) })
}) })}
}
...@@ -75,13 +75,12 @@ describe("SensorJsTest_sensor_38", function () { ...@@ -75,13 +75,12 @@ describe("SensorJsTest_sensor_38", function () {
let timeMillis = [1580486400000, 1612108800000, 1643644800000, 1675180800000, 1706716800000] let timeMillis = [1580486400000, 1612108800000, 1643644800000, 1675180800000, 1706716800000]
/* /*
* @tc.name:Sensor_GetGeomagneticField_058 * @tc.name:SensorJsTest_001
* @tc.desc:verify app info is not null * @tc.desc:Verification results of the incorrect parameters of the test interface.
* @tc.type: FUNC * @tc.number:SUB_SensorsSystem_GeneralAlgorithm_JsTest_0470
* @tc.require: I5SWJI
*/ */
it("Sensor_GetGeomagneticInfo_058", 0, async function (done) { it("SensorJsTest_001", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info("---------------------------Sensor_GetGeomagneticInfo_058----------------------------------"); console.info("---------------------------SensorJsTest_001----------------------------------");
for (let i = 0; i < timeMillis.length; i++) { for (let i = 0; i < timeMillis.length; i++) {
await sensor.getGeomagneticInfo({'latitude':80, 'longitude':0, 'altitude':0}, timeMillis[i], undefined).then((data) => { await sensor.getGeomagneticInfo({'latitude':80, 'longitude':0, 'altitude':0}, timeMillis[i], undefined).then((data) => {
console.info('Sensor_GetGeomagneticField_058 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + ',geomagneticDip: ' + data.geomagneticDip console.info('Sensor_GetGeomagneticField_058 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + ',geomagneticDip: ' + data.geomagneticDip
...@@ -94,23 +93,22 @@ describe("SensorJsTest_sensor_38", function () { ...@@ -94,23 +93,22 @@ describe("SensorJsTest_sensor_38", function () {
expect(Math.abs(data.levelIntensity - GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][5]) < EPS).assertTrue() expect(Math.abs(data.levelIntensity - GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][5]) < EPS).assertTrue()
expect(Math.abs(data.totalIntensity - GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][6]) < EPS).assertTrue() expect(Math.abs(data.totalIntensity - GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][6]) < EPS).assertTrue()
}).catch((error) => { }).catch((error) => {
console.info("Sensor_GetGeomagneticInfo_058 promise::catch", error); console.info("SensorJsTest_001 promise::catch", error);
}) })
} }
done() done()
}) })
/* /*
* @tc.name:Sensor_GetGeomagneticInfo_058 * @tc.name:SensorJsTest_002
* @tc.desc:verify app info is not null * @tc.desc:Verification results of the incorrect parameters of the test interface.
* @tc.type: FUNC * @tc.number:SUB_SensorsSystem_GeneralAlgorithm_JsTest_0480
* @tc.require: I5SWJI
*/ */
it("Sensor_GetGeomagneticInfo_059", 0, async function (done) { it("SensorJsTest_002", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info("---------------------------Sensor_GetGeomagneticInfo_059----------------------------------"); console.info("---------------------------SensorJsTest_002----------------------------------");
for (let i = 0; i < timeMillis.length; i++) { for (let i = 0; i < timeMillis.length; i++) {
await sensor.getGeomagneticInfo({'latitude':80, 'longitude':0, 'altitude':0}, timeMillis[i], null).then((data) => { await sensor.getGeomagneticInfo({'latitude':80, 'longitude':0, 'altitude':0}, timeMillis[i], null).then((data) => {
console.info('Sensor_GetGeomagneticInfo_059 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + ',geomagneticDip: ' + data.geomagneticDip console.info('SensorJsTest_002 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + ',geomagneticDip: ' + data.geomagneticDip
+ ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity); + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity);
expect(Math.abs(data.x - GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][0]) < EPS).assertTrue() expect(Math.abs(data.x - GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][0]) < EPS).assertTrue()
expect(Math.abs(data.y - GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][1]) < EPS).assertTrue() expect(Math.abs(data.y - GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][1]) < EPS).assertTrue()
...@@ -120,23 +118,22 @@ describe("SensorJsTest_sensor_38", function () { ...@@ -120,23 +118,22 @@ describe("SensorJsTest_sensor_38", function () {
expect(Math.abs(data.levelIntensity - GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][5]) < EPS).assertTrue() expect(Math.abs(data.levelIntensity - GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][5]) < EPS).assertTrue()
expect(Math.abs(data.totalIntensity - GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][6]) < EPS).assertTrue() expect(Math.abs(data.totalIntensity - GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][6]) < EPS).assertTrue()
}).catch((error) => { }).catch((error) => {
console.info("promise::catch", error); console.info("SensorJsTest_002 promise::catch", error);
}) })
} }
done() done()
}) })
/* /*
* @tc.name:Sensor_GetGeomagneticInfo_060 * @tc.name:SensorJsTest_003
* @tc.desc:verify app info is not null * @tc.desc:Verification results of the incorrect parameters of the test interface.
* @tc.type: FUNC * @tc.number:SUB_SensorsSystem_GeneralAlgorithm_JsTest_0490
* @tc.require: I5SWJI
*/ */
it("Sensor_GetGeomagneticInfo_060", 0, async function (done) { it("SensorJsTest_003", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info("---------------------------Sensor_GetGeomagneticInfo_060----------------------------------"); console.info("---------------------------SensorJsTest_003----------------------------------");
for (let i = 0; i < timeMillis.length; i++) { for (let i = 0; i < timeMillis.length; i++) {
await sensor.getGeomagneticInfo({'latitude':80, 'longitude':0, 'altitude':0}, timeMillis[i], "abc").then((data) => { await sensor.getGeomagneticInfo({'latitude':80, 'longitude':0, 'altitude':0}, timeMillis[i], "abc").then((data) => {
console.info('Sensor_GetGeomagneticInfo_060 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + ',geomagneticDip: ' + data.geomagneticDip console.info('SensorJsTest_003 x: ' + data.x + ',y: ' + data.y + ',z: ' + data.z + ',geomagneticDip: ' + data.geomagneticDip
+ ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity); + ',deflectionAngle: ' + data.deflectionAngle + ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity);
expect(Math.abs(data.x - GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][0]) < EPS).assertTrue() expect(Math.abs(data.x - GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][0]) < EPS).assertTrue()
expect(Math.abs(data.y - GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][1]) < EPS).assertTrue() expect(Math.abs(data.y - GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][1]) < EPS).assertTrue()
...@@ -146,7 +143,7 @@ describe("SensorJsTest_sensor_38", function () { ...@@ -146,7 +143,7 @@ describe("SensorJsTest_sensor_38", function () {
expect(Math.abs(data.levelIntensity - GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][5]) < EPS).assertTrue() expect(Math.abs(data.levelIntensity - GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][5]) < EPS).assertTrue()
expect(Math.abs(data.totalIntensity - GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][6]) < EPS).assertTrue() expect(Math.abs(data.totalIntensity - GEOMAGNETIC_COMPONENT_YEAR_RESULT[i][6]) < EPS).assertTrue()
}).catch((error) => { }).catch((error) => {
console.info("promise::catch", error); console.info("SensorJsTest_003 promise::catch", error);
}) })
} }
done() done()
...@@ -217,14 +214,13 @@ describe("SensorJsTest_sensor_38", function () { ...@@ -217,14 +214,13 @@ describe("SensorJsTest_sensor_38", function () {
] ]
/* /*
* tc.name: Sensor_CreateRotationMatrix_015 * @tc.name:SensorJsTest_004
* tc.desc: Verification results of the incorrect parameters of test interface. * @tc.desc:Verification results of the incorrect parameters of the test interface.
* tc.require: I5SWJI * @tc.number:SUB_SensorsSystem_GeneralAlgorithm_JsTest_0500
* @tc.author: */
*/ it("SensorJsTest_004", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
it('Sensor_CreateRotationMatrix_015', 0, async function (done) {
sensor.getRotationMatrix(gravity[0], geomagnetic[0], undefined).then((data) => { sensor.getRotationMatrix(gravity[0], geomagnetic[0], undefined).then((data) => {
console.info("Sensor_CreateRotationMatrix_015" + JSON.stringify(data)) console.info("SensorJsTest_004" + JSON.stringify(data))
expect(JSON.stringify(data)).assertEqual(JSON.stringify(SENSOR_DATA_MATRIX[0])) expect(JSON.stringify(data)).assertEqual(JSON.stringify(SENSOR_DATA_MATRIX[0]))
done() done()
}, (error) => { }, (error) => {
...@@ -234,14 +230,13 @@ describe("SensorJsTest_sensor_38", function () { ...@@ -234,14 +230,13 @@ describe("SensorJsTest_sensor_38", function () {
}) })
/* /*
* tc.name: Sensor_CreateRotationMatrix_016 * @tc.name:SensorJsTest_005
* tc.desc: Verification results of the incorrect parameters of test interface. * @tc.desc:Verification results of the incorrect parameters of the test interface.
* tc.require: I5SWJI * @tc.number:SUB_SensorsSystem_GeneralAlgorithm_JsTest_0510
* @tc.author: */
*/ it("SensorJsTest_005", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
it('Sensor_CreateRotationMatrix_016', 0, async function (done) {
sensor.getRotationMatrix(gravity[0], geomagnetic[0], null).then((data) => { sensor.getRotationMatrix(gravity[0], geomagnetic[0], null).then((data) => {
console.info("Sensor_CreateRotationMatrix_016" + JSON.stringify(data)) console.info("SensorJsTest_005" + JSON.stringify(data))
expect(JSON.stringify(data)).assertEqual(JSON.stringify(SENSOR_DATA_MATRIX[0])) expect(JSON.stringify(data)).assertEqual(JSON.stringify(SENSOR_DATA_MATRIX[0]))
done() done()
}, (error) => { }, (error) => {
...@@ -251,15 +246,14 @@ describe("SensorJsTest_sensor_38", function () { ...@@ -251,15 +246,14 @@ describe("SensorJsTest_sensor_38", function () {
}) })
/* /*
* tc.name: Sensor_CreateRotationMatrix_017 * @tc.name:SensorJsTest_006
* tc.desc: Verification results of the incorrect parameters of test interface. * @tc.desc:Verification results of the incorrect parameters of the test interface.
* tc.require: I5SWJI * @tc.number:SUB_SensorsSystem_GeneralAlgorithm_JsTest_0520
* @tc.author: */
*/ it("SensorJsTest_006", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
it('Sensor_CreateRotationMatrix_017', 0, async function (done) {
sensor.getRotationMatrix([0, 0, 0], undefined).then((data) => { sensor.getRotationMatrix([0, 0, 0], undefined).then((data) => {
for(let i = 0; i < data.length; i++) { for(let i = 0; i < data.length; i++) {
console.info("Sensor_CreateRotationMatrix_017 [" + i + "] : " + data[i]); console.info("SensorJsTest_006 [" + i + "] : " + data[i]);
expect(data[i]).assertEqual(createRotationMatrixResult[1][i]) expect(data[i]).assertEqual(createRotationMatrixResult[1][i])
} }
done() done()
...@@ -270,15 +264,14 @@ describe("SensorJsTest_sensor_38", function () { ...@@ -270,15 +264,14 @@ describe("SensorJsTest_sensor_38", function () {
}) })
/* /*
* tc.name: Sensor_CreateRotationMatrix_018 * @tc.name:SensorJsTest_007
* tc.desc: Verification results of the incorrect parameters of test interface. * @tc.desc:Verification results of the incorrect parameters of the test interface.
* tc.require: I5SWJI * @tc.number:SUB_SensorsSystem_GeneralAlgorithm_JsTest_0530
* @tc.author: */
*/ it("SensorJsTest_007", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
it('Sensor_CreateRotationMatrix_018', 0, async function (done) {
sensor.getRotationMatrix([0, 0, 0], null).then((data) => { sensor.getRotationMatrix([0, 0, 0], null).then((data) => {
for(let i = 0; i < data.length; i++) { for(let i = 0; i < data.length; i++) {
console.info("Sensor_CreateRotationMatrix_018 [" + i + "] : " + data[i]); console.info("SensorJsTest_007 [" + i + "] : " + data[i]);
expect(data[i]).assertEqual(createRotationMatrixResult[1][i]) expect(data[i]).assertEqual(createRotationMatrixResult[1][i])
} }
done() done()
...@@ -288,18 +281,15 @@ describe("SensorJsTest_sensor_38", function () { ...@@ -288,18 +281,15 @@ describe("SensorJsTest_sensor_38", function () {
}) })
}) })
/** /*
* test * @tc.name:SensorJsTest_008
* * @tc.desc:Verification results of the incorrect parameters of the test interface.
* @tc.name: Sensor_GetDirection_011 * @tc.number:SUB_SensorsSystem_GeneralAlgorithm_JsTest_0540
* @tc.desc: Verification results of the incorrect parameters of the test interface.
* @tc.require: I5SWJI
* @tc.author:
*/ */
it('Sensor_GetDirection_011', 0, async function (done) { it("SensorJsTest_008", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
sensor.getOrientation(rotationMatrix[0], undefined).then((data) => { sensor.getOrientation(rotationMatrix[0], undefined).then((data) => {
for (let i = 0; i < data.length; i++) { for (let i = 0; i < data.length; i++) {
console.info("Sensor_GetDirection_011" + data[i]) console.info("SensorJsTest_008" + data[i])
expect(data[i]).assertEqual(GET_DIRECTION[0][i]) expect(data[i]).assertEqual(GET_DIRECTION[0][i])
} }
done() done()
...@@ -309,18 +299,15 @@ describe("SensorJsTest_sensor_38", function () { ...@@ -309,18 +299,15 @@ describe("SensorJsTest_sensor_38", function () {
}) })
}) })
/** /*
* test * @tc.name:SensorJsTest_009
* * @tc.desc:Verification results of the incorrect parameters of the test interface.
* @tc.name: Sensor_GetDirection_012 * @tc.number:SUB_SensorsSystem_GeneralAlgorithm_JsTest_0550
* @tc.desc: Verification results of the incorrect parameters of the test interface.
* @tc.require: I5SWJI
* @tc.author:
*/ */
it('Sensor_GetDirection_012', 0, async function (done) { it("SensorJsTest_009", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
sensor.getOrientation(rotationMatrix[0], null).then((data) => { sensor.getOrientation(rotationMatrix[0], null).then((data) => {
for (let i = 0; i < data.length; i++) { for (let i = 0; i < data.length; i++) {
console.info("Sensor_GetDirection_012" + data[i]) console.info("SensorJsTest_009" + data[i])
expect(data[i]).assertEqual(GET_DIRECTION[0][i]) expect(data[i]).assertEqual(GET_DIRECTION[0][i])
} }
done() done()
...@@ -338,16 +325,15 @@ describe("SensorJsTest_sensor_38", function () { ...@@ -338,16 +325,15 @@ describe("SensorJsTest_sensor_38", function () {
]; ];
/* /*
* @tc.name:Sensor_GetAngleModify_017 * @tc.name:SensorJsTest_010
* @tc.desc:verify app info is not null * @tc.desc:Verification results of the incorrect parameters of the test interface.
* @tc.type: FUNC * @tc.number:SUB_SensorsSystem_GeneralAlgorithm_JsTest_0560
* @tc.require: I5SWJI
*/ */
it('Sensor_GetAngleModify_017', 0, async function (done) { it("SensorJsTest_010", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------Sensor_GetAngleModify_017---------------------------'); console.info('----------------------SensorJsTest_010---------------------------');
sensor.getAngleVariation([1,2,3,1,2,3,1,2,3], [2,2,2,2,2,2,2,2,2], undefined).then((data) => { sensor.getAngleVariation([1,2,3,1,2,3,1,2,3], [2,2,2,2,2,2,2,2,2], undefined).then((data) => {
for(let i = 0; i < data.length; i++) { for(let i = 0; i < data.length; i++) {
console.info("Sensor_GetAngleModify_017 [" + i + "] = " + data[i]); console.info("SensorJsTest_010 [" + i + "] = " + data[i]);
expect(data[0]).assertEqual(ANGLECHANGE_9_RESULT[0][0]) && expect(Number.isNaN(data[1])).assertTrue() && expect(data[0]).assertEqual(ANGLECHANGE_9_RESULT[0][0]) && expect(Number.isNaN(data[1])).assertTrue() &&
expect(data[2]).assertEqual(ANGLECHANGE_9_RESULT[0][2]); expect(data[2]).assertEqual(ANGLECHANGE_9_RESULT[0][2]);
} }
...@@ -359,16 +345,15 @@ describe("SensorJsTest_sensor_38", function () { ...@@ -359,16 +345,15 @@ describe("SensorJsTest_sensor_38", function () {
}) })
/* /*
* @tc.name:Sensor_GetAngleModify_018 * @tc.name:SensorJsTest_011
* @tc.desc:verify app info is not null * @tc.desc:Verification results of the incorrect parameters of the test interface.
* @tc.type: FUNC * @tc.number:SUB_SensorsSystem_GeneralAlgorithm_JsTest_0570
* @tc.require: I5SWJI
*/ */
it('Sensor_GetAngleModify_018', 0, async function (done) { it("SensorJsTest_011", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------Sensor_GetAngleModify_018---------------------------'); console.info('----------------------SensorJsTest_011---------------------------');
sensor.getAngleVariation([1,2,3,1,2,3,1,2,3], [2,2,2,2,2,2,2,2,2], null).then((data) => { sensor.getAngleVariation([1,2,3,1,2,3,1,2,3], [2,2,2,2,2,2,2,2,2], null).then((data) => {
for(let i = 0; i < data.length; i++) { for(let i = 0; i < data.length; i++) {
console.info("Sensor_GetAngleModify_018 [" + i + "] = " + data[i]); console.info("SensorJsTest_011 [" + i + "] = " + data[i]);
expect(data[0]).assertEqual(ANGLECHANGE_9_RESULT[0][0]) && expect(Number.isNaN(data[1])).assertTrue() && expect(data[0]).assertEqual(ANGLECHANGE_9_RESULT[0][0]) && expect(Number.isNaN(data[1])).assertTrue() &&
expect(data[2]).assertEqual(ANGLECHANGE_9_RESULT[0][2]); expect(data[2]).assertEqual(ANGLECHANGE_9_RESULT[0][2]);
} }
...@@ -380,16 +365,15 @@ describe("SensorJsTest_sensor_38", function () { ...@@ -380,16 +365,15 @@ describe("SensorJsTest_sensor_38", function () {
}) })
/* /*
* @tc.name:Sensor_GetAngleModify_019 * @tc.name:SensorJsTest_012
* @tc.desc:verify app info is not null * @tc.desc:Verification results of the incorrect parameters of the test interface.
* @tc.type: FUNC * @tc.number:SUB_SensorsSystem_GeneralAlgorithm_JsTest_0580
* @tc.require: I5SWJI
*/ */
it('Sensor_GetAngleModify_019', 0, async function (done) { it("SensorJsTest_012", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------Sensor_GetAngleModify_019---------------------------'); console.info('----------------------SensorJsTest_012---------------------------');
sensor.getAngleVariation([1,2,3,1,2,3,1,2,3], [2,2,2,2,2,2,2,2,2], null).then((data) => { sensor.getAngleVariation([1,2,3,1,2,3,1,2,3], [2,2,2,2,2,2,2,2,2], null).then((data) => {
for(let i = 0; i < data.length; i++) { for(let i = 0; i < data.length; i++) {
console.info("Sensor_GetAngleModify_019 [" + i + "] = " + data[i]); console.info("SensorJsTest_012 [" + i + "] = " + data[i]);
expect(data[0]).assertEqual(ANGLECHANGE_9_RESULT[0][0]) && expect(Number.isNaN(data[1])).assertTrue() && expect(data[0]).assertEqual(ANGLECHANGE_9_RESULT[0][0]) && expect(Number.isNaN(data[1])).assertTrue() &&
expect(data[2]).assertEqual(ANGLECHANGE_9_RESULT[0][2]); expect(data[2]).assertEqual(ANGLECHANGE_9_RESULT[0][2]);
} }
...@@ -409,16 +393,13 @@ describe("SensorJsTest_sensor_38", function () { ...@@ -409,16 +393,13 @@ describe("SensorJsTest_sensor_38", function () {
]; ];
/* /*
* test * @tc.name:SensorJsTest_013
* * @tc.desc:Verification results of the incorrect parameters of the test interface.
* @tc.name: Sensor_CreateQuaternion_016 * @tc.number:SUB_SensorsSystem_GeneralAlgorithm_JsTest_0590
* @tc.desc: Verification results of the incorrect parameters of the test interface.
* @tc.require: I5SWJI
* @tc.author:
*/ */
it('Sensor_CreateQuaternion_016', 0, async function (done) { it("SensorJsTest_013", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
sensor.getQuaternion([0.52, -0.336, -0.251], undefined).then((data) => { sensor.getQuaternion([0.52, -0.336, -0.251], undefined).then((data) => {
console.info('Sensor_CreateQuaternion_016'); console.info('SensorJsTest_013 data:' +data);
for (let i = 0; i < data.length; i++) { for (let i = 0; i < data.length; i++) {
console.info("data[" + i + "]: " + data[i]); console.info("data[" + i + "]: " + data[i]);
expect(data[i]).assertEqual(result[0][i]) expect(data[i]).assertEqual(result[0][i])
...@@ -431,16 +412,13 @@ describe("SensorJsTest_sensor_38", function () { ...@@ -431,16 +412,13 @@ describe("SensorJsTest_sensor_38", function () {
}) })
/* /*
* test * @tc.name:SensorJsTest_014
* * @tc.desc:Verification results of the incorrect parameters of the test interface.
* @tc.name: Sensor_CreateQuaternion_017 * @tc.number:SUB_SensorsSystem_GeneralAlgorithm_JsTest_0600
* @tc.desc: Verification results of the incorrect parameters of the test interface.
* @tc.require: I5SWJI
* @tc.author:
*/ */
it('Sensor_CreateQuaternion_017', 0, async function (done) { it("SensorJsTest_014", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
sensor.getQuaternion([0.52, -0.336, -0.251], null).then((data) => { sensor.getQuaternion([0.52, -0.336, -0.251], null).then((data) => {
console.info('Sensor_CreateQuaternion_017'); console.info('SensorJsTest_014 data:'+data);
for (let i = 0; i < data.length; i++) { for (let i = 0; i < data.length; i++) {
console.info("data[" + i + "]: " + data[i]); console.info("data[" + i + "]: " + data[i]);
expect(data[i]).assertEqual(result[0][i]) expect(data[i]).assertEqual(result[0][i])
...@@ -455,90 +433,85 @@ describe("SensorJsTest_sensor_38", function () { ...@@ -455,90 +433,85 @@ describe("SensorJsTest_sensor_38", function () {
const getGeomagneticDipResult = [ 0.8760581016540527, 0.862170, -Infinity, 44330]; const getGeomagneticDipResult = [ 0.8760581016540527, 0.862170, -Infinity, 44330];
/* /*
* @tc.name: Sensor_GetGeomagneticDip_008 * @tc.name:SensorJsTest_015
* @tc.desc: Verification results of the incorrect parameters of test interface. * @tc.desc:Verification results of the incorrect parameters of the test interface.
* @tc.require: I5SWJI * @tc.number:SUB_SensorsSystem_GeneralAlgorithm_JsTest_0610
* @tc.author: */
*/ it("SensorJsTest_015", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
it('Sensor_GetGeomagneticDip_008', 0, async function (done) {
sensor.getInclination([1, 2, 3, 4, 5, 6, 7, 8, 9], undefined).then((data) => { sensor.getInclination([1, 2, 3, 4, 5, 6, 7, 8, 9], undefined).then((data) => {
console.info("Sensor_GetGeomagneticDip_008" + data) console.info("SensorJsTest_015" + data)
expect(data).assertEqual(getGeomagneticDipResult[0]) expect(data).assertEqual(getGeomagneticDipResult[0])
done() done()
}, (error) => { }, (error) => {
console.info('Sensor_GetGeomagneticDip_008 failed'); console.info('SensorJsTest_015 failed');
expect(false).assertTrue(); expect(false).assertTrue();
done() done()
}); });
}) })
/* /*
* @tc.name: Sensor_GetGeomagneticDip_009 * @tc.name:SensorJsTest_016
* @tc.desc: Verification results of the incorrect parameters of test interface. * @tc.desc:Verification results of the incorrect parameters of the test interface.
* @tc.require: I5SWJI * @tc.number:SUB_SensorsSystem_GeneralAlgorithm_JsTest_0620
* @tc.author: */
*/ it("SensorJsTest_016", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
it('Sensor_GetGeomagneticDip_009', 0, async function (done) {
sensor.getInclination([1, 2, 3, 4, 5, 6, 7, 8, 9], null).then((data) => { sensor.getInclination([1, 2, 3, 4, 5, 6, 7, 8, 9], null).then((data) => {
console.info("Sensor_GetGeomagneticDip_009" + data) console.info("SensorJsTest_016" + data)
expect(data).assertEqual(getGeomagneticDipResult[0]) expect(data).assertEqual(getGeomagneticDipResult[0])
done() done()
}, (error) => { }, (error) => {
console.info('Sensor_GetGeomagneticDip_009 failed'); console.info('SensorJsTest_016 failed');
expect(false).assertTrue(); expect(false).assertTrue();
done() done()
}); });
}) })
/* /*
* @tc.name: Sensor_GetAltitude_009 * @tc.name:SensorJsTest_017
* @tc.desc: Verification results of the incorrect parameters of test interface. * @tc.desc:Verification results of the incorrect parameters of the test interface.
* @tc.require: I5SWJI * @tc.number:SUB_SensorsSystem_GeneralAlgorithm_JsTest_0630
* @tc.author: */
*/ it("SensorJsTest_017", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
it('Sensor_GetAltitude_009', 0, async function (done) {
sensor.getDeviceAltitude(0, 100, undefined).then((data) => { sensor.getDeviceAltitude(0, 100, undefined).then((data) => {
console.info("Sensor_GetAltitude_009" + data) console.info("SensorJsTest_017 data:" + data)
expect(data).assertEqual(getGeomagneticDipResult[2]) expect(data).assertEqual(getGeomagneticDipResult[2])
done() done()
}, (error) => { }, (error) => {
console.info('Sensor_GetAltitude_009 failed'); console.info(' SensorJsTest_017 failed');
expect(false).assertTrue(); expect(false).assertTrue();
done() done()
}); });
}) })
/* /*
* @tc.name: Sensor_GetAltitude_010 * @tc.name:SensorJsTest_018
* @tc.desc: Verification results of the incorrect parameters of test interface. * @tc.desc:Verification results of the incorrect parameters of the test interface.
* @tc.require: I5SWJI * @tc.number:SUB_SensorsSystem_GeneralAlgorithm_JsTest_0640
* @tc.author: */
*/ it("SensorJsTest_018", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
it('Sensor_GetAltitude_010', 0, async function (done) {
sensor.getDeviceAltitude(0, 100, null).then((data) => { sensor.getDeviceAltitude(0, 100, null).then((data) => {
console.info("Sensor_GetAltitude_010" + data) console.info("SensorJsTest_018" + data)
expect(data).assertEqual(getGeomagneticDipResult[2]) expect(data).assertEqual(getGeomagneticDipResult[2])
done() done()
}, (error) => { }, (error) => {
console.info('Sensor_GetAltitude_010 failed'); console.info('SensorJsTest_018 failed');
expect(false).assertTrue(); expect(false).assertTrue();
done() done()
}); });
}) })
/* /*
* @tc.name: Sensor_GetAltitude_011 * @tc.name:SensorJsTest_019
* @tc.desc: Verification results of the incorrect parameters of test interface. * @tc.desc:Verification results of the incorrect parameters of the test interface.
* @tc.require: I5SWJI * @tc.number:SUB_SensorsSystem_GeneralAlgorithm_JsTest_0650
* @tc.author: */
*/ it("SensorJsTest_019", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
it('Sensor_GetAltitude_011', 0, async function (done) {
sensor.getDeviceAltitude(0, 100, "abc").then((data) => { sensor.getDeviceAltitude(0, 100, "abc").then((data) => {
console.info("Sensor_GetAltitude_011" + data) console.info("SensorJsTest_019" + data)
expect(data).assertEqual(getGeomagneticDipResult[2]) expect(data).assertEqual(getGeomagneticDipResult[2])
done() done()
}, (error) => { }, (error) => {
console.info('Sensor_GetAltitude_011 failed'); console.info('SensorJsTest_019 failed');
expect(false).assertTrue(); expect(false).assertTrue();
done() done()
}); });
...@@ -552,65 +525,97 @@ describe("SensorJsTest_sensor_38", function () { ...@@ -552,65 +525,97 @@ describe("SensorJsTest_sensor_38", function () {
[Infinity, -Infinity, Infinity, Infinity, -Infinity, Infinity, Infinity, -Infinity, Infinity]] [Infinity, -Infinity, Infinity, Infinity, -Infinity, Infinity, Infinity, -Infinity, Infinity]]
/* /*
* @tc.name: Sensor_TransformCoordinateSystem_011 * @tc.name:SensorJsTest_020
* @tc.desc: Verification results of the incorrect parameters of test interface. * @tc.desc:Verification results of the incorrect parameters of the test interface.
* @tc.require: I5SWJI * @tc.number:SUB_SensorsSystem_GeneralAlgorithm_JsTest_0660
* @tc.author: */
*/ it("SensorJsTest_020", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
it("Sensor_TransformCoordinateSystem_011", 0, async function (done) { console.info("---------------------------SensorJsTest_020----------------------------------");
console.info("---------------------------Sensor_TransformCoordinateSystem_011----------------------------------");
sensor.transformRotationMatrix([1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5], {'x':1, 'y':2}, undefined).then((data) => { sensor.transformRotationMatrix([1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5], {'x':1, 'y':2}, undefined).then((data) => {
for (let i = 0; i < data.length; i++) { for (let i = 0; i < data.length; i++) {
console.info("Sensor_TransformCoordinateSystem_011 data[ " + i + "] = " + data[i]); console.info("SensorJsTest_020 data[ " + i + "] = " + data[i]);
expect(data[i]).assertEqual(transformCoordinateSystemResult[0][i]); expect(data[i]).assertEqual(transformCoordinateSystemResult[0][i]);
} }
done() done()
}, (error) => { }, (error) => {
console.info('Sensor_TransformCoordinateSystem_011 failed'); console.info('SensorJsTest_020 failed');
expect(false).assertTrue(); expect(false).assertTrue();
done() done()
}); });
}) })
/* /*
* @tc.name: Sensor_TransformCoordinateSystem_012 * @tc.name:SensorJsTest_021
* @tc.desc: Verification results of the incorrect parameters of test interface. * @tc.desc:Verification results of the incorrect parameters of the test interface.
* @tc.require: I5SWJI * @tc.number:SUB_SensorsSystem_GeneralAlgorithm_JsTest_0670
* @tc.author: */
*/ it("SensorJsTest_021", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
it("Sensor_TransformCoordinateSystem_012", 0, async function (done) { console.info("---------------------------SensorJsTest_021----------------------------------");
console.info("---------------------------Sensor_TransformCoordinateSystem_012----------------------------------");
sensor.transformRotationMatrix([1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5], {'x':1, 'y':2}, null).then((data) => { sensor.transformRotationMatrix([1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5], {'x':1, 'y':2}, null).then((data) => {
for (let i = 0; i < data.length; i++) { for (let i = 0; i < data.length; i++) {
console.info("Sensor_TransformCoordinateSystem_012 data[ " + i + "] = " + data[i]); console.info("SensorJsTest_021 data[ " + i + "] = " + data[i]);
expect(data[i]).assertEqual(transformCoordinateSystemResult[0][i]); expect(data[i]).assertEqual(transformCoordinateSystemResult[0][i]);
} }
done() done()
}, (error) => { }, (error) => {
console.info('Sensor_TransformCoordinateSystem_012 failed'); console.info('SensorJsTest_021 failed');
expect(false).assertTrue(); expect(false).assertTrue();
done() done()
}); });
}) })
/* /*
* @tc.name: Sensor_TransformCoordinateSystem_013 * @tc.name:SensorJsTest_022
* @tc.desc: Verification results of the incorrect parameters of test interface. * @tc.desc:Verification results of the incorrect parameters of the test interface.
* @tc.require: I5SWJI * @tc.number:SUB_SensorsSystem_GeneralAlgorithm_JsTest_0680
* @tc.author: */
*/ it("SensorJsTest_022", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
it("Sensor_TransformCoordinateSystem_013", 0, async function (done) { console.info("---------------------------SensorJsTest_022----------------------------------");
console.info("---------------------------Sensor_TransformCoordinateSystem_013----------------------------------");
sensor.transformRotationMatrix([1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5], {'x':1, 'y':2}, "abc").then((data) => { sensor.transformRotationMatrix([1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5], {'x':1, 'y':2}, "abc").then((data) => {
for (let i = 0; i < data.length; i++) { for (let i = 0; i < data.length; i++) {
console.info("Sensor_TransformCoordinateSystem_013 data[ " + i + "] = " + data[i]); console.info("SensorJsTest_022 data[ " + i + "] = " + data[i]);
expect(data[i]).assertEqual(transformCoordinateSystemResult[0][i]); expect(data[i]).assertEqual(transformCoordinateSystemResult[0][i]);
} }
done() done()
}, (error) => { }, (error) => {
console.info('Sensor_TransformCoordinateSystem_013 failed'); console.info('SensorJsTest_022 failed');
expect(false).assertTrue(); expect(false).assertTrue();
done() done()
}); });
}) })
/*
* @tc.name:SensorJsTest_023
* @tc.desc:Verification results of the incorrect parameters of the test interface.
* @tc.number:SUB_SensorsSystem_GeneralAlgorithm_JsTest_0690
*/
it("SensorJsTest_023", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('SensorJsTest_023 start')
let inclinationMatrix = [
1, 0, 0, 1,
0, 1, 0, 0,
0, 0, 1, 0,
1, 0, 0, 0
]
try {
sensor.getGeomagneticDip(inclinationMatrix, (error, data) => {
if (error) {
console.info("SensorJsTest_023 error:" + error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done()
} else {
console.info("SensorJsTest_023 data:" + data)
expect(data).assertEqual(0);
done()
}
})
} catch(error) {
console.info("SensorJsTest_023 catch error:" + error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
console.info("SensorJsTest_023 end")
})
})} })}
\ No newline at end of file
...@@ -12,30 +12,66 @@ ...@@ -12,30 +12,66 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
import bundle from '@ohos.bundle'
import osAccount from '@ohos.account.osAccount'
import sensor from '@ohos.sensor' import sensor from '@ohos.sensor'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestType, Size, Level } from '@ohos/hypium' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestType, Size, Level } from '@ohos/hypium'
export default function SensorJsTest_sensor_18() { export default function SensorJsTest_sensor_18() {
let PermissionFlag = {
PERMISSION_USER_SET:1,
PERMISSION_USER_FIXED:2,
PERMISSION_SYSTEM_FIXED:4
}
const PERMISSION_DENIED_CODE = 201
const PARAMETER_ERROR_CODE = 401
const SERVICE_EXCEPTION_CODE = 14500101
const SERVICE_EXCEPTION_MSG = 'Service exception.'
const PARAMETER_ERROR_MSG = 'The parameter invalid.'
const PERMISSION_DENIED_MSG = 'Permission denied.'
let tokenID = undefined
let permissionNameUser = 'ohos.permission.ACTIVITY_MOTION'
async function grantPerm(){
try {
let accountManager = osAccount.getAccountManager();
let userId = await accountManager.getOsAccountLocalIdFromProcess();
console.info("SensorJsTest_sensor_18 userId:"+userId)
console.info("============SensorJsTest_sensor_18 grant Permission start ============")
var appInfo = await bundle.getApplicationInfo('ohos.acts.sensors.sensor.function', 0, userId);
tokenID = appInfo.accessTokenId;
console.log('SensorJsTest_sensor_18 accessTokenId:' + appInfo.accessTokenId + ', name:' + appInfo.name +
' ,bundleName:' + appInfo.process)
var atManager = abilityAccessCtrl.createAtManager();
var result = await atManager.grantUserGrantedPermission(tokenID, permissionNameUser,
PermissionFlag.PERMISSION_SYSTEM_FIXED)
console.info('SensorJsTest_sensor_18 successful. result: ' + JSON.stringify(result));
console.info("============SensorJsTest_sensor_18 grant Permission end ============")
} catch(error) {
console.error('SensorJsTest_sensor_18 exception in, msg:' + JSON.stringify(error))
}
}
describe("SensorJsTest_sensor_18", function () { describe("SensorJsTest_sensor_18", function () {
function callback(data) { function callback(data) {
console.info("callback" + JSON.stringify(data)); console.info("SensorJsTest_sensor_18 callback" + JSON.stringify(data));
expect(typeof (data.steps)).assertEqual("number"); expect(typeof (data.steps)).assertEqual("number");
expect(typeof (data.timestamp)).assertEqual("number"); expect(typeof (data.timestamp)).assertEqual("number");
} }
function callback2(data) { function callback2(data) {
console.info("callback2" + JSON.stringify(data)); console.info("SensorJsTest_sensor_18 callback2" + JSON.stringify(data));
expect(typeof (data.steps)).assertEqual("number"); expect(typeof (data.steps)).assertEqual("number");
expect(typeof (data.timestamp)).assertEqual("number"); expect(typeof (data.timestamp)).assertEqual("number");
} }
beforeAll(function () { beforeAll(async function(done) {
/* /*
* @tc.setup: setup invoked before all testcases * @tc.setup: setup invoked before all testcases
*/ */
console.info('beforeAll called') console.info('beforeAll called')
await grantPerm();
done();
}) })
afterAll(function () { afterAll(function () {
...@@ -44,6 +80,13 @@ describe("SensorJsTest_sensor_18", function () { ...@@ -44,6 +80,13 @@ describe("SensorJsTest_sensor_18", function () {
* @tc.teardown: teardown invoked after all testcases * @tc.teardown: teardown invoked after all testcases
*/ */
console.info('afterAll called') console.info('afterAll called')
let atManager = abilityAccessCtrl.createAtManager();
atManager.revokeUserGrantedPermission(tokenID, permissionNameUser,
PermissionFlag.PERMISSION_SYSTEM_FIXED)
.catch((error) => {
console.info('SensorJsTest_sensor_18 error:' + JSON.stringify(error));
expect(error.code).assertEqual(ERR_NOT_HAVE_PERMISSION);
})
}) })
beforeEach(function () { beforeEach(function () {
...@@ -76,20 +119,33 @@ describe("SensorJsTest_sensor_18", function () { ...@@ -76,20 +119,33 @@ describe("SensorJsTest_sensor_18", function () {
* @tc.desc:Verification results of the incorrect parameters of the test interface * @tc.desc:Verification results of the incorrect parameters of the test interface
*/ */
it("Pedometer_SensorJsTest001", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) { it("Pedometer_SensorJsTest001", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
console.info('--------Pedometer_SensorJsTest001--------'); console.info('----------------------Pedometer_SensorJsTest001---------------------------');
try { try {
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback); sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, (error, data) => {
} catch (error) { if (error) {
console.info("Pedometer_SensorJsTest001 error:" + error); console.error('Pedometer_SensorJsTest001 getSingleSensor fail:' +JSON.stringify(error));
expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(false).assertTrue();
expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done();
done(); }
} try {
setTimeout(() => { sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback);
expect(true).assertTrue(); setTimeout(() => {
done(); sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER);
}, 500); done();
}) }, 4000);
} catch (error) {
console.error('Pedometer_SensorJsTest001 On fail, errorCode:' +JSON.stringify(error));
expect(false).assertTrue();
done();
}
});
} catch (error) {
console.error('Pedometer_SensorJsTest001 Sensor is not support');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/* /*
* @tc.number: SUB_SensorsSystem_PEDOMETER_JSTest_0020 * @tc.number: SUB_SensorsSystem_PEDOMETER_JSTest_0020
...@@ -97,16 +153,30 @@ describe("SensorJsTest_sensor_18", function () { ...@@ -97,16 +153,30 @@ describe("SensorJsTest_sensor_18", function () {
* @tc.desc:Verification results of the incorrect parameters of the test interface * @tc.desc:Verification results of the incorrect parameters of the test interface
*/ */
it("Pedometer_SensorJsTest002", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { it("Pedometer_SensorJsTest002", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('--------Pedometer_SensorJsTest002--------'); console.info('----------------------Pedometer_SensorJsTest002---------------------------');
try { try {
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER ,callback, { 'interval': 100000000 }); sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, (error, data) => {
} catch (error) { if (error) {
console.info("Pedometer_SensorJsTest002 error:" + error); console.error('Pedometer_SensorJsTest002 getSingleSensor fail:' +JSON.stringify(error));
expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(false).assertTrue();
expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done();
done(); }
} try {
}) sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, 5);
} catch (error) {
console.error('Pedometer_SensorJsTest002 On fail, errorCode:' +JSON.stringify(error));
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
});
} catch (error) {
console.error('Pedometer_SensorJsTest002 Sensor is not support');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/* /*
* @tc.number: SUB_SensorsSystem_PEDOMETER_JSTest_0030 * @tc.number: SUB_SensorsSystem_PEDOMETER_JSTest_0030
...@@ -114,22 +184,33 @@ describe("SensorJsTest_sensor_18", function () { ...@@ -114,22 +184,33 @@ describe("SensorJsTest_sensor_18", function () {
* @tc.desc:Verification results of the incorrect parameters of the test interface * @tc.desc:Verification results of the incorrect parameters of the test interface
*/ */
it("Pedometer_SensorJsTest003", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { it("Pedometer_SensorJsTest003", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('--------Pedometer_SensorJsTest003--------'); console.info('----------------------Pedometer_SensorJsTest003---------------------------');
function onSensorCallback(data) { try {
console.info('Pedometer_SensorJsTest003 on error'); sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, (error, data) => {
expect(typeof (data.steps)).assertEqual("number"); if (error) {
expect(typeof (data.timestamp)).assertEqual("number"); console.error('Pedometer_SensorJsTest003 getSingleSensor fail:' +JSON.stringify(error));
} expect(false).assertTrue();
try { done();
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, }
onSensorCallback, { 'interval': 100000000 }, 5); try {
} catch (error) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback);
console.info("Pedometer_SensorJsTest003 error:" + error); setTimeout(() => {
expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(true).assertTrue();
expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done();
done(); }, 4000);
} } catch (error) {
}) console.error('Pedometer_SensorJsTest003 Once fail, errorCode:' +JSON.stringify(error));
expect(false).assertTrue();
done();
}
});
} catch (error) {
console.error('Pedometer_SensorJsTest003 Sensor is not support');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/* /*
* @tc.number: SUB_SensorsSystem_PEDOMETER_JSTest_0040 * @tc.number: SUB_SensorsSystem_PEDOMETER_JSTest_0040
...@@ -137,16 +218,33 @@ describe("SensorJsTest_sensor_18", function () { ...@@ -137,16 +218,33 @@ describe("SensorJsTest_sensor_18", function () {
* @tc.desc:Verification results of the incorrect parameters of the test interface * @tc.desc:Verification results of the incorrect parameters of the test interface
*/ */
it("Pedometer_SensorJsTest004", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { it("Pedometer_SensorJsTest004", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('--------Pedometer_SensorJsTest004--------'); console.info('----------------------Pedometer_SensorJsTest004---------------------------');
try{ try {
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback); sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, (error, data) => {
} catch (error) { if (error) {
console.info("Pedometer_SensorJsTest004 error:" + error); console.error('Pedometer_SensorJsTest004 getSingleSensor fail:' +JSON.stringify(error));
expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(false).assertTrue();
expect(error.message).assertEqual(PARAMETER_ERROR_MSG); done();
done(); }
} try {
}) sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback, 5);
setTimeout(() => {
expect(true).assertTrue();
done();
}, 4000);
} catch (error) {
console.error('Pedometer_SensorJsTest004 Once fail, errorCode:' +JSON.stringify(error));
expect(false).assertTrue();
done();
}
});
} catch (error) {
console.error('Pedometer_SensorJsTest004 Sensor is not support');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/* /*
* @tc.number: SUB_SensorsSystem_PEDOMETER_JSTest_0050 * @tc.number: SUB_SensorsSystem_PEDOMETER_JSTest_0050
...@@ -154,61 +252,95 @@ describe("SensorJsTest_sensor_18", function () { ...@@ -154,61 +252,95 @@ describe("SensorJsTest_sensor_18", function () {
* @tc.desc:Verification results of the incorrect parameters of the test interface * @tc.desc:Verification results of the incorrect parameters of the test interface
*/ */
it("Pedometer_SensorJsTest005", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { it("Pedometer_SensorJsTest005", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('--------Pedometer_SensorJsTest005--------'); console.info('----------------------Pedometer_SensorJsTest005---------------------------');
function onceSensorCallback(data) { try {
console.info('Pedometer_SensorJsTest005 on error'); sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, (error, data) => {
expect(typeof (data.steps)).assertEqual("number"); if (error) {
expect(typeof (data.timestamp)).assertEqual("number"); console.error('Pedometer_SensorJsTest005 getSingleSensor fail:' +JSON.stringify(error));
} expect(false).assertTrue();
try { done();
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, onceSensorCallback, 5); }
} catch (error) { try {
console.info("Pedometer_SensorJsTest005 error:" + error); sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, 5);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE); } catch (error) {
expect(error.message).assertEqual(PARAMETER_ERROR_MSG); console.error('Pedometer_SensorJsTest005 On fail, errorCode:' +JSON.stringify(error));
done(); expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
} expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
}) done();
}
});
} catch (error) {
console.error('Pedometer_SensorJsTest005 Sensor is not support');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/* /*
* @tc.number: SUB_SensorsSystem_PEDOMETER_JSTest_0060 * @tc.number: SUB_SensorsSystem_PEDOMETER_JSTest_0060
* @tc.name: Pedometer_SensorJsTest006 * @tc.name: Pedometer_SensorJsTest006
* @tc.desc:Verification results of the incorrect parameters of the test interface * @tc.desc:Verification results of the incorrect parameters of the test interface
*/ */
it("Pedometer_SensorJsTest006", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { it("Pedometer_SensorJsTest006", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('--------Pedometer_SensorJsTest006--------'); console.info('----------------------Pedometer_SensorJsTest006---------------------------');
try { try {
sensor.off(string, ""); sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, (error, data) => {
} catch (error) { if (error) {
errMessage console.error('Pedometer_SensorJsTest006 getSingleSensor fail:' +JSON.stringify(error));
console.info("Pedometer_SensorJsTest006 error:" + error); expect(false).assertTrue();
errMessage = error.toString(); done();
expect(errMessage).assertEqual(errMessages[0]); }
done(); try {
} sensor.off(-1, callback);
}) } catch (error) {
expect(error.code).assertEqual(PARAMETER_ERROR_CODE)
expect(error.message).assertEqual(PARAMETER_ERROR_MSG)
done();
}
});
} catch (error) {
console.error('Pedometer_SensorJsTest006 Sensor is not support');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/* /*
* @tc.number: SUB_SensorsSystem_PEDOMETER_JSTest_0070 * @tc.number: SUB_SensorsSystem_PEDOMETER_JSTest_0070
* @tc.name: Pedometer_SensorJsTest007 * @tc.name: Pedometer_SensorJsTest007
* @tc.desc:Verification results of the incorrect parameters of the test interface * @tc.desc:Verification results of the incorrect parameters of the test interface
*/ */
it("Pedometer_SensorJsTest007", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { it("Pedometer_SensorJsTest007", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('--------Pedometer_SensorJsTest007--------'); console.info('----------------------Pedometer_SensorJsTest007---------------------------');
function onSensorCallback(data) { try {
console.info('Pedometer_SensorJsTest007 on error'); sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, (error, data) => {
expect(typeof (data.steps)).assertEqual("number"); if (error) {
} console.error('Pedometer_SensorJsTest007 getSingleSensor fail:' +JSON.stringify(error));
try { expect(false).assertTrue();
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, onSensorCallback); done();
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER); }
try {
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback);
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback2);
setTimeout(()=>{
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER);
done();
}, 4000);
} catch (error) {
console.error('Pedometer_SensorJsTest007 On fail, errorCode:' +JSON.stringify(error));
expect(false).assertTrue();
done();
}
});
} catch (error) { } catch (error) {
console.info("Pedometer_SensorJsTest007 error:" + error); console.error('Pedometer_SensorJsTest007 Sensor is not support');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE); expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG); expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done(); done();
} }
}) })
/* /*
* @tc.number: SUB_SensorsSystem_PEDOMETER_JSTest_0080 * @tc.number: SUB_SensorsSystem_PEDOMETER_JSTest_0080
...@@ -216,59 +348,103 @@ describe("SensorJsTest_sensor_18", function () { ...@@ -216,59 +348,103 @@ describe("SensorJsTest_sensor_18", function () {
* @tc.desc:Verification results of the incorrect parameters of the test interface * @tc.desc:Verification results of the incorrect parameters of the test interface
*/ */
it("Pedometer_SensorJsTest008", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { it("Pedometer_SensorJsTest008", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('--------Pedometer_SensorJsTest008--------'); console.info('----------------------Pedometer_SensorJsTest008---------------------------');
function onSensorCallback(data) { try {
console.info('Pedometer_SensorJsTest008 on error'); sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, (error, data) => {
expect(typeof (data.steps)).assertEqual("number"); if (error) {
} console.error('Pedometer_SensorJsTest008 getSingleSensor fail:' +JSON.stringify(error));
try { expect(false).assertTrue();
sensor.off(1000000, onSensorCallback); done();
} catch (error) { }
console.info("Pedometer_SensorJsTest008 error:" + error); try {
expect(error.code).assertEqual(PARAMETER_ERROR_CODE); sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG); sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback2);
done(); setTimeout(() => {
} sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback);
}) }, 4000);
setTimeout(() => {
/* sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback2);
done();
}, 4000);
} catch (error) {
console.error('Pedometer_SensorJsTest008 On fail, errorCode:' +JSON.stringify(error));
expect(false).assertTrue();
done();
}
});
} catch (error) {
console.error('Pedometer_SensorJsTest008 Sensor is not support');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number: SUB_SensorsSystem_PEDOMETER_JSTest_0090 * @tc.number: SUB_SensorsSystem_PEDOMETER_JSTest_0090
* @tc.name: Pedometer_SensorJsTest009 * @tc.name: Pedometer_SensorJsTest009
* @tc.desc:Verification results of the incorrect parameters of the test interface * @tc.desc:Verification results of the incorrect parameters of the test interface
*/ */
it("Pedometer_SensorJsTest009", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { it("Pedometer_SensorJsTest009", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('--------Pedometer_SensorJsTest009--------'); console.info('----------------------Pedometer_SensorJsTest009---------------------------');
function onSensorCallback(data) { try {
console.info('Pedometer_SensorJsTest009 on error'); sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, (error, data) => {
expect(typeof (data.steps)).assertEqual("number"); if (error) {
} console.error('Pedometer_SensorJsTest009 getSingleSensor fail:' +JSON.stringify(error));
try { expect(false).assertTrue();
sensor.off(invalid, onSensorCallback); done();
} catch (error) { }
console.info("Pedometer_SensorJsTest009 error:" + error); try {
expect(error.code).assertEqual(PARAMETER_ERROR_CODE); sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG); sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback2);
done(); setTimeout(() => {
} sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER);
}) done();
}, 4000);
/* } catch (error) {
console.error('Pedometer_SensorJsTest009 On fail, errorCode:' +JSON.stringify(error));
expect(false).assertTrue();
done();
}
});
} catch (error) {
console.error('Pedometer_SensorJsTest009 Sensor is not support');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number: SUB_SensorsSystem_PEDOMETER_JSTest_0100 * @tc.number: SUB_SensorsSystem_PEDOMETER_JSTest_0100
* @tc.name: Pedometer_SensorJsTest010 * @tc.name: Pedometer_SensorJsTest010
* @tc.desc:Verification results of the incorrect parameters of the test interface * @tc.desc:Verification results of the incorrect parameters of the test interface
*/ */
it("Pedometer_SensorJsTest010", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { it("Pedometer_SensorJsTest010", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('--------Pedometer_SensorJsTest010--------'); console.info('----------------------Pedometer_SensorJsTest010---------------------------');
function onSensorCallback(data) {
console.info('Pedometer_SensorJsTest010 on error');
expect(typeof (data.steps)).assertEqual("number");
}
try { try {
sensor.xxx(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, onSensorCallback); sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, (error, data) => {
if (error) {
console.error('Pedometer_SensorJsTest010 getSingleSensor fail:' +JSON.stringify(error));
expect(false).assertTrue();
done();
}
try {
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback);
setTimeout(() => {
done();
}, 4000);
} catch (error) {
console.error('Pedometer_SensorJsTest010 On fail, errorCode:' +JSON.stringify(error));
expect(error.code).assertEqual(PERMISSION_DENIED_CODE);
expect(error.message).assertEqual(PERMISSION_DENIED_MSG);
done();
}
});
} catch (error) { } catch (error) {
console.info("Pedometer_SensorJsTest010 error:" + error); console.error('Pedometer_SensorJsTest010 Sensor is not support');
errMessage = error.toString(); expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(errMessage).assertEqual(errMessages[1]); expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done(); done();
} }
}) })
...@@ -280,18 +456,434 @@ describe("SensorJsTest_sensor_18", function () { ...@@ -280,18 +456,434 @@ describe("SensorJsTest_sensor_18", function () {
*/ */
it("Pedometer_SensorJsTest011", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) { it("Pedometer_SensorJsTest011", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('--------Pedometer_SensorJsTest011--------'); console.info('--------Pedometer_SensorJsTest011--------');
function onSensorCallback(data) { let errorMessage = ""
console.info('Pedometer_SensorJsTest011 on error'); let errorMessages = "ReferenceError: xxx is not defined"
expect(typeof (data.steps)).assertEqual("number"); try {
} sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, (error, data) => {
try { if (error) {
xxx.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, onSensorCallback); console.error('Pedometer_SensorJsTest011 getSingleSensor fail:' +JSON.stringify(error));
} catch (error) { expect(false).assertTrue();
console.info("Pedometer_SensorJsTest011 error:" + error); done();
errMessage = error.toString(); }
expect(errMessage).assertEqual(errMessages[2]); try {
done(); function onSensorCallback(data) {
} console.info('Pedometer_SensorJsTest011 on error');
expect(typeof (data.steps)).assertEqual("number");
}
try {
xxx.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, onSensorCallback);
} catch (error) {
console.info("Pedometer_SensorJsTest011 error:" + error);
errorMessage = error.toString();
expect(errorMessage).assertEqual(errorMessages);
done();
}
} catch (error) {
console.error('Pedometer_SensorJsTest011 On fail, errorCode:' +JSON.stringify(error));
expect(false).assertTrue();
done();
}
});
} catch (error) {
console.error('Pedometer_SensorJsTest011 Sensor is not support'+error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
}) })
})
} /*
* @tc.number:SUB_SensorsSystem_PEDOMETER_JSTest_0120
* @tc.name: Pedometer_SensorJsTest012
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("Pedometer_SensorJsTest012", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('--------Pedometer_SensorJsTest012--------');
try {
sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, (error, data) => {
if (error) {
console.error('Pedometer_SensorJsTest012 getSingleSensor fail:' +JSON.stringify(error));
expect(false).assertTrue();
done();
}
try {
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback, {'interval': 100000000});
setTimeout(() => {
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER);
done();
}, 4000);
} catch (error) {
console.error('Pedometer_SensorJsTest012 catch error:' +JSON.stringify(error));
expect(false).assertTrue();
done();
}
});
} catch (error) {
console.error('Pedometer_SensorJsTest012 Sensor is not support'+error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number:SUB_SensorsSystem_PEDOMETER_JSTest_0130
* @tc.name: Pedometer_SensorJsTest013
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("Pedometer_SensorJsTest013", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('--------Pedometer_SensorJsTest013--------');
try {
sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, (error, data) => {
if (error) {
console.error('Pedometer_SensorJsTest013 getSingleSensor fail:' +JSON.stringify(error));
expect(false).assertTrue();
done();
}
try {
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback, {'interval': 100000000}, 5);
setTimeout(() => {
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER);
done();
}, 4000);
} catch (error) {
console.error('Pedometer_SensorJsTest013 On fail, errorCode:' +JSON.stringify(error));
expect(false).assertTrue();
done();
}
});
} catch (error) {
console.error('Pedometer_SensorJsTest013 Sensor is not support'+error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number:SUB_SensorsSystem_PEDOMETER_JSTest_0140
* @tc.name: Pedometer_SensorJsTest014
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("Pedometer_SensorJsTest014", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('--------Pedometer_SensorJsTest014--------');
try {
sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, (error, data) => {
if (error) {
console.error('Pedometer_SensorJsTest014 getSingleSensor fail:' +JSON.stringify(error));
expect(false).assertTrue();
done();
}
try {
function onSensorCallback(data) {
console.info('Pedometer_SensorJsTest014 callback:'+JSON.stringify(data));
expect(typeof(data.steps)).assertEqual('number');
}
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, onSensorCallback, {'interval': 100000000});
setTimeout(() => {
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER);
done();
}, 4000);
} catch (error) {
console.error('Pedometer_SensorJsTest014 On fail:' +JSON.stringify(error));
expect(false).assertTrue();
done();
}
});
} catch (error) {
console.error('Pedometer_SensorJsTest014 Sensor is not support'+error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number:SUB_SensorsSystem_PEDOMETER_JSTest_0150
* @tc.name: Pedometer_SensorJsTest015
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("Pedometer_SensorJsTest015", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------Pedometer_SensorJsTest015---------------------------');
try {
sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, (error, data) => {
if (error) {
console.error('Pedometer_SensorJsTest015 getSingleSensor fail:' +JSON.stringify(error));
expect(false).assertTrue();
done();
}
try {
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER,5);
} catch (error) {
console.error('Pedometer_SensorJsTest015 Off fail, errorCode:' +JSON.stringify(error));
expect(error.code).assertEqual(PARAMETER_ERROR_CODE)
expect(error.message).assertEqual(PARAMETER_ERROR_MSG)
done();
}
});
} catch (error) {
console.error('Pedometer_SensorJsTest015 Sensor is not support'+error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number:SUB_SensorsSystem_PEDOMETER_JSTest_0160
* @tc.name: Pedometer_SensorJsTest016
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("Pedometer_SensorJsTest016", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('--------Pedometer_SensorJsTest016--------');
try {
sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, (error, data) => {
if (error) {
console.error('Pedometer_SensorJsTest016 getSingleSensor fail:' +JSON.stringify(error));
expect(false).assertTrue();
done();
}
try {
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, (data)=>{
console.info("Pedometer_SensorJsTest016 callback: " + JSON.stringify(data));
expect(typeof(data.steps)).assertEqual('number');
expect(typeof (data.timestamp)).assertEqual("number");
}, {'interval': 100000000});
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, (data)=>{
console.info("Pedometer_SensorJsTest016 callback2: " + JSON.stringify(data));
expect(typeof(data.steps)).assertEqual('number');
expect(typeof (data.timestamp)).assertEqual("number");
});
setTimeout(()=>{
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER);
done();
}, 4000);
} catch (error) {
console.error('Pedometer_SensorJsTest016 Off fail, errorCode:' +JSON.stringify(error));
expect(error.code).assertEqual(PARAMETER_ERROR_CODE)
expect(error.message).assertEqual(PARAMETER_ERROR_MSG)
done();
}
});
} catch (error) {
console.error('Pedometer_SensorJsTest016 Sensor is not support'+error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number:SUB_SensorsSystem_PEDOMETER_JSTest_0170
* @tc.name: Pedometer_SensorJsTest017
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("Pedometer_SensorJsTest017", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('--------Pedometer_SensorJsTest017--------');
try {
sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, (error, data) => {
if (error) {
console.error('Pedometer_SensorJsTest017 getSingleSensor fail:' +JSON.stringify(error));
expect(false).assertTrue();
done();
}
try {
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, (data)=>{
console.info("Pedometer_SensorJsTest017 callback: " + JSON.stringify(data));
expect(typeof(data.steps)).assertEqual('number');
expect(typeof (data.timestamp)).assertEqual("number");
}, {'interval': -100000000});
} catch (error) {
console.error('Pedometer_SensorJsTest017 On fail, errorCode:' +JSON.stringify(error));
expect(error.code).assertEqual(SERVICE_EXCEPTION_CODE);
expect(error.message).assertEqual(SERVICE_EXCEPTION_MSG);
done();
}
});
} catch (error) {
console.error('Pedometer_SensorJsTest017 Sensor is not support'+error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number:SUB_SensorsSystem_PEDOMETER_JSTest_0180
* @tc.name: Pedometer_SensorJsTest018
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("Pedometer_SensorJsTest018", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
console.info('----------------------Pedometer_SensorJsTest018---------------------------');
try {
sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, (error, data) => {
if (error) {
console.error('Pedometer_SensorJsTest018 getSingleSensor fail:' +JSON.stringify(error));
expect(false).assertTrue();
done();
}
try {
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback, { 'interval': undefined });
setTimeout(() => {
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER);
done();
}, 4000);
} catch (error) {
console.error('Pedometer_SensorJsTest018 On fail, errorCode:' +JSON.stringify(error));
expect(false).assertTrue();
done();
}
});
} catch (error) {
console.error('Pedometer_SensorJsTest018 Sensor is not support');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number: SUB_SensorsSystem_PEDOMETER_JSTest_0190
* @tc.name: Pedometer_SensorJsTest019
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("Pedometer_SensorJsTest019", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------Pedometer_SensorJsTest019---------------------------');
try {
sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, (error, data) => {
if (error) {
console.error('Pedometer_SensorJsTest019 getSingleSensor fail:' +JSON.stringify(error));
expect(false).assertTrue();
done();
}
try {
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback, { 'interval': undefined });
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback2, { 'interval': undefined });
setTimeout(()=>{
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER);
done();
}, 4000);
} catch (error) {
console.error('Pedometer_SensorJsTest019 On fail, errorCode:' +JSON.stringify(error));
expect(false).assertTrue();
done();
}
});
} catch (error) {
console.error('Pedometer_SensorJsTest019 Sensor is not support');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number: SUB_SensorsSystem_PEDOMETER_JSTest_0200
* @tc.name: Pedometer_SensorJsTest020
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("Pedometer_SensorJsTest020", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------Pedometer_SensorJsTest020---------------------------');
try {
sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, (error, data) => {
if (error) {
console.error('Pedometer_SensorJsTest020 getSingleSensor fail:' +JSON.stringify(error));
expect(false).assertTrue();
done();
}
try {
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback, { 'interval': null });
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback2, { 'interval': null });
setTimeout(() => {
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback);
}, 4000);
setTimeout(() => {
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback2);
done();
}, 4000);
} catch (error) {
console.error('Pedometer_SensorJsTest020 On fail, errorCode:' +JSON.stringify(error));
expect(false).assertTrue();
done();
}
});
} catch (error) {
console.error('Pedometer_SensorJsTest020 Sensor is not support');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number: SUB_SensorsSystem_PEDOMETER_JSTest_0210
* @tc.name: Pedometer_SensorJsTest021
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("Pedometer_SensorJsTest021", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------Pedometer_SensorJsTest021---------------------------');
try {
sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, (error, data) => {
if (error) {
console.error('Pedometer_SensorJsTest021 getSingleSensor fail:' +JSON.stringify(error));
expect(false).assertTrue();
done();
}
try {
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback);
try{
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback, undefined);
} catch(error){
console.info('Pedometer_SensorJsTest021 Repeat subscription'+error);
}
setTimeout(() => {
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER);
done();
}, 4000);
} catch (error) {
console.error('Pedometer_SensorJsTest021 On fail, errorCode:' +JSON.stringify(error));
expect(false).assertTrue();
done();
}
});
} catch (error) {
console.error('Pedometer_SensorJsTest021 Sensor is not support');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number: SUB_SensorsSystem_PEDOMETER_JSTest_0220
* @tc.name: Pedometer_SensorJsTest022
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("Pedometer_SensorJsTest022", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
try {
sensor.getSingleSensor(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, (error, data) => {
if (error) {
console.error('Pedometer_SensorJsTest022 getSingleSensor fail:' +JSON.stringify(error));
expect(false).assertTrue();
done();
}
try {
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback);
setTimeout(() => {
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, null);
done();
}, 4000);
} catch (error) {
console.error('Pedometer_SensorJsTest022 catch error:' +JSON.stringify(error));
expect(false).assertTrue();
done();
}
});
} catch (error) {
console.error('Pedometer_SensorJsTest022 Sensor is not support'+error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
})}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册