summaryrefslogtreecommitdiff
path: root/src/tests/evas/evas_test_image.c
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@osg.samsung.com>2018-04-17 11:55:20 +0200
committerStefan Schmidt <stefan@osg.samsung.com>2018-04-17 15:14:52 +0200
commit22cb35c9a4d6efbc12e814b4a9d8a068e4b2d94f (patch)
tree3bcaf1f6f51f3b0f917f89f627809bdb5baac3fd /src/tests/evas/evas_test_image.c
parentc943c4a2ffd51d9c7a1f4dd95f99721b1cb9148e (diff)
tests: use loop test to split jpeg tests from evas_object_image_all_loader_data
Summary: jpeg loader tests take 4+ seconds due to manual value comparisons, so ensure that they run separately ref T6856 Reviewers: stefan_schmidt Subscribers: cedric Maniphest Tasks: T6856 Differential Revision: https://phab.enlightenment.org/D5911
Diffstat (limited to 'src/tests/evas/evas_test_image.c')
-rw-r--r--src/tests/evas/evas_test_image.c104
1 files changed, 59 insertions, 45 deletions
diff --git a/src/tests/evas/evas_test_image.c b/src/tests/evas/evas_test_image.c
index 35d736b26c..bbe64654af 100644
--- a/src/tests/evas/evas_test_image.c
+++ b/src/tests/evas/evas_test_image.c
@@ -38,10 +38,6 @@ static const char *exts[] = {
38#ifdef BUILD_LOADER_WEBP 38#ifdef BUILD_LOADER_WEBP
39 ,"webp" 39 ,"webp"
40#endif 40#endif
41#ifdef BUILD_LOADER_JPEG
42 ,"jpeg"
43 ,"jpg"
44#endif
45#ifdef BUILD_LOADER_TGV 41#ifdef BUILD_LOADER_TGV
46 ,"tgv" 42 ,"tgv"
47#endif 43#endif
@@ -49,6 +45,13 @@ static const char *exts[] = {
49 ,"jp2" 45 ,"jp2"
50 ,"j2k" 46 ,"j2k"
51#endif 47#endif
48/* ADD NEW FORMATS HERE
49 * JPEG MUST BE LAST
50 */
51#ifdef BUILD_LOADER_JPEG
52 ,"jpeg"
53 ,"jpg"
54#endif
52}; 55};
53 56
54EFL_START_TEST(evas_object_image_loader) 57EFL_START_TEST(evas_object_image_loader)
@@ -396,60 +399,55 @@ EFL_START_TEST(evas_object_image_all_loader_data)
396 Evas *e = _setup_evas(); 399 Evas *e = _setup_evas();
397 Evas_Object *obj, *ref; 400 Evas_Object *obj, *ref;
398 Eina_Strbuf *str; 401 Eina_Strbuf *str;
399 unsigned int i; 402 struct stat st;
403 int w, h, s, r_w, r_h, r_s;
404 const uint32_t *d, *r_d;
405 Evas_Colorspace c, r_c;
400 406
401 obj = evas_object_image_add(e); 407 obj = evas_object_image_add(e);
402 ref = evas_object_image_add(e); 408 ref = evas_object_image_add(e);
403 str = eina_strbuf_new(); 409 str = eina_strbuf_new();
404 410
405 for (i = 0; i < sizeof (exts) / sizeof (exts[0]); i++) 411 eina_strbuf_reset(str);
406 {
407 struct stat st;
408 int w, h, s, r_w, r_h, r_s;
409 const uint32_t *d, *r_d;
410 Evas_Colorspace c, r_c;
411
412 eina_strbuf_reset(str);
413 412
414 eina_strbuf_append_printf(str, "%s/Pic4-%s.png", TESTS_IMG_DIR, exts[i]); 413 eina_strbuf_append_printf(str, "%s/Pic4-%s.png", TESTS_IMG_DIR, exts[_i]);
415 414
416 if (stat(eina_strbuf_string_get(str), &st) != 0) continue; 415 if (stat(eina_strbuf_string_get(str), &st) != 0) goto end;
417 416
418 evas_object_image_file_set(obj, eina_strbuf_string_get(str), NULL); 417 evas_object_image_file_set(obj, eina_strbuf_string_get(str), NULL);
419 fail_if(evas_object_image_load_error_get(obj) != EVAS_LOAD_ERROR_NONE); 418 fail_if(evas_object_image_load_error_get(obj) != EVAS_LOAD_ERROR_NONE);
420 evas_object_image_size_get(obj, &w, &h); 419 evas_object_image_size_get(obj, &w, &h);
421 s = evas_object_image_stride_get(obj); 420 s = evas_object_image_stride_get(obj);
422 c = evas_object_image_colorspace_get(obj); 421 c = evas_object_image_colorspace_get(obj);
423 d = evas_object_image_data_get(obj, EINA_FALSE); 422 d = evas_object_image_data_get(obj, EINA_FALSE);
424 423
425 eina_strbuf_reset(str); 424 eina_strbuf_reset(str);
426 425
427 eina_strbuf_append_printf(str, "%s/Pic4.%s", TESTS_IMG_DIR, exts[i]); 426 eina_strbuf_append_printf(str, "%s/Pic4.%s", TESTS_IMG_DIR, exts[_i]);
428 evas_object_image_file_set(ref, eina_strbuf_string_get(str), NULL); 427 evas_object_image_file_set(ref, eina_strbuf_string_get(str), NULL);
429 fail_if(evas_object_image_load_error_get(ref) != EVAS_LOAD_ERROR_NONE); 428 fail_if(evas_object_image_load_error_get(ref) != EVAS_LOAD_ERROR_NONE);
430 evas_object_image_size_get(ref, &r_w, &r_h); 429 evas_object_image_size_get(ref, &r_w, &r_h);
431 r_s = evas_object_image_stride_get(ref); 430 r_s = evas_object_image_stride_get(ref);
432 r_c = evas_object_image_colorspace_get(ref); 431 r_c = evas_object_image_colorspace_get(ref);
433 r_d = evas_object_image_data_get(ref, EINA_FALSE); 432 r_d = evas_object_image_data_get(ref, EINA_FALSE);
434 433
435 fail_if(w != r_w || h != r_h); 434 fail_if(w != r_w || h != r_h);
436 fail_if(s != r_s); 435 fail_if(s != r_s);
437 fail_if(c != r_c); 436 fail_if(c != r_c);
438 fail_if(w*4 != s); 437 fail_if(w*4 != s);
439 if (strcmp(exts[i], "jpeg") == 0 || strcmp(exts[i], "jpg") == 0) 438 if (strcmp(exts[_i], "jpeg") == 0 || strcmp(exts[_i], "jpg") == 0)
439 {
440 //jpeg norm allows a variation of 1 bit per component
441 for (int j = 0; j < s * h; j++)
440 { 442 {
441 //jpeg norm allows a variation of 1 bit per component 443 fail_if(abs(((char*)d)[j] - ((char*)r_d)[j]) > 1);
442 for (int j = 0; j < s * h; j++)
443 {
444 fail_if(abs(((char*)d)[j] - ((char*)r_d)[j]) > 1);
445 }
446 }
447 else
448 {
449 fail_if(memcmp(d, r_d, w * h * 4));
450 } 444 }
451 } 445 }
452 446 else
447 {
448 fail_if(memcmp(d, r_d, w * h * 4));
449 }
450end:
453 evas_object_del(obj); 451 evas_object_del(obj);
454 evas_object_del(ref); 452 evas_object_del(ref);
455 453
@@ -883,9 +881,25 @@ void evas_test_image_object(TCase *tc)
883# if BUILD_LOADER_JP2K 881# if BUILD_LOADER_JP2K
884 tcase_add_test(tc, evas_object_image_jp2k_loader_data); 882 tcase_add_test(tc, evas_object_image_jp2k_loader_data);
885# endif 883# endif
886 tcase_add_test(tc, evas_object_image_all_loader_data); 884#ifdef BUILD_LOADER_JPEG
885 /* jpeg takes forever from manual value comparisons */
886 tcase_add_loop_test(tc, evas_object_image_all_loader_data, 0, EINA_C_ARRAY_LENGTH(exts) - 2);
887#else
888 tcase_add_loop_test(tc, evas_object_image_all_loader_data, 0, EINA_C_ARRAY_LENGTH(exts));
889#endif
887 tcase_add_test(tc, evas_object_image_buggy); 890 tcase_add_test(tc, evas_object_image_buggy);
888 tcase_add_test(tc, evas_object_image_map_unmap); 891 tcase_add_test(tc, evas_object_image_map_unmap);
889#endif 892#endif
890 tcase_add_test(tc, evas_object_image_partially_load_orientation); 893 tcase_add_test(tc, evas_object_image_partially_load_orientation);
891} 894}
895
896
897void evas_test_image_object2(TCase *tc)
898{
899#if BUILD_LOADER_PNG
900#ifdef BUILD_LOADER_JPEG
901 /* jpeg takes forever from manual value comparisons */
902 tcase_add_loop_test(tc, evas_object_image_all_loader_data, EINA_C_ARRAY_LENGTH(exts) - 2, EINA_C_ARRAY_LENGTH(exts));
903#endif
904#endif
905}