evas: jpeg loader - add tests for EXIF flip, transpose, transverse.
authorWonguk Jeong <wonguk.jeong@samsung.com>
Sun, 6 Jul 2014 17:59:44 +0000 (19:59 +0200)
committerCedric BAIL <c.bail@partner.samsung.com>
Sun, 6 Jul 2014 18:12:31 +0000 (20:12 +0200)
Summary:
Previously, there was rotation test only. (90 CW, 180 CW, 90 CCW)
Flip vertically, flip horizontally, transpose, transverse tests are added

D1126 will make added tests be passed.

Reviewers: raster, cedric, jpeg

CC: seoz, cedric
Differential Revision: https://phab.enlightenment.org/D1127

Signed-off-by: Cedric BAIL <c.bail@partner.samsung.com>
src/tests/evas/evas_test_image.c
src/tests/evas/images/Light_exif_flip_h.jpg [new file with mode: 0644]
src/tests/evas/images/Light_exif_flip_v.jpg [new file with mode: 0644]
src/tests/evas/images/Light_exif_transpose.jpg [new file with mode: 0644]
src/tests/evas/images/Light_exif_transverse.jpg [new file with mode: 0644]

index bd7b545..c9dfef8 100644 (file)
@@ -53,7 +53,7 @@ END_TEST
 
 typedef struct _orientation_Test_Res {
    const char *img;
-   int flag;
+   const char *desc;
    int (*compare_func)(const uint32_t *d1, const uint32_t *d2, int w2, int h2);
 } Orientation_Test_Res;
 
@@ -116,17 +116,93 @@ static int _compare_img_270(const uint32_t *d1, const uint32_t *d2, int w2, int
    return 0;
 }
 
+static int _compare_img_flip_h(const uint32_t *d1, const uint32_t *d2, int w2, int h2)
+{
+   int x, y;
+   int r;
+
+   for (y = 0; y < h2; y++)
+     {
+        for (x = w2 - 1; x >= 0; x--)
+          {
+             r = *d1 - *(d2 + x + y * w2);
+             if (r != 0) return r;
+             d1++;
+          }
+     }
+
+   return 0;
+}
+
+static int _compare_img_flip_v(const uint32_t *d1, const uint32_t *d2, int w2, int h2)
+{
+   int x, y;
+   int r;
+
+   for (y = h2 - 1; y >= 0; y--)
+     {
+        for (x = 0; x < w2; x++)
+          {
+             r = *d1 - *(d2 + x + y * w2);
+             if (r != 0) return r;
+             d1++;
+          }
+     }
+
+   return 0;
+}
+
+static int _compare_img_transpose(const uint32_t *d1, const uint32_t *d2, int w2, int h2)
+{
+   int x, y;
+   int r;
+
+   for (x = 0; x < w2; x++)
+     {
+        for (y = 0; y < h2; y++)
+          {
+             r = *d1 - *(d2 + x + y * w2);
+             if (r != 0) return r;
+             d1++;
+          }
+     }
+
+   return 0;
+}
+
+static int _compare_img_transverse(const uint32_t *d1, const uint32_t *d2, int w2, int h2)
+{
+   int x, y;
+   int r;
+
+   for (x = w2 - 1; x >= 0; x--)
+     {
+        for (y = h2 - 1; y >= 0; y--)
+          {
+             r = *d1 - *(d2 + x + y * w2);
+             if (r != 0) return r;
+             d1++;
+          }
+     }
+
+   return 0;
+}
+
 /* TODO: flip test code for 2, 4, 5, 7 */
 START_TEST(evas_object_image_loader_orientation)
 {
    Evas *e = _setup_evas();
    Evas_Object *orig, *rot;
    Orientation_Test_Res res[] = {
-       {TESTS_IMG_DIR"/Light_exif.jpg", 1, _compare_img},
-       {TESTS_IMG_DIR"/Light_exif_90.jpg", 6, _compare_img_90},
-       {TESTS_IMG_DIR"/Light_exif_180.jpg", 3, _compare_img_180},
-       {TESTS_IMG_DIR"/Light_exif_270.jpg", 8, _compare_img_270},
-       {NULL, 0, NULL}
+       {TESTS_IMG_DIR"/Light_exif.jpg", "Original", _compare_img},
+       {TESTS_IMG_DIR"/Light_exif_flip_h.jpg", "Flip horizontally", _compare_img_flip_h},
+       {TESTS_IMG_DIR"/Light_exif_180.jpg", "Rotate 180° CW", _compare_img_180},
+       {TESTS_IMG_DIR"/Light_exif_flip_v.jpg", "Flip vertically", _compare_img_flip_v},
+       {TESTS_IMG_DIR"/Light_exif_transpose.jpg", "Transpose", _compare_img_transpose},
+       {TESTS_IMG_DIR"/Light_exif_90.jpg", "Rotate 90° CW", _compare_img_90},
+       {TESTS_IMG_DIR"/Light_exif_transverse.jpg", "Transverse", _compare_img_transverse},
+       {TESTS_IMG_DIR"/Light_exif_270.jpg", "Rotate 90° CCW", _compare_img_270},
+       {NULL, NULL, NULL}
    };
    int w, h, r_w, r_h;
    const uint32_t *d, *r_d;
@@ -147,12 +223,12 @@ START_TEST(evas_object_image_loader_orientation)
         evas_object_image_file_set(rot, res[i].img, NULL);
         fail_if(evas_object_image_load_error_get(rot) != EVAS_LOAD_ERROR_NONE);
         evas_object_image_size_get(rot, &r_w, &r_h);
-       fail_if(w * h != r_w * r_h);
+        fail_if(w * h != r_w * r_h);
 
         r_d = evas_object_image_data_get(rot, EINA_FALSE);
 
         fail_if(res[i].compare_func(d, r_d, r_w, r_h),
-                "Image orientation test failed: exif orientation flag: %d\n", res[i].flag);
+                "Image orientation test failed: exif orientation flag: %s\n", res[i].desc);
      }
 
    evas_object_del(orig);
diff --git a/src/tests/evas/images/Light_exif_flip_h.jpg b/src/tests/evas/images/Light_exif_flip_h.jpg
new file mode 100644 (file)
index 0000000..ce2c06c
Binary files /dev/null and b/src/tests/evas/images/Light_exif_flip_h.jpg differ
diff --git a/src/tests/evas/images/Light_exif_flip_v.jpg b/src/tests/evas/images/Light_exif_flip_v.jpg
new file mode 100644 (file)
index 0000000..4504550
Binary files /dev/null and b/src/tests/evas/images/Light_exif_flip_v.jpg differ
diff --git a/src/tests/evas/images/Light_exif_transpose.jpg b/src/tests/evas/images/Light_exif_transpose.jpg
new file mode 100644 (file)
index 0000000..cf0bb50
Binary files /dev/null and b/src/tests/evas/images/Light_exif_transpose.jpg differ
diff --git a/src/tests/evas/images/Light_exif_transverse.jpg b/src/tests/evas/images/Light_exif_transverse.jpg
new file mode 100644 (file)
index 0000000..4579b04
Binary files /dev/null and b/src/tests/evas/images/Light_exif_transverse.jpg differ