mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Added test for /join with nick option
This commit is contained in:
parent
e9b5d3294b
commit
dd1ee18c72
@ -1659,9 +1659,9 @@ cmd_join(gchar **args, struct cmd_help_t help)
|
|||||||
Jid *room_jid = jid_create_from_bare_and_resource(room, nick);
|
Jid *room_jid = jid_create_from_bare_and_resource(room, nick);
|
||||||
|
|
||||||
if (!muc_room_is_active(room_jid)) {
|
if (!muc_room_is_active(room_jid)) {
|
||||||
presence_join_room(room_jid, passwd);
|
presence_join_room(room, nick, passwd);
|
||||||
}
|
}
|
||||||
ui_room_join(room_jid);
|
ui_room_join(room);
|
||||||
muc_remove_invite(room);
|
muc_remove_invite(room);
|
||||||
|
|
||||||
jid_destroy(room_arg);
|
jid_destroy(room_arg);
|
||||||
|
@ -1083,14 +1083,14 @@ _ui_outgoing_msg(const char * const from, const char * const to,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_ui_room_join(Jid *jid)
|
_ui_room_join(char *room)
|
||||||
{
|
{
|
||||||
ProfWin *window = wins_get_by_recipient(jid->barejid);
|
ProfWin *window = wins_get_by_recipient(room);
|
||||||
int num = 0;
|
int num = 0;
|
||||||
|
|
||||||
// create new window
|
// create new window
|
||||||
if (window == NULL) {
|
if (window == NULL) {
|
||||||
window = wins_new(jid->barejid, WIN_MUC);
|
window = wins_new(room, WIN_MUC);
|
||||||
}
|
}
|
||||||
|
|
||||||
num = wins_get_num(window);
|
num = wins_get_num(window);
|
||||||
|
@ -103,7 +103,7 @@ void (*ui_disconnected)(void);
|
|||||||
void (*ui_recipient_gone)(const char * const barejid);
|
void (*ui_recipient_gone)(const char * const barejid);
|
||||||
void (*ui_outgoing_msg)(const char * const from, const char * const to,
|
void (*ui_outgoing_msg)(const char * const from, const char * const to,
|
||||||
const char * const message);
|
const char * const message);
|
||||||
void (*ui_room_join)(Jid *jid);
|
void (*ui_room_join)(char *room);
|
||||||
void (*ui_room_roster)(const char * const room, GList *roster, const char * const presence);
|
void (*ui_room_roster)(const char * const room, GList *roster, const char * const presence);
|
||||||
void (*ui_room_history)(const char * const room_jid, const char * const nick,
|
void (*ui_room_history)(const char * const room_jid, const char * const nick,
|
||||||
GTimeVal tv_stamp, const char * const message);
|
GTimeVal tv_stamp, const char * const message);
|
||||||
|
@ -301,9 +301,9 @@ _bookmark_handle_result(xmpp_conn_t * const conn,
|
|||||||
log_debug("Autojoin %s with nick=%s", jid, name);
|
log_debug("Autojoin %s with nick=%s", jid, name);
|
||||||
room_jid = jid_create_from_bare_and_resource(jid, name);
|
room_jid = jid_create_from_bare_and_resource(jid, name);
|
||||||
if (!muc_room_is_active(room_jid)) {
|
if (!muc_room_is_active(room_jid)) {
|
||||||
presence_join_room(room_jid, NULL);
|
presence_join_room(jid, name, NULL);
|
||||||
/* TODO: this should be removed after fixing #195 */
|
/* TODO: this should be removed after fixing #195 */
|
||||||
ui_room_join(room_jid);
|
ui_room_join(jid);
|
||||||
}
|
}
|
||||||
jid_destroy(room_jid);
|
jid_destroy(room_jid);
|
||||||
} else {
|
} else {
|
||||||
|
@ -260,10 +260,9 @@ _send_room_presence(xmpp_conn_t *conn, xmpp_stanza_t *presence)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_presence_join_room(Jid *jid, char * passwd)
|
_presence_join_room(char *room, char *nick, char * passwd)
|
||||||
{
|
{
|
||||||
assert(jid != NULL);
|
Jid *jid = jid_create_from_bare_and_resource(room, nick);
|
||||||
assert(jid->fulljid != NULL);
|
|
||||||
|
|
||||||
log_debug("Sending room join presence to: %s", jid->fulljid);
|
log_debug("Sending room join presence to: %s", jid->fulljid);
|
||||||
xmpp_ctx_t *ctx = connection_get_ctx();
|
xmpp_ctx_t *ctx = connection_get_ctx();
|
||||||
@ -285,6 +284,7 @@ _presence_join_room(Jid *jid, char * passwd)
|
|||||||
xmpp_stanza_release(presence);
|
xmpp_stanza_release(presence);
|
||||||
|
|
||||||
muc_join_room(jid->barejid, jid->resourcepart);
|
muc_join_room(jid->barejid, jid->resourcepart);
|
||||||
|
jid_destroy(jid);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -114,7 +114,7 @@ GSList* (*presence_get_subscription_requests)(void);
|
|||||||
gint (*presence_sub_request_count)(void);
|
gint (*presence_sub_request_count)(void);
|
||||||
void (*presence_reset_sub_request_search)(void);
|
void (*presence_reset_sub_request_search)(void);
|
||||||
char * (*presence_sub_request_find)(char * search_str);
|
char * (*presence_sub_request_find)(char * search_str);
|
||||||
void (*presence_join_room)(Jid *jid, char * passwd);
|
void (*presence_join_room)(char *room, char *nick, char * passwd);
|
||||||
void (*presence_change_room_nick)(const char * const room, const char * const nick);
|
void (*presence_change_room_nick)(const char * const room, const char * const nick);
|
||||||
void (*presence_leave_chat_room)(const char * const room_jid);
|
void (*presence_leave_chat_room)(const char * const room_jid);
|
||||||
void (*presence_update)(resource_presence_t status, const char * const msg,
|
void (*presence_update)(resource_presence_t status, const char * const msg,
|
||||||
|
@ -12,7 +12,11 @@
|
|||||||
#include "ui/ui.h"
|
#include "ui/ui.h"
|
||||||
#include "ui/mock_ui.h"
|
#include "ui/mock_ui.h"
|
||||||
|
|
||||||
|
#include "config/accounts.h"
|
||||||
|
#include "config/mock_accounts.h"
|
||||||
|
|
||||||
#include "command/commands.h"
|
#include "command/commands.h"
|
||||||
|
#include "muc.h"
|
||||||
|
|
||||||
static void test_with_connection_status(jabber_conn_status_t status)
|
static void test_with_connection_status(jabber_conn_status_t status)
|
||||||
{
|
{
|
||||||
@ -84,438 +88,29 @@ void cmd_join_shows_error_message_when_invalid_room_jid(void **state)
|
|||||||
free(help);
|
free(help);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
void cmd_join_uses_supplied_nick(void **state)
|
||||||
void cmd_connect_shows_usage_when_no_server_value(void **state)
|
|
||||||
{
|
{
|
||||||
stub_ui_ask_password();
|
char *account_name = "an_account";
|
||||||
mock_cons_show();
|
char *room = "room@conf.server.org";
|
||||||
|
char *nick = "bob";
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||||
help->usage = "some usage";
|
gchar *args[] = { room, "nick", nick, NULL };
|
||||||
gchar *args[] = { "user@server.org", "server", NULL };
|
ProfAccount *account = account_new(account_name, "user@server.org", NULL,
|
||||||
|
|
||||||
mock_connection_status(JABBER_DISCONNECTED);
|
|
||||||
|
|
||||||
expect_cons_show("Usage: some usage");
|
|
||||||
expect_cons_show("");
|
|
||||||
|
|
||||||
gboolean result = cmd_connect(args, *help);
|
|
||||||
assert_true(result);
|
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmd_connect_shows_usage_when_server_no_port_value(void **state)
|
|
||||||
{
|
|
||||||
stub_ui_ask_password();
|
|
||||||
mock_cons_show();
|
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
help->usage = "some usage";
|
|
||||||
gchar *args[] = { "user@server.org", "server", "aserver", "port", NULL };
|
|
||||||
|
|
||||||
mock_connection_status(JABBER_DISCONNECTED);
|
|
||||||
|
|
||||||
expect_cons_show("Usage: some usage");
|
|
||||||
expect_cons_show("");
|
|
||||||
|
|
||||||
gboolean result = cmd_connect(args, *help);
|
|
||||||
assert_true(result);
|
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmd_connect_shows_usage_when_no_port_value(void **state)
|
|
||||||
{
|
|
||||||
stub_ui_ask_password();
|
|
||||||
mock_cons_show();
|
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
help->usage = "some usage";
|
|
||||||
gchar *args[] = { "user@server.org", "port", NULL };
|
|
||||||
|
|
||||||
mock_connection_status(JABBER_DISCONNECTED);
|
|
||||||
|
|
||||||
expect_cons_show("Usage: some usage");
|
|
||||||
expect_cons_show("");
|
|
||||||
|
|
||||||
gboolean result = cmd_connect(args, *help);
|
|
||||||
assert_true(result);
|
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmd_connect_shows_usage_when_port_no_server_value(void **state)
|
|
||||||
{
|
|
||||||
stub_ui_ask_password();
|
|
||||||
mock_cons_show();
|
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
help->usage = "some usage";
|
|
||||||
gchar *args[] = { "user@server.org", "port", "5678", "server", NULL };
|
|
||||||
|
|
||||||
mock_connection_status(JABBER_DISCONNECTED);
|
|
||||||
|
|
||||||
expect_cons_show("Usage: some usage");
|
|
||||||
expect_cons_show("");
|
|
||||||
|
|
||||||
gboolean result = cmd_connect(args, *help);
|
|
||||||
assert_true(result);
|
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmd_connect_shows_message_when_port_0(void **state)
|
|
||||||
{
|
|
||||||
stub_ui_ask_password();
|
|
||||||
mock_cons_show();
|
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "user@server.org", "port", "0", NULL };
|
|
||||||
|
|
||||||
mock_connection_status(JABBER_DISCONNECTED);
|
|
||||||
|
|
||||||
expect_cons_show("Value 0 out of range. Must be in 1..65535.");
|
|
||||||
expect_cons_show("");
|
|
||||||
|
|
||||||
gboolean result = cmd_connect(args, *help);
|
|
||||||
assert_true(result);
|
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmd_connect_shows_message_when_port_minus1(void **state)
|
|
||||||
{
|
|
||||||
stub_ui_ask_password();
|
|
||||||
mock_cons_show();
|
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "user@server.org", "port", "-1", NULL };
|
|
||||||
|
|
||||||
mock_connection_status(JABBER_DISCONNECTED);
|
|
||||||
|
|
||||||
expect_cons_show("Value -1 out of range. Must be in 1..65535.");
|
|
||||||
expect_cons_show("");
|
|
||||||
|
|
||||||
gboolean result = cmd_connect(args, *help);
|
|
||||||
assert_true(result);
|
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmd_connect_shows_message_when_port_65536(void **state)
|
|
||||||
{
|
|
||||||
stub_ui_ask_password();
|
|
||||||
mock_cons_show();
|
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "user@server.org", "port", "65536", NULL };
|
|
||||||
|
|
||||||
mock_connection_status(JABBER_DISCONNECTED);
|
|
||||||
|
|
||||||
expect_cons_show("Value 65536 out of range. Must be in 1..65535.");
|
|
||||||
expect_cons_show("");
|
|
||||||
|
|
||||||
gboolean result = cmd_connect(args, *help);
|
|
||||||
assert_true(result);
|
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmd_connect_shows_message_when_port_contains_chars(void **state)
|
|
||||||
{
|
|
||||||
stub_ui_ask_password();
|
|
||||||
mock_cons_show();
|
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "user@server.org", "port", "52f66", NULL };
|
|
||||||
|
|
||||||
mock_connection_status(JABBER_DISCONNECTED);
|
|
||||||
|
|
||||||
expect_cons_show("Could not convert \"52f66\" to a number.");
|
|
||||||
expect_cons_show("");
|
|
||||||
|
|
||||||
gboolean result = cmd_connect(args, *help);
|
|
||||||
assert_true(result);
|
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmd_connect_shows_usage_when_server_provided_twice(void **state)
|
|
||||||
{
|
|
||||||
stub_ui_ask_password();
|
|
||||||
mock_cons_show();
|
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
help->usage = "some usage";
|
|
||||||
gchar *args[] = { "user@server.org", "server", "server1", "server", "server2", NULL };
|
|
||||||
|
|
||||||
mock_connection_status(JABBER_DISCONNECTED);
|
|
||||||
|
|
||||||
expect_cons_show("Usage: some usage");
|
|
||||||
expect_cons_show("");
|
|
||||||
|
|
||||||
gboolean result = cmd_connect(args, *help);
|
|
||||||
assert_true(result);
|
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmd_connect_shows_usage_when_port_provided_twice(void **state)
|
|
||||||
{
|
|
||||||
stub_ui_ask_password();
|
|
||||||
mock_cons_show();
|
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
help->usage = "some usage";
|
|
||||||
gchar *args[] = { "user@server.org", "port", "1111", "port", "1111", NULL };
|
|
||||||
|
|
||||||
mock_connection_status(JABBER_DISCONNECTED);
|
|
||||||
|
|
||||||
expect_cons_show("Usage: some usage");
|
|
||||||
expect_cons_show("");
|
|
||||||
|
|
||||||
gboolean result = cmd_connect(args, *help);
|
|
||||||
assert_true(result);
|
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmd_connect_shows_usage_when_invalid_first_property(void **state)
|
|
||||||
{
|
|
||||||
stub_ui_ask_password();
|
|
||||||
mock_cons_show();
|
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
help->usage = "some usage";
|
|
||||||
gchar *args[] = { "user@server.org", "wrong", "server", NULL };
|
|
||||||
|
|
||||||
mock_connection_status(JABBER_DISCONNECTED);
|
|
||||||
|
|
||||||
expect_cons_show("Usage: some usage");
|
|
||||||
expect_cons_show("");
|
|
||||||
|
|
||||||
gboolean result = cmd_connect(args, *help);
|
|
||||||
assert_true(result);
|
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmd_connect_shows_usage_when_invalid_second_property(void **state)
|
|
||||||
{
|
|
||||||
stub_ui_ask_password();
|
|
||||||
mock_cons_show();
|
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
help->usage = "some usage";
|
|
||||||
gchar *args[] = { "user@server.org", "server", "aserver", "wrong", "1234", NULL };
|
|
||||||
|
|
||||||
mock_connection_status(JABBER_DISCONNECTED);
|
|
||||||
|
|
||||||
expect_cons_show("Usage: some usage");
|
|
||||||
expect_cons_show("");
|
|
||||||
|
|
||||||
gboolean result = cmd_connect(args, *help);
|
|
||||||
assert_true(result);
|
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmd_connect_when_no_account(void **state)
|
|
||||||
{
|
|
||||||
mock_cons_show();
|
|
||||||
mock_accounts_get_account();
|
|
||||||
mock_ui_ask_password();
|
|
||||||
mock_jabber_connect_with_details();
|
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "user@server.org", NULL };
|
|
||||||
|
|
||||||
mock_connection_status(JABBER_DISCONNECTED);
|
|
||||||
|
|
||||||
accounts_get_account_expect_and_return("user@server.org", NULL);
|
|
||||||
|
|
||||||
mock_ui_ask_password_returns("password");
|
|
||||||
|
|
||||||
expect_cons_show("Connecting as user@server.org");
|
|
||||||
|
|
||||||
jabber_connect_with_details_expect_and_return("user@server.org", "password", NULL, 0, JABBER_CONNECTING);
|
|
||||||
|
|
||||||
gboolean result = cmd_connect(args, *help);
|
|
||||||
assert_true(result);
|
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmd_connect_with_server_when_provided(void **state)
|
|
||||||
{
|
|
||||||
mock_ui_ask_password();
|
|
||||||
stub_cons_show();
|
|
||||||
mock_accounts_get_account();
|
|
||||||
mock_jabber_connect_with_details();
|
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "user@server.org", "server", "aserver", NULL };
|
|
||||||
|
|
||||||
mock_connection_status(JABBER_DISCONNECTED);
|
|
||||||
|
|
||||||
accounts_get_account_return(NULL);
|
|
||||||
|
|
||||||
mock_ui_ask_password_returns("password");
|
|
||||||
|
|
||||||
jabber_connect_with_details_expect_and_return("user@server.org", "password", "aserver", 0, JABBER_CONNECTING);
|
|
||||||
|
|
||||||
gboolean result = cmd_connect(args, *help);
|
|
||||||
assert_true(result);
|
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmd_connect_with_port_when_provided(void **state)
|
|
||||||
{
|
|
||||||
mock_ui_ask_password();
|
|
||||||
stub_cons_show();
|
|
||||||
mock_accounts_get_account();
|
|
||||||
mock_jabber_connect_with_details();
|
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "user@server.org", "port", "5432", NULL };
|
|
||||||
|
|
||||||
mock_connection_status(JABBER_DISCONNECTED);
|
|
||||||
|
|
||||||
accounts_get_account_return(NULL);
|
|
||||||
|
|
||||||
mock_ui_ask_password_returns("password");
|
|
||||||
|
|
||||||
jabber_connect_with_details_expect_and_return("user@server.org", "password", NULL, 5432, JABBER_CONNECTING);
|
|
||||||
|
|
||||||
gboolean result = cmd_connect(args, *help);
|
|
||||||
assert_true(result);
|
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmd_connect_with_server_and_port_when_provided(void **state)
|
|
||||||
{
|
|
||||||
mock_ui_ask_password();
|
|
||||||
stub_cons_show();
|
|
||||||
mock_accounts_get_account();
|
|
||||||
mock_jabber_connect_with_details();
|
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "user@server.org", "port", "5432", "server", "aserver", NULL };
|
|
||||||
|
|
||||||
mock_connection_status(JABBER_DISCONNECTED);
|
|
||||||
|
|
||||||
accounts_get_account_return(NULL);
|
|
||||||
|
|
||||||
mock_ui_ask_password_returns("password");
|
|
||||||
|
|
||||||
jabber_connect_with_details_expect_and_return("user@server.org", "password", "aserver", 5432, JABBER_CONNECTING);
|
|
||||||
|
|
||||||
gboolean result = cmd_connect(args, *help);
|
|
||||||
assert_true(result);
|
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmd_connect_fail_message(void **state)
|
|
||||||
{
|
|
||||||
stub_cons_show();
|
|
||||||
mock_cons_show_error();
|
|
||||||
stub_ui_ask_password();
|
|
||||||
mock_accounts_get_account();
|
|
||||||
mock_jabber_connect_with_details();
|
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "user@server.org", NULL };
|
|
||||||
|
|
||||||
mock_connection_status(JABBER_DISCONNECTED);
|
|
||||||
|
|
||||||
accounts_get_account_return(NULL);
|
|
||||||
|
|
||||||
jabber_connect_with_details_return(JABBER_DISCONNECTED);
|
|
||||||
|
|
||||||
expect_cons_show_error("Connection attempt for user@server.org failed.");
|
|
||||||
|
|
||||||
gboolean result = cmd_connect(args, *help);
|
|
||||||
assert_true(result);
|
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmd_connect_lowercases_argument(void **state)
|
|
||||||
{
|
|
||||||
stub_cons_show();
|
|
||||||
stub_ui_ask_password();
|
|
||||||
mock_accounts_get_account();
|
|
||||||
mock_jabber_connect_with_details();
|
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "USER@server.ORG", NULL };
|
|
||||||
|
|
||||||
mock_connection_status(JABBER_DISCONNECTED);
|
|
||||||
|
|
||||||
accounts_get_account_expect_and_return("user@server.org", NULL);
|
|
||||||
|
|
||||||
jabber_connect_with_details_return(JABBER_CONNECTING);
|
|
||||||
|
|
||||||
gboolean result = cmd_connect(args, *help);
|
|
||||||
assert_true(result);
|
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmd_connect_asks_password_when_not_in_account(void **state)
|
|
||||||
{
|
|
||||||
stub_cons_show();
|
|
||||||
mock_ui_ask_password();
|
|
||||||
mock_accounts_get_account();
|
|
||||||
mock_jabber_connect_with_account();
|
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "jabber_org", NULL };
|
|
||||||
ProfAccount *account = account_new("jabber_org", "me@jabber.org", NULL,
|
|
||||||
TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL);
|
|
||||||
|
|
||||||
mock_connection_status(JABBER_DISCONNECTED);
|
|
||||||
|
|
||||||
accounts_get_account_return(account);
|
|
||||||
|
|
||||||
mock_ui_ask_password_returns("password");
|
|
||||||
|
|
||||||
jabber_connect_with_account_return(JABBER_CONNECTING);
|
|
||||||
|
|
||||||
gboolean result = cmd_connect(args, *help);
|
|
||||||
assert_true(result);
|
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmd_connect_shows_message_when_connecting_with_account(void **state)
|
|
||||||
{
|
|
||||||
mock_cons_show();
|
|
||||||
mock_accounts_get_account();
|
|
||||||
mock_jabber_connect_with_account();
|
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "jabber_org", NULL };
|
|
||||||
ProfAccount *account = account_new("jabber_org", "user@jabber.org", "password",
|
|
||||||
TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL);
|
TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL);
|
||||||
|
|
||||||
mock_connection_status(JABBER_DISCONNECTED);
|
muc_init();
|
||||||
|
|
||||||
accounts_get_account_return(account);
|
mock_connection_status(JABBER_CONNECTED);
|
||||||
|
mock_connection_account_name(account_name);
|
||||||
expect_cons_show("Connecting with account jabber_org as user@jabber.org/laptop");
|
|
||||||
|
|
||||||
jabber_connect_with_account_return(JABBER_CONNECTING);
|
|
||||||
|
|
||||||
gboolean result = cmd_connect(args, *help);
|
|
||||||
assert_true(result);
|
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmd_connect_connects_with_account(void **state)
|
|
||||||
{
|
|
||||||
stub_cons_show();
|
|
||||||
mock_accounts_get_account();
|
mock_accounts_get_account();
|
||||||
mock_jabber_connect_with_account();
|
accounts_get_account_expect_and_return(account_name, account);
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "jabber_org", NULL };
|
|
||||||
ProfAccount *account = account_new("jabber_org", "me@jabber.org", "password",
|
|
||||||
TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL);
|
|
||||||
|
|
||||||
mock_connection_status(JABBER_DISCONNECTED);
|
mock_presence_join_room();
|
||||||
|
presence_join_room_expect(room, nick, NULL);
|
||||||
accounts_get_account_return(account);
|
ui_room_join_expect(room);
|
||||||
|
|
||||||
jabber_connect_with_account_expect_and_return(account, JABBER_CONNECTING);
|
gboolean result = cmd_join(args, *help);
|
||||||
|
|
||||||
gboolean result = cmd_connect(args, *help);
|
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
free(help);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
@ -4,3 +4,4 @@ void cmd_join_shows_message_when_disconnected(void **state);
|
|||||||
void cmd_join_shows_message_when_undefined(void **state);
|
void cmd_join_shows_message_when_undefined(void **state);
|
||||||
void cmd_join_shows_usage_when_no_args(void **state);
|
void cmd_join_shows_usage_when_no_args(void **state);
|
||||||
void cmd_join_shows_error_message_when_invalid_room_jid(void **state);
|
void cmd_join_shows_error_message_when_invalid_room_jid(void **state);
|
||||||
|
void cmd_join_uses_supplied_nick(void **state);
|
||||||
|
@ -493,6 +493,7 @@ int main(int argc, char* argv[]) {
|
|||||||
unit_test(cmd_join_shows_message_when_undefined),
|
unit_test(cmd_join_shows_message_when_undefined),
|
||||||
unit_test(cmd_join_shows_usage_when_no_args),
|
unit_test(cmd_join_shows_usage_when_no_args),
|
||||||
unit_test(cmd_join_shows_error_message_when_invalid_room_jid),
|
unit_test(cmd_join_shows_error_message_when_invalid_room_jid),
|
||||||
|
unit_test(cmd_join_uses_supplied_nick),
|
||||||
};
|
};
|
||||||
|
|
||||||
return run_tests(all_tests);
|
return run_tests(all_tests);
|
||||||
|
@ -187,6 +187,12 @@ gboolean _mock_ui_current_win_is_otr(void)
|
|||||||
return (gboolean)mock();
|
return (gboolean)mock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
void _mock_ui_room_join(char *room)
|
||||||
|
{
|
||||||
|
check_expected(room);
|
||||||
|
}
|
||||||
|
|
||||||
// bind mocks and stubs
|
// bind mocks and stubs
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -429,3 +435,10 @@ ui_current_win_is_otr_returns(gboolean result)
|
|||||||
ui_current_win_is_otr = _mock_ui_current_win_is_otr;
|
ui_current_win_is_otr = _mock_ui_current_win_is_otr;
|
||||||
will_return(_mock_ui_current_win_is_otr, result);
|
will_return(_mock_ui_current_win_is_otr, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ui_room_join_expect(char *room)
|
||||||
|
{
|
||||||
|
ui_room_join = _mock_ui_room_join;
|
||||||
|
expect_string(_mock_ui_room_join, room, room);
|
||||||
|
}
|
||||||
|
@ -59,4 +59,6 @@ void ui_current_print_line_expect(char *message);
|
|||||||
|
|
||||||
void ui_current_win_is_otr_returns(gboolean result);
|
void ui_current_win_is_otr_returns(gboolean result);
|
||||||
|
|
||||||
|
void ui_room_join_expect(char *room);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -88,6 +88,14 @@ _mock_message_send(const char * const msg, const char * const recipient)
|
|||||||
check_expected(recipient);
|
check_expected(recipient);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_mock_presence_join_room(char *room, char*nick, char *passwd)
|
||||||
|
{
|
||||||
|
check_expected(room);
|
||||||
|
check_expected(nick);
|
||||||
|
check_expected(passwd);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
mock_jabber_connect_with_details(void)
|
mock_jabber_connect_with_details(void)
|
||||||
{
|
{
|
||||||
@ -125,6 +133,12 @@ mock_bookmark_remove(void)
|
|||||||
bookmark_remove = _mock_bookmark_remove;
|
bookmark_remove = _mock_bookmark_remove;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
mock_presence_join_room(void)
|
||||||
|
{
|
||||||
|
presence_join_room = _mock_presence_join_room;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
bookmark_get_list_returns(GList *bookmarks)
|
bookmark_get_list_returns(GList *bookmarks)
|
||||||
{
|
{
|
||||||
@ -234,3 +248,15 @@ message_send_expect(char *message, char *recipient)
|
|||||||
expect_string(_mock_message_send, msg, message);
|
expect_string(_mock_message_send, msg, message);
|
||||||
expect_string(_mock_message_send, recipient, recipient);
|
expect_string(_mock_message_send, recipient, recipient);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
presence_join_room_expect(char *room, char *nick, char *passwd)
|
||||||
|
{
|
||||||
|
expect_string(_mock_presence_join_room, room, room);
|
||||||
|
expect_string(_mock_presence_join_room, nick, nick);
|
||||||
|
if (passwd == NULL) {
|
||||||
|
expect_any(_mock_presence_join_room, passwd);
|
||||||
|
} else {
|
||||||
|
expect_string(_mock_presence_join_room, passwd, passwd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -33,4 +33,7 @@ void expect_and_return_bookmark_remove(char *expected_jid, gboolean expected_aut
|
|||||||
|
|
||||||
void message_send_expect(char *message, char *recipient);
|
void message_send_expect(char *message, char *recipient);
|
||||||
|
|
||||||
|
void mock_presence_join_room(void);
|
||||||
|
void presence_join_room_expect(char *room, char *nick, char *passwd);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user