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