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

!7669 【Openharmony4.0.3.2】【monthly分支】【sensor子系统】【ToC】【RK3568】【必现】修改bundle-name,p7b文件,陀螺仪用例

Merge pull request !7669 from ldy/cherry-pick-1676963247
......@@ -4,8 +4,8 @@
"type": "OHJSUnitTest",
"test-timeout": "160000",
"shell-timeout": "160000",
"bundle-name": "ohos.acts.sensors.sensor.function",
"package-name": "ohos.acts.sensors.sensor.function"
"bundle-name": "ohos.acts.sensors.miscdevice.function",
"package-name": "ohos.acts.sensors.miscdevice.function"
},
"kits": [
{
......
{
"app": {
"bundleName": "ohos.acts.sensors.sensor.function",
"bundleName": "ohos.acts.sensors.miscdevice.function",
"vendor": "example",
"version": {
"code": 1,
......@@ -13,7 +13,7 @@
},
"deviceConfig": {},
"module": {
"package": "ohos.acts.sensors.sensor.function",
"package": "ohos.acts.sensors.miscdevice.function",
"name": ".entry",
"deviceType": [
"tablet",
......
......@@ -19,6 +19,7 @@ import SensorJsTest_sensor_60 from './SensorOnOffTest.test_newSensorGeomagnetic.
import SensorJsTest_sensor_3 from './SensorOnOffTest.test_oldAccelerometer.js'
import SensorJsTest_sensor_25 from './Subscribe_subscribeAccelerometer.js'
import SensorJsTest_sensor_39 from './SensorOnOffTest.test_newAccelerometer.js'
import SensorJsTest_sensor_43 from './SensorOnOffTest.test_newGyroScope.js'
export default function testsuite() {
SensorJsTest_sensor_1()
......@@ -28,4 +29,5 @@ SystemParameterTest()
SensorJsTest_sensor_3()
SensorJsTest_sensor_25()
SensorJsTest_sensor_39()
SensorJsTest_sensor_43()
}
......@@ -78,11 +78,25 @@ describe("SensorJsTest_sensor_43", function () {
*/
it("newGyroScope_SensorJsTest014", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
console.info('---------newGyroScope_SensorJsTest014--------------');
try{
sensor.getSingleSensor(sensor.SensorId.GYROSCOPE,(error, data) => {
if (error) {
console.info('newGyroScope_SensorJsTest014 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.on(sensor.SensorId.GYROSCOPE, callback);
setTimeout(()=>{
sensor.off(sensor.SensorId.GYROSCOPE);
done();
}, 500);
}
})
} catch (error) {
console.info('newGyroScope_SensorJsTest014 Device does not support!');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
......@@ -113,6 +127,12 @@ describe("SensorJsTest_sensor_43", function () {
*/
it("newGyroScope_SensorJsTest016", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('---------newGyroScope_SensorJsTest016--------------');
try{
sensor.getSingleSensor(sensor.SensorId.GYROSCOPE,(error, data) => {
if (error) {
console.info('newGyroScope_SensorJsTest016 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.on(sensor.SensorId.GYROSCOPE, callback, {'interval': 100000000});
setTimeout(()=>{
console.info('---------newGyroScope_SensorJsTest016 off in--------------');
......@@ -120,6 +140,14 @@ describe("SensorJsTest_sensor_43", function () {
console.info('---------newGyroScope_SensorJsTest016 off end--------------');
done();
}, 500);
}
})
} catch (error) {
console.info('newGyroScope_SensorJsTest016 Device does not support!');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
......@@ -136,19 +164,27 @@ describe("SensorJsTest_sensor_43", function () {
expect(typeof (data.z)).assertEqual("number");
expect(typeof (data.timestamp)).assertEqual("number");
}
try {
try{
sensor.getSingleSensor(sensor.SensorId.GYROSCOPE,(error, data) => {
if (error) {
console.info('newGyroScope_SensorJsTest017 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.on(sensor.SensorId.GYROSCOPE, onSensorCallback, {'interval': 100000000}, 5);
} catch (error) {
console.info("newGyroScope_SensorJsTest017 error:" +error);
expect(false).assertTrue();
done();
}
setTimeout(()=>{
console.info('---------newGyroScope_SensorJsTest017 off in--------------');
sensor.off(sensor.SensorId.GYROSCOPE);
console.info('---------newGyroScope_SensorJsTest017 off end--------------');
done();
}, 500);
}
})
} catch (error) {
console.info("newGyroScope_SensorJsTest017 Device does not support!");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
......@@ -157,11 +193,25 @@ describe("SensorJsTest_sensor_43", function () {
* @tc.desc: Once Normal Subscription Scenario Use Case
*/
it("newGyroScope_SensorJsTest018", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
try{
sensor.getSingleSensor(sensor.SensorId.GYROSCOPE,(error, data) => {
if (error) {
console.info('newGyroScope_SensorJsTest018 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.once(sensor.SensorId.GYROSCOPE, callback);
setTimeout(()=>{
expect(true).assertTrue();
done();
}, 500);
}
})
} catch (error) {
console.info("newGyroScope_SensorJsTest018 Device does not support!");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
......@@ -200,10 +250,18 @@ describe("SensorJsTest_sensor_43", function () {
done();
}
try{
sensor.getSingleSensor(sensor.SensorId.GYROSCOPE,(error, data) => {
if (error) {
console.info('newGyroScope_SensorJsTest020 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.once(sensor.SensorId.GYROSCOPE, onceSensorCallback, 5);
}
})
} catch (error) {
console.info('newGyroScope_SensorJsTest020 error:' +error);
expect(false).assertTrue();
console.info("newGyroScope_SensorJsTest020 error:" +error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
......@@ -217,7 +275,7 @@ describe("SensorJsTest_sensor_43", function () {
try {
sensor.off(invalid, callback);
} catch (error) {
console.info('newGyroScope_SensorJsTest021 error:' +error);
console.info('newGyroScope_SensorJsTest021 Device does not support!');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE)
expect(error.message).assertEqual(PARAMETER_ERROR_MSG)
done();
......@@ -235,28 +293,42 @@ describe("SensorJsTest_sensor_43", function () {
expect(false).assertTrue();
done();
}
try{
sensor.getSingleSensor(sensor.SensorId.GYROSCOPE,(error, data) => {
if (error) {
console.info('newGyroScope_SensorJsTest022 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.on(sensor.SensorId.GYROSCOPE, onSensorCallback);
sensor.off(sensor.SensorId.GYROSCOPE, onSensorCallback);
setTimeout(()=>{
expect(true).assertTrue();
done();
}, 500);
}
})
} catch (error) {
console.info("newGyroScope_SensorJsTest022 error:" +error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number:SUB_SensorsSystem_GYROSCOPE_JSTest_0230
* @tc.name: newnewGyroScope_SensorJsTest023
* @tc.name: newGyroScope_SensorJsTest023
* @tc.desc:SensorId1000000 of incoming exception
*/
it("newnewGyroScope_SensorJsTest023", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
it("newGyroScope_SensorJsTest023", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
function onSensorCallback(data) {
console.info('newnewGyroScope_SensorJsTest023 on error');
console.info('newGyroScope_SensorJsTest023 on error');
expect(false).assertTrue();
}
try {
sensor.off(1000000, onSensorCallback);
} catch (error) {
console.info("newnewGyroScope_SensorJsTest023 error:" +error);
console.info("newGyroScope_SensorJsTest023 error:" +error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE)
expect(error.message).assertEqual(PARAMETER_ERROR_MSG)
done();
......@@ -269,6 +341,12 @@ describe("SensorJsTest_sensor_43", function () {
* @tc.desc:Call interface multiple times
*/
it("newGyroScope_SensorJsTest024", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
try{
sensor.getSingleSensor(sensor.SensorId.GYROSCOPE,(error, data) => {
if (error) {
console.info('newGyroScope_SensorJsTest024 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.on(sensor.SensorId.GYROSCOPE, (data)=>{
console.info("newGyroScope_SensorJsTest024 callback: " + JSON.stringify(data));
expect(typeof (data.x)).assertEqual("number");
......@@ -289,6 +367,14 @@ describe("SensorJsTest_sensor_43", function () {
console.info('---------newGyroScope_SensorJsTest024 off end--------------');
done();
}, 1000);
}
})
} catch (error) {
console.info("newGyroScope_SensorJsTest024 Device does not support!");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
......@@ -300,7 +386,7 @@ describe("SensorJsTest_sensor_43", function () {
try {
sensor.off(sensor.SensorId.GYROSCOPE, 5);
} catch (error) {
console.info('newGyroScope_SensorJsTest025 error:'+error);
console.info('newGyroScope_SensorJsTest025 Device does not support!');
expect(error.code).assertEqual(PARAMETER_ERROR_CODE)
expect(error.message).assertEqual(PARAMETER_ERROR_MSG)
done();
......@@ -314,6 +400,12 @@ describe("SensorJsTest_sensor_43", function () {
*/
it("newGyroScope_SensorJsTest026", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('---------newGyroScope_SensorJsTest026--------------');
try{
sensor.getSingleSensor(sensor.SensorId.GYROSCOPE,(error, data) => {
if (error) {
console.info('newGyroScope_SensorJsTest024 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.on(sensor.SensorId.GYROSCOPE, (data)=>{
console.info("newGyroScope_SensorJsTest026 callback: " + JSON.stringify(data));
expect(typeof (data.x)).assertEqual("number");
......@@ -334,6 +426,14 @@ describe("SensorJsTest_sensor_43", function () {
console.info('---------newGyroScope_SensorJsTest026 off end--------------');
done();
}, 1000);
}
})
} catch (error) {
console.info("newGyroScope_SensorJsTest026 Device does not support!");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
......@@ -343,6 +443,12 @@ describe("SensorJsTest_sensor_43", function () {
*/
it("newGyroScope_SensorJsTest027", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('---------newGyroScope_SensorJsTest027--------------');
try{
sensor.getSingleSensor(sensor.SensorId.GYROSCOPE,(error, data) => {
if (error) {
console.info('newGyroScope_SensorJsTest024 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.on(sensor.SensorId.GYROSCOPE, (data)=>{
console.info("newGyroScope_SensorJsTest027 callback: " + JSON.stringify(data));
expect(typeof (data.x)).assertEqual("number");
......@@ -363,6 +469,14 @@ describe("SensorJsTest_sensor_43", function () {
console.info('---------newGyroScope_SensorJsTest027 off end--------------');
done();
}, 1000);
}
})
} catch (error) {
console.info("newGyroScope_SensorJsTest027 Device does not support!");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
......@@ -375,7 +489,7 @@ describe("SensorJsTest_sensor_43", function () {
try {
sensor.on();
} catch (error) {
console.info("newGyroScope_SensorJsTest028 error:" +error);
console.info("newGyroScope_SensorJsTest028_on error:" +error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
......@@ -383,7 +497,7 @@ describe("SensorJsTest_sensor_43", function () {
try {
sensor.once();
} catch (error) {
console.info("newGyroScope_SensorJsTest028 error:" +error);
console.info("newGyroScope_SensorJsTest028_once error:" +error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
......@@ -391,7 +505,7 @@ describe("SensorJsTest_sensor_43", function () {
try {
sensor.off();
} catch (error) {
console.info("newGyroScope_SensorJsTest028 error:" +error);
console.info("newGyroScope_SensorJsTest028_off error:" +error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
......@@ -405,6 +519,12 @@ describe("SensorJsTest_sensor_43", function () {
*/
it("newGyroScope_SensorJsTest029", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------newGyroScope_SensorJsTest029--------------');
try{
sensor.getSingleSensor(sensor.SensorId.GYROSCOPE,(error, data) => {
if (error) {
console.info('newGyroScope_SensorJsTest029 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.on(sensor.SensorId.GYROSCOPE, callback);
sensor.on(sensor.SensorId.GYROSCOPE, callback2);
setTimeout(() => {
......@@ -422,6 +542,14 @@ describe("SensorJsTest_sensor_43", function () {
console.info('----------------------newGyroScope_SensorJsTest029 off end--------------');
done();
}, 1000);
}
})
} catch (error) {
console.info("newGyroScope_SensorJsTest029 Device does not support!");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
......@@ -431,6 +559,12 @@ describe("SensorJsTest_sensor_43", function () {
*/
it("newGyroScope_SensorJsTest030", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------newGyroScope_SensorJsTest030--------------');
try{
sensor.getSingleSensor(sensor.SensorId.GYROSCOPE,(error, data) => {
if (error) {
console.info('newGyroScope_SensorJsTest029 error');
} else {
expect(typeof(data)).assertEqual("object");
sensor.on(sensor.SensorId.GYROSCOPE, callback, { 'interval': 100000000 });
sensor.on(sensor.SensorId.GYROSCOPE, callback2, { 'interval': 100000000 });
setTimeout(() => {
......@@ -449,5 +583,80 @@ describe("SensorJsTest_sensor_43", function () {
console.info('----------------------newGyroScope_SensorJsTest030_2 off end--------------');
done();
}, 1000);
}
})
} catch (error) {
console.info("newGyroScope_SensorJsTest030 Device does not support!");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number: SUB_SensorsSystem_GYROSCOPE_JSTest_0310
* @tc.name: newGyroScope_SensorJsTest031
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("newGyroScope_SensorJsTest031", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------newGyroScope_SensorJsTest031--------------');
try{
sensor.getSingleSensor(sensor.SensorId.GYROSCOPE,(error, data) => {
if (error) {
console.info('newGyroScope_SensorJsTest031 error');
} else {
expect(typeof(data)).assertEqual("object");
console.info('----------------------newGyroScope_SensorJsTest031 off in--------------');
try{
sensor.off(-1, callback);
console.info('----------------------newGyroScope_SensorJsTest031 off end--------------');
} catch (error) {
console.info("newGyroScope_SensorJsTest031 error:" + error);
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
}
})
} catch (error) {
console.info("newGyroScope_SensorJsTest031 Device does not support!");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
/*
* @tc.number: SUB_SensorsSystem_GYROSCOPE_JSTest_0320
* @tc.name: newGyroScope_SensorJsTest032
* @tc.desc:Verification results of the incorrect parameters of the test interface
*/
it("newGyroScope_SensorJsTest032", TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL3, async function (done) {
console.info('----------------------newGyroScope_SensorJsTest032--------------');
try{
sensor.getSingleSensor(sensor.SensorId.GYROSCOPE,(error, data) => {
if (error) {
console.info('newGyroScope_SensorJsTest032 error');
} else {
try {
sensor.on(sensor.SensorId.GYROSCOPE, callback, {'interval': -100000000});
console.info('----------------------newGyroScope_SensorJsTest032 off in---------------------------');
sensor.off(sensor.SensorId.GYROSCOPE);
console.info('----------------------newGyroScope_SensorJsTest032 off end---------------------------');
done();
} catch (error) {
console.info('newGyroScope_SensorJsTest032 On fail, errCode:' + error.code + ' ,msg:' + error.message);
expect(error.code).assertEqual(SERVICE_EXCEPTION_CODE);
expect(error.message).assertEqual(SERVICE_EXCEPTION_MSG);
done();
}
}
})
} catch (error) {
console.info("newGyroScope_SensorJsTest032 Device does not support!");
expect(error.code).assertEqual(PARAMETER_ERROR_CODE);
expect(error.message).assertEqual(PARAMETER_ERROR_MSG);
done();
}
})
})}
......@@ -15,8 +15,8 @@
import sensor from '@ohos.sensor'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestType, Size, Level } from '@ohos/hypium'
export default function SensorJsTest_sensor_39() {
describe("SensorJsTest_sensor_39", function () {
export default function SensorJsTest_sensor_37() {
describe("SensorJsTest_sensor_37", function () {
function callback(data) {
console.info("callback" + JSON.stringify(data));
expect(typeof (data.x)).assertEqual("number");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册