mirror of
https://github.com/brl/mutter.git
synced 2024-12-23 11:32:04 +00:00
tests/utils: Prefix TestClient with Meta
Soon we'll expose it via a libmutter-test library. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
This commit is contained in:
parent
f74d311d61
commit
4a6e22311a
@ -31,7 +31,8 @@
|
||||
#include "wayland/meta-xwayland.h"
|
||||
#include "x11/meta-x11-display-private.h"
|
||||
|
||||
struct _TestClient {
|
||||
struct _MetaTestClient
|
||||
{
|
||||
char *id;
|
||||
MetaWindowClientType type;
|
||||
GSubprocess *subprocess;
|
||||
@ -55,7 +56,7 @@ struct _AsyncWaiter {
|
||||
int counter_wait_value;
|
||||
};
|
||||
|
||||
G_DEFINE_QUARK (test-runner-error-quark, test_runner_error)
|
||||
G_DEFINE_QUARK (meta-test-client-error-quark, meta_test_client_error)
|
||||
|
||||
static char *test_client_path;
|
||||
|
||||
@ -205,7 +206,7 @@ async_waiter_alarm_filter (MetaX11Display *x11_display,
|
||||
}
|
||||
|
||||
char *
|
||||
test_client_get_id (TestClient *client)
|
||||
meta_test_client_get_id (MetaTestClient *client)
|
||||
{
|
||||
return client->id;
|
||||
}
|
||||
@ -213,9 +214,9 @@ test_client_get_id (TestClient *client)
|
||||
static void
|
||||
test_client_line_read (GObject *source,
|
||||
GAsyncResult *result,
|
||||
gpointer data)
|
||||
gpointer user_data)
|
||||
{
|
||||
TestClient *client = data;
|
||||
MetaTestClient *client = user_data;
|
||||
|
||||
client->line = g_data_input_stream_read_line_finish_utf8 (client->out,
|
||||
result,
|
||||
@ -225,9 +226,9 @@ test_client_line_read (GObject *source,
|
||||
}
|
||||
|
||||
gboolean
|
||||
test_client_do (TestClient *client,
|
||||
GError **error,
|
||||
...)
|
||||
meta_test_client_do (MetaTestClient *client,
|
||||
GError **error,
|
||||
...)
|
||||
{
|
||||
GString *command = g_string_new (NULL);
|
||||
char *line = NULL;
|
||||
@ -274,14 +275,20 @@ test_client_do (TestClient *client,
|
||||
if (!line)
|
||||
{
|
||||
if (*error == NULL)
|
||||
g_set_error (error, TEST_RUNNER_ERROR, TEST_RUNNER_ERROR_RUNTIME_ERROR,
|
||||
"test client exited");
|
||||
{
|
||||
g_set_error (error,
|
||||
META_TEST_CLIENT_ERROR,
|
||||
META_TEST_CLIENT_ERROR_RUNTIME_ERROR,
|
||||
"test client exited");
|
||||
}
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (strcmp (line, "OK") != 0)
|
||||
{
|
||||
g_set_error (error, TEST_RUNNER_ERROR, TEST_RUNNER_ERROR_RUNTIME_ERROR,
|
||||
g_set_error (error,
|
||||
META_TEST_CLIENT_ERROR,
|
||||
META_TEST_CLIENT_ERROR_RUNTIME_ERROR,
|
||||
"%s", line);
|
||||
goto out;
|
||||
}
|
||||
@ -294,12 +301,12 @@ test_client_do (TestClient *client,
|
||||
}
|
||||
|
||||
gboolean
|
||||
test_client_wait (TestClient *client,
|
||||
GError **error)
|
||||
meta_test_client_wait (MetaTestClient *client,
|
||||
GError **error)
|
||||
{
|
||||
if (client->type == META_WINDOW_CLIENT_TYPE_WAYLAND)
|
||||
{
|
||||
return test_client_do (client, error, "sync", NULL);
|
||||
return meta_test_client_do (client, error, "sync", NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -308,9 +315,9 @@ test_client_wait (TestClient *client,
|
||||
char *wait_value_str = g_strdup_printf ("%d", wait_value);
|
||||
gboolean success;
|
||||
|
||||
success = test_client_do (client, error,
|
||||
"set_counter", counter_str, wait_value_str,
|
||||
NULL);
|
||||
success = meta_test_client_do (client, error,
|
||||
"set_counter", counter_str, wait_value_str,
|
||||
NULL);
|
||||
g_free (counter_str);
|
||||
g_free (wait_value_str);
|
||||
if (!success)
|
||||
@ -322,9 +329,9 @@ test_client_wait (TestClient *client,
|
||||
}
|
||||
|
||||
MetaWindow *
|
||||
test_client_find_window (TestClient *client,
|
||||
const char *window_id,
|
||||
GError **error)
|
||||
meta_test_client_find_window (MetaTestClient *client,
|
||||
const char *window_id,
|
||||
GError **error)
|
||||
{
|
||||
MetaDisplay *display = meta_get_display ();
|
||||
GSList *windows;
|
||||
@ -354,8 +361,12 @@ test_client_find_window (TestClient *client,
|
||||
g_free (expected_title);
|
||||
|
||||
if (result == NULL)
|
||||
g_set_error (error, TEST_RUNNER_ERROR, TEST_RUNNER_ERROR_RUNTIME_ERROR,
|
||||
"window %s/%s isn't known to Mutter", client->id, window_id);
|
||||
{
|
||||
g_set_error (error,
|
||||
META_TEST_CLIENT_ERROR,
|
||||
META_TEST_CLIENT_ERROR_RUNTIME_ERROR,
|
||||
"window %s/%s isn't known to Mutter", client->id, window_id);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -394,8 +405,8 @@ wait_for_showing_before_redraw (gpointer user_data)
|
||||
}
|
||||
|
||||
void
|
||||
test_client_wait_for_window_shown (TestClient *client,
|
||||
MetaWindow *window)
|
||||
meta_test_client_wait_for_window_shown (MetaTestClient *client,
|
||||
MetaWindow *window)
|
||||
{
|
||||
WaitForShownData data = {
|
||||
.loop = g_main_loop_new (NULL, FALSE),
|
||||
@ -411,12 +422,10 @@ test_client_wait_for_window_shown (TestClient *client,
|
||||
}
|
||||
|
||||
gboolean
|
||||
test_client_alarm_filter (MetaX11Display *x11_display,
|
||||
XSyncAlarmNotifyEvent *event,
|
||||
gpointer data)
|
||||
meta_test_client_process_x11_event (MetaTestClient *client,
|
||||
MetaX11Display *x11_display,
|
||||
XSyncAlarmNotifyEvent *event)
|
||||
{
|
||||
TestClient *client = data;
|
||||
|
||||
if (client->waiter)
|
||||
return async_waiter_alarm_filter (x11_display, event, client->waiter);
|
||||
else
|
||||
@ -435,12 +444,12 @@ spawn_xwayland (gpointer user_data)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
TestClient *
|
||||
test_client_new (const char *id,
|
||||
MetaWindowClientType type,
|
||||
GError **error)
|
||||
MetaTestClient *
|
||||
meta_test_client_new (const char *id,
|
||||
MetaWindowClientType type,
|
||||
GError **error)
|
||||
{
|
||||
TestClient *client;
|
||||
MetaTestClient *client;
|
||||
GSubprocessLauncher *launcher;
|
||||
GSubprocess *subprocess;
|
||||
MetaWaylandCompositor *compositor;
|
||||
@ -475,7 +484,7 @@ test_client_new (const char *id,
|
||||
if (!subprocess)
|
||||
return NULL;
|
||||
|
||||
client = g_new0 (TestClient, 1);
|
||||
client = g_new0 (MetaTestClient, 1);
|
||||
client->type = type;
|
||||
client->id = g_strdup (id);
|
||||
client->cancellable = g_cancellable_new ();
|
||||
@ -508,20 +517,20 @@ test_client_new (const char *id,
|
||||
}
|
||||
|
||||
gboolean
|
||||
test_client_quit (TestClient *client,
|
||||
GError **error)
|
||||
meta_test_client_quit (MetaTestClient *client,
|
||||
GError **error)
|
||||
{
|
||||
if (!test_client_do (client, error, "destroy_all", NULL))
|
||||
if (!meta_test_client_do (client, error, "destroy_all", NULL))
|
||||
return FALSE;
|
||||
|
||||
if (!test_client_wait (client, error))
|
||||
if (!meta_test_client_wait (client, error))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
test_client_destroy (TestClient *client)
|
||||
meta_test_client_destroy (MetaTestClient *client)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
|
@ -26,19 +26,19 @@
|
||||
|
||||
#include "meta/window.h"
|
||||
|
||||
#define TEST_RUNNER_ERROR test_runner_error_quark ()
|
||||
#define META_TEST_CLIENT_ERROR meta_test_client_error_quark ()
|
||||
|
||||
typedef enum
|
||||
typedef enum _MetaClientError
|
||||
{
|
||||
TEST_RUNNER_ERROR_BAD_COMMAND,
|
||||
TEST_RUNNER_ERROR_RUNTIME_ERROR,
|
||||
TEST_RUNNER_ERROR_ASSERTION_FAILED
|
||||
} TestRunnerError;
|
||||
META_TEST_CLIENT_ERROR_BAD_COMMAND,
|
||||
META_TEST_CLIENT_ERROR_RUNTIME_ERROR,
|
||||
META_TEST_CLIENT_ERROR_ASSERTION_FAILED
|
||||
} MetaClientError;
|
||||
|
||||
GQuark test_runner_error_quark (void);
|
||||
GQuark meta_test_client_error_quark (void);
|
||||
|
||||
typedef struct _AsyncWaiter AsyncWaiter;
|
||||
typedef struct _TestClient TestClient;
|
||||
typedef struct _MetaTestClient MetaTestClient;
|
||||
|
||||
void test_init (int *argc,
|
||||
char ***argv);
|
||||
@ -53,34 +53,34 @@ AsyncWaiter * async_waiter_new (void);
|
||||
|
||||
void async_waiter_destroy (AsyncWaiter *waiter);
|
||||
|
||||
char * test_client_get_id (TestClient *client);
|
||||
char * meta_test_client_get_id (MetaTestClient *client);
|
||||
|
||||
gboolean test_client_alarm_filter (MetaX11Display *x11_display,
|
||||
XSyncAlarmNotifyEvent *event,
|
||||
gpointer data);
|
||||
gboolean meta_test_client_process_x11_event (MetaTestClient *client,
|
||||
MetaX11Display *x11_display,
|
||||
XSyncAlarmNotifyEvent *event);
|
||||
|
||||
gboolean test_client_wait (TestClient *client,
|
||||
GError **error);
|
||||
gboolean meta_test_client_wait (MetaTestClient *client,
|
||||
GError **error);
|
||||
|
||||
gboolean test_client_do (TestClient *client,
|
||||
GError **error,
|
||||
...) G_GNUC_NULL_TERMINATED;
|
||||
gboolean meta_test_client_do (MetaTestClient *client,
|
||||
GError **error,
|
||||
...) G_GNUC_NULL_TERMINATED;
|
||||
|
||||
MetaWindow * test_client_find_window (TestClient *client,
|
||||
const char *window_id,
|
||||
GError **error);
|
||||
MetaWindow * meta_test_client_find_window (MetaTestClient *client,
|
||||
const char *window_id,
|
||||
GError **error);
|
||||
|
||||
void test_client_wait_for_window_shown (TestClient *client,
|
||||
MetaWindow *window);
|
||||
void meta_test_client_wait_for_window_shown (MetaTestClient *client,
|
||||
MetaWindow *window);
|
||||
|
||||
gboolean test_client_quit (TestClient *client,
|
||||
GError **error);
|
||||
gboolean meta_test_client_quit (MetaTestClient *client,
|
||||
GError **error);
|
||||
|
||||
TestClient * test_client_new (const char *id,
|
||||
MetaWindowClientType type,
|
||||
GError **error);
|
||||
MetaTestClient * meta_test_client_new (const char *id,
|
||||
MetaWindowClientType type,
|
||||
GError **error);
|
||||
|
||||
void test_client_destroy (TestClient *client);
|
||||
void meta_test_client_destroy (MetaTestClient *client);
|
||||
|
||||
const char * test_get_plugin_name (void);
|
||||
|
||||
@ -89,4 +89,4 @@ void test_wait_for_x11_display (void);
|
||||
void meta_ensure_test_client_path (int argc,
|
||||
char **argv);
|
||||
|
||||
#endif /* META_TEST_UTILS_H */
|
||||
#endif /* TEST_UTILS_H */
|
||||
|
@ -157,8 +157,8 @@ static MonitorTestCase initial_test_case = {
|
||||
}
|
||||
};
|
||||
|
||||
static TestClient *wayland_monitor_test_client = NULL;
|
||||
static TestClient *x11_monitor_test_client = NULL;
|
||||
static MetaTestClient *wayland_monitor_test_client = NULL;
|
||||
static MetaTestClient *x11_monitor_test_client = NULL;
|
||||
|
||||
#define WAYLAND_TEST_CLIENT_NAME "wayland_monitor_test_client"
|
||||
#define WAYLAND_TEST_CLIENT_WINDOW "window1"
|
||||
@ -170,7 +170,8 @@ monitor_tests_alarm_filter (MetaX11Display *x11_display,
|
||||
XSyncAlarmNotifyEvent *event,
|
||||
gpointer data)
|
||||
{
|
||||
return test_client_alarm_filter (x11_display, event, x11_monitor_test_client);
|
||||
return meta_test_client_process_x11_event (x11_monitor_test_client,
|
||||
x11_display, event);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -178,51 +179,51 @@ create_monitor_test_clients (void)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
wayland_monitor_test_client = test_client_new (WAYLAND_TEST_CLIENT_NAME,
|
||||
META_WINDOW_CLIENT_TYPE_WAYLAND,
|
||||
&error);
|
||||
wayland_monitor_test_client = meta_test_client_new (WAYLAND_TEST_CLIENT_NAME,
|
||||
META_WINDOW_CLIENT_TYPE_WAYLAND,
|
||||
&error);
|
||||
if (!wayland_monitor_test_client)
|
||||
g_error ("Failed to launch Wayland test client: %s", error->message);
|
||||
|
||||
x11_monitor_test_client = test_client_new (X11_TEST_CLIENT_NAME,
|
||||
META_WINDOW_CLIENT_TYPE_X11,
|
||||
&error);
|
||||
x11_monitor_test_client = meta_test_client_new (X11_TEST_CLIENT_NAME,
|
||||
META_WINDOW_CLIENT_TYPE_X11,
|
||||
&error);
|
||||
if (!x11_monitor_test_client)
|
||||
g_error ("Failed to launch X11 test client: %s", error->message);
|
||||
|
||||
meta_x11_display_set_alarm_filter (meta_get_display ()->x11_display,
|
||||
monitor_tests_alarm_filter, NULL);
|
||||
|
||||
if (!test_client_do (wayland_monitor_test_client, &error,
|
||||
"create", WAYLAND_TEST_CLIENT_WINDOW,
|
||||
NULL))
|
||||
if (!meta_test_client_do (wayland_monitor_test_client, &error,
|
||||
"create", WAYLAND_TEST_CLIENT_WINDOW,
|
||||
NULL))
|
||||
g_error ("Failed to create Wayland window: %s", error->message);
|
||||
|
||||
if (!test_client_do (x11_monitor_test_client, &error,
|
||||
"create", X11_TEST_CLIENT_WINDOW,
|
||||
NULL))
|
||||
if (!meta_test_client_do (x11_monitor_test_client, &error,
|
||||
"create", X11_TEST_CLIENT_WINDOW,
|
||||
NULL))
|
||||
g_error ("Failed to create X11 window: %s", error->message);
|
||||
|
||||
if (!test_client_do (wayland_monitor_test_client, &error,
|
||||
"show", WAYLAND_TEST_CLIENT_WINDOW,
|
||||
NULL))
|
||||
if (!meta_test_client_do (wayland_monitor_test_client, &error,
|
||||
"show", WAYLAND_TEST_CLIENT_WINDOW,
|
||||
NULL))
|
||||
g_error ("Failed to show the window: %s", error->message);
|
||||
|
||||
if (!test_client_do (x11_monitor_test_client, &error,
|
||||
"show", X11_TEST_CLIENT_WINDOW,
|
||||
NULL))
|
||||
if (!meta_test_client_do (x11_monitor_test_client, &error,
|
||||
"show", X11_TEST_CLIENT_WINDOW,
|
||||
NULL))
|
||||
g_error ("Failed to show the window: %s", error->message);
|
||||
}
|
||||
|
||||
static void
|
||||
check_test_client_state (TestClient *test_client)
|
||||
check_test_client_state (MetaTestClient *test_client)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
if (!test_client_wait (test_client, &error))
|
||||
if (!meta_test_client_wait (test_client, &error))
|
||||
{
|
||||
g_error ("Failed to sync test client '%s': %s",
|
||||
test_client_get_id (test_client), error->message);
|
||||
meta_test_client_get_id (test_client), error->message);
|
||||
}
|
||||
}
|
||||
|
||||
@ -238,14 +239,14 @@ destroy_monitor_test_clients (void)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
if (!test_client_quit (wayland_monitor_test_client, &error))
|
||||
if (!meta_test_client_quit (wayland_monitor_test_client, &error))
|
||||
g_error ("Failed to quit Wayland test client: %s", error->message);
|
||||
|
||||
if (!test_client_quit (x11_monitor_test_client, &error))
|
||||
if (!meta_test_client_quit (x11_monitor_test_client, &error))
|
||||
g_error ("Failed to quit X11 test client: %s", error->message);
|
||||
|
||||
test_client_destroy (wayland_monitor_test_client);
|
||||
test_client_destroy (x11_monitor_test_client);
|
||||
meta_test_client_destroy (wayland_monitor_test_client);
|
||||
meta_test_client_destroy (x11_monitor_test_client);
|
||||
|
||||
meta_x11_display_set_alarm_filter (meta_get_display ()->x11_display,
|
||||
NULL, NULL);
|
||||
@ -2260,16 +2261,16 @@ meta_test_monitor_no_outputs (void)
|
||||
check_monitor_configuration (&test_case.expect);
|
||||
check_monitor_test_clients_state ();
|
||||
|
||||
if (!test_client_do (x11_monitor_test_client, &error,
|
||||
"resize", X11_TEST_CLIENT_WINDOW,
|
||||
"123", "210",
|
||||
NULL))
|
||||
if (!meta_test_client_do (x11_monitor_test_client, &error,
|
||||
"resize", X11_TEST_CLIENT_WINDOW,
|
||||
"123", "210",
|
||||
NULL))
|
||||
g_error ("Failed to resize X11 window: %s", error->message);
|
||||
|
||||
if (!test_client_do (wayland_monitor_test_client, &error,
|
||||
"resize", WAYLAND_TEST_CLIENT_WINDOW,
|
||||
"123", "210",
|
||||
NULL))
|
||||
if (!meta_test_client_do (wayland_monitor_test_client, &error,
|
||||
"resize", WAYLAND_TEST_CLIENT_WINDOW,
|
||||
"123", "210",
|
||||
NULL))
|
||||
g_error ("Failed to resize Wayland window: %s", error->message);
|
||||
|
||||
check_monitor_test_clients_state ();
|
||||
@ -5480,23 +5481,23 @@ dispatch (void)
|
||||
g_main_loop_run (loop);
|
||||
}
|
||||
|
||||
static TestClient *
|
||||
static MetaTestClient *
|
||||
create_test_window (const char *window_name)
|
||||
{
|
||||
TestClient *test_client;
|
||||
MetaTestClient *test_client;
|
||||
static int client_count = 0;
|
||||
g_autofree char *client_name = NULL;
|
||||
g_autoptr (GError) error = NULL;
|
||||
|
||||
client_name = g_strdup_printf ("test_client_%d", client_count++);
|
||||
test_client = test_client_new (client_name, META_WINDOW_CLIENT_TYPE_WAYLAND,
|
||||
&error);
|
||||
test_client = meta_test_client_new (client_name, META_WINDOW_CLIENT_TYPE_WAYLAND,
|
||||
&error);
|
||||
if (!test_client)
|
||||
g_error ("Failed to launch test client: %s", error->message);
|
||||
|
||||
if (!test_client_do (test_client, &error,
|
||||
"create", window_name,
|
||||
NULL))
|
||||
if (!meta_test_client_do (test_client, &error,
|
||||
"create", window_name,
|
||||
NULL))
|
||||
g_error ("Failed to create window: %s", error->message);
|
||||
|
||||
return test_client;
|
||||
@ -5508,6 +5509,7 @@ meta_test_monitor_wm_tiling (void)
|
||||
MonitorTestCase test_case = initial_test_case;
|
||||
MetaMonitorTestSetup *test_setup;
|
||||
g_autoptr (GError) error = NULL;
|
||||
MetaTestClient *test_client;
|
||||
|
||||
test_setup = create_monitor_test_setup (&test_case.setup,
|
||||
MONITOR_TEST_FLAG_NO_STORED);
|
||||
@ -5521,20 +5523,20 @@ meta_test_monitor_wm_tiling (void)
|
||||
*/
|
||||
|
||||
const char *test_window_name= "window1";
|
||||
TestClient *test_client = create_test_window (test_window_name);
|
||||
test_client = create_test_window (test_window_name);
|
||||
|
||||
if (!test_client_do (test_client, &error,
|
||||
"show", test_window_name,
|
||||
NULL))
|
||||
if (!meta_test_client_do (test_client, &error,
|
||||
"show", test_window_name,
|
||||
NULL))
|
||||
g_error ("Failed to show the window: %s", error->message);
|
||||
|
||||
MetaWindow *test_window =
|
||||
test_client_find_window (test_client,
|
||||
test_window_name,
|
||||
&error);
|
||||
meta_test_client_find_window (test_client,
|
||||
test_window_name,
|
||||
&error);
|
||||
if (!test_window)
|
||||
g_error ("Failed to find the window: %s", error->message);
|
||||
test_client_wait_for_window_shown (test_client, test_window);
|
||||
meta_test_client_wait_for_window_shown (test_client, test_window);
|
||||
|
||||
meta_window_tile (test_window, META_TILE_MAXIMIZED);
|
||||
meta_window_move_to_monitor (test_window, 1);
|
||||
@ -5574,7 +5576,7 @@ meta_test_monitor_wm_tiling (void)
|
||||
|
||||
meta_window_tile (test_window, META_TILE_MAXIMIZED);
|
||||
|
||||
test_client_destroy (test_client);
|
||||
meta_test_client_destroy (test_client);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -55,8 +55,12 @@ test_case_alarm_filter (MetaX11Display *x11_display,
|
||||
|
||||
g_hash_table_iter_init (&iter, test->clients);
|
||||
while (g_hash_table_iter_next (&iter, &key, &value))
|
||||
if (test_client_alarm_filter (x11_display, event, value))
|
||||
return TRUE;
|
||||
{
|
||||
MetaTestClient *client = value;
|
||||
|
||||
if (meta_test_client_process_x11_event (client, x11_display, event))
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
@ -139,7 +143,7 @@ test_case_wait (TestCase *test,
|
||||
*/
|
||||
g_hash_table_iter_init (&iter, test->clients);
|
||||
while (g_hash_table_iter_next (&iter, &key, &value))
|
||||
if (!test_client_wait (value, error))
|
||||
if (!meta_test_client_wait (value, error))
|
||||
return FALSE;
|
||||
|
||||
/* Then wait until we've done any outstanding queued up work. */
|
||||
@ -168,30 +172,35 @@ test_case_sleep (TestCase *test,
|
||||
#define BAD_COMMAND(...) \
|
||||
G_STMT_START { \
|
||||
g_set_error (error, \
|
||||
TEST_RUNNER_ERROR, TEST_RUNNER_ERROR_BAD_COMMAND, \
|
||||
META_TEST_CLIENT_ERROR, \
|
||||
META_TEST_CLIENT_ERROR_BAD_COMMAND, \
|
||||
__VA_ARGS__); \
|
||||
return FALSE; \
|
||||
} G_STMT_END
|
||||
|
||||
static TestClient *
|
||||
static MetaTestClient *
|
||||
test_case_lookup_client (TestCase *test,
|
||||
char *client_id,
|
||||
GError **error)
|
||||
{
|
||||
TestClient *client = g_hash_table_lookup (test->clients, client_id);
|
||||
MetaTestClient *client = g_hash_table_lookup (test->clients, client_id);
|
||||
if (!client)
|
||||
g_set_error (error, TEST_RUNNER_ERROR, TEST_RUNNER_ERROR_BAD_COMMAND,
|
||||
"No such client %s", client_id);
|
||||
{
|
||||
g_set_error (error,
|
||||
META_TEST_CLIENT_ERROR,
|
||||
META_TEST_CLIENT_ERROR_BAD_COMMAND,
|
||||
"No such client %s", client_id);
|
||||
}
|
||||
|
||||
return client;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
test_case_parse_window_id (TestCase *test,
|
||||
const char *client_and_window_id,
|
||||
TestClient **client,
|
||||
const char **window_id,
|
||||
GError **error)
|
||||
test_case_parse_window_id (TestCase *test,
|
||||
const char *client_and_window_id,
|
||||
MetaTestClient **client,
|
||||
const char **window_id,
|
||||
GError **error)
|
||||
{
|
||||
const char *slash = strchr (client_and_window_id, '/');
|
||||
char *tmp;
|
||||
@ -270,7 +279,9 @@ test_case_assert_stacking (TestCase *test,
|
||||
|
||||
if (strcmp (expected_string->str, stack_string->str) != 0)
|
||||
{
|
||||
g_set_error (error, TEST_RUNNER_ERROR, TEST_RUNNER_ERROR_ASSERTION_FAILED,
|
||||
g_set_error (error,
|
||||
META_TEST_CLIENT_ERROR,
|
||||
META_TEST_CLIENT_ERROR_ASSERTION_FAILED,
|
||||
"stacking: expected='%s', actual='%s'",
|
||||
expected_string->str, stack_string->str);
|
||||
}
|
||||
@ -292,7 +303,9 @@ test_case_assert_focused (TestCase *test,
|
||||
{
|
||||
if (g_strcmp0 (expected_window, "none") != 0)
|
||||
{
|
||||
g_set_error (error, TEST_RUNNER_ERROR, TEST_RUNNER_ERROR_ASSERTION_FAILED,
|
||||
g_set_error (error,
|
||||
META_TEST_CLIENT_ERROR,
|
||||
META_TEST_CLIENT_ERROR_ASSERTION_FAILED,
|
||||
"focus: expected='%s', actual='none'", expected_window);
|
||||
}
|
||||
}
|
||||
@ -304,7 +317,9 @@ test_case_assert_focused (TestCase *test,
|
||||
focused += 5;
|
||||
|
||||
if (g_strcmp0 (focused, expected_window) != 0)
|
||||
g_set_error (error, TEST_RUNNER_ERROR, TEST_RUNNER_ERROR_ASSERTION_FAILED,
|
||||
g_set_error (error,
|
||||
META_TEST_CLIENT_ERROR,
|
||||
META_TEST_CLIENT_ERROR_ASSERTION_FAILED,
|
||||
"focus: expected='%s', actual='%s'",
|
||||
expected_window, focused);
|
||||
}
|
||||
@ -326,7 +341,9 @@ test_case_assert_size (TestCase *test,
|
||||
if (frame_rect.width != expected_width ||
|
||||
frame_rect.height != expected_height)
|
||||
{
|
||||
g_set_error (error, TEST_RUNNER_ERROR, TEST_RUNNER_ERROR_ASSERTION_FAILED,
|
||||
g_set_error (error,
|
||||
META_TEST_CLIENT_ERROR,
|
||||
META_TEST_CLIENT_ERROR_ASSERTION_FAILED,
|
||||
"Expected size %dx%d didn't match actual size %dx%d",
|
||||
expected_width, expected_height,
|
||||
frame_rect.width, frame_rect.height);
|
||||
@ -380,7 +397,9 @@ test_case_check_xserver_stacking (TestCase *test,
|
||||
}
|
||||
|
||||
if (strcmp (x11_string->str, local_string->str) != 0)
|
||||
g_set_error (error, TEST_RUNNER_ERROR, TEST_RUNNER_ERROR_ASSERTION_FAILED,
|
||||
g_set_error (error,
|
||||
META_TEST_CLIENT_ERROR,
|
||||
META_TEST_CLIENT_ERROR_ASSERTION_FAILED,
|
||||
"xserver stacking: x11='%s', local='%s'",
|
||||
x11_string->str, local_string->str);
|
||||
|
||||
@ -451,7 +470,7 @@ test_case_do (TestCase *test,
|
||||
if (strcmp (argv[0], "new_client") == 0)
|
||||
{
|
||||
MetaWindowClientType type;
|
||||
TestClient *client;
|
||||
MetaTestClient *client;
|
||||
|
||||
if (argc != 3)
|
||||
BAD_COMMAND("usage: new_client <client-id> [wayland|x11]");
|
||||
@ -466,26 +485,26 @@ test_case_do (TestCase *test,
|
||||
if (g_hash_table_lookup (test->clients, argv[1]))
|
||||
BAD_COMMAND("client %s already exists", argv[1]);
|
||||
|
||||
client = test_client_new (argv[1], type, error);
|
||||
client = meta_test_client_new (argv[1], type, error);
|
||||
if (!client)
|
||||
return FALSE;
|
||||
|
||||
g_hash_table_insert (test->clients, test_client_get_id (client), client);
|
||||
g_hash_table_insert (test->clients, meta_test_client_get_id (client), client);
|
||||
}
|
||||
else if (strcmp (argv[0], "quit_client") == 0)
|
||||
{
|
||||
if (argc != 2)
|
||||
BAD_COMMAND("usage: quit_client <client-id>");
|
||||
|
||||
TestClient *client = test_case_lookup_client (test, argv[1], error);
|
||||
MetaTestClient *client = test_case_lookup_client (test, argv[1], error);
|
||||
if (!client)
|
||||
return FALSE;
|
||||
|
||||
if (!test_client_quit (client, error))
|
||||
if (!meta_test_client_quit (client, error))
|
||||
return FALSE;
|
||||
|
||||
g_hash_table_remove (test->clients, test_client_get_id (client));
|
||||
test_client_destroy (client);
|
||||
g_hash_table_remove (test->clients, meta_test_client_get_id (client));
|
||||
meta_test_client_destroy (client);
|
||||
}
|
||||
else if (strcmp (argv[0], "create") == 0)
|
||||
{
|
||||
@ -494,18 +513,18 @@ test_case_do (TestCase *test,
|
||||
(argc == 3 && strcmp (argv[2], "csd") == 0)))
|
||||
BAD_COMMAND("usage: %s <client-id>/<window-id > [override|csd]", argv[0]);
|
||||
|
||||
TestClient *client;
|
||||
MetaTestClient *client;
|
||||
const char *window_id;
|
||||
if (!test_case_parse_window_id (test, argv[1], &client, &window_id, error))
|
||||
return FALSE;
|
||||
|
||||
if (!test_client_do (client, error,
|
||||
"create", window_id,
|
||||
argc == 3 ? argv[2] : NULL,
|
||||
NULL))
|
||||
if (!meta_test_client_do (client, error,
|
||||
"create", window_id,
|
||||
argc == 3 ? argv[2] : NULL,
|
||||
NULL))
|
||||
return FALSE;
|
||||
|
||||
if (!test_client_wait (client, error))
|
||||
if (!meta_test_client_wait (client, error))
|
||||
return FALSE;
|
||||
}
|
||||
else if (strcmp (argv[0], "set_parent") == 0 ||
|
||||
@ -515,15 +534,15 @@ test_case_do (TestCase *test,
|
||||
BAD_COMMAND("usage: %s <client-id>/<window-id> <parent-window-id>",
|
||||
argv[0]);
|
||||
|
||||
TestClient *client;
|
||||
MetaTestClient *client;
|
||||
const char *window_id;
|
||||
if (!test_case_parse_window_id (test, argv[1], &client, &window_id, error))
|
||||
return FALSE;
|
||||
|
||||
if (!test_client_do (client, error,
|
||||
argv[0], window_id,
|
||||
argv[2],
|
||||
NULL))
|
||||
if (!meta_test_client_do (client, error,
|
||||
argv[0], window_id,
|
||||
argv[2],
|
||||
NULL))
|
||||
return FALSE;
|
||||
}
|
||||
else if (strcmp (argv[0], "accept_focus") == 0)
|
||||
@ -534,15 +553,15 @@ test_case_do (TestCase *test,
|
||||
BAD_COMMAND("usage: %s <client-id>/<window-id> [true|false]",
|
||||
argv[0]);
|
||||
|
||||
TestClient *client;
|
||||
MetaTestClient *client;
|
||||
const char *window_id;
|
||||
if (!test_case_parse_window_id (test, argv[1], &client, &window_id, error))
|
||||
return FALSE;
|
||||
|
||||
if (!test_client_do (client, error,
|
||||
argv[0], window_id,
|
||||
argv[2],
|
||||
NULL))
|
||||
if (!meta_test_client_do (client, error,
|
||||
argv[0], window_id,
|
||||
argv[2],
|
||||
NULL))
|
||||
return FALSE;
|
||||
}
|
||||
else if (strcmp (argv[0], "can_take_focus") == 0)
|
||||
@ -553,15 +572,15 @@ test_case_do (TestCase *test,
|
||||
BAD_COMMAND("usage: %s <client-id>/<window-id> [true|false]",
|
||||
argv[0]);
|
||||
|
||||
TestClient *client;
|
||||
MetaTestClient *client;
|
||||
const char *window_id;
|
||||
if (!test_case_parse_window_id (test, argv[1], &client, &window_id, error))
|
||||
return FALSE;
|
||||
|
||||
if (!test_client_do (client, error,
|
||||
argv[0], window_id,
|
||||
argv[2],
|
||||
NULL))
|
||||
if (!meta_test_client_do (client, error,
|
||||
argv[0], window_id,
|
||||
argv[2],
|
||||
NULL))
|
||||
return FALSE;
|
||||
}
|
||||
else if (strcmp (argv[0], "accept_take_focus") == 0)
|
||||
@ -572,19 +591,20 @@ test_case_do (TestCase *test,
|
||||
BAD_COMMAND("usage: %s <client-id>/<window-id> [true|false]",
|
||||
argv[0]);
|
||||
|
||||
TestClient *client;
|
||||
MetaTestClient *client;
|
||||
const char *window_id;
|
||||
if (!test_case_parse_window_id (test, argv[1], &client, &window_id, error))
|
||||
return FALSE;
|
||||
|
||||
if (!test_client_do (client, error,
|
||||
argv[0], window_id,
|
||||
argv[2],
|
||||
NULL))
|
||||
if (!meta_test_client_do (client, error,
|
||||
argv[0], window_id,
|
||||
argv[2],
|
||||
NULL))
|
||||
return FALSE;
|
||||
}
|
||||
else if (strcmp (argv[0], "show") == 0)
|
||||
{
|
||||
MetaWindow *window;
|
||||
gboolean show_async = FALSE;
|
||||
|
||||
if (argc != 2 && argc != 3)
|
||||
@ -593,49 +613,51 @@ test_case_do (TestCase *test,
|
||||
if (argc == 3 && strcmp (argv[2], "async") == 0)
|
||||
show_async = TRUE;
|
||||
|
||||
TestClient *client;
|
||||
MetaTestClient *client;
|
||||
const char *window_id;
|
||||
if (!test_case_parse_window_id (test, argv[1], &client, &window_id, error))
|
||||
return FALSE;
|
||||
|
||||
if (!test_client_do (client, error, argv[0], window_id, NULL))
|
||||
if (!meta_test_client_do (client, error, argv[0], window_id, NULL))
|
||||
return FALSE;
|
||||
|
||||
if (!test_case_wait (test, error))
|
||||
return FALSE;
|
||||
|
||||
MetaWindow *window = test_client_find_window (client, window_id, error);
|
||||
window = meta_test_client_find_window (client, window_id, error);
|
||||
if (!window)
|
||||
return FALSE;
|
||||
|
||||
if (!show_async)
|
||||
test_client_wait_for_window_shown (client, window);
|
||||
meta_test_client_wait_for_window_shown (client, window);
|
||||
}
|
||||
else if (strcmp (argv[0], "resize") == 0)
|
||||
{
|
||||
if (argc != 4)
|
||||
BAD_COMMAND("usage: %s <client-id>/<window-id> width height", argv[0]);
|
||||
|
||||
TestClient *client;
|
||||
MetaTestClient *client;
|
||||
const char *window_id;
|
||||
if (!test_case_parse_window_id (test, argv[1], &client, &window_id, error))
|
||||
return FALSE;
|
||||
|
||||
if (!test_client_do (client, error, argv[0], window_id,
|
||||
argv[2], argv[3], NULL))
|
||||
if (!meta_test_client_do (client, error, argv[0], window_id,
|
||||
argv[2], argv[3], NULL))
|
||||
return FALSE;
|
||||
}
|
||||
else if (strcmp (argv[0], "move") == 0)
|
||||
{
|
||||
MetaWindow *window;
|
||||
|
||||
if (argc != 4)
|
||||
BAD_COMMAND("usage: %s <client-id>/<window-id> x y", argv[0]);
|
||||
|
||||
TestClient *client;
|
||||
MetaTestClient *client;
|
||||
const char *window_id;
|
||||
if (!test_case_parse_window_id (test, argv[1], &client, &window_id, error))
|
||||
return FALSE;
|
||||
|
||||
MetaWindow *window = test_client_find_window (client, window_id, error);
|
||||
window = meta_test_client_find_window (client, window_id, error);
|
||||
if (!window)
|
||||
return FALSE;
|
||||
|
||||
@ -643,15 +665,17 @@ test_case_do (TestCase *test,
|
||||
}
|
||||
else if (strcmp (argv[0], "tile") == 0)
|
||||
{
|
||||
MetaWindow *window;
|
||||
|
||||
if (argc != 3)
|
||||
BAD_COMMAND("usage: %s <client-id>/<window-id> [right|left]", argv[0]);
|
||||
|
||||
TestClient *client;
|
||||
MetaTestClient *client;
|
||||
const char *window_id;
|
||||
if (!test_case_parse_window_id (test, argv[1], &client, &window_id, error))
|
||||
return FALSE;
|
||||
|
||||
MetaWindow *window = test_client_find_window (client, window_id, error);
|
||||
window = meta_test_client_find_window (client, window_id, error);
|
||||
if (!window)
|
||||
return FALSE;
|
||||
|
||||
@ -667,8 +691,8 @@ test_case_do (TestCase *test,
|
||||
else
|
||||
{
|
||||
g_set_error (error,
|
||||
TEST_RUNNER_ERROR,
|
||||
TEST_RUNNER_ERROR_ASSERTION_FAILED,
|
||||
META_TEST_CLIENT_ERROR,
|
||||
META_TEST_CLIENT_ERROR_ASSERTION_FAILED,
|
||||
"Invalid tile mode '%s'", argv[2]);
|
||||
return FALSE;
|
||||
}
|
||||
@ -677,15 +701,17 @@ test_case_do (TestCase *test,
|
||||
}
|
||||
else if (strcmp (argv[0], "untile") == 0)
|
||||
{
|
||||
MetaWindow *window;
|
||||
|
||||
if (argc != 2)
|
||||
BAD_COMMAND("usage: %s <client-id>/<window-id>", argv[0]);
|
||||
|
||||
TestClient *client;
|
||||
MetaTestClient *client;
|
||||
const char *window_id;
|
||||
if (!test_case_parse_window_id (test, argv[1], &client, &window_id, error))
|
||||
return FALSE;
|
||||
|
||||
MetaWindow *window = test_client_find_window (client, window_id, error);
|
||||
window = meta_test_client_find_window (client, window_id, error);
|
||||
if (!window)
|
||||
return FALSE;
|
||||
|
||||
@ -708,25 +734,27 @@ test_case_do (TestCase *test,
|
||||
if (argc != 2)
|
||||
BAD_COMMAND("usage: %s <client-id>/<window-id>", argv[0]);
|
||||
|
||||
TestClient *client;
|
||||
MetaTestClient *client;
|
||||
const char *window_id;
|
||||
if (!test_case_parse_window_id (test, argv[1], &client, &window_id, error))
|
||||
return FALSE;
|
||||
|
||||
if (!test_client_do (client, error, argv[0], window_id, NULL))
|
||||
if (!meta_test_client_do (client, error, argv[0], window_id, NULL))
|
||||
return FALSE;
|
||||
}
|
||||
else if (strcmp (argv[0], "local_activate") == 0)
|
||||
{
|
||||
MetaWindow *window;
|
||||
|
||||
if (argc != 2)
|
||||
BAD_COMMAND("usage: %s <client-id>/<window-id>", argv[0]);
|
||||
|
||||
TestClient *client;
|
||||
MetaTestClient *client;
|
||||
const char *window_id;
|
||||
if (!test_case_parse_window_id (test, argv[1], &client, &window_id, error))
|
||||
return FALSE;
|
||||
|
||||
MetaWindow *window = test_client_find_window (client, window_id, error);
|
||||
window = meta_test_client_find_window (client, window_id, error);
|
||||
if (!window)
|
||||
return FALSE;
|
||||
|
||||
@ -795,26 +823,28 @@ test_case_do (TestCase *test,
|
||||
}
|
||||
else if (strcmp (argv[0], "assert_size") == 0)
|
||||
{
|
||||
MetaWindow *window;
|
||||
|
||||
if (argc != 4)
|
||||
{
|
||||
BAD_COMMAND("usage: %s <client-id>/<window-id> <width> <height>",
|
||||
argv[0]);
|
||||
}
|
||||
|
||||
TestClient *client;
|
||||
MetaTestClient *client;
|
||||
const char *window_id;
|
||||
if (!test_case_parse_window_id (test, argv[1], &client, &window_id, error))
|
||||
return FALSE;
|
||||
|
||||
MetaWindow *window = test_client_find_window (client, window_id, error);
|
||||
window = meta_test_client_find_window (client, window_id, error);
|
||||
if (!window)
|
||||
return FALSE;
|
||||
|
||||
if (meta_window_get_frame (window))
|
||||
{
|
||||
g_set_error (error,
|
||||
TEST_RUNNER_ERROR,
|
||||
TEST_RUNNER_ERROR_ASSERTION_FAILED,
|
||||
META_TEST_CLIENT_ERROR,
|
||||
META_TEST_CLIENT_ERROR_ASSERTION_FAILED,
|
||||
"Can only assert size of CSD window");
|
||||
return FALSE;
|
||||
}
|
||||
@ -824,11 +854,11 @@ test_case_do (TestCase *test,
|
||||
g_autofree char *width_str = g_strdup_printf ("%d", width);
|
||||
g_autofree char *height_str = g_strdup_printf ("%d", height);
|
||||
|
||||
if (!test_client_do (client, error, argv[0],
|
||||
window_id,
|
||||
width_str,
|
||||
height_str,
|
||||
NULL))
|
||||
if (!meta_test_client_do (client, error, argv[0],
|
||||
window_id,
|
||||
width_str,
|
||||
height_str,
|
||||
NULL))
|
||||
return FALSE;
|
||||
|
||||
if (!test_case_assert_size (test, window,
|
||||
@ -838,18 +868,20 @@ test_case_do (TestCase *test,
|
||||
}
|
||||
else if (strcmp (argv[0], "assert_position") == 0)
|
||||
{
|
||||
MetaWindow *window;
|
||||
|
||||
if (argc != 4)
|
||||
{
|
||||
BAD_COMMAND("usage: %s <client-id>/<window-id> <x> <y>",
|
||||
argv[0]);
|
||||
}
|
||||
|
||||
TestClient *client;
|
||||
MetaTestClient *client;
|
||||
const char *window_id;
|
||||
if (!test_case_parse_window_id (test, argv[1], &client, &window_id, error))
|
||||
return FALSE;
|
||||
|
||||
MetaWindow *window = test_client_find_window (client, window_id, error);
|
||||
window = meta_test_client_find_window (client, window_id, error);
|
||||
if (!window)
|
||||
return FALSE;
|
||||
|
||||
@ -860,8 +892,8 @@ test_case_do (TestCase *test,
|
||||
if (frame_rect.x != x || frame_rect.y != y)
|
||||
{
|
||||
g_set_error (error,
|
||||
TEST_RUNNER_ERROR,
|
||||
TEST_RUNNER_ERROR_ASSERTION_FAILED,
|
||||
META_TEST_CLIENT_ERROR,
|
||||
META_TEST_CLIENT_ERROR_ASSERTION_FAILED,
|
||||
"Expected window position (%d, %d) doesn't match (%d, %d)",
|
||||
x, y, frame_rect.x, frame_rect.y);
|
||||
return FALSE;
|
||||
@ -890,7 +922,7 @@ test_case_destroy (TestCase *test,
|
||||
g_hash_table_iter_init (&iter, test->clients);
|
||||
while (g_hash_table_iter_next (&iter, &key, &value))
|
||||
{
|
||||
if (!test_client_do (value, error, "destroy_all", NULL))
|
||||
if (!meta_test_client_do (value, error, "destroy_all", NULL))
|
||||
return FALSE;
|
||||
|
||||
}
|
||||
@ -903,7 +935,7 @@ test_case_destroy (TestCase *test,
|
||||
|
||||
g_hash_table_iter_init (&iter, test->clients);
|
||||
while (g_hash_table_iter_next (&iter, &key, &value))
|
||||
test_client_destroy (value);
|
||||
meta_test_client_destroy (value);
|
||||
|
||||
g_clear_pointer (&test->waiter, async_waiter_destroy);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user