mirror of
				https://gitlab.gnome.org/GNOME/glib.git
				synced 2025-11-04 10:08:56 +01:00 
			
		
		
		
	tests: always remove app.desktop
https://bugzilla.gnome.org/show_bug.cgi?id=749606
This commit is contained in:
		
				
					committed by
					
						
						Cosimo Cecchi
					
				
			
			
				
	
			
			
			
						parent
						
							d09c219696
						
					
				
				
					commit
					f45ec47be1
				
			@@ -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
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user