mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-26 04:02:09 +01:00
tests: Add missing wakeup calls to gdbus-names.c
Following on from the previous commit, some explicit `g_main_context_wakeup()` calls were missing from the test code which only uses `GMainContext`. Add them, and also add some assertions to check that these functions are being called in the expected thread (as the code comments say). Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
This commit is contained in:
parent
8530a6a8e4
commit
bd8d139a77
@ -513,6 +513,7 @@ typedef struct
|
|||||||
gboolean unwatch_early;
|
gboolean unwatch_early;
|
||||||
GMutex mutex;
|
GMutex mutex;
|
||||||
guint watch_id;
|
guint watch_id;
|
||||||
|
GMainContext *thread_context; /* (unowned), only accessed from watcher_thread() */
|
||||||
} WatchNameThreadData;
|
} WatchNameThreadData;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -892,6 +893,9 @@ static void
|
|||||||
t_watch_name_data_free_func (WatchNameThreadData *thread_data)
|
t_watch_name_data_free_func (WatchNameThreadData *thread_data)
|
||||||
{
|
{
|
||||||
thread_data->data.num_free_func++;
|
thread_data->data.num_free_func++;
|
||||||
|
|
||||||
|
g_assert_true (g_main_context_is_owner (thread_data->thread_context));
|
||||||
|
g_main_context_wakeup (thread_data->thread_context);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Called in the same thread as watcher_thread() */
|
/* Called in the same thread as watcher_thread() */
|
||||||
@ -903,6 +907,9 @@ t_name_appeared_handler (GDBusConnection *connection,
|
|||||||
{
|
{
|
||||||
WatchNameThreadData *thread_data = user_data;
|
WatchNameThreadData *thread_data = user_data;
|
||||||
thread_data->data.num_appeared += 1;
|
thread_data->data.num_appeared += 1;
|
||||||
|
|
||||||
|
g_assert_true (g_main_context_is_owner (thread_data->thread_context));
|
||||||
|
g_main_context_wakeup (thread_data->thread_context);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Called in the same thread as watcher_thread() */
|
/* Called in the same thread as watcher_thread() */
|
||||||
@ -913,6 +920,9 @@ t_name_vanished_handler (GDBusConnection *connection,
|
|||||||
{
|
{
|
||||||
WatchNameThreadData *thread_data = user_data;
|
WatchNameThreadData *thread_data = user_data;
|
||||||
thread_data->data.num_vanished += 1;
|
thread_data->data.num_vanished += 1;
|
||||||
|
|
||||||
|
g_assert_true (g_main_context_is_owner (thread_data->thread_context));
|
||||||
|
g_main_context_wakeup (thread_data->thread_context);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Called in the thread which constructed the GDBusConnection */
|
/* Called in the thread which constructed the GDBusConnection */
|
||||||
@ -940,6 +950,7 @@ watcher_thread (gpointer user_data)
|
|||||||
GMainContext *thread_context;
|
GMainContext *thread_context;
|
||||||
|
|
||||||
thread_context = g_main_context_new ();
|
thread_context = g_main_context_new ();
|
||||||
|
thread_data->thread_context = thread_context;
|
||||||
g_main_context_push_thread_default (thread_context);
|
g_main_context_push_thread_default (thread_context);
|
||||||
|
|
||||||
// Notify that the thread has started
|
// Notify that the thread has started
|
||||||
|
Loading…
x
Reference in New Issue
Block a user