ecore_con: fix a wrong usage of server connection
authorJunsuChoi <jsuya.choi@samsung.com>
Tue, 12 Jun 2018 07:34:46 +0000 (16:34 +0900)
committerYeongjong Lee <yj34.lee@samsung.com>
Fri, 13 Jul 2018 10:51:56 +0000 (19:51 +0900)
Change-Id: I0f6993dffa85f94d171a30e787802ac272b998bf

TC/ecore/ecore_con/utc_ecore_con_server_flush.c

index 29c04fa334df56e151d6cb7707c33a6066fb8c82..cc632f76e995ecd8aefe0af16ad16c30f9b144ce 100644 (file)
@@ -6,12 +6,18 @@
 
 #include "../../utc_negative_unitest.h"
 
-#define HOSTNAME "yandex.ru"
+#define HOSTNAME "127.0.0.1"
 #define PORT 8080
 
 static Eina_Bool startup_status = EINA_FALSE;
 static Ecore_Con_Server *srv = NULL;
 
+Eina_Bool _quit_timer_cb(void* data)
+{
+   ecore_main_loop_quit();
+   return ECORE_CALLBACK_CANCEL;
+}
+
 /**
  * @addtogroup ecore_con
  * @{
@@ -25,13 +31,21 @@ static Ecore_Con_Server *srv = NULL;
 static void
 setup(void)
 {
+   startup_status = EINA_FALSE;
    printf(" ============ Startup ============ \n");
    if (ecore_con_init() > 0)
      {
-        srv = ecore_con_server_connect(ECORE_CON_REMOTE_TCP, HOSTNAME, PORT, NULL);
-        if (srv != NULL)
+        srv = ecore_con_server_add(ECORE_CON_REMOTE_TCP, HOSTNAME, PORT, NULL);
+        if (srv)
           {
-             startup_status = EINA_TRUE;
+             if (ecore_con_server_connect(ECORE_CON_REMOTE_TCP, HOSTNAME, PORT, NULL) == NULL)
+               {
+                  ecore_con_server_del(srv);
+               }
+             else
+               {
+                  startup_status = EINA_TRUE;
+               }
           }
      }
 }
@@ -65,9 +79,18 @@ START_TEST(utc_ecore_con_server_flush_p)
         ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed (startup was been executed unsuccessfully)..", __FILE__, __LINE__);
      }
 
+   if (ecore_timer_add(0.5, _quit_timer_cb, NULL) == NULL)
+     {
+        ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed (timer cannot be created for testing)..", __FILE__, __LINE__);
+     }
+
+   ecore_main_loop_begin();
+
    /*TODO: write a method that can check if pending data is flush*/
    ecore_con_server_flush(srv);
 
+   ecore_con_server_del(srv);
+
    printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
 }
 END_TEST
@@ -94,8 +117,14 @@ START_TEST(utc_ecore_con_server_flush_n)
         ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed (startup was been executed unsuccessfully)..", __FILE__, __LINE__);
      }
 
+   if (ecore_timer_add(0.5, _quit_timer_cb, NULL) == NULL)
+     {
+        ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed (timer cannot be created for testing)..", __FILE__, __LINE__);
+     }
+   ecore_main_loop_begin();
    UNITEST_FUNC_NEG(ecore_con_server_flush, srv);
 
+   ecore_con_server_del(srv);
    printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
 }
 END_TEST