[gtk/image-loading: 11/18] Add tests for the tiff loader




commit d6150d2eb5ee7968d1dcb71faa724a0f9e353f07
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Sep 12 01:07:16 2021 -0400

    Add tests for the tiff loader

 testsuite/gdk/clipboard-data/image.tiff | Bin 0 -> 205344 bytes
 testsuite/gdk/image.c                   |  27 +++++++++++++++++++++++++++
 2 files changed, 27 insertions(+)
---
diff --git a/testsuite/gdk/clipboard-data/image.tiff b/testsuite/gdk/clipboard-data/image.tiff
new file mode 100644
index 0000000000..ddd0d03609
Binary files /dev/null and b/testsuite/gdk/clipboard-data/image.tiff differ
diff --git a/testsuite/gdk/image.c b/testsuite/gdk/image.c
index af92c72746..55e09bc040 100644
--- a/testsuite/gdk/image.c
+++ b/testsuite/gdk/image.c
@@ -1,5 +1,6 @@
 #include <gtk/gtk.h>
 #include "gdk/gdkpng.h"
+#include "gdk/gdktiff.h"
 
 static void
 test_load_image (gconstpointer data)
@@ -18,6 +19,8 @@ test_load_image (gconstpointer data)
 
   if (g_str_has_suffix (filename, ".png"))
     texture = gdk_load_png (stream, &error);
+  else if (g_str_has_suffix (filename, ".tiff"))
+    texture = gdk_load_tiff (stream, &error);
   else
     g_assert_not_reached ();
 
@@ -48,6 +51,8 @@ load_image_done (GObject      *source,
 
   if (g_str_has_suffix (ldata->filename, ".png"))
     ldata->texture = gdk_load_png_finish (result, &ldata->error);
+  else if (g_str_has_suffix (ldata->filename, ".tiff"))
+    ldata->texture = gdk_load_tiff_finish (result, &ldata->error);
   else
     g_assert_not_reached ();
   ldata->done = TRUE;
@@ -72,6 +77,8 @@ test_load_image_async (gconstpointer data)
 
   if (g_str_has_suffix (filename, ".png"))
     gdk_load_png_async (stream, NULL, load_image_done, &ldata);
+  else if (g_str_has_suffix (filename, ".tiff"))
+    gdk_load_tiff_async (stream, NULL, load_image_done, &ldata);
   else
     g_assert_not_reached ();
   while (!ldata.done)
@@ -123,6 +130,12 @@ test_save_image (gconstpointer test_data)
                         width, height, width * 4,
                         GDK_MEMORY_DEFAULT,
                         &error);
+  else if (g_str_has_suffix (filename, ".tiff"))
+    ret = gdk_save_tiff (g_io_stream_get_output_stream (stream),
+                         data,
+                         width, height, width * 4,
+                         GDK_MEMORY_DEFAULT,
+                         &error);
   else
     g_assert_not_reached ();
 
@@ -176,6 +189,8 @@ save_image_done (GObject      *source,
 
   if (g_str_has_suffix (sdata->filename, ".png"))
     sdata->ret = gdk_save_png_finish (result, &sdata->error);
+  else if (g_str_has_suffix (sdata->filename, ".tiff"))
+    sdata->ret = gdk_save_tiff_finish (result, &sdata->error);
   else
     g_assert_not_reached ();
   sdata->done = TRUE;
@@ -219,6 +234,14 @@ test_save_image_async (gconstpointer test_data)
                         NULL,
                         save_image_done,
                         &sdata);
+  else if (g_str_has_suffix (filename, ".tiff"))
+    gdk_save_tiff_async (g_io_stream_get_output_stream (stream),
+                         data,
+                         width, height, width * 4,
+                         GDK_MEMORY_DEFAULT,
+                         NULL,
+                         save_image_done,
+                         &sdata);
   else
     g_assert_not_reached ();
 
@@ -258,9 +281,13 @@ main (int argc, char *argv[])
   (g_test_init) (&argc, &argv, NULL);
 
   g_test_add_data_func ("/image/load/png/sync", "image.png", test_load_image);
+  g_test_add_data_func ("/image/load/tiff/sync", "image.tiff", test_load_image);
   g_test_add_data_func ("/image/load/png/async", "image.png", test_load_image_async);
+  g_test_add_data_func ("/image/load/tiff/async", "image.tiff", test_load_image_async);
   g_test_add_data_func ("/image/save/png/sync", "image.png", test_save_image);
+  g_test_add_data_func ("/image/save/tiff/sync", "image.tiff", test_save_image);
   g_test_add_data_func ("/image/save/png/async", "image.png", test_save_image_async);
+  g_test_add_data_func ("/image/save/tiff/async", "image.tiff", test_save_image_async);
 
   return g_test_run ();
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]