From: Iain Lane Date: Tue, 30 Jun 2015 16:13:49 +0000 (+0100) Subject: gio/tests/appmonitor: Delete file before checking for changed event X-Git-Tag: 2.45.4~18 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f2c1cfe8c770f73367a021044bcdda550348714c;p=platform%2Fupstream%2Fglib.git gio/tests/appmonitor: Delete file before checking for changed event In 4e7d22e268a4e06beb1c09585a48288c31004da5, deleting the file was moved after the assertion which checks for the changed event that results from it being deleted. This is the wrong way around and makes the assertion fail. Move the deletion back up before we check the condition. delete_app is no longer an idle callback so it can be made void. The change notification might come in when the loop isn't running now, so don't try to quit if it isn't running. In this case we'll wait for the three second timeout and the test will still pass. https://bugzilla.gnome.org/show_bug.cgi?id=751737 --- diff --git a/gio/tests/appmonitor.c b/gio/tests/appmonitor.c index 96b9ac6..9ce6ff0 100644 --- a/gio/tests/appmonitor.c +++ b/gio/tests/appmonitor.c @@ -24,7 +24,7 @@ create_app (gpointer data) return G_SOURCE_REMOVE; } -static gboolean +static void delete_app (gpointer data) { const gchar *path = data; @@ -35,8 +35,6 @@ delete_app (gpointer data) g_remove (file); g_free (file); - - return G_SOURCE_REMOVE; } static gboolean changed_fired; @@ -53,7 +51,8 @@ quit_loop (gpointer data) { GMainLoop *loop = data; - g_main_loop_quit (loop); + if (g_main_loop_is_running (loop)) + g_main_loop_quit (loop); return G_SOURCE_REMOVE; } @@ -88,15 +87,16 @@ test_app_monitor (void) g_timeout_add_seconds (3, quit_loop, loop); + delete_app (path); + g_main_loop_run (loop); + g_assert (changed_fired); g_main_loop_unref (loop); g_object_unref (monitor); - delete_app (path); - g_free (path); }