[mutter] monitor-unit-tests: Check suggested configuration has adjacent outputs



commit ab48b6b933fd54211ff99dc2ccb9dc70c2237444
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date:   Wed Apr 3 19:02:42 2019 +0200

    monitor-unit-tests: Check suggested configuration has adjacent outputs
    
    Verify that the suggested monitor configuration contains only adjacent monitors,
    and that if this is not the case we fallback to the linear configuration.
    
    This can happen in case of multi-DPI setup, so add a test checking this too.
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/522>

 src/tests/monitor-unit-tests.c | 315 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 315 insertions(+)
---
diff --git a/src/tests/monitor-unit-tests.c b/src/tests/monitor-unit-tests.c
index c66e2b5da8..7b04b68e36 100644
--- a/src/tests/monitor-unit-tests.c
+++ b/src/tests/monitor-unit-tests.c
@@ -1488,6 +1488,317 @@ meta_test_monitor_suggested_config_overlapping (void)
   check_monitor_configuration (&test_case.expect);
 }
 
+static void
+meta_test_monitor_suggested_config_not_adjacent (void)
+{
+  MonitorTestCase test_case = {
+    .setup = {
+      .modes = {
+        {
+          .width = 800,
+          .height = 600,
+          .refresh_rate = 60.0
+        },
+        {
+          .width = 1024,
+          .height = 768,
+          .refresh_rate = 60.0
+        }
+      },
+      .n_modes = 2,
+      .outputs = {
+        {
+          .crtc = 0,
+          .modes = { 0 },
+          .n_modes = 1,
+          .preferred_mode = 0,
+          .possible_crtcs = { 0 },
+          .n_possible_crtcs = 1,
+          .width_mm = 222,
+          .height_mm = 125,
+          .hotplug_mode = TRUE,
+          .suggested_x = 1920,
+          .suggested_y = 1080,
+        },
+        {
+          .crtc = 1,
+          .modes = { 1 },
+          .n_modes = 1,
+          .preferred_mode = 1,
+          .possible_crtcs = { 1 },
+          .n_possible_crtcs = 1,
+          .width_mm = 220,
+          .height_mm = 124,
+          .hotplug_mode = TRUE,
+          .suggested_x = 0,
+          .suggested_y = 0,
+        }
+      },
+      .n_outputs = 2,
+      .crtcs = {
+        {
+          .current_mode = -1
+        },
+        {
+          .current_mode = -1
+        }
+      },
+      .n_crtcs = 2
+    },
+
+    .expect = {
+      .monitors = {
+        {
+          .outputs = { 0 },
+          .n_outputs = 1,
+          .modes = {
+            {
+              .width = 800,
+              .height = 600,
+              .refresh_rate = 60.0,
+              .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,
+              .refresh_rate = 60.0,
+              .crtc_modes = {
+                {
+                  .output = 1,
+                  .crtc_mode = 1
+                }
+              }
+            }
+          },
+          .n_modes = 1,
+          .current_mode = 0,
+          .width_mm = 220,
+          .height_mm = 124
+        }
+      },
+      .n_monitors = 2,
+      /*
+       * Logical monitors expectations follow fallback linear configuration
+       */
+      .logical_monitors = {
+        {
+          .monitors = { 0 },
+          .n_monitors = 1,
+          .layout = { .x = 1024, .y = 0, .width = 800, .height = 600 },
+          .scale = 1
+        },
+        {
+          .monitors = { 1 },
+          .n_monitors = 1,
+          .layout = { .x = 0, .y = 0, .width = 1024, .height = 768 },
+          .scale = 1
+        }
+      },
+      .n_logical_monitors = 2,
+      .primary_logical_monitor = 1,
+      .n_outputs = 2,
+      .crtcs = {
+        {
+          .current_mode = 0,
+          .x = 1024,
+          .y = 0,
+        },
+        {
+          .current_mode = 1,
+          .x = 0,
+          .y = 0,
+        }
+      },
+      .n_crtcs = 2,
+      .n_tiled_monitors = 0,
+      .screen_width = 1024 + 800,
+      .screen_height = MAX (768, 600)
+    }
+  };
+  MetaMonitorTestSetup *test_setup;
+
+  test_setup = create_monitor_test_setup (&test_case.setup,
+                                          MONITOR_TEST_FLAG_NO_STORED);
+
+  g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
+                         "Suggested monitor config has monitors with no "
+                         "neighbors, rejecting");
+  emulate_hotplug (test_setup);
+  g_test_assert_expected_messages ();
+
+  check_monitor_configuration (&test_case.expect);
+}
+
+static void
+meta_test_monitor_suggested_config_multi_dpi (void)
+{
+  MonitorTestCase test_case = {
+    .setup = {
+      .modes = {
+        {
+          .width = 800,
+          .height = 600,
+          .refresh_rate = 60.0
+        },
+        {
+          .width = 4096,
+          .height = 2160,
+          .refresh_rate = 60.0
+        }
+      },
+      .n_modes = 2,
+      .outputs = {
+        {
+          .crtc = 0,
+          .modes = { 0 },
+          .n_modes = 1,
+          .preferred_mode = 0,
+          .possible_crtcs = { 0 },
+          .n_possible_crtcs = 1,
+          .width_mm = 222,
+          .height_mm = 125,
+          .hotplug_mode = TRUE,
+          .suggested_x = 4096,
+          .suggested_y = 2160,
+        },
+        {
+          .crtc = 1,
+          .modes = { 1 },
+          .n_modes = 1,
+          .preferred_mode = 1,
+          .possible_crtcs = { 1 },
+          .n_possible_crtcs = 1,
+          .width_mm = 350,
+          .height_mm = 180,
+          .scale = 2,
+          .hotplug_mode = TRUE,
+          .suggested_x = 0,
+          .suggested_y = 0,
+        }
+      },
+      .n_outputs = 2,
+      .crtcs = {
+        {
+          .current_mode = -1
+        },
+        {
+          .current_mode = -1
+        }
+      },
+      .n_crtcs = 2
+    },
+
+    .expect = {
+      .monitors = {
+        {
+          .outputs = { 0 },
+          .n_outputs = 1,
+          .modes = {
+            {
+              .width = 800,
+              .height = 600,
+              .refresh_rate = 60.0,
+              .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 = 4096,
+              .height = 2160,
+              .refresh_rate = 60.0,
+              .crtc_modes = {
+                {
+                  .output = 1,
+                  .crtc_mode = 1
+                }
+              }
+            }
+          },
+          .n_modes = 1,
+          .current_mode = 0,
+          .width_mm = 350,
+          .height_mm = 180,
+        }
+      },
+      .n_monitors = 2,
+      /*
+       * Logical monitors expectations altered to correspond to the
+       * "suggested_x/y" changed further below.
+       */
+      .logical_monitors = {
+        {
+          .monitors = { 0 },
+          .n_monitors = 1,
+          .layout = { .x = 4096/2, .y = 0, .width = 800, .height = 600 },
+          .scale = 1
+        },
+        {
+          .monitors = { 1 },
+          .n_monitors = 1,
+          .layout = { .x = 0, .y = 0, .width = 4096/2, .height = 2160/2 },
+          .scale = 2
+        }
+      },
+      .n_logical_monitors = 2,
+      .primary_logical_monitor = 1,
+      .n_outputs = 2,
+      .crtcs = {
+        {
+          .current_mode = 0,
+          .x = 2048,
+        },
+        {
+          .current_mode = 1,
+        }
+      },
+      .n_crtcs = 2,
+      .n_tiled_monitors = 0,
+      .screen_width = 4096/2 + 800,
+      .screen_height = 2160/2
+    }
+  };
+  MetaMonitorTestSetup *test_setup;
+
+  test_setup = create_monitor_test_setup (&test_case.setup,
+                                          MONITOR_TEST_FLAG_NO_STORED);
+
+  g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
+                         "Suggested monitor config has monitors with no "
+                         "neighbors, rejecting");
+  emulate_hotplug (test_setup);
+  g_test_assert_expected_messages();
+
+  check_monitor_configuration (&test_case.expect);
+}
+
 static void
 meta_test_monitor_limited_crtcs (void)
 {
@@ -6534,6 +6845,10 @@ init_monitor_tests (void)
                     meta_test_monitor_suggested_config);
   add_monitor_test ("/backends/monitor/suggested-config-overlapping",
                     meta_test_monitor_suggested_config_overlapping);
+  add_monitor_test ("/backends/monitor/suggested-config-not-adjacent",
+                    meta_test_monitor_suggested_config_not_adjacent);
+  add_monitor_test ("/backends/monitor/suggested-config-multi-dpi",
+                    meta_test_monitor_suggested_config_multi_dpi);
   add_monitor_test ("/backends/monitor/limited-crtcs",
                     meta_test_monitor_limited_crtcs);
   add_monitor_test ("/backends/monitor/lid-switch-config",


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