2014-01-18 20:25:04 -05:00
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stddef.h>
|
2020-07-07 07:53:30 -04:00
|
|
|
#include <setjmp.h>
|
|
|
|
#include <cmocka.h>
|
2014-01-18 20:25:04 -05:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2020-07-07 07:53:30 -04:00
|
|
|
#include <glib.h>
|
2014-01-18 20:25:04 -05:00
|
|
|
|
2014-01-19 11:17:34 -05:00
|
|
|
#include "config/preferences.h"
|
|
|
|
|
2014-01-18 20:25:04 -05:00
|
|
|
#include "ui/ui.h"
|
2020-07-07 07:53:30 -04:00
|
|
|
#include "ui/stub_ui.h"
|
2014-01-18 20:25:04 -05:00
|
|
|
|
2016-05-22 18:59:52 -04:00
|
|
|
#include "command/cmd_funcs.h"
|
2014-01-18 20:25:04 -05:00
|
|
|
|
2016-05-31 18:21:19 -04:00
|
|
|
#define CMD_PRESENCE "/presence"
|
2015-07-26 19:04:48 -04:00
|
|
|
|
2020-07-07 08:18:57 -04:00
|
|
|
void
|
|
|
|
cmd_presence_shows_usage_when_bad_subcmd(void** state)
|
2014-01-18 20:25:04 -05:00
|
|
|
{
|
2020-07-07 08:18:57 -04:00
|
|
|
gchar* args[] = { "badcmd", NULL };
|
2014-01-18 20:25:04 -05:00
|
|
|
|
2016-05-31 18:21:19 -04:00
|
|
|
expect_string(cons_bad_cmd_usage, cmd, CMD_PRESENCE);
|
2014-01-18 20:25:04 -05:00
|
|
|
|
2016-05-31 18:21:19 -04:00
|
|
|
gboolean result = cmd_presence(NULL, CMD_PRESENCE, args);
|
2014-01-18 20:25:04 -05:00
|
|
|
assert_true(result);
|
|
|
|
}
|
|
|
|
|
2020-07-07 08:18:57 -04:00
|
|
|
void
|
|
|
|
cmd_presence_shows_usage_when_bad_console_setting(void** state)
|
2014-01-18 20:25:04 -05:00
|
|
|
{
|
2020-07-07 08:18:57 -04:00
|
|
|
gchar* args[] = { "console", "badsetting", NULL };
|
2014-01-18 20:25:04 -05:00
|
|
|
|
2016-05-31 18:21:19 -04:00
|
|
|
expect_string(cons_bad_cmd_usage, cmd, CMD_PRESENCE);
|
2014-01-18 20:25:04 -05:00
|
|
|
|
2016-05-31 18:21:19 -04:00
|
|
|
gboolean result = cmd_presence(NULL, CMD_PRESENCE, args);
|
2014-01-18 20:25:04 -05:00
|
|
|
assert_true(result);
|
|
|
|
}
|
|
|
|
|
2020-07-07 08:18:57 -04:00
|
|
|
void
|
|
|
|
cmd_presence_shows_usage_when_bad_chat_setting(void** state)
|
2014-01-18 20:25:04 -05:00
|
|
|
{
|
2020-07-07 08:18:57 -04:00
|
|
|
gchar* args[] = { "chat", "badsetting", NULL };
|
2014-01-18 20:25:04 -05:00
|
|
|
|
2016-05-31 18:21:19 -04:00
|
|
|
expect_string(cons_bad_cmd_usage, cmd, CMD_PRESENCE);
|
2014-01-18 20:25:04 -05:00
|
|
|
|
2016-05-31 18:21:19 -04:00
|
|
|
gboolean result = cmd_presence(NULL, CMD_PRESENCE, args);
|
2014-01-18 20:25:04 -05:00
|
|
|
assert_true(result);
|
|
|
|
}
|
|
|
|
|
2020-07-07 08:18:57 -04:00
|
|
|
void
|
|
|
|
cmd_presence_shows_usage_when_bad_muc_setting(void** state)
|
2014-01-18 20:25:04 -05:00
|
|
|
{
|
2020-07-07 08:18:57 -04:00
|
|
|
gchar* args[] = { "muc", "badsetting", NULL };
|
2014-01-18 20:25:04 -05:00
|
|
|
|
2016-05-31 18:21:19 -04:00
|
|
|
expect_string(cons_bad_cmd_usage, cmd, CMD_PRESENCE);
|
2014-01-18 20:25:04 -05:00
|
|
|
|
2016-05-31 18:21:19 -04:00
|
|
|
gboolean result = cmd_presence(NULL, CMD_PRESENCE, args);
|
2014-01-18 20:25:04 -05:00
|
|
|
assert_true(result);
|
|
|
|
}
|
2014-01-19 11:17:34 -05:00
|
|
|
|
2020-07-07 08:18:57 -04:00
|
|
|
void
|
|
|
|
cmd_presence_console_sets_all(void** state)
|
2014-01-19 11:17:34 -05:00
|
|
|
{
|
2020-07-07 08:18:57 -04:00
|
|
|
gchar* args[] = { "console", "all", NULL };
|
2014-01-19 11:17:34 -05:00
|
|
|
|
|
|
|
expect_cons_show("All presence updates will appear in the console.");
|
|
|
|
|
2016-05-31 18:21:19 -04:00
|
|
|
gboolean result = cmd_presence(NULL, CMD_PRESENCE, args);
|
2014-01-19 11:17:34 -05:00
|
|
|
|
2023-06-13 16:01:08 -04:00
|
|
|
auto_gchar gchar* setting = prefs_get_string(PREF_STATUSES_CONSOLE);
|
2014-01-19 11:17:34 -05:00
|
|
|
assert_non_null(setting);
|
|
|
|
assert_string_equal("all", setting);
|
|
|
|
assert_true(result);
|
|
|
|
}
|
|
|
|
|
2020-07-07 08:18:57 -04:00
|
|
|
void
|
|
|
|
cmd_presence_console_sets_online(void** state)
|
2014-01-19 11:17:34 -05:00
|
|
|
{
|
2020-07-07 08:18:57 -04:00
|
|
|
gchar* args[] = { "console", "online", NULL };
|
2014-01-19 11:17:34 -05:00
|
|
|
|
|
|
|
expect_cons_show("Only online/offline presence updates will appear in the console.");
|
|
|
|
|
2016-05-31 18:21:19 -04:00
|
|
|
gboolean result = cmd_presence(NULL, CMD_PRESENCE, args);
|
2014-01-19 11:17:34 -05:00
|
|
|
|
2023-06-13 16:01:08 -04:00
|
|
|
auto_gchar gchar* setting = prefs_get_string(PREF_STATUSES_CONSOLE);
|
2014-01-19 11:17:34 -05:00
|
|
|
assert_non_null(setting);
|
|
|
|
assert_string_equal("online", setting);
|
|
|
|
assert_true(result);
|
|
|
|
}
|
|
|
|
|
2020-07-07 08:18:57 -04:00
|
|
|
void
|
|
|
|
cmd_presence_console_sets_none(void** state)
|
2014-01-19 11:17:34 -05:00
|
|
|
{
|
2020-07-07 08:18:57 -04:00
|
|
|
gchar* args[] = { "console", "none", NULL };
|
2014-01-19 11:17:34 -05:00
|
|
|
|
|
|
|
expect_cons_show("Presence updates will not appear in the console.");
|
|
|
|
|
2016-05-31 18:21:19 -04:00
|
|
|
gboolean result = cmd_presence(NULL, CMD_PRESENCE, args);
|
2014-01-19 11:17:34 -05:00
|
|
|
|
2023-06-13 16:01:08 -04:00
|
|
|
auto_gchar gchar* setting = prefs_get_string(PREF_STATUSES_CONSOLE);
|
2014-01-19 11:17:34 -05:00
|
|
|
assert_non_null(setting);
|
|
|
|
assert_string_equal("none", setting);
|
|
|
|
assert_true(result);
|
|
|
|
}
|
|
|
|
|
2020-07-07 08:18:57 -04:00
|
|
|
void
|
|
|
|
cmd_presence_chat_sets_all(void** state)
|
2014-01-19 11:17:34 -05:00
|
|
|
{
|
2020-07-07 08:18:57 -04:00
|
|
|
gchar* args[] = { "chat", "all", NULL };
|
2014-01-19 11:17:34 -05:00
|
|
|
|
|
|
|
expect_cons_show("All presence updates will appear in chat windows.");
|
|
|
|
|
2016-05-31 18:21:19 -04:00
|
|
|
gboolean result = cmd_presence(NULL, CMD_PRESENCE, args);
|
2014-01-19 11:17:34 -05:00
|
|
|
|
2023-06-13 16:01:08 -04:00
|
|
|
auto_gchar gchar* setting = prefs_get_string(PREF_STATUSES_CHAT);
|
2014-01-19 11:17:34 -05:00
|
|
|
assert_non_null(setting);
|
|
|
|
assert_string_equal("all", setting);
|
|
|
|
assert_true(result);
|
|
|
|
}
|
|
|
|
|
2020-07-07 08:18:57 -04:00
|
|
|
void
|
|
|
|
cmd_presence_chat_sets_online(void** state)
|
2014-01-19 11:17:34 -05:00
|
|
|
{
|
2020-07-07 08:18:57 -04:00
|
|
|
gchar* args[] = { "chat", "online", NULL };
|
2014-01-19 11:17:34 -05:00
|
|
|
|
|
|
|
expect_cons_show("Only online/offline presence updates will appear in chat windows.");
|
|
|
|
|
2016-05-31 18:21:19 -04:00
|
|
|
gboolean result = cmd_presence(NULL, CMD_PRESENCE, args);
|
2014-01-19 11:17:34 -05:00
|
|
|
|
2023-06-13 16:01:08 -04:00
|
|
|
auto_gchar gchar* setting = prefs_get_string(PREF_STATUSES_CHAT);
|
2014-01-19 11:17:34 -05:00
|
|
|
assert_non_null(setting);
|
|
|
|
assert_string_equal("online", setting);
|
|
|
|
assert_true(result);
|
|
|
|
}
|
|
|
|
|
2020-07-07 08:18:57 -04:00
|
|
|
void
|
|
|
|
cmd_presence_chat_sets_none(void** state)
|
2014-01-19 11:17:34 -05:00
|
|
|
{
|
2020-07-07 08:18:57 -04:00
|
|
|
gchar* args[] = { "chat", "none", NULL };
|
2014-01-19 11:17:34 -05:00
|
|
|
|
|
|
|
expect_cons_show("Presence updates will not appear in chat windows.");
|
|
|
|
|
2016-05-31 18:21:19 -04:00
|
|
|
gboolean result = cmd_presence(NULL, CMD_PRESENCE, args);
|
2014-01-19 11:17:34 -05:00
|
|
|
|
2023-06-13 16:01:08 -04:00
|
|
|
auto_gchar gchar* setting = prefs_get_string(PREF_STATUSES_CHAT);
|
2014-01-19 11:17:34 -05:00
|
|
|
assert_non_null(setting);
|
|
|
|
assert_string_equal("none", setting);
|
|
|
|
assert_true(result);
|
|
|
|
}
|
|
|
|
|
2020-07-07 08:18:57 -04:00
|
|
|
void
|
|
|
|
cmd_presence_room_sets_all(void** state)
|
2014-01-19 11:17:34 -05:00
|
|
|
{
|
2020-07-07 08:18:57 -04:00
|
|
|
gchar* args[] = { "room", "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
|
|
|
|
2016-05-31 18:21:19 -04:00
|
|
|
gboolean result = cmd_presence(NULL, CMD_PRESENCE, args);
|
2014-01-19 11:17:34 -05:00
|
|
|
|
2023-06-13 16:01:08 -04:00
|
|
|
auto_gchar gchar* 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);
|
|
|
|
}
|
|
|
|
|
2020-07-07 08:18:57 -04:00
|
|
|
void
|
|
|
|
cmd_presence_room_sets_online(void** state)
|
2014-01-19 11:17:34 -05:00
|
|
|
{
|
2020-07-07 08:18:57 -04:00
|
|
|
gchar* args[] = { "room", "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
|
|
|
|
2016-05-31 18:21:19 -04:00
|
|
|
gboolean result = cmd_presence(NULL, CMD_PRESENCE, args);
|
2014-01-19 11:17:34 -05:00
|
|
|
|
2023-06-13 16:01:08 -04:00
|
|
|
auto_gchar gchar* setting = prefs_get_string(PREF_STATUSES_MUC);
|
2014-03-15 18:25:15 -04:00
|
|
|
assert_non_null(setting);
|
|
|
|
assert_string_equal("online", setting);
|
|
|
|
assert_true(result);
|
|
|
|
}
|
|
|
|
|
2020-07-07 08:18:57 -04:00
|
|
|
void
|
|
|
|
cmd_presence_room_sets_none(void** state)
|
2014-03-15 18:25:15 -04:00
|
|
|
{
|
2020-07-07 08:18:57 -04:00
|
|
|
gchar* args[] = { "room", "none", NULL };
|
2014-03-15 18:25:15 -04:00
|
|
|
|
|
|
|
expect_cons_show("Presence updates will not appear in chat room windows.");
|
|
|
|
|
2016-05-31 18:21:19 -04:00
|
|
|
gboolean result = cmd_presence(NULL, CMD_PRESENCE, args);
|
2014-03-15 18:25:15 -04:00
|
|
|
|
2023-06-13 16:01:08 -04:00
|
|
|
auto_gchar gchar* setting = prefs_get_string(PREF_STATUSES_MUC);
|
2014-03-15 18:25:15 -04:00
|
|
|
assert_non_null(setting);
|
|
|
|
assert_string_equal("none", setting);
|
2014-01-19 11:17:34 -05:00
|
|
|
assert_true(result);
|
|
|
|
}
|