Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
71add173
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
1 年多 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
71add173
编写于
12月 20, 2021
作者:
O
openharmony_ci
提交者:
Gitee
12月 20, 2021
浏览文件
操作
浏览文件
下载
差异文件
!1397 【hdf】【master】sensor驱动测试代码
Merge pull request !1397 from liuhonggang/20211220
上级
6aec3310
a94f5fed
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
125 addition
and
99 deletion
+125
-99
hdf/sensor/common/hdf_sensor_test.cpp
hdf/sensor/common/hdf_sensor_test.cpp
+125
-99
未找到文件。
hdf/sensor/common/hdf_sensor_test.cpp
100755 → 100644
浏览文件 @
71add173
...
...
@@ -35,7 +35,6 @@ namespace {
struct
SensorDevelopmentList
{
int32_t
sensorTypeId
;
char
sensorName
[
SENSOR_NAME_MAX_LEN
];
char
vendorName
[
SENSOR_NAME_MAX_LEN
];
int32_t
dataForm
;
// 0: fixed, 1: range
int32_t
dataDimension
;
struct
SensorValueRange
*
valueRange
;
...
...
@@ -43,20 +42,24 @@ namespace {
static
struct
SensorValueRange
g_testRange
[]
=
{{
1e5
,
0
}};
static
struct
SensorValueRange
g_accelRange
[]
=
{{
78
,
-
78
},
{
78
,
-
78
},
{
78
,
-
78
}};
static
struct
SensorValueRange
g_alsRange
[]
=
{{
10000
,
0
}
,
{
10000
,
0
},
{
10000
,
0
},
{
10000
,
0
}
};
static
struct
SensorValueRange
g_alsRange
[]
=
{{
10000
,
0
}};
static
struct
SensorValueRange
g_proximityRange
[]
=
{{
5
,
0
}};
static
struct
SensorValueRange
g_hallRange
[]
=
{{
1
,
0
}};
static
struct
SensorValueRange
g_barometerRange
[]
=
{{
1100
,
-
1100
},
{
1100
,
-
1100
}};
static
struct
SensorValueRange
g_magneticRange
[]
=
{{
35
,
-
35
},
{
35
,
-
35
},
{
35
,
-
35
}};
static
struct
SensorValueRange
g_gyroscopeRange
[]
=
{{
2000
,
-
2000
},
{
2000
,
-
2000
},
{
2000
,
-
2000
}};
static
struct
SensorValueRange
g_gravityRange
[]
=
{{
78
,
-
78
},
{
78
,
-
78
},
{
78
,
-
78
}};
static
struct
SensorDevelopmentList
g_sensorList
[]
=
{
{
SENSOR_TYPE_NONE
,
"sensor_test"
,
"default"
,
1
,
1
,
g_testRange
},
{
SENSOR_TYPE_ACCELEROMETER
,
"accelerometer"
,
"borsh_bmi160"
,
1
,
3
,
g_accelRange
},
{
SENSOR_TYPE_PROXIMITY
,
"proximitymeter"
,
"stk3338"
,
0
,
1
,
g_proximityRange
},
{
SENSOR_TYPE_HALL
,
"hallrometer"
,
"akm_ak8789"
,
0
,
1
,
g_hallRange
},
{
SENSOR_TYPE_BAROMETER
,
"barometer"
,
"borsh_bmp180"
,
1
,
2
,
g_barometerRange
},
{
SENSOR_TYPE_AMBIENT_LIGHT
,
"als"
,
"rohm_bh1745"
,
1
,
4
,
g_alsRange
},
{
SENSOR_TYPE_MAGNETIC_FIELD
,
"magnetometer"
,
"st_lsm303"
,
1
,
3
,
g_magneticRange
},
{
SENSOR_TYPE_NONE
,
"sensor_test"
,
1
,
1
,
g_testRange
},
{
SENSOR_TYPE_ACCELEROMETER
,
"accelerometer"
,
1
,
3
,
g_accelRange
},
{
SENSOR_TYPE_PROXIMITY
,
"proximity"
,
0
,
1
,
g_proximityRange
},
{
SENSOR_TYPE_HALL
,
"hallrometer"
,
0
,
1
,
g_hallRange
},
{
SENSOR_TYPE_BAROMETER
,
"barometer"
,
1
,
2
,
g_barometerRange
},
{
SENSOR_TYPE_AMBIENT_LIGHT
,
"als"
,
1
,
1
,
g_alsRange
},
{
SENSOR_TYPE_MAGNETIC_FIELD
,
"magnetometer"
,
1
,
3
,
g_magneticRange
},
{
SENSOR_TYPE_GYROSCOPE
,
"gyroscope"
,
1
,
3
,
g_gyroscopeRange
},
{
SENSOR_TYPE_GRAVITY
,
"gravity"
,
1
,
3
,
g_gravityRange
}
};
static
int
g_listNum
=
sizeof
(
g_sensorList
)
/
sizeof
(
g_sensorList
[
0
]);
...
...
@@ -66,18 +69,20 @@ namespace {
const
int32_t
SENSOR_POLL_TIME
=
1
;
const
int32_t
SENSOR_WAIT_TIME
=
400
;
const
struct
SensorInterface
*
g_sensorDev
=
nullptr
;
static
int32_t
g_count
=
0
;
static
struct
SensorInformation
*
g_sensorInfo
=
nullptr
;
void
SensorDataVerification
(
const
float
&
data
,
const
struct
SensorDevelopmentList
&
sensorNode
)
{
for
(
int32_t
j
=
0
;
j
<
sensorNode
.
dataDimension
;
++
j
)
{
HDF_LOGE
(
"sensor id :[%d], data[%d]: %f
\n\r
"
,
sensorNode
.
sensorTypeId
,
j
+
1
,
*
(
&
data
+
j
));
printf
(
"sensor id :[%d], data[%d]: %f
\n\r
"
,
sensorNode
.
sensorTypeId
,
j
+
1
,
*
(
&
data
+
j
));
if
(
sensorNode
.
dataForm
==
0
)
{
if
(
*
(
&
data
+
j
)
==
sensorNode
.
valueRange
[
j
].
highThreshold
||
*
(
&
data
+
j
)
==
sensorNode
.
valueRange
[
j
].
lowThreshold
)
{
g_sensorDataFlag
&=
1
;
}
else
{
g_sensorDataFlag
=
0
;
HDF_LOGE
(
"%s: %s Not expected
\n\r
"
,
__func__
,
sensorNode
.
sensorName
);
printf
(
"%s: %s Not expected
\n\r
"
,
__func__
,
sensorNode
.
sensorName
);
}
}
...
...
@@ -85,10 +90,9 @@ namespace {
if
(
*
(
&
data
+
j
)
>
sensorNode
.
valueRange
[
j
].
lowThreshold
&&
*
(
&
data
+
j
)
<
sensorNode
.
valueRange
[
j
].
highThreshold
)
{
g_sensorDataFlag
&=
1
;
HDF_LOGE
(
"g_sensorDataFlag = 1;"
);
}
else
{
g_sensorDataFlag
=
0
;
HDF_LOGE
(
"%s: %s Not expected
\n\r
"
,
__func__
,
sensorNode
.
sensorName
);
printf
(
"%s: %s Not expected
\n\r
"
,
__func__
,
sensorNode
.
sensorName
);
}
}
}
...
...
@@ -100,14 +104,17 @@ namespace {
return
-
1
;
}
float
*
data
=
(
float
*
)
event
->
data
;
for
(
int
i
=
0
;
i
<
g_listNum
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
g_listNum
;
++
i
)
{
if
(
event
->
sensorId
==
g_sensorList
[
i
].
sensorTypeId
)
{
SensorDataVerification
(
*
data
,
g_sensorList
[
i
]);
if
(
event
->
sensorId
==
SENSOR_TYPE_HALL
||
event
->
sensorId
==
SENSOR_TYPE_PROXIMITY
)
{
float
data
=
(
float
)
*
event
->
data
;
SensorDataVerification
(
data
,
g_sensorList
[
i
]);
}
else
{
float
*
data
=
(
float
*
)
event
->
data
;
SensorDataVerification
(
*
data
,
g_sensorList
[
i
]);
}
}
}
return
0
;
}
}
...
...
@@ -126,6 +133,10 @@ void HdfSensorTest::SetUpTestCase()
if
(
g_sensorDev
==
nullptr
)
{
HDF_LOGE
(
"test sensorHdi get Module instance failed
\n\r
"
);
}
int32_t
ret
=
g_sensorDev
->
GetAllSensors
(
&
g_sensorInfo
,
&
g_count
);
if
(
ret
==
-
1
)
{
HDF_LOGE
(
"get sensor informations failed
\n\r
"
);
}
}
void
HdfSensorTest
::
TearDownTestCase
()
...
...
@@ -171,7 +182,10 @@ HWTEST_F(HdfSensorTest, RemoveSensorInstance001, Function | MediumTest | Level1)
if
(
g_sensorDev
==
nullptr
)
{
HDF_LOGE
(
"test sensorHdi get Module instance failed
\n\r
"
);
ASSERT_EQ
(
0
,
ret
);
return
;
}
ret
=
g_sensorDev
->
GetAllSensors
(
&
g_sensorInfo
,
&
g_count
);
EXPECT_EQ
(
0
,
ret
);
}
/**
...
...
@@ -207,34 +221,28 @@ HWTEST_F(HdfSensorTest, RegisterSensorDataCb002, Function | MediumTest | Level1)
*/
HWTEST_F
(
HdfSensorTest
,
GetSensorList001
,
Function
|
MediumTest
|
Level1
)
{
struct
SensorInformation
*
sensorInfo
=
nullptr
;
struct
SensorInformation
*
info
=
nullptr
;
int32_t
count
=
0
;
int
j
;
int32_t
ret
=
g_sensorDev
->
GetAllSensors
(
&
sensorInfo
,
&
count
);
EXPECT_EQ
(
0
,
ret
);
if
(
sensorInfo
==
nullptr
)
{
EXPECT_NE
(
nullptr
,
sensorInfo
);
if
(
g_
sensorInfo
==
nullptr
)
{
EXPECT_NE
(
nullptr
,
g_
sensorInfo
);
return
;
}
HDF_LOGE
(
"get sensor list num[%d]
\n\r
"
,
count
);
info
=
sensorInfo
;
for
(
int
i
=
0
;
i
<
count
;
++
i
)
{
HDF_LOGE
(
"get sensoriId[%d], info name[%s], power[%f]
\n\r
"
,
info
->
sensorId
,
info
->
sensorName
,
info
->
power
);
printf
(
"get sensor list num[%d]
\n\r
"
,
g_count
);
info
=
g_sensorInfo
;
for
(
int
i
=
0
;
i
<
g_count
;
++
i
)
{
printf
(
"get sensoriId[%d], info name[%s], power[%f]
\n\r
"
,
info
->
sensorId
,
info
->
sensorName
,
info
->
power
);
for
(
j
=
0
;
j
<
g_listNum
;
++
j
)
{
if
(
info
->
sensorId
==
g_sensorList
[
j
].
sensorTypeId
)
{
EXPECT_STREQ
(
g_sensorList
[
j
].
sensorName
,
info
->
sensorName
);
EXPECT_STREQ
(
g_sensorList
[
j
].
vendorName
,
info
->
vendorName
);
break
;
}
}
if
(
j
==
g_listNum
)
{
EXPECT_NE
(
g_listNum
,
j
);
HDF_LOGE
(
"%s: The sensor ID[%d] does not match. Please check the use case or the reported sensor ID"
,
__func__
,
info
->
sensorId
);
}
info
++
;
}
...
...
@@ -249,12 +257,9 @@ HWTEST_F(HdfSensorTest, GetSensorList001, Function | MediumTest | Level1)
*/
HWTEST_F
(
HdfSensorTest
,
GetSensorList002
,
Function
|
MediumTest
|
Level1
)
{
struct
SensorInformation
*
sensorInfo
=
nullptr
;
int32_t
count
=
0
;
int32_t
ret
=
g_sensorDev
->
GetAllSensors
(
nullptr
,
&
count
);
int32_t
ret
=
g_sensorDev
->
GetAllSensors
(
nullptr
,
&
g_count
);
EXPECT_EQ
(
SENSOR_NULL_PTR
,
ret
);
ret
=
g_sensorDev
->
GetAllSensors
(
&
sensorInfo
,
nullptr
);
ret
=
g_sensorDev
->
GetAllSensors
(
&
g_
sensorInfo
,
nullptr
);
EXPECT_EQ
(
SENSOR_NULL_PTR
,
ret
);
ret
=
g_sensorDev
->
GetAllSensors
(
nullptr
,
nullptr
);
EXPECT_EQ
(
SENSOR_NULL_PTR
,
ret
);
...
...
@@ -270,29 +275,26 @@ HWTEST_F(HdfSensorTest, EnableSensor001, Function | MediumTest | Level1)
int32_t
ret
=
g_sensorDev
->
Register
(
SensorTestDataCallback
);
EXPECT_EQ
(
0
,
ret
);
struct
SensorInformation
*
sensorInfo
=
nullptr
;
struct
SensorInformation
*
info
=
nullptr
;
int32_t
count
=
0
;
ret
=
g_sensorDev
->
GetAllSensors
(
&
sensorInfo
,
&
count
);
EXPECT_EQ
(
0
,
ret
);
if
(
sensorInfo
==
nullptr
)
{
EXPECT_NE
(
nullptr
,
sensorInfo
);
if
(
g_sensorInfo
==
nullptr
)
{
EXPECT_NE
(
nullptr
,
g_sensorInfo
);
return
;
}
info
=
sensorInfo
;
for
(
int
i
=
0
;
i
<
count
;
i
++
)
{
ret
=
g_sensorDev
->
SetBatch
(
SENSOR_ID
,
SENSOR_INTERVAL
,
SENSOR_POLL_TIME
);
info
=
g_
sensorInfo
;
for
(
int
i
=
0
;
i
<
g_
count
;
i
++
)
{
ret
=
g_sensorDev
->
SetBatch
(
info
->
sensorId
,
SENSOR_INTERVAL
,
SENSOR_POLL_TIME
);
EXPECT_EQ
(
0
,
ret
);
ret
=
g_sensorDev
->
Enable
(
info
->
sensorId
);
EXPECT_EQ
(
0
,
ret
);
OsalSleep
(
SENSOR_POLL_TIME
);
EXPECT_EQ
(
1
,
g_sensorDataFlag
);
ret
=
g_sensorDev
->
Disable
(
info
->
sensorId
);
EXPECT_EQ
(
0
,
ret
);
info
++
;
}
ret
=
g_sensorDev
->
Unregister
();
EXPECT_EQ
(
0
,
ret
);
}
...
...
@@ -304,11 +306,12 @@ HWTEST_F(HdfSensorTest, EnableSensor001, Function | MediumTest | Level1)
*/
HWTEST_F
(
HdfSensorTest
,
EnableSensor002
,
Function
|
MediumTest
|
Level1
)
{
struct
SensorInformation
*
sensorInfo
=
nullptr
;
int32_t
count
=
0
;
int32_t
ret
=
g_sensorDev
->
GetAllSensors
(
&
sensorInfo
,
&
count
);
EXPECT_EQ
(
0
,
ret
);
ret
=
g_sensorDev
->
Enable
(
-
1
);
if
(
g_sensorInfo
==
nullptr
)
{
EXPECT_NE
(
nullptr
,
g_sensorInfo
);
return
;
}
int32_t
ret
=
g_sensorDev
->
Enable
(
-
1
);
EXPECT_EQ
(
-
2
,
ret
);
ret
=
g_sensorDev
->
Disable
(
-
1
);
EXPECT_EQ
(
-
2
,
ret
);
...
...
@@ -321,20 +324,29 @@ HWTEST_F(HdfSensorTest, EnableSensor002, Function | MediumTest | Level1)
*/
HWTEST_F
(
HdfSensorTest
,
SetSensorBatch001
,
Function
|
MediumTest
|
Level1
)
{
struct
SensorInformation
*
sensorInfo
=
nullptr
;
int32_t
count
=
0
;
struct
SensorInformation
*
info
=
nullptr
;
int32_t
ret
=
g_sensorDev
->
Register
(
SensorTestDataCallback
);
EXPECT_EQ
(
0
,
ret
);
ret
=
g_sensorDev
->
GetAllSensors
(
&
sensorInfo
,
&
count
);
EXPECT_EQ
(
0
,
ret
);
ret
=
g_sensorDev
->
SetBatch
(
SENSOR_ID
,
SENSOR_INTERVAL
,
SENSOR_POLL_TIME
);
EXPECT_EQ
(
0
,
ret
);
ret
=
g_sensorDev
->
Enable
(
SENSOR_ID
);
EXPECT_EQ
(
0
,
ret
);
OsalMSleep
(
SENSOR_WAIT_TIME
);
ret
=
g_sensorDev
->
Disable
(
SENSOR_ID
);
EXPECT_EQ
(
0
,
ret
);
if
(
g_sensorInfo
==
nullptr
)
{
EXPECT_NE
(
nullptr
,
g_sensorInfo
);
return
;
}
info
=
g_sensorInfo
;
for
(
int
i
=
0
;
i
<
g_count
;
i
++
)
{
ret
=
g_sensorDev
->
SetBatch
(
info
->
sensorId
,
SENSOR_INTERVAL
,
SENSOR_POLL_TIME
);
EXPECT_EQ
(
0
,
ret
);
ret
=
g_sensorDev
->
Enable
(
info
->
sensorId
);
EXPECT_EQ
(
0
,
ret
);
OsalMSleep
(
SENSOR_WAIT_TIME
);
EXPECT_EQ
(
1
,
g_sensorDataFlag
);
ret
=
g_sensorDev
->
Disable
(
info
->
sensorId
);
EXPECT_EQ
(
0
,
ret
);
info
++
;
}
ret
=
g_sensorDev
->
Unregister
();
EXPECT_EQ
(
0
,
ret
);
}
...
...
@@ -345,12 +357,7 @@ HWTEST_F(HdfSensorTest, SetSensorBatch001, Function | MediumTest | Level1)
*/
HWTEST_F
(
HdfSensorTest
,
SetSensorBatch002
,
Function
|
MediumTest
|
Level1
)
{
struct
SensorInformation
*
sensorInfo
=
nullptr
;
int32_t
count
=
0
;
int32_t
ret
=
g_sensorDev
->
GetAllSensors
(
&
sensorInfo
,
&
count
);
EXPECT_EQ
(
0
,
ret
);
ret
=
g_sensorDev
->
SetBatch
(
-
1
,
0
,
0
);
int32_t
ret
=
g_sensorDev
->
SetBatch
(
-
1
,
0
,
0
);
EXPECT_EQ
(
-
2
,
ret
);
}
...
...
@@ -361,27 +368,37 @@ HWTEST_F(HdfSensorTest, SetSensorBatch002, Function | MediumTest | Level1)
*/
HWTEST_F
(
HdfSensorTest
,
SetSensorMode001
,
Function
|
MediumTest
|
Level1
)
{
struct
SensorInformation
*
sensorInfo
=
nullptr
;
int32_t
count
=
0
;
struct
SensorInformation
*
info
=
nullptr
;
int32_t
ret
=
g_sensorDev
->
Register
(
SensorTestDataCallback
);
EXPECT_EQ
(
0
,
ret
);
ret
=
g_sensorDev
->
GetAllSensors
(
&
sensorInfo
,
&
count
);
EXPECT_EQ
(
0
,
ret
);
ret
=
g_sensorDev
->
SetBatch
(
SENSOR_ID
,
SENSOR_INTERVAL
,
SENSOR_POLL_TIME
);
EXPECT_EQ
(
0
,
ret
);
if
(
SENSOR_ID
==
SENSOR_TYPE_HALL
)
{
ret
=
g_sensorDev
->
SetMode
(
SENSOR_ID
,
SENSOR_MODE_ON_CHANGE
);
if
(
g_sensorInfo
==
nullptr
)
{
EXPECT_NE
(
nullptr
,
g_sensorInfo
);
return
;
}
info
=
g_sensorInfo
;
for
(
int
i
=
0
;
i
<
g_count
;
i
++
)
{
ret
=
g_sensorDev
->
SetBatch
(
info
->
sensorId
,
SENSOR_INTERVAL
,
SENSOR_POLL_TIME
);
EXPECT_EQ
(
0
,
ret
);
if
(
info
->
sensorId
==
SENSOR_TYPE_HALL
)
{
ret
=
g_sensorDev
->
SetMode
(
info
->
sensorId
,
SENSOR_MODE_ON_CHANGE
);
EXPECT_EQ
(
0
,
ret
);
}
else
{
ret
=
g_sensorDev
->
SetMode
(
info
->
sensorId
,
SENSOR_MODE_REALTIME
);
EXPECT_EQ
(
0
,
ret
);
}
ret
=
g_sensorDev
->
Enable
(
info
->
sensorId
);
EXPECT_EQ
(
0
,
ret
);
}
else
{
ret
=
g_sensorDev
->
SetMode
(
SENSOR_ID
,
SENSOR_MODE_REALTIME
);
OsalMSleep
(
SENSOR_WAIT_TIME
);
EXPECT_EQ
(
1
,
g_sensorDataFlag
);
ret
=
g_sensorDev
->
Disable
(
info
->
sensorId
);
EXPECT_EQ
(
0
,
ret
);
info
++
;
}
ret
=
g_sensorDev
->
Enable
(
SENSOR_ID
);
EXPECT_EQ
(
0
,
ret
);
OsalMSleep
(
SENSOR_WAIT_TIME
);
ret
=
g_sensorDev
->
Disable
(
SENSOR_ID
);
EXPECT_EQ
(
0
,
ret
);
ret
=
g_sensorDev
->
Unregister
();
EXPECT_EQ
(
0
,
ret
);
}
...
...
@@ -394,22 +411,31 @@ HWTEST_F(HdfSensorTest, SetSensorMode001, Function | MediumTest | Level1)
*/
HWTEST_F
(
HdfSensorTest
,
SetSensorMode002
,
Function
|
MediumTest
|
Level1
)
{
struct
SensorInformation
*
sensorInfo
=
nullptr
;
int32_t
count
=
0
;
struct
SensorInformation
*
info
=
nullptr
;
int32_t
ret
=
g_sensorDev
->
Register
(
SensorTestDataCallback
);
EXPECT_EQ
(
0
,
ret
);
ret
=
g_sensorDev
->
GetAllSensors
(
&
sensorInfo
,
&
count
);
EXPECT_EQ
(
0
,
ret
);
ret
=
g_sensorDev
->
SetBatch
(
SENSOR_ID
,
SENSOR_INTERVAL
,
SENSOR_POLL_TIME
);
EXPECT_EQ
(
0
,
ret
);
ret
=
g_sensorDev
->
SetMode
(
SENSOR_ID
,
SENSOR_MODE_DEFAULT
);
EXPECT_EQ
(
-
1
,
ret
);
ret
=
g_sensorDev
->
Enable
(
SENSOR_ID
);
EXPECT_EQ
(
0
,
ret
);
OsalMSleep
(
SENSOR_WAIT_TIME
);
ret
=
g_sensorDev
->
Disable
(
SENSOR_ID
);
EXPECT_EQ
(
0
,
ret
);
if
(
g_sensorInfo
==
nullptr
)
{
EXPECT_NE
(
nullptr
,
g_sensorInfo
);
return
;
}
info
=
g_sensorInfo
;
for
(
int
i
=
0
;
i
<
g_count
;
i
++
)
{
ret
=
g_sensorDev
->
SetBatch
(
info
->
sensorId
,
SENSOR_INTERVAL
,
SENSOR_POLL_TIME
);
EXPECT_EQ
(
0
,
ret
);
ret
=
g_sensorDev
->
SetMode
(
info
->
sensorId
,
SENSOR_MODE_DEFAULT
);
EXPECT_EQ
(
-
1
,
ret
);
ret
=
g_sensorDev
->
Enable
(
info
->
sensorId
);
EXPECT_EQ
(
0
,
ret
);
OsalMSleep
(
SENSOR_WAIT_TIME
);
EXPECT_EQ
(
1
,
g_sensorDataFlag
);
ret
=
g_sensorDev
->
Disable
(
info
->
sensorId
);
EXPECT_EQ
(
0
,
ret
);
info
++
;
}
ret
=
g_sensorDev
->
Unregister
();
EXPECT_EQ
(
0
,
ret
);
}
...
...
@@ -421,12 +447,11 @@ HWTEST_F(HdfSensorTest, SetSensorMode002, Function | MediumTest | Level1)
*/
HWTEST_F
(
HdfSensorTest
,
SetSensorOption001
,
Function
|
MediumTest
|
Level1
)
{
struct
SensorInformation
*
sensorInfo
=
nullptr
;
int32_t
count
=
0
;
struct
SensorInformation
*
g_sensorInfo
=
nullptr
;
int32_t
ret
=
g_sensorDev
->
Register
(
SensorTestDataCallback
);
EXPECT_EQ
(
0
,
ret
);
ret
=
g_sensorDev
->
GetAllSensors
(
&
sensorInfo
,
&
count
);
ret
=
g_sensorDev
->
GetAllSensors
(
&
g_sensorInfo
,
&
g_
count
);
EXPECT_EQ
(
0
,
ret
);
ret
=
g_sensorDev
->
SetBatch
(
SENSOR_ID
,
SENSOR_INTERVAL
,
SENSOR_POLL_TIME
);
EXPECT_EQ
(
0
,
ret
);
...
...
@@ -435,6 +460,7 @@ HWTEST_F(HdfSensorTest, SetSensorOption001, Function | MediumTest | Level1)
ret
=
g_sensorDev
->
Enable
(
SENSOR_ID
);
EXPECT_EQ
(
0
,
ret
);
OsalMSleep
(
SENSOR_WAIT_TIME
);
EXPECT_EQ
(
1
,
g_sensorDataFlag
);
ret
=
g_sensorDev
->
Disable
(
SENSOR_ID
);
EXPECT_EQ
(
0
,
ret
);
ret
=
g_sensorDev
->
Unregister
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录