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




commit afc45bac28a18152f4adb85338d393ef2ff1041c
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 2a5859c17a..fe5b36b36e 100644
--- a/src/tests/monitor-unit-tests.c
+++ b/src/tests/monitor-unit-tests.c
@@ -8497,6 +8497,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)
@@ -8504,6 +8515,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;
@@ -8512,6 +8525,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]