summaryrefslogtreecommitdiff
path: root/auto_tests/tox_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'auto_tests/tox_test.c')
-rw-r--r--auto_tests/tox_test.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/auto_tests/tox_test.c b/auto_tests/tox_test.c
index 06e8e257..def9e5df 100644
--- a/auto_tests/tox_test.c
+++ b/auto_tests/tox_test.c
@@ -49,6 +49,19 @@ void print_nickchange(Tox *m, int friendnumber, uint8_t *string, uint16_t length
49 ++name_changes; 49 ++name_changes;
50} 50}
51 51
52uint32_t typing_changes;
53
54void print_typingchange(Tox *m, int friendnumber, int typing, void *userdata)
55{
56 if (*((uint32_t *)userdata) != 974536)
57 return;
58
59 if (!typing)
60 typing_changes = 1;
61 else
62 typing_changes = 2;
63}
64
52START_TEST(test_few_clients) 65START_TEST(test_few_clients)
53{ 66{
54 long long unsigned int cur_time = time(NULL); 67 long long unsigned int cur_time = time(NULL);
@@ -118,6 +131,43 @@ START_TEST(test_few_clients)
118 uint8_t temp_name[sizeof("Gentoo")]; 131 uint8_t temp_name[sizeof("Gentoo")];
119 tox_get_name(tox3, 0, temp_name); 132 tox_get_name(tox3, 0, temp_name);
120 ck_assert_msg(memcmp(temp_name, "Gentoo", sizeof("Gentoo")) == 0, "Name not correct"); 133 ck_assert_msg(memcmp(temp_name, "Gentoo", sizeof("Gentoo")) == 0, "Name not correct");
134
135 tox_callback_typing_change(tox2, &print_typingchange, &to_compare);
136 tox_set_user_is_typing(tox3, 0, 1);
137
138 while (1) {
139 typing_changes = 0;
140 tox_do(tox1);
141 tox_do(tox2);
142 tox_do(tox3);
143
144
145 if (typing_changes == 2)
146 break;
147 else
148 ck_assert_msg(typing_changes == 0, "Typing fail");
149
150 c_sleep(50);
151 }
152
153 ck_assert_msg(tox_get_is_typing(tox2, 0) == 1, "Typing fail");
154 tox_set_user_is_typing(tox3, 0, 0);
155
156 while (1) {
157 typing_changes = 0;
158 tox_do(tox1);
159 tox_do(tox2);
160 tox_do(tox3);
161
162 if (typing_changes == 1)
163 break;
164 else
165 ck_assert_msg(typing_changes == 0, "Typing fail");
166
167 c_sleep(50);
168 }
169
170 ck_assert_msg(tox_get_is_typing(tox2, 0) == 0, "Typing fail");
121 printf("test_few_clients succeeded, took %llu seconds\n", time(NULL) - cur_time); 171 printf("test_few_clients succeeded, took %llu seconds\n", time(NULL) - cur_time);
122} 172}
123END_TEST 173END_TEST