[mutter] tests/monitor-unit-tests: Check handling of odd tiled monitors



commit fb5ebffb8da97f25fcab58976dc41741d860fb01
Author: Jonas Ådahl <jadahl gmail com>
Date:   Mon May 1 12:12:42 2017 +0800

    tests/monitor-unit-tests: Check handling of odd tiled monitors
    
    Add tests for handling tiled monitors where the origin tile output is
    not the main output.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=781723

 .../non-preferred-tiled-custom-resolution.xml      |   22 ++
 src/tests/monitor-unit-tests.c                     |  357 ++++++++++++++++++++
 2 files changed, 379 insertions(+), 0 deletions(-)
---
diff --git a/src/tests/monitor-configs/non-preferred-tiled-custom-resolution.xml 
b/src/tests/monitor-configs/non-preferred-tiled-custom-resolution.xml
new file mode 100644
index 0000000..8ee2abf
--- /dev/null
+++ b/src/tests/monitor-configs/non-preferred-tiled-custom-resolution.xml
@@ -0,0 +1,22 @@
+<monitors version="2">
+  <configuration>
+    <logicalmonitor>
+      <x>0</x>
+      <y>0</y>
+      <primary>yes</primary>
+      <monitor>
+       <monitorspec>
+         <connector>DP-2</connector>
+         <vendor>MetaProduct's Inc.</vendor>
+         <product>MetaMonitor</product>
+         <serial>0x123456</serial>
+       </monitorspec>
+       <mode>
+         <width>800</width>
+         <height>600</height>
+         <rate>60</rate>
+       </mode>
+      </monitor>
+    </logicalmonitor>
+  </configuration>
+</monitors>
diff --git a/src/tests/monitor-unit-tests.c b/src/tests/monitor-unit-tests.c
index 2134c68..ae592bb 100644
--- a/src/tests/monitor-unit-tests.c
+++ b/src/tests/monitor-unit-tests.c
@@ -1344,6 +1344,182 @@ meta_test_monitor_tiled_linear_config (void)
 }
 
 static void
