diff options
author | zugz (tox) <mbays+tox@sdf.org> | 2018-09-09 23:27:39 +0200 |
---|---|---|
committer | zugz (tox) <mbays+tox@sdf.org> | 2018-11-29 21:52:23 +0100 |
commit | 9770880e975a09635a461c46c8fcc193bce57004 (patch) | |
tree | 8c7aa3c3ee8d264a3fdd97d8a5c49caa25f5da0b /auto_tests | |
parent | caca350f435cf6a2a3778c64771dafdb7dde8b7a (diff) |
Implement conferences saving
* add global friend_connection status callback, used for group rejoining
* stop leaving groups on killing tox
Diffstat (limited to 'auto_tests')
-rw-r--r-- | auto_tests/conference_test.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/auto_tests/conference_test.c b/auto_tests/conference_test.c index 647b649d..349c2905 100644 --- a/auto_tests/conference_test.c +++ b/auto_tests/conference_test.c | |||
@@ -167,13 +167,34 @@ static void run_conference_tests(Tox **toxes, State *state) | |||
167 | 167 | ||
168 | printf("letting random toxes timeout\n"); | 168 | printf("letting random toxes timeout\n"); |
169 | bool disconnected[NUM_GROUP_TOX] = {0}; | 169 | bool disconnected[NUM_GROUP_TOX] = {0}; |
170 | bool restarting[NUM_GROUP_TOX] = {0}; | ||
170 | 171 | ||
171 | ck_assert(NUM_DISCONNECT < NUM_GROUP_TOX); | 172 | ck_assert(NUM_DISCONNECT < NUM_GROUP_TOX); |
172 | 173 | ||
173 | for (uint16_t i = 0; i < NUM_DISCONNECT; ++i) { | 174 | for (uint16_t i = 0; i < NUM_DISCONNECT; ++i) { |
174 | uint32_t disconnect = random_false_index(disconnected, NUM_GROUP_TOX); | 175 | uint32_t disconnect = random_false_index(disconnected, NUM_GROUP_TOX); |
175 | disconnected[disconnect] = true; | 176 | disconnected[disconnect] = true; |
176 | printf("Disconnecting #%u\n", state[disconnect].index); | 177 | |
178 | if (i < NUM_DISCONNECT / 2) { | ||
179 | restarting[disconnect] = true; | ||
180 | printf("Restarting #%u\n", state[disconnect].index); | ||
181 | } else { | ||
182 | printf("Disconnecting #%u\n", state[disconnect].index); | ||
183 | } | ||
184 | } | ||
185 | |||
186 | uint8_t *save[NUM_GROUP_TOX]; | ||
187 | size_t save_size[NUM_GROUP_TOX]; | ||
188 | |||
189 | for (uint16_t i = 0; i < NUM_GROUP_TOX; ++i) { | ||
190 | if (restarting[i]) { | ||
191 | save_size[i] = tox_get_savedata_size(toxes[i]); | ||
192 | ck_assert_msg(save_size[i] != 0, "save is invalid size %u", (unsigned)save_size[i]); | ||
193 | save[i] = (uint8_t *)malloc(save_size[i]); | ||
194 | ck_assert_msg(save[i] != nullptr, "malloc failed"); | ||
195 | tox_get_savedata(toxes[i], save[i]); | ||
196 | tox_kill(toxes[i]); | ||
197 | } | ||
177 | } | 198 | } |
178 | 199 | ||
179 | do { | 200 | do { |
@@ -187,6 +208,17 @@ static void run_conference_tests(Tox **toxes, State *state) | |||
187 | c_sleep(20); | 208 | c_sleep(20); |
188 | } while (!toxes_are_disconnected_from_group(NUM_GROUP_TOX, toxes, NUM_DISCONNECT, disconnected)); | 209 | } while (!toxes_are_disconnected_from_group(NUM_GROUP_TOX, toxes, NUM_DISCONNECT, disconnected)); |
189 | 210 | ||
211 | for (uint16_t i = 0; i < NUM_GROUP_TOX; ++i) { | ||
212 | if (restarting[i]) { | ||
213 | struct Tox_Options *const options = tox_options_new(nullptr); | ||
214 | tox_options_set_savedata_type(options, TOX_SAVEDATA_TYPE_TOX_SAVE); | ||
215 | tox_options_set_savedata_data(options, save[i], save_size[i]); | ||
216 | toxes[i] = tox_new_log(options, nullptr, &state[i].index); | ||
217 | tox_options_free(options); | ||
218 | free(save[i]); | ||
219 | } | ||
220 | } | ||
221 | |||
190 | if (check_name_change_propagation) { | 222 | if (check_name_change_propagation) { |
191 | printf("changing names\n"); | 223 | printf("changing names\n"); |
192 | 224 | ||