mirror of
https://github.com/profanity-im/profanity.git
synced 2025-02-02 15:08:15 -05:00
Added ping test
This commit is contained in:
parent
cddc55b51b
commit
79ecff1c52
@ -36,10 +36,10 @@ char *config_orig;
|
|||||||
char *data_orig;
|
char *data_orig;
|
||||||
|
|
||||||
void
|
void
|
||||||
prof_process_xmpp(void)
|
prof_process_xmpp(int loops)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (i < 20) {
|
while (i < loops) {
|
||||||
jabber_process_events(10);
|
jabber_process_events(10);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
@ -198,7 +198,7 @@ void
|
|||||||
close_prof_test(void **state)
|
close_prof_test(void **state)
|
||||||
{
|
{
|
||||||
jabber_disconnect();
|
jabber_disconnect();
|
||||||
prof_process_xmpp();
|
prof_process_xmpp(20);
|
||||||
jabber_shutdown();
|
jabber_shutdown();
|
||||||
roster_free();
|
roster_free();
|
||||||
muc_close();
|
muc_close();
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
void init_prof_test(void **state);
|
void init_prof_test(void **state);
|
||||||
void close_prof_test(void **state);
|
void close_prof_test(void **state);
|
||||||
void prof_process_xmpp(void);
|
void prof_process_xmpp(int loops);
|
||||||
|
@ -22,7 +22,7 @@ connect_jid(void **state)
|
|||||||
expect_cons_show("Connecting as stabber@localhost");
|
expect_cons_show("Connecting as stabber@localhost");
|
||||||
|
|
||||||
cmd_process_input(strdup("/connect stabber@localhost port 5230"));
|
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();
|
jabber_conn_status_t status = jabber_get_connection_status();
|
||||||
assert_true(status == JABBER_CONNECTED);
|
assert_true(status == JABBER_CONNECTED);
|
||||||
@ -37,7 +37,7 @@ connect_bad_password(void **state)
|
|||||||
expect_cons_show_error("Login failed.");
|
expect_cons_show_error("Login failed.");
|
||||||
|
|
||||||
cmd_process_input(strdup("/connect stabber@localhost port 5230"));
|
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();
|
jabber_conn_status_t status = jabber_get_connection_status();
|
||||||
assert_true(status == JABBER_DISCONNECTED);
|
assert_true(status == JABBER_DISCONNECTED);
|
||||||
@ -51,7 +51,7 @@ sends_rooms_iq(void **state)
|
|||||||
expect_any_cons_show();
|
expect_any_cons_show();
|
||||||
|
|
||||||
cmd_process_input(strdup("/connect stabber@localhost port 5230"));
|
cmd_process_input(strdup("/connect stabber@localhost port 5230"));
|
||||||
prof_process_xmpp();
|
prof_process_xmpp(20);
|
||||||
|
|
||||||
stbbr_for("confreq",
|
stbbr_for("confreq",
|
||||||
"<iq id=\"confreq\" type=\"result\" to=\"stabber@localhost/profanity\" from=\"conference.localhost\">"
|
"<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"));
|
cmd_process_input(strdup("/rooms"));
|
||||||
prof_process_xmpp();
|
prof_process_xmpp(20);
|
||||||
|
|
||||||
assert_true(stbbr_verify_last(
|
assert_true(stbbr_verify_last(
|
||||||
"<iq id=\"confreq\" to=\"conference.localhost\" type=\"get\">"
|
"<iq id=\"confreq\" to=\"conference.localhost\" type=\"get\">"
|
||||||
@ -71,3 +71,42 @@ sends_rooms_iq(void **state)
|
|||||||
"</iq>"
|
"</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>"
|
||||||
|
));
|
||||||
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
void connect_jid(void **state);
|
void connect_jid(void **state);
|
||||||
void connect_bad_password(void **state);
|
void connect_bad_password(void **state);
|
||||||
void sends_rooms_iq(void **state);
|
void sends_rooms_iq(void **state);
|
||||||
|
void multiple_pings(void **state);
|
||||||
|
|
||||||
|
@ -24,6 +24,9 @@ int main(int argc, char* argv[]) {
|
|||||||
unit_test_setup_teardown(sends_rooms_iq,
|
unit_test_setup_teardown(sends_rooms_iq,
|
||||||
init_prof_test,
|
init_prof_test,
|
||||||
close_prof_test),
|
close_prof_test),
|
||||||
|
unit_test_setup_teardown(multiple_pings,
|
||||||
|
init_prof_test,
|
||||||
|
close_prof_test),
|
||||||
};
|
};
|
||||||
|
|
||||||
return run_tests(all_tests);
|
return run_tests(all_tests);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user