From b743cc352861c01c355871b87fb09cdd781f4916 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Fri, 25 Aug 2023 15:47:05 +0200 Subject: [PATCH] tests/test-runner: Add 'sleep suspend_timeout' command It's a tweak to the 'sleep' command to allow well known sleep lengths. Part-of: --- src/core/window-private.h | 3 +++ src/core/window.c | 6 ++++++ src/tests/test-runner.c | 17 ++++++++++------- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/core/window-private.h b/src/core/window-private.h index eca352298..fd0dcaa45 100644 --- a/src/core/window-private.h +++ b/src/core/window-private.h @@ -900,3 +900,6 @@ void meta_window_inhibit_suspend_state (MetaWindow *window); void meta_window_uninhibit_suspend_state (MetaWindow *window); gboolean meta_window_is_suspended (MetaWindow *window); + +META_EXPORT_TEST +int meta_get_window_suspend_timeout_s (void); diff --git a/src/core/window.c b/src/core/window.c index 0660bf69f..8ea18a5bc 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -7999,3 +7999,9 @@ meta_window_calculate_bounds (MetaWindow *window, return FALSE; } } + +int +meta_get_window_suspend_timeout_s (void) +{ + return SUSPEND_HIDDEN_TIMEOUT_S; +} diff --git a/src/tests/test-runner.c b/src/tests/test-runner.c index abb124768..2eac7b79d 100644 --- a/src/tests/test-runner.c +++ b/src/tests/test-runner.c @@ -175,10 +175,11 @@ test_case_wait (TestCase *test, static gboolean test_case_sleep (TestCase *test, - guint32 interval, + uint32_t interval_ms, GError **error) { - g_timeout_add_full (G_PRIORITY_LOW, interval, test_case_loop_quit, test, NULL); + g_timeout_add_full (G_PRIORITY_LOW, interval_ms, + test_case_loop_quit, test, NULL); g_main_loop_run (test->loop); return TRUE; @@ -847,16 +848,18 @@ test_case_do (TestCase *test, } else if (strcmp (argv[0], "sleep") == 0) { - guint64 interval; + uint64_t interval_ms; if (argc != 2) - BAD_COMMAND("usage: %s ", argv[0]); + BAD_COMMAND("usage: %s |", argv[0]); - if (!g_ascii_string_to_unsigned (argv[1], 10, 0, G_MAXUINT32, - &interval, error)) + if (strcmp (argv[1], "suspend_timeout") == 0) + interval_ms = s2ms (meta_get_window_suspend_timeout_s ()); + else if (!g_ascii_string_to_unsigned (argv[1], 10, 0, G_MAXUINT32, + &interval_ms, error)) return FALSE; - if (!test_case_sleep (test, (guint32) interval, error)) + if (!test_case_sleep (test, (uint32_t) interval_ms, error)) return FALSE; } else if (strcmp (argv[0], "set_strut") == 0)