about summary refs log tree commit diff stats
path: root/tests/test_server_events.c
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-05-07 22:05:36 +0100
committerJames Booth <boothj5@gmail.com>2015-05-07 22:05:36 +0100
commita2c62117322eea58c17231c27c5ee3b41900ea81 (patch)
tree0f0278419d0eb8d02c70fc6ca535124fecf186c3 /tests/test_server_events.c
parent6fd9b179a08126deb20d6efedac3089e9bf432cb (diff)
downloadprofani-tty-a2c62117322eea58c17231c27c5ee3b41900ea81.tar.gz
Added ui_contact_online
Diffstat (limited to 'tests/test_server_events.c')
-rw-r--r--tests/test_server_events.c72
1 files changed, 18 insertions, 54 deletions
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();
 }