diff options
author | Matthias Clasen <mclasen@redhat.com> | 2021-07-26 15:53:12 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2021-07-26 15:55:34 -0400 |
commit | f9194042f4b629522cdcdfae674ece6f89837ee2 (patch) | |
tree | 158b2a1621af9a30cf42c31575c9a6c6a41ebbad | |
parent | 5c4aba4b9c9dab31aae9e35a0b7333c273c892b7 (diff) | |
download | gtk+-f9194042f4b629522cdcdfae674ece6f89837ee2.tar.gz |
Add tests for GdkContentFormatscontentformat-tests
This isn't super-extensive yet, but its a start.
-rw-r--r-- | testsuite/gdk/contentformats.c | 70 | ||||
-rw-r--r-- | testsuite/gdk/meson.build | 1 |
2 files changed, 71 insertions, 0 deletions
diff --git a/testsuite/gdk/contentformats.c b/testsuite/gdk/contentformats.c new file mode 100644 index 0000000000..0a1faf87fe --- /dev/null +++ b/testsuite/gdk/contentformats.c @@ -0,0 +1,70 @@ +#include <gdk/gdk.h> + +static void +test_contentformats_types (void) +{ + GdkContentFormats *formats; + const char *const *mimetypes; + gsize n_types; + const GType *gtypes; + + formats = gdk_content_formats_parse ("text/plain GdkFileList application/x-color GdkRGBA"); + + g_assert_nonnull (formats); + + mimetypes = gdk_content_formats_get_mime_types (formats, &n_types); + g_assert_true (n_types == 2); + g_assert_cmpstr (mimetypes[0], ==, "text/plain"); + g_assert_cmpstr (mimetypes[1], ==, "application/x-color"); + + gtypes = gdk_content_formats_get_gtypes (formats, &n_types); + g_assert_true (n_types == 2); + g_assert_true (gtypes[0] == GDK_TYPE_FILE_LIST); + g_assert_true (gtypes[1] == GDK_TYPE_RGBA); + + gdk_content_formats_unref (formats); +} + +static void +test_contentformats_union (void) +{ + GdkContentFormats *formats; + GdkContentFormats *formats2; + const char *const *mimetypes; + gsize n_types; + const GType *gtypes; + + formats = gdk_content_formats_parse ("text/plain application/x-color"); + formats2 = gdk_content_formats_parse ("GdkFileList GdkRGBA"); + + formats = gdk_content_formats_union (formats, formats2); + + g_assert_nonnull (formats); + + mimetypes = gdk_content_formats_get_mime_types (formats, &n_types); + g_assert_true (n_types == 2); + g_assert_cmpstr (mimetypes[0], ==, "text/plain"); + g_assert_cmpstr (mimetypes[1], ==, "application/x-color"); + + gtypes = gdk_content_formats_get_gtypes (formats, &n_types); + g_assert_true (n_types == 2); + g_assert_true (gtypes[0] == GDK_TYPE_FILE_LIST); + g_assert_true (gtypes[1] == GDK_TYPE_RGBA); + + gdk_content_formats_unref (formats2); + gdk_content_formats_unref (formats); +} + +int +main (int argc, char *argv[]) +{ + (g_test_init) (&argc, &argv, NULL); + + g_type_ensure (GDK_TYPE_RGBA); + g_type_ensure (GDK_TYPE_FILE_LIST); + + g_test_add_func ("/contentformats/types", test_contentformats_types); + g_test_add_func ("/contentformats/union", test_contentformats_union); + + return g_test_run (); +} diff --git a/testsuite/gdk/meson.build b/testsuite/gdk/meson.build index 50bfd0b5d0..5e62e98775 100644 --- a/testsuite/gdk/meson.build +++ b/testsuite/gdk/meson.build @@ -13,6 +13,7 @@ tests = [ 'array', 'cairo', 'clipboard', + 'contentformats', 'contentserializer', 'cursor', 'display', |