summaryrefslogtreecommitdiff
path: root/src/tests/evas/evas_test_image.c
diff options
context:
space:
mode:
authorWonguk Jeong <wonguk.jeong@samsung.com>2014-07-06 19:59:44 +0200
committerCedric BAIL <c.bail@partner.samsung.com>2014-07-06 20:12:31 +0200
commit23815453f495faea92f41b3868437ecfa30a4c6d (patch)
tree0078c533ddc6b1fc2dd5eeb2a6f6356fd31ff11e /src/tests/evas/evas_test_image.c
parent1cc23d4ff26ade2e58b575e295fb1ef4fc937a13 (diff)
evas: jpeg loader - add tests for EXIF flip, transpose, transverse.
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>
Diffstat (limited to 'src/tests/evas/evas_test_image.c')
-rw-r--r--src/tests/evas/evas_test_image.c92
1 files changed, 84 insertions, 8 deletions
diff --git a/src/tests/evas/evas_test_image.c b/src/tests/evas/evas_test_image.c
index bd7b5450e9..c9dfef8cee 100644
--- a/src/tests/evas/evas_test_image.c
+++ b/src/tests/evas/evas_test_image.c
@@ -53,7 +53,7 @@ END_TEST
53 53
54typedef struct _orientation_Test_Res { 54typedef struct _orientation_Test_Res {
55 const char *img; 55 const char *img;
56 int flag; 56 const char *desc;
57 int (*compare_func)(const uint32_t *d1, const uint32_t *d2, int w2, int h2); 57 int (*compare_func)(const uint32_t *d1, const uint32_t *d2, int w2, int h2);
58} Orientation_Test_Res; 58} Orientation_Test_Res;
59 59
@@ -116,17 +116,93 @@ static int _compare_img_270(const uint32_t *d1, const uint32_t *d2, int w2, int
116 return 0; 116 return 0;
117} 117}
118 118
119static int _compare_img_flip_h(const uint32_t *d1, const uint32_t *d2, int w2, int h2)
120{
121 int x, y;
122 int r;
123
124 for (y = 0; y < h2; y++)
125 {
126 for (x = w2 - 1; x >= 0; x--)
127 {
128 r = *d1 - *(d2 + x + y * w2);
129 if (r != 0) return r;
130 d1++;
131 }
132 }
133
134 return 0;
135}
136
137static int _compare_img_flip_v(const uint32_t *d1, const uint32_t *d2, int w2, int h2)
138{
139 int x, y;
140 int r;
141
142 for (y = h2 - 1; y >= 0; y--)
143 {
144 for (x = 0; x < w2; x++)
145 {
146 r = *d1 - *(d2 + x + y * w2);
147 if (r != 0) return r;
148 d1++;
149 }
150 }
151
152 return 0;
153}
154
155static int _compare_img_transpose(const uint32_t *d1, const uint32_t *d2, int w2, int h2)
156{
157 int x, y;
158 int r;
159
160 for (x = 0; x < w2; x++)
161 {
162 for (y = 0; y < h2; y++)
163 {
164 r = *d1 - *(d2 + x + y * w2);
165 if (r != 0) return r;
166 d1++;
167 }
168 }
169
170 return 0;
171}
172
173static int _compare_img_transverse(const uint32_t *d1, const uint32_t *d2, int w2, int h2)
174{
175 int x, y;
176 int r;
177
178 for (x = w2 - 1; x >= 0; x--)
179 {
180 for (y = h2 - 1; y >= 0; y--)
181 {
182 r = *d1 - *(d2 + x + y * w2);
183 if (r != 0) return r;
184 d1++;
185 }
186 }
187
188 return 0;
189}
190
119/* TODO: flip test code for 2, 4, 5, 7 */ 191/* TODO: flip test code for 2, 4, 5, 7 */
120START_TEST(evas_object_image_loader_orientation) 192START_TEST(evas_object_image_loader_orientation)
121{ 193{
122 Evas *e = _setup_evas(); 194 Evas *e = _setup_evas();
123 Evas_Object *orig, *rot; 195 Evas_Object *orig, *rot;
124 Orientation_Test_Res res[] = { 196 Orientation_Test_Res res[] = {
125 {TESTS_IMG_DIR"/Light_exif.jpg", 1, _compare_img}, 197 {TESTS_IMG_DIR"/Light_exif.jpg", "Original", _compare_img},
126 {TESTS_IMG_DIR"/Light_exif_90.jpg", 6, _compare_img_90}, 198 {TESTS_IMG_DIR"/Light_exif_flip_h.jpg", "Flip horizontally", _compare_img_flip_h},
127 {TESTS_IMG_DIR"/Light_exif_180.jpg", 3, _compare_img_180}, 199 {TESTS_IMG_DIR"/Light_exif_180.jpg", "Rotate 180° CW", _compare_img_180},
128 {TESTS_IMG_DIR"/Light_exif_270.jpg", 8, _compare_img_270}, 200 {TESTS_IMG_DIR"/Light_exif_flip_v.jpg", "Flip vertically", _compare_img_flip_v},
129 {NULL, 0, NULL} 201 {TESTS_IMG_DIR"/Light_exif_transpose.jpg", "Transpose", _compare_img_transpose},
202 {TESTS_IMG_DIR"/Light_exif_90.jpg", "Rotate 90° CW", _compare_img_90},
203 {TESTS_IMG_DIR"/Light_exif_transverse.jpg", "Transverse", _compare_img_transverse},
204 {TESTS_IMG_DIR"/Light_exif_270.jpg", "Rotate 90° CCW", _compare_img_270},
205 {NULL, NULL, NULL}
130 }; 206 };
131 int w, h, r_w, r_h; 207 int w, h, r_w, r_h;
132 const uint32_t *d, *r_d; 208 const uint32_t *d, *r_d;
@@ -147,12 +223,12 @@ START_TEST(evas_object_image_loader_orientation)
147 evas_object_image_file_set(rot, res[i].img, NULL); 223 evas_object_image_file_set(rot, res[i].img, NULL);
148 fail_if(evas_object_image_load_error_get(rot) != EVAS_LOAD_ERROR_NONE); 224 fail_if(evas_object_image_load_error_get(rot) != EVAS_LOAD_ERROR_NONE);
149 evas_object_image_size_get(rot, &r_w, &r_h); 225 evas_object_image_size_get(rot, &r_w, &r_h);
150 fail_if(w * h != r_w * r_h); 226 fail_if(w * h != r_w * r_h);
151 227
152 r_d = evas_object_image_data_get(rot, EINA_FALSE); 228 r_d = evas_object_image_data_get(rot, EINA_FALSE);
153 229
154 fail_if(res[i].compare_func(d, r_d, r_w, r_h), 230 fail_if(res[i].compare_func(d, r_d, r_w, r_h),
155 "Image orientation test failed: exif orientation flag: %d\n", res[i].flag); 231 "Image orientation test failed: exif orientation flag: %s\n", res[i].desc);
156 } 232 }
157 233
158 evas_object_del(orig); 234 evas_object_del(orig);