mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Fixed tests for new command format
This commit is contained in:
parent
59d5dd73a7
commit
8119025120
34
Makefile.am
34
Makefile.am
@ -68,29 +68,29 @@ unittest_sources = \
|
|||||||
tests/unittests/log/stub_log.c \
|
tests/unittests/log/stub_log.c \
|
||||||
tests/unittests/config/stub_accounts.c \
|
tests/unittests/config/stub_accounts.c \
|
||||||
tests/unittests/helpers.c tests/unittests/helpers.h \
|
tests/unittests/helpers.c tests/unittests/helpers.h \
|
||||||
tests/unittests/test_cmd_account.c tests/unittests/test_cmd_account.h \
|
tests/unittests/test_form.c tests/unittests/test_form.h \
|
||||||
|
tests/unittests/test_common.c tests/unittests/test_common.h \
|
||||||
|
tests/unittests/test_autocomplete.c tests/unittests/test_autocomplete.h \
|
||||||
|
tests/unittests/test_jid.c tests/unittests/test_jid.h \
|
||||||
|
tests/unittests/test_parser.c tests/unittests/test_parser.h \
|
||||||
|
tests/unittests/test_roster_list.c tests/unittests/test_roster_list.h \
|
||||||
|
tests/unittests/test_chat_session.c tests/unittests/test_chat_session.h \
|
||||||
|
tests/unittests/test_contact.c tests/unittests/test_contact.h \
|
||||||
|
tests/unittests/test_preferences.c tests/unittests/test_preferences.h \
|
||||||
|
tests/unittests/test_server_events.c tests/unittests/test_server_events.h \
|
||||||
|
tests/unittests/test_muc.c tests/unittests/test_muc.h \
|
||||||
|
tests/unittests/test_cmd_statuses.c tests/unittests/test_cmd_statuses.h \
|
||||||
tests/unittests/test_cmd_alias.c tests/unittests/test_cmd_alias.h \
|
tests/unittests/test_cmd_alias.c tests/unittests/test_cmd_alias.h \
|
||||||
tests/unittests/test_cmd_bookmark.c tests/unittests/test_cmd_bookmark.h \
|
|
||||||
tests/unittests/test_cmd_connect.c tests/unittests/test_cmd_connect.h \
|
tests/unittests/test_cmd_connect.c tests/unittests/test_cmd_connect.h \
|
||||||
tests/unittests/test_cmd_join.c tests/unittests/test_cmd_join.h \
|
tests/unittests/test_cmd_rooms.c tests/unittests/test_cmd_rooms.h \
|
||||||
|
tests/unittests/test_cmd_account.c tests/unittests/test_cmd_account.h \
|
||||||
|
tests/unittests/test_cmd_sub.c tests/unittests/test_cmd_sub.h \
|
||||||
|
tests/unittests/test_cmd_bookmark.c tests/unittests/test_cmd_bookmark.h \
|
||||||
tests/unittests/test_cmd_otr.c tests/unittests/test_cmd_otr.h \
|
tests/unittests/test_cmd_otr.c tests/unittests/test_cmd_otr.h \
|
||||||
tests/unittests/test_cmd_pgp.c tests/unittests/test_cmd_pgp.h \
|
tests/unittests/test_cmd_pgp.c tests/unittests/test_cmd_pgp.h \
|
||||||
tests/unittests/test_cmd_rooms.c tests/unittests/test_cmd_rooms.h \
|
tests/unittests/test_cmd_join.c tests/unittests/test_cmd_join.h \
|
||||||
tests/unittests/test_cmd_roster.c tests/unittests/test_cmd_roster.h \
|
tests/unittests/test_cmd_roster.c tests/unittests/test_cmd_roster.h \
|
||||||
tests/unittests/test_cmd_statuses.c tests/unittests/test_cmd_statuses.h \
|
|
||||||
tests/unittests/test_cmd_sub.c tests/unittests/test_cmd_sub.h \
|
|
||||||
tests/unittests/test_cmd_disconnect.c tests/unittests/test_cmd_disconnect.h \
|
tests/unittests/test_cmd_disconnect.c tests/unittests/test_cmd_disconnect.h \
|
||||||
tests/unittests/test_common.c tests/unittests/test_common.h \
|
|
||||||
tests/unittests/test_contact.c tests/unittests/test_contact.h \
|
|
||||||
tests/unittests/test_form.c tests/unittests/test_form.h \
|
|
||||||
tests/unittests/test_jid.c tests/unittests/test_jid.h \
|
|
||||||
tests/unittests/test_muc.c tests/unittests/test_muc.h \
|
|
||||||
tests/unittests/test_parser.c tests/unittests/test_parser.h \
|
|
||||||
tests/unittests/test_preferences.c tests/unittests/test_preferences.h \
|
|
||||||
tests/unittests/test_roster_list.c tests/unittests/test_roster_list.h \
|
|
||||||
tests/unittests/test_server_events.c tests/unittests/test_server_events.h \
|
|
||||||
tests/unittests/test_autocomplete.c tests/unittests/test_autocomplete.h \
|
|
||||||
tests/unittests/test_chat_session.c tests/unittests/test_chat_session.h \
|
|
||||||
tests/unittests/unittests.c
|
tests/unittests/unittests.c
|
||||||
|
|
||||||
functionaltest_sources = \
|
functionaltest_sources = \
|
||||||
|
@ -166,7 +166,9 @@ void
|
|||||||
muc_invites_clear(void)
|
muc_invites_clear(void)
|
||||||
{
|
{
|
||||||
autocomplete_clear(invite_ac);
|
autocomplete_clear(invite_ac);
|
||||||
g_hash_table_remove_all(invite_passwords);
|
if (invite_passwords) {
|
||||||
|
g_hash_table_remove_all(invite_passwords);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -15,26 +15,23 @@
|
|||||||
|
|
||||||
#include "command/commands.h"
|
#include "command/commands.h"
|
||||||
|
|
||||||
|
#define CMD_ACCOUNT "/account"
|
||||||
|
|
||||||
void cmd_account_shows_usage_when_not_connected_and_no_args(void **state)
|
void cmd_account_shows_usage_when_not_connected_and_no_args(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
help->usage = "some usage";
|
|
||||||
gchar *args[] = { NULL };
|
gchar *args[] = { NULL };
|
||||||
|
|
||||||
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
|
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
|
||||||
|
|
||||||
expect_cons_show("Usage: some usage");
|
expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT);
|
||||||
|
|
||||||
gboolean result = cmd_account(NULL, args, *help);
|
gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void cmd_account_shows_account_when_connected_and_no_args(void **state)
|
void cmd_account_shows_account_when_connected_and_no_args(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
ProfAccount *account = account_new("jabber_org", "me@jabber.org", NULL, NULL,
|
ProfAccount *account = account_new("jabber_org", "me@jabber.org", NULL, NULL,
|
||||||
TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||||
gchar *args[] = { NULL };
|
gchar *args[] = { NULL };
|
||||||
@ -46,15 +43,12 @@ void cmd_account_shows_account_when_connected_and_no_args(void **state)
|
|||||||
|
|
||||||
expect_memory(cons_show_account, account, account, sizeof(ProfAccount));
|
expect_memory(cons_show_account, account, account, sizeof(ProfAccount));
|
||||||
|
|
||||||
gboolean result = cmd_account(NULL, args, *help);
|
gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_account_list_shows_accounts(void **state)
|
void cmd_account_list_shows_accounts(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "list", NULL };
|
gchar *args[] = { "list", NULL };
|
||||||
|
|
||||||
gchar **accounts = malloc(sizeof(gchar *) * 4);
|
gchar **accounts = malloc(sizeof(gchar *) * 4);
|
||||||
@ -67,29 +61,22 @@ void cmd_account_list_shows_accounts(void **state)
|
|||||||
|
|
||||||
expect_memory(cons_show_account_list, accounts, accounts, sizeof(accounts));
|
expect_memory(cons_show_account_list, accounts, accounts, sizeof(accounts));
|
||||||
|
|
||||||
gboolean result = cmd_account(NULL, args, *help);
|
gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_account_show_shows_usage_when_no_arg(void **state)
|
void cmd_account_show_shows_usage_when_no_arg(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
help->usage = "some usage";
|
|
||||||
gchar *args[] = { "show", NULL };
|
gchar *args[] = { "show", NULL };
|
||||||
|
|
||||||
expect_cons_show("Usage: some usage");
|
expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT);
|
||||||
|
|
||||||
gboolean result = cmd_account(NULL, args, *help);
|
gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_account_show_shows_message_when_account_does_not_exist(void **state)
|
void cmd_account_show_shows_message_when_account_does_not_exist(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "show", "account_name", NULL };
|
gchar *args[] = { "show", "account_name", NULL };
|
||||||
|
|
||||||
expect_any(accounts_get_account, name);
|
expect_any(accounts_get_account, name);
|
||||||
@ -98,15 +85,12 @@ void cmd_account_show_shows_message_when_account_does_not_exist(void **state)
|
|||||||
expect_cons_show("No such account.");
|
expect_cons_show("No such account.");
|
||||||
expect_cons_show("");
|
expect_cons_show("");
|
||||||
|
|
||||||
gboolean result = cmd_account(NULL, args, *help);
|
gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_account_show_shows_account_when_exists(void **state)
|
void cmd_account_show_shows_account_when_exists(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "show", "account_name", NULL };
|
gchar *args[] = { "show", "account_name", NULL };
|
||||||
ProfAccount *account = account_new("jabber_org", "me@jabber.org", NULL, NULL,
|
ProfAccount *account = account_new("jabber_org", "me@jabber.org", NULL, NULL,
|
||||||
TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||||
@ -116,29 +100,22 @@ void cmd_account_show_shows_account_when_exists(void **state)
|
|||||||
|
|
||||||
expect_memory(cons_show_account, account, account, sizeof(account));
|
expect_memory(cons_show_account, account, account, sizeof(account));
|
||||||
|
|
||||||
gboolean result = cmd_account(NULL, args, *help);
|
gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_account_add_shows_usage_when_no_arg(void **state)
|
void cmd_account_add_shows_usage_when_no_arg(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
help->usage = "some usage";
|
|
||||||
gchar *args[] = { "add", NULL };
|
gchar *args[] = { "add", NULL };
|
||||||
|
|
||||||
expect_cons_show("Usage: some usage");
|
expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT);
|
||||||
|
|
||||||
gboolean result = cmd_account(NULL, args, *help);
|
gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_account_add_adds_account(void **state)
|
void cmd_account_add_adds_account(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "add", "new_account", NULL };
|
gchar *args[] = { "add", "new_account", NULL };
|
||||||
|
|
||||||
expect_string(accounts_add, jid, "new_account");
|
expect_string(accounts_add, jid, "new_account");
|
||||||
@ -147,29 +124,22 @@ void cmd_account_add_adds_account(void **state)
|
|||||||
expect_cons_show("Account created.");
|
expect_cons_show("Account created.");
|
||||||
expect_cons_show("");
|
expect_cons_show("");
|
||||||
|
|
||||||
gboolean result = cmd_account(NULL, args, *help);
|
gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_account_enable_shows_usage_when_no_arg(void **state)
|
void cmd_account_enable_shows_usage_when_no_arg(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
help->usage = "some usage";
|
|
||||||
gchar *args[] = { "enable", NULL };
|
gchar *args[] = { "enable", NULL };
|
||||||
|
|
||||||
expect_cons_show("Usage: some usage");
|
expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT);
|
||||||
|
|
||||||
gboolean result = cmd_account(NULL, args, *help);
|
gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_account_enable_enables_account(void **state)
|
void cmd_account_enable_enables_account(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "enable", "account_name", NULL };
|
gchar *args[] = { "enable", "account_name", NULL };
|
||||||
|
|
||||||
expect_string(accounts_enable, name, "account_name");
|
expect_string(accounts_enable, name, "account_name");
|
||||||
@ -178,15 +148,12 @@ void cmd_account_enable_enables_account(void **state)
|
|||||||
expect_cons_show("Account enabled.");
|
expect_cons_show("Account enabled.");
|
||||||
expect_cons_show("");
|
expect_cons_show("");
|
||||||
|
|
||||||
gboolean result = cmd_account(NULL, args, *help);
|
gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_account_enable_shows_message_when_account_doesnt_exist(void **state)
|
void cmd_account_enable_shows_message_when_account_doesnt_exist(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "enable", "account_name", NULL };
|
gchar *args[] = { "enable", "account_name", NULL };
|
||||||
|
|
||||||
expect_any(accounts_enable, name);
|
expect_any(accounts_enable, name);
|
||||||
@ -195,29 +162,22 @@ void cmd_account_enable_shows_message_when_account_doesnt_exist(void **state)
|
|||||||
expect_cons_show("No such account: account_name");
|
expect_cons_show("No such account: account_name");
|
||||||
expect_cons_show("");
|
expect_cons_show("");
|
||||||
|
|
||||||
gboolean result = cmd_account(NULL, args, *help);
|
gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_account_disable_shows_usage_when_no_arg(void **state)
|
void cmd_account_disable_shows_usage_when_no_arg(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
help->usage = "some usage";
|
|
||||||
gchar *args[] = { "disable", NULL };
|
gchar *args[] = { "disable", NULL };
|
||||||
|
|
||||||
expect_cons_show("Usage: some usage");
|
expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT);
|
||||||
|
|
||||||
gboolean result = cmd_account(NULL, args, *help);
|
gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_account_disable_disables_account(void **state)
|
void cmd_account_disable_disables_account(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "disable", "account_name", NULL };
|
gchar *args[] = { "disable", "account_name", NULL };
|
||||||
|
|
||||||
expect_string(accounts_disable, name, "account_name");
|
expect_string(accounts_disable, name, "account_name");
|
||||||
@ -226,15 +186,12 @@ void cmd_account_disable_disables_account(void **state)
|
|||||||
expect_cons_show("Account disabled.");
|
expect_cons_show("Account disabled.");
|
||||||
expect_cons_show("");
|
expect_cons_show("");
|
||||||
|
|
||||||
gboolean result = cmd_account(NULL, args, *help);
|
gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_account_disable_shows_message_when_account_doesnt_exist(void **state)
|
void cmd_account_disable_shows_message_when_account_doesnt_exist(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "disable", "account_name", NULL };
|
gchar *args[] = { "disable", "account_name", NULL };
|
||||||
|
|
||||||
expect_any(accounts_disable, name);
|
expect_any(accounts_disable, name);
|
||||||
@ -243,43 +200,32 @@ void cmd_account_disable_shows_message_when_account_doesnt_exist(void **state)
|
|||||||
expect_cons_show("No such account: account_name");
|
expect_cons_show("No such account: account_name");
|
||||||
expect_cons_show("");
|
expect_cons_show("");
|
||||||
|
|
||||||
gboolean result = cmd_account(NULL, args, *help);
|
gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_account_rename_shows_usage_when_no_args(void **state)
|
void cmd_account_rename_shows_usage_when_no_args(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
help->usage = "some usage";
|
|
||||||
gchar *args[] = { "rename", NULL };
|
gchar *args[] = { "rename", NULL };
|
||||||
|
|
||||||
expect_cons_show("Usage: some usage");
|
expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT);
|
||||||
|
|
||||||
gboolean result = cmd_account(NULL, args, *help);
|
gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_account_rename_shows_usage_when_one_arg(void **state)
|
void cmd_account_rename_shows_usage_when_one_arg(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
help->usage = "some usage";
|
|
||||||
gchar *args[] = { "rename", "original_name", NULL };
|
gchar *args[] = { "rename", "original_name", NULL };
|
||||||
|
|
||||||
expect_cons_show("Usage: some usage");
|
expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT);
|
||||||
|
|
||||||
gboolean result = cmd_account(NULL, args, *help);
|
gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_account_rename_renames_account(void **state)
|
void cmd_account_rename_renames_account(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "rename", "original_name", "new_name", NULL };
|
gchar *args[] = { "rename", "original_name", "new_name", NULL };
|
||||||
|
|
||||||
expect_string(accounts_rename, account_name, "original_name");
|
expect_string(accounts_rename, account_name, "original_name");
|
||||||
@ -289,15 +235,12 @@ void cmd_account_rename_renames_account(void **state)
|
|||||||
expect_cons_show("Account renamed.");
|
expect_cons_show("Account renamed.");
|
||||||
expect_cons_show("");
|
expect_cons_show("");
|
||||||
|
|
||||||
gboolean result = cmd_account(NULL, args, *help);
|
gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_account_rename_shows_message_when_not_renamed(void **state)
|
void cmd_account_rename_shows_message_when_not_renamed(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "rename", "original_name", "new_name", NULL };
|
gchar *args[] = { "rename", "original_name", "new_name", NULL };
|
||||||
|
|
||||||
expect_any(accounts_rename, account_name);
|
expect_any(accounts_rename, account_name);
|
||||||
@ -307,57 +250,42 @@ void cmd_account_rename_shows_message_when_not_renamed(void **state)
|
|||||||
expect_cons_show("Either account original_name doesn't exist, or account new_name already exists.");
|
expect_cons_show("Either account original_name doesn't exist, or account new_name already exists.");
|
||||||
expect_cons_show("");
|
expect_cons_show("");
|
||||||
|
|
||||||
gboolean result = cmd_account(NULL, args, *help);
|
gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_account_set_shows_usage_when_no_args(void **state)
|
void cmd_account_set_shows_usage_when_no_args(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
help->usage = "some usage";
|
|
||||||
gchar *args[] = { "set", NULL };
|
gchar *args[] = { "set", NULL };
|
||||||
|
|
||||||
expect_cons_show("Usage: some usage");
|
expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT);
|
||||||
|
|
||||||
gboolean result = cmd_account(NULL, args, *help);
|
gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_account_set_shows_usage_when_one_arg(void **state)
|
void cmd_account_set_shows_usage_when_one_arg(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
help->usage = "some usage";
|
|
||||||
gchar *args[] = { "set", "a_account", NULL };
|
gchar *args[] = { "set", "a_account", NULL };
|
||||||
|
|
||||||
expect_cons_show("Usage: some usage");
|
expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT);
|
||||||
|
|
||||||
gboolean result = cmd_account(NULL, args, *help);
|
gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_account_set_shows_usage_when_two_args(void **state)
|
void cmd_account_set_shows_usage_when_two_args(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
help->usage = "some usage";
|
|
||||||
gchar *args[] = { "set", "a_account", "a_property", NULL };
|
gchar *args[] = { "set", "a_account", "a_property", NULL };
|
||||||
|
|
||||||
expect_cons_show("Usage: some usage");
|
expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT);
|
||||||
|
|
||||||
gboolean result = cmd_account(NULL, args, *help);
|
gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_account_set_shows_message_when_account_doesnt_exist(void **state)
|
void cmd_account_set_shows_message_when_account_doesnt_exist(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "set", "a_account", "a_property", "a_value", NULL };
|
gchar *args[] = { "set", "a_account", "a_property", "a_value", NULL };
|
||||||
|
|
||||||
expect_string(accounts_account_exists, account_name, "a_account");
|
expect_string(accounts_account_exists, account_name, "a_account");
|
||||||
@ -366,15 +294,12 @@ void cmd_account_set_shows_message_when_account_doesnt_exist(void **state)
|
|||||||
expect_cons_show("Account a_account doesn't exist");
|
expect_cons_show("Account a_account doesn't exist");
|
||||||
expect_cons_show("");
|
expect_cons_show("");
|
||||||
|
|
||||||
gboolean result = cmd_account(NULL, args, *help);
|
gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_account_set_jid_shows_message_for_malformed_jid(void **state)
|
void cmd_account_set_jid_shows_message_for_malformed_jid(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "set", "a_account", "jid", "@malformed", NULL };
|
gchar *args[] = { "set", "a_account", "jid", "@malformed", NULL };
|
||||||
|
|
||||||
expect_any(accounts_account_exists, account_name);
|
expect_any(accounts_account_exists, account_name);
|
||||||
@ -382,15 +307,12 @@ void cmd_account_set_jid_shows_message_for_malformed_jid(void **state)
|
|||||||
|
|
||||||
expect_cons_show("Malformed jid: @malformed");
|
expect_cons_show("Malformed jid: @malformed");
|
||||||
|
|
||||||
gboolean result = cmd_account(NULL, args, *help);
|
gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_account_set_jid_sets_barejid(void **state)
|
void cmd_account_set_jid_sets_barejid(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "set", "a_account", "jid", "a_local@a_domain", NULL };
|
gchar *args[] = { "set", "a_account", "jid", "a_local@a_domain", NULL };
|
||||||
|
|
||||||
expect_any(accounts_account_exists, account_name);
|
expect_any(accounts_account_exists, account_name);
|
||||||
@ -402,15 +324,12 @@ void cmd_account_set_jid_sets_barejid(void **state)
|
|||||||
expect_cons_show("Updated jid for account a_account: a_local@a_domain");
|
expect_cons_show("Updated jid for account a_account: a_local@a_domain");
|
||||||
expect_cons_show("");
|
expect_cons_show("");
|
||||||
|
|
||||||
gboolean result = cmd_account(NULL, args, *help);
|
gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_account_set_jid_sets_resource(void **state)
|
void cmd_account_set_jid_sets_resource(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "set", "a_account", "jid", "a_local@a_domain/a_resource", NULL };
|
gchar *args[] = { "set", "a_account", "jid", "a_local@a_domain/a_resource", NULL };
|
||||||
|
|
||||||
expect_any(accounts_account_exists, account_name);
|
expect_any(accounts_account_exists, account_name);
|
||||||
@ -427,15 +346,12 @@ void cmd_account_set_jid_sets_resource(void **state)
|
|||||||
expect_cons_show("Updated resource for account a_account: a_resource");
|
expect_cons_show("Updated resource for account a_account: a_resource");
|
||||||
expect_cons_show("");
|
expect_cons_show("");
|
||||||
|
|
||||||
gboolean result = cmd_account(NULL, args, *help);
|
gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_account_set_server_sets_server(void **state)
|
void cmd_account_set_server_sets_server(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "set", "a_account", "server", "a_server", NULL };
|
gchar *args[] = { "set", "a_account", "server", "a_server", NULL };
|
||||||
|
|
||||||
expect_any(accounts_account_exists, account_name);
|
expect_any(accounts_account_exists, account_name);
|
||||||
@ -447,15 +363,12 @@ void cmd_account_set_server_sets_server(void **state)
|
|||||||
expect_cons_show("Updated server for account a_account: a_server");
|
expect_cons_show("Updated server for account a_account: a_server");
|
||||||
expect_cons_show("");
|
expect_cons_show("");
|
||||||
|
|
||||||
gboolean result = cmd_account(NULL, args, *help);
|
gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_account_set_resource_sets_resource(void **state)
|
void cmd_account_set_resource_sets_resource(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "set", "a_account", "resource", "a_resource", NULL };
|
gchar *args[] = { "set", "a_account", "resource", "a_resource", NULL };
|
||||||
|
|
||||||
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
|
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
|
||||||
@ -469,15 +382,12 @@ void cmd_account_set_resource_sets_resource(void **state)
|
|||||||
expect_cons_show("Updated resource for account a_account: a_resource");
|
expect_cons_show("Updated resource for account a_account: a_resource");
|
||||||
expect_cons_show("");
|
expect_cons_show("");
|
||||||
|
|
||||||
gboolean result = cmd_account(NULL, args, *help);
|
gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_account_set_resource_sets_resource_with_online_message(void **state)
|
void cmd_account_set_resource_sets_resource_with_online_message(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "set", "a_account", "resource", "a_resource", NULL };
|
gchar *args[] = { "set", "a_account", "resource", "a_resource", NULL };
|
||||||
|
|
||||||
will_return(jabber_get_connection_status, JABBER_CONNECTED);
|
will_return(jabber_get_connection_status, JABBER_CONNECTED);
|
||||||
@ -491,15 +401,12 @@ void cmd_account_set_resource_sets_resource_with_online_message(void **state)
|
|||||||
expect_cons_show("Updated resource for account a_account: a_resource, you will need to reconnect to pick up the change.");
|
expect_cons_show("Updated resource for account a_account: a_resource, you will need to reconnect to pick up the change.");
|
||||||
expect_cons_show("");
|
expect_cons_show("");
|
||||||
|
|
||||||
gboolean result = cmd_account(NULL, args, *help);
|
gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_account_set_password_sets_password(void **state)
|
void cmd_account_set_password_sets_password(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "set", "a_account", "password", "a_password", NULL };
|
gchar *args[] = { "set", "a_account", "password", "a_password", NULL };
|
||||||
ProfAccount *account = account_new("a_account", NULL, NULL, NULL,
|
ProfAccount *account = account_new("a_account", NULL, NULL, NULL,
|
||||||
TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||||
@ -517,20 +424,16 @@ void cmd_account_set_password_sets_password(void **state)
|
|||||||
expect_cons_show("Updated password for account a_account");
|
expect_cons_show("Updated password for account a_account");
|
||||||
expect_cons_show("");
|
expect_cons_show("");
|
||||||
|
|
||||||
gboolean result = cmd_account(NULL, args, *help);
|
gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_account_set_eval_password_sets_eval_password(void **state)
|
void cmd_account_set_eval_password_sets_eval_password(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "set", "a_account", "eval_password", "a_password", NULL };
|
gchar *args[] = { "set", "a_account", "eval_password", "a_password", NULL };
|
||||||
ProfAccount *account = account_new("a_account", NULL, NULL, NULL,
|
ProfAccount *account = account_new("a_account", NULL, NULL, NULL,
|
||||||
TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||||
|
|
||||||
|
|
||||||
expect_any(accounts_account_exists, account_name);
|
expect_any(accounts_account_exists, account_name);
|
||||||
will_return(accounts_account_exists, TRUE);
|
will_return(accounts_account_exists, TRUE);
|
||||||
|
|
||||||
@ -543,19 +446,15 @@ void cmd_account_set_eval_password_sets_eval_password(void **state)
|
|||||||
expect_cons_show("Updated eval_password for account a_account");
|
expect_cons_show("Updated eval_password for account a_account");
|
||||||
expect_cons_show("");
|
expect_cons_show("");
|
||||||
|
|
||||||
gboolean result = cmd_account(NULL, args, *help);
|
gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_account_set_password_when_eval_password_set(void **state) {
|
void cmd_account_set_password_when_eval_password_set(void **state) {
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "set", "a_account", "password", "a_password", NULL };
|
gchar *args[] = { "set", "a_account", "password", "a_password", NULL };
|
||||||
ProfAccount *account = account_new("a_account", NULL, NULL, "a_password",
|
ProfAccount *account = account_new("a_account", NULL, NULL, "a_password",
|
||||||
TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||||
|
|
||||||
|
|
||||||
expect_any(accounts_account_exists, account_name);
|
expect_any(accounts_account_exists, account_name);
|
||||||
will_return(accounts_account_exists, TRUE);
|
will_return(accounts_account_exists, TRUE);
|
||||||
|
|
||||||
@ -564,19 +463,15 @@ void cmd_account_set_password_when_eval_password_set(void **state) {
|
|||||||
|
|
||||||
expect_cons_show("Cannot set password when eval_password is set.");
|
expect_cons_show("Cannot set password when eval_password is set.");
|
||||||
|
|
||||||
gboolean result = cmd_account(NULL, args, *help);
|
gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_account_set_eval_password_when_password_set(void **state) {
|
void cmd_account_set_eval_password_when_password_set(void **state) {
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "set", "a_account", "eval_password", "a_password", NULL };
|
gchar *args[] = { "set", "a_account", "eval_password", "a_password", NULL };
|
||||||
ProfAccount *account = account_new("a_account", NULL, "a_password", NULL,
|
ProfAccount *account = account_new("a_account", NULL, "a_password", NULL,
|
||||||
TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||||
|
|
||||||
|
|
||||||
expect_any(accounts_account_exists, account_name);
|
expect_any(accounts_account_exists, account_name);
|
||||||
will_return(accounts_account_exists, TRUE);
|
will_return(accounts_account_exists, TRUE);
|
||||||
|
|
||||||
@ -585,15 +480,12 @@ void cmd_account_set_eval_password_when_password_set(void **state) {
|
|||||||
|
|
||||||
expect_cons_show("Cannot set eval_password when password is set.");
|
expect_cons_show("Cannot set eval_password when password is set.");
|
||||||
|
|
||||||
gboolean result = cmd_account(NULL, args, *help);
|
gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_account_set_muc_sets_muc(void **state)
|
void cmd_account_set_muc_sets_muc(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "set", "a_account", "muc", "a_muc", NULL };
|
gchar *args[] = { "set", "a_account", "muc", "a_muc", NULL };
|
||||||
|
|
||||||
expect_any(accounts_account_exists, account_name);
|
expect_any(accounts_account_exists, account_name);
|
||||||
@ -605,15 +497,12 @@ void cmd_account_set_muc_sets_muc(void **state)
|
|||||||
expect_cons_show("Updated muc service for account a_account: a_muc");
|
expect_cons_show("Updated muc service for account a_account: a_muc");
|
||||||
expect_cons_show("");
|
expect_cons_show("");
|
||||||
|
|
||||||
gboolean result = cmd_account(NULL, args, *help);
|
gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_account_set_nick_sets_nick(void **state)
|
void cmd_account_set_nick_sets_nick(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "set", "a_account", "nick", "a_nick", NULL };
|
gchar *args[] = { "set", "a_account", "nick", "a_nick", NULL };
|
||||||
|
|
||||||
expect_any(accounts_account_exists, account_name);
|
expect_any(accounts_account_exists, account_name);
|
||||||
@ -625,29 +514,22 @@ void cmd_account_set_nick_sets_nick(void **state)
|
|||||||
expect_cons_show("Updated muc nick for account a_account: a_nick");
|
expect_cons_show("Updated muc nick for account a_account: a_nick");
|
||||||
expect_cons_show("");
|
expect_cons_show("");
|
||||||
|
|
||||||
gboolean result = cmd_account(NULL, args, *help);
|
gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_account_show_message_for_missing_otr_policy(void **state)
|
void cmd_account_show_message_for_missing_otr_policy(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
help->usage = "Some usage";
|
|
||||||
gchar *args[] = { "set", "a_account", "otr", NULL };
|
gchar *args[] = { "set", "a_account", "otr", NULL };
|
||||||
|
|
||||||
expect_cons_show("Usage: Some usage");
|
expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT);
|
||||||
|
|
||||||
gboolean result = cmd_account(NULL, args, *help);
|
gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_account_show_message_for_invalid_otr_policy(void **state)
|
void cmd_account_show_message_for_invalid_otr_policy(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "set", "a_account", "otr", "bad_otr_policy", NULL };
|
gchar *args[] = { "set", "a_account", "otr", "bad_otr_policy", NULL };
|
||||||
|
|
||||||
expect_any(accounts_account_exists, account_name);
|
expect_any(accounts_account_exists, account_name);
|
||||||
@ -655,15 +537,12 @@ void cmd_account_show_message_for_invalid_otr_policy(void **state)
|
|||||||
|
|
||||||
expect_cons_show("OTR policy must be one of: manual, opportunistic or always.");
|
expect_cons_show("OTR policy must be one of: manual, opportunistic or always.");
|
||||||
|
|
||||||
gboolean result = cmd_account(NULL, args, *help);
|
gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_account_set_otr_sets_otr(void **state)
|
void cmd_account_set_otr_sets_otr(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "set", "a_account", "otr", "opportunistic", NULL };
|
gchar *args[] = { "set", "a_account", "otr", "opportunistic", NULL };
|
||||||
|
|
||||||
expect_any(accounts_account_exists, account_name);
|
expect_any(accounts_account_exists, account_name);
|
||||||
@ -675,15 +554,12 @@ void cmd_account_set_otr_sets_otr(void **state)
|
|||||||
expect_cons_show("Updated OTR policy for account a_account: opportunistic");
|
expect_cons_show("Updated OTR policy for account a_account: opportunistic");
|
||||||
expect_cons_show("");
|
expect_cons_show("");
|
||||||
|
|
||||||
gboolean result = cmd_account(NULL, args, *help);
|
gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_account_set_status_shows_message_when_invalid_status(void **state)
|
void cmd_account_set_status_shows_message_when_invalid_status(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "set", "a_account", "status", "bad_status", NULL };
|
gchar *args[] = { "set", "a_account", "status", "bad_status", NULL };
|
||||||
|
|
||||||
expect_any(accounts_account_exists, account_name);
|
expect_any(accounts_account_exists, account_name);
|
||||||
@ -692,15 +568,12 @@ void cmd_account_set_status_shows_message_when_invalid_status(void **state)
|
|||||||
expect_cons_show("Invalid status: bad_status");
|
expect_cons_show("Invalid status: bad_status");
|
||||||
expect_cons_show("");
|
expect_cons_show("");
|
||||||
|
|
||||||
gboolean result = cmd_account(NULL, args, *help);
|
gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_account_set_status_sets_status_when_valid(void **state)
|
void cmd_account_set_status_sets_status_when_valid(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "set", "a_account", "status", "away", NULL };
|
gchar *args[] = { "set", "a_account", "status", "away", NULL };
|
||||||
|
|
||||||
expect_any(accounts_account_exists, account_name);
|
expect_any(accounts_account_exists, account_name);
|
||||||
@ -712,15 +585,12 @@ void cmd_account_set_status_sets_status_when_valid(void **state)
|
|||||||
expect_cons_show("Updated login status for account a_account: away");
|
expect_cons_show("Updated login status for account a_account: away");
|
||||||
expect_cons_show("");
|
expect_cons_show("");
|
||||||
|
|
||||||
gboolean result = cmd_account(NULL, args, *help);
|
gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_account_set_status_sets_status_when_last(void **state)
|
void cmd_account_set_status_sets_status_when_last(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "set", "a_account", "status", "last", NULL };
|
gchar *args[] = { "set", "a_account", "status", "last", NULL };
|
||||||
|
|
||||||
expect_any(accounts_account_exists, account_name);
|
expect_any(accounts_account_exists, account_name);
|
||||||
@ -732,15 +602,12 @@ void cmd_account_set_status_sets_status_when_last(void **state)
|
|||||||
expect_cons_show("Updated login status for account a_account: last");
|
expect_cons_show("Updated login status for account a_account: last");
|
||||||
expect_cons_show("");
|
expect_cons_show("");
|
||||||
|
|
||||||
gboolean result = cmd_account(NULL, args, *help);
|
gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_account_set_invalid_presence_string_priority_shows_message(void **state)
|
void cmd_account_set_invalid_presence_string_priority_shows_message(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "set", "a_account", "blah", "10", NULL };
|
gchar *args[] = { "set", "a_account", "blah", "10", NULL };
|
||||||
|
|
||||||
expect_any(accounts_account_exists, account_name);
|
expect_any(accounts_account_exists, account_name);
|
||||||
@ -749,15 +616,12 @@ void cmd_account_set_invalid_presence_string_priority_shows_message(void **state
|
|||||||
expect_cons_show("Invalid property: blah");
|
expect_cons_show("Invalid property: blah");
|
||||||
expect_cons_show("");
|
expect_cons_show("");
|
||||||
|
|
||||||
gboolean result = cmd_account(NULL, args, *help);
|
gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_account_set_last_priority_shows_message(void **state)
|
void cmd_account_set_last_priority_shows_message(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "set", "a_account", "last", "10", NULL };
|
gchar *args[] = { "set", "a_account", "last", "10", NULL };
|
||||||
|
|
||||||
expect_any(accounts_account_exists, account_name);
|
expect_any(accounts_account_exists, account_name);
|
||||||
@ -766,15 +630,12 @@ void cmd_account_set_last_priority_shows_message(void **state)
|
|||||||
expect_cons_show("Invalid property: last");
|
expect_cons_show("Invalid property: last");
|
||||||
expect_cons_show("");
|
expect_cons_show("");
|
||||||
|
|
||||||
gboolean result = cmd_account(NULL, args, *help);
|
gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_account_set_online_priority_sets_preference(void **state)
|
void cmd_account_set_online_priority_sets_preference(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "set", "a_account", "online", "10", NULL };
|
gchar *args[] = { "set", "a_account", "online", "10", NULL };
|
||||||
|
|
||||||
expect_any(accounts_account_exists, account_name);
|
expect_any(accounts_account_exists, account_name);
|
||||||
@ -788,15 +649,12 @@ void cmd_account_set_online_priority_sets_preference(void **state)
|
|||||||
expect_cons_show("Updated online priority for account a_account: 10");
|
expect_cons_show("Updated online priority for account a_account: 10");
|
||||||
expect_cons_show("");
|
expect_cons_show("");
|
||||||
|
|
||||||
gboolean result = cmd_account(NULL, args, *help);
|
gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_account_set_chat_priority_sets_preference(void **state)
|
void cmd_account_set_chat_priority_sets_preference(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "set", "a_account", "chat", "10", NULL };
|
gchar *args[] = { "set", "a_account", "chat", "10", NULL };
|
||||||
|
|
||||||
expect_any(accounts_account_exists, account_name);
|
expect_any(accounts_account_exists, account_name);
|
||||||
@ -810,15 +668,12 @@ void cmd_account_set_chat_priority_sets_preference(void **state)
|
|||||||
expect_cons_show("Updated chat priority for account a_account: 10");
|
expect_cons_show("Updated chat priority for account a_account: 10");
|
||||||
expect_cons_show("");
|
expect_cons_show("");
|
||||||
|
|
||||||
gboolean result = cmd_account(NULL, args, *help);
|
gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_account_set_away_priority_sets_preference(void **state)
|
void cmd_account_set_away_priority_sets_preference(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "set", "a_account", "away", "10", NULL };
|
gchar *args[] = { "set", "a_account", "away", "10", NULL };
|
||||||
|
|
||||||
expect_any(accounts_account_exists, account_name);
|
expect_any(accounts_account_exists, account_name);
|
||||||
@ -832,15 +687,12 @@ void cmd_account_set_away_priority_sets_preference(void **state)
|
|||||||
expect_cons_show("Updated away priority for account a_account: 10");
|
expect_cons_show("Updated away priority for account a_account: 10");
|
||||||
expect_cons_show("");
|
expect_cons_show("");
|
||||||
|
|
||||||
gboolean result = cmd_account(NULL, args, *help);
|
gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_account_set_xa_priority_sets_preference(void **state)
|
void cmd_account_set_xa_priority_sets_preference(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "set", "a_account", "xa", "10", NULL };
|
gchar *args[] = { "set", "a_account", "xa", "10", NULL };
|
||||||
|
|
||||||
expect_any(accounts_account_exists, account_name);
|
expect_any(accounts_account_exists, account_name);
|
||||||
@ -854,15 +706,12 @@ void cmd_account_set_xa_priority_sets_preference(void **state)
|
|||||||
expect_cons_show("Updated xa priority for account a_account: 10");
|
expect_cons_show("Updated xa priority for account a_account: 10");
|
||||||
expect_cons_show("");
|
expect_cons_show("");
|
||||||
|
|
||||||
gboolean result = cmd_account(NULL, args, *help);
|
gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_account_set_dnd_priority_sets_preference(void **state)
|
void cmd_account_set_dnd_priority_sets_preference(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "set", "a_account", "dnd", "10", NULL };
|
gchar *args[] = { "set", "a_account", "dnd", "10", NULL };
|
||||||
|
|
||||||
expect_any(accounts_account_exists, account_name);
|
expect_any(accounts_account_exists, account_name);
|
||||||
@ -876,15 +725,12 @@ void cmd_account_set_dnd_priority_sets_preference(void **state)
|
|||||||
expect_cons_show("Updated dnd priority for account a_account: 10");
|
expect_cons_show("Updated dnd priority for account a_account: 10");
|
||||||
expect_cons_show("");
|
expect_cons_show("");
|
||||||
|
|
||||||
gboolean result = cmd_account(NULL, args, *help);
|
gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_account_set_priority_too_low_shows_message(void **state)
|
void cmd_account_set_priority_too_low_shows_message(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "set", "a_account", "online", "-150", NULL };
|
gchar *args[] = { "set", "a_account", "online", "-150", NULL };
|
||||||
|
|
||||||
expect_any(accounts_account_exists, account_name);
|
expect_any(accounts_account_exists, account_name);
|
||||||
@ -892,15 +738,12 @@ void cmd_account_set_priority_too_low_shows_message(void **state)
|
|||||||
|
|
||||||
expect_cons_show("Value -150 out of range. Must be in -128..127.");
|
expect_cons_show("Value -150 out of range. Must be in -128..127.");
|
||||||
|
|
||||||
gboolean result = cmd_account(NULL, args, *help);
|
gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_account_set_priority_too_high_shows_message(void **state)
|
void cmd_account_set_priority_too_high_shows_message(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "set", "a_account", "online", "150", NULL };
|
gchar *args[] = { "set", "a_account", "online", "150", NULL };
|
||||||
|
|
||||||
expect_any(accounts_account_exists, account_name);
|
expect_any(accounts_account_exists, account_name);
|
||||||
@ -908,15 +751,12 @@ void cmd_account_set_priority_too_high_shows_message(void **state)
|
|||||||
|
|
||||||
expect_cons_show("Value 150 out of range. Must be in -128..127.");
|
expect_cons_show("Value 150 out of range. Must be in -128..127.");
|
||||||
|
|
||||||
gboolean result = cmd_account(NULL, args, *help);
|
gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_account_set_priority_when_not_number_shows_message(void **state)
|
void cmd_account_set_priority_when_not_number_shows_message(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "set", "a_account", "online", "abc", NULL };
|
gchar *args[] = { "set", "a_account", "online", "abc", NULL };
|
||||||
|
|
||||||
expect_any(accounts_account_exists, account_name);
|
expect_any(accounts_account_exists, account_name);
|
||||||
@ -924,15 +764,12 @@ void cmd_account_set_priority_when_not_number_shows_message(void **state)
|
|||||||
|
|
||||||
expect_cons_show("Could not convert \"abc\" to a number.");
|
expect_cons_show("Could not convert \"abc\" to a number.");
|
||||||
|
|
||||||
gboolean result = cmd_account(NULL, args, *help);
|
gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_account_set_priority_when_empty_shows_message(void **state)
|
void cmd_account_set_priority_when_empty_shows_message(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "set", "a_account", "online", "", NULL };
|
gchar *args[] = { "set", "a_account", "online", "", NULL };
|
||||||
|
|
||||||
expect_any(accounts_account_exists, account_name);
|
expect_any(accounts_account_exists, account_name);
|
||||||
@ -940,18 +777,14 @@ void cmd_account_set_priority_when_empty_shows_message(void **state)
|
|||||||
|
|
||||||
expect_cons_show("Could not convert \"\" to a number.");
|
expect_cons_show("Could not convert \"\" to a number.");
|
||||||
|
|
||||||
gboolean result = cmd_account(NULL, args, *help);
|
gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_account_set_priority_updates_presence_when_account_connected_with_presence(void **state)
|
void cmd_account_set_priority_updates_presence_when_account_connected_with_presence(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "set", "a_account", "online", "10", NULL };
|
gchar *args[] = { "set", "a_account", "online", "10", NULL };
|
||||||
|
|
||||||
|
|
||||||
expect_any(accounts_account_exists, account_name);
|
expect_any(accounts_account_exists, account_name);
|
||||||
will_return(accounts_account_exists, TRUE);
|
will_return(accounts_account_exists, TRUE);
|
||||||
|
|
||||||
@ -984,43 +817,32 @@ void cmd_account_set_priority_updates_presence_when_account_connected_with_prese
|
|||||||
expect_cons_show("Updated online priority for account a_account: 10");
|
expect_cons_show("Updated online priority for account a_account: 10");
|
||||||
expect_cons_show("");
|
expect_cons_show("");
|
||||||
|
|
||||||
gboolean result = cmd_account(NULL, args, *help);
|
gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_account_clear_shows_usage_when_no_args(void **state)
|
void cmd_account_clear_shows_usage_when_no_args(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
help->usage = "some usage";
|
|
||||||
gchar *args[] = { "clear", NULL };
|
gchar *args[] = { "clear", NULL };
|
||||||
|
|
||||||
expect_cons_show("Usage: some usage");
|
expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT);
|
||||||
|
|
||||||
gboolean result = cmd_account(NULL, args, *help);
|
gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_account_clear_shows_usage_when_one_arg(void **state)
|
void cmd_account_clear_shows_usage_when_one_arg(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
help->usage = "some usage";
|
|
||||||
gchar *args[] = { "clear", "a_account", NULL };
|
gchar *args[] = { "clear", "a_account", NULL };
|
||||||
|
|
||||||
expect_cons_show("Usage: some usage");
|
expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT);
|
||||||
|
|
||||||
gboolean result = cmd_account(NULL, args, *help);
|
gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_account_clear_shows_message_when_account_doesnt_exist(void **state)
|
void cmd_account_clear_shows_message_when_account_doesnt_exist(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "clear", "a_account", "a_property", NULL };
|
gchar *args[] = { "clear", "a_account", "a_property", NULL };
|
||||||
|
|
||||||
expect_string(accounts_account_exists, account_name, "a_account");
|
expect_string(accounts_account_exists, account_name, "a_account");
|
||||||
@ -1029,15 +851,12 @@ void cmd_account_clear_shows_message_when_account_doesnt_exist(void **state)
|
|||||||
expect_cons_show("Account a_account doesn't exist");
|
expect_cons_show("Account a_account doesn't exist");
|
||||||
expect_cons_show("");
|
expect_cons_show("");
|
||||||
|
|
||||||
gboolean result = cmd_account(NULL, args, *help);
|
gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_account_clear_shows_message_when_invalid_property(void **state)
|
void cmd_account_clear_shows_message_when_invalid_property(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "clear", "a_account", "badproperty", NULL };
|
gchar *args[] = { "clear", "a_account", "badproperty", NULL };
|
||||||
|
|
||||||
expect_any(accounts_account_exists, account_name);
|
expect_any(accounts_account_exists, account_name);
|
||||||
@ -1046,8 +865,6 @@ void cmd_account_clear_shows_message_when_invalid_property(void **state)
|
|||||||
expect_cons_show("Invalid property: badproperty");
|
expect_cons_show("Invalid property: badproperty");
|
||||||
expect_cons_show("");
|
expect_cons_show("");
|
||||||
|
|
||||||
gboolean result = cmd_account(NULL, args, *help);
|
gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
@ -16,82 +16,63 @@
|
|||||||
#include "command/command.h"
|
#include "command/command.h"
|
||||||
#include "command/commands.h"
|
#include "command/commands.h"
|
||||||
|
|
||||||
|
#define CMD_ALIAS "/alias"
|
||||||
|
|
||||||
void cmd_alias_add_shows_usage_when_no_args(void **state)
|
void cmd_alias_add_shows_usage_when_no_args(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
help->usage = "some usage";
|
|
||||||
gchar *args[] = { "add", NULL };
|
gchar *args[] = { "add", NULL };
|
||||||
|
|
||||||
expect_cons_show("Usage: some usage");
|
expect_string(cons_bad_cmd_usage, cmd, CMD_ALIAS);
|
||||||
|
|
||||||
gboolean result = cmd_alias(NULL, args, *help);
|
gboolean result = cmd_alias(NULL, CMD_ALIAS, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_alias_add_shows_usage_when_no_value(void **state)
|
void cmd_alias_add_shows_usage_when_no_value(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
help->usage = "some usage";
|
|
||||||
gchar *args[] = { "add", "alias", NULL };
|
gchar *args[] = { "add", "alias", NULL };
|
||||||
|
|
||||||
expect_cons_show("Usage: some usage");
|
expect_string(cons_bad_cmd_usage, cmd, CMD_ALIAS);
|
||||||
|
|
||||||
gboolean result = cmd_alias(NULL, args, *help);
|
gboolean result = cmd_alias(NULL, CMD_ALIAS, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_alias_remove_shows_usage_when_no_args(void **state)
|
void cmd_alias_remove_shows_usage_when_no_args(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
help->usage = "some usage";
|
|
||||||
gchar *args[] = { "remove", NULL };
|
gchar *args[] = { "remove", NULL };
|
||||||
|
|
||||||
expect_cons_show("Usage: some usage");
|
expect_string(cons_bad_cmd_usage, cmd, CMD_ALIAS);
|
||||||
|
|
||||||
gboolean result = cmd_alias(NULL, args, *help);
|
gboolean result = cmd_alias(NULL, CMD_ALIAS, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_alias_show_usage_when_invalid_subcmd(void **state)
|
void cmd_alias_show_usage_when_invalid_subcmd(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
help->usage = "some usage";
|
|
||||||
gchar *args[] = { "blah", NULL };
|
gchar *args[] = { "blah", NULL };
|
||||||
|
|
||||||
expect_cons_show("Usage: some usage");
|
expect_string(cons_bad_cmd_usage, cmd, CMD_ALIAS);
|
||||||
|
|
||||||
gboolean result = cmd_alias(NULL, args, *help);
|
gboolean result = cmd_alias(NULL, CMD_ALIAS, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_alias_add_adds_alias(void **state)
|
void cmd_alias_add_adds_alias(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "add", "hc", "/help commands", NULL };
|
gchar *args[] = { "add", "hc", "/help commands", NULL };
|
||||||
|
|
||||||
expect_cons_show("Command alias added /hc -> /help commands");
|
expect_cons_show("Command alias added /hc -> /help commands");
|
||||||
|
|
||||||
gboolean result = cmd_alias(NULL, args, *help);
|
gboolean result = cmd_alias(NULL, CMD_ALIAS, args);
|
||||||
|
assert_true(result);
|
||||||
|
|
||||||
char *returned_val = prefs_get_alias("hc");
|
char *returned_val = prefs_get_alias("hc");
|
||||||
|
|
||||||
assert_true(result);
|
|
||||||
assert_string_equal("/help commands", returned_val);
|
assert_string_equal("/help commands", returned_val);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_alias_add_shows_message_when_exists(void **state)
|
void cmd_alias_add_shows_message_when_exists(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "add", "hc", "/help commands", NULL };
|
gchar *args[] = { "add", "hc", "/help commands", NULL };
|
||||||
|
|
||||||
cmd_init();
|
cmd_init();
|
||||||
@ -100,47 +81,37 @@ void cmd_alias_add_shows_message_when_exists(void **state)
|
|||||||
|
|
||||||
expect_cons_show("Command or alias '/hc' already exists.");
|
expect_cons_show("Command or alias '/hc' already exists.");
|
||||||
|
|
||||||
gboolean result = cmd_alias(NULL, args, *help);
|
gboolean result = cmd_alias(NULL, CMD_ALIAS, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_alias_remove_removes_alias(void **state)
|
void cmd_alias_remove_removes_alias(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "remove", "hn", NULL };
|
gchar *args[] = { "remove", "hn", NULL };
|
||||||
|
|
||||||
prefs_add_alias("hn", "/help navigation");
|
prefs_add_alias("hn", "/help navigation");
|
||||||
|
|
||||||
expect_cons_show("Command alias removed -> /hn");
|
expect_cons_show("Command alias removed -> /hn");
|
||||||
|
|
||||||
gboolean result = cmd_alias(NULL, args, *help);
|
gboolean result = cmd_alias(NULL, CMD_ALIAS, args);
|
||||||
|
assert_true(result);
|
||||||
|
|
||||||
char *returned_val = prefs_get_alias("hn");
|
char *returned_val = prefs_get_alias("hn");
|
||||||
|
|
||||||
assert_true(result);
|
|
||||||
assert_null(returned_val);
|
assert_null(returned_val);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_alias_remove_shows_message_when_no_alias(void **state)
|
void cmd_alias_remove_shows_message_when_no_alias(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "remove", "hn", NULL };
|
gchar *args[] = { "remove", "hn", NULL };
|
||||||
|
|
||||||
expect_cons_show("No such command alias /hn");
|
expect_cons_show("No such command alias /hn");
|
||||||
|
|
||||||
gboolean result = cmd_alias(NULL, args, *help);
|
gboolean result = cmd_alias(NULL, CMD_ALIAS, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_alias_list_shows_all_aliases(void **state)
|
void cmd_alias_list_shows_all_aliases(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "list", NULL };
|
gchar *args[] = { "list", NULL };
|
||||||
|
|
||||||
prefs_add_alias("vy", "/vercheck on");
|
prefs_add_alias("vy", "/vercheck on");
|
||||||
@ -152,8 +123,6 @@ void cmd_alias_list_shows_all_aliases(void **state)
|
|||||||
// write a custom checker to check the correct list is passed
|
// write a custom checker to check the correct list is passed
|
||||||
expect_any(cons_show_aliases, aliases);
|
expect_any(cons_show_aliases, aliases);
|
||||||
|
|
||||||
gboolean result = cmd_alias(NULL, args, *help);
|
gboolean result = cmd_alias(NULL, CMD_ALIAS, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
@ -20,17 +20,15 @@
|
|||||||
|
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
|
|
||||||
|
#define CMD_BOOKMARK "/bookmark"
|
||||||
|
|
||||||
static void test_with_connection_status(jabber_conn_status_t status)
|
static void test_with_connection_status(jabber_conn_status_t status)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
|
|
||||||
will_return(jabber_get_connection_status, status);
|
will_return(jabber_get_connection_status, status);
|
||||||
expect_cons_show("You are not currently connected.");
|
expect_cons_show("You are not currently connected.");
|
||||||
|
|
||||||
gboolean result = cmd_bookmark(NULL, NULL, *help);
|
gboolean result = cmd_bookmark(NULL, CMD_BOOKMARK, NULL);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_bookmark_shows_message_when_disconnected(void **state)
|
void cmd_bookmark_shows_message_when_disconnected(void **state)
|
||||||
@ -60,20 +58,16 @@ void cmd_bookmark_shows_message_when_undefined(void **state)
|
|||||||
|
|
||||||
void cmd_bookmark_shows_usage_when_no_args(void **state)
|
void cmd_bookmark_shows_usage_when_no_args(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
help->usage = "some usage";
|
|
||||||
gchar *args[] = { NULL };
|
gchar *args[] = { NULL };
|
||||||
ProfWin window;
|
ProfWin window;
|
||||||
window.type = WIN_CONSOLE;
|
window.type = WIN_CONSOLE;
|
||||||
|
|
||||||
will_return(jabber_get_connection_status, JABBER_CONNECTED);
|
will_return(jabber_get_connection_status, JABBER_CONNECTED);
|
||||||
|
|
||||||
expect_cons_show("Usage: some usage");
|
expect_string(cons_bad_cmd_usage, cmd, CMD_BOOKMARK);
|
||||||
|
|
||||||
gboolean result = cmd_bookmark(&window, args, *help);
|
gboolean result = cmd_bookmark(&window, CMD_BOOKMARK, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _free_bookmark(Bookmark *bookmark)
|
static void _free_bookmark(Bookmark *bookmark)
|
||||||
@ -101,7 +95,6 @@ _cmp_bookmark(Bookmark *bm1, Bookmark *bm2)
|
|||||||
|
|
||||||
void cmd_bookmark_list_shows_bookmarks(void **state)
|
void cmd_bookmark_list_shows_bookmarks(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "list", NULL };
|
gchar *args[] = { "list", NULL };
|
||||||
GList *bookmarks = NULL;
|
GList *bookmarks = NULL;
|
||||||
ProfWin window;
|
ProfWin window;
|
||||||
@ -141,17 +134,15 @@ void cmd_bookmark_list_shows_bookmarks(void **state)
|
|||||||
glist_set_cmp((GCompareFunc)_cmp_bookmark);
|
glist_set_cmp((GCompareFunc)_cmp_bookmark);
|
||||||
expect_any(cons_show_bookmarks, list);
|
expect_any(cons_show_bookmarks, list);
|
||||||
|
|
||||||
gboolean result = cmd_bookmark(&window, args, *help);
|
gboolean result = cmd_bookmark(&window, CMD_BOOKMARK, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
g_list_free_full(bookmarks, (GDestroyNotify)_free_bookmark);
|
g_list_free_full(bookmarks, (GDestroyNotify)_free_bookmark);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_bookmark_add_shows_message_when_invalid_jid(void **state)
|
void cmd_bookmark_add_shows_message_when_invalid_jid(void **state)
|
||||||
{
|
{
|
||||||
char *jid = "room";
|
char *jid = "room";
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "add", jid, NULL };
|
gchar *args[] = { "add", jid, NULL };
|
||||||
ProfWin window;
|
ProfWin window;
|
||||||
window.type = WIN_CONSOLE;
|
window.type = WIN_CONSOLE;
|
||||||
@ -160,16 +151,13 @@ void cmd_bookmark_add_shows_message_when_invalid_jid(void **state)
|
|||||||
|
|
||||||
expect_cons_show("Can't add bookmark with JID 'room'; should be 'room@domain.tld'");
|
expect_cons_show("Can't add bookmark with JID 'room'; should be 'room@domain.tld'");
|
||||||
|
|
||||||
gboolean result = cmd_bookmark(&window, args, *help);
|
gboolean result = cmd_bookmark(&window, CMD_BOOKMARK, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_bookmark_add_adds_bookmark_with_jid(void **state)
|
void cmd_bookmark_add_adds_bookmark_with_jid(void **state)
|
||||||
{
|
{
|
||||||
char *jid = "room@conf.server";
|
char *jid = "room@conf.server";
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "add", jid, NULL };
|
gchar *args[] = { "add", jid, NULL };
|
||||||
ProfWin window;
|
ProfWin window;
|
||||||
window.type = WIN_CONSOLE;
|
window.type = WIN_CONSOLE;
|
||||||
@ -184,16 +172,14 @@ void cmd_bookmark_add_adds_bookmark_with_jid(void **state)
|
|||||||
|
|
||||||
expect_cons_show("Bookmark added for room@conf.server.");
|
expect_cons_show("Bookmark added for room@conf.server.");
|
||||||
|
|
||||||
gboolean result = cmd_bookmark(&window, args, *help);
|
gboolean result = cmd_bookmark(&window, CMD_BOOKMARK, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_bookmark_add_adds_bookmark_with_jid_nick(void **state)
|
void cmd_bookmark_add_adds_bookmark_with_jid_nick(void **state)
|
||||||
{ char *jid = "room@conf.server";
|
{
|
||||||
|
char *jid = "room@conf.server";
|
||||||
char *nick = "bob";
|
char *nick = "bob";
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "add", jid, "nick", nick, NULL };
|
gchar *args[] = { "add", jid, "nick", nick, NULL };
|
||||||
ProfWin window;
|
ProfWin window;
|
||||||
window.type = WIN_CONSOLE;
|
window.type = WIN_CONSOLE;
|
||||||
@ -208,16 +194,13 @@ void cmd_bookmark_add_adds_bookmark_with_jid_nick(void **state)
|
|||||||
|
|
||||||
expect_cons_show("Bookmark added for room@conf.server.");
|
expect_cons_show("Bookmark added for room@conf.server.");
|
||||||
|
|
||||||
gboolean result = cmd_bookmark(&window, args, *help);
|
gboolean result = cmd_bookmark(&window, CMD_BOOKMARK, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_bookmark_add_adds_bookmark_with_jid_autojoin(void **state)
|
void cmd_bookmark_add_adds_bookmark_with_jid_autojoin(void **state)
|
||||||
{
|
{
|
||||||
char *jid = "room@conf.server";
|
char *jid = "room@conf.server";
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "add", jid, "autojoin", "on", NULL };
|
gchar *args[] = { "add", jid, "autojoin", "on", NULL };
|
||||||
ProfWin window;
|
ProfWin window;
|
||||||
window.type = WIN_CONSOLE;
|
window.type = WIN_CONSOLE;
|
||||||
@ -232,17 +215,14 @@ void cmd_bookmark_add_adds_bookmark_with_jid_autojoin(void **state)
|
|||||||
|
|
||||||
expect_cons_show("Bookmark added for room@conf.server.");
|
expect_cons_show("Bookmark added for room@conf.server.");
|
||||||
|
|
||||||
gboolean result = cmd_bookmark(&window, args, *help);
|
gboolean result = cmd_bookmark(&window, CMD_BOOKMARK, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_bookmark_add_adds_bookmark_with_jid_nick_autojoin(void **state)
|
void cmd_bookmark_add_adds_bookmark_with_jid_nick_autojoin(void **state)
|
||||||
{
|
{
|
||||||
char *jid = "room@conf.server";
|
char *jid = "room@conf.server";
|
||||||
char *nick = "bob";
|
char *nick = "bob";
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "add", jid, "nick", nick, "autojoin", "on", NULL };
|
gchar *args[] = { "add", jid, "nick", nick, "autojoin", "on", NULL };
|
||||||
ProfWin window;
|
ProfWin window;
|
||||||
window.type = WIN_CONSOLE;
|
window.type = WIN_CONSOLE;
|
||||||
@ -257,16 +237,13 @@ void cmd_bookmark_add_adds_bookmark_with_jid_nick_autojoin(void **state)
|
|||||||
|
|
||||||
expect_cons_show("Bookmark added for room@conf.server.");
|
expect_cons_show("Bookmark added for room@conf.server.");
|
||||||
|
|
||||||
gboolean result = cmd_bookmark(&window, args, *help);
|
gboolean result = cmd_bookmark(&window, CMD_BOOKMARK, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_bookmark_remove_removes_bookmark(void **state)
|
void cmd_bookmark_remove_removes_bookmark(void **state)
|
||||||
{
|
{
|
||||||
char *jid = "room@conf.server";
|
char *jid = "room@conf.server";
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "remove", jid, NULL };
|
gchar *args[] = { "remove", jid, NULL };
|
||||||
ProfWin window;
|
ProfWin window;
|
||||||
window.type = WIN_CONSOLE;
|
window.type = WIN_CONSOLE;
|
||||||
@ -278,16 +255,13 @@ void cmd_bookmark_remove_removes_bookmark(void **state)
|
|||||||
|
|
||||||
expect_cons_show("Bookmark removed for room@conf.server.");
|
expect_cons_show("Bookmark removed for room@conf.server.");
|
||||||
|
|
||||||
gboolean result = cmd_bookmark(&window, args, *help);
|
gboolean result = cmd_bookmark(&window, CMD_BOOKMARK, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_bookmark_remove_shows_message_when_no_bookmark(void **state)
|
void cmd_bookmark_remove_shows_message_when_no_bookmark(void **state)
|
||||||
{
|
{
|
||||||
char *jid = "room@conf.server";
|
char *jid = "room@conf.server";
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "remove", jid, NULL };
|
gchar *args[] = { "remove", jid, NULL };
|
||||||
ProfWin window;
|
ProfWin window;
|
||||||
window.type = WIN_CONSOLE;
|
window.type = WIN_CONSOLE;
|
||||||
@ -299,8 +273,6 @@ void cmd_bookmark_remove_shows_message_when_no_bookmark(void **state)
|
|||||||
|
|
||||||
expect_cons_show("No bookmark exists for room@conf.server.");
|
expect_cons_show("No bookmark exists for room@conf.server.");
|
||||||
|
|
||||||
gboolean result = cmd_bookmark(&window, args, *help);
|
gboolean result = cmd_bookmark(&window, CMD_BOOKMARK, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
@ -14,18 +14,16 @@
|
|||||||
#include "command/commands.h"
|
#include "command/commands.h"
|
||||||
#include "config/accounts.h"
|
#include "config/accounts.h"
|
||||||
|
|
||||||
|
#define CMD_CONNECT "/connect"
|
||||||
|
|
||||||
static void test_with_connection_status(jabber_conn_status_t status)
|
static void test_with_connection_status(jabber_conn_status_t status)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
|
|
||||||
will_return(jabber_get_connection_status, status);
|
will_return(jabber_get_connection_status, status);
|
||||||
|
|
||||||
expect_cons_show("You are either connected already, or a login is in process.");
|
expect_cons_show("You are either connected already, or a login is in process.");
|
||||||
|
|
||||||
gboolean result = cmd_connect(NULL, NULL, *help);
|
gboolean result = cmd_connect(NULL, CMD_CONNECT, NULL);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_connect_shows_message_when_disconnecting(void **state)
|
void cmd_connect_shows_message_when_disconnecting(void **state)
|
||||||
@ -48,209 +46,8 @@ void cmd_connect_shows_message_when_undefined(void **state)
|
|||||||
test_with_connection_status(JABBER_UNDEFINED);
|
test_with_connection_status(JABBER_UNDEFINED);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_connect_shows_usage_when_no_server_value(void **state)
|
|
||||||
{
|
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
help->usage = "some usage";
|
|
||||||
gchar *args[] = { "user@server.org", "server", NULL };
|
|
||||||
|
|
||||||
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
|
|
||||||
|
|
||||||
expect_cons_show("Usage: some usage");
|
|
||||||
expect_cons_show("");
|
|
||||||
|
|
||||||
gboolean result = cmd_connect(NULL, args, *help);
|
|
||||||
assert_true(result);
|
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmd_connect_shows_usage_when_server_no_port_value(void **state)
|
|
||||||
{
|
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
help->usage = "some usage";
|
|
||||||
gchar *args[] = { "user@server.org", "server", "aserver", "port", NULL };
|
|
||||||
|
|
||||||
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
|
|
||||||
|
|
||||||
expect_cons_show("Usage: some usage");
|
|
||||||
expect_cons_show("");
|
|
||||||
|
|
||||||
gboolean result = cmd_connect(NULL, args, *help);
|
|
||||||
assert_true(result);
|
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmd_connect_shows_usage_when_no_port_value(void **state)
|
|
||||||
{
|
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
help->usage = "some usage";
|
|
||||||
gchar *args[] = { "user@server.org", "port", NULL };
|
|
||||||
|
|
||||||
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
|
|
||||||
|
|
||||||
expect_cons_show("Usage: some usage");
|
|
||||||
expect_cons_show("");
|
|
||||||
|
|
||||||
gboolean result = cmd_connect(NULL, args, *help);
|
|
||||||
assert_true(result);
|
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmd_connect_shows_usage_when_port_no_server_value(void **state)
|
|
||||||
{
|
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
help->usage = "some usage";
|
|
||||||
gchar *args[] = { "user@server.org", "port", "5678", "server", NULL };
|
|
||||||
|
|
||||||
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
|
|
||||||
|
|
||||||
expect_cons_show("Usage: some usage");
|
|
||||||
expect_cons_show("");
|
|
||||||
|
|
||||||
gboolean result = cmd_connect(NULL, args, *help);
|
|
||||||
assert_true(result);
|
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmd_connect_shows_message_when_port_0(void **state)
|
|
||||||
{
|
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "user@server.org", "port", "0", NULL };
|
|
||||||
|
|
||||||
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
|
|
||||||
|
|
||||||
expect_cons_show("Value 0 out of range. Must be in 1..65535.");
|
|
||||||
expect_cons_show("");
|
|
||||||
|
|
||||||
gboolean result = cmd_connect(NULL, args, *help);
|
|
||||||
assert_true(result);
|
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmd_connect_shows_message_when_port_minus1(void **state)
|
|
||||||
{
|
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "user@server.org", "port", "-1", NULL };
|
|
||||||
|
|
||||||
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
|
|
||||||
|
|
||||||
expect_cons_show("Value -1 out of range. Must be in 1..65535.");
|
|
||||||
expect_cons_show("");
|
|
||||||
|
|
||||||
gboolean result = cmd_connect(NULL, args, *help);
|
|
||||||
assert_true(result);
|
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmd_connect_shows_message_when_port_65536(void **state)
|
|
||||||
{
|
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "user@server.org", "port", "65536", NULL };
|
|
||||||
|
|
||||||
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
|
|
||||||
|
|
||||||
expect_cons_show("Value 65536 out of range. Must be in 1..65535.");
|
|
||||||
expect_cons_show("");
|
|
||||||
|
|
||||||
gboolean result = cmd_connect(NULL, args, *help);
|
|
||||||
assert_true(result);
|
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmd_connect_shows_message_when_port_contains_chars(void **state)
|
|
||||||
{
|
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "user@server.org", "port", "52f66", NULL };
|
|
||||||
|
|
||||||
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
|
|
||||||
|
|
||||||
expect_cons_show("Could not convert \"52f66\" to a number.");
|
|
||||||
expect_cons_show("");
|
|
||||||
|
|
||||||
gboolean result = cmd_connect(NULL, args, *help);
|
|
||||||
assert_true(result);
|
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmd_connect_shows_usage_when_server_provided_twice(void **state)
|
|
||||||
{
|
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
help->usage = "some usage";
|
|
||||||
gchar *args[] = { "user@server.org", "server", "server1", "server", "server2", NULL };
|
|
||||||
|
|
||||||
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
|
|
||||||
|
|
||||||
expect_cons_show("Usage: some usage");
|
|
||||||
expect_cons_show("");
|
|
||||||
|
|
||||||
gboolean result = cmd_connect(NULL, args, *help);
|
|
||||||
assert_true(result);
|
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmd_connect_shows_usage_when_port_provided_twice(void **state)
|
|
||||||
{
|
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
help->usage = "some usage";
|
|
||||||
gchar *args[] = { "user@server.org", "port", "1111", "port", "1111", NULL };
|
|
||||||
|
|
||||||
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
|
|
||||||
|
|
||||||
expect_cons_show("Usage: some usage");
|
|
||||||
expect_cons_show("");
|
|
||||||
|
|
||||||
gboolean result = cmd_connect(NULL, args, *help);
|
|
||||||
assert_true(result);
|
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmd_connect_shows_usage_when_invalid_first_property(void **state)
|
|
||||||
{
|
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
help->usage = "some usage";
|
|
||||||
gchar *args[] = { "user@server.org", "wrong", "server", NULL };
|
|
||||||
|
|
||||||
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
|
|
||||||
|
|
||||||
expect_cons_show("Usage: some usage");
|
|
||||||
expect_cons_show("");
|
|
||||||
|
|
||||||
gboolean result = cmd_connect(NULL, args, *help);
|
|
||||||
assert_true(result);
|
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmd_connect_shows_usage_when_invalid_second_property(void **state)
|
|
||||||
{
|
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
help->usage = "some usage";
|
|
||||||
gchar *args[] = { "user@server.org", "server", "aserver", "wrong", "1234", NULL };
|
|
||||||
|
|
||||||
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
|
|
||||||
|
|
||||||
expect_cons_show("Usage: some usage");
|
|
||||||
expect_cons_show("");
|
|
||||||
|
|
||||||
gboolean result = cmd_connect(NULL, args, *help);
|
|
||||||
assert_true(result);
|
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmd_connect_when_no_account(void **state)
|
void cmd_connect_when_no_account(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "user@server.org", NULL };
|
gchar *args[] = { "user@server.org", NULL };
|
||||||
|
|
||||||
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
|
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
|
||||||
@ -268,93 +65,12 @@ void cmd_connect_when_no_account(void **state)
|
|||||||
expect_value(jabber_connect_with_details, port, 0);
|
expect_value(jabber_connect_with_details, port, 0);
|
||||||
will_return(jabber_connect_with_details, JABBER_CONNECTING);
|
will_return(jabber_connect_with_details, JABBER_CONNECTING);
|
||||||
|
|
||||||
gboolean result = cmd_connect(NULL, args, *help);
|
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmd_connect_with_server_when_provided(void **state)
|
|
||||||
{
|
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "user@server.org", "server", "aserver", NULL };
|
|
||||||
|
|
||||||
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
|
|
||||||
|
|
||||||
expect_string(accounts_get_account, name, "user@server.org");
|
|
||||||
will_return(accounts_get_account, NULL);
|
|
||||||
|
|
||||||
will_return(ui_ask_password, strdup("password"));
|
|
||||||
|
|
||||||
expect_cons_show("Connecting as user@server.org");
|
|
||||||
|
|
||||||
expect_string(jabber_connect_with_details, jid, "user@server.org");
|
|
||||||
expect_string(jabber_connect_with_details, passwd, "password");
|
|
||||||
expect_string(jabber_connect_with_details, altdomain, "aserver");
|
|
||||||
expect_value(jabber_connect_with_details, port, 0);
|
|
||||||
will_return(jabber_connect_with_details, JABBER_CONNECTING);
|
|
||||||
|
|
||||||
gboolean result = cmd_connect(NULL, args, *help);
|
|
||||||
assert_true(result);
|
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmd_connect_with_port_when_provided(void **state)
|
|
||||||
{
|
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "user@server.org", "port", "5432", NULL };
|
|
||||||
|
|
||||||
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
|
|
||||||
|
|
||||||
expect_string(accounts_get_account, name, "user@server.org");
|
|
||||||
will_return(accounts_get_account, NULL);
|
|
||||||
|
|
||||||
will_return(ui_ask_password, strdup("password"));
|
|
||||||
|
|
||||||
expect_cons_show("Connecting as user@server.org");
|
|
||||||
|
|
||||||
expect_string(jabber_connect_with_details, jid, "user@server.org");
|
|
||||||
expect_string(jabber_connect_with_details, passwd, "password");
|
|
||||||
expect_value(jabber_connect_with_details, altdomain, NULL);
|
|
||||||
expect_value(jabber_connect_with_details, port, 5432);
|
|
||||||
will_return(jabber_connect_with_details, JABBER_CONNECTING);
|
|
||||||
|
|
||||||
gboolean result = cmd_connect(NULL, args, *help);
|
|
||||||
assert_true(result);
|
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmd_connect_with_server_and_port_when_provided(void **state)
|
|
||||||
{
|
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "user@server.org", "port", "5432", "server", "aserver", NULL };
|
|
||||||
|
|
||||||
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
|
|
||||||
|
|
||||||
expect_string(accounts_get_account, name, "user@server.org");
|
|
||||||
will_return(accounts_get_account, NULL);
|
|
||||||
|
|
||||||
will_return(ui_ask_password, strdup("password"));
|
|
||||||
|
|
||||||
expect_cons_show("Connecting as user@server.org");
|
|
||||||
|
|
||||||
expect_string(jabber_connect_with_details, jid, "user@server.org");
|
|
||||||
expect_string(jabber_connect_with_details, passwd, "password");
|
|
||||||
expect_string(jabber_connect_with_details, altdomain, "aserver");
|
|
||||||
expect_value(jabber_connect_with_details, port, 5432);
|
|
||||||
will_return(jabber_connect_with_details, JABBER_CONNECTING);
|
|
||||||
|
|
||||||
gboolean result = cmd_connect(NULL, args, *help);
|
|
||||||
assert_true(result);
|
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_connect_fail_message(void **state)
|
void cmd_connect_fail_message(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "user@server.org", NULL };
|
gchar *args[] = { "user@server.org", NULL };
|
||||||
|
|
||||||
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
|
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
|
||||||
@ -374,15 +90,12 @@ void cmd_connect_fail_message(void **state)
|
|||||||
|
|
||||||
expect_cons_show_error("Connection attempt for user@server.org failed.");
|
expect_cons_show_error("Connection attempt for user@server.org failed.");
|
||||||
|
|
||||||
gboolean result = cmd_connect(NULL, args, *help);
|
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_connect_lowercases_argument(void **state)
|
void cmd_connect_lowercases_argument(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "USER@server.ORG", NULL };
|
gchar *args[] = { "USER@server.ORG", NULL };
|
||||||
|
|
||||||
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
|
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
|
||||||
@ -400,15 +113,12 @@ void cmd_connect_lowercases_argument(void **state)
|
|||||||
expect_any(jabber_connect_with_details, port);
|
expect_any(jabber_connect_with_details, port);
|
||||||
will_return(jabber_connect_with_details, JABBER_CONNECTING);
|
will_return(jabber_connect_with_details, JABBER_CONNECTING);
|
||||||
|
|
||||||
gboolean result = cmd_connect(NULL, args, *help);
|
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_connect_asks_password_when_not_in_account(void **state)
|
void cmd_connect_asks_password_when_not_in_account(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "jabber_org", NULL };
|
gchar *args[] = { "jabber_org", NULL };
|
||||||
ProfAccount *account = account_new("jabber_org", "me@jabber.org", NULL, NULL,
|
ProfAccount *account = account_new("jabber_org", "me@jabber.org", NULL, NULL,
|
||||||
TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||||
@ -425,15 +135,237 @@ void cmd_connect_asks_password_when_not_in_account(void **state)
|
|||||||
expect_any(jabber_connect_with_account, account);
|
expect_any(jabber_connect_with_account, account);
|
||||||
will_return(jabber_connect_with_account, JABBER_CONNECTING);
|
will_return(jabber_connect_with_account, JABBER_CONNECTING);
|
||||||
|
|
||||||
gboolean result = cmd_connect(NULL, args, *help);
|
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
}
|
||||||
|
|
||||||
free(help);
|
void cmd_connect_shows_usage_when_no_server_value(void **state)
|
||||||
|
{
|
||||||
|
gchar *args[] = { "user@server.org", "server", NULL };
|
||||||
|
|
||||||
|
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
|
||||||
|
|
||||||
|
expect_string(cons_bad_cmd_usage, cmd, CMD_CONNECT);
|
||||||
|
expect_cons_show("");
|
||||||
|
|
||||||
|
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
|
||||||
|
assert_true(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmd_connect_shows_usage_when_server_no_port_value(void **state)
|
||||||
|
{
|
||||||
|
gchar *args[] = { "user@server.org", "server", "aserver", "port", NULL };
|
||||||
|
|
||||||
|
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
|
||||||
|
|
||||||
|
expect_string(cons_bad_cmd_usage, cmd, CMD_CONNECT);
|
||||||
|
expect_cons_show("");
|
||||||
|
|
||||||
|
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
|
||||||
|
assert_true(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmd_connect_shows_usage_when_no_port_value(void **state)
|
||||||
|
{
|
||||||
|
gchar *args[] = { "user@server.org", "port", NULL };
|
||||||
|
|
||||||
|
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
|
||||||
|
|
||||||
|
expect_string(cons_bad_cmd_usage, cmd, CMD_CONNECT);
|
||||||
|
expect_cons_show("");
|
||||||
|
|
||||||
|
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
|
||||||
|
assert_true(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmd_connect_shows_usage_when_port_no_server_value(void **state)
|
||||||
|
{
|
||||||
|
gchar *args[] = { "user@server.org", "port", "5678", "server", NULL };
|
||||||
|
|
||||||
|
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
|
||||||
|
|
||||||
|
expect_string(cons_bad_cmd_usage, cmd, CMD_CONNECT);
|
||||||
|
expect_cons_show("");
|
||||||
|
|
||||||
|
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
|
||||||
|
assert_true(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmd_connect_shows_message_when_port_0(void **state)
|
||||||
|
{
|
||||||
|
gchar *args[] = { "user@server.org", "port", "0", NULL };
|
||||||
|
|
||||||
|
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
|
||||||
|
|
||||||
|
expect_cons_show("Value 0 out of range. Must be in 1..65535.");
|
||||||
|
expect_cons_show("");
|
||||||
|
|
||||||
|
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
|
||||||
|
assert_true(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmd_connect_shows_message_when_port_minus1(void **state)
|
||||||
|
{
|
||||||
|
gchar *args[] = { "user@server.org", "port", "-1", NULL };
|
||||||
|
|
||||||
|
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
|
||||||
|
|
||||||
|
expect_cons_show("Value -1 out of range. Must be in 1..65535.");
|
||||||
|
expect_cons_show("");
|
||||||
|
|
||||||
|
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
|
||||||
|
assert_true(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmd_connect_shows_message_when_port_65536(void **state)
|
||||||
|
{
|
||||||
|
gchar *args[] = { "user@server.org", "port", "65536", NULL };
|
||||||
|
|
||||||
|
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
|
||||||
|
|
||||||
|
expect_cons_show("Value 65536 out of range. Must be in 1..65535.");
|
||||||
|
expect_cons_show("");
|
||||||
|
|
||||||
|
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
|
||||||
|
assert_true(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmd_connect_shows_message_when_port_contains_chars(void **state)
|
||||||
|
{
|
||||||
|
gchar *args[] = { "user@server.org", "port", "52f66", NULL };
|
||||||
|
|
||||||
|
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
|
||||||
|
|
||||||
|
expect_cons_show("Could not convert \"52f66\" to a number.");
|
||||||
|
expect_cons_show("");
|
||||||
|
|
||||||
|
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
|
||||||
|
assert_true(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmd_connect_shows_usage_when_server_provided_twice(void **state)
|
||||||
|
{
|
||||||
|
gchar *args[] = { "user@server.org", "server", "server1", "server", "server2", NULL };
|
||||||
|
|
||||||
|
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
|
||||||
|
|
||||||
|
expect_string(cons_bad_cmd_usage, cmd, CMD_CONNECT);
|
||||||
|
expect_cons_show("");
|
||||||
|
|
||||||
|
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
|
||||||
|
assert_true(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmd_connect_shows_usage_when_port_provided_twice(void **state)
|
||||||
|
{
|
||||||
|
gchar *args[] = { "user@server.org", "port", "1111", "port", "1111", NULL };
|
||||||
|
|
||||||
|
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
|
||||||
|
|
||||||
|
expect_string(cons_bad_cmd_usage, cmd, CMD_CONNECT);
|
||||||
|
expect_cons_show("");
|
||||||
|
|
||||||
|
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
|
||||||
|
assert_true(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmd_connect_shows_usage_when_invalid_first_property(void **state)
|
||||||
|
{
|
||||||
|
gchar *args[] = { "user@server.org", "wrong", "server", NULL };
|
||||||
|
|
||||||
|
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
|
||||||
|
|
||||||
|
expect_string(cons_bad_cmd_usage, cmd, CMD_CONNECT);
|
||||||
|
expect_cons_show("");
|
||||||
|
|
||||||
|
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
|
||||||
|
assert_true(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmd_connect_shows_usage_when_invalid_second_property(void **state)
|
||||||
|
{
|
||||||
|
gchar *args[] = { "user@server.org", "server", "aserver", "wrong", "1234", NULL };
|
||||||
|
|
||||||
|
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
|
||||||
|
|
||||||
|
expect_string(cons_bad_cmd_usage, cmd, CMD_CONNECT);
|
||||||
|
expect_cons_show("");
|
||||||
|
|
||||||
|
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
|
||||||
|
assert_true(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmd_connect_with_server_when_provided(void **state)
|
||||||
|
{
|
||||||
|
gchar *args[] = { "user@server.org", "server", "aserver", NULL };
|
||||||
|
|
||||||
|
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
|
||||||
|
|
||||||
|
expect_string(accounts_get_account, name, "user@server.org");
|
||||||
|
will_return(accounts_get_account, NULL);
|
||||||
|
|
||||||
|
will_return(ui_ask_password, strdup("password"));
|
||||||
|
|
||||||
|
expect_cons_show("Connecting as user@server.org");
|
||||||
|
|
||||||
|
expect_string(jabber_connect_with_details, jid, "user@server.org");
|
||||||
|
expect_string(jabber_connect_with_details, passwd, "password");
|
||||||
|
expect_string(jabber_connect_with_details, altdomain, "aserver");
|
||||||
|
expect_value(jabber_connect_with_details, port, 0);
|
||||||
|
will_return(jabber_connect_with_details, JABBER_CONNECTING);
|
||||||
|
|
||||||
|
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
|
||||||
|
assert_true(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmd_connect_with_port_when_provided(void **state)
|
||||||
|
{
|
||||||
|
gchar *args[] = { "user@server.org", "port", "5432", NULL };
|
||||||
|
|
||||||
|
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
|
||||||
|
|
||||||
|
expect_string(accounts_get_account, name, "user@server.org");
|
||||||
|
will_return(accounts_get_account, NULL);
|
||||||
|
|
||||||
|
will_return(ui_ask_password, strdup("password"));
|
||||||
|
|
||||||
|
expect_cons_show("Connecting as user@server.org");
|
||||||
|
|
||||||
|
expect_string(jabber_connect_with_details, jid, "user@server.org");
|
||||||
|
expect_string(jabber_connect_with_details, passwd, "password");
|
||||||
|
expect_value(jabber_connect_with_details, altdomain, NULL);
|
||||||
|
expect_value(jabber_connect_with_details, port, 5432);
|
||||||
|
will_return(jabber_connect_with_details, JABBER_CONNECTING);
|
||||||
|
|
||||||
|
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
|
||||||
|
assert_true(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmd_connect_with_server_and_port_when_provided(void **state)
|
||||||
|
{
|
||||||
|
gchar *args[] = { "user@server.org", "port", "5432", "server", "aserver", NULL };
|
||||||
|
|
||||||
|
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
|
||||||
|
|
||||||
|
expect_string(accounts_get_account, name, "user@server.org");
|
||||||
|
will_return(accounts_get_account, NULL);
|
||||||
|
|
||||||
|
will_return(ui_ask_password, strdup("password"));
|
||||||
|
|
||||||
|
expect_cons_show("Connecting as user@server.org");
|
||||||
|
|
||||||
|
expect_string(jabber_connect_with_details, jid, "user@server.org");
|
||||||
|
expect_string(jabber_connect_with_details, passwd, "password");
|
||||||
|
expect_string(jabber_connect_with_details, altdomain, "aserver");
|
||||||
|
expect_value(jabber_connect_with_details, port, 5432);
|
||||||
|
will_return(jabber_connect_with_details, JABBER_CONNECTING);
|
||||||
|
|
||||||
|
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
|
||||||
|
assert_true(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_connect_shows_message_when_connecting_with_account(void **state)
|
void cmd_connect_shows_message_when_connecting_with_account(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "jabber_org", NULL };
|
gchar *args[] = { "jabber_org", NULL };
|
||||||
ProfAccount *account = account_new("jabber_org", "user@jabber.org", "password", NULL,
|
ProfAccount *account = account_new("jabber_org", "user@jabber.org", "password", NULL,
|
||||||
TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||||
@ -448,15 +380,12 @@ void cmd_connect_shows_message_when_connecting_with_account(void **state)
|
|||||||
expect_any(jabber_connect_with_account, account);
|
expect_any(jabber_connect_with_account, account);
|
||||||
will_return(jabber_connect_with_account, JABBER_CONNECTING);
|
will_return(jabber_connect_with_account, JABBER_CONNECTING);
|
||||||
|
|
||||||
gboolean result = cmd_connect(NULL, args, *help);
|
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_connect_connects_with_account(void **state)
|
void cmd_connect_connects_with_account(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "jabber_org", NULL };
|
gchar *args[] = { "jabber_org", NULL };
|
||||||
ProfAccount *account = account_new("jabber_org", "me@jabber.org", "password", NULL,
|
ProfAccount *account = account_new("jabber_org", "me@jabber.org", "password", NULL,
|
||||||
TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||||
@ -471,8 +400,6 @@ void cmd_connect_connects_with_account(void **state)
|
|||||||
expect_memory(jabber_connect_with_account, account, account, sizeof(account));
|
expect_memory(jabber_connect_with_account, account, account, sizeof(account));
|
||||||
will_return(jabber_connect_with_account, JABBER_CONNECTING);
|
will_return(jabber_connect_with_account, JABBER_CONNECTING);
|
||||||
|
|
||||||
gboolean result = cmd_connect(NULL, args, *help);
|
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
@ -12,10 +12,10 @@
|
|||||||
|
|
||||||
#include "ui/stub_ui.h"
|
#include "ui/stub_ui.h"
|
||||||
|
|
||||||
|
#define CMD_DISCONNECT "/disconnect"
|
||||||
|
|
||||||
void clears_chat_sessions(void **state)
|
void clears_chat_sessions(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
|
|
||||||
chat_sessions_init();
|
chat_sessions_init();
|
||||||
roster_init();
|
roster_init();
|
||||||
chat_session_recipient_active("bob@server.org", "laptop", FALSE);
|
chat_session_recipient_active("bob@server.org", "laptop", FALSE);
|
||||||
@ -25,7 +25,7 @@ void clears_chat_sessions(void **state)
|
|||||||
will_return(jabber_get_fulljid, "myjid@myserver.com");
|
will_return(jabber_get_fulljid, "myjid@myserver.com");
|
||||||
expect_any_cons_show();
|
expect_any_cons_show();
|
||||||
|
|
||||||
gboolean result = cmd_disconnect(NULL, NULL, *help);
|
gboolean result = cmd_disconnect(NULL, CMD_DISCONNECT, NULL);
|
||||||
|
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
@ -33,5 +33,4 @@ void clears_chat_sessions(void **state)
|
|||||||
ChatSession *session2 = chat_session_get("mike@server.org");
|
ChatSession *session2 = chat_session_get("mike@server.org");
|
||||||
assert_null(session1);
|
assert_null(session1);
|
||||||
assert_null(session2);
|
assert_null(session2);
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
@ -16,18 +16,16 @@
|
|||||||
#include "command/commands.h"
|
#include "command/commands.h"
|
||||||
#include "muc.h"
|
#include "muc.h"
|
||||||
|
|
||||||
|
#define CMD_JOIN "/join"
|
||||||
|
|
||||||
static void test_with_connection_status(jabber_conn_status_t status)
|
static void test_with_connection_status(jabber_conn_status_t status)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
|
|
||||||
will_return(jabber_get_connection_status, status);
|
will_return(jabber_get_connection_status, status);
|
||||||
|
|
||||||
expect_cons_show("You are not currently connected.");
|
expect_cons_show("You are not currently connected.");
|
||||||
|
|
||||||
gboolean result = cmd_join(NULL, NULL, *help);
|
gboolean result = cmd_join(NULL, CMD_JOIN, NULL);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_join_shows_message_when_disconnecting(void **state)
|
void cmd_join_shows_message_when_disconnecting(void **state)
|
||||||
@ -52,7 +50,6 @@ void cmd_join_shows_message_when_undefined(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)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "//@@/", NULL };
|
gchar *args[] = { "//@@/", NULL };
|
||||||
|
|
||||||
will_return(jabber_get_connection_status, JABBER_CONNECTED);
|
will_return(jabber_get_connection_status, JABBER_CONNECTED);
|
||||||
@ -60,10 +57,8 @@ void cmd_join_shows_error_message_when_invalid_room_jid(void **state)
|
|||||||
expect_cons_show_error("Specified room has incorrect format.");
|
expect_cons_show_error("Specified room has incorrect format.");
|
||||||
expect_cons_show("");
|
expect_cons_show("");
|
||||||
|
|
||||||
gboolean result = cmd_join(NULL, args, *help);
|
gboolean result = cmd_join(NULL, CMD_JOIN, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_join_uses_account_mucservice_when_no_service_specified(void **state)
|
void cmd_join_uses_account_mucservice_when_no_service_specified(void **state)
|
||||||
@ -73,7 +68,6 @@ void cmd_join_uses_account_mucservice_when_no_service_specified(void **state)
|
|||||||
char *nick = "bob";
|
char *nick = "bob";
|
||||||
char *account_service = "conference.server.org";
|
char *account_service = "conference.server.org";
|
||||||
char *expected_room = "room@conference.server.org";
|
char *expected_room = "room@conference.server.org";
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { room, "nick", nick, NULL };
|
gchar *args[] = { room, "nick", nick, NULL };
|
||||||
ProfAccount *account = account_new(account_name, "user@server.org", NULL, NULL,
|
ProfAccount *account = account_new(account_name, "user@server.org", NULL, NULL,
|
||||||
TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, account_service, NULL, NULL, NULL, NULL, NULL, NULL);
|
TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, account_service, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||||
@ -90,10 +84,8 @@ void cmd_join_uses_account_mucservice_when_no_service_specified(void **state)
|
|||||||
expect_string(presence_join_room, nick, nick);
|
expect_string(presence_join_room, nick, nick);
|
||||||
expect_value(presence_join_room, passwd, NULL);
|
expect_value(presence_join_room, passwd, NULL);
|
||||||
|
|
||||||
gboolean result = cmd_join(NULL, args, *help);
|
gboolean result = cmd_join(NULL, CMD_JOIN, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_join_uses_supplied_nick(void **state)
|
void cmd_join_uses_supplied_nick(void **state)
|
||||||
@ -101,7 +93,6 @@ void cmd_join_uses_supplied_nick(void **state)
|
|||||||
char *account_name = "an_account";
|
char *account_name = "an_account";
|
||||||
char *room = "room@conf.server.org";
|
char *room = "room@conf.server.org";
|
||||||
char *nick = "bob";
|
char *nick = "bob";
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { room, "nick", nick, NULL };
|
gchar *args[] = { room, "nick", nick, NULL };
|
||||||
ProfAccount *account = account_new(account_name, "user@server.org", NULL, NULL,
|
ProfAccount *account = account_new(account_name, "user@server.org", NULL, NULL,
|
||||||
TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||||
@ -118,10 +109,8 @@ void cmd_join_uses_supplied_nick(void **state)
|
|||||||
expect_string(presence_join_room, nick, nick);
|
expect_string(presence_join_room, nick, nick);
|
||||||
expect_value(presence_join_room, passwd, NULL);
|
expect_value(presence_join_room, passwd, NULL);
|
||||||
|
|
||||||
gboolean result = cmd_join(NULL, args, *help);
|
gboolean result = cmd_join(NULL, CMD_JOIN, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_join_uses_account_nick_when_not_supplied(void **state)
|
void cmd_join_uses_account_nick_when_not_supplied(void **state)
|
||||||
@ -129,7 +118,6 @@ void cmd_join_uses_account_nick_when_not_supplied(void **state)
|
|||||||
char *account_name = "an_account";
|
char *account_name = "an_account";
|
||||||
char *room = "room2@conf.server.org";
|
char *room = "room2@conf.server.org";
|
||||||
char *account_nick = "a_nick";
|
char *account_nick = "a_nick";
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { room, NULL };
|
gchar *args[] = { room, NULL };
|
||||||
ProfAccount *account = account_new(account_name, "user@server.org", NULL, NULL,
|
ProfAccount *account = account_new(account_name, "user@server.org", NULL, NULL,
|
||||||
TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, NULL, account_nick, NULL, NULL, NULL, NULL, NULL);
|
TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, NULL, account_nick, NULL, NULL, NULL, NULL, NULL);
|
||||||
@ -146,10 +134,8 @@ void cmd_join_uses_account_nick_when_not_supplied(void **state)
|
|||||||
expect_string(presence_join_room, nick, account_nick);
|
expect_string(presence_join_room, nick, account_nick);
|
||||||
expect_value(presence_join_room, passwd, NULL);
|
expect_value(presence_join_room, passwd, NULL);
|
||||||
|
|
||||||
gboolean result = cmd_join(NULL, args, *help);
|
gboolean result = cmd_join(NULL, CMD_JOIN, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_join_uses_password_when_supplied(void **state)
|
void cmd_join_uses_password_when_supplied(void **state)
|
||||||
@ -160,7 +146,6 @@ void cmd_join_uses_password_when_supplied(void **state)
|
|||||||
char *account_nick = "a_nick";
|
char *account_nick = "a_nick";
|
||||||
char *account_service = "a_service";
|
char *account_service = "a_service";
|
||||||
char *expected_room = "room@a_service";
|
char *expected_room = "room@a_service";
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { room, "password", password, NULL };
|
gchar *args[] = { room, "password", password, NULL };
|
||||||
ProfAccount *account = account_new(account_name, "user@server.org", NULL, NULL,
|
ProfAccount *account = account_new(account_name, "user@server.org", NULL, NULL,
|
||||||
TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, account_service, account_nick, NULL, NULL, NULL, NULL, NULL);
|
TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, account_service, account_nick, NULL, NULL, NULL, NULL, NULL);
|
||||||
@ -177,8 +162,6 @@ void cmd_join_uses_password_when_supplied(void **state)
|
|||||||
expect_string(presence_join_room, nick, account_nick);
|
expect_string(presence_join_room, nick, account_nick);
|
||||||
expect_value(presence_join_room, passwd, password);
|
expect_value(presence_join_room, passwd, password);
|
||||||
|
|
||||||
gboolean result = cmd_join(NULL, args, *help);
|
gboolean result = cmd_join(NULL, CMD_JOIN, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
@ -22,86 +22,68 @@
|
|||||||
#include "ui/ui.h"
|
#include "ui/ui.h"
|
||||||
#include "ui/stub_ui.h"
|
#include "ui/stub_ui.h"
|
||||||
|
|
||||||
|
#define CMD_OTR "/otr"
|
||||||
|
|
||||||
#ifdef HAVE_LIBOTR
|
#ifdef HAVE_LIBOTR
|
||||||
void cmd_otr_shows_usage_when_no_args(void **state)
|
void cmd_otr_shows_usage_when_no_args(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
help->usage = "Some usage";
|
|
||||||
gchar *args[] = { NULL };
|
gchar *args[] = { NULL };
|
||||||
|
|
||||||
expect_cons_show("Usage: Some usage");
|
expect_string(cons_bad_cmd_usage, cmd, CMD_OTR);
|
||||||
|
|
||||||
gboolean result = cmd_otr(NULL, args, *help);
|
gboolean result = cmd_otr(NULL, CMD_OTR, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_otr_shows_usage_when_invalid_subcommand(void **state)
|
void cmd_otr_shows_usage_when_invalid_subcommand(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
help->usage = "Some usage";
|
|
||||||
gchar *args[] = { "unknown", NULL };
|
gchar *args[] = { "unknown", NULL };
|
||||||
|
|
||||||
will_return(jabber_get_connection_status, JABBER_CONNECTED);
|
will_return(jabber_get_connection_status, JABBER_CONNECTED);
|
||||||
|
|
||||||
expect_cons_show("Usage: Some usage");
|
expect_string(cons_bad_cmd_usage, cmd, CMD_OTR);
|
||||||
|
|
||||||
gboolean result = cmd_otr(NULL, args, *help);
|
gboolean result = cmd_otr(NULL, CMD_OTR, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_otr_log_shows_usage_when_no_args(void **state)
|
void cmd_otr_log_shows_usage_when_no_args(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
help->usage = "Some usage";
|
|
||||||
gchar *args[] = { "log", NULL };
|
gchar *args[] = { "log", NULL };
|
||||||
|
|
||||||
expect_cons_show("Usage: Some usage");
|
expect_string(cons_bad_cmd_usage, cmd, CMD_OTR);
|
||||||
|
|
||||||
gboolean result = cmd_otr(NULL, args, *help);
|
gboolean result = cmd_otr(NULL, CMD_OTR, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_otr_log_shows_usage_when_invalid_subcommand(void **state)
|
void cmd_otr_log_shows_usage_when_invalid_subcommand(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
help->usage = "Some usage";
|
|
||||||
gchar *args[] = { "log", "wrong", NULL };
|
gchar *args[] = { "log", "wrong", NULL };
|
||||||
|
|
||||||
expect_cons_show("Usage: Some usage");
|
expect_string(cons_bad_cmd_usage, cmd, CMD_OTR);
|
||||||
|
|
||||||
gboolean result = cmd_otr(NULL, args, *help);
|
gboolean result = cmd_otr(NULL, CMD_OTR, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_otr_log_on_enables_logging(void **state)
|
void cmd_otr_log_on_enables_logging(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "log", "on", NULL };
|
gchar *args[] = { "log", "on", NULL };
|
||||||
prefs_set_string(PREF_OTR_LOG, "off");
|
prefs_set_string(PREF_OTR_LOG, "off");
|
||||||
prefs_set_boolean(PREF_CHLOG, TRUE);
|
prefs_set_boolean(PREF_CHLOG, TRUE);
|
||||||
|
|
||||||
expect_cons_show("OTR messages will be logged as plaintext.");
|
expect_cons_show("OTR messages will be logged as plaintext.");
|
||||||
|
|
||||||
gboolean result = cmd_otr(NULL, args, *help);
|
gboolean result = cmd_otr(NULL, CMD_OTR, args);
|
||||||
char *pref_otr_log = prefs_get_string(PREF_OTR_LOG);
|
char *pref_otr_log = prefs_get_string(PREF_OTR_LOG);
|
||||||
|
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
assert_string_equal("on", pref_otr_log);
|
assert_string_equal("on", pref_otr_log);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_otr_log_on_shows_warning_when_chlog_disabled(void **state)
|
void cmd_otr_log_on_shows_warning_when_chlog_disabled(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "log", "on", NULL };
|
gchar *args[] = { "log", "on", NULL };
|
||||||
prefs_set_string(PREF_OTR_LOG, "off");
|
prefs_set_string(PREF_OTR_LOG, "off");
|
||||||
prefs_set_boolean(PREF_CHLOG, FALSE);
|
prefs_set_boolean(PREF_CHLOG, FALSE);
|
||||||
@ -109,51 +91,42 @@ void cmd_otr_log_on_shows_warning_when_chlog_disabled(void **state)
|
|||||||
expect_cons_show("OTR messages will be logged as plaintext.");
|
expect_cons_show("OTR messages will be logged as plaintext.");
|
||||||
expect_cons_show("Chat logging is currently disabled, use '/chlog on' to enable.");
|
expect_cons_show("Chat logging is currently disabled, use '/chlog on' to enable.");
|
||||||
|
|
||||||
gboolean result = cmd_otr(NULL, args, *help);
|
gboolean result = cmd_otr(NULL, CMD_OTR, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_otr_log_off_disables_logging(void **state)
|
void cmd_otr_log_off_disables_logging(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "log", "off", NULL };
|
gchar *args[] = { "log", "off", NULL };
|
||||||
prefs_set_string(PREF_OTR_LOG, "on");
|
prefs_set_string(PREF_OTR_LOG, "on");
|
||||||
prefs_set_boolean(PREF_CHLOG, TRUE);
|
prefs_set_boolean(PREF_CHLOG, TRUE);
|
||||||
|
|
||||||
expect_cons_show("OTR message logging disabled.");
|
expect_cons_show("OTR message logging disabled.");
|
||||||
|
|
||||||
gboolean result = cmd_otr(NULL, args, *help);
|
gboolean result = cmd_otr(NULL, CMD_OTR, args);
|
||||||
char *pref_otr_log = prefs_get_string(PREF_OTR_LOG);
|
char *pref_otr_log = prefs_get_string(PREF_OTR_LOG);
|
||||||
|
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
assert_string_equal("off", pref_otr_log);
|
assert_string_equal("off", pref_otr_log);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_otr_redact_redacts_logging(void **state)
|
void cmd_otr_redact_redacts_logging(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "log", "redact", NULL };
|
gchar *args[] = { "log", "redact", NULL };
|
||||||
prefs_set_string(PREF_OTR_LOG, "on");
|
prefs_set_string(PREF_OTR_LOG, "on");
|
||||||
prefs_set_boolean(PREF_CHLOG, TRUE);
|
prefs_set_boolean(PREF_CHLOG, TRUE);
|
||||||
|
|
||||||
expect_cons_show("OTR messages will be logged as '[redacted]'.");
|
expect_cons_show("OTR messages will be logged as '[redacted]'.");
|
||||||
|
|
||||||
gboolean result = cmd_otr(NULL, args, *help);
|
gboolean result = cmd_otr(NULL, CMD_OTR, args);
|
||||||
char *pref_otr_log = prefs_get_string(PREF_OTR_LOG);
|
char *pref_otr_log = prefs_get_string(PREF_OTR_LOG);
|
||||||
|
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
assert_string_equal("redact", pref_otr_log);
|
assert_string_equal("redact", pref_otr_log);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_otr_log_redact_shows_warning_when_chlog_disabled(void **state)
|
void cmd_otr_log_redact_shows_warning_when_chlog_disabled(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "log", "redact", NULL };
|
gchar *args[] = { "log", "redact", NULL };
|
||||||
prefs_set_string(PREF_OTR_LOG, "off");
|
prefs_set_string(PREF_OTR_LOG, "off");
|
||||||
prefs_set_boolean(PREF_CHLOG, FALSE);
|
prefs_set_boolean(PREF_CHLOG, FALSE);
|
||||||
@ -161,15 +134,12 @@ void cmd_otr_log_redact_shows_warning_when_chlog_disabled(void **state)
|
|||||||
expect_cons_show("OTR messages will be logged as '[redacted]'.");
|
expect_cons_show("OTR messages will be logged as '[redacted]'.");
|
||||||
expect_cons_show("Chat logging is currently disabled, use '/chlog on' to enable.");
|
expect_cons_show("Chat logging is currently disabled, use '/chlog on' to enable.");
|
||||||
|
|
||||||
gboolean result = cmd_otr(NULL, args, *help);
|
gboolean result = cmd_otr(NULL, CMD_OTR, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_otr_libver_shows_libotr_version(void **state)
|
void cmd_otr_libver_shows_libotr_version(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "libver", NULL };
|
gchar *args[] = { "libver", NULL };
|
||||||
char *version = "9.9.9";
|
char *version = "9.9.9";
|
||||||
GString *message = g_string_new("Using libotr version ");
|
GString *message = g_string_new("Using libotr version ");
|
||||||
@ -179,41 +149,34 @@ void cmd_otr_libver_shows_libotr_version(void **state)
|
|||||||
|
|
||||||
expect_cons_show(message->str);
|
expect_cons_show(message->str);
|
||||||
|
|
||||||
gboolean result = cmd_otr(NULL, args, *help);
|
gboolean result = cmd_otr(NULL, CMD_OTR, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
g_string_free(message, TRUE);
|
g_string_free(message, TRUE);
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_otr_gen_shows_message_when_not_connected(void **state)
|
void cmd_otr_gen_shows_message_when_not_connected(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "gen", NULL };
|
gchar *args[] = { "gen", NULL };
|
||||||
|
|
||||||
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
|
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
|
||||||
|
|
||||||
expect_cons_show("You must be connected with an account to load OTR information.");
|
expect_cons_show("You must be connected with an account to load OTR information.");
|
||||||
|
|
||||||
gboolean result = cmd_otr(NULL, args, *help);
|
gboolean result = cmd_otr(NULL, CMD_OTR, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_with_command_and_connection_status(char *command, jabber_conn_status_t status)
|
static void test_with_command_and_connection_status(char *command, jabber_conn_status_t status)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { command, NULL };
|
gchar *args[] = { command, NULL };
|
||||||
|
|
||||||
will_return(jabber_get_connection_status, status);
|
will_return(jabber_get_connection_status, status);
|
||||||
|
|
||||||
expect_cons_show("You must be connected with an account to load OTR information.");
|
expect_cons_show("You must be connected with an account to load OTR information.");
|
||||||
|
|
||||||
gboolean result = cmd_otr(NULL, args, *help);
|
gboolean result = cmd_otr(NULL, CMD_OTR, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_otr_gen_shows_message_when_disconnected(void **state)
|
void cmd_otr_gen_shows_message_when_disconnected(void **state)
|
||||||
@ -243,7 +206,6 @@ void cmd_otr_gen_shows_message_when_disconnecting(void **state)
|
|||||||
|
|
||||||
void cmd_otr_gen_generates_key_for_connected_account(void **state)
|
void cmd_otr_gen_generates_key_for_connected_account(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "gen", NULL };
|
gchar *args[] = { "gen", NULL };
|
||||||
char *account_name = "myaccount";
|
char *account_name = "myaccount";
|
||||||
ProfAccount *account = account_new(account_name, "me@jabber.org", NULL, NULL,
|
ProfAccount *account = account_new(account_name, "me@jabber.org", NULL, NULL,
|
||||||
@ -258,10 +220,8 @@ void cmd_otr_gen_generates_key_for_connected_account(void **state)
|
|||||||
|
|
||||||
expect_memory(otr_keygen, account, account, sizeof(ProfAccount));
|
expect_memory(otr_keygen, account, account, sizeof(ProfAccount));
|
||||||
|
|
||||||
gboolean result = cmd_otr(NULL, args, *help);
|
gboolean result = cmd_otr(NULL, CMD_OTR, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_otr_myfp_shows_message_when_disconnected(void **state)
|
void cmd_otr_myfp_shows_message_when_disconnected(void **state)
|
||||||
@ -291,7 +251,6 @@ void cmd_otr_myfp_shows_message_when_disconnecting(void **state)
|
|||||||
|
|
||||||
void cmd_otr_myfp_shows_message_when_no_key(void **state)
|
void cmd_otr_myfp_shows_message_when_no_key(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "myfp", NULL };
|
gchar *args[] = { "myfp", NULL };
|
||||||
|
|
||||||
will_return(jabber_get_connection_status, JABBER_CONNECTED);
|
will_return(jabber_get_connection_status, JABBER_CONNECTED);
|
||||||
@ -299,16 +258,13 @@ void cmd_otr_myfp_shows_message_when_no_key(void **state)
|
|||||||
|
|
||||||
expect_ui_current_print_formatted_line('!', 0, "You have not generated or loaded a private key, use '/otr gen'");
|
expect_ui_current_print_formatted_line('!', 0, "You have not generated or loaded a private key, use '/otr gen'");
|
||||||
|
|
||||||
gboolean result = cmd_otr(NULL, args, *help);
|
gboolean result = cmd_otr(NULL, CMD_OTR, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_otr_myfp_shows_my_fingerprint(void **state)
|
void cmd_otr_myfp_shows_my_fingerprint(void **state)
|
||||||
{
|
{
|
||||||
char *fingerprint = "AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD EEEEEEEE";
|
char *fingerprint = "AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD EEEEEEEE";
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "myfp", NULL };
|
gchar *args[] = { "myfp", NULL };
|
||||||
GString *message = g_string_new("Your OTR fingerprint: ");
|
GString *message = g_string_new("Your OTR fingerprint: ");
|
||||||
g_string_append(message, fingerprint);
|
g_string_append(message, fingerprint);
|
||||||
@ -319,17 +275,15 @@ void cmd_otr_myfp_shows_my_fingerprint(void **state)
|
|||||||
|
|
||||||
expect_ui_current_print_formatted_line('!', 0, message->str);
|
expect_ui_current_print_formatted_line('!', 0, message->str);
|
||||||
|
|
||||||
gboolean result = cmd_otr(NULL, args, *help);
|
gboolean result = cmd_otr(NULL, CMD_OTR, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
g_string_free(message, TRUE);
|
g_string_free(message, TRUE);
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_cmd_otr_theirfp_from_wintype(win_type_t wintype)
|
test_cmd_otr_theirfp_from_wintype(win_type_t wintype)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "theirfp", NULL };
|
gchar *args[] = { "theirfp", NULL };
|
||||||
ProfWin window;
|
ProfWin window;
|
||||||
window.type = wintype;
|
window.type = wintype;
|
||||||
@ -338,10 +292,9 @@ test_cmd_otr_theirfp_from_wintype(win_type_t wintype)
|
|||||||
|
|
||||||
expect_ui_current_print_line("You must be in a regular chat window to view a recipient's fingerprint.");
|
expect_ui_current_print_line("You must be in a regular chat window to view a recipient's fingerprint.");
|
||||||
|
|
||||||
gboolean result = cmd_otr(&window, args, *help);
|
gboolean result = cmd_otr(&window, CMD_OTR, args);
|
||||||
assert_true(result);
|
|
||||||
|
|
||||||
free(help);
|
assert_true(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_otr_theirfp_shows_message_when_in_console(void **state)
|
void cmd_otr_theirfp_shows_message_when_in_console(void **state)
|
||||||
@ -361,7 +314,6 @@ void cmd_otr_theirfp_shows_message_when_in_private(void **state)
|
|||||||
|
|
||||||
void cmd_otr_theirfp_shows_message_when_non_otr_chat_window(void **state)
|
void cmd_otr_theirfp_shows_message_when_non_otr_chat_window(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "theirfp", NULL };
|
gchar *args[] = { "theirfp", NULL };
|
||||||
|
|
||||||
ProfWin window;
|
ProfWin window;
|
||||||
@ -374,17 +326,15 @@ void cmd_otr_theirfp_shows_message_when_non_otr_chat_window(void **state)
|
|||||||
|
|
||||||
expect_ui_current_print_formatted_line('!', 0, "You are not currently in an OTR session.");
|
expect_ui_current_print_formatted_line('!', 0, "You are not currently in an OTR session.");
|
||||||
|
|
||||||
gboolean result = cmd_otr((ProfWin*)&chatwin, args, *help);
|
gboolean result = cmd_otr((ProfWin*)&chatwin, CMD_OTR, args);
|
||||||
assert_true(result);
|
|
||||||
|
|
||||||
free(help);
|
assert_true(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_otr_theirfp_shows_fingerprint(void **state)
|
void cmd_otr_theirfp_shows_fingerprint(void **state)
|
||||||
{
|
{
|
||||||
char *recipient = "someone@chat.com";
|
char *recipient = "someone@chat.com";
|
||||||
char *fingerprint = "AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD EEEEEEEE";
|
char *fingerprint = "AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD EEEEEEEE";
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "theirfp", NULL };
|
gchar *args[] = { "theirfp", NULL };
|
||||||
GString *message = g_string_new(recipient);
|
GString *message = g_string_new(recipient);
|
||||||
g_string_append(message, "'s OTR fingerprint: ");
|
g_string_append(message, "'s OTR fingerprint: ");
|
||||||
@ -405,17 +355,15 @@ void cmd_otr_theirfp_shows_fingerprint(void **state)
|
|||||||
|
|
||||||
expect_ui_current_print_formatted_line('!', 0, message->str);
|
expect_ui_current_print_formatted_line('!', 0, message->str);
|
||||||
|
|
||||||
gboolean result = cmd_otr((ProfWin*)&chatwin, args, *help);
|
gboolean result = cmd_otr((ProfWin*)&chatwin, CMD_OTR, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
g_string_free(message, TRUE);
|
g_string_free(message, TRUE);
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_cmd_otr_start_from_wintype(win_type_t wintype)
|
test_cmd_otr_start_from_wintype(win_type_t wintype)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "start", NULL };
|
gchar *args[] = { "start", NULL };
|
||||||
ProfWin window;
|
ProfWin window;
|
||||||
window.type = wintype;
|
window.type = wintype;
|
||||||
@ -424,10 +372,8 @@ test_cmd_otr_start_from_wintype(win_type_t wintype)
|
|||||||
|
|
||||||
expect_ui_current_print_line("You must be in a regular chat window to start an OTR session.");
|
expect_ui_current_print_line("You must be in a regular chat window to start an OTR session.");
|
||||||
|
|
||||||
gboolean result = cmd_otr(&window, args, *help);
|
gboolean result = cmd_otr(&window, CMD_OTR, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_otr_start_shows_message_when_in_console(void **state)
|
void cmd_otr_start_shows_message_when_in_console(void **state)
|
||||||
@ -448,7 +394,6 @@ void cmd_otr_start_shows_message_when_in_private(void **state)
|
|||||||
void cmd_otr_start_shows_message_when_already_started(void **state)
|
void cmd_otr_start_shows_message_when_already_started(void **state)
|
||||||
{
|
{
|
||||||
char *recipient = "someone@server.org";
|
char *recipient = "someone@server.org";
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "start", NULL };
|
gchar *args[] = { "start", NULL };
|
||||||
|
|
||||||
will_return(jabber_get_connection_status, JABBER_CONNECTED);
|
will_return(jabber_get_connection_status, JABBER_CONNECTED);
|
||||||
@ -463,16 +408,13 @@ void cmd_otr_start_shows_message_when_already_started(void **state)
|
|||||||
|
|
||||||
expect_ui_current_print_formatted_line('!', 0, "You are already in an OTR session.");
|
expect_ui_current_print_formatted_line('!', 0, "You are already in an OTR session.");
|
||||||
|
|
||||||
gboolean result = cmd_otr((ProfWin*)&chatwin, args, *help);
|
gboolean result = cmd_otr((ProfWin*)&chatwin, CMD_OTR, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_otr_start_shows_message_when_no_key(void **state)
|
void cmd_otr_start_shows_message_when_no_key(void **state)
|
||||||
{
|
{
|
||||||
char *recipient = "someone@server.org";
|
char *recipient = "someone@server.org";
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "start", NULL };
|
gchar *args[] = { "start", NULL };
|
||||||
|
|
||||||
will_return(jabber_get_connection_status, JABBER_CONNECTED);
|
will_return(jabber_get_connection_status, JABBER_CONNECTED);
|
||||||
@ -488,10 +430,8 @@ void cmd_otr_start_shows_message_when_no_key(void **state)
|
|||||||
|
|
||||||
expect_ui_current_print_formatted_line('!', 0, "You have not generated or loaded a private key, use '/otr gen'");
|
expect_ui_current_print_formatted_line('!', 0, "You have not generated or loaded a private key, use '/otr gen'");
|
||||||
|
|
||||||
gboolean result = cmd_otr((ProfWin*)&chatwin, args, *help);
|
gboolean result = cmd_otr((ProfWin*)&chatwin, CMD_OTR, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -499,7 +439,6 @@ cmd_otr_start_sends_otr_query_message_to_current_recipeint(void **state)
|
|||||||
{
|
{
|
||||||
char *recipient = "buddy@chat.com";
|
char *recipient = "buddy@chat.com";
|
||||||
char *query_message = "?OTR?";
|
char *query_message = "?OTR?";
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "start", NULL };
|
gchar *args[] = { "start", NULL };
|
||||||
|
|
||||||
ProfWin window;
|
ProfWin window;
|
||||||
@ -517,23 +456,18 @@ cmd_otr_start_sends_otr_query_message_to_current_recipeint(void **state)
|
|||||||
expect_string(message_send_chat_otr, barejid, recipient);
|
expect_string(message_send_chat_otr, barejid, recipient);
|
||||||
expect_string(message_send_chat_otr, msg, query_message);
|
expect_string(message_send_chat_otr, msg, query_message);
|
||||||
|
|
||||||
gboolean result = cmd_otr((ProfWin*)&chatwin, args, *help);
|
gboolean result = cmd_otr((ProfWin*)&chatwin, CMD_OTR, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
void cmd_otr_shows_message_when_otr_unsupported(void **state)
|
void cmd_otr_shows_message_when_otr_unsupported(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "gen", NULL };
|
gchar *args[] = { "gen", NULL };
|
||||||
|
|
||||||
expect_cons_show("This version of Profanity has not been built with OTR support enabled");
|
expect_cons_show("This version of Profanity has not been built with OTR support enabled");
|
||||||
|
|
||||||
gboolean result = cmd_otr(NULL, args, *help);
|
gboolean result = cmd_otr(NULL, CMD_OTR, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -12,25 +12,21 @@
|
|||||||
|
|
||||||
#include "ui/stub_ui.h"
|
#include "ui/stub_ui.h"
|
||||||
|
|
||||||
|
#define CMD_PGP "/pgp"
|
||||||
|
|
||||||
#ifdef HAVE_LIBGPGME
|
#ifdef HAVE_LIBGPGME
|
||||||
void cmd_pgp_shows_usage_when_no_args(void **state)
|
void cmd_pgp_shows_usage_when_no_args(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
help->usage = "Some usage";
|
|
||||||
gchar *args[] = { NULL };
|
gchar *args[] = { NULL };
|
||||||
|
|
||||||
expect_cons_show("Usage: Some usage");
|
expect_string(cons_bad_cmd_usage, cmd, CMD_PGP);
|
||||||
|
|
||||||
gboolean result = cmd_pgp(NULL, args, *help);
|
gboolean result = cmd_pgp(NULL, CMD_PGP, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_pgp_start_shows_message_when_connection(jabber_conn_status_t conn_status)
|
void cmd_pgp_start_shows_message_when_connection(jabber_conn_status_t conn_status)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
help->usage = "Some usage";
|
|
||||||
gchar *args[] = { "start", NULL };
|
gchar *args[] = { "start", NULL };
|
||||||
ProfWin window;
|
ProfWin window;
|
||||||
window.type = WIN_CHAT;
|
window.type = WIN_CHAT;
|
||||||
@ -39,10 +35,8 @@ void cmd_pgp_start_shows_message_when_connection(jabber_conn_status_t conn_statu
|
|||||||
|
|
||||||
expect_cons_show("You must be connected to start PGP encrpytion.");
|
expect_cons_show("You must be connected to start PGP encrpytion.");
|
||||||
|
|
||||||
gboolean result = cmd_pgp(&window, args, *help);
|
gboolean result = cmd_pgp(&window, CMD_PGP, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_pgp_start_shows_message_when_disconnected(void **state)
|
void cmd_pgp_start_shows_message_when_disconnected(void **state)
|
||||||
@ -72,8 +66,6 @@ void cmd_pgp_start_shows_message_when_started(void **state)
|
|||||||
|
|
||||||
void cmd_pgp_start_shows_message_when_no_arg_in_wintype(win_type_t wintype)
|
void cmd_pgp_start_shows_message_when_no_arg_in_wintype(win_type_t wintype)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
help->usage = "Some usage";
|
|
||||||
gchar *args[] = { "start", NULL };
|
gchar *args[] = { "start", NULL };
|
||||||
ProfWin window;
|
ProfWin window;
|
||||||
window.type = wintype;
|
window.type = wintype;
|
||||||
@ -82,10 +74,8 @@ void cmd_pgp_start_shows_message_when_no_arg_in_wintype(win_type_t wintype)
|
|||||||
|
|
||||||
expect_cons_show("You must be in a regular chat window to start PGP encrpytion.");
|
expect_cons_show("You must be in a regular chat window to start PGP encrpytion.");
|
||||||
|
|
||||||
gboolean result = cmd_pgp(&window, args, *help);
|
gboolean result = cmd_pgp(&window, CMD_PGP, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_pgp_start_shows_message_when_no_arg_in_console(void **state)
|
void cmd_pgp_start_shows_message_when_no_arg_in_console(void **state)
|
||||||
@ -116,14 +106,11 @@ void cmd_pgp_start_shows_message_when_no_arg_in_xmlconsole(void **state)
|
|||||||
#else
|
#else
|
||||||
void cmd_pgp_shows_message_when_pgp_unsupported(void **state)
|
void cmd_pgp_shows_message_when_pgp_unsupported(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "gen", NULL };
|
gchar *args[] = { "gen", NULL };
|
||||||
|
|
||||||
expect_cons_show("This version of Profanity has not been built with PGP support enabled");
|
expect_cons_show("This version of Profanity has not been built with PGP support enabled");
|
||||||
|
|
||||||
gboolean result = cmd_pgp(NULL, args, *help);
|
gboolean result = cmd_pgp(NULL, CMD_PGP, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -14,18 +14,16 @@
|
|||||||
#include "config/accounts.h"
|
#include "config/accounts.h"
|
||||||
#include "command/commands.h"
|
#include "command/commands.h"
|
||||||
|
|
||||||
|
#define CMD_ROOMS "/rooms"
|
||||||
|
|
||||||
static void test_with_connection_status(jabber_conn_status_t status)
|
static void test_with_connection_status(jabber_conn_status_t status)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
|
|
||||||
will_return(jabber_get_connection_status, status);
|
will_return(jabber_get_connection_status, status);
|
||||||
|
|
||||||
expect_cons_show("You are not currently connected.");
|
expect_cons_show("You are not currently connected.");
|
||||||
|
|
||||||
gboolean result = cmd_rooms(NULL, NULL, *help);
|
gboolean result = cmd_rooms(NULL, CMD_ROOMS, NULL);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_rooms_shows_message_when_disconnected(void **state)
|
void cmd_rooms_shows_message_when_disconnected(void **state)
|
||||||
@ -55,7 +53,6 @@ void cmd_rooms_shows_message_when_undefined(void **state)
|
|||||||
|
|
||||||
void cmd_rooms_uses_account_default_when_no_arg(void **state)
|
void cmd_rooms_uses_account_default_when_no_arg(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { NULL };
|
gchar *args[] = { NULL };
|
||||||
ProfAccount *account = malloc(sizeof(ProfAccount));
|
ProfAccount *account = malloc(sizeof(ProfAccount));
|
||||||
account->name = NULL;
|
account->name = NULL;
|
||||||
@ -81,25 +78,18 @@ void cmd_rooms_uses_account_default_when_no_arg(void **state)
|
|||||||
|
|
||||||
expect_string(iq_room_list_request, conferencejid, "default_conf_server");
|
expect_string(iq_room_list_request, conferencejid, "default_conf_server");
|
||||||
|
|
||||||
gboolean result = cmd_rooms(NULL, args, *help);
|
gboolean result = cmd_rooms(NULL, CMD_ROOMS, args);
|
||||||
|
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_rooms_arg_used_when_passed(void **state)
|
void cmd_rooms_arg_used_when_passed(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "conf_server_arg" };
|
gchar *args[] = { "conf_server_arg" };
|
||||||
|
|
||||||
will_return(jabber_get_connection_status, JABBER_CONNECTED);
|
will_return(jabber_get_connection_status, JABBER_CONNECTED);
|
||||||
|
|
||||||
expect_string(iq_room_list_request, conferencejid, "conf_server_arg");
|
expect_string(iq_room_list_request, conferencejid, "conf_server_arg");
|
||||||
|
|
||||||
gboolean result = cmd_rooms(NULL, args, *help);
|
gboolean result = cmd_rooms(NULL, CMD_ROOMS, args);
|
||||||
|
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
@ -13,19 +13,18 @@
|
|||||||
#include "roster_list.h"
|
#include "roster_list.h"
|
||||||
#include "command/commands.h"
|
#include "command/commands.h"
|
||||||
|
|
||||||
|
#define CMD_ROSTER "/roster"
|
||||||
|
|
||||||
static void test_with_connection_status(jabber_conn_status_t status)
|
static void test_with_connection_status(jabber_conn_status_t status)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { NULL };
|
gchar *args[] = { NULL };
|
||||||
|
|
||||||
will_return(jabber_get_connection_status, status);
|
will_return(jabber_get_connection_status, status);
|
||||||
|
|
||||||
expect_cons_show("You are not currently connected.");
|
expect_cons_show("You are not currently connected.");
|
||||||
|
|
||||||
gboolean result = cmd_roster(NULL, args, *help);
|
gboolean result = cmd_roster(NULL, CMD_ROSTER, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_roster_shows_message_when_disconnecting(void **state)
|
void cmd_roster_shows_message_when_disconnecting(void **state)
|
||||||
@ -50,7 +49,6 @@ void cmd_roster_shows_message_when_undefined(void **state)
|
|||||||
|
|
||||||
void cmd_roster_shows_roster_when_no_args(void **state)
|
void cmd_roster_shows_roster_when_no_args(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { NULL };
|
gchar *args[] = { NULL };
|
||||||
|
|
||||||
will_return(jabber_get_connection_status, JABBER_CONNECTED);
|
will_return(jabber_get_connection_status, JABBER_CONNECTED);
|
||||||
@ -61,34 +59,28 @@ void cmd_roster_shows_roster_when_no_args(void **state)
|
|||||||
|
|
||||||
expect_memory(cons_show_roster, list, roster, sizeof(roster));
|
expect_memory(cons_show_roster, list, roster, sizeof(roster));
|
||||||
|
|
||||||
gboolean result = cmd_roster(NULL, args, *help);
|
gboolean result = cmd_roster(NULL, CMD_ROSTER, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
roster_free();
|
roster_free();
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_roster_add_shows_message_when_no_jid(void **state)
|
void cmd_roster_add_shows_message_when_no_jid(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
help->usage = "some usage";
|
|
||||||
gchar *args[] = { "add", NULL };
|
gchar *args[] = { "add", NULL };
|
||||||
|
|
||||||
will_return(jabber_get_connection_status, JABBER_CONNECTED);
|
will_return(jabber_get_connection_status, JABBER_CONNECTED);
|
||||||
|
|
||||||
expect_cons_show("Usage: some usage");
|
expect_string(cons_bad_cmd_usage, cmd, CMD_ROSTER);
|
||||||
|
|
||||||
gboolean result = cmd_roster(NULL, args, *help);
|
gboolean result = cmd_roster(NULL, CMD_ROSTER, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_roster_add_sends_roster_add_request(void **state)
|
void cmd_roster_add_sends_roster_add_request(void **state)
|
||||||
{
|
{
|
||||||
char *jid = "bob@server.org";
|
char *jid = "bob@server.org";
|
||||||
char *nick = "bob";
|
char *nick = "bob";
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "add", jid, nick, NULL };
|
gchar *args[] = { "add", jid, nick, NULL };
|
||||||
|
|
||||||
will_return(jabber_get_connection_status, JABBER_CONNECTED);
|
will_return(jabber_get_connection_status, JABBER_CONNECTED);
|
||||||
@ -96,80 +88,61 @@ void cmd_roster_add_sends_roster_add_request(void **state)
|
|||||||
expect_string(roster_send_add_new, barejid, jid);
|
expect_string(roster_send_add_new, barejid, jid);
|
||||||
expect_string(roster_send_add_new, name, nick);
|
expect_string(roster_send_add_new, name, nick);
|
||||||
|
|
||||||
gboolean result = cmd_roster(NULL, args, *help);
|
gboolean result = cmd_roster(NULL, CMD_ROSTER, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_roster_remove_shows_message_when_no_jid(void **state)
|
void cmd_roster_remove_shows_message_when_no_jid(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
help->usage = "some usage";
|
|
||||||
gchar *args[] = { "remove", NULL };
|
gchar *args[] = { "remove", NULL };
|
||||||
|
|
||||||
will_return(jabber_get_connection_status, JABBER_CONNECTED);
|
will_return(jabber_get_connection_status, JABBER_CONNECTED);
|
||||||
|
|
||||||
expect_cons_show("Usage: some usage");
|
expect_string(cons_bad_cmd_usage, cmd, CMD_ROSTER);
|
||||||
|
|
||||||
gboolean result = cmd_roster(NULL, args, *help);
|
gboolean result = cmd_roster(NULL, CMD_ROSTER, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_roster_remove_sends_roster_remove_request(void **state)
|
void cmd_roster_remove_sends_roster_remove_request(void **state)
|
||||||
{
|
{
|
||||||
char *jid = "bob@server.org";
|
char *jid = "bob@server.org";
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "remove", jid, NULL };
|
gchar *args[] = { "remove", jid, NULL };
|
||||||
|
|
||||||
will_return(jabber_get_connection_status, JABBER_CONNECTED);
|
will_return(jabber_get_connection_status, JABBER_CONNECTED);
|
||||||
|
|
||||||
expect_string(roster_send_remove, barejid, jid);
|
expect_string(roster_send_remove, barejid, jid);
|
||||||
|
|
||||||
gboolean result = cmd_roster(NULL, args, *help);
|
gboolean result = cmd_roster(NULL, CMD_ROSTER, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_roster_nick_shows_message_when_no_jid(void **state)
|
void cmd_roster_nick_shows_message_when_no_jid(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
help->usage = "some usage";
|
|
||||||
gchar *args[] = { "nick", NULL };
|
gchar *args[] = { "nick", NULL };
|
||||||
|
|
||||||
will_return(jabber_get_connection_status, JABBER_CONNECTED);
|
will_return(jabber_get_connection_status, JABBER_CONNECTED);
|
||||||
|
|
||||||
expect_cons_show("Usage: some usage");
|
expect_string(cons_bad_cmd_usage, cmd, CMD_ROSTER);
|
||||||
|
|
||||||
gboolean result = cmd_roster(NULL, args, *help);
|
gboolean result = cmd_roster(NULL, CMD_ROSTER, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_roster_nick_shows_message_when_no_nick(void **state)
|
void cmd_roster_nick_shows_message_when_no_nick(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
help->usage = "some usage";
|
|
||||||
gchar *args[] = { "nick", "bob@server.org", NULL };
|
gchar *args[] = { "nick", "bob@server.org", NULL };
|
||||||
|
|
||||||
will_return(jabber_get_connection_status, JABBER_CONNECTED);
|
will_return(jabber_get_connection_status, JABBER_CONNECTED);
|
||||||
|
|
||||||
expect_cons_show("Usage: some usage");
|
expect_string(cons_bad_cmd_usage, cmd, CMD_ROSTER);
|
||||||
|
|
||||||
gboolean result = cmd_roster(NULL, args, *help);
|
gboolean result = cmd_roster(NULL, CMD_ROSTER, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_roster_nick_shows_message_when_no_contact_exists(void **state)
|
void cmd_roster_nick_shows_message_when_no_contact_exists(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
help->usage = "some usage";
|
|
||||||
gchar *args[] = { "nick", "bob@server.org", "bobster", NULL };
|
gchar *args[] = { "nick", "bob@server.org", "bobster", NULL };
|
||||||
|
|
||||||
roster_init();
|
roster_init();
|
||||||
@ -178,10 +151,9 @@ void cmd_roster_nick_shows_message_when_no_contact_exists(void **state)
|
|||||||
|
|
||||||
expect_cons_show("Contact not found in roster: bob@server.org");
|
expect_cons_show("Contact not found in roster: bob@server.org");
|
||||||
|
|
||||||
gboolean result = cmd_roster(NULL, args, *help);
|
gboolean result = cmd_roster(NULL, CMD_ROSTER, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
roster_free();
|
roster_free();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,7 +161,6 @@ void cmd_roster_nick_sends_name_change_request(void **state)
|
|||||||
{
|
{
|
||||||
char *jid = "bob@server.org";
|
char *jid = "bob@server.org";
|
||||||
char *nick = "bobster";
|
char *nick = "bobster";
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "nick", jid, nick, NULL };
|
gchar *args[] = { "nick", jid, nick, NULL };
|
||||||
|
|
||||||
roster_init();
|
roster_init();
|
||||||
@ -205,36 +176,28 @@ void cmd_roster_nick_sends_name_change_request(void **state)
|
|||||||
|
|
||||||
expect_cons_show("Nickname for bob@server.org set to: bobster.");
|
expect_cons_show("Nickname for bob@server.org set to: bobster.");
|
||||||
|
|
||||||
gboolean result = cmd_roster(NULL, args, *help);
|
gboolean result = cmd_roster(NULL, CMD_ROSTER, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
PContact contact = roster_get_contact(jid);
|
PContact contact = roster_get_contact(jid);
|
||||||
assert_string_equal(p_contact_name(contact), nick);
|
assert_string_equal(p_contact_name(contact), nick);
|
||||||
|
|
||||||
free(help);
|
|
||||||
roster_free();
|
roster_free();
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_roster_clearnick_shows_message_when_no_jid(void **state)
|
void cmd_roster_clearnick_shows_message_when_no_jid(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
help->usage = "some usage";
|
|
||||||
gchar *args[] = { "clearnick", NULL };
|
gchar *args[] = { "clearnick", NULL };
|
||||||
|
|
||||||
will_return(jabber_get_connection_status, JABBER_CONNECTED);
|
will_return(jabber_get_connection_status, JABBER_CONNECTED);
|
||||||
|
|
||||||
expect_cons_show("Usage: some usage");
|
expect_string(cons_bad_cmd_usage, cmd, CMD_ROSTER);
|
||||||
|
|
||||||
gboolean result = cmd_roster(NULL, args, *help);
|
gboolean result = cmd_roster(NULL, CMD_ROSTER, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_roster_clearnick_shows_message_when_no_contact_exists(void **state)
|
void cmd_roster_clearnick_shows_message_when_no_contact_exists(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
help->usage = "some usage";
|
|
||||||
gchar *args[] = { "clearnick", "bob@server.org", NULL };
|
gchar *args[] = { "clearnick", "bob@server.org", NULL };
|
||||||
|
|
||||||
roster_init();
|
roster_init();
|
||||||
@ -243,17 +206,15 @@ void cmd_roster_clearnick_shows_message_when_no_contact_exists(void **state)
|
|||||||
|
|
||||||
expect_cons_show("Contact not found in roster: bob@server.org");
|
expect_cons_show("Contact not found in roster: bob@server.org");
|
||||||
|
|
||||||
gboolean result = cmd_roster(NULL, args, *help);
|
gboolean result = cmd_roster(NULL, CMD_ROSTER, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
roster_free();
|
roster_free();
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_roster_clearnick_sends_name_change_request_with_empty_nick(void **state)
|
void cmd_roster_clearnick_sends_name_change_request_with_empty_nick(void **state)
|
||||||
{
|
{
|
||||||
char *jid = "bob@server.org";
|
char *jid = "bob@server.org";
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "clearnick", jid, NULL };
|
gchar *args[] = { "clearnick", jid, NULL };
|
||||||
|
|
||||||
roster_init();
|
roster_init();
|
||||||
@ -269,12 +230,11 @@ void cmd_roster_clearnick_sends_name_change_request_with_empty_nick(void **state
|
|||||||
|
|
||||||
expect_cons_show("Nickname for bob@server.org removed.");
|
expect_cons_show("Nickname for bob@server.org removed.");
|
||||||
|
|
||||||
gboolean result = cmd_roster(NULL, args, *help);
|
gboolean result = cmd_roster(NULL, CMD_ROSTER, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
PContact contact = roster_get_contact(jid);
|
PContact contact = roster_get_contact(jid);
|
||||||
assert_null(p_contact_name(contact));
|
assert_null(p_contact_name(contact));
|
||||||
|
|
||||||
free(help);
|
|
||||||
roster_free();
|
roster_free();
|
||||||
}
|
}
|
||||||
|
@ -13,211 +13,170 @@
|
|||||||
|
|
||||||
#include "command/commands.h"
|
#include "command/commands.h"
|
||||||
|
|
||||||
|
#define CMD_STATUSES "/statuses"
|
||||||
|
|
||||||
void cmd_statuses_shows_usage_when_bad_subcmd(void **state)
|
void cmd_statuses_shows_usage_when_bad_subcmd(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
help->usage = "some usage";
|
|
||||||
gchar *args[] = { "badcmd", NULL };
|
gchar *args[] = { "badcmd", NULL };
|
||||||
|
|
||||||
expect_cons_show("Usage: some usage");
|
expect_string(cons_bad_cmd_usage, cmd, CMD_STATUSES);
|
||||||
|
|
||||||
gboolean result = cmd_statuses(NULL, args, *help);
|
gboolean result = cmd_statuses(NULL, CMD_STATUSES, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_statuses_shows_usage_when_bad_console_setting(void **state)
|
void cmd_statuses_shows_usage_when_bad_console_setting(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
help->usage = "some usage";
|
|
||||||
gchar *args[] = { "console", "badsetting", NULL };
|
gchar *args[] = { "console", "badsetting", NULL };
|
||||||
|
|
||||||
expect_cons_show("Usage: some usage");
|
expect_string(cons_bad_cmd_usage, cmd, CMD_STATUSES);
|
||||||
|
|
||||||
gboolean result = cmd_statuses(NULL, args, *help);
|
gboolean result = cmd_statuses(NULL, CMD_STATUSES, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_statuses_shows_usage_when_bad_chat_setting(void **state)
|
void cmd_statuses_shows_usage_when_bad_chat_setting(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
help->usage = "some usage";
|
|
||||||
gchar *args[] = { "chat", "badsetting", NULL };
|
gchar *args[] = { "chat", "badsetting", NULL };
|
||||||
|
|
||||||
expect_cons_show("Usage: some usage");
|
expect_string(cons_bad_cmd_usage, cmd, CMD_STATUSES);
|
||||||
|
|
||||||
gboolean result = cmd_statuses(NULL, args, *help);
|
gboolean result = cmd_statuses(NULL, CMD_STATUSES, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_statuses_shows_usage_when_bad_muc_setting(void **state)
|
void cmd_statuses_shows_usage_when_bad_muc_setting(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
help->usage = "some usage";
|
|
||||||
gchar *args[] = { "muc", "badsetting", NULL };
|
gchar *args[] = { "muc", "badsetting", NULL };
|
||||||
|
|
||||||
expect_cons_show("Usage: some usage");
|
expect_string(cons_bad_cmd_usage, cmd, CMD_STATUSES);
|
||||||
|
|
||||||
gboolean result = cmd_statuses(NULL, args, *help);
|
gboolean result = cmd_statuses(NULL, CMD_STATUSES, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_statuses_console_sets_all(void **state)
|
void cmd_statuses_console_sets_all(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "console", "all", NULL };
|
gchar *args[] = { "console", "all", NULL };
|
||||||
|
|
||||||
expect_cons_show("All presence updates will appear in the console.");
|
expect_cons_show("All presence updates will appear in the console.");
|
||||||
|
|
||||||
gboolean result = cmd_statuses(NULL, args, *help);
|
gboolean result = cmd_statuses(NULL, CMD_STATUSES, args);
|
||||||
|
|
||||||
char *setting = prefs_get_string(PREF_STATUSES_CONSOLE);
|
char *setting = prefs_get_string(PREF_STATUSES_CONSOLE);
|
||||||
assert_non_null(setting);
|
assert_non_null(setting);
|
||||||
assert_string_equal("all", setting);
|
assert_string_equal("all", setting);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_statuses_console_sets_online(void **state)
|
void cmd_statuses_console_sets_online(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "console", "online", NULL };
|
gchar *args[] = { "console", "online", NULL };
|
||||||
|
|
||||||
expect_cons_show("Only online/offline presence updates will appear in the console.");
|
expect_cons_show("Only online/offline presence updates will appear in the console.");
|
||||||
|
|
||||||
gboolean result = cmd_statuses(NULL, args, *help);
|
gboolean result = cmd_statuses(NULL, CMD_STATUSES, args);
|
||||||
|
|
||||||
char *setting = prefs_get_string(PREF_STATUSES_CONSOLE);
|
char *setting = prefs_get_string(PREF_STATUSES_CONSOLE);
|
||||||
assert_non_null(setting);
|
assert_non_null(setting);
|
||||||
assert_string_equal("online", setting);
|
assert_string_equal("online", setting);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_statuses_console_sets_none(void **state)
|
void cmd_statuses_console_sets_none(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "console", "none", NULL };
|
gchar *args[] = { "console", "none", NULL };
|
||||||
|
|
||||||
expect_cons_show("Presence updates will not appear in the console.");
|
expect_cons_show("Presence updates will not appear in the console.");
|
||||||
|
|
||||||
gboolean result = cmd_statuses(NULL, args, *help);
|
gboolean result = cmd_statuses(NULL, CMD_STATUSES, args);
|
||||||
|
|
||||||
char *setting = prefs_get_string(PREF_STATUSES_CONSOLE);
|
char *setting = prefs_get_string(PREF_STATUSES_CONSOLE);
|
||||||
assert_non_null(setting);
|
assert_non_null(setting);
|
||||||
assert_string_equal("none", setting);
|
assert_string_equal("none", setting);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_statuses_chat_sets_all(void **state)
|
void cmd_statuses_chat_sets_all(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "chat", "all", NULL };
|
gchar *args[] = { "chat", "all", NULL };
|
||||||
|
|
||||||
expect_cons_show("All presence updates will appear in chat windows.");
|
expect_cons_show("All presence updates will appear in chat windows.");
|
||||||
|
|
||||||
gboolean result = cmd_statuses(NULL, args, *help);
|
gboolean result = cmd_statuses(NULL, CMD_STATUSES, args);
|
||||||
|
|
||||||
char *setting = prefs_get_string(PREF_STATUSES_CHAT);
|
char *setting = prefs_get_string(PREF_STATUSES_CHAT);
|
||||||
assert_non_null(setting);
|
assert_non_null(setting);
|
||||||
assert_string_equal("all", setting);
|
assert_string_equal("all", setting);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_statuses_chat_sets_online(void **state)
|
void cmd_statuses_chat_sets_online(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "chat", "online", NULL };
|
gchar *args[] = { "chat", "online", NULL };
|
||||||
|
|
||||||
expect_cons_show("Only online/offline presence updates will appear in chat windows.");
|
expect_cons_show("Only online/offline presence updates will appear in chat windows.");
|
||||||
|
|
||||||
gboolean result = cmd_statuses(NULL, args, *help);
|
gboolean result = cmd_statuses(NULL, CMD_STATUSES, args);
|
||||||
|
|
||||||
char *setting = prefs_get_string(PREF_STATUSES_CHAT);
|
char *setting = prefs_get_string(PREF_STATUSES_CHAT);
|
||||||
assert_non_null(setting);
|
assert_non_null(setting);
|
||||||
assert_string_equal("online", setting);
|
assert_string_equal("online", setting);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_statuses_chat_sets_none(void **state)
|
void cmd_statuses_chat_sets_none(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "chat", "none", NULL };
|
gchar *args[] = { "chat", "none", NULL };
|
||||||
|
|
||||||
expect_cons_show("Presence updates will not appear in chat windows.");
|
expect_cons_show("Presence updates will not appear in chat windows.");
|
||||||
|
|
||||||
gboolean result = cmd_statuses(NULL, args, *help);
|
gboolean result = cmd_statuses(NULL, CMD_STATUSES, args);
|
||||||
|
|
||||||
char *setting = prefs_get_string(PREF_STATUSES_CHAT);
|
char *setting = prefs_get_string(PREF_STATUSES_CHAT);
|
||||||
assert_non_null(setting);
|
assert_non_null(setting);
|
||||||
assert_string_equal("none", setting);
|
assert_string_equal("none", setting);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_statuses_muc_sets_all(void **state)
|
void cmd_statuses_muc_sets_all(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "muc", "all", NULL };
|
gchar *args[] = { "muc", "all", NULL };
|
||||||
|
|
||||||
expect_cons_show("All presence updates will appear in chat room windows.");
|
expect_cons_show("All presence updates will appear in chat room windows.");
|
||||||
|
|
||||||
gboolean result = cmd_statuses(NULL, args, *help);
|
gboolean result = cmd_statuses(NULL, CMD_STATUSES, args);
|
||||||
|
|
||||||
char *setting = prefs_get_string(PREF_STATUSES_MUC);
|
char *setting = prefs_get_string(PREF_STATUSES_MUC);
|
||||||
assert_non_null(setting);
|
assert_non_null(setting);
|
||||||
assert_string_equal("all", setting);
|
assert_string_equal("all", setting);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_statuses_muc_sets_online(void **state)
|
void cmd_statuses_muc_sets_online(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "muc", "online", NULL };
|
gchar *args[] = { "muc", "online", NULL };
|
||||||
|
|
||||||
expect_cons_show("Only join/leave presence updates will appear in chat room windows.");
|
expect_cons_show("Only join/leave presence updates will appear in chat room windows.");
|
||||||
|
|
||||||
gboolean result = cmd_statuses(NULL, args, *help);
|
gboolean result = cmd_statuses(NULL, CMD_STATUSES, args);
|
||||||
|
|
||||||
char *setting = prefs_get_string(PREF_STATUSES_MUC);
|
char *setting = prefs_get_string(PREF_STATUSES_MUC);
|
||||||
assert_non_null(setting);
|
assert_non_null(setting);
|
||||||
assert_string_equal("online", setting);
|
assert_string_equal("online", setting);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_statuses_muc_sets_none(void **state)
|
void cmd_statuses_muc_sets_none(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { "muc", "none", NULL };
|
gchar *args[] = { "muc", "none", NULL };
|
||||||
|
|
||||||
expect_cons_show("Presence updates will not appear in chat room windows.");
|
expect_cons_show("Presence updates will not appear in chat room windows.");
|
||||||
|
|
||||||
gboolean result = cmd_statuses(NULL, args, *help);
|
gboolean result = cmd_statuses(NULL, CMD_STATUSES, args);
|
||||||
|
|
||||||
char *setting = prefs_get_string(PREF_STATUSES_MUC);
|
char *setting = prefs_get_string(PREF_STATUSES_MUC);
|
||||||
assert_non_null(setting);
|
assert_non_null(setting);
|
||||||
assert_string_equal("none", setting);
|
assert_string_equal("none", setting);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
@ -13,33 +13,28 @@
|
|||||||
|
|
||||||
#include "command/commands.h"
|
#include "command/commands.h"
|
||||||
|
|
||||||
|
#define CMD_SUB "/sub"
|
||||||
|
|
||||||
void cmd_sub_shows_message_when_not_connected(void **state)
|
void cmd_sub_shows_message_when_not_connected(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
gchar *args[] = { NULL };
|
gchar *args[] = { NULL };
|
||||||
|
|
||||||
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
|
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
|
||||||
|
|
||||||
expect_cons_show("You are currently not connected.");
|
expect_cons_show("You are currently not connected.");
|
||||||
|
|
||||||
gboolean result = cmd_sub(NULL, args, *help);
|
gboolean result = cmd_sub(NULL, CMD_SUB, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_sub_shows_usage_when_no_arg(void **state)
|
void cmd_sub_shows_usage_when_no_arg(void **state)
|
||||||
{
|
{
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
||||||
help->usage = "Some usage";
|
|
||||||
gchar *args[] = { NULL };
|
gchar *args[] = { NULL };
|
||||||
|
|
||||||
will_return(jabber_get_connection_status, JABBER_CONNECTED);
|
will_return(jabber_get_connection_status, JABBER_CONNECTED);
|
||||||
|
|
||||||
expect_cons_show("Usage: Some usage");
|
expect_string(cons_bad_cmd_usage, cmd, CMD_SUB);
|
||||||
|
|
||||||
gboolean result = cmd_sub(NULL, args, *help);
|
gboolean result = cmd_sub(NULL, CMD_SUB, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
|
||||||
}
|
}
|
||||||
|
@ -398,6 +398,12 @@ void cons_show_roster(GSList * list)
|
|||||||
check_expected(list);
|
check_expected(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cons_bad_cmd_usage(const char * const cmd)
|
||||||
|
{
|
||||||
|
check_expected(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
void cons_show_roster_group(const char * const group, GSList * list) {}
|
void cons_show_roster_group(const char * const group, GSList * list) {}
|
||||||
void cons_show_wins(void) {}
|
void cons_show_wins(void) {}
|
||||||
void cons_show_status(const char * const barejid) {}
|
void cons_show_status(const char * const barejid) {}
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
const UnitTest all_tests[] = {
|
const UnitTest all_tests[] = {
|
||||||
|
|
||||||
unit_test(replace_one_substr),
|
unit_test(replace_one_substr),
|
||||||
unit_test(replace_one_substr_beginning),
|
unit_test(replace_one_substr_beginning),
|
||||||
unit_test(replace_one_substr_end),
|
unit_test(replace_one_substr_end),
|
||||||
@ -214,6 +215,7 @@ int main(int argc, char* argv[]) {
|
|||||||
unit_test_setup_teardown(removes_chat_session,
|
unit_test_setup_teardown(removes_chat_session,
|
||||||
init_chat_sessions,
|
init_chat_sessions,
|
||||||
close_chat_sessions),
|
close_chat_sessions),
|
||||||
|
|
||||||
unit_test_setup_teardown(cmd_connect_shows_message_when_disconnecting,
|
unit_test_setup_teardown(cmd_connect_shows_message_when_disconnecting,
|
||||||
load_preferences,
|
load_preferences,
|
||||||
close_preferences),
|
close_preferences),
|
||||||
@ -238,15 +240,15 @@ int main(int argc, char* argv[]) {
|
|||||||
unit_test_setup_teardown(cmd_connect_asks_password_when_not_in_account,
|
unit_test_setup_teardown(cmd_connect_asks_password_when_not_in_account,
|
||||||
load_preferences,
|
load_preferences,
|
||||||
close_preferences),
|
close_preferences),
|
||||||
|
unit_test_setup_teardown(cmd_connect_shows_usage_when_no_server_value,
|
||||||
|
load_preferences,
|
||||||
|
close_preferences),
|
||||||
unit_test_setup_teardown(cmd_connect_shows_message_when_connecting_with_account,
|
unit_test_setup_teardown(cmd_connect_shows_message_when_connecting_with_account,
|
||||||
load_preferences,
|
load_preferences,
|
||||||
close_preferences),
|
close_preferences),
|
||||||
unit_test_setup_teardown(cmd_connect_connects_with_account,
|
unit_test_setup_teardown(cmd_connect_connects_with_account,
|
||||||
load_preferences,
|
load_preferences,
|
||||||
close_preferences),
|
close_preferences),
|
||||||
unit_test_setup_teardown(cmd_connect_shows_usage_when_no_server_value,
|
|
||||||
load_preferences,
|
|
||||||
close_preferences),
|
|
||||||
unit_test_setup_teardown(cmd_connect_shows_usage_when_server_no_port_value,
|
unit_test_setup_teardown(cmd_connect_shows_usage_when_server_no_port_value,
|
||||||
load_preferences,
|
load_preferences,
|
||||||
close_preferences),
|
close_preferences),
|
||||||
|
Loading…
Reference in New Issue
Block a user