Add checking features in sensor haltest 27/264627/2 accepted/tizen/unified/20210929.022404 submit/tizen/20210928.040319
authortaemin.yeom <taemin.yeom@samsung.com>
Mon, 27 Sep 2021 09:45:08 +0000 (18:45 +0900)
committertaemin.yeom <taemin.yeom@samsung.com>
Tue, 28 Sep 2021 03:40:33 +0000 (12:40 +0900)
Change-Id: I0d0086eb401d835a0520a94156d5f4512bbda625
Signed-off-by: taemin.yeom <taemin.yeom@samsung.com>
haltest/CMakeLists.txt
haltest/main.cpp
haltest/sensor-device.cpp
haltest/sensor-haltest.h
packaging/hal-api-sensor.spec

index 97c237c..6cccd68 100644 (file)
@@ -12,6 +12,7 @@ SET(REQUIRES_LIST ${REQUIRES_LIST}
     gio-2.0
     gmock
     dlog
+    capi-system-info
 )
 
 FIND_LIBRARY(
index 287c9f4..1a20fef 100644 (file)
@@ -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.";
index 58bd034..3b87482 100644 (file)
@@ -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{}
 };
 
index 3e030f1..88ef284 100644 (file)
@@ -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)
index 8c7ac36..ca81eea 100644 (file)
@@ -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