tests/stacking: Add workspace management commands
New commands to set the number of workspaces, activate a workspace, with and without focus, move windows to specific workspaces, and check the stacking on a specific workspace. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2489>
This commit is contained in:
parent
b4b9a7c90f
commit
ed7a9af62a
@ -89,6 +89,7 @@ void meta_workspace_manager_workspace_switched (MetaWorkspaceManager *workspace_
|
||||
int to,
|
||||
MetaMotionDirection direction);
|
||||
|
||||
META_EXPORT_TEST
|
||||
void meta_workspace_manager_update_num_workspaces (MetaWorkspaceManager *workspace_manager,
|
||||
guint32 timestamp,
|
||||
int new_num);
|
||||
|
@ -440,6 +440,8 @@ stacking_tests = [
|
||||
'map-fixed-size',
|
||||
'client-resize-respect-constraints',
|
||||
'map-on-hotplug',
|
||||
'workspace-basic',
|
||||
'workspace-test',
|
||||
]
|
||||
|
||||
foreach stacking_test: stacking_tests
|
||||
|
41
src/tests/stacking/workspace-basic.metatest
Normal file
41
src/tests/stacking/workspace-basic.metatest
Normal file
@ -0,0 +1,41 @@
|
||||
num_workspaces 2
|
||||
activate_workspace 1
|
||||
|
||||
new_client 1 wayland
|
||||
create 1/1
|
||||
show 1/1
|
||||
create 1/2
|
||||
show 1/2
|
||||
wait
|
||||
assert_stacking 1/1 1/2
|
||||
assert_stacking_workspace 1 1/1 1/2
|
||||
assert_stacking_workspace 0
|
||||
|
||||
activate_workspace 0
|
||||
wait
|
||||
assert_stacking 1/1 1/2
|
||||
assert_stacking_workspace 1 1/1 1/2
|
||||
assert_stacking_workspace 0
|
||||
|
||||
activate_workspace_with_focus 0 1/1
|
||||
wait
|
||||
assert_stacking 1/2 1/1
|
||||
assert_stacking_workspace 1 1/2 1/1
|
||||
assert_stacking_workspace 0
|
||||
|
||||
window_to_workspace 1/2 0
|
||||
wait
|
||||
assert_stacking 1/2 1/1
|
||||
assert_stacking_workspace 1 1/1
|
||||
assert_stacking_workspace 0 1/2
|
||||
|
||||
activate_workspace 0
|
||||
wait
|
||||
new_client 2 wayland
|
||||
create 2/1
|
||||
show 2/1
|
||||
wait
|
||||
|
||||
assert_stacking 1/1 1/2 2/1
|
||||
assert_stacking_workspace 1 1/1
|
||||
assert_stacking_workspace 0 1/2 2/1
|
30
src/tests/stacking/workspace-test.metatest
Normal file
30
src/tests/stacking/workspace-test.metatest
Normal file
@ -0,0 +1,30 @@
|
||||
num_workspaces 2
|
||||
activate_workspace 0
|
||||
|
||||
new_client 1 wayland
|
||||
create 1/1
|
||||
show 1/1
|
||||
create 1/2
|
||||
show 1/2
|
||||
wait
|
||||
assert_stacking_workspace 0 1/1 1/2
|
||||
assert_stacking_workspace 1
|
||||
|
||||
activate_workspace 1
|
||||
new_client 2 wayland
|
||||
create 2/1
|
||||
show 2/1
|
||||
wait
|
||||
assert_stacking_workspace 0 1/1 1/2
|
||||
assert_stacking_workspace 1 2/1
|
||||
|
||||
create 1/3
|
||||
show 1/3
|
||||
wait
|
||||
assert_stacking_workspace 0 1/1 1/2
|
||||
assert_stacking_workspace 1 2/1 1/3
|
||||
|
||||
activate_workspace_with_focus 0 1/1
|
||||
wait
|
||||
assert_stacking_workspace 0 1/2 1/1
|
||||
assert_stacking_workspace 1 2/1 1/3
|
@ -29,7 +29,7 @@
|
||||
#include "meta-test/meta-context-test.h"
|
||||
#include "meta/util.h"
|
||||
#include "meta/window.h"
|
||||
#include "meta/meta-workspace-manager.h"
|
||||
#include "core/meta-workspace-manager-private.h"
|
||||
#include "tests/meta-test-utils.h"
|
||||
#include "ui/ui.h"
|
||||
#include "wayland/meta-wayland.h"
|
||||
@ -227,6 +227,7 @@ static gboolean
|
||||
test_case_assert_stacking (TestCase *test,
|
||||
char **expected_windows,
|
||||
int n_expected_windows,
|
||||
MetaWorkspace *workspace,
|
||||
GError **error)
|
||||
{
|
||||
MetaDisplay *display = meta_get_display ();
|
||||
@ -240,6 +241,10 @@ test_case_assert_stacking (TestCase *test,
|
||||
for (i = 0; i < n_windows; i++)
|
||||
{
|
||||
MetaWindow *window = meta_display_lookup_stack_id (display, windows[i]);
|
||||
|
||||
if (workspace && !meta_window_located_on_workspace (window, workspace))
|
||||
continue;
|
||||
|
||||
if (window != NULL && window->title)
|
||||
{
|
||||
/* See comment in meta_ui_new() about why the dummy window for GTK+ theming
|
||||
@ -893,7 +898,7 @@ test_case_do (TestCase *test,
|
||||
}
|
||||
else if (strcmp (argv[0], "assert_stacking") == 0)
|
||||
{
|
||||
if (!test_case_assert_stacking (test, argv + 1, argc - 1, error))
|
||||
if (!test_case_assert_stacking (test, argv + 1, argc - 1, NULL, error))
|
||||
return FALSE;
|
||||
|
||||
if (!test_case_check_xserver_stacking (test, error))
|
||||
@ -1030,6 +1035,119 @@ test_case_do (TestCase *test,
|
||||
crtc_mode_info->refresh_rate);
|
||||
meta_monitor_manager_reload (monitor_manager);
|
||||
}
|
||||
else if (strcmp (argv[0], "num_workspaces") == 0)
|
||||
{
|
||||
if (argc != 2)
|
||||
BAD_COMMAND("usage: %s <num>", argv[0]);
|
||||
|
||||
MetaDisplay *display = meta_get_display ();
|
||||
MetaWorkspaceManager *workspace_manager =
|
||||
meta_display_get_workspace_manager (display);
|
||||
uint32_t timestamp = meta_display_get_current_time_roundtrip (display);
|
||||
int num = atoi (argv[1]);
|
||||
meta_workspace_manager_update_num_workspaces (workspace_manager,
|
||||
timestamp, num);
|
||||
}
|
||||
else if (strcmp (argv[0], "activate_workspace") == 0)
|
||||
{
|
||||
if (argc != 2)
|
||||
BAD_COMMAND("usage: %s <workspace-index>", argv[0]);
|
||||
|
||||
MetaDisplay *display = meta_get_display ();
|
||||
MetaWorkspaceManager *workspace_manager =
|
||||
meta_display_get_workspace_manager (display);
|
||||
|
||||
int index = atoi (argv[1]);
|
||||
if (index >= meta_workspace_manager_get_n_workspaces (workspace_manager))
|
||||
return FALSE;
|
||||
|
||||
MetaWorkspace *workspace =
|
||||
meta_workspace_manager_get_workspace_by_index (workspace_manager,
|
||||
index);
|
||||
uint32_t timestamp = meta_display_get_current_time_roundtrip (display);
|
||||
meta_workspace_activate (workspace, timestamp);
|
||||
}
|
||||
else if (strcmp (argv[0], "activate_workspace_with_focus") == 0)
|
||||
{
|
||||
if (argc != 3)
|
||||
BAD_COMMAND("usage: %s <workspace-index> <window-id>", argv[0]);
|
||||
|
||||
MetaTestClient *client;
|
||||
const char *window_id;
|
||||
if (!test_case_parse_window_id (test, argv[2], &client, &window_id, error))
|
||||
return FALSE;
|
||||
|
||||
MetaWindow *window;
|
||||
window = meta_test_client_find_window (client, window_id, error);
|
||||
if (!window)
|
||||
return FALSE;
|
||||
|
||||
MetaDisplay *display = meta_get_display ();
|
||||
MetaWorkspaceManager *workspace_manager =
|
||||
meta_display_get_workspace_manager (display);
|
||||
|
||||
int index = atoi (argv[1]);
|
||||
if (index >= meta_workspace_manager_get_n_workspaces (workspace_manager))
|
||||
return FALSE;
|
||||
|
||||
MetaWorkspace *workspace =
|
||||
meta_workspace_manager_get_workspace_by_index (workspace_manager,
|
||||
index);
|
||||
uint32_t timestamp = meta_display_get_current_time_roundtrip (display);
|
||||
meta_workspace_activate_with_focus (workspace, window, timestamp);
|
||||
}
|
||||
else if (strcmp (argv[0], "assert_stacking_workspace") == 0)
|
||||
{
|
||||
if (argc < 2)
|
||||
BAD_COMMAND("usage: %s <workspace-index> [<window-id1> ...]", argv[0]);
|
||||
|
||||
MetaDisplay *display = meta_get_display ();
|
||||
MetaWorkspaceManager *workspace_manager =
|
||||
meta_display_get_workspace_manager (display);
|
||||
|
||||
int index = atoi (argv[1]);
|
||||
if (index >= meta_workspace_manager_get_n_workspaces (workspace_manager))
|
||||
return FALSE;
|
||||
|
||||
MetaWorkspace *workspace =
|
||||
meta_workspace_manager_get_workspace_by_index (workspace_manager,
|
||||
index);
|
||||
|
||||
if (!test_case_assert_stacking (test, argv + 2, argc - 2, workspace, error))
|
||||
return FALSE;
|
||||
|
||||
if (!test_case_check_xserver_stacking (test, error))
|
||||
return FALSE;
|
||||
}
|
||||
else if (strcmp (argv[0], "window_to_workspace") == 0)
|
||||
{
|
||||
if (argc != 3)
|
||||
BAD_COMMAND("usage: %s <window-id> <workspace-index>", argv[0]);
|
||||
|
||||
MetaTestClient *client;
|
||||
const char *window_id;
|
||||
if (!test_case_parse_window_id (test, argv[1], &client, &window_id, error))
|
||||
return FALSE;
|
||||
|
||||
MetaWindow *window;
|
||||
window = meta_test_client_find_window (client, window_id, error);
|
||||
if (!window)
|
||||
return FALSE;
|
||||
|
||||
MetaDisplay *display = meta_get_display ();
|
||||
MetaWorkspaceManager *workspace_manager =
|
||||
meta_display_get_workspace_manager (display);
|
||||
|
||||
int index = atoi (argv[2]);
|
||||
if (index >= meta_workspace_manager_get_n_workspaces (workspace_manager))
|
||||
return FALSE;
|
||||
|
||||
MetaWorkspace *workspace =
|
||||
meta_workspace_manager_get_workspace_by_index (workspace_manager,
|
||||
index);
|
||||
|
||||
meta_window_change_workspace (window, workspace);
|
||||
}
|
||||
else
|
||||
{
|
||||
BAD_COMMAND("Unknown command %s", argv[0]);
|
||||
@ -1061,7 +1179,7 @@ test_case_destroy (TestCase *test,
|
||||
if (!test_case_wait (test, error))
|
||||
return FALSE;
|
||||
|
||||
if (!test_case_assert_stacking (test, NULL, 0, error))
|
||||
if (!test_case_assert_stacking (test, NULL, 0, NULL, error))
|
||||
return FALSE;
|
||||
|
||||
g_hash_table_iter_init (&iter, test->clients);
|
||||
|
Loading…
Reference in New Issue
Block a user