5 #include <gio/gdesktopappinfo.h>
13 appinfo = (GAppInfo*)g_desktop_app_info_new_from_filename (SRCDIR "/appinfo-test.desktop");
14 g_assert (appinfo != NULL);
17 g_assert (g_app_info_launch (appinfo, NULL, NULL, &error));
18 g_assert_no_error (error);
20 g_assert (g_app_info_launch_uris (appinfo, NULL, NULL, &error));
21 g_assert_no_error (error);
25 test_locale (const char *locale)
30 orig = setlocale (LC_ALL, NULL);
31 g_setenv ("LANGUAGE", locale, TRUE);
32 setlocale (LC_ALL, "");
34 appinfo = (GAppInfo*)g_desktop_app_info_new_from_filename (SRCDIR "/appinfo-test.desktop");
36 if (g_strcmp0 (locale, "C") == 0)
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, "en"))
44 g_assert_cmpstr (g_app_info_get_name (appinfo), ==, "appinfo-test");
45 g_assert_cmpstr (g_app_info_get_description (appinfo), ==, "GAppInfo example");
46 g_assert_cmpstr (g_app_info_get_display_name (appinfo), ==, "example");
48 else if (g_str_has_prefix (locale, "de"))
50 g_assert_cmpstr (g_app_info_get_name (appinfo), ==, "appinfo-test-de");
51 g_assert_cmpstr (g_app_info_get_description (appinfo), ==, "GAppInfo Beispiel");
52 g_assert_cmpstr (g_app_info_get_display_name (appinfo), ==, "Beispiel");
55 g_object_unref (appinfo);
57 g_setenv ("LANGUAGE", orig, TRUE);
58 setlocale (LC_ALL, "");
65 test_locale ("en_US");
67 test_locale ("de_DE.UTF-8");
77 appinfo = (GAppInfo*)g_desktop_app_info_new_from_filename (SRCDIR "/appinfo-test.desktop");
79 g_assert (g_app_info_get_id (appinfo) == NULL);
80 g_assert_cmpstr (g_app_info_get_executable (appinfo), ==, "./appinfo-test");
81 g_assert_cmpstr (g_app_info_get_commandline (appinfo), ==, "./appinfo-test --option");
83 icon = g_app_info_get_icon (appinfo);
84 g_assert (G_IS_THEMED_ICON (icon));
85 icon2 = g_themed_icon_new ("testicon");
86 g_assert (g_icon_equal (icon, icon2));
87 g_object_unref (icon2);
89 appinfo2 = g_app_info_dup (appinfo);
90 g_assert (g_app_info_get_id (appinfo) == g_app_info_get_id (appinfo2));
91 g_assert_cmpstr (g_app_info_get_commandline (appinfo), ==, g_app_info_get_commandline (appinfo2));
93 g_object_unref (appinfo);
94 g_object_unref (appinfo2);
102 g_desktop_app_info_set_desktop_env ("GNOME");
104 appinfo = (GAppInfo*)g_desktop_app_info_new_from_filename (SRCDIR "/appinfo-test.desktop");
105 g_assert (g_app_info_should_show (appinfo));
106 g_object_unref (appinfo);
108 appinfo = (GAppInfo*)g_desktop_app_info_new_from_filename (SRCDIR "/appinfo-test-gnome.desktop");
109 g_assert (g_app_info_should_show (appinfo));
110 g_object_unref (appinfo);
112 appinfo = (GAppInfo*)g_desktop_app_info_new_from_filename (SRCDIR "/appinfo-test-notgnome.desktop");
113 g_assert (!g_app_info_should_show (appinfo));
114 g_object_unref (appinfo);
118 test_commandline (void)
124 appinfo = g_app_info_create_from_commandline ("./appinfo-test --option",
126 G_APP_INFO_CREATE_SUPPORTS_URIS,
128 g_assert (appinfo != NULL);
129 g_assert_no_error (error);
130 g_assert_cmpstr (g_app_info_get_name (appinfo), ==, "cmdline-app-test");
131 g_assert_cmpstr (g_app_info_get_commandline (appinfo), ==, "./appinfo-test --option %u");
132 g_assert (g_app_info_supports_uris (appinfo));
133 g_assert (!g_app_info_supports_files (appinfo));
135 g_object_unref (appinfo);
138 appinfo = g_app_info_create_from_commandline ("./appinfo-test --option",
140 G_APP_INFO_CREATE_NONE,
142 g_assert (appinfo != NULL);
143 g_assert_no_error (error);
144 g_assert_cmpstr (g_app_info_get_name (appinfo), ==, "cmdline-app-test");
145 g_assert_cmpstr (g_app_info_get_commandline (appinfo), ==, "./appinfo-test --option %f");
146 g_assert (!g_app_info_supports_uris (appinfo));
147 g_assert (g_app_info_supports_files (appinfo));
149 g_object_unref (appinfo);
153 test_launch_context (void)
155 GAppLaunchContext *context;
159 context = g_app_launch_context_new ();
160 appinfo = g_app_info_create_from_commandline ("./appinfo-test --option",
162 G_APP_INFO_CREATE_SUPPORTS_URIS,
165 str = g_app_launch_context_get_display (context, appinfo, NULL);
166 g_assert (str == NULL);
168 str = g_app_launch_context_get_startup_notify_id (context, appinfo, NULL);
169 g_assert (str == NULL);
171 g_object_unref (appinfo);
172 g_object_unref (context);
180 appinfo = (GAppInfo*)g_desktop_app_info_new_from_filename (SRCDIR "/appinfo-test2.desktop");
182 g_assert (appinfo == NULL);
186 main (int argc, char *argv[])
189 g_test_init (&argc, &argv, NULL);
191 g_test_add_func ("/appinfo/basic", test_basic);
192 g_test_add_func ("/appinfo/text", test_text);
193 g_test_add_func ("/appinfo/launch", test_launch);
194 g_test_add_func ("/appinfo/show-in", test_show_in);
195 g_test_add_func ("/appinfo/commandline", test_commandline);
196 g_test_add_func ("/appinfo/launch-context", test_launch_context);
197 g_test_add_func ("/appinfo/tryexec", test_tryexec);
199 return g_test_run ();