Coverage Report

Created: 2026-10-24 08:16

/work/auto_tests/scenarios/scenario_typing_test.c
Line
Count
Source (jump to first uncovered line)
1
#include "framework/framework.h"
2
#include <stdio.h>
3
4
static void alice_script(ToxNode *self, void *ctx)
5
1
{
6
1
    WAIT_UNTIL(tox_node_is_self_connected(self));
7
1
    WAIT_UNTIL(tox_node_is_friend_connected(self, 0));
8
9
1
    tox_node_log(self, "Setting typing to true");
10
1
    tox_self_set_typing(tox_node_get_tox(self), 0, true, nullptr);
11
12
    // Wait some time
13
11
    for (int i = 0; i < 10; ++i) {
14
10
        tox_scenario_yield(self);
15
10
    }
16
17
1
    tox_node_log(self, "Setting typing to false");
18
1
    tox_self_set_typing(tox_node_get_tox(self), 0, false, nullptr);
19
1
}
20
21
static void bob_script(ToxNode *self, void *ctx)
22
1
{
23
1
    WAIT_UNTIL(tox_node_is_self_connected(self));
24
1
    WAIT_UNTIL(tox_node_is_friend_connected(self, 0));
25
26
1
    tox_node_log(self, "Waiting for Alice to start typing...");
27
1
    WAIT_UNTIL(tox_node_friend_typing_is(self, 0, true));
28
1
    tox_node_log(self, "Alice is typing!");
29
30
1
    tox_node_log(self, "Waiting for Alice to stop typing...");
31
1
    WAIT_UNTIL(tox_node_friend_typing_is(self, 0, false));
32
1
    tox_node_log(self, "Alice stopped typing.");
33
1
}
34
35
int main(int argc, char *argv[])
36
31
{
37
31
    ToxScenario *s = tox_scenario_new(argc, argv, 60000);
38
39
31
    ToxNode *alice = tox_scenario_add_node(s, "Alice", alice_script, nullptr, 0);
40
31
    ToxNode *bob = tox_scenario_add_node(s, "Bob", bob_script, nullptr, 0);
41
42
31
    tox_node_bootstrap(bob, alice);
43
31
    tox_node_friend_add(alice, bob);
44
31
    tox_node_friend_add(bob, alice);
45
46
31
    ToxScenarioStatus res = tox_scenario_run(s);
47
31
    if (res != TOX_SCENARIO_DONE) {
48
0
        tox_scenario_log(s, "Test failed with status %u", res);
49
0
        return 1;
50
0
    }
51
52
31
    tox_scenario_free(s);
53
31
    return 0;
54
31
}