mimetype tests: don't depend on specific behaviour
[platform/upstream/glib.git] / gio / tests / desktop-app-info.c
1 /* 
2  * Copyright (C) 2008 Red Hat, Inc
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General
15  * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
16  * 
17  * Author: Matthias Clasen
18  */
19
20 #include <glib/glib.h>
21 #include <gio/gio.h>
22 #include <gio/gdesktopappinfo.h>
23 #include <stdlib.h>
24 #include <string.h>
25 #include <unistd.h>
26
27 static char *basedir;
28
29 static GAppInfo * 
30 create_app_info (const char *name)
31 {
32   GError *error;
33   GAppInfo *info;
34
35   error = NULL;
36   info = g_app_info_create_from_commandline ("true blah",
37                                              name,
38                                              G_APP_INFO_CREATE_NONE,
39                                              &error);
40   g_assert (error == NULL);
41
42   /* this is necessary to ensure that the info is saved */
43   g_app_info_set_as_default_for_type (info, "application/x-blah", &error);
44   g_assert (error == NULL);
45   g_app_info_remove_supports_type (info, "application/x-blah", &error);
46   g_assert (error == NULL);
47   g_app_info_reset_type_associations ("application/x-blah");
48   
49   return info;
50 }
51
52 static void
53 test_delete (void)
54 {
55   GAppInfo *info;
56
57   const char *id;
58   char *filename;
59   gboolean res;
60
61   info = create_app_info ("Blah");
62  
63   id = g_app_info_get_id (info);
64   g_assert (id != NULL);
65
66   filename = g_build_filename (basedir, "applications", id, NULL);
67
68   res = g_file_test (filename, G_FILE_TEST_EXISTS);
69   g_assert (res);
70
71   res = g_app_info_can_delete (info);
72   g_assert (res);
73
74   res = g_app_info_delete (info);
75   g_assert (res);
76
77   res = g_file_test (filename, G_FILE_TEST_EXISTS);
78   g_assert (!res);
79
80   g_object_unref (info);
81
82   if (g_file_test ("/usr/share/applications/gedit.desktop", G_FILE_TEST_EXISTS))
83     {
84       info = (GAppInfo*)g_desktop_app_info_new_from_filename ("/usr/share/applications/gedit.desktop");
85       g_assert (info);
86      
87       res = g_app_info_can_delete (info);
88       g_assert (!res);
89  
90       res = g_app_info_delete (info);
91       g_assert (!res);
92     }
93 }
94
95 static void
96 test_default (void)
97 {
98   GAppInfo *info, *info1, *info2, *info3;
99   GList *list;
100   GError *error = NULL;  
101
102   info1 = create_app_info ("Blah1");
103   info2 = create_app_info ("Blah2");
104   info3 = create_app_info ("Blah3");
105
106   g_app_info_set_as_default_for_type (info1, "application/x-test", &error);
107   g_assert (error == NULL);
108
109   g_app_info_set_as_default_for_type (info2, "application/x-test", &error);
110   g_assert (error == NULL);
111
112   info = g_app_info_get_default_for_type ("application/x-test", FALSE);
113   g_assert (info != NULL);
114   g_assert_cmpstr (g_app_info_get_id (info), ==, g_app_info_get_id (info2));
115
116   /* now try adding something, but not setting as default */
117   g_app_info_add_supports_type (info3, "application/x-test", &error);
118   g_assert (error == NULL);
119
120   /* check that info2 is still default */
121   info = g_app_info_get_default_for_type ("application/x-test", FALSE);
122   g_assert (info != NULL);
123   g_assert_cmpstr (g_app_info_get_id (info), ==, g_app_info_get_id (info2));
124
125   /* now remove info1 again */
126   g_app_info_remove_supports_type (info1, "application/x-test", &error);
127   g_assert (error == NULL);
128
129   /* and make sure info2 is still default */
130   info = g_app_info_get_default_for_type ("application/x-test", FALSE);
131   g_assert (info != NULL);
132   g_assert_cmpstr (g_app_info_get_id (info), ==, g_app_info_get_id (info2));
133
134   /* now clean it all up */
135   g_app_info_reset_type_associations ("application/x-test");
136
137   list = g_app_info_get_all_for_type ("application/x-test");
138   g_assert (list == NULL);
139
140   g_app_info_delete (info1);
141   g_app_info_delete (info2);
142   g_app_info_delete (info3);
143
144   g_object_unref (info1);
145   g_object_unref (info2);
146 }
147
148 static void
149 test_fallback (void)
150 {
151   GAppInfo *info1, *info2, *app;
152   GList *apps, *recomm, *fallback, *list, *l, *m;
153   GError *error = NULL;
154   gint old_length;
155
156   info1 = create_app_info ("Test1");
157   info2 = create_app_info ("Test2");
158
159   g_assert (g_content_type_is_a ("text/x-python", "text/plain"));
160
161   apps = g_app_info_get_all_for_type ("text/x-python");
162   old_length = g_list_length (apps);
163   g_list_free_full (apps, g_object_unref);
164
165   g_app_info_add_supports_type (info1, "text/x-python", &error);
166   g_assert (error == NULL);
167
168   g_app_info_add_supports_type (info2, "text/plain", &error);
169   g_assert (error == NULL);
170
171   /* check that both apps are registered */
172   apps = g_app_info_get_all_for_type ("text/x-python");
173   g_assert_cmpint (g_list_length (apps), ==, old_length + 2);
174
175   /* check the ordering */
176   app = g_list_nth_data (apps, 0);
177   g_assert (g_app_info_equal (info1, app));
178
179   /* check that Test1 is the first recommended app */
180   recomm = g_app_info_get_recommended_for_type ("text/x-python");
181   g_assert (recomm != NULL);
182   app = g_list_nth_data (recomm, 0);
183   g_assert (g_app_info_equal (info1, app));
184
185   /* and that Test2 is the first fallback */
186   fallback = g_app_info_get_fallback_for_type ("text/x-python");
187   g_assert (fallback != NULL);
188   app = g_list_nth_data (fallback, 0);
189   g_assert (g_app_info_equal (info2, app));
190
191   /* check that recomm + fallback = all applications */
192   list = g_list_concat (g_list_copy (recomm), g_list_copy (fallback));
193   g_assert (g_list_length (list) == g_list_length (apps));
194
195   for (l = list, m = apps; l != NULL && m != NULL; l = l->next, m = m->next)
196     {
197       g_assert (g_app_info_equal (l->data, m->data));
198     }
199
200   g_list_free (list);
201
202   g_list_free_full (apps, g_object_unref);
203   g_list_free_full (recomm, g_object_unref);
204   g_list_free_full (fallback, g_object_unref);
205
206   g_app_info_reset_type_associations ("text/x-python");
207   g_app_info_reset_type_associations ("text/plain");
208
209   g_app_info_delete (info1);
210   g_app_info_delete (info2);
211
212   g_object_unref (info1);
213   g_object_unref (info2);
214 }
215
216 static void
217 test_last_used (void)
218 {
219   GList *applications;
220   GAppInfo *info1, *info2, *default_app;
221   GError *error = NULL;
222
223   info1 = create_app_info ("Test1");
224   info2 = create_app_info ("Test2");
225
226   g_app_info_set_as_default_for_type (info1, "application/x-test", &error);
227   g_assert (error == NULL);
228
229   g_app_info_add_supports_type (info2, "application/x-test", &error);
230   g_assert (error == NULL);
231
232   applications = g_app_info_get_recommended_for_type ("application/x-test");
233   g_assert (g_list_length (applications) == 2);
234
235   /* the first should be the default app now */
236   g_assert (g_app_info_equal (g_list_nth_data (applications, 0), info1));
237   g_assert (g_app_info_equal (g_list_nth_data (applications, 1), info2));
238
239   g_list_free_full (applications, g_object_unref);
240
241   g_app_info_set_as_last_used_for_type (info2, "application/x-test", &error);
242   g_assert (error == NULL);
243
244   applications = g_app_info_get_recommended_for_type ("application/x-test");
245   g_assert (g_list_length (applications) == 2);
246
247   default_app = g_app_info_get_default_for_type ("application/x-test", FALSE);
248   g_assert (g_app_info_equal (default_app, info1));
249
250   /* the first should be the other app now */
251   g_assert (g_app_info_equal (g_list_nth_data (applications, 0), info2));
252   g_assert (g_app_info_equal (g_list_nth_data (applications, 1), info1));
253
254   g_list_free_full (applications, g_object_unref);
255
256   g_app_info_reset_type_associations ("application/x-test");
257
258   g_app_info_delete (info1);
259   g_app_info_delete (info2);
260
261   g_object_unref (info1);
262   g_object_unref (info2);
263   g_object_unref (default_app);
264 }
265
266 static void
267 cleanup_dir_recurse (GFile *parent, GFile *root)
268 {
269   gboolean res;
270   GError *error;
271   GFileEnumerator *enumerator;
272   GFileInfo *info;
273   GFile *descend;
274   char *relative_path;
275
276   g_assert (root != NULL);
277
278   error = NULL;
279   enumerator =
280     g_file_enumerate_children (parent, "*",
281                                G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, NULL,
282                                &error);
283   if (! enumerator)
284           return;
285   error = NULL;
286   info = g_file_enumerator_next_file (enumerator, NULL, &error);
287   while ((info) && (!error))
288     {
289       descend = g_file_get_child (parent, g_file_info_get_name (info));
290       g_assert (descend != NULL);
291       relative_path = g_file_get_relative_path (root, descend);
292       g_assert (relative_path != NULL);
293
294       if (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY)
295           cleanup_dir_recurse (descend, root);
296
297       error = NULL;
298       res = g_file_delete (descend, NULL, &error);
299       g_assert_cmpint (res, ==, TRUE);
300
301       g_object_unref (descend);
302       error = NULL;
303       info = g_file_enumerator_next_file (enumerator, NULL, &error);
304     }
305   g_assert (error == NULL);
306
307   error = NULL;
308   res = g_file_enumerator_close (enumerator, NULL, &error);
309   g_assert_cmpint (res, ==, TRUE);
310   g_assert (error == NULL);
311 }
312
313 static void
314 cleanup_subdirs (const char *base_dir)
315 {
316   GFile *base, *file;
317  
318   base = g_file_new_for_path (base_dir);  
319   file = g_file_get_child (base, "applications");
320   cleanup_dir_recurse (file, file);
321   g_object_unref (file);
322   file = g_file_get_child (base, "mime");
323   cleanup_dir_recurse (file, file);
324   g_object_unref (file);
325 }
326
327 static void
328 test_extra_getters (void)
329 {
330   GDesktopAppInfo *appinfo;
331   gchar *s;
332   gboolean b;
333
334   appinfo = g_desktop_app_info_new_from_filename (g_test_get_filename (G_TEST_DIST, "appinfo-test.desktop", NULL));
335   g_assert (appinfo != NULL);
336
337   g_assert (g_desktop_app_info_has_key (appinfo, "Terminal"));
338   g_assert (!g_desktop_app_info_has_key (appinfo, "Bratwurst"));
339
340   s = g_desktop_app_info_get_string (appinfo, "StartupWMClass");
341   g_assert_cmpstr (s, ==, "appinfo-class");
342   g_free (s);
343
344   b = g_desktop_app_info_get_boolean (appinfo, "Terminal");
345   g_assert (b);
346
347   g_object_unref (appinfo);
348 }
349
350 static void
351 wait_for_file (const gchar *want_this,
352                const gchar *but_not_this,
353                const gchar *or_this)
354 {
355   gint retries = 600;
356
357   /* I hate time-based conditions in tests, but this will wait up to one
358    * whole minute for "touch file" to finish running.  I think it should
359    * be OK.
360    *
361    * 600 * 100ms = 60 seconds.
362    */
363   while (access (want_this, F_OK) != 0)
364     {
365       g_usleep (100000); /* 100ms */
366       g_assert (retries);
367       retries--;
368     }
369
370   g_assert (access (but_not_this, F_OK) != 0);
371   g_assert (access (or_this, F_OK) != 0);
372
373   unlink (want_this);
374   unlink (but_not_this);
375   unlink (or_this);
376 }
377
378 static void
379 test_actions (void)
380 {
381   const gchar * const *actions;
382   GDesktopAppInfo *appinfo;
383   gchar *name;
384
385   appinfo = g_desktop_app_info_new_from_filename (g_test_get_filename (G_TEST_DIST, "appinfo-test-actions.desktop", NULL));
386   g_assert (appinfo != NULL);
387
388   actions = g_desktop_app_info_list_actions (appinfo);
389   g_assert_cmpstr (actions[0], ==, "frob");
390   g_assert_cmpstr (actions[1], ==, "tweak");
391   g_assert_cmpstr (actions[2], ==, "twiddle");
392   g_assert_cmpstr (actions[3], ==, "broken");
393   g_assert_cmpstr (actions[4], ==, NULL);
394
395   name = g_desktop_app_info_get_action_name (appinfo, "frob");
396   g_assert_cmpstr (name, ==, "Frobnicate");
397   g_free (name);
398
399   name = g_desktop_app_info_get_action_name (appinfo, "tweak");
400   g_assert_cmpstr (name, ==, "Tweak");
401   g_free (name);
402
403   name = g_desktop_app_info_get_action_name (appinfo, "twiddle");
404   g_assert_cmpstr (name, ==, "Twiddle");
405   g_free (name);
406
407   name = g_desktop_app_info_get_action_name (appinfo, "broken");
408   g_assert (name != NULL);
409   g_assert (g_utf8_validate (name, -1, NULL));
410   g_free (name);
411
412   unlink ("frob"); unlink ("tweak"); unlink ("twiddle");
413
414   g_desktop_app_info_launch_action (appinfo, "frob", NULL);
415   wait_for_file ("frob", "tweak", "twiddle");
416
417   g_desktop_app_info_launch_action (appinfo, "tweak", NULL);
418   wait_for_file ("tweak", "frob", "twiddle");
419
420   g_desktop_app_info_launch_action (appinfo, "twiddle", NULL);
421   wait_for_file ("twiddle", "frob", "tweak");
422
423   g_object_unref (appinfo);
424 }
425
426 static gchar *
427 run_apps (const gchar *command,
428           const gchar *arg,
429           gboolean     with_usr,
430           gboolean     with_home,
431           const gchar *locale_name,
432           const gchar *language)
433 {
434   gboolean success;
435   gchar **envp;
436   gchar **argv;
437   gint status;
438   gchar *out;
439
440   argv = g_new (gchar *, 4);
441   argv[0] = g_test_build_filename (G_TEST_BUILT, "apps", NULL);
442   argv[1] = g_strdup (command);
443   argv[2] = g_strdup (arg);
444   argv[3] = NULL;
445
446   envp = g_get_environ ();
447
448   if (with_usr)
449     {
450       gchar *tmp = g_test_build_filename (G_TEST_DIST, "desktop-files", "usr", NULL);
451       envp = g_environ_setenv (envp, "XDG_DATA_DIRS", tmp, TRUE);
452       g_free (tmp);
453     }
454   else
455     envp = g_environ_setenv (envp, "XDG_DATA_DIRS", "/does-not-exist", TRUE);
456
457   if (with_home)
458     {
459       gchar *tmp = g_test_build_filename (G_TEST_DIST, "desktop-files", "home", NULL);
460       envp = g_environ_setenv (envp, "XDG_DATA_HOME", tmp, TRUE);
461       g_free (tmp);
462     }
463   else
464     envp = g_environ_setenv (envp, "XDG_DATA_HOME", "/does-not-exist", TRUE);
465
466   if (locale_name)
467     envp = g_environ_setenv (envp, "LC_ALL", locale_name, TRUE);
468   else
469     envp = g_environ_setenv (envp, "LC_ALL", "C", TRUE);
470
471   if (language)
472     envp = g_environ_setenv (envp, "LANGUAGE", language, TRUE);
473   else
474     envp = g_environ_unsetenv (envp, "LANGUAGE");
475
476   success = g_spawn_sync (NULL, argv, envp, 0, NULL, NULL, &out, NULL, &status, NULL);
477   g_assert (success);
478   g_assert (status == 0);
479
480   g_strfreev (envp);
481   g_strfreev (argv);
482
483   return out;
484 }
485
486 static void
487 assert_strings_equivalent (const gchar *expected,
488                            const gchar *result)
489 {
490   gchar **expected_words;
491   gchar **result_words;
492   gint i, j;
493
494   expected_words = g_strsplit (expected, " ", 0);
495   result_words = g_strsplit (result, " ", 0);
496
497   for (i = 0; expected_words[i]; i++)
498     {
499       for (j = 0; result_words[j]; j++)
500         if (g_str_equal (expected_words[i], result_words[j]))
501           goto got_it;
502
503       g_test_message ("Unable to find expected string '%s' in result '%s'", expected_words[i], result);
504       g_test_fail ();
505
506 got_it:
507       continue;
508     }
509
510   g_assert_cmpint (g_strv_length (expected_words), ==, g_strv_length (result_words));
511   g_strfreev (expected_words);
512   g_strfreev (result_words);
513 }
514
515 static void
516 assert_list (const gchar *expected,
517              gboolean     with_usr,
518              gboolean     with_home,
519              const gchar *locale_name,
520              const gchar *language)
521 {
522   gchar *result;
523
524   result = run_apps ("list", NULL, with_usr, with_home, locale_name, language);
525   g_strchomp (result);
526   assert_strings_equivalent (expected, result);
527   g_free (result);
528 }
529
530 static void
531 assert_info (const gchar *desktop_id,
532              const gchar *expected,
533              gboolean     with_usr,
534              gboolean     with_home,
535              const gchar *locale_name,
536              const gchar *language)
537 {
538   gchar *result;
539
540   result = run_apps ("show-info", desktop_id, with_usr, with_home, locale_name, language);
541   g_assert_cmpstr (result, ==, expected);
542   g_free (result);
543 }
544
545 static void
546 assert_search (const gchar *search_string,
547                const gchar *expected,
548                gboolean     with_usr,
549                gboolean     with_home,
550                const gchar *locale_name,
551                const gchar *language)
552 {
553   gchar **expected_lines;
554   gchar **result_lines;
555   gchar *result;
556   gint i;
557
558   expected_lines = g_strsplit (expected, "\n", -1);
559   result = run_apps ("search", search_string, with_usr, with_home, locale_name, language);
560   result_lines = g_strsplit (result, "\n", -1);
561   g_assert_cmpint (g_strv_length (expected_lines), ==, g_strv_length (result_lines));
562   for (i = 0; expected_lines[i]; i++)
563     assert_strings_equivalent (expected_lines[i], result_lines[i]);
564   g_strfreev (expected_lines);
565   g_strfreev (result_lines);
566   g_free (result);
567 }
568
569 #define ALL_USR_APPS  "evince-previewer.desktop nautilus-classic.desktop gnome-font-viewer.desktop "         \
570                       "baobab.desktop yelp.desktop eog.desktop cheese.desktop gnome-clocks.desktop "         \
571                       "gnome-contacts.desktop kde4-kate.desktop gcr-prompter.desktop totem.desktop "         \
572                       "gnome-terminal.desktop nautilus-autorun-software.desktop gcr-viewer.desktop "         \
573                       "nautilus-connect-server.desktop kde4-dolphin.desktop gnome-music.desktop "            \
574                       "kde4-konqbrowser.desktop gucharmap.desktop kde4-okular.desktop nautilus.desktop "     \
575                       "gedit.desktop evince.desktop file-roller.desktop dconf-editor.desktop glade.desktop"
576 #define HOME_APPS     "epiphany-weather-for-toronto-island-9c6a4e022b17686306243dada811d550d25eb1fb.desktop"
577 #define ALL_HOME_APPS HOME_APPS " eog.desktop"
578
579 static void
580 test_search (void)
581 {
582   assert_list ("", FALSE, FALSE, NULL, NULL);
583   assert_list (ALL_USR_APPS, TRUE, FALSE, NULL, NULL);
584   assert_list (ALL_HOME_APPS, FALSE, TRUE, NULL, NULL);
585   assert_list (ALL_USR_APPS " " HOME_APPS, TRUE, TRUE, NULL, NULL);
586
587   /* The user has "installed" their own version of eog.desktop which
588    * calls it "Eye of GNOME".  Do some testing based on that.
589    *
590    * We should always find "Pictures" keyword no matter where we look.
591    */
592   assert_search ("Picture", "eog.desktop\n", TRUE, TRUE, NULL, NULL);
593   assert_search ("Picture", "eog.desktop\n", TRUE, FALSE, NULL, NULL);
594   assert_search ("Picture", "eog.desktop\n", FALSE, TRUE, NULL, NULL);
595   assert_search ("Picture", "", FALSE, FALSE, NULL, NULL);
596
597   /* We should only find it called "eye of gnome" when using the user's
598    * directory.
599    */
600   assert_search ("eye gnome", "", TRUE, FALSE, NULL, NULL);
601   assert_search ("eye gnome", "eog.desktop\n", FALSE, TRUE, NULL, NULL);
602   assert_search ("eye gnome", "eog.desktop\n", TRUE, TRUE, NULL, NULL);
603
604   /* We should only find it called "image viewer" when _not_ using the
605    * user's directory.
606    */
607   assert_search ("image viewer", "eog.desktop\n", TRUE, FALSE, NULL, NULL);
608   assert_search ("image viewer", "", FALSE, TRUE, NULL, NULL);
609   assert_search ("image viewer", "", TRUE, TRUE, NULL, NULL);
610
611   /* Obvious multi-word search */
612   assert_search ("gno hel", "yelp.desktop\n", TRUE, TRUE, NULL, NULL);
613
614   /* Repeated search terms should do nothing... */
615   assert_search ("files file fil fi f", "nautilus.desktop\n"
616                                         "gedit.desktop\n", TRUE, TRUE, NULL, NULL);
617
618   /* "con" will match "connect" and "contacts" on name but dconf only on
619    * the "config" keyword
620    */
621   assert_search ("con", "nautilus-connect-server.desktop gnome-contacts.desktop\n"
622                         "dconf-editor.desktop\n", TRUE, TRUE, NULL, NULL);
623
624   /* "gnome" will match "eye of gnome" from the user's directory, plus
625    * matching "GNOME Clocks" X-GNOME-FullName.  It's only a comment on
626    * yelp and gnome-contacts, though.
627    */
628   assert_search ("gnome", "eog.desktop\n"
629                           "gnome-clocks.desktop\n"
630                           "yelp.desktop gnome-contacts.desktop\n", TRUE, TRUE, NULL, NULL);
631
632   /* eog has exec name 'false' in usr only */
633   assert_search ("false", "eog.desktop\n", TRUE, FALSE, NULL, NULL);
634   assert_search ("false", "", FALSE, TRUE, NULL, NULL);
635   assert_search ("false", "", TRUE, TRUE, NULL, NULL);
636   assert_search ("false", "", FALSE, FALSE, NULL, NULL);
637
638   /* make sure we only search the first component */
639   assert_search ("nonsearchable", "", TRUE, FALSE, NULL, NULL);
640
641   /* "gnome con" will match only gnome contacts; via the name for
642    * "contacts" and the comment for "gnome"
643    */
644   assert_search ("gnome con", "gnome-contacts.desktop\n", TRUE, TRUE, NULL, NULL);
645
646   /* make sure we get the correct kde4- prefix on the application IDs
647    * from subdirectories
648    */
649   assert_search ("konq", "kde4-konqbrowser.desktop\n", TRUE, TRUE, NULL, NULL);
650   assert_search ("kate", "kde4-kate.desktop\n", TRUE, TRUE, NULL, NULL);
651
652   /* make sure we can lookup apps by name properly */
653   assert_info ("kde4-kate.desktop",
654                "kde4-kate.desktop\n"
655                "Kate\n"
656                "Kate\n"
657                "nil\n", TRUE, TRUE, NULL, NULL);
658
659   assert_info ("nautilus.desktop",
660                "nautilus.desktop\n"
661                "Files\n"
662                "Files\n"
663                "Access and organize files\n", TRUE, TRUE, NULL, NULL);
664
665   /* make sure localised searching works properly */
666   assert_search ("foliumi", "nautilus.desktop\n"
667                             "kde4-konqbrowser.desktop\n"
668                             "eog.desktop\n", TRUE, FALSE, "en_US.UTF-8", "eo");
669   /* the user's eog.desktop has no translations... */
670   assert_search ("foliumi", "nautilus.desktop\n"
671                             "kde4-konqbrowser.desktop\n", TRUE, TRUE, "en_US.UTF-8", "eo");
672 }
673
674 int
675 main (int   argc,
676       char *argv[])
677 {
678   gint result;
679
680   g_test_init (&argc, &argv, NULL);
681
682   basedir = g_get_current_dir ();
683   g_setenv ("XDG_DATA_HOME", basedir, TRUE);
684   cleanup_subdirs (basedir);
685
686   g_test_add_func ("/desktop-app-info/delete", test_delete);
687   g_test_add_func ("/desktop-app-info/default", test_default);
688   g_test_add_func ("/desktop-app-info/fallback", test_fallback);
689   g_test_add_func ("/desktop-app-info/lastused", test_last_used);
690   g_test_add_func ("/desktop-app-info/extra-getters", test_extra_getters);
691   g_test_add_func ("/desktop-app-info/actions", test_actions);
692   g_test_add_func ("/desktop-app-info/search", test_search);
693
694   result = g_test_run ();
695
696   cleanup_subdirs (basedir);
697
698   return result;
699 }