utc_elm_image: fix memfile_set TC properly. 99/189099/1
authorHermet Park <hermetpark@gmail.com>
Thu, 13 Sep 2018 09:53:48 +0000 (18:53 +0900)
committerHermet Park <hermetpark@gmail.com>
Thu, 13 Sep 2018 09:55:24 +0000 (18:55 +0900)
memfile data must be a vaild, previous gargabe data is insane.

Change-Id: Ie4676434d640dee420605045f4ecd1c4e973d234

TC/elementary/image/utc_elm_image_memfile_set.c

index 28add9dc2cff655fcadfa1957ccca525151b2090..c22d8feb3f7703a2aae1bccbb3681f425c070e8a 100644 (file)
@@ -5,6 +5,11 @@
 static Evas_Object *main_win;
 static Evas_Object *image;
 
+static void *map = NULL;
+static Eina_File* file = NULL;
+static size_t filesize = 0;
+
+
 /**
  *
  * @addtogroup elm_image
@@ -24,11 +29,31 @@ setup(void)
    UTC_ELM_INIT();
    main_win = elm_win_add(NULL, "main", ELM_WIN_BASIC);
    evas_object_show(main_win);
+
+   file = eina_file_open("image/image_home.png", EINA_FALSE);
+   if (!file)
+     {
+        ck_abort_msg("[TET_MSG]:: %s[%d] : Eina_File is not opened..", __FILE__, __LINE__);
+        return;
+     }
+   filesize = eina_file_size_get(file);
+   map = eina_file_map_all(file, EINA_FILE_SEQUENTIAL);
+
+   if (!map)
+     {
+        ck_abort_msg("[TET_MSG]:: %s[%d] : Image is not loaded from file..", __FILE__, __LINE__);
+        file = NULL;
+        ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
+        return;
+     }
 }
 
 static void
 teardown(void)
 {
+   eina_file_map_free(file, map);
+   eina_file_close(file);
+
    if (NULL != main_win)
      {
         evas_object_del(main_win);
@@ -66,13 +91,8 @@ teardown(void)
 START_TEST(utc_UIFW_elm_image_memfile_set_p_1)
 {
    image = elm_image_add(main_win);
-   int mydata[] = {
-         0x00000000, 0x88888888, 0x00000000, 0x88888888, 0x00000000, 0x88888888, 0x00000000, 0x88888888,
-         0xffff0000, 0xffffffff, 0xffff0000, 0xffffffff, 0xffff0000, 0xffffffff, 0xffff0000, 0xffffffff
-   };
-
 
-   if (EINA_TRUE != elm_image_memfile_set(image, mydata, 16 * sizeof(int), "png", NULL))
+   if (EINA_TRUE != elm_image_memfile_set(image, map, filesize, NULL, NULL))
      {
         ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__,__LINE__);
      }
@@ -105,13 +125,9 @@ START_TEST(utc_UIFW_elm_image_memfile_set_n_1)
 {
    image = elm_image_add(main_win);
    elm_image_file_set(image, "image/image_home.png", "icon");
-   int mydata[] = {
-         0x00000000, 0x88888888, 0x00000000, 0x88888888, 0x00000000, 0x88888888, 0x00000000, 0x88888888,
-         0xffff0000, 0xffffffff, 0xffff0000, 0xffffffff, 0xffff0000, 0xffffffff, 0xffff0000, 0xffffffff
-   };
    if ((EINA_FALSE == elm_image_memfile_set(NULL, NULL, 0, NULL,  NULL)) &&
          (EINA_FALSE == elm_image_memfile_set(image, NULL, 0, NULL,  NULL)) &&
-         (EINA_FALSE == elm_image_memfile_set(NULL, mydata, 0, NULL,  NULL))) {
+         (EINA_FALSE == elm_image_memfile_set(NULL, map, filesize, NULL,  NULL))) {
       printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__,__LINE__);
    }
    else