summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2020-02-25 09:23:46 -0500
committerMike Blumenkrantz <zmike@samsung.com>2020-02-25 09:23:46 -0500
commit526b1e2c72560f80bcc7c435a924b2def3016215 (patch)
treec46486351e572a215ec1a959ddf3c9c4cf42d347
parent1b5ad4740e19be9e49432fbf895ae15a81c05a18 (diff)
tests/elm: verify image file_set -> memfile_set -> file_set
Summary: ref D11392 Depends on D11397 Reviewers: kimcinoo, Hermet Reviewed By: Hermet Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D11398
-rw-r--r--src/tests/elementary/elm_test_image.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/tests/elementary/elm_test_image.c b/src/tests/elementary/elm_test_image.c
index 36e9aa2a84..bfd6dad3dd 100644
--- a/src/tests/elementary/elm_test_image.c
+++ b/src/tests/elementary/elm_test_image.c
@@ -18,6 +18,34 @@ struct _Test_Data
18 int success; 18 int success;
19}; 19};
20 20
21static int
22_file_to_memory(const char *filename, char **result)
23{
24 int size;
25 FILE *f;
26
27 f = fopen(filename, "rb");
28 if (f == NULL)
29 {
30 *result = NULL;
31 return -1;
32 }
33
34 fseek(f, 0, SEEK_END);
35 size = ftell(f);
36 fseek(f, 0, SEEK_SET);
37 *result = (char *)malloc(size + 1);
38 if ((size_t)size != fread(*result, sizeof(char), size, f))
39 {
40 free(*result);
41 fclose(f);
42 return -1;
43 }
44 fclose(f);
45 (*result)[size] = 0;
46 return size;
47}
48
21EFL_START_TEST(elm_image_legacy_type_check) 49EFL_START_TEST(elm_image_legacy_type_check)
22{ 50{
23 Evas_Object *win, *image; 51 Evas_Object *win, *image;
@@ -227,6 +255,28 @@ EFL_START_TEST(elm_image_evas_image_get)
227} 255}
228EFL_END_TEST 256EFL_END_TEST
229 257
258EFL_START_TEST(elm_image_test_memfile_set)
259{
260 Evas_Object *win, *image;
261 char *mem;
262 int size;
263 const char *file = NULL;
264
265 win = win_add(NULL, "image", ELM_WIN_BASIC);
266
267 image = elm_image_add(win);
268 ck_assert(elm_image_file_set(image, ELM_IMAGE_DATA_DIR"/images/icon_01.png", NULL));
269 size = _file_to_memory(ELM_IMAGE_DATA_DIR"/images/icon_02.png", &mem);
270 ck_assert_int_ge(size, 0);
271 ck_assert(elm_image_memfile_set(image, mem, size, "png", NULL));
272 elm_image_file_get(image, &file, NULL);
273 ck_assert_str_ne(file, ELM_IMAGE_DATA_DIR"/images/icon_01.png");
274 ck_assert(elm_image_file_set(image, ELM_IMAGE_DATA_DIR"/images/icon_01.png", NULL));
275 elm_image_file_get(image, &file, NULL);
276 ck_assert_str_eq(file, ELM_IMAGE_DATA_DIR"/images/icon_01.png");
277}
278EFL_END_TEST
279
230void elm_test_image(TCase *tc) 280void elm_test_image(TCase *tc)
231{ 281{
232 tcase_add_test(tc, elm_image_legacy_type_check); 282 tcase_add_test(tc, elm_image_legacy_type_check);
@@ -235,4 +285,5 @@ void elm_test_image(TCase *tc)
235 tcase_add_test(tc, elm_image_async_mmap); 285 tcase_add_test(tc, elm_image_async_mmap);
236 tcase_add_test(tc, elm_image_evas_object_color_set); 286 tcase_add_test(tc, elm_image_evas_object_color_set);
237 tcase_add_test(tc, elm_image_evas_image_get); 287 tcase_add_test(tc, elm_image_evas_image_get);
288 tcase_add_test(tc, elm_image_test_memfile_set);
238} 289}