ecore_con: add another test case to cover remaining functions in ecore_con_eet.
authorSrivardhan Hebbar <sri.hebbar@samsung.com>
Wed, 22 Apr 2015 12:52:28 +0000 (14:52 +0200)
committerCedric BAIL <cedric@osg.samsung.com>
Wed, 22 Apr 2015 13:10:20 +0000 (15:10 +0200)
Summary:
When I checked the Jenkins report, I saw few of the functions were left off. So added another case and modified the existing case to cover all the functions or ecore_con_eet.

Signed-off-by: Srivardhan Hebbar <sri.hebbar@samsung.com>
Reviewers: cedric

Reviewed By: cedric

Subscribers: cedric

Differential Revision: https://phab.enlightenment.org/D2383

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
src/tests/ecore_con/ecore_con_test_ecore_con_eet.c

index d981a9349a86fe65f29296c288434b9d1704d03d..a9ce4b40309cb893c23ba0a391a167304b763355 100644 (file)
@@ -43,7 +43,7 @@ _ece_test_descriptor_shutdown(void)
    eet_data_descriptor_free(_ece_test_descriptor);
 }
 
-Eina_Bool
+static Eina_Bool
 _eet_client_discnct_cb(void *data EINA_UNUSED, Ecore_Con_Reply *reply EINA_UNUSED, Ecore_Con_Client *conn EINA_UNUSED)
 {
    ecore_main_loop_quit();
@@ -51,7 +51,7 @@ _eet_client_discnct_cb(void *data EINA_UNUSED, Ecore_Con_Reply *reply EINA_UNUSE
    return EINA_FALSE;
 }
 
-Eina_Bool
+static Eina_Bool
 _eet_client_cnct_cb(void *data EINA_UNUSED, Ecore_Con_Reply *reply, Ecore_Con_Client *conn EINA_UNUSED)
 {
    char *ec_eet_data;
@@ -79,36 +79,45 @@ _eet_data_cb(void *data EINA_UNUSED, Ecore_Con_Reply *reply, const char *protoco
                           strlen(toSend));
 }
 
-Eina_Bool
-_eet_svr_discnct_cb(void *data EINA_UNUSED, Ecore_Con_Reply *reply EINA_UNUSED, Ecore_Con_Client *conn EINA_UNUSED)
-{
-   ecore_main_loop_quit();
-   return EINA_FALSE;
-}
-
-Eina_Bool
-_eet_svr_cnct_cb(void *data EINA_UNUSED, Ecore_Con_Reply *reply, Ecore_Con_Client *conn EINA_UNUSED)
+static Eina_Bool
+_eet_svr_cnct_cb(void *data, Ecore_Con_Reply *reply, Ecore_Con_Client *conn EINA_UNUSED)
 {
+   int *i = data;
    ECE_Test toSend = {1, CLI_MSG};
+   char rawMsg[] = CLI_MSG;
+
+   if (*i)
+     ecore_con_eet_send(reply, TEST_STREAM, &toSend);
+   else
+     ecore_con_eet_raw_send(reply, TEST_STREAM, "message", rawMsg,
+                            strlen(rawMsg));
 
-   ecore_con_eet_send(reply, TEST_STREAM, &toSend);
    return EINA_TRUE;
 }
 
 static void
-_eet_raw_data_cb(void *data EINA_UNUSED, Ecore_Con_Reply *reply EINA_UNUSED, const char *protocol_name EINA_UNUSED, const char *section, void *value, size_t length)
+_eet_raw_data_cb(void *data, Ecore_Con_Reply *reply, const char *protocol_name EINA_UNUSED, const char *section, void *value, size_t length)
 {
+   Ecore_Con_Server *cl = data;
+   Ecore_Con_Eet *ece_cl = ecore_con_eet_reply(reply);
+
    fprintf(stderr, "Section: %s\n", section);
    fprintf(stderr, "Value: %s\n", (char *) value);
    fail_if(strncmp((char *) value, SRV_MSG, length));
 
-   ecore_main_loop_quit();
+   ecore_con_eet_raw_data_callback_del(ece_cl, TEST_STREAM);
+   ecore_con_eet_server_connect_callback_del(ece_cl, _eet_svr_cnct_cb, NULL);
+
+   ecore_con_eet_server_free(ece_cl);
+   ecore_con_server_del(cl);
 }
 
 START_TEST(ecore_con_test_ecore_con_eet_svr_cl)
 {
    Ecore_Con_Eet *ece_svr, *ece_cl;
    Ecore_Con_Server *svr, *cl;
+   int *cb_data = (int *) malloc(sizeof(int));
+   *cb_data = 1;
 
    eina_init();
    eet_init();
@@ -141,17 +150,12 @@ START_TEST(ecore_con_test_ecore_con_eet_svr_cl)
 
    ecore_con_eet_register(ece_cl, TEST_STREAM, _ece_test_descriptor);
    ecore_con_eet_raw_data_callback_add(ece_cl, TEST_STREAM,
-                                       _eet_raw_data_cb, NULL);
-   ecore_con_eet_server_connect_callback_add(ece_cl, _eet_svr_cnct_cb, NULL);
-   ecore_con_eet_server_disconnect_callback_add(ece_cl, _eet_svr_discnct_cb,
-                                                NULL);
+                                       _eet_raw_data_cb, cl);
+   ecore_con_eet_server_connect_callback_add(ece_cl, _eet_svr_cnct_cb,
+                                             cb_data);
 
    ecore_main_loop_begin();
 
-   ecore_con_eet_raw_data_callback_del(ece_cl, TEST_STREAM);
-   ecore_con_eet_server_connect_callback_del(ece_cl, _eet_svr_cnct_cb, NULL);
-   ecore_con_eet_server_disconnect_callback_del(ece_cl, _eet_svr_discnct_cb,
-                                                NULL);
 
    ecore_con_eet_data_callback_del(ece_svr, TEST_STREAM);
    ecore_con_eet_client_connect_callback_del(ece_svr, _eet_client_cnct_cb,
@@ -159,15 +163,97 @@ START_TEST(ecore_con_test_ecore_con_eet_svr_cl)
    ecore_con_eet_client_disconnect_callback_del(ece_svr,
                                                 _eet_client_discnct_cb, NULL);
 
+   free(cb_data);
+   ecore_con_eet_server_free(ece_svr);
    _ece_test_descriptor_shutdown();
-   ecore_con_server_del(cl);
    ecore_con_server_del(svr);
    ecore_con_shutdown();
    eet_shutdown();
    eina_shutdown();
 }
 END_TEST
+
+static Eina_Bool
+_eet_svr_discnct_cb(void *data EINA_UNUSED, Ecore_Con_Reply *reply EINA_UNUSED, Ecore_Con_Client *conn EINA_UNUSED)
+{
+   ecore_main_loop_quit();
+   return EINA_FALSE;
+}
+
+static void
+_eet_svr_raw_data_cb(void *data, Ecore_Con_Reply *reply, const char *protocol_name EINA_UNUSED, const char *section, void *value, size_t length)
+{
+   Ecore_Con_Server *svr = data;
+   Ecore_Con_Eet *ece_svr = ecore_con_eet_reply(reply);
+
+   fprintf(stderr, "Section: %s\n", section);
+   fprintf(stderr, "Value: %s\n", (char *) value);
+   fail_if(strncmp((char *) value, CLI_MSG, length));
+
+   ecore_con_eet_raw_data_callback_del(ece_svr, TEST_STREAM);
+
+   ecore_con_eet_server_free(ece_svr);
+   ecore_con_server_del(svr);
+}
+
+START_TEST(ecore_con_test_ecore_con_eet_svr_del)
+{
+   Ecore_Con_Eet *ece_svr, *ece_cl;
+   Ecore_Con_Server *svr, *cl;
+   int *cb_data = (int *) malloc(sizeof(int));
+   *cb_data = 0;
+
+   eina_init();
+   eet_init();
+   ecore_con_init();
+   _ece_test_descriptor_init();
+
+   svr = ecore_con_server_add(ECORE_CON_REMOTE_TCP, "127.0.0.1",
+                              8080, NULL);
+   fail_unless(svr);
+
+   ece_svr = ecore_con_eet_server_new(svr);
+   fail_unless(ece_svr);
+
+   ecore_con_eet_data_set(ece_svr, eet_data);
+
+   ecore_con_eet_register(ece_svr, TEST_STREAM, _ece_test_descriptor);
+   ecore_con_eet_raw_data_callback_add(ece_svr, TEST_STREAM,
+                                  _eet_svr_raw_data_cb, svr);
+
+   cl = ecore_con_server_connect(ECORE_CON_REMOTE_TCP, "127.0.0.1",
+                                 8080, NULL);
+   fail_unless (cl);
+
+   ece_cl = ecore_con_eet_client_new(cl);
+   fail_unless (ece_cl);
+
+   ecore_con_eet_register(ece_cl, TEST_STREAM, _ece_test_descriptor);
+   ecore_con_eet_server_connect_callback_add(ece_cl, _eet_svr_cnct_cb,
+                                             cb_data);
+   ecore_con_eet_server_disconnect_callback_add(ece_cl,
+                                                _eet_svr_discnct_cb, NULL);
+
+   ecore_main_loop_begin();
+
+
+   ecore_con_eet_server_connect_callback_del(ece_svr, _eet_client_cnct_cb,
+                                             NULL);
+   ecore_con_eet_server_disconnect_callback_del(ece_svr,
+                                                _eet_client_discnct_cb, NULL);
+
+   free(cb_data);
+   ecore_con_eet_server_free(ece_cl);
+   _ece_test_descriptor_shutdown();
+   ecore_con_server_del(cl);
+   ecore_con_shutdown();
+   eet_shutdown();
+   eina_shutdown();
+}
+END_TEST
+
 void ecore_con_test_ecore_con_eet(TCase *tc)
 {
    tcase_add_test(tc, ecore_con_test_ecore_con_eet_svr_cl);
+   tcase_add_test(tc, ecore_con_test_ecore_con_eet_svr_del);
 }