Fixed evas_object_smart_data_set(and *_get) testcases
authorManoj Kumar <manoj.km@samsung.com>
Mon, 30 Jul 2018 06:00:28 +0000 (11:30 +0530)
committerYeongjong Lee <yj34.lee@samsung.com>
Mon, 6 Aug 2018 03:06:15 +0000 (12:06 +0900)
Change-Id: I45f28d8278e30c47f3d2b294fdfcf5025055f135

TC/evas/canvas/evas_object_smart/utc_evas_object_smart_data_get.c
TC/evas/canvas/evas_object_smart/utc_evas_object_smart_data_set.c

index 5d25a9f5070ab1333251847ac9242504523263b2..412aa7e641baec688d5633968d34f8584cf99f51 100644 (file)
@@ -3,6 +3,18 @@
 #include <Ecore_Evas.h>
 #include "../../../utc_negative_unitest.h"
 
+static void *data=NULL;
+
+static void _smart_add(Evas_Object *obj)
+{
+   data = (void *)malloc(2);
+   if (!data)
+       {
+          ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Memory is not allocated..", __FILE__, __LINE__);
+       }
+   evas_object_smart_data_set(obj, data);
+}
+
 /**
  * @addtogroup evas_object_smart
  * @{
@@ -35,8 +47,8 @@ teardown(void)
  *
  * @procedure
  * @step 1 Create new Evas object.
- * @step 2 Create new table Evas_Object.
- * @step 3 Set data of the table pointer to newly allocated buffer
+ * @step 2 Create new smart Evas_Object.
+ * @step 3 Set data of the smart object to newly allocated buffer
  * @step 4 Get the data from the box and compare it with data, which was set.
  *
  * @passcondition Returned pointer and pointer that was set are equal.
@@ -44,31 +56,30 @@ teardown(void)
  */
 START_TEST(utc_evas_object_smart_data_get_p)
 {
-   Ecore_Evas *ee = ecore_evas_buffer_new(320, 240);
-   Evas *evas = ecore_evas_get(ee);
-   Evas_Object *obj = evas_object_table_add(evas);
-   void *data = (void *)malloc(2);
-
-   if (!data)
+   Evas *evas = evas_new();
+   if (!evas)
      {
-        ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Memmory is not allocated..", __FILE__, __LINE__);
-        return;
+        ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Evas object is not created..", __FILE__, __LINE__);
      }
+   Evas_Smart_Class sc = EVAS_SMART_CLASS_INIT_NAME_VERSION("utc_smart_data_get");
+   sc.add = _smart_add;
+   Evas_Smart *smart = evas_smart_class_new(&sc);
+   Evas_Object *obj = evas_object_smart_add(evas, smart);
    if (!obj)
      {
-        free (data);
-        ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Evas_Object is not created..", __FILE__, __LINE__);
-        return;
+        evas_free(evas);
+        free(data);
+        ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Smart Evas_Object is not created..", __FILE__, __LINE__);
      }
-   evas_object_smart_data_set(obj, data);
    if (data != evas_object_smart_data_get(obj))
      {
-        free (data);
+        evas_free(evas);
+        free(data);
         ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
-        return;
      }
 
-   free (data);
+   evas_free(evas);
+   free(data);
    printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
 }
 END_TEST
@@ -92,7 +103,6 @@ START_TEST(utc_evas_object_smart_data_get_n)
    if (UNITEST_FUNC_NEG_RET(NULL, evas_object_smart_data_get, NULL) == TEST_FAIL)
      {
         ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
-        return;
      }
    printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
 }
index 250d0f74f9ed218ddcdb784252cf9e1e209ca8b8..678de55f2492dccf8c4d73ee61ea2365f14167a6 100644 (file)
@@ -3,6 +3,28 @@
 #include <Ecore_Evas.h>
 #include "../../../utc_negative_unitest.h"
 
