mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 09:30:45 -05:00
tests/utils: Prefix AsyncWaiter with Meta
This too will be used by test cases via a shared library. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
This commit is contained in:
parent
4a6e22311a
commit
9f1f3139b8
@ -44,10 +44,10 @@ struct _MetaTestClient
|
|||||||
char *line;
|
char *line;
|
||||||
GError **error;
|
GError **error;
|
||||||
|
|
||||||
AsyncWaiter *waiter;
|
MetaAsyncWaiter *waiter;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _AsyncWaiter {
|
struct _MetaAsyncWaiter {
|
||||||
XSyncCounter counter;
|
XSyncCounter counter;
|
||||||
int counter_value;
|
int counter_value;
|
||||||
XSyncAlarm alarm;
|
XSyncAlarm alarm;
|
||||||
@ -100,10 +100,10 @@ test_init (int *argc,
|
|||||||
meta_xwayland_override_display_number (512);
|
meta_xwayland_override_display_number (512);
|
||||||
}
|
}
|
||||||
|
|
||||||
AsyncWaiter *
|
MetaAsyncWaiter *
|
||||||
async_waiter_new (void)
|
meta_async_waiter_new (void)
|
||||||
{
|
{
|
||||||
AsyncWaiter *waiter = g_new0 (AsyncWaiter, 1);
|
MetaAsyncWaiter *waiter = g_new0 (MetaAsyncWaiter, 1);
|
||||||
|
|
||||||
MetaDisplay *display = meta_get_display ();
|
MetaDisplay *display = meta_get_display ();
|
||||||
Display *xdisplay = display->x11_display->xdisplay;
|
Display *xdisplay = display->x11_display->xdisplay;
|
||||||
@ -144,7 +144,7 @@ async_waiter_new (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
async_waiter_destroy (AsyncWaiter *waiter)
|
meta_async_waiter_destroy (MetaAsyncWaiter *waiter)
|
||||||
{
|
{
|
||||||
MetaDisplay *display = meta_get_display ();
|
MetaDisplay *display = meta_get_display ();
|
||||||
Display *xdisplay = display->x11_display->xdisplay;
|
Display *xdisplay = display->x11_display->xdisplay;
|
||||||
@ -155,14 +155,14 @@ async_waiter_destroy (AsyncWaiter *waiter)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
async_waiter_next_value (AsyncWaiter *waiter)
|
meta_async_waiter_next_value (MetaAsyncWaiter *waiter)
|
||||||
{
|
{
|
||||||
return waiter->counter_value + 1;
|
return waiter->counter_value + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
async_waiter_wait (AsyncWaiter *waiter,
|
meta_async_waiter_wait (MetaAsyncWaiter *waiter,
|
||||||
int wait_value)
|
int wait_value)
|
||||||
{
|
{
|
||||||
if (waiter->counter_value < wait_value)
|
if (waiter->counter_value < wait_value)
|
||||||
{
|
{
|
||||||
@ -173,25 +173,24 @@ async_waiter_wait (AsyncWaiter *waiter,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
async_waiter_set_and_wait (AsyncWaiter *waiter)
|
meta_async_waiter_set_and_wait (MetaAsyncWaiter *waiter)
|
||||||
{
|
{
|
||||||
MetaDisplay *display = meta_get_display ();
|
MetaDisplay *display = meta_get_display ();
|
||||||
Display *xdisplay = display->x11_display->xdisplay;
|
Display *xdisplay = display->x11_display->xdisplay;
|
||||||
int wait_value = async_waiter_next_value (waiter);
|
int wait_value = meta_async_waiter_next_value (waiter);
|
||||||
|
|
||||||
XSyncValue sync_value;
|
XSyncValue sync_value;
|
||||||
XSyncIntToValue (&sync_value, wait_value);
|
XSyncIntToValue (&sync_value, wait_value);
|
||||||
|
|
||||||
XSyncSetCounter (xdisplay, waiter->counter, sync_value);
|
XSyncSetCounter (xdisplay, waiter->counter, sync_value);
|
||||||
async_waiter_wait (waiter, wait_value);
|
meta_async_waiter_wait (waiter, wait_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
async_waiter_alarm_filter (MetaX11Display *x11_display,
|
meta_async_waiter_process_x11_event (MetaAsyncWaiter *waiter,
|
||||||
XSyncAlarmNotifyEvent *event,
|
MetaX11Display *x11_display,
|
||||||
gpointer data)
|
XSyncAlarmNotifyEvent *event)
|
||||||
{
|
{
|
||||||
AsyncWaiter *waiter = data;
|
|
||||||
|
|
||||||
if (event->alarm != waiter->alarm)
|
if (event->alarm != waiter->alarm)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -310,7 +309,7 @@ meta_test_client_wait (MetaTestClient *client,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int wait_value = async_waiter_next_value (client->waiter);
|
int wait_value = meta_async_waiter_next_value (client->waiter);
|
||||||
char *counter_str = g_strdup_printf ("%lu", client->waiter->counter);
|
char *counter_str = g_strdup_printf ("%lu", client->waiter->counter);
|
||||||
char *wait_value_str = g_strdup_printf ("%d", wait_value);
|
char *wait_value_str = g_strdup_printf ("%d", wait_value);
|
||||||
gboolean success;
|
gboolean success;
|
||||||
@ -323,7 +322,7 @@ meta_test_client_wait (MetaTestClient *client,
|
|||||||
if (!success)
|
if (!success)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
async_waiter_wait (client->waiter, wait_value);
|
meta_async_waiter_wait (client->waiter, wait_value);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -427,9 +426,15 @@ meta_test_client_process_x11_event (MetaTestClient *client,
|
|||||||
XSyncAlarmNotifyEvent *event)
|
XSyncAlarmNotifyEvent *event)
|
||||||
{
|
{
|
||||||
if (client->waiter)
|
if (client->waiter)
|
||||||
return async_waiter_alarm_filter (x11_display, event, client->waiter);
|
{
|
||||||
|
return meta_async_waiter_process_x11_event (client->waiter,
|
||||||
|
x11_display,
|
||||||
|
event);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return FALSE;
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static gpointer
|
static gpointer
|
||||||
@ -510,7 +515,7 @@ meta_test_client_new (const char *id,
|
|||||||
g_thread_join (thread);
|
g_thread_join (thread);
|
||||||
}
|
}
|
||||||
|
|
||||||
client->waiter = async_waiter_new ();
|
client->waiter = meta_async_waiter_new ();
|
||||||
}
|
}
|
||||||
|
|
||||||
return client;
|
return client;
|
||||||
@ -535,7 +540,7 @@ meta_test_client_destroy (MetaTestClient *client)
|
|||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
if (client->waiter)
|
if (client->waiter)
|
||||||
async_waiter_destroy (client->waiter);
|
meta_async_waiter_destroy (client->waiter);
|
||||||
|
|
||||||
g_output_stream_close (G_OUTPUT_STREAM (client->in), NULL, &error);
|
g_output_stream_close (G_OUTPUT_STREAM (client->in), NULL, &error);
|
||||||
if (error)
|
if (error)
|
||||||
|
@ -37,21 +37,21 @@ typedef enum _MetaClientError
|
|||||||
|
|
||||||
GQuark meta_test_client_error_quark (void);
|
GQuark meta_test_client_error_quark (void);
|
||||||
|
|
||||||
typedef struct _AsyncWaiter AsyncWaiter;
|
typedef struct _MetaAsyncWaiter MetaAsyncWaiter;
|
||||||
typedef struct _MetaTestClient MetaTestClient;
|
typedef struct _MetaTestClient MetaTestClient;
|
||||||
|
|
||||||
void test_init (int *argc,
|
void test_init (int *argc,
|
||||||
char ***argv);
|
char ***argv);
|
||||||
|
|
||||||
gboolean async_waiter_alarm_filter (MetaX11Display *display,
|
gboolean meta_async_waiter_process_x11_event (MetaAsyncWaiter *waiter,
|
||||||
XSyncAlarmNotifyEvent *event,
|
MetaX11Display *display,
|
||||||
gpointer data);
|
XSyncAlarmNotifyEvent *event);
|
||||||
|
|
||||||
void async_waiter_set_and_wait (AsyncWaiter *waiter);
|
void meta_async_waiter_set_and_wait (MetaAsyncWaiter *waiter);
|
||||||
|
|
||||||
AsyncWaiter * async_waiter_new (void);
|
MetaAsyncWaiter * meta_async_waiter_new (void);
|
||||||
|
|
||||||
void async_waiter_destroy (AsyncWaiter *waiter);
|
void meta_async_waiter_destroy (MetaAsyncWaiter *waiter);
|
||||||
|
|
||||||
char * meta_test_client_get_id (MetaTestClient *client);
|
char * meta_test_client_get_id (MetaTestClient *client);
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
GHashTable *clients;
|
GHashTable *clients;
|
||||||
AsyncWaiter *waiter;
|
MetaAsyncWaiter *waiter;
|
||||||
GString *warning_messages;
|
GString *warning_messages;
|
||||||
GMainLoop *loop;
|
GMainLoop *loop;
|
||||||
gulong x11_display_opened_handler_id;
|
gulong x11_display_opened_handler_id;
|
||||||
@ -50,7 +50,7 @@ test_case_alarm_filter (MetaX11Display *x11_display,
|
|||||||
GHashTableIter iter;
|
GHashTableIter iter;
|
||||||
gpointer key, value;
|
gpointer key, value;
|
||||||
|
|
||||||
if (async_waiter_alarm_filter (x11_display, event, test->waiter))
|
if (meta_async_waiter_process_x11_event (test->waiter, x11_display, event))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
g_hash_table_iter_init (&iter, test->clients);
|
g_hash_table_iter_init (&iter, test->clients);
|
||||||
@ -71,7 +71,7 @@ on_x11_display_opened (MetaDisplay *display,
|
|||||||
{
|
{
|
||||||
meta_x11_display_set_alarm_filter (display->x11_display,
|
meta_x11_display_set_alarm_filter (display->x11_display,
|
||||||
test_case_alarm_filter, test);
|
test_case_alarm_filter, test);
|
||||||
test->waiter = async_waiter_new ();
|
test->waiter = meta_async_waiter_new ();
|
||||||
}
|
}
|
||||||
|
|
||||||
static TestCase *
|
static TestCase *
|
||||||
@ -154,7 +154,7 @@ test_case_wait (TestCase *test,
|
|||||||
* received back any X events we generated.
|
* received back any X events we generated.
|
||||||
*/
|
*/
|
||||||
if (test->waiter)
|
if (test->waiter)
|
||||||
async_waiter_set_and_wait (test->waiter);
|
meta_async_waiter_set_and_wait (test->waiter);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -937,7 +937,7 @@ test_case_destroy (TestCase *test,
|
|||||||
while (g_hash_table_iter_next (&iter, &key, &value))
|
while (g_hash_table_iter_next (&iter, &key, &value))
|
||||||
meta_test_client_destroy (value);
|
meta_test_client_destroy (value);
|
||||||
|
|
||||||
g_clear_pointer (&test->waiter, async_waiter_destroy);
|
g_clear_pointer (&test->waiter, meta_async_waiter_destroy);
|
||||||
|
|
||||||
display = meta_get_display ();
|
display = meta_get_display ();
|
||||||
g_clear_signal_handler (&test->x11_display_opened_handler_id, display);
|
g_clear_signal_handler (&test->x11_display_opened_handler_id, display);
|
||||||
|
Loading…
Reference in New Issue
Block a user