1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Added ping test

This commit is contained in:
James Booth 2015-05-24 19:24:01 +01:00
parent cddc55b51b
commit 79ecff1c52
5 changed files with 51 additions and 8 deletions

View File

@ -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();

View File

@ -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);

View File

@ -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>"
));
}

View File

@ -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);

View File

@ -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);