about summary refs log tree commit diff stats
path: root/tests/test_chat_session.c
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-01-06 23:19:56 +0000
committerJames Booth <boothj5@gmail.com>2015-01-06 23:19:56 +0000
commit95ad5643725d1cc857454d47460091ca18cbb807 (patch)
tree424b86f34e596324feaeef3248fd873ae26ac8a8 /tests/test_chat_session.c
parent36790dc26bbd4d00702a75469980e7c9fbf1282d (diff)
downloadprofani-tty-95ad5643725d1cc857454d47460091ca18cbb807.tar.gz
Added offline handler for chat sessions
Diffstat (limited to 'tests/test_chat_session.c')
-rw-r--r--tests/test_chat_session.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/test_chat_session.c b/tests/test_chat_session.c
index a93c64b6..bcb8dcce 100644
--- a/tests/test_chat_session.c
+++ b/tests/test_chat_session.c
@@ -122,4 +122,42 @@ void removes_chat_session_on_cancel_for_fulljid(void **state)
     gboolean exists = chat_session_exists(barejid);
 
     assert_false(exists);
+}
+
+void removes_chat_session_on_offline_matching_resource(void **state)
+{
+    char *barejid = "myjid@server.org";
+    char *resource = "work";
+
+    chat_session_on_message_send(barejid);
+    chat_session_on_incoming_message(barejid, resource, TRUE);
+    chat_session_on_offline(barejid, resource);
+    gboolean exists = chat_session_exists(barejid);
+
+    assert_false(exists);
+}
+
+void does_not_remove_chat_session_on_offline_different_resource(void **state)
+{
+    char *barejid = "myjid@server.org";
+    char *resource = "work";
+    char *offline_resource = "home";
+
+    chat_session_on_message_send(barejid);
+    chat_session_on_incoming_message(barejid, resource, TRUE);
+    chat_session_on_offline(barejid, offline_resource);
+    gboolean exists = chat_session_exists(barejid);
+
+    assert_true(exists);
+}
+
+void does_not_remove_chat_session_on_offline_null_resource(void **state)
+{
+    char *barejid = "myjid@server.org";
+
+    chat_session_on_message_send(barejid);
+    chat_session_on_offline(barejid, NULL);
+    gboolean exists = chat_session_exists(barejid);
+
+    assert_true(exists);
 }
\ No newline at end of file