[mutter/wip/smcv/disoriented: 3/3] tests: Watch the orientation manager independently




commit 568dd82e03f6e8dfedc0035e87238876c197f540
Author: Simon McVittie <smcv debian org>
Date:   Sun Oct 10 12:36:24 2021 +0100

    tests: Watch the orientation manager independently
    
    This will tell us whether signals were emitted before
    wait_for_orientation() was ready for them.
    
    Signed-off-by: Simon McVittie <smcv debian org>

 src/tests/monitor-unit-tests.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
---
diff --git a/src/tests/monitor-unit-tests.c b/src/tests/monitor-unit-tests.c
index 65bf3d4181..dcadb72339 100644
--- a/src/tests/monitor-unit-tests.c
+++ b/src/tests/monitor-unit-tests.c
@@ -8487,6 +8487,17 @@ meta_test_monitor_supported_fractional_scales (void)
                                             META_MONITOR_SCALES_CONSTRAINT_NONE));
 }
 
+static void
+on_orientation_changed (MetaOrientationManager *orientation_manager,
+                        gpointer unused)
+{
+  MetaOrientation orientation;
+
+  orientation = meta_orientation_manager_get_orientation (orientation_manager);
+  g_test_message ("%p: Orientation changed to %d: %s",
+                  orientation_manager, orientation, orientation_to_string (orientation));
+}
+
 static void
 test_case_setup (void       **fixture,
                  const void   *data)
@@ -8494,6 +8505,8 @@ test_case_setup (void       **fixture,
   MetaBackend *backend = meta_get_backend ();
   MetaMonitorManager *monitor_manager =
     meta_backend_get_monitor_manager (backend);
+  MetaOrientationManager *orientation_manager =
+    meta_backend_get_orientation_manager (backend);
   MetaMonitorManagerTest *monitor_manager_test =
     META_MONITOR_MANAGER_TEST (monitor_manager);
   MetaMonitorConfigManager *config_manager = monitor_manager->config_manager;
@@ -8502,6 +8515,19 @@ test_case_setup (void       **fixture,
                                                     TRUE);
   meta_monitor_config_manager_set_current (config_manager, NULL);
   meta_monitor_config_manager_clear_history (config_manager);
+
+  if (g_object_get_data (G_OBJECT (orientation_manager), "monitor-unit-tests-watching-orientation") != NULL)
+    {
+      g_test_message ("reusing existing orientation manager %p", orientation_manager);
+    }
+  else
+    {
+      g_signal_connect (orientation_manager, "orientation-changed",
+                        G_CALLBACK (on_orientation_changed), NULL);
+      g_object_set_data (G_OBJECT (orientation_manager),
+                         "monitor-unit-tests-watching-orientation",
+                         (void *) "yes");
+    }
 }
 
 static void


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