diff options
Diffstat (limited to 'stabbertests')
-rw-r--r-- | stabbertests/proftest.c | 6 | ||||
-rw-r--r-- | stabbertests/proftest.h | 2 | ||||
-rw-r--r-- | stabbertests/test_connect.c | 47 | ||||
-rw-r--r-- | stabbertests/test_connect.h | 1 | ||||
-rw-r--r-- | stabbertests/testsuite.c | 3 |
5 files changed, 51 insertions, 8 deletions
diff --git a/stabbertests/proftest.c b/stabbertests/proftest.c index 96c0cb69..d20e9f3a 100644 --- a/stabbertests/proftest.c +++ b/stabbertests/proftest.c @@ -36,10 +36,10 @@ char *config_orig; char *data_orig; void -prof_process_xmpp(void) +prof_process_xmpp(int loops) { int i = 0; - while (i < 20) { + while (i < loops) { jabber_process_events(10); i++; } @@ -198,7 +198,7 @@ void close_prof_test(void **state) { jabber_disconnect(); - prof_process_xmpp(); + prof_process_xmpp(20); jabber_shutdown(); roster_free(); muc_close(); diff --git a/stabbertests/proftest.h b/stabbertests/proftest.h index e0b6dded..2feb0346 100644 --- a/stabbertests/proftest.h +++ b/stabbertests/proftest.h @@ -1,3 +1,3 @@ void init_prof_test(void **state); void close_prof_test(void **state); -void prof_process_xmpp(void); +void prof_process_xmpp(int loops); diff --git a/stabbertests/test_connect.c b/stabbertests/test_connect.c index 1b69a990..bfc8c69a 100644 --- a/stabbertests/test_connect.c +++ b/stabbertests/test_connect.c @@ -22,7 +22,7 @@ connect_jid(void **state) expect_cons_show("Connecting as stabber@localhost"); cmd_process_input(strdup("/connect stabber@localhost port 5230")); - prof_process_xmpp(); + prof_process_xmpp(20); jabber_conn_status_t status = jabber_get_connection_status(); assert_true(status == JABBER_CONNECTED); @@ -37,7 +37,7 @@ connect_bad_password(void **state) expect_cons_show_error("Login failed."); cmd_process_input(strdup("/connect stabber@localhost port 5230")); - prof_process_xmpp(); + prof_process_xmpp(20); jabber_conn_status_t status = jabber_get_connection_status(); assert_true(status == JABBER_DISCONNECTED); @@ -51,7 +51,7 @@ sends_rooms_iq(void **state) expect_any_cons_show(); cmd_process_input(strdup("/connect stabber@localhost port 5230")); - prof_process_xmpp(); + prof_process_xmpp(20); stbbr_for("confreq", "<iq id=\"confreq\" type=\"result\" to=\"stabber@localhost/profanity\" from=\"conference.localhost\">" @@ -63,7 +63,7 @@ sends_rooms_iq(void **state) ); cmd_process_input(strdup("/rooms")); - prof_process_xmpp(); + prof_process_xmpp(20); assert_true(stbbr_verify_last( "<iq id=\"confreq\" to=\"conference.localhost\" type=\"get\">" @@ -71,3 +71,42 @@ sends_rooms_iq(void **state) "</iq>" )); } + +void +multiple_pings(void **state) +{ + will_return(ui_ask_password, strdup("password")); + + expect_any_cons_show(); + + cmd_process_input(strdup("/connect stabber@localhost port 5230")); + prof_process_xmpp(20); + + expect_cons_show("Pinged server..."); + expect_any_cons_show(); + expect_cons_show("Pinged server..."); + expect_any_cons_show(); + + stbbr_for("prof_ping_1", + "<iq id=\"prof_ping_1\" type=\"result\" to=\"stabber@localhost/profanity\"/>" + ); + stbbr_for("prof_ping_2", + "<iq id=\"prof_ping_2\" type=\"result\" to=\"stabber@localhost/profanity\"/>" + ); + + cmd_process_input(strdup("/ping")); + prof_process_xmpp(20); + cmd_process_input(strdup("/ping")); + prof_process_xmpp(20); + + assert_true(stbbr_verify( + "<iq id=\"prof_ping_1\" type=\"get\">" + "<ping xmlns=\"urn:xmpp:ping\"/>" + "</iq>" + )); + assert_true(stbbr_verify( + "<iq id=\"prof_ping_2\" type=\"get\">" + "<ping xmlns=\"urn:xmpp:ping\"/>" + "</iq>" + )); +} diff --git a/stabbertests/test_connect.h b/stabbertests/test_connect.h index 968740c2..0bf018cd 100644 --- a/stabbertests/test_connect.h +++ b/stabbertests/test_connect.h @@ -1,4 +1,5 @@ void connect_jid(void **state); void connect_bad_password(void **state); void sends_rooms_iq(void **state); +void multiple_pings(void **state); diff --git a/stabbertests/testsuite.c b/stabbertests/testsuite.c index 9fb28c31..6905aeec 100644 --- a/stabbertests/testsuite.c +++ b/stabbertests/testsuite.c @@ -24,6 +24,9 @@ int main(int argc, char* argv[]) { unit_test_setup_teardown(sends_rooms_iq, init_prof_test, close_prof_test), + unit_test_setup_teardown(multiple_pings, + init_prof_test, + close_prof_test), }; return run_tests(all_tests); |