haltest: fix display test 70/254970/1
authorYoungjae Cho <y0.cho@samsung.com>
Thu, 11 Mar 2021 05:18:08 +0000 (14:18 +0900)
committerYoungjae Cho <y0.cho@samsung.com>
Thu, 11 Mar 2021 05:18:08 +0000 (14:18 +0900)
Added skip message for not supported feature.

Change-Id: I5a3419738e05234ca49865536b90c6d89dcaffaa
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
haltest/display.cpp
haltest/haltest.h

index 9f85a53..719a7a5 100644 (file)
@@ -1,7 +1,5 @@
-
-#include <iostream>
-#include <gtest/gtest.h>
 #include <system_info.h>
+
 #include "haltest.h"
 #include "hal-display.h"
 
@@ -10,22 +8,24 @@ using namespace std;
 /* Define Classes */
 class DISPLAY : public testing::Test
 {
-       public:
-               virtual void SetUp()
+       protected:
+               void SetUp() override
                {
                        int ret;
 
-                       ret = system_info_get_platform_bool(FEATURE_DISPLAY, &supported);
+                       ret = system_info_get_platform_bool(FEATURE_DISPLAY, &display_supported);
                        EXPECT_EQ(SYSTEM_INFO_ERROR_NONE, ret) << "system_info_get_platform_bool failed";
-
                }
 
-               virtual void TearDown()
+               void TearDown() override
                {
 
                }
+
+               bool display_supported;
 };
 
+
 /*
  * Testcase for Display
  */
