1 #pragma once 2 3 #include <tox/tox.h> 4 5 #include "toxext.h" 6 7 /* 8 * Copy paste of the linux kernel's container_of macro to allow for "subclassing" in our mocks 9 */ 10 #ifndef container_of 11 #define container_of(ptr, type, member) \ 12 ({ \ 13 const typeof(((type *)0)->member) *__mptr = (ptr); \ 14 (type *)((char *)__mptr - offsetof(type, member)); \ 15 }) 16 #endif 17 18 /* 19 * Mock abstraction to model a tox user with no extension support 20 */ 21 struct ToxUser { 22 Tox *tox; 23 uint32_t id; 24 tox_friend_lossless_packet_cb *lossless_packet_cb; 25 }; 26 27 /* 28 * Mock abstraction to model a tox user with extension support 29 */ 30 struct ToxExtUser { 31 struct ToxUser tox_user; 32 struct ToxExt *toxext; 33 }; 34 35 /* 36 * Initializes an empty ToxUser 37 * 38 * Note: If this abstraction is used the tox_user _must_ be passed to the tox_iterate call 39 */ 40 void toxext_test_init_tox_user(struct ToxUser *tox_user); 41 void toxext_test_cleanup_tox_user(struct ToxUser *tox_user); 42 43 /* 44 * Initializes an empty ToxExtUser 45 * 46 * Note: If this abstraction is used toxext_user.tox_user _must_ be passed to the tox_iterate call 47 */ 48 void toxext_test_init_tox_ext_user(struct ToxExtUser *toxext_user); 49 50 void toxext_test_cleanup_tox_ext_user(struct ToxExtUser *toxext_user); 51