]> git.0d.be Git - empathy.git/blob - tests/empathy-chatroom-test.c
Merge branch 'gnome-3-8'
[empathy.git] / tests / empathy-chatroom-test.c
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <string.h>
4
5 #include "test-helper.h"
6 #include "empathy-chatroom.h"
7
8 #if 0
9 static EmpathyChatroom *
10 create_chatroom (void)
11 {
12   EmpathyAccount *account;
13   EmpathyChatroom *chatroom;
14
15   account = get_test_account ();
16   chatroom = empathy_chatroom_new (account);
17   fail_if (chatroom == NULL);
18
19   return chatroom;
20 }
21
22 START_TEST (test_empathy_chatroom_new)
23 {
24   EmpathyChatroom *chatroom;
25   gboolean auto_connect, favorite;
26
27   chatroom = create_chatroom ();
28   fail_if (empathy_chatroom_get_auto_connect (chatroom));
29   g_object_get (chatroom,
30       "auto_connect", &auto_connect,
31       "favorite", &favorite,
32       NULL);
33   fail_if (auto_connect);
34   fail_if (favorite);
35
36   g_object_unref (empathy_chatroom_get_account (chatroom));
37   g_object_unref (chatroom);
38 }
39 END_TEST
40
41 START_TEST (test_favorite_and_auto_connect)
42 {
43   /* auto connect implies favorite */
44   EmpathyChatroom *chatroom;
45   gboolean auto_connect, favorite;
46
47   chatroom = create_chatroom ();
48
49   /* set auto_connect so favorite as a side effect */
50   empathy_chatroom_set_auto_connect (chatroom, TRUE);
51   fail_if (!empathy_chatroom_get_auto_connect (chatroom));
52   g_object_get (chatroom,
53       "auto_connect", &auto_connect,
54       "favorite", &favorite,
55       NULL);
56   fail_if (!auto_connect);
57   fail_if (!favorite);
58
59   /* Remove auto_connect. Chatroom is still favorite */
60   empathy_chatroom_set_auto_connect (chatroom, FALSE);
61   fail_if (empathy_chatroom_get_auto_connect (chatroom));
62   g_object_get (chatroom,
63       "auto_connect", &auto_connect,
64       "favorite", &favorite,
65       NULL);
66   fail_if (auto_connect);
67   fail_if (!favorite);
68
69   /* Remove favorite too now */
70   g_object_set (chatroom, "favorite", FALSE, NULL);
71   fail_if (empathy_chatroom_get_auto_connect (chatroom));
72   g_object_get (chatroom,
73       "auto_connect", &auto_connect,
74       "favorite", &favorite,
75       NULL);
76   fail_if (auto_connect);
77   fail_if (favorite);
78
79   /* Just add favorite but not auto-connect */
80   g_object_set (chatroom, "favorite", TRUE, NULL);
81   fail_if (empathy_chatroom_get_auto_connect (chatroom));
82   g_object_get (chatroom,
83       "auto_connect", &auto_connect,
84       "favorite", &favorite,
85       NULL);
86   fail_if (auto_connect);
87   fail_if (!favorite);
88
89   /* ... and re-add auto_connect */
90   g_object_set (chatroom, "auto_connect", TRUE, NULL);
91   fail_if (!empathy_chatroom_get_auto_connect (chatroom));
92   g_object_get (chatroom,
93       "auto_connect", &auto_connect,
94       "favorite", &favorite,
95       NULL);
96   fail_if (!auto_connect);
97   fail_if (!favorite);
98
99   /* Remove favorite remove auto_connect too */
100   g_object_set (chatroom, "favorite", FALSE, NULL);
101   fail_if (empathy_chatroom_get_auto_connect (chatroom));
102   g_object_get (chatroom,
103       "auto_connect", &auto_connect,
104       "favorite", &favorite,
105       NULL);
106   fail_if (auto_connect);
107   fail_if (favorite);
108
109   g_object_unref (empathy_chatroom_get_account (chatroom));
110   g_object_unref (chatroom);
111 }
112 END_TEST
113
114 static void
115 favorite_changed (EmpathyChatroom *chatroom,
116                   GParamSpec *spec,
117                   gboolean *changed)
118 {
119   *changed = TRUE;
120 }
121
122 START_TEST (test_change_favorite)
123 {
124   EmpathyChatroom *chatroom;
125   gboolean changed = FALSE;
126
127   chatroom = create_chatroom ();
128
129   g_signal_connect (chatroom, "notify::favorite", G_CALLBACK (favorite_changed),
130       &changed);
131
132   /* change favorite to TRUE */
133   g_object_set (chatroom, "favorite", TRUE, NULL);
134   fail_if (!changed);
135
136   changed = FALSE;
137
138   /* change favorite to FALSE */
139   g_object_set (chatroom, "favorite", FALSE, NULL);
140   fail_if (!changed);
141 }
142 END_TEST
143 #endif
144
145 int
146 main (int argc,
147     char **argv)
148 {
149   int result;
150
151   test_init (argc, argv);
152
153 #if 0
154   g_test_add_func ("/chatroom/new", test_empathy_chatroom_new);
155   g_test_add_func ("/chatroom/favorite-and-auto-connect",
156       test_favorite_and_auto_connect);
157   g_test_add_func ("/chatroom/change-favorite", test_change_favorite);
158 #endif
159
160   result = g_test_run ();
161   test_deinit ();
162   return result;
163 }