[mutter/wip/smcv/orientation-test-debug] tests: Add additional debug for orientation test (Debian#995929)
- From: Simon McVittie <smcv src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/smcv/orientation-test-debug] tests: Add additional debug for orientation test (Debian#995929)
- Date: Sun, 10 Oct 2021 10:42:26 +0000 (UTC)
commit 95d99d3a0b85e79e59157e4901518d16e612c84f
Author: Simon McVittie <smcv debian org>
Date: Sat Oct 9 16:13:18 2021 +0100
tests: Add additional debug for orientation test (Debian#995929)
Signed-off-by: Simon McVittie <smcv debian org>
src/tests/monitor-unit-tests.c | 26 ++++++++++++++++++++
src/tests/orientation-manager-unit-tests.c | 38 +++++++++++++++++++++++++++++-
src/tests/orientation-manager-unit-tests.h | 2 ++
3 files changed, 65 insertions(+), 1 deletion(-)
---
diff --git a/src/tests/monitor-unit-tests.c b/src/tests/monitor-unit-tests.c
index 6b93db0aed..6d9a69ebde 100644
--- a/src/tests/monitor-unit-tests.c
+++ b/src/tests/monitor-unit-tests.c
@@ -8493,6 +8493,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)
@@ -8500,6 +8511,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;
@@ -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 a936dccb7a..9c0043b765 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 56eff09d1d..4f6c7640f6 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 */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]