5 #include <gio/gdesktopappinfo.h>
12 appinfo = (GAppInfo*)g_desktop_app_info_new_from_filename (SRCDIR "/appinfo-test.desktop");
13 g_assert (appinfo != NULL);
15 g_assert (g_app_info_launch (appinfo, NULL, NULL, NULL));
19 test_locale (const char *locale)
24 orig = setlocale (LC_ALL, NULL);
25 g_setenv ("LANGUAGE", locale, TRUE);
26 setlocale (LC_ALL, "");
28 appinfo = (GAppInfo*)g_desktop_app_info_new_from_filename (SRCDIR "/appinfo-test.desktop");
30 if (g_strcmp0 (locale, "C") == 0)
32 g_assert_cmpstr (g_app_info_get_name (appinfo), ==, "appinfo-test");
33 g_assert_cmpstr (g_app_info_get_description (appinfo), ==, "GAppInfo example");
34 g_assert_cmpstr (g_app_info_get_display_name (appinfo), ==, "example");
36 else if (g_str_has_prefix (locale, "en"))
38 g_assert_cmpstr (g_app_info_get_name (appinfo), ==, "appinfo-test");
39 g_assert_cmpstr (g_app_info_get_description (appinfo), ==, "GAppInfo example");
40 g_assert_cmpstr (g_app_info_get_display_name (appinfo), ==, "example");
42 else if (g_str_has_prefix (locale, "de"))
44 g_assert_cmpstr (g_app_info_get_name (appinfo), ==, "appinfo-test-de");
45 g_assert_cmpstr (g_app_info_get_description (appinfo), ==, "GAppInfo Beispiel");
46 g_assert_cmpstr (g_app_info_get_display_name (appinfo), ==, "Beispiel");
49 g_object_unref (appinfo);
51 g_setenv ("LANGUAGE", orig, TRUE);
52 setlocale (LC_ALL, "");
59 test_locale ("en_US");
61 test_locale ("de_DE.UTF-8");
70 appinfo = (GAppInfo*)g_desktop_app_info_new_from_filename (SRCDIR "/appinfo-test.desktop");
72 g_assert (g_app_info_get_id (appinfo) == NULL);
73 g_assert_cmpstr (g_app_info_get_executable (appinfo), ==, "./appinfo-test");
74 g_assert_cmpstr (g_app_info_get_commandline (appinfo), ==, "./appinfo-test --option");
76 icon = g_app_info_get_icon (appinfo);
77 g_assert (G_IS_THEMED_ICON (icon));
78 icon2 = g_themed_icon_new ("testicon");
79 g_assert (g_icon_equal (icon, icon2));
80 g_object_unref (icon2);
82 g_object_unref (appinfo);
90 g_desktop_app_info_set_desktop_env ("GNOME");
92 appinfo = (GAppInfo*)g_desktop_app_info_new_from_filename (SRCDIR "/appinfo-test.desktop");
93 g_assert (g_app_info_should_show (appinfo));
94 g_object_unref (appinfo);
96 appinfo = (GAppInfo*)g_desktop_app_info_new_from_filename (SRCDIR "/appinfo-test-gnome.desktop");
97 g_assert (g_app_info_should_show (appinfo));
98 g_object_unref (appinfo);
100 appinfo = (GAppInfo*)g_desktop_app_info_new_from_filename (SRCDIR "/appinfo-test-notgnome.desktop");
101 g_assert (!g_app_info_should_show (appinfo));
102 g_object_unref (appinfo);
106 test_commandline (void)
112 appinfo = g_app_info_create_from_commandline ("./appinfo-test --option",
114 G_APP_INFO_CREATE_SUPPORTS_URIS,
116 g_assert (appinfo != NULL);
117 g_assert_no_error (error);
118 g_assert_cmpstr (g_app_info_get_name (appinfo), ==, "cmdline-app-test");
119 g_assert_cmpstr (g_app_info_get_commandline (appinfo), ==, "./appinfo-test --option %u");
120 g_assert (g_app_info_supports_uris (appinfo));
121 g_assert (!g_app_info_supports_files (appinfo));
123 g_object_unref (appinfo);
126 appinfo = g_app_info_create_from_commandline ("./appinfo-test --option",
128 G_APP_INFO_CREATE_NONE,
130 g_assert (appinfo != NULL);
131 g_assert_no_error (error);
132 g_assert_cmpstr (g_app_info_get_name (appinfo), ==, "cmdline-app-test");
133 g_assert_cmpstr (g_app_info_get_commandline (appinfo), ==, "./appinfo-test --option %f");
134 g_assert (!g_app_info_supports_uris (appinfo));
135 g_assert (g_app_info_supports_files (appinfo));
137 g_object_unref (appinfo);
141 test_launch_context (void)
143 GAppLaunchContext *context;
147 context = g_app_launch_context_new ();
148 appinfo = g_app_info_create_from_commandline ("./appinfo-test --option",
150 G_APP_INFO_CREATE_SUPPORTS_URIS,
153 str = g_app_launch_context_get_display (context, appinfo, NULL);
154 g_assert (str == NULL);
156 str = g_app_launch_context_get_startup_notify_id (context, appinfo, NULL);
157 g_assert (str == NULL);
159 g_object_unref (appinfo);
160 g_object_unref (context);
164 main (int argc, char *argv[])
167 g_test_init (&argc, &argv, NULL);
170 g_test_add_func ("/appinfo/basic", test_basic);
171 g_test_add_func ("/appinfo/text", test_text);
172 g_test_add_func ("/appinfo/launch", test_launch);
173 g_test_add_func ("/appinfo/show-in", test_show_in);
174 g_test_add_func ("/appinfo/commandline", test_commandline);
175 g_test_add_func ("/appinfo/launch-context", test_launch_context);
176 return g_test_run ();