[UTC][device][Non-ACR] Fix ENOTSUP not to be considered as an error 79/271979/1
authorYoungjae Cho <y0.cho@samsung.com>
Fri, 4 Mar 2022 06:11:21 +0000 (15:11 +0900)
committerHyotaek Shim <hyotaek.shim@samsung.com>
Fri, 4 Mar 2022 07:42:30 +0000 (07:42 +0000)
Change-Id: I027ebcd4e611ecb1cc06d1d76a137a88620579d9
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
src/utc/device/utc-system-device-display.c

index 6142e6e502834b55919214366c9f3791aaa694e1..bc74119a0eb724579bbc2755cef2157bd0160cc2 100755 (executable)
@@ -33,6 +33,23 @@ static bool g_DisplayStateFeature = false;
 
 static int cnt;
 
+/* Do not regard DEVICE_ERROR_NOT_SUPPORTED as an error for brightness operation.
+ *
+ * It is likely to return DEVICE_ERROR_NOT_SUPPORTED even though the display feature is true.
+ * This is mainly in case of headed tizeniot profile, which supports plugin-display.
+ * If a display is attached, it works properly, returning DEVICE_ERROR_NONE. On the other hand,
+ * if a display is detached, it returns DEVICE_ERROR_NOT_SUPPORTED and it won't work. This is
+ * intended behaviour, not an error case. */
+static int assert_except_not_supported(int error, int val)
+{
+       if (error == DEVICE_ERROR_NOT_SUPPORTED)
+               return 0;
+
+       assert_eq(error, val);
+
+       return 0;
+}
+
 /**
  * @function           utc_system_device_display_startup
  * @description                Called before each test
@@ -102,14 +119,16 @@ int utc_system_device_display_get_numbers_n(void)
  */
 int utc_system_device_display_get_max_brightness_p(void)
 {
-       int value, error, i;
+       int value, error, i, ret;
 
        for (i = 0; i < cnt; i++) {
                error = device_display_get_max_brightness(i, &value);
                if (g_DisplayFeature == false)
                        assert_eq(error, DEVICE_ERROR_NOT_SUPPORTED);
-               else
-                       assert_eq(error, DEVICE_ERROR_NONE);
+
+               ret = assert_except_not_supported(error, DEVICE_ERROR_NONE);
+               if (ret != 0)
+                       return ret;
        }
 
        return 0;
@@ -160,14 +179,16 @@ int utc_system_device_display_get_max_brightness_n_2(void)
  */
 int utc_system_device_display_get_brightness_p(void)
 {
-       int value, error, i;
+       int value, error, i, ret;
 
        for (i = 0; i < cnt; i++) {
                error = device_display_get_brightness(i, &value);
                if (g_DisplayFeature == false)
                        assert_eq(error, DEVICE_ERROR_NOT_SUPPORTED);
-               else
-                       assert_eq(error, DEVICE_ERROR_NONE);
+
+               ret = assert_except_not_supported(error, DEVICE_ERROR_NONE);
+               if (ret != 0)
+                       return ret;
        }
 
        return 0;
@@ -218,20 +239,24 @@ int utc_system_device_display_get_brightness_n_2(void)
  */
 int utc_system_device_display_set_brightness_p(void)
 {
-       int max, error, i;
+       int max, error, i, ret;
 
        for (i = 0; i < cnt; i++) {
                error = device_display_get_max_brightness(i, &max);
                if (g_DisplayFeature == false)
                        assert_eq(error, DEVICE_ERROR_NOT_SUPPORTED);
-               else
-                       assert_eq(error, DEVICE_ERROR_NONE);
+
+               ret = assert_except_not_supported(error, DEVICE_ERROR_NONE);
+               if (ret != 0)
+                       return ret;
 
                error = device_display_set_brightness(i, max);
                if (g_DisplayFeature == false)
                        assert_eq(error, DEVICE_ERROR_NOT_SUPPORTED);
-               else
-                       assert_eq(error, DEVICE_ERROR_NONE);
+
+               ret = assert_except_not_supported(error, DEVICE_ERROR_NONE);
+               if (ret != 0)
+                       return ret;
        }
 
        return 0;