@@ -33,8 +33,10 @@ TEST_F(DISPLAY, GetBackendP)
 {
        int ret;
 
-       if (!supported)
+       if (!display_supported) {
+               SKIP_MESSAGE("Display not supported");
                return;
+       }
 
        ret = hal_device_display_get_backend();
        EXPECT_EQ(ret, 0) << "Fail to get display device (" << ret << ")";
@@ -45,8 +47,10 @@ TEST_F(DISPLAY, GetMaxBrightnessP)
        int ret;
        int max;
 
-       if (!supported)
+       if (!display_supported) {
+               SKIP_MESSAGE("Display not supported");
                return;
+       }
 
        ret = hal_device_display_get_max_brightness(&max);
        if (ret == -ENODEV)
@@ -60,8 +64,10 @@ TEST_F(DISPLAY, GetBrightnessP)
        int ret;
        int brt;
 
-       if (!supported)
+       if (!display_supported) {
+               SKIP_MESSAGE("Display not supported");
                return;
+       }
 
        ret = hal_device_display_get_brightness(&brt);
        if (ret == -ENODEV)
@@ -75,8 +81,10 @@ TEST_F(DISPLAY, SetBrightnessP)
        int ret;
        int max = 100;
 
-       if (!supported)
+       if (!display_supported) {
+               SKIP_MESSAGE("Display not supported");
                return;
+       }
 
        ret = hal_device_display_set_brightness(max);
        if (ret == -ENODEV)
@@ -90,8 +98,10 @@ TEST_F(DISPLAY, SetMultiBrightnessP)
        int ret;
        int brt = 50, step = 5, delay = 10000;
 
-       if (!supported)
+       if (!display_supported) {
+               SKIP_MESSAGE("Display not supported");
                return;
+       }
 
        ret = hal_device_display_set_multi_brightness(brt, step, delay);
        if (ret == -ENODEV)
@@ -106,8 +116,10 @@ TEST_F(DISPLAY, GetAutoBrightnessP)
        int brt;
        float lmax = 0, lmin = 0, light = 0;
 
-       if (!supported)
+       if (!display_supported) {
+               SKIP_MESSAGE("Display not supported");
                return;
+       }
 
        ret = hal_device_display_get_auto_brightness(lmax, lmin, light, &brt);
        if (ret == -ENODEV)
@@ -121,8 +133,10 @@ TEST_F(DISPLAY, GetStateP)
        int ret;
        enum display_state state;
 
-       if (!supported)
+       if (!display_supported) {
+               SKIP_MESSAGE("Display not supported");
                return;
+       }
 
        ret = hal_device_display_get_state(&state);
        if (ret == -ENODEV)
@@ -135,8 +149,10 @@ TEST_F(DISPLAY, SetStateP)
 {
        int ret;
 
-       if (!supported)
+       if (!display_supported) {
+               SKIP_MESSAGE("Display not supported");
                return;
+       }
 
        ret = hal_device_display_set_state(DISPLAY_ON);
        if (ret == -ENODEV)
@@ -150,8 +166,10 @@ TEST_F(DISPLAY, GetImageEffectP)
        enum display_image_effect effect;
        int ret;
 
-       if (!supported)
+       if (!display_supported) {
+               SKIP_MESSAGE("Display not supported");
                return;
+       }
 
        ret = hal_device_display_get_image_effect(&effect);
        if (ret == -ENODEV)
@@ -164,8 +182,10 @@ TEST_F(DISPLAY, SetImageEffectP)
 {
        int ret;
 
-       if (!supported)
+       if (!display_supported) {
+               SKIP_MESSAGE("Display not supported");
                return;
+       }
 
        ret = hal_device_display_set_image_effect(DISPLAY_IMAGE_EFFECT_GREY);
        if (ret == -ENODEV)
@@ -179,8 +199,10 @@ TEST_F(DISPLAY, GetPanelModeP)
        enum display_panel_mode mode;
        int ret;
 
-       if (!supported)
+       if (!display_supported) {
+               SKIP_MESSAGE("Display not supported");
                return;
+       }
 
        ret = hal_device_display_get_panel_mode(&mode);
        if (ret == -ENODEV)
@@ -193,8 +215,10 @@ TEST_F(DISPLAY, SetPanelModeP)
 {
        int ret;
 
-       if (!supported)
+       if (!display_supported) {
+               SKIP_MESSAGE("Display not supported");
                return;
+       }
 
        ret = hal_device_display_set_panel_mode(DISPLAY_PANEL_MODE_LOWPOWER);
        if (ret == -ENODEV)
@@ -208,8 +232,10 @@ TEST_F(DISPLAY, GetAodModeP)
        enum display_aod_mode mode;
        int ret;
 
-       if (!supported)
+       if (!display_supported) {
+               SKIP_MESSAGE("Display not supported");
                return;
+       }
 
        ret = hal_device_display_get_aod_mode(&mode);
        if (ret == -ENODEV)
@@ -223,8 +249,10 @@ TEST_F(DISPLAY, GetAodBrightnessP)
        int max, normal, min, charging;
        int ret;
 
-       if (!supported)
+       if (!display_supported) {
+               SKIP_MESSAGE("Display not supported");
                return;
+       }
 
        ret = hal_device_display_get_aod_brightness(&max, &normal, &min, &charging);
        if (ret == -ENODEV)
@@ -239,8 +267,10 @@ TEST_F(DISPLAY, GetMaxFrameRateP)
        int ret;
        int max;
 
-       if (!supported)
+       if (!display_supported) {
+               SKIP_MESSAGE("Display not supported");
                return;
+       }
 
        ret = hal_device_display_get_max_frame_rate(&max);
        if (ret == -ENODEV)
@@ -254,8 +284,10 @@ TEST_F(DISPLAY, GetMinFrameRateP)
        int ret;
        int min;
 
-       if (!supported)
+       if (!display_supported) {
+               SKIP_MESSAGE("Display not supported");
                return;
+       }
 
        ret = hal_device_display_get_min_frame_rate(&min);
        if (ret == -ENODEV)
@@ -268,8 +300,10 @@ TEST_F(DISPLAY, GetFrameRateP)
 {
        int ret, rate;
 
-       if (!supported)
+       if (!display_supported) {
+               SKIP_MESSAGE("Display not supported");
                return;
+       }
 
        ret = hal_device_display_get_frame_rate(&rate);
        if (ret == -ENODEV)
@@ -282,8 +316,10 @@ TEST_F(DISPLAY, SetFrameRateP)
 {
        int ret, fmax;
 
-       if (!supported)
+       if (!display_supported) {
+               SKIP_MESSAGE("Display not supported");
                return;
+       }
 
        ret = hal_device_display_get_max_frame_rate(&fmax);
        if (ret == -ENODEV)
@@ -302,8 +338,10 @@ TEST_F(DISPLAY, DeinitP)
 {
        int ret;
 
-       if (!supported)
+       if (!display_supported) {
+               SKIP_MESSAGE("Display not supported");
                return;
+       }
 
        ret = hal_device_display_put_backend();
        EXPECT_GE(ret, 0) << "Fail to close display device (" << ret << ")";
index 2ddc558..8576f55 100644 (file)
 #ifndef __HALTEST_H__
 #define __HALTEST_H__
 
-#include <glib.h>
+#include <gtest/gtest.h>
+
+// hack gtest internal for print message
+namespace testing
+{
+       namespace internal
+       {
+               enum GTestColor {
+                       COLOR_DEFAULT,
+                       COLOR_RED,
+                       COLOR_GREEN,
+                       COLOR_YELLOW
+               };
+
+               extern void ColoredPrintf(GTestColor color, const char* fmt, ...);
+       }
+}
+
+#define SKIP_MESSAGE(args...) \
+do { \
+       testing::internal::ColoredPrintf(testing::internal::COLOR_YELLOW, "[  SKIPPED ] "); \
+       testing::internal::ColoredPrintf(testing::internal::COLOR_YELLOW, ##args); \
+       testing::internal::ColoredPrintf(testing::internal::COLOR_YELLOW, "\n"); \
+} while (0)
 
 #define FEATURE_BATTERY     "http://tizen.org/feature/battery"
 #define FEATURE_DISPLAY     "http://tizen.org/feature/display"
@@ -26,6 +49,4 @@
 #define FEATURE_BEZEL       "http://tizen.org/feature/input.rotating_bezel"
 
 
-bool supported;
-
 #endif /* __HALTEST_H__ */