mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-02 07:23:41 +02:00
Merge branch 'w32-contenttype' into 'main'
Various contenttype-related test fixes on win32 See merge request GNOME/glib!2499
This commit is contained in:
@@ -30,7 +30,7 @@ test_guess (void)
|
||||
existing_directory = (gchar *) g_getenv ("SYSTEMROOT");
|
||||
|
||||
if (existing_directory)
|
||||
existing_directory = g_strdup_printf ("%s/", existing_directory);
|
||||
existing_directory = g_strdup_printf ("%s" G_DIR_SEPARATOR_S, existing_directory);
|
||||
#else
|
||||
existing_directory = g_strdup ("/etc/");
|
||||
#endif
|
||||
@@ -56,7 +56,8 @@ test_guess (void)
|
||||
g_free (res);
|
||||
g_free (expected);
|
||||
|
||||
/* Sadly OSX just doesn't have as large and robust of a mime type database as Linux */
|
||||
/* Sadly win32 & OSX just don't have as large and robust of a mime type database as Linux */
|
||||
#ifndef G_OS_WIN32
|
||||
#ifndef __APPLE__
|
||||
res = g_content_type_guess ("foo", data, sizeof (data) - 1, &uncertain);
|
||||
expected = g_content_type_from_mime_type ("text/plain");
|
||||
@@ -110,7 +111,7 @@ test_guess (void)
|
||||
g_assert_false (uncertain);
|
||||
g_free (res);
|
||||
g_free (expected);
|
||||
#endif
|
||||
#endif /* __APPLE__ */
|
||||
|
||||
res = g_content_type_guess (NULL, (guchar *)"%!PS-Adobe-2.0 EPSF-1.2", 23, &uncertain);
|
||||
expected = g_content_type_from_mime_type ("image/x-eps");
|
||||
@@ -126,6 +127,7 @@ test_guess (void)
|
||||
g_assert_false (uncertain);
|
||||
g_free (res);
|
||||
g_free (expected);
|
||||
#endif /* G_OS_WIN32 */
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -200,6 +202,13 @@ test_executable (void)
|
||||
{
|
||||
gchar *type;
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
type = g_content_type_from_mime_type ("application/vnd.microsoft.portable-executable");
|
||||
/* FIXME: the MIME is not in the default `MIME\Database\Content Type` registry.
|
||||
* g_assert_true (g_content_type_can_be_executable (type));
|
||||
*/
|
||||
g_free (type);
|
||||
#else
|
||||
type = g_content_type_from_mime_type ("application/x-executable");
|
||||
g_assert_true (g_content_type_can_be_executable (type));
|
||||
g_free (type);
|
||||
@@ -207,7 +216,7 @@ test_executable (void)
|
||||
type = g_content_type_from_mime_type ("text/plain");
|
||||
g_assert_true (g_content_type_can_be_executable (type));
|
||||
g_free (type);
|
||||
|
||||
#endif
|
||||
type = g_content_type_from_mime_type ("image/png");
|
||||
g_assert_false (g_content_type_can_be_executable (type));
|
||||
g_free (type);
|
||||
@@ -244,7 +253,9 @@ test_icon (void)
|
||||
#ifdef __APPLE__
|
||||
g_assert_true (g_strv_contains (names, "text-*"));
|
||||
#else
|
||||
#ifndef G_OS_WIN32
|
||||
g_assert_true (g_strv_contains (names, "text-plain"));
|
||||
#endif
|
||||
g_assert_true (g_strv_contains (names, "text-x-generic"));
|
||||
#endif
|
||||
}
|
||||
@@ -259,9 +270,13 @@ test_icon (void)
|
||||
const gchar *const *names;
|
||||
|
||||
names = g_themed_icon_get_names (G_THEMED_ICON (icon));
|
||||
#ifdef G_OS_WIN32
|
||||
g_assert_true (g_strv_contains (names, "text-x-generic"));
|
||||
#else
|
||||
g_assert_true (g_strv_contains (names, "application-rtf"));
|
||||
#ifndef __APPLE__
|
||||
g_assert_true (g_strv_contains (names, "x-office-document"));
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
g_object_unref (icon);
|
||||
@@ -329,8 +344,8 @@ test_tree (void)
|
||||
gchar **types;
|
||||
gsize i;
|
||||
|
||||
#ifdef __APPLE__
|
||||
g_test_skip ("The OSX backend does not implement g_content_type_guess_for_tree()");
|
||||
#if defined(__APPLE__) || defined(G_OS_WIN32)
|
||||
g_test_skip ("The OSX & Windows backends do not implement g_content_type_guess_for_tree()");
|
||||
return;
|
||||
#endif
|
||||
|
||||
@@ -355,7 +370,7 @@ test_type_is_a_special_case (void)
|
||||
/* Everything but the inode type is application/octet-stream */
|
||||
res = g_content_type_is_a ("inode/directory", "application/octet-stream");
|
||||
g_assert_false (res);
|
||||
#ifndef __APPLE__
|
||||
#if !defined(__APPLE__) && !defined(G_OS_WIN32)
|
||||
res = g_content_type_is_a ("anything", "application/octet-stream");
|
||||
g_assert_true (res);
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user