diff options
Diffstat (limited to 'auto_tests/toxav_basic_test.c')
-rw-r--r-- | auto_tests/toxav_basic_test.c | 71 |
1 files changed, 16 insertions, 55 deletions
diff --git a/auto_tests/toxav_basic_test.c b/auto_tests/toxav_basic_test.c index c192f556..5c27e11f 100644 --- a/auto_tests/toxav_basic_test.c +++ b/auto_tests/toxav_basic_test.c | |||
@@ -57,41 +57,25 @@ typedef struct { | |||
57 | */ | 57 | */ |
58 | static void t_toxav_call_cb(ToxAV *av, uint32_t friend_number, bool audio_enabled, bool video_enabled, void *user_data) | 58 | static void t_toxav_call_cb(ToxAV *av, uint32_t friend_number, bool audio_enabled, bool video_enabled, void *user_data) |
59 | { | 59 | { |
60 | (void) av; | ||
61 | (void) friend_number; | ||
62 | (void) audio_enabled; | ||
63 | (void) video_enabled; | ||
64 | |||
65 | printf("Handling CALL callback\n"); | 60 | printf("Handling CALL callback\n"); |
66 | ((CallControl *)user_data)->incoming = true; | 61 | ((CallControl *)user_data)->incoming = true; |
67 | } | 62 | } |
63 | |||
68 | static void t_toxav_call_state_cb(ToxAV *av, uint32_t friend_number, uint32_t state, void *user_data) | 64 | static void t_toxav_call_state_cb(ToxAV *av, uint32_t friend_number, uint32_t state, void *user_data) |
69 | { | 65 | { |
70 | (void) av; | ||
71 | (void) friend_number; | ||
72 | |||
73 | printf("Handling CALL STATE callback: %d\n", state); | 66 | printf("Handling CALL STATE callback: %d\n", state); |
74 | ((CallControl *)user_data)->state = state; | 67 | ((CallControl *)user_data)->state = state; |
75 | } | 68 | } |
69 | |||
76 | static void t_toxav_receive_video_frame_cb(ToxAV *av, uint32_t friend_number, | 70 | static void t_toxav_receive_video_frame_cb(ToxAV *av, uint32_t friend_number, |
77 | uint16_t width, uint16_t height, | 71 | uint16_t width, uint16_t height, |
78 | uint8_t const *y, uint8_t const *u, uint8_t const *v, | 72 | uint8_t const *y, uint8_t const *u, uint8_t const *v, |
79 | int32_t ystride, int32_t ustride, int32_t vstride, | 73 | int32_t ystride, int32_t ustride, int32_t vstride, |
80 | void *user_data) | 74 | void *user_data) |
81 | { | 75 | { |
82 | (void) av; | ||
83 | (void) friend_number; | ||
84 | (void) width; | ||
85 | (void) height; | ||
86 | (void) y; | ||
87 | (void) u; | ||
88 | (void) v; | ||
89 | (void) ystride; | ||
90 | (void) ustride; | ||
91 | (void) vstride; | ||
92 | (void) user_data; | ||
93 | printf("Received video payload\n"); | 76 | printf("Received video payload\n"); |
94 | } | 77 | } |
78 | |||
95 | static void t_toxav_receive_audio_frame_cb(ToxAV *av, uint32_t friend_number, | 79 | static void t_toxav_receive_audio_frame_cb(ToxAV *av, uint32_t friend_number, |
96 | int16_t const *pcm, | 80 | int16_t const *pcm, |
97 | size_t sample_count, | 81 | size_t sample_count, |
@@ -99,20 +83,12 @@ static void t_toxav_receive_audio_frame_cb(ToxAV *av, uint32_t friend_number, | |||
99 | uint32_t sampling_rate, | 83 | uint32_t sampling_rate, |
100 | void *user_data) | 84 | void *user_data) |
101 | { | 85 | { |
102 | (void) av; | ||
103 | (void) friend_number; | ||
104 | (void) pcm; | ||
105 | (void) sample_count; | ||
106 | (void) channels; | ||
107 | (void) sampling_rate; | ||
108 | (void) user_data; | ||
109 | printf("Received audio payload\n"); | 86 | printf("Received audio payload\n"); |
110 | } | 87 | } |
88 | |||
111 | static void t_accept_friend_request_cb(Tox *m, const uint8_t *public_key, const uint8_t *data, size_t length, | 89 | static void t_accept_friend_request_cb(Tox *m, const uint8_t *public_key, const uint8_t *data, size_t length, |
112 | void *userdata) | 90 | void *userdata) |
113 | { | 91 | { |
114 | (void) userdata; | ||
115 | |||
116 | if (length == 7 && memcmp("gentoo", data, 7) == 0) { | 92 | if (length == 7 && memcmp("gentoo", data, 7) == 0) { |
117 | ck_assert(tox_friend_add_norequest(m, public_key, nullptr) != (uint32_t) ~0); | 93 | ck_assert(tox_friend_add_norequest(m, public_key, nullptr) != (uint32_t) ~0); |
118 | } | 94 | } |
@@ -122,19 +98,15 @@ static void t_accept_friend_request_cb(Tox *m, const uint8_t *public_key, const | |||
122 | /** | 98 | /** |
123 | * Iterate helper | 99 | * Iterate helper |
124 | */ | 100 | */ |
125 | static int iterate_tox(Tox *bootstrap, Tox *Alice, Tox *Bob) | 101 | static void iterate_tox(Tox *bootstrap, Tox *Alice, Tox *Bob) |
126 | { | 102 | { |
127 | c_sleep(100); | 103 | c_sleep(100); |
128 | tox_iterate(bootstrap, nullptr); | 104 | tox_iterate(bootstrap, nullptr); |
129 | tox_iterate(Alice, nullptr); | 105 | tox_iterate(Alice, nullptr); |
130 | tox_iterate(Bob, nullptr); | 106 | tox_iterate(Bob, nullptr); |
131 | |||
132 | return MIN(tox_iteration_interval(Alice), tox_iteration_interval(Bob)); | ||
133 | } | 107 | } |
134 | 108 | ||
135 | 109 | static void test_av_flows(void) | |
136 | |||
137 | START_TEST(test_AV_flows) | ||
138 | { | 110 | { |
139 | Tox *Alice, *Bob, *bootstrap; | 111 | Tox *Alice, *Bob, *bootstrap; |
140 | ToxAV *AliceAV, *BobAV; | 112 | ToxAV *AliceAV, *BobAV; |
@@ -164,6 +136,13 @@ START_TEST(test_AV_flows) | |||
164 | tox_callback_friend_request(Alice, t_accept_friend_request_cb); | 136 | tox_callback_friend_request(Alice, t_accept_friend_request_cb); |
165 | tox_self_get_address(Alice, address); | 137 | tox_self_get_address(Alice, address); |
166 | 138 | ||
139 | printf("bootstrapping Alice and Bob off a third bootstrap node\n"); | ||
140 | uint8_t dht_key[TOX_PUBLIC_KEY_SIZE]; | ||
141 | tox_self_get_dht_id(bootstrap, dht_key); | ||
142 | const uint16_t dht_port = tox_self_get_udp_port(bootstrap, nullptr); | ||
143 | |||
144 | tox_bootstrap(Alice, "localhost", dht_port, dht_key, nullptr); | ||
145 | tox_bootstrap(Bob, "localhost", dht_port, dht_key, nullptr); | ||
167 | 146 | ||
168 | ck_assert(tox_friend_add(Bob, address, (const uint8_t *)"gentoo", 7, nullptr) != (uint32_t) ~0); | 147 | ck_assert(tox_friend_add(Bob, address, (const uint8_t *)"gentoo", 7, nullptr) != (uint32_t) ~0); |
169 | 148 | ||
@@ -579,29 +558,11 @@ START_TEST(test_AV_flows) | |||
579 | 558 | ||
580 | printf("\nTest successful!\n"); | 559 | printf("\nTest successful!\n"); |
581 | } | 560 | } |
582 | END_TEST | ||
583 | 561 | ||
584 | static Suite *tox_suite(void) | ||
585 | { | ||
586 | Suite *s = suite_create("ToxAV"); | ||
587 | |||
588 | DEFTESTCASE_SLOW(AV_flows, 200); | ||
589 | return s; | ||
590 | } | ||
591 | int main(int argc, char *argv[]) | 562 | int main(int argc, char *argv[]) |
592 | { | 563 | { |
593 | (void) argc; | 564 | setvbuf(stdout, nullptr, _IONBF, 0); |
594 | (void) argv; | ||
595 | |||
596 | Suite *tox = tox_suite(); | ||
597 | SRunner *test_runner = srunner_create(tox); | ||
598 | |||
599 | setbuf(stdout, nullptr); | ||
600 | |||
601 | srunner_run_all(test_runner, CK_NORMAL); | ||
602 | int number_failed = srunner_ntests_failed(test_runner); | ||
603 | |||
604 | srunner_free(test_runner); | ||
605 | 565 | ||
606 | return number_failed; | 566 | test_av_flows(); |
567 | return 0; | ||
607 | } | 568 | } |