evas tests - add Jpeg2000 tests
authorVincent Torri <vincent.torri@gmail.com>
Fri, 11 Aug 2017 08:51:29 +0000 (17:51 +0900)
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>
Fri, 11 Aug 2017 08:53:28 +0000 (17:53 +0900)
add tests for loading jp2k files correctly and the images

src/Makefile_Evas.am
src/tests/evas/evas_test_image.c
src/tests/evas/images/flower.jp2 [new file with mode: 0644]
src/tests/evas/images/flower.jp2.png [new file with mode: 0644]
src/tests/evas/images/train.j2k [new file with mode: 0644]
src/tests/evas/images/train.j2k.png [new file with mode: 0644]

index 72aeb4b..18d609a 100644 (file)
@@ -2448,7 +2448,11 @@ tests/evas/images/Pic4.xpm \
 tests/evas/meshes/md2/sonic.md2 \
 tests/evas/meshes/obj/man_mesh.obj \
 tests/evas/images/gray.jpg \
-tests/evas/images/bg_gray.png
+tests/evas/images/bg_gray.png \
+tests/evas/images/flower.jp2k \
+tests/evas/images/flower.jp2k.png \
+tests/evas/images/train.jp2k \
+tests/evas/images/train.jp2k.png
 
 if HAVE_ELUA
 
index c34a52d..5cbfa01 100644 (file)
@@ -44,6 +44,10 @@ static const char *exts[] = {
 #ifdef BUILD_LOADER_TGV
   ,"tgv"
 #endif
+#ifdef BUILD_LOADER_JP2K
+  ,"jp2"
+  ,"j2k"
+#endif
 };
 
 START_TEST(evas_object_image_loader)
@@ -331,6 +335,7 @@ START_TEST(evas_object_image_orient)
 }
 END_TEST
 
+#ifdef BUILD_LOADER_TGV
 START_TEST(evas_object_image_tgv_loader_data)
 {
    Evas *e = _setup_evas();
@@ -387,6 +392,7 @@ START_TEST(evas_object_image_tgv_loader_data)
    evas_shutdown();
 }
 END_TEST
+#endif
 
 START_TEST(evas_object_image_all_loader_data)
 {
@@ -812,16 +818,72 @@ START_TEST(evas_object_image_map_unmap)
 }
 END_TEST
 
+#if BUILD_LOADER_JP2K
+START_TEST(evas_object_image_jp2k_loader_data)
+{
+   Evas *e = _setup_evas();
+   Evas_Object *obj, *ref;
+   Eina_Strbuf *str;
+
+   const char *files[] = {
+     "train.j2k",
+     "flower.jp2"
+   };
+   unsigned int i;
+
+   obj = evas_object_image_add(e);
+   ref = evas_object_image_add(e);
+   str = eina_strbuf_new();
+
+   for (i = 0; i < sizeof (files) / sizeof (files[0]); i++)
+     {
+        int w, h, r_w, r_h;
+        const uint32_t *d, *r_d;
+
+        eina_strbuf_append_printf(str, "%s/%s", TESTS_IMG_DIR, files[i]);
+        evas_object_image_file_set(obj, eina_strbuf_string_get(str), NULL);
+        fail_if(evas_object_image_load_error_get(obj) != EVAS_LOAD_ERROR_NONE);
+        evas_object_image_size_get(obj, &w, &h);
+        d = evas_object_image_data_get(obj, EINA_FALSE);
+
+        eina_strbuf_reset(str);
+
+        eina_strbuf_append_printf(str, "%s/%s.png", TESTS_IMG_DIR, files[i]);
+        evas_object_image_file_set(ref, eina_strbuf_string_get(str), NULL);
+        fail_if(evas_object_image_load_error_get(ref) != EVAS_LOAD_ERROR_NONE);
+        evas_object_image_size_get(ref, &r_w, &r_h);
+        r_d = evas_object_image_data_get(ref, EINA_FALSE);
+
+        eina_strbuf_reset(str);
+
+        fail_if(w != r_w || h != r_h);
+        fail_if(memcmp(d, r_d, w * h * 4));
+     }
+
+   evas_object_del(obj);
+   evas_object_del(ref);
+
+   eina_strbuf_free(str);
+
+   evas_free(e);
+   evas_shutdown();
+}
+END_TEST
+#endif
+
 void evas_test_image_object(TCase *tc)
 {
    tcase_add_test(tc, evas_object_image_defaults);
    tcase_add_test(tc, evas_object_image_loader);
    tcase_add_test(tc, evas_object_image_loader_orientation);
    tcase_add_test(tc, evas_object_image_orient);
-#if BUILD_LOADER_TGV && BUILD_LOADER_PNG
-   tcase_add_test(tc, evas_object_image_tgv_loader_data);
-#endif
 #if BUILD_LOADER_PNG
+# if BUILD_LOADER_TGV
+   tcase_add_test(tc, evas_object_image_tgv_loader_data);
+# endif
+# if BUILD_LOADER_JP2K
+   tcase_add_test(tc, evas_object_image_jp2k_loader_data);
+# endif
    tcase_add_test(tc, evas_object_image_all_loader_data);
    tcase_add_test(tc, evas_object_image_buggy);
    tcase_add_test(tc, evas_object_image_map_unmap);
diff --git a/src/tests/evas/images/flower.jp2 b/src/tests/evas/images/flower.jp2
new file mode 100644 (file)
index 0000000..a2e0e31
Binary files /dev/null and b/src/tests/evas/images/flower.jp2 differ
diff --git a/src/tests/evas/images/flower.jp2.png b/src/tests/evas/images/flower.jp2.png
new file mode 100644 (file)
index 0000000..ee3c40c
Binary files /dev/null and b/src/tests/evas/images/flower.jp2.png differ
diff --git a/src/tests/evas/images/train.j2k b/src/tests/evas/images/train.j2k
new file mode 100644 (file)
index 0000000..d426050
Binary files /dev/null and b/src/tests/evas/images/train.j2k differ
diff --git a/src/tests/evas/images/train.j2k.png b/src/tests/evas/images/train.j2k.png
new file mode 100644 (file)
index 0000000..e7262a9
Binary files /dev/null and b/src/tests/evas/images/train.j2k.png differ