1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-07-07 18:04:15 -04:00
profanity/stabbertests/test_connect.c

74 lines
1.9 KiB
C
Raw Normal View History

2015-05-16 20:11:03 -04:00
#include <glib.h>
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include <stdlib.h>
2015-05-17 17:05:43 -04:00
#include <string.h>
#include <stabber.h>
#include "proftest.h"
#include "xmpp/xmpp.h"
#include "ui/stub_ui.h"
2015-05-23 23:13:28 -04:00
#include "ui/window.h"
2015-05-17 17:05:43 -04:00
#include "command/command.h"
2015-05-16 20:11:03 -04:00
void
2015-05-23 19:56:13 -04:00
connect_jid(void **state)
2015-05-16 20:11:03 -04:00
{
2015-05-23 23:13:28 -04:00
will_return(ui_ask_password, strdup("password"));
2015-05-17 17:05:43 -04:00
expect_cons_show("Connecting as stabber@localhost");
2015-05-23 23:13:28 -04:00
cmd_process_input(strdup("/connect stabber@localhost port 5230"));
2015-05-17 17:05:43 -04:00
prof_process_xmpp();
jabber_conn_status_t status = jabber_get_connection_status();
assert_true(status == JABBER_CONNECTED);
2015-05-16 20:11:03 -04:00
}
2015-05-23 19:56:13 -04:00
void
connect_bad_password(void **state)
{
will_return(ui_ask_password, strdup("badpassword"));
expect_cons_show("Connecting as stabber@localhost");
expect_cons_show_error("Login failed.");
2015-05-23 23:13:28 -04:00
cmd_process_input(strdup("/connect stabber@localhost port 5230"));
2015-05-23 19:56:13 -04:00
prof_process_xmpp();
jabber_conn_status_t status = jabber_get_connection_status();
assert_true(status == JABBER_DISCONNECTED);
}
2015-05-23 23:13:28 -04:00
void
sends_rooms_iq(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();
2015-05-24 13:45:17 -04:00
stbbr_for("confreq",
"<iq id=\"confreq\" type=\"result\" to=\"stabber@localhost/profanity\" from=\"conference.localhost\">"
"<query xmlns=\"http://jabber.org/protocol/disco#items\">"
"<item jid=\"chatroom@conference.localhost\" name=\"A chat room\"/>"
"<item jid=\"hangout@conference.localhost\" name=\"Another chat room\"/>"
"</query>"
"</iq>"
);
2015-05-23 23:13:28 -04:00
cmd_process_input(strdup("/rooms"));
prof_process_xmpp();
2015-05-24 13:35:06 -04:00
assert_true(stbbr_verify_last(
"<iq id=\"confreq\" to=\"conference.localhost\" type=\"get\">"
"<query xmlns=\"http://jabber.org/protocol/disco#items\"/>"
"</iq>"
));
2015-05-23 23:13:28 -04:00
}