2014-01-18 20:25:04 -05:00
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <setjmp.h>
|
|
|
|
#include <cmocka.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <glib.h>
|
|
|
|
|
2014-01-19 11:17:34 -05:00
|
|
|
#include "config/preferences.h"
|
|
|
|
|
2014-01-18 20:25:04 -05:00
|
|
|
#include "ui/ui.h"
|
2014-12-24 19:02:18 -05:00
|
|
|
#include "ui/stub_ui.h"
|
2014-01-18 20:25:04 -05:00
|
|
|
|
|
|
|
#include "command/commands.h"
|
|
|
|
|
|
|
|
void cmd_statuses_shows_usage_when_bad_subcmd(void **state)
|
|
|
|
{
|
|
|
|
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
|
|
help->usage = "some usage";
|
|
|
|
gchar *args[] = { "badcmd", NULL };
|
|
|
|
|
|
|
|
expect_cons_show("Usage: some usage");
|
|
|
|
|
2015-06-16 19:15:28 -04:00
|
|
|
gboolean result = cmd_statuses(NULL, args, *help);
|
2014-01-18 20:25:04 -05:00
|
|
|
assert_true(result);
|
|
|
|
|
|
|
|
free(help);
|
|
|
|
}
|
|
|
|
|
|
|
|
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 };
|
|
|
|
|
|
|
|
expect_cons_show("Usage: some usage");
|
|
|
|
|
2015-06-16 19:15:28 -04:00
|
|
|
gboolean result = cmd_statuses(NULL, args, *help);
|
2014-01-18 20:25:04 -05:00
|
|
|
assert_true(result);
|
|
|
|
|
|
|
|
free(help);
|
|
|
|
}
|
|
|
|
|
|
|
|
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 };
|
|
|
|
|
|
|
|
expect_cons_show("Usage: some usage");
|
|
|
|
|
2015-06-16 19:15:28 -04:00
|
|
|
gboolean result = cmd_statuses(NULL, args, *help);
|
2014-01-18 20:25:04 -05:00
|
|
|
assert_true(result);
|
|
|
|
|
|
|
|
free(help);
|
|
|
|
}
|
|
|
|
|
|
|
|
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 };
|
|
|
|
|
|
|
|
expect_cons_show("Usage: some usage");
|
|
|
|
|
2015-06-16 19:15:28 -04:00
|
|
|
gboolean result = cmd_statuses(NULL, args, *help);
|
2014-01-18 20:25:04 -05:00
|
|
|
assert_true(result);
|
|
|
|
|
|
|
|
free(help);
|
|
|
|
}
|
2014-01-19 11:17:34 -05:00
|
|
|
|
|
|
|
void cmd_statuses_console_sets_all(void **state)
|
|
|
|
{
|
|
|
|
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
|
|
gchar *args[] = { "console", "all", NULL };
|
|
|
|
|
|
|
|
expect_cons_show("All presence updates will appear in the console.");
|
|
|
|
|
2015-06-16 19:15:28 -04:00
|
|
|
gboolean result = cmd_statuses(NULL, args, *help);
|
2014-01-19 11:17:34 -05:00
|
|
|
|
|
|
|
char *setting = prefs_get_string(PREF_STATUSES_CONSOLE);
|
|
|
|
assert_non_null(setting);
|
|
|
|
assert_string_equal("all", setting);
|
|
|
|
assert_true(result);
|
|
|
|
|
|
|
|
free(help);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmd_statuses_console_sets_online(void **state)
|
|
|
|
{
|
|
|
|
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
|
|
gchar *args[] = { "console", "online", NULL };
|
|
|
|
|
|
|
|
expect_cons_show("Only online/offline presence updates will appear in the console.");
|
|
|
|
|
2015-06-16 19:15:28 -04:00
|
|
|
gboolean result = cmd_statuses(NULL, args, *help);
|
2014-01-19 11:17:34 -05:00
|
|
|
|
|
|
|
char *setting = prefs_get_string(PREF_STATUSES_CONSOLE);
|
|
|
|
assert_non_null(setting);
|
|
|
|
assert_string_equal("online", setting);
|
|
|
|
assert_true(result);
|
|
|
|
|
|
|
|
free(help);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmd_statuses_console_sets_none(void **state)
|
|
|
|
{
|
|
|
|
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
|
|
gchar *args[] = { "console", "none", NULL };
|
|
|
|
|
|
|
|
expect_cons_show("Presence updates will not appear in the console.");
|
|
|
|
|
2015-06-16 19:15:28 -04:00
|
|
|
gboolean result = cmd_statuses(NULL, args, *help);
|
2014-01-19 11:17:34 -05:00
|
|
|
|
|
|
|
char *setting = prefs_get_string(PREF_STATUSES_CONSOLE);
|
|
|
|
assert_non_null(setting);
|
|
|
|
assert_string_equal("none", setting);
|
|
|
|
assert_true(result);
|
|
|
|
|
|
|
|
free(help);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmd_statuses_chat_sets_all(void **state)
|
|
|
|
{
|
|
|
|
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
|
|
gchar *args[] = { "chat", "all", NULL };
|
|
|
|
|
|
|
|
expect_cons_show("All presence updates will appear in chat windows.");
|
|
|
|
|
2015-06-16 19:15:28 -04:00
|
|
|
gboolean result = cmd_statuses(NULL, args, *help);
|
2014-01-19 11:17:34 -05:00
|
|
|
|
|
|
|
char *setting = prefs_get_string(PREF_STATUSES_CHAT);
|
|
|
|
assert_non_null(setting);
|
|
|
|
assert_string_equal("all", setting);
|
|
|
|
assert_true(result);
|
|
|
|
|
|
|
|
free(help);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmd_statuses_chat_sets_online(void **state)
|
|
|
|
{
|
|
|
|
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
|
|
gchar *args[] = { "chat", "online", NULL };
|
|
|
|
|
|
|
|
expect_cons_show("Only online/offline presence updates will appear in chat windows.");
|
|
|
|
|
2015-06-16 19:15:28 -04:00
|
|
|
gboolean result = cmd_statuses(NULL, args, *help);
|
2014-01-19 11:17:34 -05:00
|
|
|
|
|
|
|
char *setting = prefs_get_string(PREF_STATUSES_CHAT);
|
|
|
|
assert_non_null(setting);
|
|
|
|
assert_string_equal("online", setting);
|
|
|
|
assert_true(result);
|
|
|
|
|
|
|
|
free(help);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmd_statuses_chat_sets_none(void **state)
|
|
|
|
{
|
|
|
|
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
|
|
gchar *args[] = { "chat", "none", NULL };
|
|
|
|
|
|
|
|
expect_cons_show("Presence updates will not appear in chat windows.");
|
|
|
|
|
2015-06-16 19:15:28 -04:00
|
|
|
gboolean result = cmd_statuses(NULL, args, *help);
|
2014-01-19 11:17:34 -05:00
|
|
|
|
|
|
|
char *setting = prefs_get_string(PREF_STATUSES_CHAT);
|
|
|
|
assert_non_null(setting);
|
|
|
|
assert_string_equal("none", setting);
|
|
|
|
assert_true(result);
|
|
|
|
|
|
|
|
free(help);
|
|
|
|
}
|
|
|
|
|
2014-03-15 18:25:15 -04:00
|
|
|
void cmd_statuses_muc_sets_all(void **state)
|
2014-01-19 11:17:34 -05:00
|
|
|
{
|
|
|
|
CommandHelp *help = malloc(sizeof(CommandHelp));
|
2014-03-15 18:25:15 -04:00
|
|
|
gchar *args[] = { "muc", "all", NULL };
|
2014-01-19 11:17:34 -05:00
|
|
|
|
2014-03-15 18:25:15 -04:00
|
|
|
expect_cons_show("All presence updates will appear in chat room windows.");
|
2014-01-19 11:17:34 -05:00
|
|
|
|
2015-06-16 19:15:28 -04:00
|
|
|
gboolean result = cmd_statuses(NULL, args, *help);
|
2014-01-19 11:17:34 -05:00
|
|
|
|
2014-03-15 18:25:15 -04:00
|
|
|
char *setting = prefs_get_string(PREF_STATUSES_MUC);
|
2014-01-19 11:17:34 -05:00
|
|
|
assert_non_null(setting);
|
2014-03-15 18:25:15 -04:00
|
|
|
assert_string_equal("all", setting);
|
2014-01-19 11:17:34 -05:00
|
|
|
assert_true(result);
|
|
|
|
|
|
|
|
free(help);
|
|
|
|
}
|
|
|
|
|
2014-03-15 18:25:15 -04:00
|
|
|
void cmd_statuses_muc_sets_online(void **state)
|
2014-01-19 11:17:34 -05:00
|
|
|
{
|
|
|
|
CommandHelp *help = malloc(sizeof(CommandHelp));
|
2014-03-15 18:25:15 -04:00
|
|
|
gchar *args[] = { "muc", "online", NULL };
|
2014-01-19 11:17:34 -05:00
|
|
|
|
2014-03-15 18:25:15 -04:00
|
|
|
expect_cons_show("Only join/leave presence updates will appear in chat room windows.");
|
2014-01-19 11:17:34 -05:00
|
|
|
|
2015-06-16 19:15:28 -04:00
|
|
|
gboolean result = cmd_statuses(NULL, args, *help);
|
2014-01-19 11:17:34 -05:00
|
|
|
|
2014-03-15 18:25:15 -04:00
|
|
|
char *setting = prefs_get_string(PREF_STATUSES_MUC);
|
|
|
|
assert_non_null(setting);
|
|
|
|
assert_string_equal("online", setting);
|
|
|
|
assert_true(result);
|
|
|
|
|
|
|
|
free(help);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmd_statuses_muc_sets_none(void **state)
|
|
|
|
{
|
|
|
|
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
|
|
gchar *args[] = { "muc", "none", NULL };
|
|
|
|
|
|
|
|
expect_cons_show("Presence updates will not appear in chat room windows.");
|
|
|
|
|
2015-06-16 19:15:28 -04:00
|
|
|
gboolean result = cmd_statuses(NULL, args, *help);
|
2014-03-15 18:25:15 -04:00
|
|
|
|
|
|
|
char *setting = prefs_get_string(PREF_STATUSES_MUC);
|
|
|
|
assert_non_null(setting);
|
|
|
|
assert_string_equal("none", setting);
|
2014-01-19 11:17:34 -05:00
|
|
|
assert_true(result);
|
|
|
|
|
|
|
|
free(help);
|
|
|
|
}
|