diff options
author | irungentoo <irungentoo@gmail.com> | 2015-03-12 12:18:52 -0400 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2015-03-12 12:18:52 -0400 |
commit | 1eca7b8e678d8afd886dad7f44b7dc09597238f5 (patch) | |
tree | c0cdd2036b4baad1e36cbfe59dc3442f61b3b119 /auto_tests | |
parent | 43fe6e71bd06dd4fcc2bb49662f56b493ed9b6fc (diff) |
Added simple status message test to tox_test.c
Diffstat (limited to 'auto_tests')
-rw-r--r-- | auto_tests/tox_test.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/auto_tests/tox_test.c b/auto_tests/tox_test.c index 7cae9da6..7069c4b7 100644 --- a/auto_tests/tox_test.c +++ b/auto_tests/tox_test.c | |||
@@ -56,6 +56,16 @@ void print_nickchange(Tox *m, uint32_t friendnumber, const uint8_t *string, size | |||
56 | ++name_changes; | 56 | ++name_changes; |
57 | } | 57 | } |
58 | 58 | ||
59 | uint32_t status_m_changes; | ||
60 | void print_status_m_change(Tox *tox, uint32_t friend_number, const uint8_t *message, size_t length, void *user_data) | ||
61 | { | ||
62 | if (*((uint32_t *)user_data) != 974536) | ||
63 | return; | ||
64 | |||
65 | if (length == sizeof("Installing Gentoo") && memcmp(message, "Installing Gentoo", sizeof("Installing Gentoo")) == 0) | ||
66 | ++status_m_changes; | ||
67 | } | ||
68 | |||
59 | uint32_t typing_changes; | 69 | uint32_t typing_changes; |
60 | 70 | ||
61 | void print_typingchange(Tox *m, uint32_t friendnumber, bool typing, void *userdata) | 71 | void print_typingchange(Tox *m, uint32_t friendnumber, bool typing, void *userdata) |
@@ -376,6 +386,29 @@ START_TEST(test_few_clients) | |||
376 | tox_friend_get_name(tox3, 0, temp_name, 0); | 386 | tox_friend_get_name(tox3, 0, temp_name, 0); |
377 | ck_assert_msg(memcmp(temp_name, "Gentoo", sizeof("Gentoo")) == 0, "Name not correct"); | 387 | ck_assert_msg(memcmp(temp_name, "Gentoo", sizeof("Gentoo")) == 0, "Name not correct"); |
378 | 388 | ||
389 | tox_callback_friend_status_message(tox3, print_status_m_change, &to_compare); | ||
390 | succ = tox_self_set_status_message(tox2, (uint8_t *)"Installing Gentoo", sizeof("Installing Gentoo"), &err_n); | ||
391 | ck_assert_msg(succ && err_n == TOX_ERR_SET_INFO_OK, "tox_self_set_status_message failed because %u\n", err_n); | ||
392 | |||
393 | while (1) { | ||
394 | status_m_changes = 0; | ||
395 | tox_iteration(tox1); | ||
396 | tox_iteration(tox2); | ||
397 | tox_iteration(tox3); | ||
398 | |||
399 | if (status_m_changes) | ||
400 | break; | ||
401 | |||
402 | c_sleep(50); | ||
403 | } | ||
404 | |||
405 | ck_assert_msg(tox_friend_get_status_message_size(tox3, 0, 0) == sizeof("Installing Gentoo"), | ||
406 | "status message length not correct"); | ||
407 | uint8_t temp_status_m[sizeof("Installing Gentoo")]; | ||
408 | tox_friend_get_status_message(tox3, 0, temp_status_m, 0); | ||
409 | ck_assert_msg(memcmp(temp_status_m, "Installing Gentoo", sizeof("Installing Gentoo")) == 0, | ||
410 | "status message not correct"); | ||
411 | |||
379 | tox_callback_friend_typing(tox2, &print_typingchange, &to_compare); | 412 | tox_callback_friend_typing(tox2, &print_typingchange, &to_compare); |
380 | tox_self_set_typing(tox3, 0, 1, 0); | 413 | tox_self_set_typing(tox3, 0, 1, 0); |
381 | 414 | ||
@@ -460,6 +493,8 @@ START_TEST(test_few_clients) | |||
460 | c_sleep(50); | 493 | c_sleep(50); |
461 | } | 494 | } |
462 | 495 | ||
496 | printf("Starting file transfer test.\n"); | ||
497 | |||
463 | file_accepted = file_size = file_recv = sendf_ok = size_recv = 0; | 498 | file_accepted = file_size = file_recv = sendf_ok = size_recv = 0; |
464 | long long unsigned int f_time = time(NULL); | 499 | long long unsigned int f_time = time(NULL); |
465 | tox_callback_file_receive_chunk(tox3, write_file, &to_compare); | 500 | tox_callback_file_receive_chunk(tox3, write_file, &to_compare); |