[glib] tests: always remove app.desktop



commit f45ec47be1244fd16be339dd5be37af3506e05ca
Author: Cosimo Cecchi <cosimo endlessm com>
Date:   Tue May 12 19:43:32 2015 -0700

    tests: always remove app.desktop
    
    https://bugzilla.gnome.org/show_bug.cgi?id=749606

 gio/tests/appmonitor.c |   22 ++++++++--------------
 1 files changed, 8 insertions(+), 14 deletions(-)
---
diff --git a/gio/tests/appmonitor.c b/gio/tests/appmonitor.c
index 9ce6ff0..e0068e1 100644
--- a/gio/tests/appmonitor.c
+++ b/gio/tests/appmonitor.c
@@ -5,7 +5,6 @@ static gboolean
 create_app (gpointer data)
 {
   const gchar *path = data;
-  gchar *file;
   GError *error = NULL;
   const gchar *contents = 
     "[Desktop Entry]\n"
@@ -14,13 +13,9 @@ create_app (gpointer data)
     "Type=Application\n"
     "Exec=true\n";
 
-  file = g_build_filename (path, "app.desktop", NULL);
-
-  g_file_set_contents (file, contents, -1, &error);
+  g_file_set_contents (path, contents, -1, &error);
   g_assert_no_error (error);
 
-  g_free (file);
-
   return G_SOURCE_REMOVE;
 }
 
@@ -28,13 +23,8 @@ static void
 delete_app (gpointer data)
 {
   const gchar *path = data;
-  gchar *file;
-
-  file = g_build_filename (path, "app.desktop", NULL);
 
-  g_remove (file);
-
-  g_free (file);
+  g_remove (path);
 }
 
 static gboolean changed_fired;
@@ -60,13 +50,15 @@ quit_loop (gpointer data)
 static void
 test_app_monitor (void)
 {
-  gchar *path;
+  gchar *path, *app_path;
   GAppInfoMonitor *monitor;
   GMainLoop *loop;
 
   path = g_build_filename (g_get_user_data_dir (), "applications", NULL);
   g_mkdir (path, 0755);
 
+  app_path = g_build_filename (path, "app.desktop", NULL);
+
   /* FIXME: this shouldn't be required */
   g_list_free_full (g_app_info_get_all (), g_object_unref);
 
@@ -75,7 +67,7 @@ test_app_monitor (void)
 
   g_signal_connect (monitor, "changed", G_CALLBACK (changed_cb), loop);
 
-  g_idle_add (create_app, path);
+  g_idle_add (create_app, app_path);
   g_timeout_add_seconds (3, quit_loop, loop);
 
   g_main_loop_run (loop);
@@ -94,10 +86,12 @@ test_app_monitor (void)
   g_assert (changed_fired);
 
   g_main_loop_unref (loop);
+  g_remove (app_path);
 
   g_object_unref (monitor);
 
   g_free (path);
+  g_free (app_path);
 }
 
 int


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