mirror of
https://gitee.com/openharmony/xts_hats
synced 2024-12-11 17:07:55 +00:00
Override Enumeration
Signed-off-by: Yyyingchao <chenyingchao4@huawei.com> Change-Id: I8a10c572fd2230f72f6027a54a600f0597e4d4b0
This commit is contained in:
parent
e60b71dbfa
commit
879b03b304
@ -21,6 +21,7 @@
|
||||
#include "osal_time.h"
|
||||
#include "v1_0/ilight_interface.h"
|
||||
#include "light_type.h"
|
||||
#include <hdf_log.h>
|
||||
|
||||
using namespace OHOS::HDI::Light::V1_0;
|
||||
using namespace testing::ext;
|
||||
@ -32,7 +33,6 @@ namespace {
|
||||
constexpr int32_t g_onTime = 500;
|
||||
constexpr int32_t g_offTime = 500;
|
||||
sptr<ILightInterface> g_lightInterface = nullptr;
|
||||
}
|
||||
|
||||
class HdfLightHdiServiceTest : public testing::Test {
|
||||
public:
|
||||
@ -113,7 +113,7 @@ HWTEST_F(HdfLightHdiServiceTest, SUB_DriverSystem_LightHdi_0030, Function | Medi
|
||||
effect.lightColor.colorValue.rgbColor.r = 255;
|
||||
effect.lightColor.colorValue.rgbColor.g = 0;
|
||||
effect.lightColor.colorValue.rgbColor.b = 0;
|
||||
effect.flashEffect.flashMode = HDF_LIGHT_FLASH_NONE;
|
||||
effect.flashEffect.flashMode = LIGHT_FLASH_NONE;
|
||||
int32_t ret = g_lightInterface->TurnOnLight(iter.lightId, effect);
|
||||
EXPECT_EQ(HDF_SUCCESS, ret);
|
||||
OsalSleep(g_sleepTime);
|
||||
@ -145,7 +145,7 @@ HWTEST_F(HdfLightHdiServiceTest, SUB_DriverSystem_LightHdi_0040, Function | Medi
|
||||
effect.lightColor.colorValue.rgbColor.r = 255;
|
||||
effect.lightColor.colorValue.rgbColor.g = 0;
|
||||
effect.lightColor.colorValue.rgbColor.b = 0;
|
||||
effect.flashEffect.flashMode = HDF_LIGHT_FLASH_BUTT;
|
||||
effect.flashEffect.flashMode = LIGHT_FLASH_BUTT;
|
||||
int32_t ret = g_lightInterface->TurnOnLight(iter.lightId, effect);
|
||||
EXPECT_EQ(LIGHT_NOT_FLASH, ret);
|
||||
}
|
||||
@ -174,7 +174,7 @@ HWTEST_F(HdfLightHdiServiceTest, SUB_DriverSystem_LightHdi_0050, Function | Medi
|
||||
effect.lightColor.colorValue.rgbColor.r = 255;
|
||||
effect.lightColor.colorValue.rgbColor.g = 0;
|
||||
effect.lightColor.colorValue.rgbColor.b = 0;
|
||||
effect.flashEffect.flashMode = HDF_LIGHT_FLASH_BLINK;
|
||||
effect.flashEffect.flashMode = LIGHT_FLASH_BLINK;
|
||||
effect.flashEffect.onTime = g_onTime;
|
||||
effect.flashEffect.offTime = g_offTime;
|
||||
int32_t ret = g_lightInterface->TurnOnLight(iter.lightId, effect);
|
||||
@ -185,6 +185,38 @@ HWTEST_F(HdfLightHdiServiceTest, SUB_DriverSystem_LightHdi_0050, Function | Medi
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: TurnOnLight005
|
||||
* @tc.desc: TurnOnLight.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(HdfLightHdiServiceTest, SUB_DriverSystem_LightHdi_0170, Function | MediumTest | Level1)
|
||||
{
|
||||
ASSERT_NE(nullptr, g_lightInterface);
|
||||
|
||||
std::vector<HdfLightInfo> info;
|
||||
int32_t ret = g_lightInterface->GetLightInfo(info);
|
||||
EXPECT_EQ(HDF_SUCCESS, ret);
|
||||
printf("get light list num[%zu]\n\r", info.size());
|
||||
|
||||
for (auto iter : info)
|
||||
{
|
||||
EXPECT_GE(iter.lightId, g_minLightId);
|
||||
EXPECT_LE(iter.lightId, g_maxLightId);
|
||||
|
||||
HdfLightEffect effect;
|
||||
effect.lightColor.colorValue.rgbColor.r = 255;
|
||||
effect.lightColor.colorValue.rgbColor.g = 0;
|
||||
effect.lightColor.colorValue.rgbColor.b = 0;
|
||||
effect.flashEffect.flashMode = LIGHT_FLASH_GRADIENT;
|
||||
int32_t ret = g_lightInterface->TurnOnLight(iter.lightId, effect);
|
||||
EXPECT_EQ(HDF_ERR_NOT_SUPPORT, ret);
|
||||
OsalSleep(g_sleepTime);
|
||||
ret = g_lightInterface->TurnOffLight(iter.lightId);
|
||||
EXPECT_EQ(HDF_SUCCESS, ret);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: DisableLight001
|
||||
* @tc.desc: DisableLight.
|
||||
@ -200,3 +232,21 @@ HWTEST_F(HdfLightHdiServiceTest, SUB_DriverSystem_LightHdi_0160, Function | Medi
|
||||
ret = g_lightInterface->TurnOffLight(HDF_LIGHT_ID_BUTT);
|
||||
EXPECT_EQ(LIGHT_NOT_SUPPORT, ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: DisableLight002
|
||||
* @tc.desc: DisableLight.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(HdfLightHdiServiceTest, SUB_DriverSystem_LightHdi_0180, Function | MediumTest | Level1)
|
||||
{
|
||||
ASSERT_NE(nullptr, g_lightInterface);
|
||||
|
||||
HdfLightEffect effect;
|
||||
int32_t ret = g_lightInterface->TurnOnLight(HDF_LIGHT_ID_NOTIFICATIONS, effect);
|
||||
EXPECT_EQ(LIGHT_NOT_SUPPORT, ret);
|
||||
ret = g_lightInterface->TurnOffLight(HDF_LIGHT_ID_NOTIFICATIONS);
|
||||
EXPECT_EQ(LIGHT_NOT_SUPPORT, ret);
|
||||
}
|
||||
|
||||
}
|
@ -101,7 +101,7 @@ BENCHMARK_F(lightBenchmarkTest, SUB_DriverSystem_LightBenchmark_0020)(benchmark:
|
||||
effect.lightColor.colorValue.rgbColor.r = 255;
|
||||
effect.lightColor.colorValue.rgbColor.g = 0;
|
||||
effect.lightColor.colorValue.rgbColor.b = 0;
|
||||
effect.flashEffect.flashMode = HDF_LIGHT_FLASH_NONE;
|
||||
effect.flashEffect.flashMode = LIGHT_FLASH_NONE;
|
||||
int32_t ret;
|
||||
for (auto _ : st) {
|
||||
ret = g_lightInterface->TurnOnLight(iter.lightId, effect);
|
||||
@ -139,7 +139,7 @@ BENCHMARK_F(lightBenchmarkTest, SUB_DriverSystem_LightBenchmark_0030)(benchmark:
|
||||
effect.lightColor.colorValue.rgbColor.r = 255;
|
||||
effect.lightColor.colorValue.rgbColor.g = 0;
|
||||
effect.lightColor.colorValue.rgbColor.b = 0;
|
||||
effect.flashEffect.flashMode = HDF_LIGHT_FLASH_BLINK;
|
||||
effect.flashEffect.flashMode = LIGHT_FLASH_BLINK;
|
||||
effect.flashEffect.onTime = g_onTime;
|
||||
effect.flashEffect.offTime = g_offTime;
|
||||
int32_t ret = g_lightInterface->TurnOnLight(iter.lightId, effect);
|
||||
|
@ -669,6 +669,96 @@ HWTEST_F(HdfSensorHdiTest, SUB_DriverSystem_HdiSensor_0320, TestSize.Level1)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: SetSensorMode0001
|
||||
* @tc.desc: Sets the data reporting mode for the specified sensor.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(HdfSensorHdiTest, SUB_DriverSystem_HdiSensor_0321, TestSize.Level1)
|
||||
{
|
||||
if (g_sensorInterface == nullptr) {
|
||||
ASSERT_NE(nullptr, g_sensorInterface);
|
||||
return;
|
||||
}
|
||||
EXPECT_GT(g_info.size(), 0);
|
||||
for (auto iter : g_info) {
|
||||
int32_t ret = g_sensorInterface->SetBatch(iter.sensorId, SENSOR_INTERVAL1, SENSOR_POLL_TIME);
|
||||
EXPECT_EQ(SENSOR_SUCCESS, ret);
|
||||
if (iter.sensorId == SENSOR_TYPE_HALL) {
|
||||
ret = g_sensorInterface->SetMode(iter.sensorId, SENSOR_MODE_ONE_SHOT);
|
||||
EXPECT_EQ(SENSOR_SUCCESS, ret);
|
||||
} else {
|
||||
ret = g_sensorInterface->SetMode(iter.sensorId, SENSOR_MODE_REALTIME);
|
||||
EXPECT_EQ(SENSOR_SUCCESS, ret);
|
||||
}
|
||||
ret = g_sensorInterface->Enable(iter.sensorId);
|
||||
EXPECT_EQ(SENSOR_SUCCESS, ret);
|
||||
OsalMSleep(SENSOR_WAIT_TIME);
|
||||
ret = g_sensorInterface->Disable(iter.sensorId);
|
||||
EXPECT_EQ(SENSOR_SUCCESS, ret);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: SetSensorMode0001
|
||||
* @tc.desc: Sets the data reporting mode for the specified sensor.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(HdfSensorHdiTest, SUB_DriverSystem_HdiSensor_0322, TestSize.Level1)
|
||||
{
|
||||
if (g_sensorInterface == nullptr) {
|
||||
ASSERT_NE(nullptr, g_sensorInterface);
|
||||
return;
|
||||
}
|
||||
EXPECT_GT(g_info.size(), 0);
|
||||
for (auto iter : g_info) {
|
||||
int32_t ret = g_sensorInterface->SetBatch(iter.sensorId, SENSOR_INTERVAL1, SENSOR_POLL_TIME);
|
||||
EXPECT_EQ(SENSOR_SUCCESS, ret);
|
||||
if (iter.sensorId == SENSOR_TYPE_HALL) {
|
||||
ret = g_sensorInterface->SetMode(iter.sensorId, SENSOR_MODE_FIFO_MODE);
|
||||
EXPECT_EQ(SENSOR_SUCCESS, ret);
|
||||
} else {
|
||||
ret = g_sensorInterface->SetMode(iter.sensorId, SENSOR_MODE_REALTIME);
|
||||
EXPECT_EQ(SENSOR_SUCCESS, ret);
|
||||
}
|
||||
ret = g_sensorInterface->Enable(iter.sensorId);
|
||||
EXPECT_EQ(SENSOR_SUCCESS, ret);
|
||||
OsalMSleep(SENSOR_WAIT_TIME);
|
||||
ret = g_sensorInterface->Disable(iter.sensorId);
|
||||
EXPECT_EQ(SENSOR_SUCCESS, ret);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: SetSensorMode0001
|
||||
* @tc.desc: Sets the data reporting mode for the specified sensor.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(HdfSensorHdiTest, SUB_DriverSystem_HdiSensor_0323, TestSize.Level1)
|
||||
{
|
||||
if (g_sensorInterface == nullptr) {
|
||||
ASSERT_NE(nullptr, g_sensorInterface);
|
||||
return;
|
||||
}
|
||||
EXPECT_GT(g_info.size(), 0);
|
||||
for (auto iter : g_info) {
|
||||
int32_t ret = g_sensorInterface->SetBatch(iter.sensorId, SENSOR_INTERVAL1, SENSOR_POLL_TIME);
|
||||
EXPECT_EQ(SENSOR_SUCCESS, ret);
|
||||
if (iter.sensorId == SENSOR_TYPE_HALL) {
|
||||
ret = g_sensorInterface->SetMode(iter.sensorId, SENSOR_MODE_MAX);
|
||||
EXPECT_EQ(SENSOR_SUCCESS, ret);
|
||||
} else {
|
||||
ret = g_sensorInterface->SetMode(iter.sensorId, SENSOR_MODE_REALTIME);
|
||||
EXPECT_EQ(SENSOR_SUCCESS, ret);
|
||||
}
|
||||
ret = g_sensorInterface->Enable(iter.sensorId);
|
||||
EXPECT_EQ(SENSOR_SUCCESS, ret);
|
||||
OsalMSleep(SENSOR_WAIT_TIME);
|
||||
ret = g_sensorInterface->Disable(iter.sensorId);
|
||||
EXPECT_EQ(SENSOR_SUCCESS, ret);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: SetSensorMode0002
|
||||
* @tc.desc: Sets the data reporting mode for the specified sensor.The current real-time polling mode is valid.
|
||||
|
@ -32,6 +32,8 @@ namespace {
|
||||
uint32_t g_duration = 1;
|
||||
uint32_t g_sleepTime1 = 1;
|
||||
uint32_t g_sleepTime2 = 2;
|
||||
int32_t g_intensity1 = 3;
|
||||
int32_t g_frequency1 = 20;
|
||||
std::string g_timeSequence = "haptic.clock.timer";
|
||||
std::string g_builtIn = "haptic.default.effect";
|
||||
std::string g_arbitraryStr = "arbitraryString";
|
||||
@ -129,6 +131,83 @@ BENCHMARK_F(vibratorBenchmarkTest, SUB_DriverSystem_VibratorBenchmark_0030)(benc
|
||||
|
||||
BENCHMARK_REGISTER_F(vibratorBenchmarkTest, SUB_DriverSystem_VibratorBenchmark_0030)->
|
||||
Iterations(100)->Repetitions(3)->ReportAggregatesOnly();
|
||||
|
||||
/**
|
||||
* @tc.name: SUB_DriverSystem_VibratorBenchmark_0040
|
||||
* @tc.desc: Benchmarktest for interface GetVibratorInfo.
|
||||
* Controls this Performing Time Series Vibrator Effects.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
BENCHMARK_F(vibratorBenchmarkTest, SUB_DriverSystem_VibratorBenchmark_0040)(benchmark::State &state)
|
||||
{
|
||||
uint32_t majorVer;
|
||||
uint32_t minorVer;
|
||||
uint32_t ret;
|
||||
|
||||
ASSERT_NE(nullptr, g_vibratorInterface);
|
||||
|
||||
ret = g_vibratorInterface->GetVersion(majorVer, minorVer);
|
||||
ASSERT_EQ(HDF_SUCCESS, ret);
|
||||
|
||||
ASSERT_LT(0, minorVer);
|
||||
ASSERT_LT(0, majorVer);
|
||||
|
||||
std::vector<HdfVibratorInfo> info;
|
||||
|
||||
for (auto _ : state) {
|
||||
int32_t startRet = g_vibratorInterface->GetVibratorInfo(info);
|
||||
EXPECT_EQ(startRet, HDF_SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK_REGISTER_F(vibratorBenchmarkTest, SUB_DriverSystem_VibratorBenchmark_0040)->
|
||||
Iterations(100)->Repetitions(3)->ReportAggregatesOnly();
|
||||
|
||||
/**
|
||||
* @tc.name: SUB_DriverSystem_VibratorBenchmark_0050
|
||||
* @tc.desc: Benchmarktest for interface EnableVibratorModulation.
|
||||
* Controls this Performing built-in Vibrator Effects.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
BENCHMARK_F(vibratorBenchmarkTest, SUB_DriverSystem_VibratorBenchmark_0050)(benchmark::State &state)
|
||||
{
|
||||
uint32_t majorVer;
|
||||
uint32_t minorVer;
|
||||
if (g_vibratorInterface->GetVersion(majorVer, minorVer) != HDF_SUCCESS) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (majorVer > 0 && minorVer <= 0) {
|
||||
return;
|
||||
}
|
||||
ASSERT_NE(nullptr, g_vibratorInterface);
|
||||
|
||||
std::vector<HdfVibratorInfo> info;
|
||||
|
||||
int32_t startRet = g_vibratorInterface->GetVibratorInfo(info);
|
||||
EXPECT_EQ(startRet, HDF_SUCCESS);
|
||||
|
||||
for (auto _ : state) {
|
||||
if ((info[0].isSupportIntensity == 1) || (info[0].isSupportFrequency == 1)) {
|
||||
printf("vibratot benchmarktest successed!\n\t");
|
||||
EXPECT_GT(g_duration, 0);
|
||||
EXPECT_GE(g_intensity1, info[0].intensityMinValue);
|
||||
EXPECT_LE(g_intensity1, info[0].intensityMaxValue);
|
||||
EXPECT_GE(g_frequency1, info[0].frequencyMinValue);
|
||||
EXPECT_LE(g_frequency1, info[0].frequencyMaxValue);
|
||||
printf("vibratot benchmark test successed!\n\t");
|
||||
startRet = g_vibratorInterface->EnableVibratorModulation(g_duration, g_intensity1, g_frequency1);
|
||||
EXPECT_EQ(startRet, HDF_SUCCESS);
|
||||
OsalMSleep(g_sleepTime1);
|
||||
startRet = g_vibratorInterface->Stop(HDF_VIBRATOR_MODE_ONCE);
|
||||
EXPECT_EQ(startRet, HDF_SUCCESS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK_REGISTER_F(vibratorBenchmarkTest, SUB_DriverSystem_VibratorBenchmark_0050)->
|
||||
Iterations(100)->Repetitions(3)->ReportAggregatesOnly();
|
||||
|
||||
}
|
||||
|
||||
BENCHMARK_MAIN();
|
Loading…
Reference in New Issue
Block a user