Added ui_contact_online
This commit is contained in:
@@ -14,31 +14,19 @@
|
||||
#include "ui/stub_ui.h"
|
||||
#include "muc.h"
|
||||
|
||||
void console_doesnt_show_online_presence_when_set_none(void **state)
|
||||
{
|
||||
prefs_set_string(PREF_STATUSES_CONSOLE, "none");
|
||||
roster_init();
|
||||
roster_add("test1@server", "bob", NULL, "both", FALSE);
|
||||
Resource *resource = resource_new("resource", RESOURCE_ONLINE, NULL, 10);
|
||||
|
||||
sv_ev_contact_online("test1@server", resource, NULL);
|
||||
|
||||
roster_clear();
|
||||
}
|
||||
|
||||
void console_shows_online_presence_when_set_online(void **state)
|
||||
{
|
||||
prefs_set_string(PREF_STATUSES_CONSOLE, "online");
|
||||
roster_init();
|
||||
roster_add("test1@server", "bob", NULL, "both", FALSE);
|
||||
char *barejid = "test1@server";
|
||||
roster_add(barejid, "bob", NULL, "both", FALSE);
|
||||
Resource *resource = resource_new("resource", RESOURCE_ONLINE, NULL, 10);
|
||||
PContact contact = roster_get_contact("test1@server");
|
||||
|
||||
expect_memory(cons_show_contact_online, contact, contact, sizeof(contact));
|
||||
expect_memory(cons_show_contact_online, resource, resource, sizeof(resource));
|
||||
expect_value(cons_show_contact_online, last_activity, NULL);
|
||||
expect_memory(ui_contact_online, barejid, barejid, sizeof(barejid));
|
||||
expect_memory(ui_contact_online, resource, resource, sizeof(resource));
|
||||
expect_value(ui_contact_online, last_activity, NULL);
|
||||
|
||||
sv_ev_contact_online("test1@server", resource, NULL);
|
||||
sv_ev_contact_online(barejid, resource, NULL);
|
||||
|
||||
roster_clear();
|
||||
}
|
||||
@@ -47,39 +35,15 @@ void console_shows_online_presence_when_set_all(void **state)
|
||||
{
|
||||
prefs_set_string(PREF_STATUSES_CONSOLE, "all");
|
||||
roster_init();
|
||||
roster_add("test1@server", "bob", NULL, "both", FALSE);
|
||||
char *barejid = "test1@server";
|
||||
roster_add(barejid, "bob", NULL, "both", FALSE);
|
||||
Resource *resource = resource_new("resource", RESOURCE_ONLINE, NULL, 10);
|
||||
PContact contact = roster_get_contact("test1@server");
|
||||
|
||||
expect_memory(cons_show_contact_online, contact, contact, sizeof(contact));
|
||||
expect_memory(cons_show_contact_online, resource, resource, sizeof(resource));
|
||||
expect_value(cons_show_contact_online, last_activity, NULL);
|
||||
expect_memory(ui_contact_online, barejid, barejid, sizeof(barejid));
|
||||
expect_memory(ui_contact_online, resource, resource, sizeof(resource));
|
||||
expect_value(ui_contact_online, last_activity, NULL);
|
||||
|
||||
sv_ev_contact_online("test1@server", resource, NULL);
|
||||
|
||||
roster_clear();
|
||||
}
|
||||
|
||||
void console_doesnt_show_dnd_presence_when_set_none(void **state)
|
||||
{
|
||||
prefs_set_string(PREF_STATUSES_CONSOLE, "none");
|
||||
roster_init();
|
||||
roster_add("test1@server", "bob", NULL, "both", FALSE);
|
||||
Resource *resource = resource_new("resource", RESOURCE_DND, NULL, 10);
|
||||
|
||||
sv_ev_contact_online("test1@server", resource, NULL);
|
||||
|
||||
roster_clear();
|
||||
}
|
||||
|
||||
void console_doesnt_show_dnd_presence_when_set_online(void **state)
|
||||
{
|
||||
prefs_set_string(PREF_STATUSES_CONSOLE, "online");
|
||||
roster_init();
|
||||
roster_add("test1@server", "bob", NULL, "both", FALSE);
|
||||
Resource *resource = resource_new("resource", RESOURCE_DND, NULL, 10);
|
||||
|
||||
sv_ev_contact_online("test1@server", resource, NULL);
|
||||
sv_ev_contact_online(barejid, resource, NULL);
|
||||
|
||||
roster_clear();
|
||||
}
|
||||
@@ -88,15 +52,15 @@ void console_shows_dnd_presence_when_set_all(void **state)
|
||||
{
|
||||
prefs_set_string(PREF_STATUSES_CONSOLE, "all");
|
||||
roster_init();
|
||||
roster_add("test1@server", "bob", NULL, "both", FALSE);
|
||||
char *barejid = "test1@server";
|
||||
roster_add(barejid, "bob", NULL, "both", FALSE);
|
||||
Resource *resource = resource_new("resource", RESOURCE_ONLINE, NULL, 10);
|
||||
PContact contact = roster_get_contact("test1@server");
|
||||
|
||||
expect_memory(cons_show_contact_online, contact, contact, sizeof(contact));
|
||||
expect_memory(cons_show_contact_online, resource, resource, sizeof(resource));
|
||||
expect_value(cons_show_contact_online, last_activity, NULL);
|
||||
expect_memory(ui_contact_online, barejid, barejid, sizeof(barejid));
|
||||
expect_memory(ui_contact_online, resource, resource, sizeof(resource));
|
||||
expect_value(ui_contact_online, last_activity, NULL);
|
||||
|
||||
sv_ev_contact_online("test1@server", resource, NULL);
|
||||
sv_ev_contact_online(barejid, resource, NULL);
|
||||
|
||||
roster_clear();
|
||||
}
|
||||
|
||||
@@ -425,21 +425,12 @@ int main(int argc, char* argv[]) {
|
||||
load_preferences,
|
||||
close_preferences),
|
||||
|
||||
unit_test_setup_teardown(console_doesnt_show_online_presence_when_set_none,
|
||||
load_preferences,
|
||||
close_preferences),
|
||||
unit_test_setup_teardown(console_shows_online_presence_when_set_online,
|
||||
load_preferences,
|
||||
close_preferences),
|
||||
unit_test_setup_teardown(console_shows_online_presence_when_set_all,
|
||||
load_preferences,
|
||||
close_preferences),
|
||||
unit_test_setup_teardown(console_doesnt_show_dnd_presence_when_set_none,
|
||||
load_preferences,
|
||||
close_preferences),
|
||||
unit_test_setup_teardown(console_doesnt_show_dnd_presence_when_set_online,
|
||||
load_preferences,
|
||||
close_preferences),
|
||||
unit_test_setup_teardown(console_shows_dnd_presence_when_set_all,
|
||||
load_preferences,
|
||||
close_preferences),
|
||||
|
||||
@@ -185,6 +185,13 @@ char * ui_ask_password(void)
|
||||
void ui_handle_stanza(const char * const msg) {}
|
||||
|
||||
// ui events
|
||||
void ui_contact_online(char *barejid, Resource *resource, GDateTime *last_activity)
|
||||
{
|
||||
check_expected(barejid);
|
||||
check_expected(resource);
|
||||
check_expected(last_activity);
|
||||
}
|
||||
|
||||
void ui_contact_typing(const char * const barejid, const char * const resource) {}
|
||||
void ui_incoming_msg(const char * const from, const char * const resource, const char * const message, GTimeVal *tv_stamp) {}
|
||||
void ui_message_receipt(const char * const barejid, const char * const id) {}
|
||||
|
||||
Reference in New Issue
Block a user