summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <smcv@debian.org>2021-10-09 16:13:18 +0100
committerSimon McVittie <smcv@debian.org>2021-10-10 11:39:37 +0100
commit95d99d3a0b85e79e59157e4901518d16e612c84f (patch)
tree22044be0fb8715bf28fe11b88f9c38fe4cef3fe0
parent867db93043dd3c93d8ccb6cb197d4a3687d3a5e5 (diff)
downloadmutter-wip/smcv/orientation-test-debug.tar.gz
tests: Add additional debug for orientation test (Debian#995929)wip/smcv/orientation-test-debug
Signed-off-by: Simon McVittie <smcv@debian.org>
-rw-r--r--src/tests/monitor-unit-tests.c26
-rw-r--r--src/tests/orientation-manager-unit-tests.c38
-rw-r--r--src/tests/orientation-manager-unit-tests.h2
3 files changed, 65 insertions, 1 deletions
diff --git a/src/tests/monitor-unit-tests.c b/src/tests/monitor-unit-tests.c
index 6b93db0ae..6d9a69ebd 100644
--- a/src/tests/monitor-unit-tests.c
+++ b/src/tests/monitor-unit-tests.c
@@ -8494,12 +8494,25 @@ meta_test_monitor_supported_fractional_scales (void)
}
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)
{
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;
@@ -8508,6 +8521,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
diff --git a/src/tests/orientation-manager-unit-tests.c b/src/tests/orientation-manager-unit-tests.c
index a936dccb7..9c0043b76 100644
--- a/src/tests/orientation-manager-unit-tests.c
+++ b/src/tests/orientation-manager-unit-tests.c
@@ -24,10 +24,36 @@
#include "tests/meta-sensors-proxy-mock.h"
+const char *
+orientation_to_string (MetaOrientation orientation)
+{
+ switch (orientation)
+ {
+ case META_ORIENTATION_UNDEFINED:
+ return "(undefined)";
+ case META_ORIENTATION_NORMAL:
+ return "normal";
+ case META_ORIENTATION_BOTTOM_UP:
+ return "bottom-up";
+ case META_ORIENTATION_LEFT_UP:
+ return "left-up";
+ case META_ORIENTATION_RIGHT_UP:
+ return "right-up";
+ default:
+ return "(invalid)";
+ }
+}
+
static void
-on_orientation_changed (gpointer data)
+on_orientation_changed (gpointer data,
+ MetaOrientationManager *orientation_manager)
{
gboolean *changed = data;
+ MetaOrientation orientation;
+
+ orientation = meta_orientation_manager_get_orientation (orientation_manager);
+ g_test_message ("wait_for_orientation_changes: Orientation changed to %d: %s",
+ orientation, orientation_to_string (orientation));
*changed = TRUE;
}
@@ -37,6 +63,7 @@ on_max_wait_timeout (gpointer data)
{
guint *timeout_id = data;
+ g_test_message ("wait_for_orientation_changes: Timed out waiting for orientation change");
*timeout_id = 0;
return G_SOURCE_REMOVE;
@@ -48,6 +75,11 @@ wait_for_orientation_changes (MetaOrientationManager *orientation_manager)
gboolean changed = FALSE;
gulong connection_id;
guint timeout_id;
+ MetaOrientation orientation;
+
+ orientation = meta_orientation_manager_get_orientation (orientation_manager);
+ g_test_message ("%s: Waiting for orientation to change from %d: %s...",
+ G_STRFUNC, orientation, orientation_to_string (orientation));
timeout_id = g_timeout_add (300, on_max_wait_timeout, &timeout_id);
connection_id = g_signal_connect_swapped (orientation_manager,
@@ -60,6 +92,10 @@ wait_for_orientation_changes (MetaOrientationManager *orientation_manager)
g_clear_handle_id (&timeout_id, g_source_remove);
g_signal_handler_disconnect (orientation_manager, connection_id);
+
+ orientation = meta_orientation_manager_get_orientation (orientation_manager);
+ g_test_message ("%s: Orientation is now %d: %s",
+ G_STRFUNC, orientation, orientation_to_string (orientation));
}
static void
diff --git a/src/tests/orientation-manager-unit-tests.h b/src/tests/orientation-manager-unit-tests.h
index 56eff09d1..4f6c7640f 100644
--- a/src/tests/orientation-manager-unit-tests.h
+++ b/src/tests/orientation-manager-unit-tests.h
@@ -27,4 +27,6 @@ void init_orientation_manager_tests (void);
void wait_for_orientation_changes (MetaOrientationManager *orientation_manager);
+const char *orientation_to_string (MetaOrientation orientation);
+
#endif /* ORIENTATION_MANAGER_UNIT_TESTS_H */