mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-12 23:46:17 +01:00
tests: always remove app.desktop
https://bugzilla.gnome.org/show_bug.cgi?id=749606
This commit is contained in:
parent
d09c219696
commit
f45ec47be1
@ -5,7 +5,6 @@ static gboolean
|
|||||||
create_app (gpointer data)
|
create_app (gpointer data)
|
||||||
{
|
{
|
||||||
const gchar *path = data;
|
const gchar *path = data;
|
||||||
gchar *file;
|
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
const gchar *contents =
|
const gchar *contents =
|
||||||
"[Desktop Entry]\n"
|
"[Desktop Entry]\n"
|
||||||
@ -14,13 +13,9 @@ create_app (gpointer data)
|
|||||||
"Type=Application\n"
|
"Type=Application\n"
|
||||||
"Exec=true\n";
|
"Exec=true\n";
|
||||||
|
|
||||||
file = g_build_filename (path, "app.desktop", NULL);
|
g_file_set_contents (path, contents, -1, &error);
|
||||||
|
|
||||||
g_file_set_contents (file, contents, -1, &error);
|
|
||||||
g_assert_no_error (error);
|
g_assert_no_error (error);
|
||||||
|
|
||||||
g_free (file);
|
|
||||||
|
|
||||||
return G_SOURCE_REMOVE;
|
return G_SOURCE_REMOVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,13 +23,8 @@ static void
|
|||||||
delete_app (gpointer data)
|
delete_app (gpointer data)
|
||||||
{
|
{
|
||||||
const gchar *path = data;
|
const gchar *path = data;
|
||||||
gchar *file;
|
|
||||||
|
|
||||||
file = g_build_filename (path, "app.desktop", NULL);
|
g_remove (path);
|
||||||
|
|
||||||
g_remove (file);
|
|
||||||
|
|
||||||
g_free (file);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean changed_fired;
|
static gboolean changed_fired;
|
||||||
@ -60,13 +50,15 @@ quit_loop (gpointer data)
|
|||||||
static void
|
static void
|
||||||
test_app_monitor (void)
|
test_app_monitor (void)
|
||||||
{
|
{
|
||||||
gchar *path;
|
gchar *path, *app_path;
|
||||||
GAppInfoMonitor *monitor;
|
GAppInfoMonitor *monitor;
|
||||||
GMainLoop *loop;
|
GMainLoop *loop;
|
||||||
|
|
||||||
path = g_build_filename (g_get_user_data_dir (), "applications", NULL);
|
path = g_build_filename (g_get_user_data_dir (), "applications", NULL);
|
||||||
g_mkdir (path, 0755);
|
g_mkdir (path, 0755);
|
||||||
|
|
||||||
|
app_path = g_build_filename (path, "app.desktop", NULL);
|
||||||
|
|
||||||
/* FIXME: this shouldn't be required */
|
/* FIXME: this shouldn't be required */
|
||||||
g_list_free_full (g_app_info_get_all (), g_object_unref);
|
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_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_timeout_add_seconds (3, quit_loop, loop);
|
||||||
|
|
||||||
g_main_loop_run (loop);
|
g_main_loop_run (loop);
|
||||||
@ -94,10 +86,12 @@ test_app_monitor (void)
|
|||||||
g_assert (changed_fired);
|
g_assert (changed_fired);
|
||||||
|
|
||||||
g_main_loop_unref (loop);
|
g_main_loop_unref (loop);
|
||||||
|
g_remove (app_path);
|
||||||
|
|
||||||
g_object_unref (monitor);
|
g_object_unref (monitor);
|
||||||
|
|
||||||
g_free (path);
|
g_free (path);
|
||||||
|
g_free (app_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
Loading…
Reference in New Issue
Block a user