[glib] Add tests for x-content type sniffing
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Add tests for x-content type sniffing
- Date: Wed, 1 Jan 2014 23:00:46 +0000 (UTC)
commit 6c75ba2b902602c90fe239346e557aa1284eb667
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Dec 23 12:11:03 2013 -0500
Add tests for x-content type sniffing
This test exercises the tree matching parts of gcontenttype.c
gio/tests/Makefile.am | 4 ++
gio/tests/contenttype.c | 31 ++++++++++++++++++++
gio/tests/x-content/unix-software/autorun.sh | 3 ++
3 files changed, 38 insertions(+), 0 deletions(-)
---
diff --git a/gio/tests/Makefile.am b/gio/tests/Makefile.am
index b3e51ef..d3a2162 100644
--- a/gio/tests/Makefile.am
+++ b/gio/tests/Makefile.am
@@ -299,6 +299,10 @@ dist_test_data += \
appinfo-test2.desktop \
file.c \
org.gtk.test.dbusappinfo.desktop \
+ x-content/image-dcf/DCIM/Camera/20130831_203925.jpg \
+ x-content/image-dcf/DCIM/Camera/20130831_203928.jpg \
+ x-content/unix-software/autorun.sh \
+ x-content/win32-software/autorun.exe \
$(NULL)
test_extra_programs += \
diff --git a/gio/tests/contenttype.c b/gio/tests/contenttype.c
index 645bddc..aa8ff82 100644
--- a/gio/tests/contenttype.c
+++ b/gio/tests/contenttype.c
@@ -97,6 +97,13 @@ test_guess (void)
g_assert (!uncertain);
g_free (res);
g_free (expected);
+
+ 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");
+ g_assert_content_type_equals (expected, res);
+ g_assert (!uncertain);
+ g_free (res);
+ g_free (expected);
}
static void
@@ -211,6 +218,29 @@ test_icon (void)
g_free (type);
}
+static void
+test_tree (void)
+{
+ const gchar *tests[] = {
+ "x-content/image-dcf",
+ "x-content/unix-software",
+ "x-content/win32-software"
+ };
+ const gchar *path;
+ GFile *file;
+ gchar **types;
+ gint i;
+
+ for (i = 0; i < G_N_ELEMENTS (tests); i++)
+ {
+ path = g_test_get_filename (G_TEST_DIST, tests[i], NULL);
+ file = g_file_new_for_path (path);
+ types = g_content_type_guess_for_tree (file);
+ g_assert_content_type_equals (types[0], tests[i]);
+ g_strfreev (types);
+ g_object_unref (file);
+ }
+}
int
main (int argc, char *argv[])
@@ -224,6 +254,7 @@ main (int argc, char *argv[])
g_test_add_func ("/contenttype/executable", test_executable);
g_test_add_func ("/contenttype/description", test_description);
g_test_add_func ("/contenttype/icon", test_icon);
+ g_test_add_func ("/contenttype/tree", test_tree);
return g_test_run ();
}
diff --git a/gio/tests/x-content/image-dcf/DCIM/Camera/20130831_203925.jpg
b/gio/tests/x-content/image-dcf/DCIM/Camera/20130831_203925.jpg
new file mode 100644
index 0000000..e69de29
diff --git a/gio/tests/x-content/image-dcf/DCIM/Camera/20130831_203928.jpg
b/gio/tests/x-content/image-dcf/DCIM/Camera/20130831_203928.jpg
new file mode 100644
index 0000000..e69de29
diff --git a/gio/tests/x-content/unix-software/autorun.sh b/gio/tests/x-content/unix-software/autorun.sh
new file mode 100644
index 0000000..6dfc559
--- /dev/null
+++ b/gio/tests/x-content/unix-software/autorun.sh
@@ -0,0 +1,3 @@
+#! /bin/sh
+
+do something here
diff --git a/gio/tests/x-content/win32-software/autorun.exe b/gio/tests/x-content/win32-software/autorun.exe
new file mode 100755
index 0000000..e69de29
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]