gio/tests/appmonitor: Delete file before checking for changed event
authorIain Lane <iain@orangesquash.org.uk>
Tue, 30 Jun 2015 16:13:49 +0000 (17:13 +0100)
committerLars Uebernickel <lars.uebernickel@canonical.com>
Wed, 1 Jul 2015 10:11:23 +0000 (12:11 +0200)
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

gio/tests/appmonitor.c

index 96b9ac6..9ce6ff0 100644 (file)
@@ -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);
 }