/work/auto_tests/scenarios/scenario_set_status_message_test.c
Line | Count | Source (jump to first uncovered line) |
1 | | #include "framework/framework.h" |
2 | | #include <stdio.h> |
3 | | #include <string.h> |
4 | | |
5 | 23 | #define STATUS_MESSAGE "Installing Gentoo" |
6 | | |
7 | | static void alice_script(ToxNode *self, void *ctx) |
8 | 7 | { |
9 | 7 | WAIT_UNTIL(tox_node_is_self_connected(self)); |
10 | 7 | WAIT_UNTIL(tox_node_is_friend_connected(self, 0)); |
11 | | |
12 | 7 | tox_node_log(self, "Setting status message to %s", STATUS_MESSAGE); |
13 | 7 | tox_self_set_status_message(tox_node_get_tox(self), (const uint8_t *)STATUS_MESSAGE, sizeof(STATUS_MESSAGE), nullptr); |
14 | 7 | } |
15 | | |
16 | | static void bob_script(ToxNode *self, void *ctx) |
17 | 2 | { |
18 | 2 | WAIT_UNTIL(tox_node_is_self_connected(self)); |
19 | 2 | WAIT_UNTIL(tox_node_is_friend_connected(self, 0)); |
20 | | |
21 | 2 | tox_node_log(self, "Waiting for Alice to change status message..."); |
22 | 2 | WAIT_UNTIL(tox_node_friend_status_message_is(self, 0, (const uint8_t *)STATUS_MESSAGE, sizeof(STATUS_MESSAGE))); |
23 | 2 | tox_node_log(self, "Alice\'s status message is now %s", STATUS_MESSAGE); |
24 | 2 | } |
25 | | |
26 | | int main(int argc, char *argv[]) |
27 | 31 | { |
28 | 31 | ToxScenario *s = tox_scenario_new(argc, argv, 60000); |
29 | | |
30 | 31 | ToxNode *alice = tox_scenario_add_node(s, "Alice", alice_script, nullptr, 0); |
31 | 31 | ToxNode *bob = tox_scenario_add_node(s, "Bob", bob_script, nullptr, 0); |
32 | | |
33 | 31 | tox_node_bootstrap(bob, alice); |
34 | 31 | tox_node_friend_add(alice, bob); |
35 | 31 | tox_node_friend_add(bob, alice); |
36 | | |
37 | 31 | ToxScenarioStatus res = tox_scenario_run(s); |
38 | 31 | if (res != TOX_SCENARIO_DONE) { |
39 | 0 | tox_scenario_log(s, "Test failed with status %u", res); |
40 | 0 | return 1; |
41 | 0 | } |
42 | | |
43 | 31 | tox_scenario_free(s); |
44 | 31 | return 0; |
45 | 31 | } |