about summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2012-10-04 00:34:03 +0100
committerJames Booth <boothj5@gmail.com>2012-10-04 00:34:03 +0100
commit5b8599272a7b20b1f1b684f90f9b1fbbd584c18e (patch)
treedc048d704dec9ccd9b54d75cf81e64fe6494a63f /tests
parentf8de28232e353794617e402dc0ebf05b57728cc5 (diff)
downloadprofani-tty-5b8599272a7b20b1f1b684f90f9b1fbbd584c18e.tar.gz
Basic chat session states
Diffstat (limited to 'tests')
-rw-r--r--tests/test_chat_session.c62
1 files changed, 55 insertions, 7 deletions
diff --git a/tests/test_chat_session.c b/tests/test_chat_session.c
index 7c513fc7..0a4dd262 100644
--- a/tests/test_chat_session.c
+++ b/tests/test_chat_session.c
@@ -2,24 +2,72 @@
 #include <head-unit.h>
 #include "chat_session.h"
 
-void can_init(void)
+void setup(void)
 {
     chat_session_init();
-    assert_true(1);
 }
 
 void adding_new_sets_state_to_active(void)
 {
-    chat_session_init();
-    chat_session_new("prof1@panesar");
-    ChatSession session = chat_session_get("prof1@panesar");
+    chat_session_start("prof1@panesar");
+    chat_state_t state = chat_session_get_state("prof1@panesar");
+
+    assert_int_equals(ACTIVE, state);
+}
+
+void set_inactive(void)
+{
+    chat_session_start("prof2@panesar");
+    chat_session_set_state("prof2@panesar", INACTIVE);
+    chat_state_t state = chat_session_get_state("prof2@panesar");
+
+    assert_int_equals(INACTIVE, state);
+}
+
+void set_gone(void)
+{
+    chat_session_start("prof3@panesar");
+    chat_session_set_state("prof3@panesar", GONE);
+    chat_state_t state = chat_session_get_state("prof3@panesar");
+
+    assert_int_equals(GONE, state);
+}
+
+void set_composing(void)
+{
+    chat_session_start("prof4@panesar");
+    chat_session_set_state("prof4@panesar", COMPOSING);
+    chat_state_t state = chat_session_get_state("prof4@panesar");
+
+    assert_int_equals(COMPOSING, state);
+}
+
+void set_paused(void)
+{
+    chat_session_start("prof5@panesar");
+    chat_session_set_state("prof5@panesar", PAUSED);
+    chat_state_t state = chat_session_get_state("prof5@panesar");
+
+    assert_int_equals(PAUSED, state);
+}
+
+void end_session(void)
+{
+    chat_session_start(strdup("prof6@panesar"));
+    chat_session_end("prof6@panesar");
+    chat_state_t state = chat_session_get_state("prof5@panesat");
 
-    assert_int_equals(ACTIVE, chat_session_get_state(session));
+    assert_int_equals(SESSION_ERR, state);
 }
 
 void register_chat_session_tests(void)
 {
     TEST_MODULE("chat_session_tests");
-    TEST(can_init);
+    SETUP(setup);
     TEST(adding_new_sets_state_to_active);
+    TEST(set_inactive);
+    TEST(set_gone);
+    TEST(set_composing);
+    TEST(set_paused);
+    TEST(end_session);
 }
ofani-tty/blame/src/contact.h?id=576be7921d33863667661db268ea373e4d97b73c'>^
6e46e8fe ^
facb2a65 ^
8e90f7a4 ^
c5f76721 ^
8e90f7a4 ^
a84e4ade ^
8e90f7a4 ^
a84e4ade ^
8e90f7a4 ^
2f2fa8de ^
b5e06a07 ^
a0eda420 ^
d300e8e7 ^
a061b0d4 ^

8e90f7a4 ^
6794fb81 ^
a84e4ade ^
e955df88 ^
d017999a ^

9dd5456f ^
581c1e8b ^
383d91ec ^
5314e597 ^

6e46e8fe ^

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75