From a2c62117322eea58c17231c27c5ee3b41900ea81 Mon Sep 17 00:00:00 2001 From: James Booth Date: Thu, 7 May 2015 22:05:36 +0100 Subject: Added ui_contact_online --- tests/test_server_events.c | 72 ++++++++++++---------------------------------- 1 file changed, 18 insertions(+), 54 deletions(-) (limited to 'tests/test_server_events.c') diff --git a/tests/test_server_events.c b/tests/test_server_events.c index d87dc217..58489807 100644 --- a/tests/test_server_events.c +++ b/tests/test_server_events.c @@ -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); - - 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); + 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_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(); } -- cgit 1.4.1-2-gfad0