[mutter] tests/utils: Prefix AsyncWaiter with Meta



commit 9f1f3139b884225f4f2da3d26d73195a557ff60b
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Thu May 6 23:35:44 2021 +0200

    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>

 src/tests/meta-test-utils.c | 49 +++++++++++++++++++++++++--------------------
 src/tests/meta-test-utils.h | 14 ++++++-------
 src/tests/test-runner.c     | 10 ++++-----
 3 files changed, 39 insertions(+), 34 deletions(-)
---
diff --git a/src/tests/meta-test-utils.c b/src/tests/meta-test-utils.c
index 5d2d468aea..ff3eb873de 100644
--- a/src/tests/meta-test-utils.c
+++ b/src/tests/meta-test-utils.c
@@ -44,10 +44,10 @@ struct _MetaTestClient
   char *line;
   GError **error;
 
-  AsyncWaiter *waiter;
+  MetaAsyncWaiter *waiter;
 };
 
-struct _AsyncWaiter {
+struct _MetaAsyncWaiter {
   XSyncCounter counter;
   int counter_value;
   XSyncAlarm alarm;
@@ -100,10 +100,10 @@ test_init (int    *argc,
   meta_xwayland_override_display_number (512);
 }
 
-AsyncWaiter *
-async_waiter_new (void)
+MetaAsyncWaiter *
+meta_async_waiter_new (void)
 {
-  AsyncWaiter *waiter = g_new0 (AsyncWaiter, 1);
+  MetaAsyncWaiter *waiter = g_new0 (MetaAsyncWaiter, 1);
 
   MetaDisplay *display = meta_get_display ();
   Display *xdisplay = display->x11_display->xdisplay;
@@ -144,7 +144,7 @@ async_waiter_new (void)
 }
 
 void
-async_waiter_destroy (AsyncWaiter *waiter)
+meta_async_waiter_destroy (MetaAsyncWaiter *waiter)
 {
   MetaDisplay *display = meta_get_display ();
   Display *xdisplay = display->x11_display->xdisplay;
@@ -155,14 +155,14 @@ async_waiter_destroy (AsyncWaiter *waiter)
 }
 
 static int
-async_waiter_next_value (AsyncWaiter *waiter)
+meta_async_waiter_next_value (MetaAsyncWaiter *waiter)
 {
   return waiter->counter_value + 1;
 }
 
 static void
-async_waiter_wait (AsyncWaiter *waiter,
-                   int          wait_value)
+meta_async_waiter_wait (MetaAsyncWaiter *waiter,
+                        int              wait_value)
 {
   if (waiter->counter_value < wait_value)
     {
@@ -173,25 +173,24 @@ async_waiter_wait (AsyncWaiter *waiter,
 }
 
 void
-async_waiter_set_and_wait (AsyncWaiter *waiter)
+meta_async_waiter_set_and_wait (MetaAsyncWaiter *waiter)
 {
   MetaDisplay *display = meta_get_display ();
   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;
   XSyncIntToValue (&sync_value, wait_value);
 
   XSyncSetCounter (xdisplay, waiter->counter, sync_value);
-  async_waiter_wait (waiter, wait_value);
+  meta_async_waiter_wait (waiter, wait_value);
 }
 
 gboolean
-async_waiter_alarm_filter (MetaX11Display        *x11_display,
-                           XSyncAlarmNotifyEvent *event,
-                           gpointer               data)
+meta_async_waiter_process_x11_event (MetaAsyncWaiter       *waiter,
+                                     MetaX11Display        *x11_display,
+                                     XSyncAlarmNotifyEvent *event)
 {
-  AsyncWaiter *waiter = data;
 
   if (event->alarm != waiter->alarm)
     return FALSE;
@@ -310,7 +309,7 @@ meta_test_client_wait (MetaTestClient  *client,
     }
   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 *wait_value_str = g_strdup_printf ("%d", wait_value);
       gboolean success;
@@ -323,7 +322,7 @@ meta_test_client_wait (MetaTestClient  *client,
       if (!success)
         return FALSE;
 
-      async_waiter_wait (client->waiter, wait_value);
+      meta_async_waiter_wait (client->waiter, wait_value);
       return TRUE;
     }
 }
@@ -427,9 +426,15 @@ meta_test_client_process_x11_event (MetaTestClient        *client,
                                     XSyncAlarmNotifyEvent *event)
 {
   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
-    return FALSE;
+    {
+      return FALSE;
+    }
 }
 
 static gpointer
@@ -510,7 +515,7 @@ meta_test_client_new (const char            *id,
           g_thread_join (thread);
         }
 
-      client->waiter = async_waiter_new ();
+      client->waiter = meta_async_waiter_new ();
     }
 
   return client;
@@ -535,7 +540,7 @@ meta_test_client_destroy (MetaTestClient *client)
   GError *error = NULL;
 
   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);
   if (error)
diff --git a/src/tests/meta-test-utils.h b/src/tests/meta-test-utils.h
index d5bbf827d4..3100a8e735 100644
--- a/src/tests/meta-test-utils.h
+++ b/src/tests/meta-test-utils.h
@@ -37,21 +37,21 @@ typedef enum _MetaClientError
 
 GQuark meta_test_client_error_quark (void);
 
-typedef struct _AsyncWaiter AsyncWaiter;
+typedef struct _MetaAsyncWaiter MetaAsyncWaiter;
 typedef struct _MetaTestClient MetaTestClient;
 
 void test_init (int    *argc,
                 char ***argv);
 
-gboolean async_waiter_alarm_filter (MetaX11Display        *display,
-                                    XSyncAlarmNotifyEvent *event,
-                                    gpointer               data);
+gboolean meta_async_waiter_process_x11_event (MetaAsyncWaiter       *waiter,
+                                              MetaX11Display        *display,
+                                              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);
 
diff --git a/src/tests/test-runner.c b/src/tests/test-runner.c
index 60c9d86d92..395807e3ca 100644
--- a/src/tests/test-runner.c
+++ b/src/tests/test-runner.c
@@ -35,7 +35,7 @@
 
 typedef struct {
   GHashTable *clients;
-  AsyncWaiter *waiter;
+  MetaAsyncWaiter *waiter;
   GString *warning_messages;
   GMainLoop *loop;
   gulong x11_display_opened_handler_id;
@@ -50,7 +50,7 @@ test_case_alarm_filter (MetaX11Display        *x11_display,
   GHashTableIter iter;
   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;
 
   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,
                                      test_case_alarm_filter, test);
-  test->waiter = async_waiter_new ();
+  test->waiter = meta_async_waiter_new ();
 }
 
 static TestCase *
@@ -154,7 +154,7 @@ test_case_wait (TestCase *test,
    * received back any X events we generated.
    */
   if (test->waiter)
-    async_waiter_set_and_wait (test->waiter);
+    meta_async_waiter_set_and_wait (test->waiter);
   return TRUE;
 }
 
@@ -937,7 +937,7 @@ test_case_destroy (TestCase *test,
   while (g_hash_table_iter_next (&iter, &key, &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 ();
   g_clear_signal_handler (&test->x11_display_opened_handler_id, display);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]