summaryrefslogtreecommitdiff
path: root/src/tests/evas/evas_test_image.c
diff options
context:
space:
mode:
authorkabeer khan <kabeer.khan@samsung.com>2015-04-06 15:48:34 +0200
committerCedric BAIL <cedric@osg.samsung.com>2015-04-06 16:37:52 +0200
commit757c7c3f100275c52c2be3f16759bb40890536ef (patch)
tree80bd4d1cac81d4fb01cb0b0966f6622ee93ed9ac /src/tests/evas/evas_test_image.c
parent3f35bc341ae2c636305cfff36804df25b2c2d780 (diff)
evas: add image_orient_set/get tests in evas tests suite.
Reviewers: cedric Reviewed By: cedric Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D2239 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
Diffstat (limited to 'src/tests/evas/evas_test_image.c')
-rw-r--r--src/tests/evas/evas_test_image.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/tests/evas/evas_test_image.c b/src/tests/evas/evas_test_image.c
index cb3ff690e6..ca7a0cbbf9 100644
--- a/src/tests/evas/evas_test_image.c
+++ b/src/tests/evas/evas_test_image.c
@@ -106,6 +106,12 @@ typedef struct _orientation_Test_Res {
106 int (*compare_func)(const uint32_t *d1, const uint32_t *d2, int w2, int h2); 106 int (*compare_func)(const uint32_t *d1, const uint32_t *d2, int w2, int h2);
107} Orientation_Test_Res; 107} Orientation_Test_Res;
108 108
109typedef struct _orient_Test {
110 Evas_Image_Orient orient;
111 const char *desc;
112 int (*compare_func)(const uint32_t *d1, const uint32_t *d2, int w2, int h2);
113} Orient_Test;
114
109static int _compare_img(const uint32_t *d1, const uint32_t *d2, int w2, int h2) 115static int _compare_img(const uint32_t *d1, const uint32_t *d2, int w2, int h2)
110{ 116{
111 return memcmp(d1, d2, w2 * h2 * 4); 117 return memcmp(d1, d2, w2 * h2 * 4);
@@ -287,6 +293,56 @@ START_TEST(evas_object_image_loader_orientation)
287} 293}
288END_TEST 294END_TEST
289 295
296START_TEST(evas_object_image_orient)
297{
298 Evas *e = _setup_evas();
299 Evas_Object *orig;
300 Orient_Test res[] = {
301 {EVAS_IMAGE_ORIENT_0, "Original", _compare_img},
302 {EVAS_IMAGE_FLIP_HORIZONTAL, "Flip horizontally", _compare_img_flip_h},
303 {EVAS_IMAGE_ORIENT_180, "Rotate 180° CW", _compare_img_180},
304 {EVAS_IMAGE_FLIP_VERTICAL, "Flip vertically", _compare_img_flip_v},
305 {EVAS_IMAGE_FLIP_TRANSPOSE, "Transpose", _compare_img_transpose},
306 {EVAS_IMAGE_ORIENT_90, "Rotate 90° CW", _compare_img_90},
307 {EVAS_IMAGE_FLIP_TRANSVERSE, "Transverse", _compare_img_transverse},
308 {EVAS_IMAGE_ORIENT_270, "Rotate 90° CCW", _compare_img_270},
309 {0, NULL, NULL}
310 };
311 int w, h, r_w, r_h;
312 uint32_t *d, *r_d;
313 int i;
314
315 orig = evas_object_image_add(e);
316 evas_object_image_file_set(orig, TESTS_IMG_DIR"/Light.jpg", NULL);
317 fail_if(evas_object_image_load_error_get(orig) != EVAS_LOAD_ERROR_NONE);
318 evas_object_image_size_get(orig, &w, &h);
319 fail_if(w == 0 || h == 0);
320
321 d = malloc(w * h * 4);
322 fail_if(!d);
323 r_d = evas_object_image_data_get(orig, EINA_FALSE);
324 memcpy(d, r_d, w * h * 4);
325
326 for (i = 0; res[i].desc; i++)
327 {
328 evas_object_image_orient_set(orig, res[i].orient);
329 fail_if(evas_object_image_orient_get(orig) != res[i].orient);
330 evas_object_image_size_get(orig, &r_w, &r_h);
331 fail_if(w * h != r_w * r_h);
332
333 r_d = evas_object_image_data_get(orig, EINA_FALSE);
334
335 fail_if(res[i].compare_func(d, r_d, r_w, r_h),
336 "Image orientation test failed: orient flag: %s\n", res[i].desc);
337 }
338
339 evas_object_del(orig);
340
341 evas_free(e);
342 evas_shutdown();
343}
344END_TEST
345
290START_TEST(evas_object_image_tgv_loader_data) 346START_TEST(evas_object_image_tgv_loader_data)
291{ 347{
292 Evas *e = _setup_evas(); 348 Evas *e = _setup_evas();
@@ -476,6 +532,7 @@ void evas_test_image_object(TCase *tc)
476{ 532{
477 tcase_add_test(tc, evas_object_image_loader); 533 tcase_add_test(tc, evas_object_image_loader);
478 tcase_add_test(tc, evas_object_image_loader_orientation); 534 tcase_add_test(tc, evas_object_image_loader_orientation);
535 tcase_add_test(tc, evas_object_image_orient);
479#if BUILD_LOADER_TGV && BUILD_LOADER_PNG 536#if BUILD_LOADER_TGV && BUILD_LOADER_PNG
480 tcase_add_test(tc, evas_object_image_tgv_loader_data); 537 tcase_add_test(tc, evas_object_image_tgv_loader_data);
481#endif 538#endif