Squashed 'external/toxcore/c-toxcore/' changes from 67badf694..82460b212

82460b212 feat: add ngc events
24b54722a fix: Ensure we have allocators available for the error paths.
48dbcfebc cleanup: Remove redundant `-DSODIUM_EXPORT` from definitions.
0cef46ee9 cleanup: Fix a few more clang-tidy warnings.
0c5b918e9 cleanup: Fix a few more clang-tidy warnings.
4d3c97f49 cleanup: Enforce stricter identifier naming using clang-tidy.
a549807df refactor: Add `mem` module to allow tests to override allocators.
6133fb153 chore: Add devcontainer setup for codespaces.
620e07ecd chore: Set a timeout for tests started using Conan
c0ec33b16 chore: Migrate Windows CI from Appveyor to Azure DevOps
8ed47f3ef fix incorrect documentation
a1e245841 docs: Fix doxygen config and remove some redundant comments.
b0f633185 chore: Fix the Android CI job
7469a529b fix: Add missing `#include <array>`.
2b1a6b0d2 add missing ngc constants getter declarations and definitions
2e02d5637 chore: Add missing module dependencies.
REVERT: 67badf694 feat: add ngc events

git-subtree-dir: external/toxcore/c-toxcore
git-subtree-split: 82460b2124216af1ac9d63060de310a682a2fd15
This commit is contained in:
2023-10-10 19:37:39 +02:00
parent 227425b90e
commit a3126d581b
114 changed files with 2090 additions and 1653 deletions

View File

@ -43,7 +43,7 @@ static void dump_events(const char *path, const Tox_Events *events)
}
}
static void print_events(Tox_Events *events)
static void print_events(const Tox_System *sys, Tox_Events *events)
{
const uint32_t size = tox_events_bytes_size(events);
@ -52,11 +52,11 @@ static void print_events(Tox_Events *events)
tox_events_get_bytes(events, bytes);
Tox_Events *events_copy = tox_events_load(bytes, size);
Tox_Events *events_copy = tox_events_load(sys, bytes, size);
ck_assert(events_copy != nullptr);
free(bytes);
ck_assert(tox_events_equal(events, events_copy));
ck_assert(tox_events_equal(sys, events, events_copy));
tox_events_free(events_copy);
tox_events_free(events);
@ -64,9 +64,11 @@ static void print_events(Tox_Events *events)
static bool await_message(Tox **toxes, const Tox_Dispatch *dispatch)
{
const Tox_System *sys = tox_get_system(toxes[0]);
for (uint32_t i = 0; i < 100; ++i) {
// Ignore events on tox 1.
print_events(tox_events_iterate(toxes[0], false, nullptr));
print_events(sys, tox_events_iterate(toxes[0], false, nullptr));
// Check if tox 2 got the message from tox 1.
Tox_Events *events = tox_events_iterate(toxes[1], false, nullptr);
@ -74,7 +76,7 @@ static bool await_message(Tox **toxes, const Tox_Dispatch *dispatch)
bool success = false;
tox_dispatch_invoke(dispatch, events, toxes[1], &success);
print_events(events);
print_events(sys, events);
if (success) {
return true;
@ -101,6 +103,8 @@ static void test_tox_events(void)
ck_assert_msg(toxes[i] != nullptr, "failed to create tox instances %u", i);
}
const Tox_System *sys = tox_get_system(toxes[0]);
Tox_Err_Dispatch_New err_new;
Tox_Dispatch *dispatch = tox_dispatch_new(&err_new);
ck_assert_msg(dispatch != nullptr, "failed to create event dispatcher");
@ -123,8 +127,8 @@ static void test_tox_events(void)
while (tox_self_get_connection_status(toxes[0]) == TOX_CONNECTION_NONE ||
tox_self_get_connection_status(toxes[1]) == TOX_CONNECTION_NONE) {
// Ignore connection events for now.
print_events(tox_events_iterate(toxes[0], false, nullptr));
print_events(tox_events_iterate(toxes[1], false, nullptr));
print_events(sys, tox_events_iterate(toxes[0], false, nullptr));
print_events(sys, tox_events_iterate(toxes[1], false, nullptr));
c_sleep(tox_iteration_interval(toxes[0]));
}
@ -134,8 +138,8 @@ static void test_tox_events(void)
while (tox_friend_get_connection_status(toxes[0], 0, nullptr) == TOX_CONNECTION_NONE ||
tox_friend_get_connection_status(toxes[1], 0, nullptr) == TOX_CONNECTION_NONE) {
// Ignore connection events for now.
print_events(tox_events_iterate(toxes[0], false, nullptr));
print_events(tox_events_iterate(toxes[1], false, nullptr));
print_events(sys, tox_events_iterate(toxes[0], false, nullptr));
print_events(sys, tox_events_iterate(toxes[1], false, nullptr));
c_sleep(tox_iteration_interval(toxes[0]));
}