summaryrefslogtreecommitdiff
path: root/src/tests/ecore_con
diff options
context:
space:
mode:
authorSrivardhan Hebbar <sri.hebbar@samsung.com>2015-04-22 14:52:28 +0200
committerCedric BAIL <cedric@osg.samsung.com>2015-04-22 15:10:20 +0200
commitf4453bc00b9c27eb4d32b683dde9af000674dd9b (patch)
tree84dcdb156b4205f35bb22a15ffedc2e06e643e2b /src/tests/ecore_con
parent48db81cfb5e01e7993afa65b649de4e2c043b07d (diff)
ecore_con: add another test case to cover remaining functions in ecore_con_eet.
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>
Diffstat (limited to 'src/tests/ecore_con')
-rw-r--r--src/tests/ecore_con/ecore_con_test_ecore_con_eet.c132
1 files changed, 109 insertions, 23 deletions
diff --git a/src/tests/ecore_con/ecore_con_test_ecore_con_eet.c b/src/tests/ecore_con/ecore_con_test_ecore_con_eet.c
index d981a93..a9ce4b4 100644
--- a/src/tests/ecore_con/ecore_con_test_ecore_con_eet.c
+++ b/src/tests/ecore_con/ecore_con_test_ecore_con_eet.c
@@ -43,7 +43,7 @@ _ece_test_descriptor_shutdown(void)
43 eet_data_descriptor_free(_ece_test_descriptor); 43 eet_data_descriptor_free(_ece_test_descriptor);
44} 44}
45 45
46Eina_Bool 46static Eina_Bool
47_eet_client_discnct_cb(void *data EINA_UNUSED, Ecore_Con_Reply *reply EINA_UNUSED, Ecore_Con_Client *conn EINA_UNUSED) 47_eet_client_discnct_cb(void *data EINA_UNUSED, Ecore_Con_Reply *reply EINA_UNUSED, Ecore_Con_Client *conn EINA_UNUSED)
48{ 48{
49 ecore_main_loop_quit(); 49 ecore_main_loop_quit();
@@ -51,7 +51,7 @@ _eet_client_discnct_cb(void *data EINA_UNUSED, Ecore_Con_Reply *reply EINA_UNUSE
51 return EINA_FALSE; 51 return EINA_FALSE;
52} 52}
53 53
54Eina_Bool 54static Eina_Bool
55_eet_client_cnct_cb(void *data EINA_UNUSED, Ecore_Con_Reply *reply, Ecore_Con_Client *conn EINA_UNUSED) 55_eet_client_cnct_cb(void *data EINA_UNUSED, Ecore_Con_Reply *reply, Ecore_Con_Client *conn EINA_UNUSED)
56{ 56{
57 char *ec_eet_data; 57 char *ec_eet_data;
@@ -79,36 +79,45 @@ _eet_data_cb(void *data EINA_UNUSED, Ecore_Con_Reply *reply, const char *protoco
79 strlen(toSend)); 79 strlen(toSend));
80} 80}
81 81
82Eina_Bool 82static Eina_Bool
83_eet_svr_discnct_cb(void *data EINA_UNUSED, Ecore_Con_Reply *reply EINA_UNUSED, Ecore_Con_Client *conn EINA_UNUSED) 83_eet_svr_cnct_cb(void *data, Ecore_Con_Reply *reply, Ecore_Con_Client *conn EINA_UNUSED)
84{
85 ecore_main_loop_quit();
86 return EINA_FALSE;
87}
88
89Eina_Bool
90_eet_svr_cnct_cb(void *data EINA_UNUSED, Ecore_Con_Reply *reply, Ecore_Con_Client *conn EINA_UNUSED)
91{ 84{
85 int *i = data;
92 ECE_Test toSend = {1, CLI_MSG}; 86 ECE_Test toSend = {1, CLI_MSG};
87 char rawMsg[] = CLI_MSG;
88
89 if (*i)
90 ecore_con_eet_send(reply, TEST_STREAM, &toSend);
91 else
92 ecore_con_eet_raw_send(reply, TEST_STREAM, "message", rawMsg,
93 strlen(rawMsg));
93 94
94 ecore_con_eet_send(reply, TEST_STREAM, &toSend);
95 return EINA_TRUE; 95 return EINA_TRUE;
96} 96}
97 97
98static void 98static void
99_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) 99_eet_raw_data_cb(void *data, Ecore_Con_Reply *reply, const char *protocol_name EINA_UNUSED, const char *section, void *value, size_t length)
100{ 100{
101 Ecore_Con_Server *cl = data;
102 Ecore_Con_Eet *ece_cl = ecore_con_eet_reply(reply);
103
101 fprintf(stderr, "Section: %s\n", section); 104 fprintf(stderr, "Section: %s\n", section);
102 fprintf(stderr, "Value: %s\n", (char *) value); 105 fprintf(stderr, "Value: %s\n", (char *) value);
103 fail_if(strncmp((char *) value, SRV_MSG, length)); 106 fail_if(strncmp((char *) value, SRV_MSG, length));
104 107
105 ecore_main_loop_quit(); 108 ecore_con_eet_raw_data_callback_del(ece_cl, TEST_STREAM);
109 ecore_con_eet_server_connect_callback_del(ece_cl, _eet_svr_cnct_cb, NULL);
110
111 ecore_con_eet_server_free(ece_cl);
112 ecore_con_server_del(cl);
106} 113}
107 114
108START_TEST(ecore_con_test_ecore_con_eet_svr_cl) 115START_TEST(ecore_con_test_ecore_con_eet_svr_cl)
109{ 116{
110 Ecore_Con_Eet *ece_svr, *ece_cl; 117 Ecore_Con_Eet *ece_svr, *ece_cl;
111 Ecore_Con_Server *svr, *cl; 118 Ecore_Con_Server *svr, *cl;
119 int *cb_data = (int *) malloc(sizeof(int));
120 *cb_data = 1;
112 121
113 eina_init(); 122 eina_init();
114 eet_init(); 123 eet_init();
@@ -141,17 +150,12 @@ START_TEST(ecore_con_test_ecore_con_eet_svr_cl)
141 150
142 ecore_con_eet_register(ece_cl, TEST_STREAM, _ece_test_descriptor); 151 ecore_con_eet_register(ece_cl, TEST_STREAM, _ece_test_descriptor);
143 ecore_con_eet_raw_data_callback_add(ece_cl, TEST_STREAM, 152 ecore_con_eet_raw_data_callback_add(ece_cl, TEST_STREAM,
144 _eet_raw_data_cb, NULL); 153 _eet_raw_data_cb, cl);
145 ecore_con_eet_server_connect_callback_add(ece_cl, _eet_svr_cnct_cb, NULL); 154 ecore_con_eet_server_connect_callback_add(ece_cl, _eet_svr_cnct_cb,
146 ecore_con_eet_server_disconnect_callback_add(ece_cl, _eet_svr_discnct_cb, 155 cb_data);
147 NULL);
148 156
149 ecore_main_loop_begin(); 157 ecore_main_loop_begin();
150 158
151 ecore_con_eet_raw_data_callback_del(ece_cl, TEST_STREAM);
152 ecore_con_eet_server_connect_callback_del(ece_cl, _eet_svr_cnct_cb, NULL);
153 ecore_con_eet_server_disconnect_callback_del(ece_cl, _eet_svr_discnct_cb,
154 NULL);
155 159
156 ecore_con_eet_data_callback_del(ece_svr, TEST_STREAM); 160 ecore_con_eet_data_callback_del(ece_svr, TEST_STREAM);
157 ecore_con_eet_client_connect_callback_del(ece_svr, _eet_client_cnct_cb, 161 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)
159 ecore_con_eet_client_disconnect_callback_del(ece_svr, 163 ecore_con_eet_client_disconnect_callback_del(ece_svr,
160 _eet_client_discnct_cb, NULL); 164 _eet_client_discnct_cb, NULL);
161 165
166 free(cb_data);
167 ecore_con_eet_server_free(ece_svr);
162 _ece_test_descriptor_shutdown(); 168 _ece_test_descriptor_shutdown();
163 ecore_con_server_del(cl);
164 ecore_con_server_del(svr); 169 ecore_con_server_del(svr);
165 ecore_con_shutdown(); 170 ecore_con_shutdown();
166 eet_shutdown(); 171 eet_shutdown();
167 eina_shutdown(); 172 eina_shutdown();
168} 173}
169END_TEST 174END_TEST
175
176static Eina_Bool
177_eet_svr_discnct_cb(void *data EINA_UNUSED, Ecore_Con_Reply *reply EINA_UNUSED, Ecore_Con_Client *conn EINA_UNUSED)
178{
179 ecore_main_loop_quit();
180 return EINA_FALSE;
181}
182
183static void
184_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)
185{
186 Ecore_Con_Server *svr = data;
187 Ecore_Con_Eet *ece_svr = ecore_con_eet_reply(reply);
188
189 fprintf(stderr, "Section: %s\n", section);
190 fprintf(stderr, "Value: %s\n", (char *) value);
191 fail_if(strncmp((char *) value, CLI_MSG, length));
192
193 ecore_con_eet_raw_data_callback_del(ece_svr, TEST_STREAM);
194
195 ecore_con_eet_server_free(ece_svr);
196 ecore_con_server_del(svr);
197}
198
199START_TEST(ecore_con_test_ecore_con_eet_svr_del)
200{
201 Ecore_Con_Eet *ece_svr, *ece_cl;
202 Ecore_Con_Server *svr, *cl;
203 int *cb_data = (int *) malloc(sizeof(int));
204 *cb_data = 0;
205
206 eina_init();
207 eet_init();
208 ecore_con_init();
209 _ece_test_descriptor_init();
210
211 svr = ecore_con_server_add(ECORE_CON_REMOTE_TCP, "127.0.0.1",
212 8080, NULL);
213 fail_unless(svr);
214
215 ece_svr = ecore_con_eet_server_new(svr);
216 fail_unless(ece_svr);
217
218 ecore_con_eet_data_set(ece_svr, eet_data);
219
220 ecore_con_eet_register(ece_svr, TEST_STREAM, _ece_test_descriptor);
221 ecore_con_eet_raw_data_callback_add(ece_svr, TEST_STREAM,
222 _eet_svr_raw_data_cb, svr);
223
224 cl = ecore_con_server_connect(ECORE_CON_REMOTE_TCP, "127.0.0.1",
225 8080, NULL);
226 fail_unless (cl);
227
228 ece_cl = ecore_con_eet_client_new(cl);
229 fail_unless (ece_cl);
230
231 ecore_con_eet_register(ece_cl, TEST_STREAM, _ece_test_descriptor);
232 ecore_con_eet_server_connect_callback_add(ece_cl, _eet_svr_cnct_cb,
233 cb_data);
234 ecore_con_eet_server_disconnect_callback_add(ece_cl,
235 _eet_svr_discnct_cb, NULL);
236
237 ecore_main_loop_begin();
238
239
240 ecore_con_eet_server_connect_callback_del(ece_svr, _eet_client_cnct_cb,
241 NULL);
242 ecore_con_eet_server_disconnect_callback_del(ece_svr,
243 _eet_client_discnct_cb, NULL);
244
245 free(cb_data);
246 ecore_con_eet_server_free(ece_cl);
247 _ece_test_descriptor_shutdown();
248 ecore_con_server_del(cl);
249 ecore_con_shutdown();
250 eet_shutdown();
251 eina_shutdown();
252}
253END_TEST
254
170void ecore_con_test_ecore_con_eet(TCase *tc) 255void ecore_con_test_ecore_con_eet(TCase *tc)
171{ 256{
172 tcase_add_test(tc, ecore_con_test_ecore_con_eet_svr_cl); 257 tcase_add_test(tc, ecore_con_test_ecore_con_eet_svr_cl);
258 tcase_add_test(tc, ecore_con_test_ecore_con_eet_svr_del);
173} 259}