[mutter] tests: Test that transforms are properly configured



commit 17c54c6e031a375b46862d2e82d13c566c931889
Author: Jonas Ådahl <jadahl gmail com>
Date:   Tue Mar 21 14:28:25 2017 +0800

    tests: Test that transforms are properly configured
    
    https://bugzilla.gnome.org/show_bug.cgi?id=777732

 src/tests/monitor-unit-tests.c |  289 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 289 insertions(+), 0 deletions(-)
---
diff --git a/src/tests/monitor-unit-tests.c b/src/tests/monitor-unit-tests.c
index 5f354c2..c55509d 100644
--- a/src/tests/monitor-unit-tests.c
+++ b/src/tests/monitor-unit-tests.c
@@ -155,10 +155,12 @@ typedef struct _MonitorTestCaseLogicalMonitor
   int scale;
   int monitors[MAX_N_MONITORS];
   int n_monitors;
+  MetaMonitorTransform transform;
 } MonitorTestCaseLogicalMonitor;
 
 typedef struct _MonitorTestCaseCrtcExpect
 {
+  MetaMonitorTransform transform;
   int current_mode;
   int x;
   int y;
@@ -438,6 +440,9 @@ check_logical_monitor (MonitorTestCase               *test_case,
   g_assert_cmpint (logical_monitor->scale,
                    ==,
                    test_logical_monitor->scale);
+  g_assert_cmpuint (logical_monitor->transform,
+                    ==,
+                    test_logical_monitor->transform);
 
   if (logical_monitor == monitor_manager->primary_logical_monitor)
     g_assert (meta_logical_monitor_is_primary (logical_monitor));
@@ -708,6 +713,10 @@ check_monitor_configuration (MonitorTestCase *test_case)
 
           g_assert (crtc->current_mode == expected_current_mode);
 
+          g_assert_cmpuint (crtc->transform,
+                            ==,
+                            test_case->expect.crtcs[i].transform);
+
           get_compensated_crtc_position (crtc, &crtc_x, &crtc_y);
 
           g_assert_cmpint (crtc_x, ==, test_case->expect.crtcs[i].x);
@@ -3210,6 +3219,282 @@ meta_test_monitor_custom_mirrored_config (void)
   check_monitor_configuration (&test_case);
 }
 
+static void
+meta_test_monitor_custom_first_rotated_config (void)
+{
+  MonitorTestCase test_case = {
+    .setup = {
+      .modes = {
+        {
+          .width = 1024,
+          .height = 768,
+          .refresh_rate = 60.000495910644531
+        }
+      },
+      .n_modes = 1,
+      .outputs = {
+        {
+          .crtc = 0,
+          .modes = { 0 },
+          .n_modes = 1,
+          .preferred_mode = 0,
+          .possible_crtcs = { 0 },
+          .n_possible_crtcs = 1,
+          .width_mm = 222,
+          .height_mm = 125,
+        },
+        {
+          .crtc = 1,
+          .modes = { 0 },
+          .n_modes = 1,
+          .preferred_mode = 0,
+          .possible_crtcs = { 1 },
+          .n_possible_crtcs = 1,
+          .width_mm = 222,
+          .height_mm = 125,
+        }
+      },
+      .n_outputs = 2,
+      .crtcs = {
+        {
+          .current_mode = 0,
+        },
+        {
+          .current_mode = 0
+        }
+      },
+      .n_crtcs = 2
+    },
+
+    .expect = {
+      .monitors = {
+        {
+          .outputs = { 0 },
+          .n_outputs = 1,
+          .modes = {
+            {
+              .width = 1024,
+              .height = 768,
+              .crtc_modes = {
+                {
+                  .output = 0,
+                  .crtc_mode = 0
+                }
+              }
+            }
+          },
+          .n_modes = 1,
+          .current_mode = 0,
+          .width_mm = 222,
+          .height_mm = 125,
+        },
+        {
+          .outputs = { 1 },
+          .n_outputs = 1,
+          .modes = {
+            {
+              .width = 1024,
+              .height = 768,
+              .crtc_modes = {
+                {
+                  .output = 1,
+                  .crtc_mode = 0
+                }
+              }
+            }
+          },
+          .n_modes = 1,
+          .current_mode = 0,
+          .width_mm = 222,
+          .height_mm = 125,
+        }
+      },
+      .n_monitors = 2,
+      .logical_monitors = {
+        {
+          .monitors = { 0 },
+          .n_monitors = 1,
+          .layout = { .x = 0, .y = 0, .width = 768, .height = 1024 },
+          .scale = 1,
+          .transform = META_MONITOR_TRANSFORM_270
+        },
+        {
+          .monitors = { 1 },
+          .n_monitors = 1,
+          .layout = { .x = 768, .y = 0, .width = 1024, .height = 768 },
+          .scale = 1
+        }
+      },
+      .n_logical_monitors = 2,
+      .primary_logical_monitor = 0,
+      .n_outputs = 2,
+      .crtcs = {
+        {
+          .current_mode = 0,
+          .transform = META_MONITOR_TRANSFORM_270
+        },
+        {
+          .current_mode = 0,
+        }
+      },
+      .n_crtcs = 2,
+      .screen_width = 768 + 1024,
+      .screen_height = 1024
+    }
+  };
+  MetaMonitorTestSetup *test_setup;
+
+  if (!is_using_monitor_config_manager ())
+    {
+      g_test_skip ("Not using MetaMonitorConfigManager");
+      return;
+    }
+
+  test_setup = create_monitor_test_setup (&test_case,
+                                          MONITOR_TEST_FLAG_NONE);
+  set_custom_monitor_config ("first-rotated.xml");
+  emulate_hotplug (test_setup);
+  check_monitor_configuration (&test_case);
+}
+
+static void
+meta_test_monitor_custom_second_rotated_config (void)
+{
+  MonitorTestCase test_case = {
+    .setup = {
+      .modes = {
+        {
+          .width = 1024,
+          .height = 768,
+          .refresh_rate = 60.000495910644531
+        }
+      },
+      .n_modes = 1,
+      .outputs = {
+        {
+          .crtc = 0,
+          .modes = { 0 },
+          .n_modes = 1,
+          .preferred_mode = 0,
+          .possible_crtcs = { 0 },
+          .n_possible_crtcs = 1,
+          .width_mm = 222,
+          .height_mm = 125,
+        },
+        {
+          .crtc = 1,
+          .modes = { 0 },
+          .n_modes = 1,
+          .preferred_mode = 0,
+          .possible_crtcs = { 1 },
+          .n_possible_crtcs = 1,
+          .width_mm = 222,
+          .height_mm = 125,
+        }
+      },
+      .n_outputs = 2,
+      .crtcs = {
+        {
+          .current_mode = 0
+        },
+        {
+          .current_mode = 0
+        }
+      },
+      .n_crtcs = 2
+    },
+
+    .expect = {
+      .monitors = {
+        {
+          .outputs = { 0 },
+          .n_outputs = 1,
+          .modes = {
+            {
+              .width = 1024,
+              .height = 768,
+              .crtc_modes = {
+                {
+                  .output = 0,
+                  .crtc_mode = 0
+                }
+              }
+            }
+          },
+          .n_modes = 1,
+          .current_mode = 0,
+          .width_mm = 222,
+          .height_mm = 125,
+        },
+        {
+          .outputs = { 1 },
+          .n_outputs = 1,
+          .modes = {
+            {
+              .width = 1024,
+              .height = 768,
+              .crtc_modes = {
+                {
+                  .output = 1,
+                  .crtc_mode = 0
+                }
+              }
+            }
+          },
+          .n_modes = 1,
+          .current_mode = 0,
+          .width_mm = 222,
+          .height_mm = 125,
+        }
+      },
+      .n_monitors = 2,
+      .logical_monitors = {
+        {
+          .monitors = { 0 },
+          .n_monitors = 1,
+          .layout = { .x = 0, .y = 256, .width = 1024, .height = 768 },
+          .scale = 1
+        },
+        {
+          .monitors = { 1 },
+          .n_monitors = 1,
+          .layout = { .x = 1024, .y = 0, .width = 768, .height = 1024 },
+          .scale = 1,
+          .transform = META_MONITOR_TRANSFORM_90
+        }
+      },
+      .n_logical_monitors = 2,
+      .primary_logical_monitor = 0,
+      .n_outputs = 2,
+      .crtcs = {
+        {
+          .current_mode = 0,
+        },
+        {
+          .current_mode = 0,
+          .transform = META_MONITOR_TRANSFORM_90
+        }
+      },
+      .n_crtcs = 2,
+      .screen_width = 768 + 1024,
+      .screen_height = 1024
+    }
+  };
+  MetaMonitorTestSetup *test_setup;
+
+  if (!is_using_monitor_config_manager ())
+    {
+      g_test_skip ("Not using MetaMonitorConfigManager");
+      return;
+    }
+
+  test_setup = create_monitor_test_setup (&test_case,
+                                          MONITOR_TEST_FLAG_NONE);
+  set_custom_monitor_config ("second-rotated.xml");
+  emulate_hotplug (test_setup);
+  check_monitor_configuration (&test_case);
+}
+
 void
 init_monitor_tests (void)
 {
@@ -3260,4 +3545,8 @@ init_monitor_tests (void)
                    meta_test_monitor_custom_tiled_custom_resolution_config);
   g_test_add_func ("/backends/monitor/custom/mirrored-config",
                    meta_test_monitor_custom_mirrored_config);
+  g_test_add_func ("/backends/monitor/custom/first-rotated-config",
+                   meta_test_monitor_custom_first_rotated_config);
+  g_test_add_func ("/backends/monitor/custom/second-rotated-config",
+                   meta_test_monitor_custom_second_rotated_config);
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]