diff options
-rw-r--r-- | haltest/CMakeLists.txt | 1 | ||||
-rw-r--r-- | haltest/main.cpp | 13 | ||||
-rw-r--r-- | haltest/sensor-device.cpp | 10 | ||||
-rw-r--r-- | haltest/sensor-haltest.h | 52 | ||||
-rw-r--r-- | packaging/hal-api-sensor.spec | 1 |
5 files changed, 71 insertions, 6 deletions
diff --git a/haltest/CMakeLists.txt b/haltest/CMakeLists.txt index 97c237c..6cccd68 100644 --- a/haltest/CMakeLists.txt +++ b/haltest/CMakeLists.txt @@ -12,6 +12,7 @@ SET(REQUIRES_LIST ${REQUIRES_LIST} gio-2.0 gmock dlog + capi-system-info ) FIND_LIBRARY( diff --git a/haltest/main.cpp b/haltest/main.cpp index 287c9f4..1a20fef 100644 --- a/haltest/main.cpp +++ b/haltest/main.cpp @@ -12,14 +12,20 @@ protected: static void SetUpHalTestSuite() { } - void SetUp() override {} + void SetUp() override { + int ret_val = check_feature_all(); + if (!ret_val) { + SKIP_MESSAGE("All sensor features are false"); + GTEST_SKIP(); + return; + } + } void TearDown() override {} }; TEST_F(SENSOR_API, GetBackendP) { int ret_val; - ret_val = hal_sensor_get_backend(); EXPECT_EQ(ret_val, 0) << strerr("Failed to get sensor device", ret_val); } @@ -27,12 +33,11 @@ TEST_F(SENSOR_API, GetBackendP) TEST_F(SENSOR_API, CreateP) { int ret_val; - void **devices; ret_val = hal_sensor_create(&devices); if (ret_val == -ENODEV) { SKIP_MESSAGE("Not supported HAL"); - return ; + return; } ASSERT_GT(ret_val, 0) << strerr("Failed to call create", ret_val); ASSERT_NE(devices[0], nullptr) << "Opened devices are invalid."; diff --git a/haltest/sensor-device.cpp b/haltest/sensor-device.cpp index 58bd034..3b87482 100644 --- a/haltest/sensor-device.cpp +++ b/haltest/sensor-device.cpp @@ -13,7 +13,6 @@ public: static void SetUpHalTestSuite() { void **sensors = nullptr; - device_count = hal_sensor_create(&sensors); ASSERT_GT(device_count, 0) << "Failed to get sensor devices"; @@ -23,7 +22,14 @@ public: } } - void SetUp() override{} + void SetUp() override { + int ret_val = check_feature_all(); + if (!ret_val) { + SKIP_MESSAGE("All sensor features are false"); + GTEST_SKIP(); + return; + } + } void TearDown() override{} }; diff --git a/haltest/sensor-haltest.h b/haltest/sensor-haltest.h index 3e030f1..88ef284 100644 --- a/haltest/sensor-haltest.h +++ b/haltest/sensor-haltest.h @@ -16,6 +16,7 @@ #ifndef __SENSOR_HALTEST_H__ #define __SENSOR_HALTEST_H__ +#include <system_info.h> #include <gtest/gtest.h> #include <string.h> @@ -63,6 +64,57 @@ do { \ #define BUFMAX 256 static char errbuf1[BUFMAX]; +#define FEATURE_NUM 37 +static const char *feature[FEATURE_NUM] = { + "http://tizen.org/feature/sensor.accelerometer", + "http://tizen.org/feature/sensor.accelerometer.wakeup", + "http://tizen.org/feature/sensor.activity_recognition", + "http://tizen.org/feature/sensor.barometer", + "http://tizen.org/feature/sensor.barometer.wakeup", + "http://tizen.org/feature/sensor.geomagnetic_rotation_vector", + "http://tizen.org/feature/sensor.gesture_recognition", + "http://tizen.org/feature/sensor.gravity", + "http://tizen.org/feature/sensor.gyroscope", + "http://tizen.org/feature/sensor.gyroscope_rotation_vector", + "http://tizen.org/feature/sensor.gyroscope.uncalibrated", + "http://tizen.org/feature/sensor.gyroscope.wakeup", + "http://tizen.org/feature/sensor.heart_rate_monitor", + "http://tizen.org/feature/sensor.heart_rate_monitor.batch", + "http://tizen.org/feature/sensor.heart_rate_monitor.led_green", + "http://tizen.org/feature/sensor.heart_rate_monitor.led_green.batch", + "http://tizen.org/feature/sensor.heart_rate_monitor.led_ir", + "http://tizen.org/feature/sensor.heart_rate_monitor.led_red", + "http://tizen.org/feature/sensor.humidity", + "http://tizen.org/feature/sensor.linear_acceleration", + "http://tizen.org/feature/sensor.magnetometer", + "http://tizen.org/feature/sensor.magnetometer.uncalibrated", + "http://tizen.org/feature/sensor.magnetometer.wakeup", + "http://tizen.org/feature/sensor.pedometer", + "http://tizen.org/feature/sensor.photometer", + "http://tizen.org/feature/sensor.photometer.wakeup", + "http://tizen.org/feature/sensor.proximity", + "http://tizen.org/feature/sensor.proximity.wakeup", + "http://tizen.org/feature/sensor.rotation_vector", + "http://tizen.org/feature/sensor.significant_motion", + "http://tizen.org/feature/sensor.sleep_monitor", + "http://tizen.org/feature/sensor.stress_monitor", + "http://tizen.org/feature/sensor.temperature", + "http://tizen.org/feature/sensor.tiltmeter", + "http://tizen.org/feature/sensor.tiltmeter.wakeup", + "http://tizen.org/feature/sensor.ultraviolet", + "http://tizen.org/feature/sensor.wrist_up" +}; + +static bool check_feature_all() { + bool ret, val; + for (int i = 0; i < FEATURE_NUM; ++i) { + ret = system_info_get_platform_bool(feature[i], &val); + if (!ret && val) + return true; + } + return false; +} + static inline const char* strerr(const char* message, int eno) { if (eno == 0) diff --git a/packaging/hal-api-sensor.spec b/packaging/hal-api-sensor.spec index 8c7ac36..ca81eea 100644 --- a/packaging/hal-api-sensor.spec +++ b/packaging/hal-api-sensor.spec @@ -21,6 +21,7 @@ BuildRequires: pkgconfig(gio-2.0) BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(gmock) BuildRequires: pkgconfig(hal-api-common) +BuildRequires: pkgconfig(capi-system-info) %description %{name} interface |