tests: Apply coding style to unit tests
This commit is contained in:
@@ -22,7 +22,9 @@
|
||||
|
||||
#define PROF_FUNC_TEST(test) cmocka_unit_test_setup_teardown(test, init_prof_test, close_prof_test)
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
|
||||
const struct CMUnitTest all_tests[] = {
|
||||
|
||||
|
||||
@@ -14,13 +14,13 @@
|
||||
|
||||
#include "proftest.h"
|
||||
|
||||
char *config_orig;
|
||||
char *data_orig;
|
||||
char* config_orig;
|
||||
char* data_orig;
|
||||
|
||||
int fd = 0;
|
||||
|
||||
gboolean
|
||||
_create_dir(const char *name)
|
||||
_create_dir(const char* name)
|
||||
{
|
||||
struct stat sb;
|
||||
|
||||
@@ -38,14 +38,14 @@ _create_dir(const char *name)
|
||||
}
|
||||
|
||||
gboolean
|
||||
_mkdir_recursive(const char *dir)
|
||||
_mkdir_recursive(const char* dir)
|
||||
{
|
||||
int i;
|
||||
gboolean result = TRUE;
|
||||
|
||||
for (i = 1; i <= strlen(dir); i++) {
|
||||
if (dir[i] == '/' || dir[i] == '\0') {
|
||||
gchar *next_dir = g_strndup(dir, i);
|
||||
gchar* next_dir = g_strndup(dir, i);
|
||||
result = _create_dir(next_dir);
|
||||
g_free(next_dir);
|
||||
if (!result) {
|
||||
@@ -60,7 +60,7 @@ _mkdir_recursive(const char *dir)
|
||||
void
|
||||
_create_config_dir(void)
|
||||
{
|
||||
GString *profanity_dir = g_string_new(XDG_CONFIG_HOME);
|
||||
GString* profanity_dir = g_string_new(XDG_CONFIG_HOME);
|
||||
g_string_append(profanity_dir, "/profanity");
|
||||
|
||||
if (!_mkdir_recursive(profanity_dir->str)) {
|
||||
@@ -73,7 +73,7 @@ _create_config_dir(void)
|
||||
void
|
||||
_create_data_dir(void)
|
||||
{
|
||||
GString *profanity_dir = g_string_new(XDG_DATA_HOME);
|
||||
GString* profanity_dir = g_string_new(XDG_DATA_HOME);
|
||||
g_string_append(profanity_dir, "/profanity");
|
||||
|
||||
if (!_mkdir_recursive(profanity_dir->str)) {
|
||||
@@ -86,7 +86,7 @@ _create_data_dir(void)
|
||||
void
|
||||
_create_chatlogs_dir(void)
|
||||
{
|
||||
GString *chatlogs_dir = g_string_new(XDG_DATA_HOME);
|
||||
GString* chatlogs_dir = g_string_new(XDG_DATA_HOME);
|
||||
g_string_append(chatlogs_dir, "/profanity/chatlogs");
|
||||
|
||||
if (!_mkdir_recursive(chatlogs_dir->str)) {
|
||||
@@ -99,7 +99,7 @@ _create_chatlogs_dir(void)
|
||||
void
|
||||
_create_logs_dir(void)
|
||||
{
|
||||
GString *logs_dir = g_string_new(XDG_DATA_HOME);
|
||||
GString* logs_dir = g_string_new(XDG_DATA_HOME);
|
||||
g_string_append(logs_dir, "/profanity/logs");
|
||||
|
||||
if (!_mkdir_recursive(logs_dir->str)) {
|
||||
@@ -124,21 +124,21 @@ prof_start(void)
|
||||
// helper script sets terminal columns, avoids assertions failing
|
||||
// based on the test runner terminal size
|
||||
fd = exp_spawnl("sh",
|
||||
"sh",
|
||||
"-c",
|
||||
"./tests/functionaltests/start_profanity.sh",
|
||||
NULL);
|
||||
FILE *fp = fdopen(fd, "r+");
|
||||
"sh",
|
||||
"-c",
|
||||
"./tests/functionaltests/start_profanity.sh",
|
||||
NULL);
|
||||
FILE* fp = fdopen(fd, "r+");
|
||||
|
||||
assert_true(fp != NULL);
|
||||
|
||||
setbuf(fp, (char *)0);
|
||||
setbuf(fp, (char*)0);
|
||||
}
|
||||
|
||||
int
|
||||
init_prof_test(void **state)
|
||||
init_prof_test(void** state)
|
||||
{
|
||||
if (stbbr_start(STBBR_LOGDEBUG ,5230, 0) != 0) {
|
||||
if (stbbr_start(STBBR_LOGDEBUG, 5230, 0) != 0) {
|
||||
assert_true(FALSE);
|
||||
return -1;
|
||||
}
|
||||
@@ -191,7 +191,7 @@ init_prof_test(void **state)
|
||||
}
|
||||
|
||||
int
|
||||
close_prof_test(void **state)
|
||||
close_prof_test(void** state)
|
||||
{
|
||||
prof_input("/quit");
|
||||
waitpid(exp_pid, NULL, 0);
|
||||
@@ -205,48 +205,45 @@ close_prof_test(void **state)
|
||||
}
|
||||
|
||||
void
|
||||
prof_input(const char *input)
|
||||
prof_input(const char* input)
|
||||
{
|
||||
GString *inp_str = g_string_new(input);
|
||||
GString* inp_str = g_string_new(input);
|
||||
g_string_append(inp_str, "\r");
|
||||
write(fd, inp_str->str, inp_str->len);
|
||||
g_string_free(inp_str, TRUE);
|
||||
}
|
||||
|
||||
int
|
||||
prof_output_exact(const char *text)
|
||||
prof_output_exact(const char* text)
|
||||
{
|
||||
return (1 == exp_expectl(fd, exp_exact, text, 1, exp_end));
|
||||
}
|
||||
|
||||
int
|
||||
prof_output_regex(const char *text)
|
||||
prof_output_regex(const char* text)
|
||||
{
|
||||
return (1 == exp_expectl(fd, exp_regexp, text, 1, exp_end));
|
||||
}
|
||||
|
||||
void
|
||||
prof_connect_with_roster(const char *roster)
|
||||
prof_connect_with_roster(const char* roster)
|
||||
{
|
||||
GString *roster_str = g_string_new(
|
||||
GString* roster_str = g_string_new(
|
||||
"<iq type='result' to='stabber@localhost/profanity'>"
|
||||
"<query xmlns='jabber:iq:roster' ver='362'>"
|
||||
);
|
||||
"<query xmlns='jabber:iq:roster' ver='362'>");
|
||||
g_string_append(roster_str, roster);
|
||||
g_string_append(roster_str,
|
||||
"</query>"
|
||||
"</iq>"
|
||||
);
|
||||
"</query>"
|
||||
"</iq>");
|
||||
|
||||
stbbr_for_query("jabber:iq:roster", roster_str->str);
|
||||
g_string_free(roster_str, TRUE);
|
||||
|
||||
stbbr_for_id("prof_presence_1",
|
||||
"<presence id='prof_presence_1' lang='en' to='stabber@localhost/profanity' from='stabber@localhost/profanity'>"
|
||||
"<priority>0</priority>"
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io/' ver='f8mrtdyAmhnj8Ca+630bThSL718='/>"
|
||||
"</presence>"
|
||||
);
|
||||
"<presence id='prof_presence_1' lang='en' to='stabber@localhost/profanity' from='stabber@localhost/profanity'>"
|
||||
"<priority>0</priority>"
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io/' ver='f8mrtdyAmhnj8Ca+630bThSL718='/>"
|
||||
"</presence>");
|
||||
|
||||
prof_input("/connect stabber@localhost server 127.0.0.1 port 5230 tls allow");
|
||||
prof_input("password");
|
||||
@@ -275,6 +272,5 @@ prof_connect(void)
|
||||
{
|
||||
prof_connect_with_roster(
|
||||
"<item jid='buddy1@localhost' subscription='both' name='Buddy1'/>"
|
||||
"<item jid='buddy2@localhost' subscription='both' name='Buddy2'/>"
|
||||
);
|
||||
"<item jid='buddy2@localhost' subscription='both' name='Buddy2'/>");
|
||||
}
|
||||
|
||||
@@ -4,16 +4,16 @@
|
||||
#define XDG_CONFIG_HOME "./tests/functionaltests/files/xdg_config_home"
|
||||
#define XDG_DATA_HOME "./tests/functionaltests/files/xdg_data_home"
|
||||
|
||||
int init_prof_test(void **state);
|
||||
int close_prof_test(void **state);
|
||||
int init_prof_test(void** state);
|
||||
int close_prof_test(void** state);
|
||||
|
||||
void prof_start(void);
|
||||
void prof_connect(void);
|
||||
void prof_connect_with_roster(const char *roster);
|
||||
void prof_input(const char *input);
|
||||
void prof_connect_with_roster(const char* roster);
|
||||
void prof_input(const char* input);
|
||||
|
||||
int prof_output_exact(const char *text);
|
||||
int prof_output_regex(const char *text);
|
||||
int prof_output_exact(const char* text);
|
||||
int prof_output_regex(const char* text);
|
||||
|
||||
void prof_timeout(int timeout);
|
||||
void prof_timeout_reset(void);
|
||||
|
||||
@@ -9,31 +9,29 @@
|
||||
#include "proftest.h"
|
||||
|
||||
void
|
||||
send_enable_carbons(void **state)
|
||||
send_enable_carbons(void** state)
|
||||
{
|
||||
prof_connect();
|
||||
|
||||
prof_input("/carbons on");
|
||||
|
||||
assert_true(stbbr_received(
|
||||
"<iq id='*' type='set'><enable xmlns='urn:xmpp:carbons:2'/></iq>"
|
||||
));
|
||||
"<iq id='*' type='set'><enable xmlns='urn:xmpp:carbons:2'/></iq>"));
|
||||
}
|
||||
|
||||
void
|
||||
connect_with_carbons_enabled(void **state)
|
||||
connect_with_carbons_enabled(void** state)
|
||||
{
|
||||
prof_input("/carbons on");
|
||||
|
||||
prof_connect();
|
||||
|
||||
assert_true(stbbr_received(
|
||||
"<iq id='*' type='set'><enable xmlns='urn:xmpp:carbons:2'/></iq>"
|
||||
));
|
||||
"<iq id='*' type='set'><enable xmlns='urn:xmpp:carbons:2'/></iq>"));
|
||||
}
|
||||
|
||||
void
|
||||
send_disable_carbons(void **state)
|
||||
send_disable_carbons(void** state)
|
||||
{
|
||||
prof_input("/carbons on");
|
||||
|
||||
@@ -42,106 +40,96 @@ send_disable_carbons(void **state)
|
||||
prof_input("/carbons off");
|
||||
|
||||
assert_true(stbbr_received(
|
||||
"<iq id='*' type='set'><disable xmlns='urn:xmpp:carbons:2'/></iq>"
|
||||
));
|
||||
"<iq id='*' type='set'><disable xmlns='urn:xmpp:carbons:2'/></iq>"));
|
||||
}
|
||||
|
||||
void
|
||||
receive_carbon(void **state)
|
||||
receive_carbon(void** state)
|
||||
{
|
||||
prof_input("/carbons on");
|
||||
|
||||
prof_connect();
|
||||
assert_true(stbbr_received(
|
||||
"<iq id='*' type='set'><enable xmlns='urn:xmpp:carbons:2'/></iq>"
|
||||
));
|
||||
"<iq id='*' type='set'><enable xmlns='urn:xmpp:carbons:2'/></iq>"));
|
||||
|
||||
stbbr_send(
|
||||
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
|
||||
"<priority>10</priority>"
|
||||
"<status>On my mobile</status>"
|
||||
"</presence>"
|
||||
);
|
||||
"<priority>10</priority>"
|
||||
"<status>On my mobile</status>"
|
||||
"</presence>");
|
||||
assert_true(prof_output_exact("Buddy1 (mobile) is online, \"On my mobile\""));
|
||||
prof_input("/msg Buddy1");
|
||||
assert_true(prof_output_exact("unencrypted"));
|
||||
|
||||
stbbr_send(
|
||||
"<message type='chat' to='stabber@localhost/profanity' from='stabber@localhost'>"
|
||||
"<received xmlns='urn:xmpp:carbons:2'>"
|
||||
"<forwarded xmlns='urn:xmpp:forward:0'>"
|
||||
"<message id='prof_msg_7' xmlns='jabber:client' type='chat' lang='en' to='stabber@localhost/profanity' from='buddy1@localhost/mobile'>"
|
||||
"<body>test carbon from recipient</body>"
|
||||
"</message>"
|
||||
"</forwarded>"
|
||||
"</received>"
|
||||
"<received xmlns='urn:xmpp:carbons:2'>"
|
||||
"<forwarded xmlns='urn:xmpp:forward:0'>"
|
||||
"<message id='prof_msg_7' xmlns='jabber:client' type='chat' lang='en' to='stabber@localhost/profanity' from='buddy1@localhost/mobile'>"
|
||||
"<body>test carbon from recipient</body>"
|
||||
"</message>"
|
||||
);
|
||||
"</forwarded>"
|
||||
"</received>"
|
||||
"</message>");
|
||||
|
||||
assert_true(prof_output_regex("Buddy1/mobile: .+test carbon from recipient"));
|
||||
}
|
||||
|
||||
void
|
||||
receive_self_carbon(void **state)
|
||||
receive_self_carbon(void** state)
|
||||
{
|
||||
prof_input("/carbons on");
|
||||
|
||||
prof_connect();
|
||||
assert_true(stbbr_received(
|
||||
"<iq id='*' type='set'><enable xmlns='urn:xmpp:carbons:2'/></iq>"
|
||||
));
|
||||
"<iq id='*' type='set'><enable xmlns='urn:xmpp:carbons:2'/></iq>"));
|
||||
|
||||
stbbr_send(
|
||||
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
|
||||
"<priority>10</priority>"
|
||||
"<status>On my mobile</status>"
|
||||
"</presence>"
|
||||
);
|
||||
"<priority>10</priority>"
|
||||
"<status>On my mobile</status>"
|
||||
"</presence>");
|
||||
assert_true(prof_output_exact("Buddy1 (mobile) is online, \"On my mobile\""));
|
||||
prof_input("/msg Buddy1");
|
||||
assert_true(prof_output_exact("unencrypted"));
|
||||
|
||||
stbbr_send(
|
||||
"<message type='chat' to='stabber@localhost/profanity' from='stabber@localhost'>"
|
||||
"<sent xmlns='urn:xmpp:carbons:2'>"
|
||||
"<forwarded xmlns='urn:xmpp:forward:0'>"
|
||||
"<message id='59' xmlns='jabber:client' type='chat' to='buddy1@localhost/mobile' lang='en' from='stabber@localhost/profanity'>"
|
||||
"<body>self sent carbon</body>"
|
||||
"</message>"
|
||||
"</forwarded>"
|
||||
"</sent>"
|
||||
"<sent xmlns='urn:xmpp:carbons:2'>"
|
||||
"<forwarded xmlns='urn:xmpp:forward:0'>"
|
||||
"<message id='59' xmlns='jabber:client' type='chat' to='buddy1@localhost/mobile' lang='en' from='stabber@localhost/profanity'>"
|
||||
"<body>self sent carbon</body>"
|
||||
"</message>"
|
||||
);
|
||||
"</forwarded>"
|
||||
"</sent>"
|
||||
"</message>");
|
||||
|
||||
assert_true(prof_output_regex("me: .+self sent carbon"));
|
||||
}
|
||||
|
||||
void
|
||||
receive_private_carbon(void **state)
|
||||
receive_private_carbon(void** state)
|
||||
{
|
||||
prof_input("/carbons on");
|
||||
|
||||
prof_connect();
|
||||
assert_true(stbbr_received(
|
||||
"<iq id='*' type='set'><enable xmlns='urn:xmpp:carbons:2'/></iq>"
|
||||
));
|
||||
"<iq id='*' type='set'><enable xmlns='urn:xmpp:carbons:2'/></iq>"));
|
||||
|
||||
stbbr_send(
|
||||
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
|
||||
"<priority>10</priority>"
|
||||
"<status>On my mobile</status>"
|
||||
"</presence>"
|
||||
);
|
||||
"<priority>10</priority>"
|
||||
"<status>On my mobile</status>"
|
||||
"</presence>");
|
||||
assert_true(prof_output_exact("Buddy1 (mobile) is online, \"On my mobile\""));
|
||||
prof_input("/msg Buddy1");
|
||||
assert_true(prof_output_exact("unencrypted"));
|
||||
|
||||
stbbr_send(
|
||||
"<message type='chat' to='stabber@localhost/profanity' from='buddy1@localhost/mobile'>"
|
||||
"<body>Private carbon</body>"
|
||||
"<private xmlns='urn:xmpp:carbons:2'/>"
|
||||
"</message>"
|
||||
);
|
||||
"<body>Private carbon</body>"
|
||||
"<private xmlns='urn:xmpp:carbons:2'/>"
|
||||
"</message>");
|
||||
|
||||
assert_true(prof_output_regex("Buddy1/mobile: .+Private carbon"));
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
void send_enable_carbons(void **state);
|
||||
void connect_with_carbons_enabled(void **state);
|
||||
void send_disable_carbons(void **state);
|
||||
void receive_carbon(void **state);
|
||||
void receive_self_carbon(void **state);
|
||||
void receive_private_carbon(void **state);
|
||||
void send_enable_carbons(void** state);
|
||||
void connect_with_carbons_enabled(void** state);
|
||||
void send_disable_carbons(void** state);
|
||||
void receive_carbon(void** state);
|
||||
void receive_self_carbon(void** state);
|
||||
void receive_private_carbon(void** state);
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "proftest.h"
|
||||
|
||||
void
|
||||
sends_message_to_barejid_when_contact_offline(void **state)
|
||||
sends_message_to_barejid_when_contact_offline(void** state)
|
||||
{
|
||||
prof_connect();
|
||||
|
||||
@@ -17,188 +17,166 @@ sends_message_to_barejid_when_contact_offline(void **state)
|
||||
|
||||
assert_true(stbbr_received(
|
||||
"<message id='*' to='buddy1@localhost' type='chat'>"
|
||||
"<body>Hi there</body>"
|
||||
"</message>"
|
||||
));
|
||||
"<body>Hi there</body>"
|
||||
"</message>"));
|
||||
}
|
||||
|
||||
void
|
||||
sends_message_to_barejid_when_contact_online(void **state)
|
||||
sends_message_to_barejid_when_contact_online(void** state)
|
||||
{
|
||||
prof_connect();
|
||||
|
||||
stbbr_send(
|
||||
"<presence to='stabber@localhost/profanity' from='buddy1@localhost/mobile'>"
|
||||
"<priority>10</priority>"
|
||||
"</presence>"
|
||||
);
|
||||
"<priority>10</priority>"
|
||||
"</presence>");
|
||||
assert_true(prof_output_exact("Buddy1 (mobile) is online"));
|
||||
|
||||
prof_input("/msg buddy1@localhost Hi there");
|
||||
|
||||
assert_true(stbbr_received(
|
||||
"<message id='*' to='buddy1@localhost' type='chat'>"
|
||||
"<body>Hi there</body>"
|
||||
"</message>"
|
||||
));
|
||||
"<body>Hi there</body>"
|
||||
"</message>"));
|
||||
}
|
||||
|
||||
void
|
||||
sends_message_to_fulljid_when_received_from_fulljid(void **state)
|
||||
sends_message_to_fulljid_when_received_from_fulljid(void** state)
|
||||
{
|
||||
prof_connect();
|
||||
|
||||
stbbr_send(
|
||||
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
|
||||
"<priority>10</priority>"
|
||||
"</presence>"
|
||||
);
|
||||
"<priority>10</priority>"
|
||||
"</presence>");
|
||||
assert_true(prof_output_exact("Buddy1 (mobile) is online"));
|
||||
|
||||
stbbr_send(
|
||||
"<message id='message1' to='stabber@localhost' from='buddy1@localhost/mobile' type='chat'>"
|
||||
"<body>First message</body>"
|
||||
"</message>"
|
||||
);
|
||||
"<body>First message</body>"
|
||||
"</message>");
|
||||
assert_true(prof_output_exact("<< chat message: Buddy1/mobile (win 2)"));
|
||||
|
||||
prof_input("/msg buddy1@localhost Hi there");
|
||||
|
||||
assert_true(stbbr_received(
|
||||
"<message id='*' to='buddy1@localhost/mobile' type='chat'>"
|
||||
"<body>Hi there</body>"
|
||||
"</message>"
|
||||
));
|
||||
"<body>Hi there</body>"
|
||||
"</message>"));
|
||||
}
|
||||
|
||||
void
|
||||
sends_subsequent_messages_to_fulljid(void **state)
|
||||
sends_subsequent_messages_to_fulljid(void** state)
|
||||
{
|
||||
prof_connect();
|
||||
|
||||
stbbr_send(
|
||||
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
|
||||
"<priority>10</priority>"
|
||||
"</presence>"
|
||||
);
|
||||
"<priority>10</priority>"
|
||||
"</presence>");
|
||||
assert_true(prof_output_exact("Buddy1 (mobile) is online"));
|
||||
|
||||
stbbr_send(
|
||||
"<message id='message1' to='stabber@localhost' from='buddy1@localhost/mobile' type='chat'>"
|
||||
"<body>First message</body>"
|
||||
"</message>"
|
||||
);
|
||||
"<body>First message</body>"
|
||||
"</message>");
|
||||
assert_true(prof_output_exact("<< chat message: Buddy1/mobile (win 2)"));
|
||||
|
||||
prof_input("/msg buddy1@localhost Outgoing 1");
|
||||
assert_true(stbbr_received(
|
||||
"<message id='*' to='buddy1@localhost/mobile' type='chat'>"
|
||||
"<body>Outgoing 1</body>"
|
||||
"</message>"
|
||||
));
|
||||
"<body>Outgoing 1</body>"
|
||||
"</message>"));
|
||||
|
||||
prof_input("/msg buddy1@localhost Outgoing 2");
|
||||
assert_true(stbbr_received(
|
||||
"<message id='*' to='buddy1@localhost/mobile' type='chat'>"
|
||||
"<body>Outgoing 2</body>"
|
||||
"</message>"
|
||||
));
|
||||
"<body>Outgoing 2</body>"
|
||||
"</message>"));
|
||||
|
||||
prof_input("/msg buddy1@localhost Outgoing 3");
|
||||
assert_true(stbbr_received(
|
||||
"<message id='*' to='buddy1@localhost/mobile' type='chat'>"
|
||||
"<body>Outgoing 3</body>"
|
||||
"</message>"
|
||||
));
|
||||
"<body>Outgoing 3</body>"
|
||||
"</message>"));
|
||||
}
|
||||
|
||||
void
|
||||
resets_to_barejid_after_presence_received(void **state)
|
||||
resets_to_barejid_after_presence_received(void** state)
|
||||
{
|
||||
prof_connect();
|
||||
|
||||
stbbr_send(
|
||||
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
|
||||
"<priority>10</priority>"
|
||||
"</presence>"
|
||||
);
|
||||
"<priority>10</priority>"
|
||||
"</presence>");
|
||||
assert_true(prof_output_exact("Buddy1 (mobile) is online"));
|
||||
|
||||
stbbr_send(
|
||||
"<message id='message1' to='stabber@localhost' from='buddy1@localhost/mobile' type='chat'>"
|
||||
"<body>First message</body>"
|
||||
"</message>"
|
||||
);
|
||||
"<body>First message</body>"
|
||||
"</message>");
|
||||
assert_true(prof_output_exact("<< chat message: Buddy1/mobile (win 2)"));
|
||||
|
||||
prof_input("/msg buddy1@localhost Outgoing 1");
|
||||
assert_true(stbbr_received(
|
||||
"<message id='*' to='buddy1@localhost/mobile' type='chat'>"
|
||||
"<body>Outgoing 1</body>"
|
||||
"</message>"
|
||||
));
|
||||
"<body>Outgoing 1</body>"
|
||||
"</message>"));
|
||||
|
||||
stbbr_send(
|
||||
"<presence to='stabber@localhost' from='buddy1@localhost/laptop'>"
|
||||
"<priority>5</priority>"
|
||||
"<show>dnd</show>"
|
||||
"</presence>"
|
||||
);
|
||||
"<priority>5</priority>"
|
||||
"<show>dnd</show>"
|
||||
"</presence>");
|
||||
assert_true(prof_output_exact("Buddy1 (laptop) is dnd"));
|
||||
|
||||
prof_input("/msg buddy1@localhost Outgoing 2");
|
||||
assert_true(stbbr_received(
|
||||
"<message id='*' to='buddy1@localhost' type='chat'>"
|
||||
"<body>Outgoing 2</body>"
|
||||
"</message>"
|
||||
));
|
||||
"<body>Outgoing 2</body>"
|
||||
"</message>"));
|
||||
}
|
||||
|
||||
void
|
||||
new_session_when_message_received_from_different_fulljid(void **state)
|
||||
new_session_when_message_received_from_different_fulljid(void** state)
|
||||
{
|
||||
prof_connect();
|
||||
|
||||
stbbr_send(
|
||||
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
|
||||
"<priority>10</priority>"
|
||||
"</presence>"
|
||||
);
|
||||
"<priority>10</priority>"
|
||||
"</presence>");
|
||||
assert_true(prof_output_exact("Buddy1 (mobile) is online"));
|
||||
|
||||
stbbr_send(
|
||||
"<presence to='stabber@localhost' from='buddy1@localhost/laptop'>"
|
||||
"<priority>8</priority>"
|
||||
"<show>away</show>"
|
||||
"</presence>"
|
||||
);
|
||||
"<priority>8</priority>"
|
||||
"<show>away</show>"
|
||||
"</presence>");
|
||||
assert_true(prof_output_exact("Buddy1 (laptop) is away"));
|
||||
|
||||
stbbr_send(
|
||||
"<message id='message1' to='stabber@localhost' from='buddy1@localhost/mobile' type='chat'>"
|
||||
"<body>From first resource</body>"
|
||||
"</message>"
|
||||
);
|
||||
"<body>From first resource</body>"
|
||||
"</message>");
|
||||
assert_true(prof_output_exact("<< chat message: Buddy1/mobile (win 2)"));
|
||||
|
||||
prof_input("/msg buddy1@localhost Outgoing 1");
|
||||
assert_true(stbbr_received(
|
||||
"<message id='*' to='buddy1@localhost/mobile' type='chat'>"
|
||||
"<body>Outgoing 1</body>"
|
||||
"</message>"
|
||||
));
|
||||
"<body>Outgoing 1</body>"
|
||||
"</message>"));
|
||||
|
||||
stbbr_send(
|
||||
"<message id='message1' to='stabber@localhost' from='buddy1@localhost/laptop' type='chat'>"
|
||||
"<body>From second resource</body>"
|
||||
"</message>"
|
||||
);
|
||||
"<body>From second resource</body>"
|
||||
"</message>");
|
||||
assert_true(prof_output_regex("Buddy1/laptop:.+From second resource"));
|
||||
|
||||
prof_input("/msg buddy1@localhost Outgoing 2");
|
||||
assert_true(stbbr_received(
|
||||
"<message id='*' to='buddy1@localhost/laptop' type='chat'>"
|
||||
"<body>Outgoing 2</body>"
|
||||
"</message>"
|
||||
));
|
||||
"<body>Outgoing 2</body>"
|
||||
"</message>"));
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
void sends_message_to_barejid_when_contact_offline(void **state);
|
||||
void sends_message_to_barejid_when_contact_online(void **state);
|
||||
void sends_message_to_fulljid_when_received_from_fulljid(void **state);
|
||||
void sends_subsequent_messages_to_fulljid(void **state);
|
||||
void resets_to_barejid_after_presence_received(void **state);
|
||||
void new_session_when_message_received_from_different_fulljid(void **state);
|
||||
void sends_message_to_barejid_when_contact_offline(void** state);
|
||||
void sends_message_to_barejid_when_contact_online(void** state);
|
||||
void sends_message_to_fulljid_when_received_from_fulljid(void** state);
|
||||
void sends_subsequent_messages_to_fulljid(void** state);
|
||||
void resets_to_barejid_after_presence_received(void** state);
|
||||
void new_session_when_message_received_from_different_fulljid(void** state);
|
||||
|
||||
@@ -9,43 +9,40 @@
|
||||
#include "proftest.h"
|
||||
|
||||
void
|
||||
connect_jid_requests_roster(void **state)
|
||||
connect_jid_requests_roster(void** state)
|
||||
{
|
||||
prof_connect();
|
||||
|
||||
assert_true(stbbr_received(
|
||||
"<iq id='*' type='get'><query xmlns='jabber:iq:roster'/></iq>"
|
||||
));
|
||||
"<iq id='*' type='get'><query xmlns='jabber:iq:roster'/></iq>"));
|
||||
}
|
||||
|
||||
void
|
||||
connect_jid_sends_presence_after_receiving_roster(void **state)
|
||||
connect_jid_sends_presence_after_receiving_roster(void** state)
|
||||
{
|
||||
prof_connect();
|
||||
|
||||
assert_true(stbbr_received(
|
||||
"<presence id='*'>"
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
|
||||
"</presence>"
|
||||
));
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
|
||||
"</presence>"));
|
||||
}
|
||||
|
||||
void
|
||||
connect_jid_requests_bookmarks(void **state)
|
||||
connect_jid_requests_bookmarks(void** state)
|
||||
{
|
||||
prof_connect();
|
||||
|
||||
assert_true(stbbr_received(
|
||||
"<iq id='*' type='get'>"
|
||||
"<query xmlns='jabber:iq:private'>"
|
||||
"<storage xmlns='storage:bookmarks'/>"
|
||||
"</query>"
|
||||
"</iq>"
|
||||
));
|
||||
"<query xmlns='jabber:iq:private'>"
|
||||
"<storage xmlns='storage:bookmarks'/>"
|
||||
"</query>"
|
||||
"</iq>"));
|
||||
}
|
||||
|
||||
void
|
||||
connect_bad_password(void **state)
|
||||
connect_bad_password(void** state)
|
||||
{
|
||||
prof_input("/connect stabber@localhost server 127.0.0.1 port 5230 tls allow");
|
||||
prof_input("badpassword");
|
||||
@@ -54,39 +51,35 @@ connect_bad_password(void **state)
|
||||
}
|
||||
|
||||
void
|
||||
connect_shows_presence_updates(void **state)
|
||||
connect_shows_presence_updates(void** state)
|
||||
{
|
||||
prof_connect();
|
||||
|
||||
stbbr_send(
|
||||
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
|
||||
"<show>dnd</show>"
|
||||
"<status>busy!</status>"
|
||||
"</presence>"
|
||||
);
|
||||
"<show>dnd</show>"
|
||||
"<status>busy!</status>"
|
||||
"</presence>");
|
||||
assert_true(prof_output_exact("Buddy1 (mobile) is dnd, \"busy!\""));
|
||||
|
||||
stbbr_send(
|
||||
"<presence to='stabber@localhost' from='buddy1@localhost/laptop'>"
|
||||
"<show>chat</show>"
|
||||
"<status>Talk to me!</status>"
|
||||
"</presence>"
|
||||
);
|
||||
"<show>chat</show>"
|
||||
"<status>Talk to me!</status>"
|
||||
"</presence>");
|
||||
assert_true(prof_output_exact("Buddy1 (laptop) is chat, \"Talk to me!\""));
|
||||
|
||||
stbbr_send(
|
||||
"<presence to='stabber@localhost' from='buddy2@localhost/work'>"
|
||||
"<show>away</show>"
|
||||
"<status>Out of office</status>"
|
||||
"</presence>"
|
||||
);
|
||||
"<show>away</show>"
|
||||
"<status>Out of office</status>"
|
||||
"</presence>");
|
||||
assert_true(prof_output_exact("Buddy2 (work) is away, \"Out of office\""));
|
||||
|
||||
stbbr_send(
|
||||
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
|
||||
"<show>xa</show>"
|
||||
"<status>Gone :(</status>"
|
||||
"</presence>"
|
||||
);
|
||||
"<show>xa</show>"
|
||||
"<status>Gone :(</status>"
|
||||
"</presence>");
|
||||
assert_true(prof_output_exact("Buddy1 (mobile) is xa, \"Gone :(\""));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
void connect_jid_requests_roster(void **state);
|
||||
void connect_jid_sends_presence_after_receiving_roster(void **state);
|
||||
void connect_jid_requests_bookmarks(void **state);
|
||||
void connect_bad_password(void **state);
|
||||
void connect_shows_presence_updates(void **state);
|
||||
void connect_jid_requests_roster(void** state);
|
||||
void connect_jid_sends_presence_after_receiving_roster(void** state);
|
||||
void connect_jid_requests_bookmarks(void** state);
|
||||
void connect_bad_password(void** state);
|
||||
void connect_shows_presence_updates(void** state);
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "proftest.h"
|
||||
|
||||
void
|
||||
disconnect_ends_session(void **state)
|
||||
disconnect_ends_session(void** state)
|
||||
{
|
||||
prof_connect();
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
void disconnect_ends_session(void **state);
|
||||
void disconnect_ends_session(void** state);
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "proftest.h"
|
||||
|
||||
void
|
||||
message_send(void **state)
|
||||
message_send(void** state)
|
||||
{
|
||||
prof_connect();
|
||||
|
||||
@@ -17,29 +17,27 @@ message_send(void **state)
|
||||
|
||||
assert_true(stbbr_received(
|
||||
"<message id='*' to='somejid@someserver.com' type='chat'>"
|
||||
"<body>Hi there</body>"
|
||||
"</message>"
|
||||
));
|
||||
"<body>Hi there</body>"
|
||||
"</message>"));
|
||||
|
||||
assert_true(prof_output_regex("me: .+Hi there"));
|
||||
}
|
||||
|
||||
void
|
||||
message_receive_console(void **state)
|
||||
message_receive_console(void** state)
|
||||
{
|
||||
prof_connect();
|
||||
|
||||
stbbr_send(
|
||||
"<message id='message1' to='stabber@localhost' from='someuser@chatserv.org/laptop' type='chat'>"
|
||||
"<body>How are you?</body>"
|
||||
"</message>"
|
||||
);
|
||||
"<body>How are you?</body>"
|
||||
"</message>");
|
||||
|
||||
assert_true(prof_output_exact("<< chat message: someuser@chatserv.org/laptop (win 2)"));
|
||||
}
|
||||
|
||||
void
|
||||
message_receive_chatwin(void **state)
|
||||
message_receive_chatwin(void** state)
|
||||
{
|
||||
prof_connect();
|
||||
|
||||
@@ -48,9 +46,8 @@ message_receive_chatwin(void **state)
|
||||
|
||||
stbbr_send(
|
||||
"<message id='message1' to='stabber@localhost' from='someuser@chatserv.org/laptop' type='chat'>"
|
||||
"<body>How are you?</body>"
|
||||
"</message>"
|
||||
);
|
||||
"<body>How are you?</body>"
|
||||
"</message>");
|
||||
|
||||
assert_true(prof_output_regex("someuser@chatserv.org/laptop: .+How are you?"));
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
void message_send(void **state);
|
||||
void message_receive_console(void **state);
|
||||
void message_receive_chatwin(void **state);
|
||||
void message_send(void** state);
|
||||
void message_receive_console(void** state);
|
||||
void message_receive_chatwin(void** state);
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "proftest.h"
|
||||
|
||||
void
|
||||
sends_room_join(void **state)
|
||||
sends_room_join(void** state)
|
||||
{
|
||||
prof_connect();
|
||||
|
||||
@@ -17,14 +17,13 @@ sends_room_join(void **state)
|
||||
|
||||
assert_true(stbbr_last_received(
|
||||
"<presence id='*' to='testroom@conference.localhost/stabber'>"
|
||||
"<x xmlns='http://jabber.org/protocol/muc'/>"
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
|
||||
"</presence>"
|
||||
));
|
||||
"<x xmlns='http://jabber.org/protocol/muc'/>"
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
|
||||
"</presence>"));
|
||||
}
|
||||
|
||||
void
|
||||
sends_room_join_with_nick(void **state)
|
||||
sends_room_join_with_nick(void** state)
|
||||
{
|
||||
prof_connect();
|
||||
|
||||
@@ -32,14 +31,13 @@ sends_room_join_with_nick(void **state)
|
||||
|
||||
assert_true(stbbr_last_received(
|
||||
"<presence id='*' to='testroom@conference.localhost/testnick'>"
|
||||
"<x xmlns='http://jabber.org/protocol/muc'/>"
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
|
||||
"</presence>"
|
||||
));
|
||||
"<x xmlns='http://jabber.org/protocol/muc'/>"
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
|
||||
"</presence>"));
|
||||
}
|
||||
|
||||
void
|
||||
sends_room_join_with_password(void **state)
|
||||
sends_room_join_with_password(void** state)
|
||||
{
|
||||
prof_connect();
|
||||
|
||||
@@ -47,16 +45,15 @@ sends_room_join_with_password(void **state)
|
||||
|
||||
assert_true(stbbr_last_received(
|
||||
"<presence id='*' to='testroom@conference.localhost/stabber'>"
|
||||
"<x xmlns='http://jabber.org/protocol/muc'>"
|
||||
"<password>testpassword</password>"
|
||||
"</x>"
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
|
||||
"</presence>"
|
||||
));
|
||||
"<x xmlns='http://jabber.org/protocol/muc'>"
|
||||
"<password>testpassword</password>"
|
||||
"</x>"
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
|
||||
"</presence>"));
|
||||
}
|
||||
|
||||
void
|
||||
sends_room_join_with_nick_and_password(void **state)
|
||||
sends_room_join_with_nick_and_password(void** state)
|
||||
{
|
||||
prof_connect();
|
||||
|
||||
@@ -64,28 +61,26 @@ sends_room_join_with_nick_and_password(void **state)
|
||||
|
||||
assert_true(stbbr_last_received(
|
||||
"<presence id='*' to='testroom@conference.localhost/testnick'>"
|
||||
"<x xmlns='http://jabber.org/protocol/muc'>"
|
||||
"<password>testpassword</password>"
|
||||
"</x>"
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
|
||||
"</presence>"
|
||||
));
|
||||
"<x xmlns='http://jabber.org/protocol/muc'>"
|
||||
"<password>testpassword</password>"
|
||||
"</x>"
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
|
||||
"</presence>"));
|
||||
}
|
||||
|
||||
void
|
||||
shows_role_and_affiliation_on_join(void **state)
|
||||
shows_role_and_affiliation_on_join(void** state)
|
||||
{
|
||||
prof_connect();
|
||||
|
||||
stbbr_for_id("prof_join_4",
|
||||
"<presence id='prof_join_4' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='*'/>"
|
||||
"<x xmlns='http://jabber.org/protocol/muc#user'>"
|
||||
"<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
|
||||
"</x>"
|
||||
"<status code='110'/>"
|
||||
"</presence>"
|
||||
);
|
||||
"<presence id='prof_join_4' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='*'/>"
|
||||
"<x xmlns='http://jabber.org/protocol/muc#user'>"
|
||||
"<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
|
||||
"</x>"
|
||||
"<status code='110'/>"
|
||||
"</presence>");
|
||||
|
||||
prof_input("/join testroom@conference.localhost");
|
||||
|
||||
@@ -93,186 +88,173 @@ shows_role_and_affiliation_on_join(void **state)
|
||||
}
|
||||
|
||||
void
|
||||
shows_subject_on_join(void **state)
|
||||
shows_subject_on_join(void** state)
|
||||
{
|
||||
prof_connect();
|
||||
|
||||
stbbr_for_id("prof_join_4",
|
||||
"<presence id='prof_join_4' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='*'/>"
|
||||
"<x xmlns='http://jabber.org/protocol/muc#user'>"
|
||||
"<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
|
||||
"</x>"
|
||||
"<status code='110'/>"
|
||||
"</presence>"
|
||||
);
|
||||
"<presence id='prof_join_4' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='*'/>"
|
||||
"<x xmlns='http://jabber.org/protocol/muc#user'>"
|
||||
"<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
|
||||
"</x>"
|
||||
"<status code='110'/>"
|
||||
"</presence>");
|
||||
|
||||
prof_input("/join testroom@conference.localhost");
|
||||
assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none"));
|
||||
|
||||
stbbr_send(
|
||||
"<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost'>"
|
||||
"<subject>Test room subject</subject>"
|
||||
"<body>anothernick has set the subject to: Test room subject</body>"
|
||||
"</message>"
|
||||
);
|
||||
"<subject>Test room subject</subject>"
|
||||
"<body>anothernick has set the subject to: Test room subject</body>"
|
||||
"</message>");
|
||||
|
||||
assert_true(prof_output_regex("Room subject: .+Test room subject"));
|
||||
}
|
||||
|
||||
void
|
||||
shows_history_message(void **state)
|
||||
shows_history_message(void** state)
|
||||
{
|
||||
prof_connect();
|
||||
|
||||
stbbr_for_id("prof_join_4",
|
||||
"<presence id='prof_join_4' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='*'/>"
|
||||
"<x xmlns='http://jabber.org/protocol/muc#user'>"
|
||||
"<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
|
||||
"</x>"
|
||||
"<status code='110'/>"
|
||||
"</presence>"
|
||||
);
|
||||
"<presence id='prof_join_4' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='*'/>"
|
||||
"<x xmlns='http://jabber.org/protocol/muc#user'>"
|
||||
"<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
|
||||
"</x>"
|
||||
"<status code='110'/>"
|
||||
"</presence>");
|
||||
|
||||
prof_input("/join testroom@conference.localhost");
|
||||
assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none"));
|
||||
|
||||
stbbr_send(
|
||||
"<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/testoccupant'>"
|
||||
"<body>an old message</body>"
|
||||
"<delay xmlns='urn:xmpp:delay' stamp='2015-12-19T23:55:25Z' from='testroom@conference.localhost'/>"
|
||||
"<x xmlns='jabber:x:delay' stamp='20151219T23:55:25'/>"
|
||||
"</message>"
|
||||
);
|
||||
"<body>an old message</body>"
|
||||
"<delay xmlns='urn:xmpp:delay' stamp='2015-12-19T23:55:25Z' from='testroom@conference.localhost'/>"
|
||||
"<x xmlns='jabber:x:delay' stamp='20151219T23:55:25'/>"
|
||||
"</message>");
|
||||
|
||||
assert_true(prof_output_regex("testoccupant: an old message"));
|
||||
}
|
||||
|
||||
void
|
||||
shows_occupant_join(void **state)
|
||||
shows_occupant_join(void** state)
|
||||
{
|
||||
prof_connect();
|
||||
|
||||
stbbr_for_id("prof_join_4",
|
||||
"<presence id='prof_join_4' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='*'/>"
|
||||
"<x xmlns='http://jabber.org/protocol/muc#user'>"
|
||||
"<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
|
||||
"</x>"
|
||||
"<status code='110'/>"
|
||||
"</presence>"
|
||||
);
|
||||
"<presence id='prof_join_4' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='*'/>"
|
||||
"<x xmlns='http://jabber.org/protocol/muc#user'>"
|
||||
"<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
|
||||
"</x>"
|
||||
"<status code='110'/>"
|
||||
"</presence>");
|
||||
|
||||
prof_input("/join testroom@conference.localhost");
|
||||
assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none"));
|
||||
|
||||
stbbr_send(
|
||||
"<presence to='stabber@localhost/profanity' from='testroom@conference.localhost/testoccupant'>"
|
||||
"<x xmlns='http://jabber.org/protocol/muc#user'>"
|
||||
"<item role='participant' jid='someuser@someserver.org/work' affiliation='none'/>"
|
||||
"</x>"
|
||||
"</presence>"
|
||||
);
|
||||
"<x xmlns='http://jabber.org/protocol/muc#user'>"
|
||||
"<item role='participant' jid='someuser@someserver.org/work' affiliation='none'/>"
|
||||
"</x>"
|
||||
"</presence>");
|
||||
|
||||
assert_true(prof_output_exact("-> testoccupant has joined the room, role: participant, affiliation: none"));
|
||||
}
|
||||
|
||||
void
|
||||
shows_message(void **state)
|
||||
shows_message(void** state)
|
||||
{
|
||||
prof_connect();
|
||||
|
||||
stbbr_for_id("prof_join_4",
|
||||
"<presence id='prof_join_4' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='*'/>"
|
||||
"<x xmlns='http://jabber.org/protocol/muc#user'>"
|
||||
"<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
|
||||
"</x>"
|
||||
"<status code='110'/>"
|
||||
"</presence>"
|
||||
);
|
||||
"<presence id='prof_join_4' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='*'/>"
|
||||
"<x xmlns='http://jabber.org/protocol/muc#user'>"
|
||||
"<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
|
||||
"</x>"
|
||||
"<status code='110'/>"
|
||||
"</presence>");
|
||||
|
||||
prof_input("/join testroom@conference.localhost");
|
||||
assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none"));
|
||||
|
||||
stbbr_send(
|
||||
"<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/testoccupant'>"
|
||||
"<body>a new message</body>"
|
||||
"</message>"
|
||||
);
|
||||
"<body>a new message</body>"
|
||||
"</message>");
|
||||
|
||||
assert_true(prof_output_regex("testoccupant: .+a new message"));
|
||||
}
|
||||
|
||||
void
|
||||
shows_me_message_from_occupant(void **state)
|
||||
shows_me_message_from_occupant(void** state)
|
||||
{
|
||||
prof_connect();
|
||||
|
||||
stbbr_for_id("prof_join_4",
|
||||
"<presence id='prof_join_4' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='*'/>"
|
||||
"<x xmlns='http://jabber.org/protocol/muc#user'>"
|
||||
"<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
|
||||
"</x>"
|
||||
"<status code='110'/>"
|
||||
"</presence>"
|
||||
);
|
||||
"<presence id='prof_join_4' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='*'/>"
|
||||
"<x xmlns='http://jabber.org/protocol/muc#user'>"
|
||||
"<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
|
||||
"</x>"
|
||||
"<status code='110'/>"
|
||||
"</presence>");
|
||||
|
||||
prof_input("/join testroom@conference.localhost");
|
||||
assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none"));
|
||||
|
||||
stbbr_send(
|
||||
"<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/testoccupant'>"
|
||||
"<body>/me did something</body>"
|
||||
"</message>"
|
||||
);
|
||||
"<body>/me did something</body>"
|
||||
"</message>");
|
||||
|
||||
assert_true(prof_output_exact("*testoccupant did something"));
|
||||
}
|
||||
|
||||
void
|
||||
shows_me_message_from_self(void **state)
|
||||
shows_me_message_from_self(void** state)
|
||||
{
|
||||
prof_connect();
|
||||
|
||||
stbbr_for_id("prof_join_4",
|
||||
"<presence id='prof_join_4' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='*'/>"
|
||||
"<x xmlns='http://jabber.org/protocol/muc#user'>"
|
||||
"<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
|
||||
"</x>"
|
||||
"<status code='110'/>"
|
||||
"</presence>"
|
||||
);
|
||||
"<presence id='prof_join_4' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='*'/>"
|
||||
"<x xmlns='http://jabber.org/protocol/muc#user'>"
|
||||
"<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
|
||||
"</x>"
|
||||
"<status code='110'/>"
|
||||
"</presence>");
|
||||
|
||||
prof_input("/join testroom@conference.localhost");
|
||||
assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none"));
|
||||
|
||||
stbbr_send(
|
||||
"<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
|
||||
"<body>/me did something</body>"
|
||||
"</message>"
|
||||
);
|
||||
"<body>/me did something</body>"
|
||||
"</message>");
|
||||
|
||||
assert_true(prof_output_exact("*stabber did something"));
|
||||
}
|
||||
|
||||
void
|
||||
shows_all_messages_in_console_when_window_not_focussed(void **state)
|
||||
shows_all_messages_in_console_when_window_not_focussed(void** state)
|
||||
{
|
||||
prof_connect();
|
||||
|
||||
stbbr_for_id("prof_join_4",
|
||||
"<presence id='prof_join_4' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='*'/>"
|
||||
"<x xmlns='http://jabber.org/protocol/muc#user'>"
|
||||
"<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
|
||||
"</x>"
|
||||
"<status code='110'/>"
|
||||
"</presence>"
|
||||
);
|
||||
"<presence id='prof_join_4' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='*'/>"
|
||||
"<x xmlns='http://jabber.org/protocol/muc#user'>"
|
||||
"<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
|
||||
"</x>"
|
||||
"<status code='110'/>"
|
||||
"</presence>");
|
||||
|
||||
prof_input("/join testroom@conference.localhost");
|
||||
assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none"));
|
||||
@@ -282,23 +264,21 @@ shows_all_messages_in_console_when_window_not_focussed(void **state)
|
||||
|
||||
stbbr_send(
|
||||
"<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/testoccupant'>"
|
||||
"<body>a new message</body>"
|
||||
"</message>"
|
||||
);
|
||||
"<body>a new message</body>"
|
||||
"</message>");
|
||||
|
||||
assert_true(prof_output_exact("<< room message: testoccupant in testroom@conference.localhost (win 2)"));
|
||||
|
||||
stbbr_send(
|
||||
"<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/anotheroccupant'>"
|
||||
"<body>some other message</body>"
|
||||
"</message>"
|
||||
);
|
||||
"<body>some other message</body>"
|
||||
"</message>");
|
||||
|
||||
assert_true(prof_output_exact("<< room message: anotheroccupant in testroom@conference.localhost (win 2)"));
|
||||
}
|
||||
|
||||
void
|
||||
shows_first_message_in_console_when_window_not_focussed(void **state)
|
||||
shows_first_message_in_console_when_window_not_focussed(void** state)
|
||||
{
|
||||
prof_connect();
|
||||
|
||||
@@ -306,14 +286,13 @@ shows_first_message_in_console_when_window_not_focussed(void **state)
|
||||
assert_true(prof_output_exact("Console MUC messages set: first"));
|
||||
|
||||
stbbr_for_id("prof_join_4",
|
||||
"<presence id='prof_join_4' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='*'/>"
|
||||
"<x xmlns='http://jabber.org/protocol/muc#user'>"
|
||||
"<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
|
||||
"</x>"
|
||||
"<status code='110'/>"
|
||||
"</presence>"
|
||||
);
|
||||
"<presence id='prof_join_4' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='*'/>"
|
||||
"<x xmlns='http://jabber.org/protocol/muc#user'>"
|
||||
"<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
|
||||
"</x>"
|
||||
"<status code='110'/>"
|
||||
"</presence>");
|
||||
|
||||
prof_input("/join testroom@conference.localhost");
|
||||
assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none"));
|
||||
@@ -323,9 +302,8 @@ shows_first_message_in_console_when_window_not_focussed(void **state)
|
||||
|
||||
stbbr_send(
|
||||
"<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/testoccupant'>"
|
||||
"<body>a new message</body>"
|
||||
"</message>"
|
||||
);
|
||||
"<body>a new message</body>"
|
||||
"</message>");
|
||||
|
||||
assert_true(prof_output_exact("<< room message: testroom@conference.localhost (win 2)"));
|
||||
prof_input("/clear");
|
||||
@@ -334,9 +312,8 @@ shows_first_message_in_console_when_window_not_focussed(void **state)
|
||||
|
||||
stbbr_send(
|
||||
"<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/anotheroccupant'>"
|
||||
"<body>some other message</body>"
|
||||
"</message>"
|
||||
);
|
||||
"<body>some other message</body>"
|
||||
"</message>");
|
||||
|
||||
prof_timeout(2);
|
||||
assert_false(prof_output_exact("<< room message: testroom@conference.localhost (win 2)"));
|
||||
@@ -344,7 +321,7 @@ shows_first_message_in_console_when_window_not_focussed(void **state)
|
||||
}
|
||||
|
||||
void
|
||||
shows_no_message_in_console_when_window_not_focussed(void **state)
|
||||
shows_no_message_in_console_when_window_not_focussed(void** state)
|
||||
{
|
||||
prof_connect();
|
||||
|
||||
@@ -352,14 +329,13 @@ shows_no_message_in_console_when_window_not_focussed(void **state)
|
||||
assert_true(prof_output_exact("Console MUC messages set: none"));
|
||||
|
||||
stbbr_for_id("prof_join_4",
|
||||
"<presence id='prof_join_4' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='*'/>"
|
||||
"<x xmlns='http://jabber.org/protocol/muc#user'>"
|
||||
"<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
|
||||
"</x>"
|
||||
"<status code='110'/>"
|
||||
"</presence>"
|
||||
);
|
||||
"<presence id='prof_join_4' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='*'/>"
|
||||
"<x xmlns='http://jabber.org/protocol/muc#user'>"
|
||||
"<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
|
||||
"</x>"
|
||||
"<status code='110'/>"
|
||||
"</presence>");
|
||||
|
||||
prof_input("/join testroom@conference.localhost");
|
||||
assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none"));
|
||||
@@ -369,9 +345,8 @@ shows_no_message_in_console_when_window_not_focussed(void **state)
|
||||
|
||||
stbbr_send(
|
||||
"<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/testoccupant'>"
|
||||
"<body>a new message</body>"
|
||||
"</message>"
|
||||
);
|
||||
"<body>a new message</body>"
|
||||
"</message>");
|
||||
|
||||
prof_timeout(2);
|
||||
assert_false(prof_output_exact("testroom@conference.localhost (win 2)"));
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
void sends_room_join(void **state);
|
||||
void sends_room_join_with_nick(void **state);
|
||||
void sends_room_join_with_password(void **state);
|
||||
void sends_room_join_with_nick_and_password(void **state);
|
||||
void shows_role_and_affiliation_on_join(void **state);
|
||||
void shows_subject_on_join(void **state);
|
||||
void shows_history_message(void **state);
|
||||
void shows_occupant_join(void **state);
|
||||
void shows_message(void **state);
|
||||
void shows_me_message_from_occupant(void **state);
|
||||
void shows_me_message_from_self(void **state);
|
||||
void shows_all_messages_in_console_when_window_not_focussed(void **state);
|
||||
void shows_first_message_in_console_when_window_not_focussed(void **state);
|
||||
void shows_no_message_in_console_when_window_not_focussed(void **state);
|
||||
void sends_room_join(void** state);
|
||||
void sends_room_join_with_nick(void** state);
|
||||
void sends_room_join_with_password(void** state);
|
||||
void sends_room_join_with_nick_and_password(void** state);
|
||||
void shows_role_and_affiliation_on_join(void** state);
|
||||
void shows_subject_on_join(void** state);
|
||||
void shows_history_message(void** state);
|
||||
void shows_occupant_join(void** state);
|
||||
void shows_message(void** state);
|
||||
void shows_me_message_from_occupant(void** state);
|
||||
void shows_me_message_from_self(void** state);
|
||||
void shows_all_messages_in_console_when_window_not_focussed(void** state);
|
||||
void shows_first_message_in_console_when_window_not_focussed(void** state);
|
||||
void shows_no_message_in_console_when_window_not_focussed(void** state);
|
||||
|
||||
@@ -9,53 +9,47 @@
|
||||
#include "proftest.h"
|
||||
|
||||
void
|
||||
ping_server(void **state)
|
||||
ping_server(void** state)
|
||||
{
|
||||
stbbr_for_id("prof_disco_info_onconnect_2",
|
||||
"<iq id='prof_disco_info_onconnect_2' to='stabber@localhost/profanity' type='result' from='localhost'>"
|
||||
"<query xmlns='http://jabber.org/protocol/disco#info'>"
|
||||
"<identity category='server' type='im' name='Prosody'/>"
|
||||
"<feature var='urn:xmpp:ping'/>"
|
||||
"</query>"
|
||||
"</iq>"
|
||||
);
|
||||
"<iq id='prof_disco_info_onconnect_2' to='stabber@localhost/profanity' type='result' from='localhost'>"
|
||||
"<query xmlns='http://jabber.org/protocol/disco#info'>"
|
||||
"<identity category='server' type='im' name='Prosody'/>"
|
||||
"<feature var='urn:xmpp:ping'/>"
|
||||
"</query>"
|
||||
"</iq>");
|
||||
|
||||
stbbr_for_id("prof_ping_4",
|
||||
"<iq id='prof_ping_4' type='result' to='stabber@localhost/profanity'/>"
|
||||
);
|
||||
"<iq id='prof_ping_4' type='result' to='stabber@localhost/profanity'/>");
|
||||
stbbr_for_id("prof_ping_5",
|
||||
"<iq id='prof_ping_5' type='result' to='stabber@localhost/profanity'/>"
|
||||
);
|
||||
"<iq id='prof_ping_5' type='result' to='stabber@localhost/profanity'/>");
|
||||
|
||||
prof_connect();
|
||||
|
||||
prof_input("/ping");
|
||||
assert_true(stbbr_received(
|
||||
"<iq id='prof_ping_4' type='get'>"
|
||||
"<ping xmlns='urn:xmpp:ping'/>"
|
||||
"</iq>"
|
||||
));
|
||||
"<ping xmlns='urn:xmpp:ping'/>"
|
||||
"</iq>"));
|
||||
assert_true(prof_output_exact("Ping response from server"));
|
||||
|
||||
prof_input("/ping");
|
||||
assert_true(stbbr_received(
|
||||
"<iq id='prof_ping_5' type='get'>"
|
||||
"<ping xmlns='urn:xmpp:ping'/>"
|
||||
"</iq>"
|
||||
));
|
||||
"<ping xmlns='urn:xmpp:ping'/>"
|
||||
"</iq>"));
|
||||
assert_true(prof_output_exact("Ping response from server"));
|
||||
}
|
||||
|
||||
void
|
||||
ping_server_not_supported(void **state)
|
||||
ping_server_not_supported(void** state)
|
||||
{
|
||||
stbbr_for_id("prof_disco_info_onconnect_2",
|
||||
"<iq id='prof_disco_info_onconnect_2' to='stabber@localhost/profanity' type='result' from='localhost'>"
|
||||
"<query xmlns='http://jabber.org/protocol/disco#info'>"
|
||||
"<identity category='server' type='im' name='Stabber'/>"
|
||||
"</query>"
|
||||
"</iq>"
|
||||
);
|
||||
"<iq id='prof_disco_info_onconnect_2' to='stabber@localhost/profanity' type='result' from='localhost'>"
|
||||
"<query xmlns='http://jabber.org/protocol/disco#info'>"
|
||||
"<identity category='server' type='im' name='Stabber'/>"
|
||||
"</query>"
|
||||
"</iq>");
|
||||
|
||||
prof_connect();
|
||||
|
||||
@@ -64,103 +58,95 @@ ping_server_not_supported(void **state)
|
||||
}
|
||||
|
||||
void
|
||||
ping_responds_to_server_request(void **state)
|
||||
ping_responds_to_server_request(void** state)
|
||||
{
|
||||
prof_connect();
|
||||
|
||||
stbbr_send(
|
||||
"<iq id='pingtest1' type='get' to='stabber@localhost/profanity' from='localhost'>"
|
||||
"<ping xmlns='urn:xmpp:ping'/>"
|
||||
"</iq>"
|
||||
);
|
||||
"<ping xmlns='urn:xmpp:ping'/>"
|
||||
"</iq>");
|
||||
|
||||
assert_true(stbbr_received(
|
||||
"<iq id='pingtest1' type='result' from='stabber@localhost/profanity' to='localhost'/>"
|
||||
));
|
||||
"<iq id='pingtest1' type='result' from='stabber@localhost/profanity' to='localhost'/>"));
|
||||
}
|
||||
|
||||
void ping_jid(void **state)
|
||||
void
|
||||
ping_jid(void** state)
|
||||
{
|
||||
stbbr_for_id("prof_caps_4",
|
||||
"<iq id='prof_caps_4' to='stabber@localhost/profanity' type='result' from='buddy1@localhost/mobile'>"
|
||||
"<query xmlns='http://jabber.org/protocol/disco#info' node='http://profanity-im.github.io#LpT2xs3nun7jC2sq4gg3WRDQFZ4='>"
|
||||
"<identity category='client' type='console' name='Profanity0.6.0'/>"
|
||||
"<feature var='urn:xmpp:ping'/>"
|
||||
"<feature var='http://jabber.org/protocol/disco#info'/>"
|
||||
"<feature var='http://jabber.org/protocol/caps'/>"
|
||||
"</query>"
|
||||
"</iq>"
|
||||
);
|
||||
"<iq id='prof_caps_4' to='stabber@localhost/profanity' type='result' from='buddy1@localhost/mobile'>"
|
||||
"<query xmlns='http://jabber.org/protocol/disco#info' node='http://profanity-im.github.io#LpT2xs3nun7jC2sq4gg3WRDQFZ4='>"
|
||||
"<identity category='client' type='console' name='Profanity0.6.0'/>"
|
||||
"<feature var='urn:xmpp:ping'/>"
|
||||
"<feature var='http://jabber.org/protocol/disco#info'/>"
|
||||
"<feature var='http://jabber.org/protocol/caps'/>"
|
||||
"</query>"
|
||||
"</iq>");
|
||||
|
||||
prof_connect();
|
||||
|
||||
stbbr_send(
|
||||
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
|
||||
"<priority>10</priority>"
|
||||
"<status>I'm here</status>"
|
||||
"<c "
|
||||
"hash='sha-1' "
|
||||
"xmlns='http://jabber.org/protocol/caps' "
|
||||
"node='http://profanity-im.github.io' "
|
||||
"ver='LpT2xs3nun7jC2sq4gg3WRDQFZ4='"
|
||||
"/>"
|
||||
"</presence>"
|
||||
);
|
||||
"<priority>10</priority>"
|
||||
"<status>I'm here</status>"
|
||||
"<c "
|
||||
"hash='sha-1' "
|
||||
"xmlns='http://jabber.org/protocol/caps' "
|
||||
"node='http://profanity-im.github.io' "
|
||||
"ver='LpT2xs3nun7jC2sq4gg3WRDQFZ4='"
|
||||
"/>"
|
||||
"</presence>");
|
||||
assert_true(prof_output_exact("Buddy1 (mobile) is online, \"I'm here\""));
|
||||
|
||||
assert_true(stbbr_received(
|
||||
"<iq id='prof_caps_4' to='buddy1@localhost/mobile' type='get'>"
|
||||
"<query xmlns='http://jabber.org/protocol/disco#info' node='http://profanity-im.github.io#LpT2xs3nun7jC2sq4gg3WRDQFZ4='/>"
|
||||
"</iq>"
|
||||
));
|
||||
"<query xmlns='http://jabber.org/protocol/disco#info' node='http://profanity-im.github.io#LpT2xs3nun7jC2sq4gg3WRDQFZ4='/>"
|
||||
"</iq>"));
|
||||
|
||||
stbbr_for_id("prof_ping_5",
|
||||
"<iq from='buddy1@localhost/mobile' to='stabber@localhost' id='prof_ping_5' type='result'/>"
|
||||
);
|
||||
"<iq from='buddy1@localhost/mobile' to='stabber@localhost' id='prof_ping_5' type='result'/>");
|
||||
|
||||
prof_input("/ping buddy1@localhost/mobile");
|
||||
|
||||
assert_true(stbbr_received(
|
||||
"<iq id='prof_ping_5' type='get' to='buddy1@localhost/mobile'>"
|
||||
"<ping xmlns='urn:xmpp:ping'/>"
|
||||
"</iq>"
|
||||
));
|
||||
"<ping xmlns='urn:xmpp:ping'/>"
|
||||
"</iq>"));
|
||||
assert_true(prof_output_exact("Ping response from buddy1@localhost/mobile"));
|
||||
}
|
||||
|
||||
void ping_jid_not_supported(void **state)
|
||||
void
|
||||
ping_jid_not_supported(void** state)
|
||||
{
|
||||
stbbr_for_id("prof_caps_4",
|
||||
"<iq id='prof_caps_4' to='stabber@localhost/profanity' type='result' from='buddy1@localhost/mobile'>"
|
||||
"<query xmlns='http://jabber.org/protocol/disco#info' node='http://profanity-im.github.io#LpT2xs3nun7jC2sq4gg3WRDQFZ4='>"
|
||||
"<identity category='client' type='console' name='Profanity0.6.0'/>"
|
||||
"<feature var='http://jabber.org/protocol/disco#info'/>"
|
||||
"<feature var='http://jabber.org/protocol/caps'/>"
|
||||
"</query>"
|
||||
"</iq>"
|
||||
);
|
||||
"<iq id='prof_caps_4' to='stabber@localhost/profanity' type='result' from='buddy1@localhost/mobile'>"
|
||||
"<query xmlns='http://jabber.org/protocol/disco#info' node='http://profanity-im.github.io#LpT2xs3nun7jC2sq4gg3WRDQFZ4='>"
|
||||
"<identity category='client' type='console' name='Profanity0.6.0'/>"
|
||||
"<feature var='http://jabber.org/protocol/disco#info'/>"
|
||||
"<feature var='http://jabber.org/protocol/caps'/>"
|
||||
"</query>"
|
||||
"</iq>");
|
||||
|
||||
prof_connect();
|
||||
|
||||
stbbr_send(
|
||||
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
|
||||
"<priority>10</priority>"
|
||||
"<status>I'm here</status>"
|
||||
"<c "
|
||||
"hash='sha-1' "
|
||||
"xmlns='http://jabber.org/protocol/caps' "
|
||||
"node='http://profanity-im.github.io' "
|
||||
"ver='LpT2xs3nun7jC2sq4gg3WRDQFZ4='"
|
||||
"/>"
|
||||
"</presence>"
|
||||
);
|
||||
"<priority>10</priority>"
|
||||
"<status>I'm here</status>"
|
||||
"<c "
|
||||
"hash='sha-1' "
|
||||
"xmlns='http://jabber.org/protocol/caps' "
|
||||
"node='http://profanity-im.github.io' "
|
||||
"ver='LpT2xs3nun7jC2sq4gg3WRDQFZ4='"
|
||||
"/>"
|
||||
"</presence>");
|
||||
assert_true(prof_output_exact("Buddy1 (mobile) is online, \"I'm here\""));
|
||||
|
||||
assert_true(stbbr_received(
|
||||
"<iq id='prof_caps_4' to='buddy1@localhost/mobile' type='get'>"
|
||||
"<query xmlns='http://jabber.org/protocol/disco#info' node='http://profanity-im.github.io#LpT2xs3nun7jC2sq4gg3WRDQFZ4='/>"
|
||||
"</iq>"
|
||||
));
|
||||
"<query xmlns='http://jabber.org/protocol/disco#info' node='http://profanity-im.github.io#LpT2xs3nun7jC2sq4gg3WRDQFZ4='/>"
|
||||
"</iq>"));
|
||||
|
||||
prof_input("/ping buddy1@localhost/mobile");
|
||||
assert_true(prof_output_exact("buddy1@localhost/mobile does not support ping requests."));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
void ping_server(void **state);
|
||||
void ping_server_not_supported(void **state);
|
||||
void ping_responds_to_server_request(void **state);
|
||||
void ping_jid(void **state);
|
||||
void ping_jid_not_supported(void **state);
|
||||
void ping_server(void** state);
|
||||
void ping_server_not_supported(void** state);
|
||||
void ping_responds_to_server_request(void** state);
|
||||
void ping_jid(void** state);
|
||||
void ping_jid_not_supported(void** state);
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "proftest.h"
|
||||
|
||||
void
|
||||
presence_online(void **state)
|
||||
presence_online(void** state)
|
||||
{
|
||||
prof_connect();
|
||||
|
||||
@@ -17,15 +17,14 @@ presence_online(void **state)
|
||||
|
||||
assert_true(stbbr_received(
|
||||
"<presence id='prof_presence_3'>"
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
|
||||
"</presence>"
|
||||
));
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
|
||||
"</presence>"));
|
||||
|
||||
assert_true(prof_output_exact("Status set to online (priority 0)"));
|
||||
}
|
||||
|
||||
void
|
||||
presence_online_with_message(void **state)
|
||||
presence_online_with_message(void** state)
|
||||
{
|
||||
prof_connect();
|
||||
|
||||
@@ -33,16 +32,15 @@ presence_online_with_message(void **state)
|
||||
|
||||
assert_true(stbbr_received(
|
||||
"<presence id='prof_presence_4'>"
|
||||
"<status>Hi there</status>"
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
|
||||
"</presence>"
|
||||
));
|
||||
"<status>Hi there</status>"
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
|
||||
"</presence>"));
|
||||
|
||||
assert_true(prof_output_exact("Status set to online (priority 0), \"Hi there\"."));
|
||||
}
|
||||
|
||||
void
|
||||
presence_away(void **state)
|
||||
presence_away(void** state)
|
||||
{
|
||||
prof_connect();
|
||||
|
||||
@@ -50,16 +48,15 @@ presence_away(void **state)
|
||||
|
||||
assert_true(stbbr_received(
|
||||
"<presence id='prof_presence_4'>"
|
||||
"<show>away</show>"
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
|
||||
"</presence>"
|
||||
));
|
||||
"<show>away</show>"
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
|
||||
"</presence>"));
|
||||
|
||||
assert_true(prof_output_exact("Status set to away (priority 0)"));
|
||||
}
|
||||
|
||||
void
|
||||
presence_away_with_message(void **state)
|
||||
presence_away_with_message(void** state)
|
||||
{
|
||||
prof_connect();
|
||||
|
||||
@@ -67,17 +64,16 @@ presence_away_with_message(void **state)
|
||||
|
||||
assert_true(stbbr_received(
|
||||
"<presence id='prof_presence_4'>"
|
||||
"<show>away</show>"
|
||||
"<status>I'm not here for a bit</status>"
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
|
||||
"</presence>"
|
||||
));
|
||||
"<show>away</show>"
|
||||
"<status>I'm not here for a bit</status>"
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
|
||||
"</presence>"));
|
||||
|
||||
assert_true(prof_output_exact("Status set to away (priority 0), \"I'm not here for a bit\"."));
|
||||
}
|
||||
|
||||
void
|
||||
presence_xa(void **state)
|
||||
presence_xa(void** state)
|
||||
{
|
||||
prof_connect();
|
||||
|
||||
@@ -85,16 +81,15 @@ presence_xa(void **state)
|
||||
|
||||
assert_true(stbbr_received(
|
||||
"<presence id='prof_presence_4'>"
|
||||
"<show>xa</show>"
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
|
||||
"</presence>"
|
||||
));
|
||||
"<show>xa</show>"
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
|
||||
"</presence>"));
|
||||
|
||||
assert_true(prof_output_exact("Status set to xa (priority 0)"));
|
||||
}
|
||||
|
||||
void
|
||||
presence_xa_with_message(void **state)
|
||||
presence_xa_with_message(void** state)
|
||||
{
|
||||
prof_connect();
|
||||
|
||||
@@ -102,17 +97,16 @@ presence_xa_with_message(void **state)
|
||||
|
||||
assert_true(stbbr_received(
|
||||
"<presence id='prof_presence_4'>"
|
||||
"<show>xa</show>"
|
||||
"<status>Gone to the shops</status>"
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
|
||||
"</presence>"
|
||||
));
|
||||
"<show>xa</show>"
|
||||
"<status>Gone to the shops</status>"
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
|
||||
"</presence>"));
|
||||
|
||||
assert_true(prof_output_exact("Status set to xa (priority 0), \"Gone to the shops\"."));
|
||||
}
|
||||
|
||||
void
|
||||
presence_dnd(void **state)
|
||||
presence_dnd(void** state)
|
||||
{
|
||||
prof_connect();
|
||||
|
||||
@@ -120,16 +114,15 @@ presence_dnd(void **state)
|
||||
|
||||
assert_true(stbbr_received(
|
||||
"<presence id='prof_presence_4'>"
|
||||
"<show>dnd</show>"
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
|
||||
"</presence>"
|
||||
));
|
||||
"<show>dnd</show>"
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
|
||||
"</presence>"));
|
||||
|
||||
assert_true(prof_output_exact("Status set to dnd (priority 0)"));
|
||||
}
|
||||
|
||||
void
|
||||
presence_dnd_with_message(void **state)
|
||||
presence_dnd_with_message(void** state)
|
||||
{
|
||||
prof_connect();
|
||||
|
||||
@@ -137,17 +130,16 @@ presence_dnd_with_message(void **state)
|
||||
|
||||
assert_true(stbbr_received(
|
||||
"<presence id='prof_presence_4'>"
|
||||
"<show>dnd</show>"
|
||||
"<status>Working</status>"
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
|
||||
"</presence>"
|
||||
));
|
||||
"<show>dnd</show>"
|
||||
"<status>Working</status>"
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
|
||||
"</presence>"));
|
||||
|
||||
assert_true(prof_output_exact("Status set to dnd (priority 0), \"Working\"."));
|
||||
}
|
||||
|
||||
void
|
||||
presence_chat(void **state)
|
||||
presence_chat(void** state)
|
||||
{
|
||||
prof_connect();
|
||||
|
||||
@@ -155,16 +147,15 @@ presence_chat(void **state)
|
||||
|
||||
assert_true(stbbr_received(
|
||||
"<presence id='prof_presence_4'>"
|
||||
"<show>chat</show>"
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
|
||||
"</presence>"
|
||||
));
|
||||
"<show>chat</show>"
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
|
||||
"</presence>"));
|
||||
|
||||
assert_true(prof_output_exact("Status set to chat (priority 0)"));
|
||||
}
|
||||
|
||||
void
|
||||
presence_chat_with_message(void **state)
|
||||
presence_chat_with_message(void** state)
|
||||
{
|
||||
prof_connect();
|
||||
|
||||
@@ -172,17 +163,16 @@ presence_chat_with_message(void **state)
|
||||
|
||||
assert_true(stbbr_received(
|
||||
"<presence id='prof_presence_4'>"
|
||||
"<show>chat</show>"
|
||||
"<status>Free to talk</status>"
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
|
||||
"</presence>"
|
||||
));
|
||||
"<show>chat</show>"
|
||||
"<status>Free to talk</status>"
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
|
||||
"</presence>"));
|
||||
|
||||
assert_true(prof_output_exact("Status set to chat (priority 0), \"Free to talk\"."));
|
||||
}
|
||||
|
||||
void
|
||||
presence_set_priority(void **state)
|
||||
presence_set_priority(void** state)
|
||||
{
|
||||
prof_connect();
|
||||
|
||||
@@ -190,94 +180,87 @@ presence_set_priority(void **state)
|
||||
|
||||
assert_true(stbbr_received(
|
||||
"<presence id='prof_presence_4'>"
|
||||
"<priority>25</priority>"
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
|
||||
"</presence>"
|
||||
));
|
||||
"<priority>25</priority>"
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
|
||||
"</presence>"));
|
||||
|
||||
assert_true(prof_output_exact("Priority set to 25."));
|
||||
}
|
||||
|
||||
void
|
||||
presence_includes_priority(void **state)
|
||||
presence_includes_priority(void** state)
|
||||
{
|
||||
prof_connect();
|
||||
|
||||
prof_input("/priority 25");
|
||||
assert_true(stbbr_received(
|
||||
"<presence id='prof_presence_4'>"
|
||||
"<priority>25</priority>"
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
|
||||
"</presence>"
|
||||
));
|
||||
"<priority>25</priority>"
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
|
||||
"</presence>"));
|
||||
assert_true(prof_output_exact("Priority set to 25."));
|
||||
|
||||
prof_input("/chat \"Free to talk\"");
|
||||
assert_true(stbbr_received(
|
||||
"<presence id='prof_presence_5'>"
|
||||
"<priority>25</priority>"
|
||||
"<show>chat</show>"
|
||||
"<status>Free to talk</status>"
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
|
||||
"</presence>"
|
||||
));
|
||||
"<priority>25</priority>"
|
||||
"<show>chat</show>"
|
||||
"<status>Free to talk</status>"
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
|
||||
"</presence>"));
|
||||
assert_true(prof_output_exact("Status set to chat (priority 25), \"Free to talk\"."));
|
||||
}
|
||||
|
||||
void
|
||||
presence_keeps_status(void **state)
|
||||
presence_keeps_status(void** state)
|
||||
{
|
||||
prof_connect();
|
||||
|
||||
prof_input("/chat \"Free to talk\"");
|
||||
assert_true(stbbr_received(
|
||||
"<presence id='prof_presence_4'>"
|
||||
"<show>chat</show>"
|
||||
"<status>Free to talk</status>"
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
|
||||
"</presence>"
|
||||
));
|
||||
"<show>chat</show>"
|
||||
"<status>Free to talk</status>"
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
|
||||
"</presence>"));
|
||||
assert_true(prof_output_exact("Status set to chat (priority 0), \"Free to talk\"."));
|
||||
|
||||
prof_input("/priority 25");
|
||||
assert_true(stbbr_received(
|
||||
"<presence id='prof_presence_5'>"
|
||||
"<show>chat</show>"
|
||||
"<status>Free to talk</status>"
|
||||
"<priority>25</priority>"
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
|
||||
"</presence>"
|
||||
));
|
||||
"<show>chat</show>"
|
||||
"<status>Free to talk</status>"
|
||||
"<priority>25</priority>"
|
||||
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
|
||||
"</presence>"));
|
||||
assert_true(prof_output_exact("Priority set to 25."));
|
||||
}
|
||||
|
||||
void
|
||||
presence_received(void **state)
|
||||
presence_received(void** state)
|
||||
{
|
||||
prof_connect();
|
||||
|
||||
stbbr_send(
|
||||
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
|
||||
"<priority>10</priority>"
|
||||
"<status>I'm here</status>"
|
||||
"</presence>"
|
||||
);
|
||||
"<priority>10</priority>"
|
||||
"<status>I'm here</status>"
|
||||
"</presence>");
|
||||
|
||||
assert_true(prof_output_exact("Buddy1 (mobile) is online, \"I'm here\""));
|
||||
}
|
||||
|
||||
// Typical use case for gateways that don't support resources
|
||||
void
|
||||
presence_missing_resource_defaults(void **state)
|
||||
presence_missing_resource_defaults(void** state)
|
||||
{
|
||||
prof_connect();
|
||||
|
||||
stbbr_send(
|
||||
"<presence to='stabber@localhost' from='buddy1@localhost'>"
|
||||
"<priority>15</priority>"
|
||||
"<status>My status</status>"
|
||||
"</presence>"
|
||||
);
|
||||
"<priority>15</priority>"
|
||||
"<status>My status</status>"
|
||||
"</presence>");
|
||||
|
||||
assert_true(prof_output_exact("Buddy1 is online, \"My status\""));
|
||||
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
void presence_away(void **state);
|
||||
void presence_away_with_message(void **state);
|
||||
void presence_online(void **state);
|
||||
void presence_online_with_message(void **state);
|
||||
void presence_xa(void **state);
|
||||
void presence_xa_with_message(void **state);
|
||||
void presence_dnd(void **state);
|
||||
void presence_dnd_with_message(void **state);
|
||||
void presence_chat(void **state);
|
||||
void presence_chat_with_message(void **state);
|
||||
void presence_set_priority(void **state);
|
||||
void presence_includes_priority(void **state);
|
||||
void presence_keeps_status(void **state);
|
||||
void presence_received(void **state);
|
||||
void presence_missing_resource_defaults(void **state);
|
||||
void presence_away(void** state);
|
||||
void presence_away_with_message(void** state);
|
||||
void presence_online(void** state);
|
||||
void presence_online_with_message(void** state);
|
||||
void presence_xa(void** state);
|
||||
void presence_xa_with_message(void** state);
|
||||
void presence_dnd(void** state);
|
||||
void presence_dnd_with_message(void** state);
|
||||
void presence_chat(void** state);
|
||||
void presence_chat_with_message(void** state);
|
||||
void presence_set_priority(void** state);
|
||||
void presence_includes_priority(void** state);
|
||||
void presence_keeps_status(void** state);
|
||||
void presence_received(void** state);
|
||||
void presence_missing_resource_defaults(void** state);
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "proftest.h"
|
||||
|
||||
void
|
||||
does_not_send_receipt_request_to_barejid(void **state)
|
||||
does_not_send_receipt_request_to_barejid(void** state)
|
||||
{
|
||||
prof_input("/receipts request on");
|
||||
|
||||
@@ -19,34 +19,31 @@ does_not_send_receipt_request_to_barejid(void **state)
|
||||
|
||||
assert_true(stbbr_received(
|
||||
"<message id='*' type='chat' to='somejid@someserver.com'>"
|
||||
"<body>Hi there</body>"
|
||||
"</message>"
|
||||
));
|
||||
"<body>Hi there</body>"
|
||||
"</message>"));
|
||||
}
|
||||
|
||||
void
|
||||
send_receipt_request(void **state)
|
||||
send_receipt_request(void** state)
|
||||
{
|
||||
prof_input("/receipts request on");
|
||||
|
||||
prof_connect();
|
||||
|
||||
stbbr_for_id("prof_caps_4",
|
||||
"<iq from='buddy1@localhost/laptop' to='stabber@localhost' id='prof_caps_4' type='result'>"
|
||||
"<query xmlns='http://jabber.org/protocol/disco#info' node='http://profanity-im.github.io#hAkb1xZdJV9BQpgGNw8zG5Xsals='>"
|
||||
"<identity category='client' name='Profanity 0.5.0' type='console'/>"
|
||||
"<feature var='urn:xmpp:receipts'/>"
|
||||
"</query>"
|
||||
"</iq>"
|
||||
);
|
||||
"<iq from='buddy1@localhost/laptop' to='stabber@localhost' id='prof_caps_4' type='result'>"
|
||||
"<query xmlns='http://jabber.org/protocol/disco#info' node='http://profanity-im.github.io#hAkb1xZdJV9BQpgGNw8zG5Xsals='>"
|
||||
"<identity category='client' name='Profanity 0.5.0' type='console'/>"
|
||||
"<feature var='urn:xmpp:receipts'/>"
|
||||
"</query>"
|
||||
"</iq>");
|
||||
|
||||
stbbr_send(
|
||||
"<presence to='stabber@localhost' from='buddy1@localhost/laptop'>"
|
||||
"<priority>15</priority>"
|
||||
"<status>My status</status>"
|
||||
"<c hash='sha-256' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='hAkb1xZdJV9BQpgGNw8zG5Xsals='/>"
|
||||
"</presence>"
|
||||
);
|
||||
"<priority>15</priority>"
|
||||
"<status>My status</status>"
|
||||
"<c hash='sha-256' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='hAkb1xZdJV9BQpgGNw8zG5Xsals='/>"
|
||||
"</presence>");
|
||||
|
||||
prof_output_exact("Buddy1 is online, \"My status\"");
|
||||
|
||||
@@ -56,14 +53,13 @@ send_receipt_request(void **state)
|
||||
|
||||
assert_true(stbbr_received(
|
||||
"<message id='*' type='chat' to='buddy1@localhost/laptop'>"
|
||||
"<body>Hi there, where is my receipt?</body>"
|
||||
"<request xmlns='urn:xmpp:receipts'/>"
|
||||
"</message>"
|
||||
));
|
||||
"<body>Hi there, where is my receipt?</body>"
|
||||
"<request xmlns='urn:xmpp:receipts'/>"
|
||||
"</message>"));
|
||||
}
|
||||
|
||||
void
|
||||
send_receipt_on_request(void **state)
|
||||
send_receipt_on_request(void** state)
|
||||
{
|
||||
prof_input("/receipts send on");
|
||||
|
||||
@@ -71,14 +67,12 @@ send_receipt_on_request(void **state)
|
||||
|
||||
stbbr_send(
|
||||
"<message id='msg12213' type='chat' to='stabber@localhost/profanity' from='someuser@server.org/profanity'>"
|
||||
"<body>Wants a receipt</body>"
|
||||
"<request xmlns='urn:xmpp:receipts'/>"
|
||||
"</message>"
|
||||
);
|
||||
"<body>Wants a receipt</body>"
|
||||
"<request xmlns='urn:xmpp:receipts'/>"
|
||||
"</message>");
|
||||
|
||||
assert_true(stbbr_received(
|
||||
"<message id='*' to='someuser@server.org/profanity'>"
|
||||
"<received id='msg12213' xmlns='urn:xmpp:receipts'/>"
|
||||
"</message>"
|
||||
));
|
||||
"<received id='msg12213' xmlns='urn:xmpp:receipts'/>"
|
||||
"</message>"));
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
void does_not_send_receipt_request_to_barejid(void **state);
|
||||
void send_receipt_request(void **state);
|
||||
void send_receipt_on_request(void **state);
|
||||
void does_not_send_receipt_request_to_barejid(void** state);
|
||||
void send_receipt_request(void** state);
|
||||
void send_receipt_on_request(void** state);
|
||||
|
||||
@@ -9,16 +9,15 @@
|
||||
#include "proftest.h"
|
||||
|
||||
void
|
||||
rooms_query(void **state)
|
||||
rooms_query(void** state)
|
||||
{
|
||||
stbbr_for_id("prof_confreq_4",
|
||||
"<iq id='prof_confreq_4' type='result' to='stabber@localhost/profanity' from='conference.localhost'>"
|
||||
"<query xmlns='http://jabber.org/protocol/disco#items'>"
|
||||
"<item jid='chatroom@conference.localhost' name='A chat room'/>"
|
||||
"<item jid='hangout@conference.localhost' name='Another chat room'/>"
|
||||
"</query>"
|
||||
"</iq>"
|
||||
);
|
||||
"<iq id='prof_confreq_4' type='result' to='stabber@localhost/profanity' from='conference.localhost'>"
|
||||
"<query xmlns='http://jabber.org/protocol/disco#items'>"
|
||||
"<item jid='chatroom@conference.localhost' name='A chat room'/>"
|
||||
"<item jid='hangout@conference.localhost' name='Another chat room'/>"
|
||||
"</query>"
|
||||
"</iq>");
|
||||
|
||||
prof_connect();
|
||||
|
||||
@@ -29,7 +28,6 @@ rooms_query(void **state)
|
||||
|
||||
assert_true(stbbr_last_received(
|
||||
"<iq id='prof_confreq_4' to='conference.localhost' type='get'>"
|
||||
"<query xmlns='http://jabber.org/protocol/disco#items'/>"
|
||||
"</iq>"
|
||||
));
|
||||
"<query xmlns='http://jabber.org/protocol/disco#items'/>"
|
||||
"</iq>"));
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
void rooms_query(void **state);
|
||||
void rooms_query(void** state);
|
||||
|
||||
@@ -9,121 +9,110 @@
|
||||
#include "proftest.h"
|
||||
|
||||
void
|
||||
sends_new_item(void **state)
|
||||
sends_new_item(void** state)
|
||||
{
|
||||
prof_connect();
|
||||
|
||||
stbbr_for_query("jabber:iq:roster",
|
||||
"<iq type='set' from='stabber@localhost'>"
|
||||
"<query xmlns='jabber:iq:roster'>"
|
||||
"<item jid='bob@localhost' subscription='none' name=''/>"
|
||||
"</query>"
|
||||
"</iq>"
|
||||
);
|
||||
"<iq type='set' from='stabber@localhost'>"
|
||||
"<query xmlns='jabber:iq:roster'>"
|
||||
"<item jid='bob@localhost' subscription='none' name=''/>"
|
||||
"</query>"
|
||||
"</iq>");
|
||||
|
||||
prof_input("/roster add bob@localhost");
|
||||
|
||||
assert_true(stbbr_received(
|
||||
"<iq type='set' id='*'>"
|
||||
"<query xmlns='jabber:iq:roster'>"
|
||||
"<item jid='bob@localhost' name=''/>"
|
||||
"</query>"
|
||||
"</iq>"
|
||||
));
|
||||
"<query xmlns='jabber:iq:roster'>"
|
||||
"<item jid='bob@localhost' name=''/>"
|
||||
"</query>"
|
||||
"</iq>"));
|
||||
|
||||
assert_true(prof_output_exact("Roster item added: bob@localhost"));
|
||||
}
|
||||
|
||||
void
|
||||
sends_new_item_nick(void **state)
|
||||
sends_new_item_nick(void** state)
|
||||
{
|
||||
prof_connect();
|
||||
|
||||
stbbr_for_query("jabber:iq:roster",
|
||||
"<iq type='set' from='stabber@localhost'>"
|
||||
"<query xmlns='jabber:iq:roster'>"
|
||||
"<item jid='bob@localhost' subscription='none' name='Bobby'/>"
|
||||
"</query>"
|
||||
"</iq>"
|
||||
);
|
||||
"<iq type='set' from='stabber@localhost'>"
|
||||
"<query xmlns='jabber:iq:roster'>"
|
||||
"<item jid='bob@localhost' subscription='none' name='Bobby'/>"
|
||||
"</query>"
|
||||
"</iq>");
|
||||
|
||||
prof_input("/roster add bob@localhost Bobby");
|
||||
|
||||
assert_true(stbbr_received(
|
||||
"<iq type='set' id='*'>"
|
||||
"<query xmlns='jabber:iq:roster'>"
|
||||
"<item jid='bob@localhost' name='Bobby'/>"
|
||||
"</query>"
|
||||
"</iq>"
|
||||
));
|
||||
"<query xmlns='jabber:iq:roster'>"
|
||||
"<item jid='bob@localhost' name='Bobby'/>"
|
||||
"</query>"
|
||||
"</iq>"));
|
||||
|
||||
assert_true(prof_output_exact("Roster item added: bob@localhost (Bobby)"));
|
||||
}
|
||||
|
||||
void
|
||||
sends_remove_item(void **state)
|
||||
sends_remove_item(void** state)
|
||||
{
|
||||
prof_connect_with_roster(
|
||||
"<item jid='buddy1@localhost' subscription='both'/>"
|
||||
"<item jid='buddy2@localhost' subscription='both'/>"
|
||||
);
|
||||
"<item jid='buddy2@localhost' subscription='both'/>");
|
||||
|
||||
stbbr_for_query("jabber:iq:roster",
|
||||
"<iq id='*' type='set'>"
|
||||
"<query xmlns='jabber:iq:roster'>"
|
||||
"<item jid='buddy1@localhost' subscription='remove'/>"
|
||||
"</query>"
|
||||
"</iq>"
|
||||
);
|
||||
"<iq id='*' type='set'>"
|
||||
"<query xmlns='jabber:iq:roster'>"
|
||||
"<item jid='buddy1@localhost' subscription='remove'/>"
|
||||
"</query>"
|
||||
"</iq>");
|
||||
|
||||
prof_input("/roster remove buddy1@localhost");
|
||||
|
||||
assert_true(stbbr_received(
|
||||
"<iq type='set' id='*'>"
|
||||
"<query xmlns='jabber:iq:roster'>"
|
||||
"<item jid='buddy1@localhost' subscription='remove'/>"
|
||||
"</query>"
|
||||
"</iq>"
|
||||
));
|
||||
"<query xmlns='jabber:iq:roster'>"
|
||||
"<item jid='buddy1@localhost' subscription='remove'/>"
|
||||
"</query>"
|
||||
"</iq>"));
|
||||
|
||||
assert_true(prof_output_exact("Roster item removed: buddy1@localhost"));
|
||||
}
|
||||
|
||||
void
|
||||
sends_remove_item_nick(void **state)
|
||||
sends_remove_item_nick(void** state)
|
||||
{
|
||||
prof_connect_with_roster(
|
||||
"<item jid='buddy1@localhost' name='Bobby' subscription='both'/>"
|
||||
"<item jid='buddy2@localhost' subscription='both'/>"
|
||||
);
|
||||
"<item jid='buddy2@localhost' subscription='both'/>");
|
||||
|
||||
stbbr_for_query("jabber:iq:roster",
|
||||
"<iq id='*' type='set'>"
|
||||
"<query xmlns='jabber:iq:roster'>"
|
||||
"<item jid='buddy1@localhost' subscription='remove'/>"
|
||||
"</query>"
|
||||
"</iq>"
|
||||
);
|
||||
"<iq id='*' type='set'>"
|
||||
"<query xmlns='jabber:iq:roster'>"
|
||||
"<item jid='buddy1@localhost' subscription='remove'/>"
|
||||
"</query>"
|
||||
"</iq>");
|
||||
|
||||
prof_input("/roster remove Bobby");
|
||||
|
||||
assert_true(stbbr_received(
|
||||
"<iq type='set' id='*'>"
|
||||
"<query xmlns='jabber:iq:roster'>"
|
||||
"<item jid='buddy1@localhost' subscription='remove'/>"
|
||||
"</query>"
|
||||
"</iq>"
|
||||
));
|
||||
"<query xmlns='jabber:iq:roster'>"
|
||||
"<item jid='buddy1@localhost' subscription='remove'/>"
|
||||
"</query>"
|
||||
"</iq>"));
|
||||
|
||||
assert_true(prof_output_exact("Roster item removed: buddy1@localhost"));
|
||||
}
|
||||
|
||||
void
|
||||
sends_nick_change(void **state)
|
||||
sends_nick_change(void** state)
|
||||
{
|
||||
prof_connect_with_roster(
|
||||
"<item jid='buddy1@localhost' subscription='both'/>"
|
||||
);
|
||||
"<item jid='buddy1@localhost' subscription='both'/>");
|
||||
|
||||
prof_input("/roster nick buddy1@localhost Buddy1");
|
||||
|
||||
@@ -131,9 +120,8 @@ sends_nick_change(void **state)
|
||||
|
||||
assert_true(stbbr_received(
|
||||
"<iq type='set' id='*'>"
|
||||
"<query xmlns='jabber:iq:roster'>"
|
||||
"<item jid='buddy1@localhost' name='Buddy1'/>"
|
||||
"</query>"
|
||||
"</iq>"
|
||||
));
|
||||
"<query xmlns='jabber:iq:roster'>"
|
||||
"<item jid='buddy1@localhost' name='Buddy1'/>"
|
||||
"</query>"
|
||||
"</iq>"));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
void sends_new_item(void **state);
|
||||
void sends_new_item_nick(void **state);
|
||||
void sends_remove_item(void **state);
|
||||
void sends_remove_item_nick(void **state);
|
||||
void sends_nick_change(void **state);
|
||||
void sends_new_item(void** state);
|
||||
void sends_new_item_nick(void** state);
|
||||
void sends_remove_item(void** state);
|
||||
void sends_remove_item_nick(void** state);
|
||||
void sends_nick_change(void** state);
|
||||
|
||||
@@ -9,72 +9,66 @@
|
||||
#include "proftest.h"
|
||||
|
||||
void
|
||||
send_software_version_request(void **state)
|
||||
send_software_version_request(void** state)
|
||||
{
|
||||
prof_connect();
|
||||
stbbr_send(
|
||||
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
|
||||
"<priority>10</priority>"
|
||||
"<status>I'm here</status>"
|
||||
"</presence>"
|
||||
);
|
||||
"<priority>10</priority>"
|
||||
"<status>I'm here</status>"
|
||||
"</presence>");
|
||||
assert_true(prof_output_exact("Buddy1 (mobile) is online, \"I'm here\""));
|
||||
prof_input("/software buddy1@localhost/mobile");
|
||||
|
||||
assert_true(stbbr_received(
|
||||
"<iq id='*' to='buddy1@localhost/mobile' type='get'>"
|
||||
"<query xmlns='jabber:iq:version'/>"
|
||||
"</iq>"
|
||||
));
|
||||
"<query xmlns='jabber:iq:version'/>"
|
||||
"</iq>"));
|
||||
}
|
||||
|
||||
void
|
||||
display_software_version_result(void **state)
|
||||
display_software_version_result(void** state)
|
||||
{
|
||||
prof_connect();
|
||||
stbbr_send(
|
||||
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
|
||||
"<priority>10</priority>"
|
||||
"<status>I'm here</status>"
|
||||
"</presence>"
|
||||
);
|
||||
"<priority>10</priority>"
|
||||
"<status>I'm here</status>"
|
||||
"</presence>");
|
||||
assert_true(prof_output_exact("Buddy1 (mobile) is online, \"I'm here\""));
|
||||
|
||||
stbbr_for_query("jabber:iq:version",
|
||||
"<iq id='*' type='result' lang='en' to='stabber@localhost/profanity' from='buddy1@localhost/mobile'>"
|
||||
"<query xmlns='jabber:iq:version'>"
|
||||
"<name>Profanity</name>"
|
||||
"<version>0.4.7dev.master.2cb2f83</version>"
|
||||
"</query>"
|
||||
"</iq>"
|
||||
);
|
||||
"<iq id='*' type='result' lang='en' to='stabber@localhost/profanity' from='buddy1@localhost/mobile'>"
|
||||
"<query xmlns='jabber:iq:version'>"
|
||||
"<name>Profanity</name>"
|
||||
"<version>0.4.7dev.master.2cb2f83</version>"
|
||||
"</query>"
|
||||
"</iq>");
|
||||
prof_input("/software buddy1@localhost/mobile");
|
||||
|
||||
// assert_true(prof_output_exact("buddy1@localhost/mobile:"));
|
||||
// assert_true(prof_output_exact("Name : Profanity"));
|
||||
// assert_true(prof_output_exact("buddy1@localhost/mobile:"));
|
||||
// assert_true(prof_output_exact("Name : Profanity"));
|
||||
assert_true(prof_output_exact("Version : 0.4.7dev.master.2cb2f83"));
|
||||
}
|
||||
|
||||
void
|
||||
shows_message_when_software_version_error(void **state)
|
||||
shows_message_when_software_version_error(void** state)
|
||||
{
|
||||
prof_connect();
|
||||
stbbr_send(
|
||||
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
|
||||
"<priority>10</priority>"
|
||||
"<status>I'm here</status>"
|
||||
"</presence>"
|
||||
);
|
||||
"<priority>10</priority>"
|
||||
"<status>I'm here</status>"
|
||||
"</presence>");
|
||||
assert_true(prof_output_exact("Buddy1 (mobile) is online, \"I'm here\""));
|
||||
|
||||
stbbr_for_query("jabber:iq:version",
|
||||
"<iq id='*' lang='en' type='error' to='stabber@localhost/profanity' from='buddy1@localhost/laptop'>"
|
||||
"<query xmlns='jabber:iq:version'/>"
|
||||
"<error code='503' type='cancel'>"
|
||||
"<service-unavailable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>"
|
||||
"</error>"
|
||||
"</iq>"
|
||||
);
|
||||
"<iq id='*' lang='en' type='error' to='stabber@localhost/profanity' from='buddy1@localhost/laptop'>"
|
||||
"<query xmlns='jabber:iq:version'/>"
|
||||
"<error code='503' type='cancel'>"
|
||||
"<service-unavailable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>"
|
||||
"</error>"
|
||||
"</iq>");
|
||||
prof_input("/software buddy1@localhost/laptop");
|
||||
|
||||
assert_true(prof_output_exact("Could not get software version: service-unavailable"));
|
||||
@@ -82,42 +76,39 @@ shows_message_when_software_version_error(void **state)
|
||||
|
||||
// Typical use case for gateways that don't support resources
|
||||
void
|
||||
display_software_version_result_when_from_domainpart(void **state)
|
||||
display_software_version_result_when_from_domainpart(void** state)
|
||||
{
|
||||
prof_connect();
|
||||
stbbr_send(
|
||||
"<presence to='stabber@localhost' from='buddy1@localhost'>"
|
||||
"<priority>10</priority>"
|
||||
"<status>I'm here</status>"
|
||||
"</presence>"
|
||||
);
|
||||
"<priority>10</priority>"
|
||||
"<status>I'm here</status>"
|
||||
"</presence>");
|
||||
assert_true(prof_output_exact("Buddy1 is online, \"I'm here\""));
|
||||
|
||||
stbbr_for_query("jabber:iq:version",
|
||||
"<iq id='*' type='result' lang='en' to='stabber@localhost/profanity' from='localhost'>"
|
||||
"<query xmlns='jabber:iq:version'>"
|
||||
"<name>Some Gateway</name>"
|
||||
"<version>1.0</version>"
|
||||
"</query>"
|
||||
"</iq>"
|
||||
);
|
||||
"<iq id='*' type='result' lang='en' to='stabber@localhost/profanity' from='localhost'>"
|
||||
"<query xmlns='jabber:iq:version'>"
|
||||
"<name>Some Gateway</name>"
|
||||
"<version>1.0</version>"
|
||||
"</query>"
|
||||
"</iq>");
|
||||
prof_input("/software buddy1@localhost/__prof_default");
|
||||
|
||||
// assert_true(prof_output_exact("buddy1@localhost/__prof_default:"));
|
||||
// assert_true(prof_output_exact("Name : Some Gateway"));
|
||||
// assert_true(prof_output_exact("buddy1@localhost/__prof_default:"));
|
||||
// assert_true(prof_output_exact("Name : Some Gateway"));
|
||||
assert_true(prof_output_exact("Version : 1.0"));
|
||||
}
|
||||
|
||||
void
|
||||
show_message_in_chat_window_when_no_resource(void **state)
|
||||
show_message_in_chat_window_when_no_resource(void** state)
|
||||
{
|
||||
prof_connect();
|
||||
stbbr_send(
|
||||
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
|
||||
"<priority>10</priority>"
|
||||
"<status>I'm here</status>"
|
||||
"</presence>"
|
||||
);
|
||||
"<priority>10</priority>"
|
||||
"<status>I'm here</status>"
|
||||
"</presence>");
|
||||
assert_true(prof_output_exact("Buddy1 (mobile) is online, \"I'm here\""));
|
||||
|
||||
prof_input("/msg Buddy1");
|
||||
@@ -127,37 +118,34 @@ show_message_in_chat_window_when_no_resource(void **state)
|
||||
}
|
||||
|
||||
void
|
||||
display_software_version_result_in_chat(void **state)
|
||||
display_software_version_result_in_chat(void** state)
|
||||
{
|
||||
prof_connect();
|
||||
stbbr_send(
|
||||
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
|
||||
"<priority>10</priority>"
|
||||
"<status>I'm here</status>"
|
||||
"</presence>"
|
||||
);
|
||||
"<priority>10</priority>"
|
||||
"<status>I'm here</status>"
|
||||
"</presence>");
|
||||
assert_true(prof_output_exact("Buddy1 (mobile) is online, \"I'm here\""));
|
||||
prof_input("/msg Buddy1");
|
||||
|
||||
stbbr_send(
|
||||
"<message id='message1' to='stabber@localhost' from='buddy1@localhost/mobile' type='chat'>"
|
||||
"<body>Here's a message</body>"
|
||||
"</message>"
|
||||
);
|
||||
"<body>Here's a message</body>"
|
||||
"</message>");
|
||||
assert_true(prof_output_exact("Here's a message"));
|
||||
|
||||
stbbr_for_query("jabber:iq:version",
|
||||
"<iq id='*' type='result' lang='en' to='stabber@localhost/profanity' from='buddy1@localhost/mobile'>"
|
||||
"<query xmlns='jabber:iq:version'>"
|
||||
"<name>Profanity</name>"
|
||||
"<version>0.4.7dev.master.2cb2f83</version>"
|
||||
"</query>"
|
||||
"</iq>"
|
||||
);
|
||||
"<iq id='*' type='result' lang='en' to='stabber@localhost/profanity' from='buddy1@localhost/mobile'>"
|
||||
"<query xmlns='jabber:iq:version'>"
|
||||
"<name>Profanity</name>"
|
||||
"<version>0.4.7dev.master.2cb2f83</version>"
|
||||
"</query>"
|
||||
"</iq>");
|
||||
|
||||
prof_input("/software");
|
||||
|
||||
// assert_true(prof_output_exact("buddy1@localhost/mobile:"));
|
||||
// assert_true(prof_output_exact("Name : Profanity"));
|
||||
// assert_true(prof_output_exact("buddy1@localhost/mobile:"));
|
||||
// assert_true(prof_output_exact("Name : Profanity"));
|
||||
assert_true(prof_output_exact("Version : 0.4.7dev.master.2cb2f83"));
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
void send_software_version_request(void **state);
|
||||
void display_software_version_result(void **state);
|
||||
void shows_message_when_software_version_error(void **state);
|
||||
void display_software_version_result_when_from_domainpart(void **state);
|
||||
void show_message_in_chat_window_when_no_resource(void **state);
|
||||
void display_software_version_result_in_chat(void **state);
|
||||
void send_software_version_request(void** state);
|
||||
void display_software_version_result(void** state);
|
||||
void shows_message_when_software_version_error(void** state);
|
||||
void display_software_version_result_when_from_domainpart(void** state);
|
||||
void show_message_in_chat_window_when_no_resource(void** state);
|
||||
void display_software_version_result_in_chat(void** state);
|
||||
|
||||
@@ -109,7 +109,7 @@ omemo_encrypt_file(FILE* in, FILE* out, off_t file_size, int* gcry_res)
|
||||
{
|
||||
return NULL;
|
||||
};
|
||||
void omemo_free(void* a){};
|
||||
void omemo_free(void* a) {};
|
||||
|
||||
uint32_t
|
||||
omemo_device_id()
|
||||
|
||||
@@ -328,7 +328,9 @@ strip_arg_quotes__returns__stripped_both(void** state)
|
||||
free(result);
|
||||
}
|
||||
|
||||
void valid_tls_policy_option__is__correct_for_various_inputs(void** state) {
|
||||
void
|
||||
valid_tls_policy_option__is__correct_for_various_inputs(void** state)
|
||||
{
|
||||
// Valid inputs
|
||||
assert_true(valid_tls_policy_option("force"));
|
||||
assert_true(valid_tls_policy_option("allow"));
|
||||
@@ -348,11 +350,13 @@ void valid_tls_policy_option__is__correct_for_various_inputs(void** state) {
|
||||
expect_any_cons_show(); // For "TLS policy must be one of: 'force', 'allow', 'trust', 'disable', 'legacy', or 'direct'."
|
||||
assert_false(valid_tls_policy_option(""));
|
||||
|
||||
// NULL
|
||||
// NULL
|
||||
assert_true(valid_tls_policy_option(NULL));
|
||||
}
|
||||
|
||||
void get_expanded_path__returns__expanded(void** state) {
|
||||
void
|
||||
get_expanded_path__returns__expanded(void** state)
|
||||
{
|
||||
gchar* expanded_path;
|
||||
|
||||
// `file://` prefix
|
||||
@@ -378,7 +382,9 @@ void get_expanded_path__returns__expanded(void** state) {
|
||||
g_free(expanded_path);
|
||||
}
|
||||
|
||||
void strtoi_range__returns__true_for_valid_input(void** state) {
|
||||
void
|
||||
strtoi_range__returns__true_for_valid_input(void** state)
|
||||
{
|
||||
int value;
|
||||
gchar* err_msg = NULL;
|
||||
gboolean result;
|
||||
@@ -404,7 +410,9 @@ void strtoi_range__returns__true_for_valid_input(void** state) {
|
||||
assert_null(err_msg);
|
||||
}
|
||||
|
||||
void strtoi_range__returns__false_for_out_of_range(void** state) {
|
||||
void
|
||||
strtoi_range__returns__false_for_out_of_range(void** state)
|
||||
{
|
||||
int value;
|
||||
gchar* err_msg = NULL;
|
||||
gboolean result;
|
||||
@@ -431,7 +439,9 @@ void strtoi_range__returns__false_for_out_of_range(void** state) {
|
||||
err_msg = NULL;
|
||||
}
|
||||
|
||||
void strtoi_range__returns__false_for_invalid_input(void** state) {
|
||||
void
|
||||
strtoi_range__returns__false_for_invalid_input(void** state)
|
||||
{
|
||||
int value;
|
||||
gchar* err_msg = NULL;
|
||||
gboolean result;
|
||||
@@ -451,7 +461,9 @@ void strtoi_range__returns__false_for_invalid_input(void** state) {
|
||||
err_msg = NULL;
|
||||
}
|
||||
|
||||
void strtoi_range__returns__false_for_null_empty_input(void** state) {
|
||||
void
|
||||
strtoi_range__returns__false_for_null_empty_input(void** state)
|
||||
{
|
||||
int value;
|
||||
gchar* err_msg = NULL;
|
||||
gboolean result;
|
||||
@@ -471,7 +483,9 @@ void strtoi_range__returns__false_for_null_empty_input(void** state) {
|
||||
err_msg = NULL;
|
||||
}
|
||||
|
||||
void strtoi_range__returns__correct_values_when_err_msg_null(void** state) {
|
||||
void
|
||||
strtoi_range__returns__correct_values_when_err_msg_null(void** state)
|
||||
{
|
||||
int value;
|
||||
gboolean result;
|
||||
|
||||
@@ -485,7 +499,9 @@ void strtoi_range__returns__correct_values_when_err_msg_null(void** state) {
|
||||
assert_false(result);
|
||||
}
|
||||
|
||||
void string_to_verbosity__returns__correct_values(void** state) {
|
||||
void
|
||||
string_to_verbosity__returns__correct_values(void** state)
|
||||
{
|
||||
int verbosity;
|
||||
gchar* err_msg = NULL;
|
||||
gboolean result;
|
||||
@@ -495,52 +511,59 @@ void string_to_verbosity__returns__correct_values(void** state) {
|
||||
assert_true(result);
|
||||
assert_int_equal(0, verbosity);
|
||||
assert_null(err_msg);
|
||||
g_free(err_msg); err_msg = NULL; // Clear for next test
|
||||
g_free(err_msg);
|
||||
err_msg = NULL; // Clear for next test
|
||||
|
||||
// Valid input string (1)
|
||||
result = string_to_verbosity("1", &verbosity, &err_msg);
|
||||
assert_true(result);
|
||||
assert_int_equal(1, verbosity);
|
||||
assert_null(err_msg);
|
||||
g_free(err_msg); err_msg = NULL;
|
||||
g_free(err_msg);
|
||||
err_msg = NULL;
|
||||
|
||||
// Valid input string (3)
|
||||
result = string_to_verbosity("3", &verbosity, &err_msg);
|
||||
assert_true(result);
|
||||
assert_int_equal(3, verbosity);
|
||||
assert_null(err_msg);
|
||||
g_free(err_msg); err_msg = NULL;
|
||||
g_free(err_msg);
|
||||
err_msg = NULL;
|
||||
|
||||
// Invalid input string (not a number)
|
||||
result = string_to_verbosity("profanity", &verbosity, &err_msg);
|
||||
assert_false(result);
|
||||
assert_string_equal("Could not convert \"profanity\" to a number.", err_msg);
|
||||
g_free(err_msg);
|
||||
err_msg = NULL;
|
||||
err_msg = NULL;
|
||||
|
||||
// Valid input string, out of range (too low)
|
||||
result = string_to_verbosity("-1", &verbosity, &err_msg);
|
||||
assert_false(result);
|
||||
assert_string_equal("Value -1 out of range. Must be in 0..3.", err_msg);
|
||||
g_free(err_msg); err_msg = NULL;
|
||||
g_free(err_msg);
|
||||
err_msg = NULL;
|
||||
|
||||
// Valid input string, out of range (too high)
|
||||
result = string_to_verbosity("4", &verbosity, &err_msg);
|
||||
assert_false(result);
|
||||
assert_string_equal("Value 4 out of range. Must be in 0..3.", err_msg);
|
||||
g_free(err_msg); err_msg = NULL;
|
||||
g_free(err_msg);
|
||||
err_msg = NULL;
|
||||
|
||||
// NULL input string
|
||||
result = string_to_verbosity(NULL, &verbosity, &err_msg);
|
||||
assert_false(result);
|
||||
assert_string_equal("'str' input pointer can not be NULL", err_msg);
|
||||
g_free(err_msg); err_msg = NULL;
|
||||
g_free(err_msg);
|
||||
err_msg = NULL;
|
||||
|
||||
// Empty input string
|
||||
result = string_to_verbosity("", &verbosity, &err_msg);
|
||||
assert_false(result);
|
||||
assert_string_equal("Could not convert \"\" to a number.", err_msg);
|
||||
g_free(err_msg); err_msg = NULL;
|
||||
g_free(err_msg);
|
||||
err_msg = NULL;
|
||||
|
||||
// err_msg is NULL
|
||||
result = string_to_verbosity("abc", &verbosity, NULL);
|
||||
@@ -874,66 +897,83 @@ get_mentions__tests__various(void** state)
|
||||
expected = g_slist_append(expected, GINT_TO_POINTER(6));
|
||||
actual = get_mentions(FALSE, TRUE, "hello boothj5", "boothj5");
|
||||
assert_true(_lists_equal(actual, expected));
|
||||
g_slist_free(actual); actual = NULL;
|
||||
g_slist_free(expected); expected = NULL;
|
||||
g_slist_free(actual);
|
||||
actual = NULL;
|
||||
g_slist_free(expected);
|
||||
expected = NULL;
|
||||
|
||||
// Case insensitive match
|
||||
expected = g_slist_append(expected, GINT_TO_POINTER(6));
|
||||
actual = get_mentions(FALSE, FALSE, "hello BOOTHJ5", "boothj5");
|
||||
assert_true(_lists_equal(actual, expected));
|
||||
g_slist_free(actual); actual = NULL;
|
||||
g_slist_free(expected); expected = NULL;
|
||||
g_slist_free(actual);
|
||||
actual = NULL;
|
||||
g_slist_free(expected);
|
||||
expected = NULL;
|
||||
|
||||
// Whole word match
|
||||
expected = g_slist_append(expected, GINT_TO_POINTER(0));
|
||||
actual = get_mentions(TRUE, TRUE, "boothj5 hello", "boothj5");
|
||||
assert_true(_lists_equal(actual, expected));
|
||||
g_slist_free(actual); actual = NULL;
|
||||
g_slist_free(expected); expected = NULL;
|
||||
g_slist_free(actual);
|
||||
actual = NULL;
|
||||
g_slist_free(expected);
|
||||
expected = NULL;
|
||||
|
||||
// Whole word no match (partial)
|
||||
actual = get_mentions(TRUE, TRUE, "boothj5hello", "boothj5");
|
||||
assert_true(_lists_equal(actual, expected)); // expected is NULL
|
||||
g_slist_free(actual); actual = NULL;
|
||||
g_slist_free(actual);
|
||||
actual = NULL;
|
||||
|
||||
// Multiple matches
|
||||
expected = g_slist_append(expected, GINT_TO_POINTER(0));
|
||||
expected = g_slist_append(expected, GINT_TO_POINTER(14));
|
||||
actual = get_mentions(FALSE, TRUE, "boothj5 hello boothj5", "boothj5");
|
||||
assert_true(_lists_equal(actual, expected));
|
||||
g_slist_free(actual); actual = NULL;
|
||||
g_slist_free(expected); expected = NULL;
|
||||
g_slist_free(actual);
|
||||
actual = NULL;
|
||||
g_slist_free(expected);
|
||||
expected = NULL;
|
||||
|
||||
// Nick with punctuation (whole word)
|
||||
expected = g_slist_append(expected, GINT_TO_POINTER(0));
|
||||
actual = get_mentions(TRUE, TRUE, "boothj5: hi", "boothj5");
|
||||
assert_true(_lists_equal(actual, expected));
|
||||
g_slist_free(actual); actual = NULL;
|
||||
g_slist_free(expected); expected = NULL;
|
||||
g_slist_free(actual);
|
||||
actual = NULL;
|
||||
g_slist_free(expected);
|
||||
expected = NULL;
|
||||
|
||||
// Nick surrounded by punctuation
|
||||
expected = g_slist_append(expected, GINT_TO_POINTER(1));
|
||||
actual = get_mentions(TRUE, TRUE, "(boothj5)", "boothj5");
|
||||
assert_true(_lists_equal(actual, expected));
|
||||
g_slist_free(actual); actual = NULL;
|
||||
g_slist_free(expected); expected = NULL;
|
||||
g_slist_free(actual);
|
||||
actual = NULL;
|
||||
g_slist_free(expected);
|
||||
expected = NULL;
|
||||
|
||||
// Empty message
|
||||
actual = get_mentions(FALSE, TRUE, "", "boothj5");
|
||||
assert_true(_lists_equal(actual, expected)); // expected is NULL
|
||||
g_slist_free(actual); actual = NULL;
|
||||
g_slist_free(actual);
|
||||
actual = NULL;
|
||||
|
||||
// Empty nick
|
||||
actual = get_mentions(FALSE, TRUE, "hello", "");
|
||||
assert_true(_lists_equal(actual, expected)); // expected is NULL
|
||||
g_slist_free(actual); actual = NULL;
|
||||
g_slist_free(actual);
|
||||
actual = NULL;
|
||||
|
||||
// UTF-8 characters
|
||||
expected = g_slist_append(expected, GINT_TO_POINTER(0));
|
||||
actual = get_mentions(TRUE, TRUE, "我能 hello", "我能");
|
||||
assert_true(_lists_equal(actual, expected));
|
||||
g_slist_free(actual); actual = NULL;
|
||||
g_slist_free(expected); expected = NULL;
|
||||
g_slist_free(actual);
|
||||
actual = NULL;
|
||||
g_slist_free(expected);
|
||||
expected = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -962,9 +1002,9 @@ release_is_new__tests__various(void** state)
|
||||
assert_true(release_is_new("1.2.3", "2.0.0"));
|
||||
|
||||
// Malformed version strings
|
||||
assert_false(release_is_new("0.16.0", "0.16")); // Missing patch in found
|
||||
assert_false(release_is_new("0.16", "0.16.0")); // Missing patch in curr
|
||||
assert_false(release_is_new("0.16.0", "0.16.0.1")); // Extra part
|
||||
assert_false(release_is_new("0.16.0", "0.16")); // Missing patch in found
|
||||
assert_false(release_is_new("0.16", "0.16.0")); // Missing patch in curr
|
||||
assert_false(release_is_new("0.16.0", "0.16.0.1")); // Extra part
|
||||
|
||||
assert_false(release_is_new("0.16.0", "abc.def.ghi"));
|
||||
assert_false(release_is_new("0.16.0", ""));
|
||||
@@ -1175,7 +1215,9 @@ prof_occurrences__tests__whole(void** state)
|
||||
expected = NULL;
|
||||
}
|
||||
|
||||
void string_matches_one_of__tests__edge_cases(void** state) {
|
||||
void
|
||||
string_matches_one_of__tests__edge_cases(void** state)
|
||||
{
|
||||
// is is NULL, is_can_be_null is TRUE -> should return TRUE
|
||||
assert_true(string_matches_one_of(NULL, NULL, TRUE, "option1", "option2", NULL));
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ aesgcm_file_get(void* userdata)
|
||||
return NULL;
|
||||
};
|
||||
|
||||
void aesgcm_download_cancel_processes(ProfWin* window){};
|
||||
void aesgcm_download_add_download(AESGCMDownload* download){};
|
||||
void aesgcm_download_cancel_processes(ProfWin* window) {};
|
||||
void aesgcm_download_add_download(AESGCMDownload* download) {};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -27,7 +27,7 @@ http_file_get(void* userdata)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void http_download_cancel_processes(){};
|
||||
void http_download_add_download(){};
|
||||
void http_download_cancel_processes() {};
|
||||
void http_download_add_download() {};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -38,7 +38,7 @@ file_size(int filedes)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void http_upload_cancel_processes(){};
|
||||
void http_upload_add_upload(){};
|
||||
void http_upload_cancel_processes() {};
|
||||
void http_upload_add_upload() {};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -483,10 +483,10 @@ mucwin_unset_message_char(ProfMucWin* mucwin)
|
||||
{
|
||||
}
|
||||
|
||||
void win_update_entry_message(ProfWin* window, const char* const id, const char* const message){};
|
||||
void win_mark_received(ProfWin* window, const char* const id){};
|
||||
void win_print_http_transfer(ProfWin* window, const char* const message, char* id){};
|
||||
void win_print_loading_history(ProfWin* window){};
|
||||
void win_update_entry_message(ProfWin* window, const char* const id, const char* const message) {};
|
||||
void win_mark_received(ProfWin* window, const char* const id) {};
|
||||
void win_print_http_transfer(ProfWin* window, const char* const message, char* id) {};
|
||||
void win_print_loading_history(ProfWin* window) {};
|
||||
|
||||
void
|
||||
ui_show_roster(void)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include <glib.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
void avatar_pep_subscribe(void){};
|
||||
void avatar_pep_subscribe(void) {};
|
||||
|
||||
gboolean
|
||||
avatar_get_by_nick(const char* nick, gboolean open)
|
||||
|
||||
@@ -309,8 +309,8 @@ presence_sub_request_exists(const char* const bare_jid)
|
||||
}
|
||||
|
||||
// iq functions
|
||||
void iq_disable_carbons(){};
|
||||
void iq_enable_carbons(){};
|
||||
void iq_disable_carbons() {};
|
||||
void iq_enable_carbons() {};
|
||||
void
|
||||
iq_send_software_version(const char* const fulljid)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user