2013-12-14 11:17:53 -05:00
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <setjmp.h>
|
|
|
|
#include <cmocka.h>
|
|
|
|
#include <stdlib.h>
|
2013-12-15 14:38:23 -05:00
|
|
|
#include <string.h>
|
2013-12-14 12:15:43 -05:00
|
|
|
#include <glib.h>
|
2013-12-14 11:17:53 -05:00
|
|
|
|
|
|
|
#include "xmpp/xmpp.h"
|
2013-12-18 18:06:43 -05:00
|
|
|
#include "xmpp/mock_xmpp.h"
|
|
|
|
|
2013-12-14 11:17:53 -05:00
|
|
|
#include "ui/ui.h"
|
2013-12-19 16:05:39 -05:00
|
|
|
#include "ui/mock_ui.h"
|
2013-12-18 18:06:43 -05:00
|
|
|
|
2013-12-15 11:10:32 -05:00
|
|
|
#include "command/commands.h"
|
2013-12-14 11:17:53 -05:00
|
|
|
|
2013-12-26 08:37:22 -05:00
|
|
|
#include "config/accounts.h"
|
|
|
|
#include "config/mock_accounts.h"
|
2013-12-18 17:49:43 -05:00
|
|
|
|
2013-12-14 13:43:19 -05:00
|
|
|
static void test_with_connection_status(jabber_conn_status_t status)
|
2013-12-14 11:17:53 -05:00
|
|
|
{
|
2014-04-12 10:20:19 -04:00
|
|
|
mock_cons_show();
|
2013-12-14 12:15:43 -05:00
|
|
|
CommandHelp *help = malloc(sizeof(CommandHelp));
|
2013-12-15 15:38:26 -05:00
|
|
|
|
2013-12-18 17:49:43 -05:00
|
|
|
mock_connection_status(status);
|
|
|
|
|
2014-04-12 10:20:19 -04:00
|
|
|
expect_cons_show("You are either connected already, or a login is in process.");
|
|
|
|
|
2013-12-15 13:08:26 -05:00
|
|
|
gboolean result = cmd_connect(NULL, *help);
|
2013-12-14 13:43:19 -05:00
|
|
|
assert_true(result);
|
|
|
|
|
|
|
|
free(help);
|
|
|
|
}
|
|
|
|
|
2013-12-15 13:08:26 -05:00
|
|
|
void cmd_connect_shows_message_when_disconnecting(void **state)
|
2013-12-14 13:43:19 -05:00
|
|
|
{
|
|
|
|
test_with_connection_status(JABBER_DISCONNECTING);
|
|
|
|
}
|
|
|
|
|
2013-12-15 13:08:26 -05:00
|
|
|
void cmd_connect_shows_message_when_connecting(void **state)
|
2013-12-14 13:43:19 -05:00
|
|
|
{
|
|
|
|
test_with_connection_status(JABBER_CONNECTING);
|
|
|
|
}
|
|
|
|
|
2013-12-15 13:08:26 -05:00
|
|
|
void cmd_connect_shows_message_when_connected(void **state)
|
2013-12-14 13:43:19 -05:00
|
|
|
{
|
2013-12-15 13:08:26 -05:00
|
|
|
test_with_connection_status(JABBER_CONNECTED);
|
2013-12-14 13:43:19 -05:00
|
|
|
}
|
|
|
|
|
2013-12-15 13:08:26 -05:00
|
|
|
void cmd_connect_shows_message_when_undefined(void **state)
|
2013-12-14 13:43:19 -05:00
|
|
|
{
|
|
|
|
test_with_connection_status(JABBER_UNDEFINED);
|
|
|
|
}
|
2013-12-15 14:38:23 -05:00
|
|
|
|
2014-01-18 16:18:25 -05:00
|
|
|
void cmd_connect_shows_usage_when_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", "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_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("");
|
2014-01-18 17:45:24 -05:00
|
|
|
|
|
|
|
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("");
|
2014-01-18 17:50:17 -05:00
|
|
|
|
|
|
|
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("");
|
2014-01-18 17:55:15 -05:00
|
|
|
|
|
|
|
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("");
|
2014-01-18 16:18:25 -05:00
|
|
|
|
|
|
|
gboolean result = cmd_connect(args, *help);
|
|
|
|
assert_true(result);
|
|
|
|
|
|
|
|
free(help);
|
|
|
|
}
|
|
|
|
|
2014-01-18 17:02:51 -05:00
|
|
|
void cmd_connect_when_no_account(void **state)
|
2013-12-15 14:56:48 -05:00
|
|
|
{
|
2014-01-18 17:02:51 -05:00
|
|
|
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();
|
2013-12-19 16:05:39 -05:00
|
|
|
stub_cons_show();
|
2013-12-26 08:37:22 -05:00
|
|
|
mock_accounts_get_account();
|
2013-12-26 09:48:25 -05:00
|
|
|
mock_jabber_connect_with_details();
|
2013-12-15 14:56:48 -05:00
|
|
|
CommandHelp *help = malloc(sizeof(CommandHelp));
|
2014-01-18 17:02:51 -05:00
|
|
|
gchar *args[] = { "user@server.org", "port", "5432", NULL };
|
2013-12-15 14:56:48 -05:00
|
|
|
|
2013-12-18 17:49:43 -05:00
|
|
|
mock_connection_status(JABBER_DISCONNECTED);
|
2013-12-15 15:38:26 -05:00
|
|
|
|
2013-12-26 08:37:22 -05:00
|
|
|
accounts_get_account_return(NULL);
|
2013-12-15 14:56:48 -05:00
|
|
|
|
2014-01-18 17:02:51 -05:00
|
|
|
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);
|
2013-12-15 14:56:48 -05:00
|
|
|
|
|
|
|
gboolean result = cmd_connect(args, *help);
|
|
|
|
assert_true(result);
|
|
|
|
|
|
|
|
free(help);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmd_connect_fail_message(void **state)
|
|
|
|
{
|
2013-12-19 16:05:39 -05:00
|
|
|
stub_cons_show();
|
2013-12-22 17:14:15 -05:00
|
|
|
mock_cons_show_error();
|
|
|
|
stub_ui_ask_password();
|
2013-12-26 08:37:22 -05:00
|
|
|
mock_accounts_get_account();
|
2013-12-26 09:48:25 -05:00
|
|
|
mock_jabber_connect_with_details();
|
2013-12-15 14:56:48 -05:00
|
|
|
CommandHelp *help = malloc(sizeof(CommandHelp));
|
2013-12-15 15:02:25 -05:00
|
|
|
gchar *args[] = { "user@server.org", NULL };
|
2013-12-15 14:56:48 -05:00
|
|
|
|
2013-12-18 17:49:43 -05:00
|
|
|
mock_connection_status(JABBER_DISCONNECTED);
|
2013-12-15 15:38:26 -05:00
|
|
|
|
2013-12-26 08:37:22 -05:00
|
|
|
accounts_get_account_return(NULL);
|
2013-12-15 14:56:48 -05:00
|
|
|
|
2013-12-26 09:48:25 -05:00
|
|
|
jabber_connect_with_details_return(JABBER_DISCONNECTED);
|
2013-12-15 14:56:48 -05:00
|
|
|
|
2013-12-22 17:14:15 -05:00
|
|
|
expect_cons_show_error("Connection attempt for user@server.org failed.");
|
2013-12-15 14:56:48 -05:00
|
|
|
|
|
|
|
gboolean result = cmd_connect(args, *help);
|
|
|
|
assert_true(result);
|
|
|
|
|
|
|
|
free(help);
|
|
|
|
}
|
2013-12-15 15:38:26 -05:00
|
|
|
|
|
|
|
void cmd_connect_lowercases_argument(void **state)
|
|
|
|
{
|
2013-12-19 16:05:39 -05:00
|
|
|
stub_cons_show();
|
2013-12-22 17:14:15 -05:00
|
|
|
stub_ui_ask_password();
|
2013-12-26 08:37:22 -05:00
|
|
|
mock_accounts_get_account();
|
2013-12-26 09:48:25 -05:00
|
|
|
mock_jabber_connect_with_details();
|
2013-12-15 15:38:26 -05:00
|
|
|
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
|
|
gchar *args[] = { "USER@server.ORG", NULL };
|
|
|
|
|
2013-12-18 17:49:43 -05:00
|
|
|
mock_connection_status(JABBER_DISCONNECTED);
|
2013-12-15 15:38:26 -05:00
|
|
|
|
2013-12-26 08:37:22 -05:00
|
|
|
accounts_get_account_expect_and_return("user@server.org", NULL);
|
2013-12-15 15:38:26 -05:00
|
|
|
|
2013-12-26 09:48:25 -05:00
|
|
|
jabber_connect_with_details_return(JABBER_CONNECTING);
|
2013-12-15 15:38:26 -05:00
|
|
|
|
|
|
|
gboolean result = cmd_connect(args, *help);
|
|
|
|
assert_true(result);
|
|
|
|
|
|
|
|
free(help);
|
|
|
|
}
|
2013-12-15 15:52:30 -05:00
|
|
|
|
|
|
|
void cmd_connect_asks_password_when_not_in_account(void **state)
|
|
|
|
{
|
2013-12-19 16:05:39 -05:00
|
|
|
stub_cons_show();
|
2014-01-22 17:22:01 -05:00
|
|
|
mock_ui_ask_password();
|
2013-12-26 08:37:22 -05:00
|
|
|
mock_accounts_get_account();
|
2013-12-26 09:48:25 -05:00
|
|
|
mock_jabber_connect_with_account();
|
2013-12-15 15:52:30 -05:00
|
|
|
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
|
|
gchar *args[] = { "jabber_org", NULL };
|
2014-01-22 17:22:01 -05:00
|
|
|
ProfAccount *account = account_new("jabber_org", "me@jabber.org", NULL,
|
2014-05-11 14:32:07 -04:00
|
|
|
TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL);
|
2013-12-15 15:52:30 -05:00
|
|
|
|
2013-12-18 17:49:43 -05:00
|
|
|
mock_connection_status(JABBER_DISCONNECTED);
|
2013-12-15 15:52:30 -05:00
|
|
|
|
2013-12-26 08:37:22 -05:00
|
|
|
accounts_get_account_return(account);
|
2013-12-15 15:52:30 -05:00
|
|
|
|
2014-01-22 17:22:01 -05:00
|
|
|
mock_ui_ask_password_returns("password");
|
2013-12-15 15:52:30 -05:00
|
|
|
|
2013-12-26 09:48:25 -05:00
|
|
|
jabber_connect_with_account_return(JABBER_CONNECTING);
|
2013-12-15 15:52:30 -05:00
|
|
|
|
|
|
|
gboolean result = cmd_connect(args, *help);
|
|
|
|
assert_true(result);
|
|
|
|
|
|
|
|
free(help);
|
|
|
|
}
|
2013-12-15 16:23:58 -05:00
|
|
|
|
|
|
|
void cmd_connect_shows_message_when_connecting_with_account(void **state)
|
|
|
|
{
|
2013-12-19 16:05:39 -05:00
|
|
|
mock_cons_show();
|
2013-12-26 08:37:22 -05:00
|
|
|
mock_accounts_get_account();
|
2013-12-26 09:48:25 -05:00
|
|
|
mock_jabber_connect_with_account();
|
2013-12-15 16:23:58 -05:00
|
|
|
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
|
|
gchar *args[] = { "jabber_org", NULL };
|
2014-01-22 17:22:01 -05:00
|
|
|
ProfAccount *account = account_new("jabber_org", "user@jabber.org", "password",
|
2014-05-11 14:32:07 -04:00
|
|
|
TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL);
|
2013-12-15 16:23:58 -05:00
|
|
|
|
2013-12-18 17:49:43 -05:00
|
|
|
mock_connection_status(JABBER_DISCONNECTED);
|
2013-12-15 16:23:58 -05:00
|
|
|
|
2013-12-26 08:37:22 -05:00
|
|
|
accounts_get_account_return(account);
|
2013-12-15 16:23:58 -05:00
|
|
|
|
2013-12-19 16:05:39 -05:00
|
|
|
expect_cons_show("Connecting with account jabber_org as user@jabber.org/laptop");
|
2013-12-15 16:31:27 -05:00
|
|
|
|
2013-12-26 09:48:25 -05:00
|
|
|
jabber_connect_with_account_return(JABBER_CONNECTING);
|
2013-12-15 16:31:27 -05:00
|
|
|
|
|
|
|
gboolean result = cmd_connect(args, *help);
|
|
|
|
assert_true(result);
|
|
|
|
|
|
|
|
free(help);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmd_connect_connects_with_account(void **state)
|
|
|
|
{
|
2013-12-19 16:05:39 -05:00
|
|
|
stub_cons_show();
|
2013-12-26 08:37:22 -05:00
|
|
|
mock_accounts_get_account();
|
2013-12-26 09:48:25 -05:00
|
|
|
mock_jabber_connect_with_account();
|
2013-12-15 16:31:27 -05:00
|
|
|
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
|
|
gchar *args[] = { "jabber_org", NULL };
|
2014-01-22 17:22:01 -05:00
|
|
|
ProfAccount *account = account_new("jabber_org", "me@jabber.org", "password",
|
2014-05-11 14:32:07 -04:00
|
|
|
TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL);
|
2013-12-15 16:31:27 -05:00
|
|
|
|
2013-12-18 17:49:43 -05:00
|
|
|
mock_connection_status(JABBER_DISCONNECTED);
|
2013-12-15 16:31:27 -05:00
|
|
|
|
2013-12-26 08:37:22 -05:00
|
|
|
accounts_get_account_return(account);
|
2013-12-15 16:31:27 -05:00
|
|
|
|
2013-12-26 09:48:25 -05:00
|
|
|
jabber_connect_with_account_expect_and_return(account, JABBER_CONNECTING);
|
2013-12-15 16:23:58 -05:00
|
|
|
|
|
|
|
gboolean result = cmd_connect(args, *help);
|
|
|
|
assert_true(result);
|
|
|
|
|
|
|
|
free(help);
|
|
|
|
}
|