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




commit b659a501e6e38b4c0e05bd2ac19bc05d835cc4e9
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 | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
---
diff --git a/src/tests/monitor-unit-tests.c b/src/tests/monitor-unit-tests.c
index a45569e9ef..095f7d98a7 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)
+{
+  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,21 @@ 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"))
+    {
+      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]