Files
cproof/tests/unittests/test_cmd_presence.c
jabber.developer2 f9e184eda7
All checks were successful
CI Code / Check spelling (pull_request) Successful in 18s
CI Code / Check coding style (pull_request) Successful in 30s
CI Code / Linux (ubuntu) (pull_request) Successful in 4m51s
CI Code / Linux (debian) (pull_request) Successful in 6m59s
CI Code / Linux (arch) (pull_request) Successful in 10m12s
CI Code / Code Coverage (pull_request) Successful in 6m44s
revert: restore pre-upstream-merge baseline (tree of 3b673150b)
Roll the tree back to the pre-merge tip 3b673150b, undoing the upstream sync merge 72f4f186d (303 files) and the 13 post-merge commits layered on top of it.

Purpose: restore the last pre-sync baseline so the reported OMEMO/OTR encryption regressions can be reproduced against a known-good state and the upstream sync ruled in or out as the cause. Nothing is dropped from history; the merge and every post-merge commit remain reachable and can be cherry-picked back selectively.

Baseline:     3b673150b chore(chatlog): disable background message file logging (stage 1)

Undoes merge: 72f4f186d merge: sync upstream profanity-im/profanity
2026-06-29 12:17:01 +03:00

193 lines
4.9 KiB
C

#include "prof_cmocka.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include "config/preferences.h"
#include "ui/ui.h"
#include "ui/stub_ui.h"
#include "command/cmd_funcs.h"
#define CMD_PRESENCE "/presence"
void
cmd_presence_shows_usage_when_bad_subcmd(void** state)
{
gchar* args[] = { "badcmd", NULL };
expect_string(cons_bad_cmd_usage, cmd, CMD_PRESENCE);
gboolean result = cmd_presence(NULL, CMD_PRESENCE, args);
assert_true(result);
}
void
cmd_presence_shows_usage_when_bad_console_setting(void** state)
{
gchar* args[] = { "console", "badsetting", NULL };
expect_string(cons_bad_cmd_usage, cmd, CMD_PRESENCE);
gboolean result = cmd_presence(NULL, CMD_PRESENCE, args);
assert_true(result);
}
void
cmd_presence_shows_usage_when_bad_chat_setting(void** state)
{
gchar* args[] = { "chat", "badsetting", NULL };
expect_string(cons_bad_cmd_usage, cmd, CMD_PRESENCE);
gboolean result = cmd_presence(NULL, CMD_PRESENCE, args);
assert_true(result);
}
void
cmd_presence_shows_usage_when_bad_muc_setting(void** state)
{
gchar* args[] = { "muc", "badsetting", NULL };
expect_string(cons_bad_cmd_usage, cmd, CMD_PRESENCE);
gboolean result = cmd_presence(NULL, CMD_PRESENCE, args);
assert_true(result);
}
void
cmd_presence_console_sets_all(void** state)
{
gchar* args[] = { "console", "all", NULL };
expect_cons_show("All presence updates will appear in the console.");
gboolean result = cmd_presence(NULL, CMD_PRESENCE, args);
auto_gchar gchar* setting = prefs_get_string(PREF_STATUSES_CONSOLE);
assert_non_null(setting);
assert_string_equal("all", setting);
assert_true(result);
}
void
cmd_presence_console_sets_online(void** state)
{
gchar* args[] = { "console", "online", NULL };
expect_cons_show("Only online/offline presence updates will appear in the console.");
gboolean result = cmd_presence(NULL, CMD_PRESENCE, args);
auto_gchar gchar* setting = prefs_get_string(PREF_STATUSES_CONSOLE);
assert_non_null(setting);
assert_string_equal("online", setting);
assert_true(result);
}
void
cmd_presence_console_sets_none(void** state)
{
gchar* args[] = { "console", "none", NULL };
expect_cons_show("Presence updates will not appear in the console.");
gboolean result = cmd_presence(NULL, CMD_PRESENCE, args);
auto_gchar gchar* setting = prefs_get_string(PREF_STATUSES_CONSOLE);
assert_non_null(setting);
assert_string_equal("none", setting);
assert_true(result);
}
void
cmd_presence_chat_sets_all(void** state)
{
gchar* args[] = { "chat", "all", NULL };
expect_cons_show("All presence updates will appear in chat windows.");
gboolean result = cmd_presence(NULL, CMD_PRESENCE, args);
auto_gchar gchar* setting = prefs_get_string(PREF_STATUSES_CHAT);
assert_non_null(setting);
assert_string_equal("all", setting);
assert_true(result);
}
void
cmd_presence_chat_sets_online(void** state)
{
gchar* args[] = { "chat", "online", NULL };
expect_cons_show("Only online/offline presence updates will appear in chat windows.");
gboolean result = cmd_presence(NULL, CMD_PRESENCE, args);
auto_gchar gchar* setting = prefs_get_string(PREF_STATUSES_CHAT);
assert_non_null(setting);
assert_string_equal("online", setting);
assert_true(result);
}
void
cmd_presence_chat_sets_none(void** state)
{
gchar* args[] = { "chat", "none", NULL };
expect_cons_show("Presence updates will not appear in chat windows.");
gboolean result = cmd_presence(NULL, CMD_PRESENCE, args);
auto_gchar gchar* setting = prefs_get_string(PREF_STATUSES_CHAT);
assert_non_null(setting);
assert_string_equal("none", setting);
assert_true(result);
}
void
cmd_presence_room_sets_all(void** state)
{
gchar* args[] = { "room", "all", NULL };
expect_cons_show("All presence updates will appear in chat room windows.");
gboolean result = cmd_presence(NULL, CMD_PRESENCE, args);
auto_gchar gchar* setting = prefs_get_string(PREF_STATUSES_MUC);
assert_non_null(setting);
assert_string_equal("all", setting);
assert_true(result);
}
void
cmd_presence_room_sets_online(void** state)
{
gchar* args[] = { "room", "online", NULL };
expect_cons_show("Only join/leave presence updates will appear in chat room windows.");
gboolean result = cmd_presence(NULL, CMD_PRESENCE, args);
auto_gchar gchar* setting = prefs_get_string(PREF_STATUSES_MUC);
assert_non_null(setting);
assert_string_equal("online", setting);
assert_true(result);
}
void
cmd_presence_room_sets_none(void** state)
{
gchar* args[] = { "room", "none", NULL };
expect_cons_show("Presence updates will not appear in chat room windows.");
gboolean result = cmd_presence(NULL, CMD_PRESENCE, args);
auto_gchar gchar* setting = prefs_get_string(PREF_STATUSES_MUC);
assert_non_null(setting);
assert_string_equal("none", setting);
assert_true(result);
}