diff options
Diffstat (limited to 'auto_tests')
-rw-r--r-- | auto_tests/tox_test.c | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/auto_tests/tox_test.c b/auto_tests/tox_test.c index d08fc125..14510ea4 100644 --- a/auto_tests/tox_test.c +++ b/auto_tests/tox_test.c | |||
@@ -1172,26 +1172,26 @@ static void g_accept_friend_request(Tox *m, const uint8_t *public_key, const uin | |||
1172 | static Tox *invite_tox; | 1172 | static Tox *invite_tox; |
1173 | static unsigned int invite_counter; | 1173 | static unsigned int invite_counter; |
1174 | 1174 | ||
1175 | static void print_group_invite_callback(Tox *tox, int32_t friendnumber, uint8_t type, const uint8_t *data, | 1175 | static void print_group_invite_callback(Tox *tox, uint32_t friendnumber, TOX_CONFERENCE_TYPE type, const uint8_t *data, |
1176 | uint16_t length, | 1176 | size_t length, |
1177 | void *userdata) | 1177 | void *userdata) |
1178 | { | 1178 | { |
1179 | if (*((uint32_t *)userdata) != 234212) { | 1179 | if (*((uint32_t *)userdata) != 234212) { |
1180 | return; | 1180 | return; |
1181 | } | 1181 | } |
1182 | 1182 | ||
1183 | if (type != TOX_GROUPCHAT_TYPE_TEXT) { | 1183 | if (type != TOX_CONFERENCE_TYPE_TEXT) { |
1184 | return; | 1184 | return; |
1185 | } | 1185 | } |
1186 | 1186 | ||
1187 | int g_num; | 1187 | int g_num; |
1188 | 1188 | ||
1189 | if ((g_num = tox_join_groupchat(tox, friendnumber, data, length)) == -1) { | 1189 | if ((g_num = tox_conference_join(tox, friendnumber, data, length, NULL)) == -1) { |
1190 | return; | 1190 | return; |
1191 | } | 1191 | } |
1192 | 1192 | ||
1193 | ck_assert_msg(g_num == 0, "Group number was not 0"); | 1193 | ck_assert_msg(g_num == 0, "Group number was not 0"); |
1194 | ck_assert_msg(tox_join_groupchat(tox, friendnumber, data, length) == -1, | 1194 | ck_assert_msg(tox_conference_join(tox, friendnumber, data, length, NULL) == -1, |
1195 | "Joining groupchat twice should be impossible."); | 1195 | "Joining groupchat twice should be impossible."); |
1196 | 1196 | ||
1197 | invite_tox = tox; | 1197 | invite_tox = tox; |
@@ -1200,7 +1200,8 @@ static void print_group_invite_callback(Tox *tox, int32_t friendnumber, uint8_t | |||
1200 | 1200 | ||
1201 | static unsigned int num_recv; | 1201 | static unsigned int num_recv; |
1202 | 1202 | ||
1203 | static void print_group_message(Tox *tox, int groupnumber, int peernumber, const uint8_t *message, uint16_t length, | 1203 | static void print_group_message(Tox *tox, uint32_t groupnumber, uint32_t peernumber, TOX_MESSAGE_TYPE type, |
1204 | const uint8_t *message, size_t length, | ||
1204 | void *userdata) | 1205 | void *userdata) |
1205 | { | 1206 | { |
1206 | if (*((uint32_t *)userdata) != 234212) { | 1207 | if (*((uint32_t *)userdata) != 234212) { |
@@ -1226,7 +1227,7 @@ group_test_restart: | |||
1226 | toxes[i] = tox_new(0, 0); | 1227 | toxes[i] = tox_new(0, 0); |
1227 | ck_assert_msg(toxes[i] != 0, "Failed to create tox instances %u", i); | 1228 | ck_assert_msg(toxes[i] != 0, "Failed to create tox instances %u", i); |
1228 | tox_callback_friend_request(toxes[i], &g_accept_friend_request); | 1229 | tox_callback_friend_request(toxes[i], &g_accept_friend_request); |
1229 | tox_callback_group_invite(toxes[i], &print_group_invite_callback, &to_comp); | 1230 | tox_callback_conference_invite(toxes[i], &print_group_invite_callback, &to_comp); |
1230 | } | 1231 | } |
1231 | 1232 | ||
1232 | { | 1233 | { |
@@ -1264,9 +1265,9 @@ group_test_restart: | |||
1264 | 1265 | ||
1265 | printf("friends connected, took %llu seconds\n", time(NULL) - cur_time); | 1266 | printf("friends connected, took %llu seconds\n", time(NULL) - cur_time); |
1266 | 1267 | ||
1267 | ck_assert_msg(tox_add_groupchat(toxes[0]) != -1, "Failed to create group"); | 1268 | ck_assert_msg(tox_conference_new(toxes[0], NULL) != -1, "Failed to create group"); |
1268 | ck_assert_msg(tox_invite_friend(toxes[0], 0, 0) == 0, "Failed to invite friend"); | 1269 | ck_assert_msg(tox_conference_invite(toxes[0], 0, 0, NULL) == 0, "Failed to invite friend"); |
1269 | ck_assert_msg(tox_group_set_title(toxes[0], 0, (const uint8_t *)"Gentoo", sizeof("Gentoo") - 1) == 0, | 1270 | ck_assert_msg(tox_conference_set_title(toxes[0], 0, (const uint8_t *)"Gentoo", sizeof("Gentoo") - 1, NULL) == 0, |
1270 | "Failed to set group title"); | 1271 | "Failed to set group title"); |
1271 | invite_counter = ~0; | 1272 | invite_counter = ~0; |
1272 | 1273 | ||
@@ -1279,7 +1280,7 @@ group_test_restart: | |||
1279 | } | 1280 | } |
1280 | 1281 | ||
1281 | if (!invite_counter) { | 1282 | if (!invite_counter) { |
1282 | ck_assert_msg(tox_invite_friend(invite_tox, 0, 0) == 0, "Failed to invite friend"); | 1283 | ck_assert_msg(tox_conference_invite(invite_tox, 0, 0, NULL) == 0, "Failed to invite friend"); |
1283 | } | 1284 | } |
1284 | 1285 | ||
1285 | if (done == invite_counter) { | 1286 | if (done == invite_counter) { |
@@ -1291,7 +1292,7 @@ group_test_restart: | |||
1291 | } | 1292 | } |
1292 | 1293 | ||
1293 | for (i = 0; i < NUM_GROUP_TOX; ++i) { | 1294 | for (i = 0; i < NUM_GROUP_TOX; ++i) { |
1294 | int num_peers = tox_group_number_peers(toxes[i], 0); | 1295 | int num_peers = tox_conference_peer_count(toxes[i], 0, NULL); |
1295 | 1296 | ||
1296 | /** | 1297 | /** |
1297 | * Group chats fail unpredictably, currently they'll rerun as many times | 1298 | * Group chats fail unpredictably, currently they'll rerun as many times |
@@ -1321,7 +1322,8 @@ group_test_restart: | |||
1321 | NUM_GROUP_TOX, i, num_peers); | 1322 | NUM_GROUP_TOX, i, num_peers); |
1322 | 1323 | ||
1323 | uint8_t title[2048]; | 1324 | uint8_t title[2048]; |
1324 | int ret = tox_group_get_title(toxes[i], 0, title, sizeof(title)); | 1325 | int ret = tox_conference_get_title_size(toxes[i], 0, NULL); |
1326 | tox_conference_get_title(toxes[i], 0, title, NULL); | ||
1325 | ck_assert_msg(ret == sizeof("Gentoo") - 1, "Wrong title length"); | 1327 | ck_assert_msg(ret == sizeof("Gentoo") - 1, "Wrong title length"); |
1326 | ck_assert_msg(memcmp("Gentoo", title, ret) == 0, "Wrong title"); | 1328 | ck_assert_msg(memcmp("Gentoo", title, ret) == 0, "Wrong title"); |
1327 | } | 1329 | } |
@@ -1329,11 +1331,13 @@ group_test_restart: | |||
1329 | printf("group connected\n"); | 1331 | printf("group connected\n"); |
1330 | 1332 | ||
1331 | for (i = 0; i < NUM_GROUP_TOX; ++i) { | 1333 | for (i = 0; i < NUM_GROUP_TOX; ++i) { |
1332 | tox_callback_group_message(toxes[i], &print_group_message, &to_comp); | 1334 | tox_callback_conference_message(toxes[i], &print_group_message, &to_comp); |
1333 | } | 1335 | } |
1334 | 1336 | ||
1335 | ck_assert_msg(tox_group_message_send(toxes[rand() % NUM_GROUP_TOX], 0, (const uint8_t *)"Install Gentoo", | 1337 | ck_assert_msg( |
1336 | sizeof("Install Gentoo") - 1) == 0, "Failed to send group message."); | 1338 | tox_conference_send_message( |
1339 | toxes[rand() % NUM_GROUP_TOX], 0, TOX_MESSAGE_TYPE_NORMAL, (const uint8_t *)"Install Gentoo", | ||
1340 | sizeof("Install Gentoo") - 1, NULL) == 0, "Failed to send group message."); | ||
1337 | num_recv = 0; | 1341 | num_recv = 0; |
1338 | 1342 | ||
1339 | for (j = 0; j < 20; ++j) { | 1343 | for (j = 0; j < 20; ++j) { |
@@ -1348,7 +1352,7 @@ group_test_restart: | |||
1348 | ck_assert_msg(num_recv == NUM_GROUP_TOX, "Failed to recv group messages."); | 1352 | ck_assert_msg(num_recv == NUM_GROUP_TOX, "Failed to recv group messages."); |
1349 | 1353 | ||
1350 | for (k = NUM_GROUP_TOX; k != 0 ; --k) { | 1354 | for (k = NUM_GROUP_TOX; k != 0 ; --k) { |
1351 | tox_del_groupchat(toxes[k - 1], 0); | 1355 | tox_conference_delete(toxes[k - 1], 0, NULL); |
1352 | 1356 | ||
1353 | for (j = 0; j < 10; ++j) { | 1357 | for (j = 0; j < 10; ++j) { |
1354 | for (i = 0; i < NUM_GROUP_TOX; ++i) { | 1358 | for (i = 0; i < NUM_GROUP_TOX; ++i) { |
@@ -1359,7 +1363,7 @@ group_test_restart: | |||
1359 | } | 1363 | } |
1360 | 1364 | ||
1361 | for (i = 0; i < (k - 1); ++i) { | 1365 | for (i = 0; i < (k - 1); ++i) { |
1362 | int num_peers = tox_group_number_peers(toxes[i], 0); | 1366 | int num_peers = tox_conference_peer_count(toxes[i], 0, NULL); |
1363 | ck_assert_msg(num_peers == (k - 1), "\n\tBad number of group peers (post check)." | 1367 | ck_assert_msg(num_peers == (k - 1), "\n\tBad number of group peers (post check)." |
1364 | "\n\t\t\tExpected: %u but tox_instance(%u) only has: %i\n\n", | 1368 | "\n\t\t\tExpected: %u but tox_instance(%u) only has: %i\n\n", |
1365 | (k - 1), i, num_peers); | 1369 | (k - 1), i, num_peers); |