summaryrefslogtreecommitdiff
path: root/src/tests/evas/evas_test_image.c
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2019-06-14 16:46:17 -0700
committerCedric BAIL <cedric.bail@free.fr>2019-07-12 09:54:24 -0700
commitb799ba1a10b0f4906a5487474ba9f14db465caeb (patch)
tree87efc26e191f61081a52ba9cbedd1b5eeace4b07 /src/tests/evas/evas_test_image.c
parent5847886a3fdb7c470bd55e215b822bbbaf109080 (diff)
evas: add a test for loading Android 9patch file.
Example data come from https://github.com/vindolin/ninepatch/tree/master/ninepatch/data under MIT license. Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Reviewed-by: Hermet Park <hermetpark@gmail.com> Differential Revision: https://phab.enlightenment.org/D9105
Diffstat (limited to 'src/tests/evas/evas_test_image.c')
-rw-r--r--src/tests/evas/evas_test_image.c89
1 files changed, 89 insertions, 0 deletions
diff --git a/src/tests/evas/evas_test_image.c b/src/tests/evas/evas_test_image.c
index c66d718ce0..1eaa6d0e2e 100644
--- a/src/tests/evas/evas_test_image.c
+++ b/src/tests/evas/evas_test_image.c
@@ -1029,6 +1029,94 @@ EFL_START_TEST(evas_object_image_jp2k_loader_data)
1029EFL_END_TEST 1029EFL_END_TEST
1030#endif 1030#endif
1031 1031
1032EFL_START_TEST(evas_object_image_9patch)
1033{
1034 Evas *e = _setup_evas();
1035 Evas *sub_e;
1036 Ecore_Evas *ee, *sub_ee;
1037 Evas_Object *obj, *cmp, *ref;
1038 Eina_Strbuf *str;
1039
1040 const char *files[] = {
1041 "9patch_test.9.png"
1042 };
1043 unsigned int i;
1044
1045 ee = ecore_evas_ecore_evas_get(e);
1046
1047 cmp = ecore_evas_object_image_new(ee);
1048 evas_object_image_filled_set(cmp, EINA_TRUE);
1049 evas_object_image_size_set(cmp, 1024, 1024);
1050 evas_object_resize(cmp, 1024, 1024);
1051 evas_object_show(cmp);
1052
1053 sub_ee = ecore_evas_object_ecore_evas_get(cmp);
1054 sub_e = ecore_evas_object_evas_get(cmp);
1055
1056 ecore_evas_alpha_set(sub_ee, EINA_TRUE);
1057
1058 obj = evas_object_rectangle_add(sub_e);
1059 evas_object_color_set(obj, 0, 0, 0, 0);
1060 evas_object_move(obj, 0, 0);
1061 evas_object_resize(obj, 1024, 1024);
1062 evas_object_show(obj);
1063
1064 obj = evas_object_image_filled_add(sub_e);
1065 evas_object_image_alpha_set(obj, 1);
1066 evas_object_move(obj, 0, 0);
1067 evas_object_resize(obj, 1024, 1024);
1068 ecore_evas_resize(sub_ee, 1024, 1024);
1069 evas_object_show(obj);
1070
1071 Evas_Object *rect = evas_object_rectangle_add(sub_e);
1072 evas_object_color_set(rect, 128, 0, 0, 128);
1073 evas_object_show(rect);
1074
1075 ref = evas_object_image_add(e);
1076 str = eina_strbuf_new();
1077
1078 for (i = 0; i < sizeof (files) / sizeof (files[0]); i++)
1079 {
1080 Eina_Rect content;
1081 int r_w, r_h;
1082 const uint32_t *d, *r_d;
1083
1084 eina_strbuf_append_printf(str, "%s/%s", TESTS_IMG_DIR, files[i]);
1085 evas_object_image_file_set(obj, eina_strbuf_string_get(str), NULL);
1086 ck_assert_int_eq(evas_object_image_load_error_get(obj), EVAS_LOAD_ERROR_NONE);
1087 content = efl_gfx_image_content_region_get(obj);
1088
1089 evas_object_move(rect, content.x, content.y);
1090 evas_object_resize(rect, content.w, content.h);
1091
1092 eina_strbuf_reset(str);
1093
1094 ecore_evas_manual_render(ee);
1095
1096 d = evas_object_image_data_get(cmp, EINA_FALSE);
1097
1098 eina_strbuf_append_printf(str, "%s/%s.png", TESTS_IMG_DIR, files[i]);
1099 evas_object_image_file_set(ref, eina_strbuf_string_get(str), NULL);
1100 ck_assert_int_eq(evas_object_image_load_error_get(ref), EVAS_LOAD_ERROR_NONE);
1101 evas_object_image_size_get(ref, &r_w, &r_h);
1102 r_d = evas_object_image_data_get(ref, EINA_FALSE);
1103
1104 eina_strbuf_reset(str);
1105
1106 fail_if(r_w != 1024 || r_h != 1024);
1107 for (int i = 0; i < r_w * r_h; i++)
1108 fail_if(((d[i] - r_d[i]) & 0xF8F8F8F8) != 0);
1109 }
1110
1111 evas_object_del(obj);
1112 evas_object_del(ref);
1113
1114 eina_strbuf_free(str);
1115
1116 evas_free(e);
1117}
1118EFL_END_TEST
1119
1032void evas_test_image_object(TCase *tc) 1120void evas_test_image_object(TCase *tc)
1033{ 1121{
1034 tcase_add_test(tc, evas_object_image_api); 1122 tcase_add_test(tc, evas_object_image_api);
@@ -1054,6 +1142,7 @@ void evas_test_image_object(TCase *tc)
1054#endif 1142#endif
1055 tcase_add_test(tc, evas_object_image_partially_load_orientation); 1143 tcase_add_test(tc, evas_object_image_partially_load_orientation);
1056 tcase_add_test(tc, evas_object_image_cached_data_comparision); 1144 tcase_add_test(tc, evas_object_image_cached_data_comparision);
1145 tcase_add_test(tc, evas_object_image_9patch);
1057} 1146}
1058 1147
1059 1148