14 "Exec=./appinfo-test --option\n";
16 res = g_content_type_guess ("/etc/", NULL, 0, &uncertain);
17 expected = g_content_type_from_mime_type ("inode/directory");
18 g_assert (g_content_type_equals (expected, res));
23 res = g_content_type_guess ("foo.txt", NULL, 0, &uncertain);
24 expected = g_content_type_from_mime_type ("text/plain");
25 g_assert (g_content_type_equals (expected, res));
26 g_assert (!uncertain);
30 res = g_content_type_guess ("foo.desktop", data, sizeof (data) - 1, &uncertain);
31 expected = g_content_type_from_mime_type ("application/x-desktop");
32 g_assert (g_content_type_equals (expected, res));
33 g_assert (!uncertain);
37 res = g_content_type_guess ("foo.txt", data, sizeof (data) - 1, &uncertain);
38 expected = g_content_type_from_mime_type ("text/plain");
39 g_assert (g_content_type_equals (expected, res));
40 g_assert (!uncertain);
44 res = g_content_type_guess ("foo", data, sizeof (data) - 1, &uncertain);
45 expected = g_content_type_from_mime_type ("text/plain");
46 g_assert (g_content_type_equals (expected, res));
47 g_assert (!uncertain);
51 res = g_content_type_guess (NULL, data, sizeof (data) - 1, &uncertain);
52 expected = g_content_type_from_mime_type ("application/x-desktop");
53 g_assert (g_content_type_equals (expected, res));
54 g_assert (!uncertain);
58 res = g_content_type_guess ("test.pot", (guchar *)"ABC abc", 7, &uncertain);
59 expected = g_content_type_from_mime_type ("application/vnd.ms-powerpoint");
60 g_assert (g_content_type_equals (expected, res));
65 res = g_content_type_guess ("test.otf", (guchar *)"OTTO", 4, &uncertain);
66 expected = g_content_type_from_mime_type ("application/x-font-otf");
67 g_assert (g_content_type_equals (expected, res));
68 g_assert (!uncertain);
79 unknown = g_content_type_from_mime_type ("application/octet-stream");
80 g_assert (g_content_type_is_unknown (unknown));
81 str = g_content_type_get_mime_type (unknown);
82 g_assert_cmpstr (str, ==, "application/octet-stream");
93 plain = g_content_type_from_mime_type ("text/plain");
94 xml = g_content_type_from_mime_type ("application/xml");
96 g_assert (g_content_type_is_a (xml, plain));
103 find_mime (gconstpointer a, gconstpointer b)
105 if (g_content_type_equals (a, b))
117 plain = g_content_type_from_mime_type ("text/plain");
118 xml = g_content_type_from_mime_type ("application/xml");
120 types = g_content_types_get_registered ();
122 g_assert (g_list_length (types) > 1);
124 /* just check that some types are in the list */
125 g_assert (g_list_find_custom (types, plain, find_mime) != NULL);
126 g_assert (g_list_find_custom (types, xml, find_mime) != NULL);
128 g_list_free_full (types, g_free);
135 test_executable (void)
139 type = g_content_type_from_mime_type ("application/x-executable");
140 g_assert (g_content_type_can_be_executable (type));
143 type = g_content_type_from_mime_type ("text/plain");
144 g_assert (g_content_type_can_be_executable (type));
147 type = g_content_type_from_mime_type ("image/png");
148 g_assert (!g_content_type_can_be_executable (type));
153 test_description (void)
158 type = g_content_type_from_mime_type ("text/plain");
159 desc = g_content_type_get_description (type);
160 g_assert (desc != NULL);
172 type = g_content_type_from_mime_type ("text/plain");
173 icon = g_content_type_get_icon (type);
174 g_assert (G_IS_ICON (icon));
175 g_object_unref (icon);
178 type = g_content_type_from_mime_type ("application/rtf");
179 icon = g_content_type_get_icon (type);
180 g_assert (G_IS_ICON (icon));
181 g_object_unref (icon);
187 main (int argc, char *argv[])
191 g_test_init (&argc, &argv, NULL);
193 g_test_add_func ("/contenttype/guess", test_guess);
194 g_test_add_func ("/contenttype/unknown", test_unknown);
195 g_test_add_func ("/contenttype/subtype", test_subtype);
196 g_test_add_func ("/contenttype/list", test_list);
197 g_test_add_func ("/contenttype/executable", test_executable);
198 g_test_add_func ("/contenttype/description", test_description);
199 g_test_add_func ("/contenttype/icon", test_icon);
201 return g_test_run ();