mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Astyled test.
This commit is contained in:
parent
1efb1d341f
commit
813198a6e7
|
@ -22,8 +22,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
typedef enum _CallStatus
|
typedef enum _CallStatus {
|
||||||
{
|
|
||||||
none,
|
none,
|
||||||
InCall,
|
InCall,
|
||||||
Ringing,
|
Ringing,
|
||||||
|
@ -33,8 +32,7 @@ typedef enum _CallStatus
|
||||||
|
|
||||||
} CallStatus;
|
} CallStatus;
|
||||||
|
|
||||||
typedef struct _Party
|
typedef struct _Party {
|
||||||
{
|
|
||||||
CallStatus status;
|
CallStatus status;
|
||||||
ToxAv *av;
|
ToxAv *av;
|
||||||
time_t *CallStarted;
|
time_t *CallStarted;
|
||||||
|
@ -86,8 +84,7 @@ void callback_recv_ending ( void *_arg )
|
||||||
if ( cast->Alice.status == Rejected) {
|
if ( cast->Alice.status == Rejected) {
|
||||||
printf ( "Call ended for Bob!\n" );
|
printf ( "Call ended for Bob!\n" );
|
||||||
cast->Bob.status = Ended;
|
cast->Bob.status = Ended;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
printf ( "Call ended for Alice!\n" );
|
printf ( "Call ended for Alice!\n" );
|
||||||
cast->Alice.status = Ended;
|
cast->Alice.status = Ended;
|
||||||
}
|
}
|
||||||
|
@ -174,6 +171,7 @@ START_TEST(test_AV)
|
||||||
ck_assert_msg(test == 0, "Failed to add friend error code: %i", test);
|
ck_assert_msg(test == 0, "Failed to add friend error code: %i", test);
|
||||||
|
|
||||||
uint8_t off = 1;
|
uint8_t off = 1;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
tox_do(bootstrap_node);
|
tox_do(bootstrap_node);
|
||||||
tox_do(Alice);
|
tox_do(Alice);
|
||||||
|
@ -194,8 +192,7 @@ START_TEST(test_AV)
|
||||||
printf("All set after %llu seconds! Starting call...\n", time(NULL) - cur_time);
|
printf("All set after %llu seconds! Starting call...\n", time(NULL) - cur_time);
|
||||||
|
|
||||||
|
|
||||||
Status status_control =
|
Status status_control = {
|
||||||
{
|
|
||||||
{none, toxav_new(Alice, 128, 128), NULL},
|
{none, toxav_new(Alice, 128, 128), NULL},
|
||||||
{none, toxav_new(Bob, 128, 128), NULL},
|
{none, toxav_new(Bob, 128, 128), NULL},
|
||||||
};
|
};
|
||||||
|
@ -234,8 +231,7 @@ START_TEST(test_AV)
|
||||||
/*
|
/*
|
||||||
* Call with audio only on both sides. Alice calls Bob.
|
* Call with audio only on both sides. Alice calls Bob.
|
||||||
*/
|
*/
|
||||||
CALL_AND_START_LOOP(TypeAudio, TypeAudio)
|
CALL_AND_START_LOOP(TypeAudio, TypeAudio) {
|
||||||
{
|
|
||||||
/* Both send */
|
/* Both send */
|
||||||
toxav_send_audio(status_control.Alice.av, sample_payload, 10);
|
toxav_send_audio(status_control.Alice.av, sample_payload, 10);
|
||||||
toxav_send_audio(status_control.Bob.av, sample_payload, 10);
|
toxav_send_audio(status_control.Bob.av, sample_payload, 10);
|
||||||
|
@ -246,6 +242,7 @@ START_TEST(test_AV)
|
||||||
|
|
||||||
/* Payload from Alice */
|
/* Payload from Alice */
|
||||||
recved = toxav_recv_audio(status_control.Alice.av, 10, storage);
|
recved = toxav_recv_audio(status_control.Alice.av, 10, storage);
|
||||||
|
|
||||||
if ( recved ) {
|
if ( recved ) {
|
||||||
ck_assert_msg(recved == 10 && memcmp(storage, sample_payload, 10) == 0, "Payload from Bob is invalid");
|
ck_assert_msg(recved == 10 && memcmp(storage, sample_payload, 10) == 0, "Payload from Bob is invalid");
|
||||||
memset(storage, 0, 10);
|
memset(storage, 0, 10);
|
||||||
|
@ -253,6 +250,7 @@ START_TEST(test_AV)
|
||||||
|
|
||||||
/* Payload from Bob */
|
/* Payload from Bob */
|
||||||
recved = toxav_recv_audio(status_control.Bob.av, 10, storage);
|
recved = toxav_recv_audio(status_control.Bob.av, 10, storage);
|
||||||
|
|
||||||
if ( recved ) {
|
if ( recved ) {
|
||||||
ck_assert_msg(recved == 10 && memcmp(storage, sample_payload, 10) == 0, "Payload from Alice is invalid");
|
ck_assert_msg(recved == 10 && memcmp(storage, sample_payload, 10) == 0, "Payload from Alice is invalid");
|
||||||
}
|
}
|
||||||
|
@ -272,8 +270,7 @@ START_TEST(test_AV)
|
||||||
/*
|
/*
|
||||||
* Call with audio on both sides and video on one side. Alice calls Bob.
|
* Call with audio on both sides and video on one side. Alice calls Bob.
|
||||||
*/
|
*/
|
||||||
CALL_AND_START_LOOP(TypeAudio, TypeVideo)
|
CALL_AND_START_LOOP(TypeAudio, TypeVideo) {
|
||||||
{
|
|
||||||
/* Both send */
|
/* Both send */
|
||||||
toxav_send_audio(status_control.Alice.av, sample_payload, 10);
|
toxav_send_audio(status_control.Alice.av, sample_payload, 10);
|
||||||
|
|
||||||
|
@ -287,10 +284,12 @@ START_TEST(test_AV)
|
||||||
|
|
||||||
/* Payload from Bob */
|
/* Payload from Bob */
|
||||||
recved = toxav_recv_audio(status_control.Alice.av, 10, storage);
|
recved = toxav_recv_audio(status_control.Alice.av, 10, storage);
|
||||||
|
|
||||||
if ( recved ) {
|
if ( recved ) {
|
||||||
ck_assert_msg(recved == 10 && memcmp(storage, sample_payload, 10) == 0, "Payload from Bob is invalid");
|
ck_assert_msg(recved == 10 && memcmp(storage, sample_payload, 10) == 0, "Payload from Bob is invalid");
|
||||||
memset(storage, 0, 10);
|
memset(storage, 0, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Video payload */
|
/* Video payload */
|
||||||
toxav_recv_video(status_control.Alice.av, &video_storage);
|
toxav_recv_video(status_control.Alice.av, &video_storage);
|
||||||
|
|
||||||
|
@ -305,6 +304,7 @@ START_TEST(test_AV)
|
||||||
|
|
||||||
/* Payload from Alice */
|
/* Payload from Alice */
|
||||||
recved = toxav_recv_audio(status_control.Bob.av, 10, storage);
|
recved = toxav_recv_audio(status_control.Bob.av, 10, storage);
|
||||||
|
|
||||||
if ( recved ) {
|
if ( recved ) {
|
||||||
ck_assert_msg(recved == 10 && memcmp(storage, sample_payload, 10) == 0, "Payload from Alice is invalid");
|
ck_assert_msg(recved == 10 && memcmp(storage, sample_payload, 10) == 0, "Payload from Alice is invalid");
|
||||||
}
|
}
|
||||||
|
@ -324,8 +324,7 @@ START_TEST(test_AV)
|
||||||
/*
|
/*
|
||||||
* Call with audio and video on both sides. Alice calls Bob.
|
* Call with audio and video on both sides. Alice calls Bob.
|
||||||
*/
|
*/
|
||||||
CALL_AND_START_LOOP(TypeVideo, TypeVideo)
|
CALL_AND_START_LOOP(TypeVideo, TypeVideo) {
|
||||||
{
|
|
||||||
/* Both send */
|
/* Both send */
|
||||||
toxav_send_audio(status_control.Alice.av, sample_payload, 10);
|
toxav_send_audio(status_control.Alice.av, sample_payload, 10);
|
||||||
toxav_send_video(status_control.Alice.av, sample_image);
|
toxav_send_video(status_control.Alice.av, sample_image);
|
||||||
|
@ -340,10 +339,12 @@ START_TEST(test_AV)
|
||||||
|
|
||||||
/* Payload from Bob */
|
/* Payload from Bob */
|
||||||
recved = toxav_recv_audio(status_control.Alice.av, 10, storage);
|
recved = toxav_recv_audio(status_control.Alice.av, 10, storage);
|
||||||
|
|
||||||
if ( recved ) {
|
if ( recved ) {
|
||||||
ck_assert_msg(recved == 10 && memcmp(storage, sample_payload, 10) == 0, "Payload from Bob is invalid");
|
ck_assert_msg(recved == 10 && memcmp(storage, sample_payload, 10) == 0, "Payload from Bob is invalid");
|
||||||
memset(storage, 0, 10);
|
memset(storage, 0, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Video payload */
|
/* Video payload */
|
||||||
toxav_recv_video(status_control.Alice.av, &video_storage);
|
toxav_recv_video(status_control.Alice.av, &video_storage);
|
||||||
|
|
||||||
|
@ -358,9 +359,11 @@ START_TEST(test_AV)
|
||||||
|
|
||||||
/* Payload from Alice */
|
/* Payload from Alice */
|
||||||
recved = toxav_recv_audio(status_control.Bob.av, 10, storage);
|
recved = toxav_recv_audio(status_control.Bob.av, 10, storage);
|
||||||
|
|
||||||
if ( recved ) {
|
if ( recved ) {
|
||||||
ck_assert_msg(recved == 10 && memcmp(storage, sample_payload, 10) == 0, "Payload from Alice is invalid");
|
ck_assert_msg(recved == 10 && memcmp(storage, sample_payload, 10) == 0, "Payload from Alice is invalid");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Video payload */
|
/* Video payload */
|
||||||
toxav_recv_video(status_control.Bob.av, &video_storage);
|
toxav_recv_video(status_control.Bob.av, &video_storage);
|
||||||
|
|
||||||
|
@ -394,27 +397,38 @@ START_TEST(test_AV)
|
||||||
{
|
{
|
||||||
int step = 0;
|
int step = 0;
|
||||||
int running = 1;
|
int running = 1;
|
||||||
|
|
||||||
while (running) {
|
while (running) {
|
||||||
tox_do(bootstrap_node);
|
tox_do(bootstrap_node);
|
||||||
tox_do(Alice);
|
tox_do(Alice);
|
||||||
tox_do(Bob);
|
tox_do(Bob);
|
||||||
|
|
||||||
switch ( step ) {
|
switch ( step ) {
|
||||||
case 0: /* Alice */
|
case 0: /* Alice */
|
||||||
printf("Alice is calling...\n");
|
printf("Alice is calling...\n");
|
||||||
toxav_call(status_control.Alice.av, 0, TypeAudio, 10);
|
toxav_call(status_control.Alice.av, 0, TypeAudio, 10);
|
||||||
step++;
|
step++;
|
||||||
break;\
|
break;
|
||||||
|
\
|
||||||
|
|
||||||
case 1: /* Bob */
|
case 1: /* Bob */
|
||||||
if (status_control.Bob.status == Ringing) {
|
if (status_control.Bob.status == Ringing) {
|
||||||
printf("Bob rejects...\n");
|
printf("Bob rejects...\n");
|
||||||
toxav_reject(status_control.Bob.av, "Who likes D's anyway?");
|
toxav_reject(status_control.Bob.av, "Who likes D's anyway?");
|
||||||
step++;
|
step++;
|
||||||
} break;
|
|
||||||
case 2: /* Wait for Both to have status ended */
|
|
||||||
if (status_control.Alice.status == Rejected && status_control.Bob.status == Ended) running = 0; break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2: /* Wait for Both to have status ended */
|
||||||
|
if (status_control.Alice.status == Rejected && status_control.Bob.status == Ended) running = 0;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
c_sleep(20);
|
c_sleep(20);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -425,27 +439,38 @@ START_TEST(test_AV)
|
||||||
{
|
{
|
||||||
int step = 0;
|
int step = 0;
|
||||||
int running = 1;
|
int running = 1;
|
||||||
|
|
||||||
while (running) {
|
while (running) {
|
||||||
tox_do(bootstrap_node);
|
tox_do(bootstrap_node);
|
||||||
tox_do(Alice);
|
tox_do(Alice);
|
||||||
tox_do(Bob);
|
tox_do(Bob);
|
||||||
|
|
||||||
switch ( step ) {
|
switch ( step ) {
|
||||||
case 0: /* Alice */
|
case 0: /* Alice */
|
||||||
printf("Alice is calling...\n");
|
printf("Alice is calling...\n");
|
||||||
toxav_call(status_control.Alice.av, 0, TypeAudio, 10);
|
toxav_call(status_control.Alice.av, 0, TypeAudio, 10);
|
||||||
step++;
|
step++;
|
||||||
break;\
|
break;
|
||||||
|
\
|
||||||
|
|
||||||
case 1: /* Alice again */
|
case 1: /* Alice again */
|
||||||
if (status_control.Bob.status == Ringing) {
|
if (status_control.Bob.status == Ringing) {
|
||||||
printf("Alice cancels...\n");
|
printf("Alice cancels...\n");
|
||||||
toxav_cancel(status_control.Alice.av, 0, "Who likes D's anyway?");
|
toxav_cancel(status_control.Alice.av, 0, "Who likes D's anyway?");
|
||||||
step++;
|
step++;
|
||||||
} break;
|
|
||||||
case 2: /* Wait for Both to have status ended */
|
|
||||||
if (status_control.Alice.status == Ended && status_control.Bob.status == Cancel) running = 0; break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2: /* Wait for Both to have status ended */
|
||||||
|
if (status_control.Alice.status == Ended && status_control.Bob.status == Cancel) running = 0;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
c_sleep(20);
|
c_sleep(20);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user