mirror of
https://github.com/brl/mutter.git
synced 2024-11-30 12:00:44 -05:00
test-runner: Add 'assert_focused' command
This allows to verify which window should have the focus, which might not
be the same as the top of the stack.
It's possible to assert the case where there's no focused window using
"NONE" as parameter.
https://gitlab.gnome.org/GNOME/mutter/merge_requests/307
(cherry picked from commit 51f9e04ef1
)
This commit is contained in:
parent
1ebf32187a
commit
1dd0799c77
@ -273,6 +273,37 @@ test_case_assert_stacking (TestCase *test,
|
|||||||
return *error == NULL;
|
return *error == NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
test_case_assert_focused (TestCase *test,
|
||||||
|
const char *expected_window,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
MetaDisplay *display = meta_get_display ();
|
||||||
|
|
||||||
|
if (!display->focus_window)
|
||||||
|
{
|
||||||
|
if (g_strcmp0 (expected_window, "none") != 0)
|
||||||
|
{
|
||||||
|
g_set_error (error, TEST_RUNNER_ERROR, TEST_RUNNER_ERROR_ASSERTION_FAILED,
|
||||||
|
"focus: expected='%s', actual='none'", expected_window);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const char *focused = display->focus_window->title;
|
||||||
|
|
||||||
|
if (g_str_has_prefix (focused, "test/"))
|
||||||
|
focused += 5;
|
||||||
|
|
||||||
|
if (g_strcmp0 (focused, expected_window) != 0)
|
||||||
|
g_set_error (error, TEST_RUNNER_ERROR, TEST_RUNNER_ERROR_ASSERTION_FAILED,
|
||||||
|
"focus: expected='%s', actual='%s'",
|
||||||
|
expected_window, focused);
|
||||||
|
}
|
||||||
|
|
||||||
|
return *error == NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
test_case_check_xserver_stacking (TestCase *test,
|
test_case_check_xserver_stacking (TestCase *test,
|
||||||
GError **error)
|
GError **error)
|
||||||
@ -496,6 +527,11 @@ test_case_do (TestCase *test,
|
|||||||
if (!test_case_check_xserver_stacking (test, error))
|
if (!test_case_check_xserver_stacking (test, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
else if (strcmp (argv[0], "assert_focused") == 0)
|
||||||
|
{
|
||||||
|
if (!test_case_assert_focused (test, argv[1], error))
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
BAD_COMMAND("Unknown command %s", argv[0]);
|
BAD_COMMAND("Unknown command %s", argv[0]);
|
||||||
|
Loading…
Reference in New Issue
Block a user