Astyled test.

This commit is contained in:
irungentoo 2014-04-05 14:47:58 -04:00
parent 1efb1d341f
commit 813198a6e7
No known key found for this signature in database
GPG Key ID: 10349DC9BED89E98

View File

@ -22,8 +22,7 @@
#endif
typedef enum _CallStatus
{
typedef enum _CallStatus {
none,
InCall,
Ringing,
@ -33,8 +32,7 @@ typedef enum _CallStatus
} CallStatus;
typedef struct _Party
{
typedef struct _Party {
CallStatus status;
ToxAv *av;
time_t *CallStarted;
@ -86,8 +84,7 @@ void callback_recv_ending ( void *_arg )
if ( cast->Alice.status == Rejected) {
printf ( "Call ended for Bob!\n" );
cast->Bob.status = Ended;
}
else {
} else {
printf ( "Call ended for Alice!\n" );
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);
uint8_t off = 1;
while (1) {
tox_do(bootstrap_node);
tox_do(Alice);
@ -194,8 +192,7 @@ START_TEST(test_AV)
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(Bob, 128, 128), NULL},
};
@ -234,8 +231,7 @@ START_TEST(test_AV)
/*
* Call with audio only on both sides. Alice calls Bob.
*/
CALL_AND_START_LOOP(TypeAudio, TypeAudio)
{
CALL_AND_START_LOOP(TypeAudio, TypeAudio) {
/* Both send */
toxav_send_audio(status_control.Alice.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 */
recved = toxav_recv_audio(status_control.Alice.av, 10, storage);
if ( recved ) {
ck_assert_msg(recved == 10 && memcmp(storage, sample_payload, 10) == 0, "Payload from Bob is invalid");
memset(storage, 0, 10);
@ -253,6 +250,7 @@ START_TEST(test_AV)
/* Payload from Bob */
recved = toxav_recv_audio(status_control.Bob.av, 10, storage);
if ( recved ) {
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_AND_START_LOOP(TypeAudio, TypeVideo)
{
CALL_AND_START_LOOP(TypeAudio, TypeVideo) {
/* Both send */
toxav_send_audio(status_control.Alice.av, sample_payload, 10);
@ -287,10 +284,12 @@ START_TEST(test_AV)
/* Payload from Bob */
recved = toxav_recv_audio(status_control.Alice.av, 10, storage);
if ( recved ) {
ck_assert_msg(recved == 10 && memcmp(storage, sample_payload, 10) == 0, "Payload from Bob is invalid");
memset(storage, 0, 10);
}
/* Video payload */
toxav_recv_video(status_control.Alice.av, &video_storage);
@ -305,6 +304,7 @@ START_TEST(test_AV)
/* Payload from Alice */
recved = toxav_recv_audio(status_control.Bob.av, 10, storage);
if ( recved ) {
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_AND_START_LOOP(TypeVideo, TypeVideo)
{
CALL_AND_START_LOOP(TypeVideo, TypeVideo) {
/* Both send */
toxav_send_audio(status_control.Alice.av, sample_payload, 10);
toxav_send_video(status_control.Alice.av, sample_image);
@ -340,10 +339,12 @@ START_TEST(test_AV)
/* Payload from Bob */
recved = toxav_recv_audio(status_control.Alice.av, 10, storage);
if ( recved ) {
ck_assert_msg(recved == 10 && memcmp(storage, sample_payload, 10) == 0, "Payload from Bob is invalid");
memset(storage, 0, 10);
}
/* Video payload */
toxav_recv_video(status_control.Alice.av, &video_storage);
@ -358,9 +359,11 @@ START_TEST(test_AV)
/* Payload from Alice */
recved = toxav_recv_audio(status_control.Bob.av, 10, storage);
if ( recved ) {
ck_assert_msg(recved == 10 && memcmp(storage, sample_payload, 10) == 0, "Payload from Alice is invalid");
}
/* Video payload */
toxav_recv_video(status_control.Bob.av, &video_storage);
@ -394,27 +397,38 @@ START_TEST(test_AV)
{
int step = 0;
int running = 1;
while (running) {
tox_do(bootstrap_node);
tox_do(Alice);
tox_do(Bob);
switch ( step ) {
case 0: /* Alice */
printf("Alice is calling...\n");
toxav_call(status_control.Alice.av, 0, TypeAudio, 10);
step++;
break;\
break;
\
case 1: /* Bob */
if (status_control.Bob.status == Ringing) {
printf("Bob rejects...\n");
toxav_reject(status_control.Bob.av, "Who likes D's anyway?");
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);
}
printf("\n");
}
@ -425,27 +439,38 @@ START_TEST(test_AV)
{
int step = 0;
int running = 1;
while (running) {
tox_do(bootstrap_node);
tox_do(Alice);
tox_do(Bob);
switch ( step ) {
case 0: /* Alice */
printf("Alice is calling...\n");
toxav_call(status_control.Alice.av, 0, TypeAudio, 10);
step++;
break;\
break;
\
case 1: /* Alice again */
if (status_control.Bob.status == Ringing) {
printf("Alice cancels...\n");
toxav_cancel(status_control.Alice.av, 0, "Who likes D's anyway?");
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);
}
printf("\n");
}