+static void *data=NULL;
+
+static void _smart_add(Evas_Object *obj)
+{
+   data = (void *)malloc(2);
+   if (!data)
+       {
+          ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Memory is not allocated..", __FILE__, __LINE__);
+       }
+   evas_object_smart_data_set(obj, data);
+}
+
+static void _smart_add_negative(Evas_Object *obj)
+{
+   data = (void *)malloc(2);
+   if (!data)
+       {
+          ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Memory is not allocated..", __FILE__, __LINE__);
+       }
+   UNITEST_FUNC_NEG(evas_object_smart_data_set, obj, data);
+}
+
 /**
  * @addtogroup evas_object_smart
  * @{
@@ -36,8 +58,8 @@ teardown(void)
  *
  * @procedure
  * @step 1 Create new Evas object.
- * @step 2 Create new table Evas_Object.
- * @step 3 Set data of the table - pointer to local integer variable.
+ * @step 2 Create new smart Evas_Object.
+ * @step 3 Set data of the smart object to newly allocated buffer
  * @step 4 Get the data from the box and compare it with data, which was set.
  *
  * @passcondition Function sets data successfully, pointer returned by 'evas_object_smart_data_get'
@@ -46,30 +68,29 @@ teardown(void)
  */
 START_TEST(utc_evas_object_smart_data_set_p)
 {
-   Ecore_Evas *ee = ecore_evas_buffer_new(320, 240);
-   Evas *evas = ecore_evas_get(ee);
-   Evas_Object *obj = evas_object_table_add(evas);
-   void *data = (void *)malloc(2);
-
-   if (!data)
+   Evas *evas = evas_new();
+   if (!evas)
      {
-        ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Memmory is not allocated..", __FILE__, __LINE__);
-        return;
+        ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Evas object is not created..", __FILE__, __LINE__);
      }
+   Evas_Smart_Class sc = EVAS_SMART_CLASS_INIT_NAME_VERSION("smart_data_set");
+   sc.add = _smart_add;
+   Evas_Smart *smart = evas_smart_class_new(&sc);
+   Evas_Object *obj = evas_object_smart_add(evas, smart);
    if (!obj)
      {
+        evas_free(evas);
         free(data);
-        ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Evas_Object is not created..", __FILE__, __LINE__);
-        return;
+        ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Smart Evas_Object is not created..", __FILE__, __LINE__);
      }
-   evas_object_smart_data_set(obj, data);
    if (data != evas_object_smart_data_get(obj))
      {
+        evas_free(evas);
         free(data);
         ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
-        return;
      }
 
+   evas_free(evas);
    free(data);
    printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
 }
@@ -81,12 +102,12 @@ END_TEST
  * @objective Negative test case checks if function doesn't cause segmentation fault
  * if it is called with NULL instead of any argument.
  * @n Input Data:
- * @li pointer to table Evas_Object;
+ * @li pointer to smart Evas_Object;
  * @li pointer to user data to store in the object.
  *
  * @procedure
  * @step 1 Create new Evas object.
- * @step 2 Create new table Evas_Object.
+ * @step 2 Create new smart Evas_Object.
  * @step 3 Call function 2 times and pass (in turn) NULL instead of one from valid arguments.
  *
  * @passcondition Function doesn't cause segmentation fault.
@@ -94,25 +115,23 @@ END_TEST
  */
 START_TEST(utc_evas_object_smart_data_set_n)
 {
-   Ecore_Evas *ee = ecore_evas_buffer_new(1, 1);
-   Evas *evas = ecore_evas_get(ee);
-   Evas_Object *obj = evas_object_table_add(evas);
-   void *data = (void *)malloc(2);
-
-   if (!data)
-     {
-        ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Memmory is not allocated..", __FILE__, __LINE__);
-        return;
-     }
-   if (!obj)
-     {
-        free(data);
-        ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Evas_Object is not created..", __FILE__, __LINE__);
-        return;
-     }
-
-   UNITEST_FUNC_NEG(evas_object_smart_data_set, obj, data);
-
+       Evas *evas = evas_new();
+       if (!evas)
+         {
+                ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Evas object is not created..", __FILE__, __LINE__);
+         }
+       Evas_Smart_Class sc = EVAS_SMART_CLASS_INIT_NAME_VERSION("smart_data_set_n");
+       sc.add = _smart_add_negative;
+       Evas_Smart *smart = evas_smart_class_new(&sc);
+       Evas_Object *obj = evas_object_smart_add(evas, smart);
+       if (!obj)
+         {
+                evas_free(evas);
+                free(data);
+                ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. Smart Evas_Object is not created..", __FILE__, __LINE__);
+         }
+   
+   evas_free(evas);
    free(data);
    printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
 }