summaryrefslogtreecommitdiff
path: root/src/tests/evas/evas_test_image.c
diff options
context:
space:
mode:
authorVincent Torri <vincent.torri@gmail.com>2017-08-11 17:51:29 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2017-08-11 17:53:28 +0900
commitc358ac0222c56356d4ed2d2cb722c61e67e56dec (patch)
tree4615a7fedfb0541af177a460d92661897fbd2642 /src/tests/evas/evas_test_image.c
parent190cce71f5a914eb144c9e6fffab0238b86361ce (diff)
evas tests - add Jpeg2000 tests
add tests for loading jp2k files correctly and the images
Diffstat (limited to 'src/tests/evas/evas_test_image.c')
-rw-r--r--src/tests/evas/evas_test_image.c68
1 files changed, 65 insertions, 3 deletions
diff --git a/src/tests/evas/evas_test_image.c b/src/tests/evas/evas_test_image.c
index c34a52da69..5cbfa015fc 100644
--- a/src/tests/evas/evas_test_image.c
+++ b/src/tests/evas/evas_test_image.c
@@ -44,6 +44,10 @@ static const char *exts[] = {
44#ifdef BUILD_LOADER_TGV 44#ifdef BUILD_LOADER_TGV
45 ,"tgv" 45 ,"tgv"
46#endif 46#endif
47#ifdef BUILD_LOADER_JP2K
48 ,"jp2"
49 ,"j2k"
50#endif
47}; 51};
48 52
49START_TEST(evas_object_image_loader) 53START_TEST(evas_object_image_loader)
@@ -331,6 +335,7 @@ START_TEST(evas_object_image_orient)
331} 335}
332END_TEST 336END_TEST
333 337
338#ifdef BUILD_LOADER_TGV
334START_TEST(evas_object_image_tgv_loader_data) 339START_TEST(evas_object_image_tgv_loader_data)
335{ 340{
336 Evas *e = _setup_evas(); 341 Evas *e = _setup_evas();
@@ -387,6 +392,7 @@ START_TEST(evas_object_image_tgv_loader_data)
387 evas_shutdown(); 392 evas_shutdown();
388} 393}
389END_TEST 394END_TEST
395#endif
390 396
391START_TEST(evas_object_image_all_loader_data) 397START_TEST(evas_object_image_all_loader_data)
392{ 398{
@@ -812,16 +818,72 @@ START_TEST(evas_object_image_map_unmap)
812} 818}
813END_TEST 819END_TEST
814 820
821#if BUILD_LOADER_JP2K
822START_TEST(evas_object_image_jp2k_loader_data)
823{
824 Evas *e = _setup_evas();
825 Evas_Object *obj, *ref;
826 Eina_Strbuf *str;
827
828 const char *files[] = {
829 "train.j2k",
830 "flower.jp2"
831 };
832 unsigned int i;
833
834 obj = evas_object_image_add(e);
835 ref = evas_object_image_add(e);
836 str = eina_strbuf_new();
837
838 for (i = 0; i < sizeof (files) / sizeof (files[0]); i++)
839 {
840 int w, h, r_w, r_h;
841 const uint32_t *d, *r_d;
842
843 eina_strbuf_append_printf(str, "%s/%s", TESTS_IMG_DIR, files[i]);
844 evas_object_image_file_set(obj, eina_strbuf_string_get(str), NULL);
845 fail_if(evas_object_image_load_error_get(obj) != EVAS_LOAD_ERROR_NONE);
846 evas_object_image_size_get(obj, &w, &h);
847 d = evas_object_image_data_get(obj, EINA_FALSE);
848
849 eina_strbuf_reset(str);
850
851 eina_strbuf_append_printf(str, "%s/%s.png", TESTS_IMG_DIR, files[i]);
852 evas_object_image_file_set(ref, eina_strbuf_string_get(str), NULL);
853 fail_if(evas_object_image_load_error_get(ref) != EVAS_LOAD_ERROR_NONE);
854 evas_object_image_size_get(ref, &r_w, &r_h);
855 r_d = evas_object_image_data_get(ref, EINA_FALSE);
856
857 eina_strbuf_reset(str);
858
859 fail_if(w != r_w || h != r_h);
860 fail_if(memcmp(d, r_d, w * h * 4));
861 }
862
863 evas_object_del(obj);
864 evas_object_del(ref);
865
866 eina_strbuf_free(str);
867
868 evas_free(e);
869 evas_shutdown();
870}
871END_TEST
872#endif
873
815void evas_test_image_object(TCase *tc) 874void evas_test_image_object(TCase *tc)
816{ 875{
817 tcase_add_test(tc, evas_object_image_defaults); 876 tcase_add_test(tc, evas_object_image_defaults);
818 tcase_add_test(tc, evas_object_image_loader); 877 tcase_add_test(tc, evas_object_image_loader);
819 tcase_add_test(tc, evas_object_image_loader_orientation); 878 tcase_add_test(tc, evas_object_image_loader_orientation);
820 tcase_add_test(tc, evas_object_image_orient); 879 tcase_add_test(tc, evas_object_image_orient);
821#if BUILD_LOADER_TGV && BUILD_LOADER_PNG
822 tcase_add_test(tc, evas_object_image_tgv_loader_data);
823#endif
824#if BUILD_LOADER_PNG 880#if BUILD_LOADER_PNG
881# if BUILD_LOADER_TGV
882 tcase_add_test(tc, evas_object_image_tgv_loader_data);
883# endif
884# if BUILD_LOADER_JP2K
885 tcase_add_test(tc, evas_object_image_jp2k_loader_data);
886# endif
825 tcase_add_test(tc, evas_object_image_all_loader_data); 887 tcase_add_test(tc, evas_object_image_all_loader_data);
826 tcase_add_test(tc, evas_object_image_buggy); 888 tcase_add_test(tc, evas_object_image_buggy);
827 tcase_add_test(tc, evas_object_image_map_unmap); 889 tcase_add_test(tc, evas_object_image_map_unmap);