+meta_test_monitor_tiled_non_preferred_linear_config (void)
+{
+  MonitorTestCase test_case = {
+    .setup = {
+      .modes = {
+        {
+          .width = 640,
+          .height = 480,
+          .refresh_rate = 60.0
+        },
+        {
+          .width = 800,
+          .height = 600,
+          .refresh_rate = 60.0
+        },
+        {
+          .width = 512,
+          .height = 768,
+          .refresh_rate = 120.0
+        },
+        {
+          .width = 1024,
+          .height = 768,
+          .refresh_rate = 60.0
+        },
+      },
+      .n_modes = 4,
+      .outputs = {
+        {
+          .crtc = -1,
+          .modes = { 0, 2 },
+          .n_modes = 2,
+          .preferred_mode = 1,
+          .possible_crtcs = { 0 },
+          .n_possible_crtcs = 1,
+          .width_mm = 222,
+          .height_mm = 125,
+          .tile_info = {
+            .group_id = 1,
+            .max_h_tiles = 2,
+            .max_v_tiles = 1,
+            .loc_h_tile = 0,
+            .loc_v_tile = 0,
+            .tile_w = 512,
+            .tile_h = 768
+          }
+        },
+        {
+          .crtc = -1,
+          .modes = { 1, 2, 3 },
+          .n_modes = 3,
+          .preferred_mode = 0,
+          .possible_crtcs = { 1 },
+          .n_possible_crtcs = 1,
+          .width_mm = 222,
+          .height_mm = 125,
+          .tile_info = {
+            .group_id = 1,
+            .max_h_tiles = 2,
+            .max_v_tiles = 1,
+            .loc_h_tile = 1,
+            .loc_v_tile = 0,
+            .tile_w = 512,
+            .tile_h = 768
+          }
+        }
+      },
+      .n_outputs = 2,
+      .crtcs = {
+        {
+          .current_mode = -1
+        },
+        {
+          .current_mode = -1
+        }
+      },
+      .n_crtcs = 2
+    },
+
+    .expect = {
+      .monitors = {
+        {
+          .outputs = { 0, 1 },
+          .n_outputs = 2,
+          .modes = {
+            {
+              .width = 1024,
+              .height = 768,
+              .crtc_modes = {
+                {
+                  .output = 0,
+                  .crtc_mode = 2
+                },
+                {
+                  .output = 1,
+                  .crtc_mode = 2,
+                }
+              }
+            },
+            {
+              .width = 800,
+              .height = 600,
+              .crtc_modes = {
+                {
+                  .output = 0,
+                  .crtc_mode = -1
+                },
+                {
+                  .output = 1,
+                  .crtc_mode = 1,
+                }
+              }
+            },
+            {
+              .width = 1024,
+              .height = 768,
+              .crtc_modes = {
+                {
+                  .output = 0,
+                  .crtc_mode = -1
+                },
+                {
+                  .output = 1,
+                  .crtc_mode = 3,
+                }
+              }
+            },
+          },
+          .n_modes = 3,
+          .current_mode = 0,
+          .width_mm = 222,
+          .height_mm = 125,
+        }
+      },
+      .n_monitors = 1,
+      .logical_monitors = {
+        {
+          .monitors = { 0 },
+          .n_monitors = 1,
+          .layout = { .x = 0, .y = 0, .width = 1024, .height = 768 },
+          .scale = 1
+        },
+      },
+      .n_logical_monitors = 1,
+      .primary_logical_monitor = 0,
+      .n_outputs = 2,
+      .crtcs = {
+        {
+          .current_mode = 2,
+        },
+        {
+          .current_mode = 2,
+          .x = 512
+        }
+      },
+      .n_crtcs = 2,
+      .n_tiled_monitors = 1,
+      .screen_width = 1024,
+      .screen_height = 768,
+    }
+  };
+  MetaMonitorTestSetup *test_setup;
+
+  if (!is_using_monitor_config_manager ())
+    {
+      g_test_skip ("Only the new monitor config manager handles this case.");
+      return;
+    }
+
+  test_setup = create_monitor_test_setup (&test_case,
+                                          MONITOR_TEST_FLAG_NO_STORED);
+  emulate_hotplug (test_setup);
+  check_monitor_configuration (&test_case);
+}
+
+static void
 meta_test_monitor_hidpi_linear_config (void)
 {
   MonitorTestCase test_case = {
@@ -3137,6 +3313,183 @@ meta_test_monitor_custom_tiled_custom_resolution_config (void)
 }
 
 static void
+meta_test_monitor_custom_tiled_non_preferred_config (void)
+{
+  MonitorTestCase test_case = {
+    .setup = {
+      .modes = {
+        {
+          .width = 640,
+          .height = 480,
+          .refresh_rate = 60.0
+        },
+        {
+          .width = 800,
+          .height = 600,
+          .refresh_rate = 60.0
+        },
+        {
+          .width = 512,
+          .height = 768,
+          .refresh_rate = 120.0
+        },
+        {
+          .width = 1024,
+          .height = 768,
+          .refresh_rate = 60.0
+        },
+      },
+      .n_modes = 4,
+      .outputs = {
+        {
+          .crtc = -1,
+          .modes = { 0, 2 },
+          .n_modes = 2,
+          .preferred_mode = 1,
+          .possible_crtcs = { 0 },
+          .n_possible_crtcs = 1,
+          .width_mm = 222,
+          .height_mm = 125,
+          .tile_info = {
+            .group_id = 1,
+            .max_h_tiles = 2,
+            .max_v_tiles = 1,
+            .loc_h_tile = 0,
+            .loc_v_tile = 0,
+            .tile_w = 512,
+            .tile_h = 768
+          }
+        },
+        {
+          .crtc = -1,
+          .modes = { 1, 2, 3 },
+          .n_modes = 3,
+          .preferred_mode = 0,
+          .possible_crtcs = { 1 },
+          .n_possible_crtcs = 1,
+          .width_mm = 222,
+          .height_mm = 125,
+          .tile_info = {
+            .group_id = 1,
+            .max_h_tiles = 2,
+            .max_v_tiles = 1,
+            .loc_h_tile = 1,
+            .loc_v_tile = 0,
+            .tile_w = 512,
+            .tile_h = 768
+          }
+        }
+      },
+      .n_outputs = 2,
+      .crtcs = {
+        {
+          .current_mode = -1
+        },
+        {
+          .current_mode = -1
+        }
+      },
+      .n_crtcs = 2
+    },
+
+    .expect = {
+      .monitors = {
+        {
+          .outputs = { 0, 1 },
+          .n_outputs = 2,
+          .modes = {
+            {
+              .width = 1024,
+              .height = 768,
+              .crtc_modes = {
+                {
+                  .output = 0,
+                  .crtc_mode = 2
+                },
+                {
+                  .output = 1,
+                  .crtc_mode = 2,
+                }
+              }
+            },
+            {
+              .width = 800,
+              .height = 600,
+              .crtc_modes = {
+                {
+                  .output = 0,
+                  .crtc_mode = -1
+                },
+                {
+                  .output = 1,
+                  .crtc_mode = 1,
+                }
+              }
+            },
+            {
+              .width = 1024,
+              .height = 768,
+              .crtc_modes = {
+                {
+                  .output = 0,
+                  .crtc_mode = -1
+                },
+                {
+                  .output = 1,
+                  .crtc_mode = 3,
+                }
+              }
+            },
+          },
+          .n_modes = 3,
+          .current_mode = 1,
+          .width_mm = 222,
+          .height_mm = 125,
+        }
+      },
+      .n_monitors = 1,
+      .logical_monitors = {
+        {
+          .monitors = { 0 },
+          .n_monitors = 1,
+          .layout = { .x = 0, .y = 0, .width = 800, .height = 600 },
+          .scale = 1
+        },
+      },
+      .n_logical_monitors = 1,
+      .primary_logical_monitor = 0,
+      .n_outputs = 2,
+      .crtcs = {
+        {
+          .current_mode = -1,
+        },
+        {
+          .current_mode = 1,
+        }
+      },
+      .n_crtcs = 2,
+      .n_tiled_monitors = 1,
+      .screen_width = 800,
+      .screen_height = 600,
+    }
+  };
+  MetaMonitorTestSetup *test_setup;
+
+  if (!is_using_monitor_config_manager ())
+    {
+      g_test_skip ("Only the new monitor config manager handles this case.");
+      return;
+    }
+
+  test_setup = create_monitor_test_setup (&test_case,
+                                          MONITOR_TEST_FLAG_NONE);
+  set_custom_monitor_config ("non-preferred-tiled-custom-resolution.xml");
+  emulate_hotplug (test_setup);
+
+  check_monitor_configuration (&test_case);
+}
+
+static void
 meta_test_monitor_custom_mirrored_config (void)
 {
   MonitorTestCase test_case = {
@@ -3908,6 +4261,8 @@ init_monitor_tests (void)
                    meta_test_monitor_preferred_linear_config);
   g_test_add_func ("/backends/monitor/tiled-linear-config",
                    meta_test_monitor_tiled_linear_config);
+  g_test_add_func ("/backends/monitor/tiled-non-preferred-linear-config",
+                   meta_test_monitor_tiled_non_preferred_linear_config);
   g_test_add_func ("/backends/monitor/hidpi-linear-config",
                    meta_test_monitor_hidpi_linear_config);
   g_test_add_func ("/backends/monitor/suggested-config",
@@ -3937,6 +4292,8 @@ init_monitor_tests (void)
                    meta_test_monitor_custom_tiled_config);
   g_test_add_func ("/backends/monitor/custom/tiled-custom-resolution-config",
                    meta_test_monitor_custom_tiled_custom_resolution_config);
+  g_test_add_func ("/backends/monitor/custom/tiled-non-preferred-config",
+                   meta_test_monitor_custom_tiled_non_preferred_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",


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