diff options
Diffstat (limited to 'auto_tests/tox_test.c')
-rw-r--r-- | auto_tests/tox_test.c | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/auto_tests/tox_test.c b/auto_tests/tox_test.c index d3f9472a..7cae9da6 100644 --- a/auto_tests/tox_test.c +++ b/auto_tests/tox_test.c | |||
@@ -202,6 +202,18 @@ void write_file(Tox *tox, uint32_t friendnumber, uint32_t filenumber, uint64_t p | |||
202 | } | 202 | } |
203 | } | 203 | } |
204 | 204 | ||
205 | unsigned int connected_t1; | ||
206 | void tox_connection_status(Tox *tox, TOX_CONNECTION connection_status, void *user_data) | ||
207 | { | ||
208 | if (*((uint32_t *)user_data) != 974536) | ||
209 | return; | ||
210 | |||
211 | if (connected_t1 && !connection_status) | ||
212 | ck_abort_msg("Tox went offline"); | ||
213 | |||
214 | connected_t1 = connection_status; | ||
215 | } | ||
216 | |||
205 | START_TEST(test_one) | 217 | START_TEST(test_one) |
206 | { | 218 | { |
207 | Tox *tox1 = tox_new(0, 0, 0, 0); | 219 | Tox *tox1 = tox_new(0, 0, 0, 0); |
@@ -286,6 +298,8 @@ START_TEST(test_few_clients) | |||
286 | } | 298 | } |
287 | 299 | ||
288 | uint32_t to_compare = 974536; | 300 | uint32_t to_compare = 974536; |
301 | connected_t1 = 0; | ||
302 | tox_callback_connection_status(tox1, tox_connection_status, &to_compare); | ||
289 | tox_callback_friend_request(tox2, accept_friend_request, &to_compare); | 303 | tox_callback_friend_request(tox2, accept_friend_request, &to_compare); |
290 | uint8_t address[TOX_ADDRESS_SIZE]; | 304 | uint8_t address[TOX_ADDRESS_SIZE]; |
291 | tox_self_get_address(tox2, address); | 305 | tox_self_get_address(tox2, address); |
@@ -299,20 +313,22 @@ START_TEST(test_few_clients) | |||
299 | tox_iteration(tox2); | 313 | tox_iteration(tox2); |
300 | tox_iteration(tox3); | 314 | tox_iteration(tox3); |
301 | 315 | ||
302 | if (tox_get_connection_status(tox1) && tox_get_connection_status(tox2) && tox_get_connection_status(tox3) && off) { | 316 | if (tox_get_connection_status(tox1) && tox_get_connection_status(tox2) && tox_get_connection_status(tox3)) { |
303 | printf("Toxes are online, took %llu seconds\n", time(NULL) - cur_time); | 317 | if (off) { |
304 | con_time = time(NULL); | 318 | printf("Toxes are online, took %llu seconds\n", time(NULL) - cur_time); |
305 | off = 0; | 319 | con_time = time(NULL); |
306 | } | 320 | off = 0; |
307 | 321 | } | |
308 | 322 | ||
309 | if (tox_friend_get_connection_status(tox2, 0, 0) == TOX_CONNECTION_UDP | 323 | if (tox_friend_get_connection_status(tox2, 0, 0) == TOX_CONNECTION_UDP |
310 | && tox_friend_get_connection_status(tox3, 0, 0) == TOX_CONNECTION_UDP) | 324 | && tox_friend_get_connection_status(tox3, 0, 0) == TOX_CONNECTION_UDP) |
311 | break; | 325 | break; |
326 | } | ||
312 | 327 | ||
313 | c_sleep(50); | 328 | c_sleep(50); |
314 | } | 329 | } |
315 | 330 | ||
331 | ck_assert_msg(connected_t1, "Tox1 isn't connected. %u", connected_t1); | ||
316 | printf("tox clients connected took %llu seconds\n", time(NULL) - con_time); | 332 | printf("tox clients connected took %llu seconds\n", time(NULL) - con_time); |
317 | to_compare = 974536; | 333 | to_compare = 974536; |
318 | tox_callback_friend_message(tox3, print_message, &to_compare); | 334 | tox_callback_friend_message(tox3, print_message, &to_compare); |