Updated Spanish translation
[empathy-mirror.git] / tests / check-empathy-chatroom.c
blob4d0b7e1ee318b3f49907bd7871f4eea418abdb5d
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <string.h>
5 #include <check.h>
6 #include "check-helpers.h"
7 #include "check-libempathy.h"
8 #include "check-empathy-helpers.h"
10 #include <libempathy/empathy-chatroom.h>
12 #if 0
13 static EmpathyChatroom *
14 create_chatroom (void)
16 EmpathyAccount *account;
17 EmpathyChatroom *chatroom;
19 account = get_test_account ();
20 chatroom = empathy_chatroom_new (account);
21 fail_if (chatroom == NULL);
23 return chatroom;
26 START_TEST (test_empathy_chatroom_new)
28 EmpathyChatroom *chatroom;
29 gboolean auto_connect, favorite;
31 chatroom = create_chatroom ();
32 fail_if (empathy_chatroom_get_auto_connect (chatroom));
33 g_object_get (chatroom,
34 "auto_connect", &auto_connect,
35 "favorite", &favorite,
36 NULL);
37 fail_if (auto_connect);
38 fail_if (favorite);
40 g_object_unref (empathy_chatroom_get_account (chatroom));
41 g_object_unref (chatroom);
43 END_TEST
45 START_TEST (test_favorite_and_auto_connect)
47 /* auto connect implies favorite */
48 EmpathyChatroom *chatroom;
49 gboolean auto_connect, favorite;
51 chatroom = create_chatroom ();
53 /* set auto_connect so favorite as a side effect */
54 empathy_chatroom_set_auto_connect (chatroom, TRUE);
55 fail_if (!empathy_chatroom_get_auto_connect (chatroom));
56 g_object_get (chatroom,
57 "auto_connect", &auto_connect,
58 "favorite", &favorite,
59 NULL);
60 fail_if (!auto_connect);
61 fail_if (!favorite);
63 /* Remove auto_connect. Chatroom is still favorite */
64 empathy_chatroom_set_auto_connect (chatroom, FALSE);
65 fail_if (empathy_chatroom_get_auto_connect (chatroom));
66 g_object_get (chatroom,
67 "auto_connect", &auto_connect,
68 "favorite", &favorite,
69 NULL);
70 fail_if (auto_connect);
71 fail_if (!favorite);
73 /* Remove favorite too now */
74 g_object_set (chatroom, "favorite", FALSE, NULL);
75 fail_if (empathy_chatroom_get_auto_connect (chatroom));
76 g_object_get (chatroom,
77 "auto_connect", &auto_connect,
78 "favorite", &favorite,
79 NULL);
80 fail_if (auto_connect);
81 fail_if (favorite);
83 /* Just add favorite but not auto-connect */
84 g_object_set (chatroom, "favorite", TRUE, NULL);
85 fail_if (empathy_chatroom_get_auto_connect (chatroom));
86 g_object_get (chatroom,
87 "auto_connect", &auto_connect,
88 "favorite", &favorite,
89 NULL);
90 fail_if (auto_connect);
91 fail_if (!favorite);
93 /* ... and re-add auto_connect */
94 g_object_set (chatroom, "auto_connect", TRUE, NULL);
95 fail_if (!empathy_chatroom_get_auto_connect (chatroom));
96 g_object_get (chatroom,
97 "auto_connect", &auto_connect,
98 "favorite", &favorite,
99 NULL);
100 fail_if (!auto_connect);
101 fail_if (!favorite);
103 /* Remove favorite remove auto_connect too */
104 g_object_set (chatroom, "favorite", FALSE, NULL);
105 fail_if (empathy_chatroom_get_auto_connect (chatroom));
106 g_object_get (chatroom,
107 "auto_connect", &auto_connect,
108 "favorite", &favorite,
109 NULL);
110 fail_if (auto_connect);
111 fail_if (favorite);
113 g_object_unref (empathy_chatroom_get_account (chatroom));
114 g_object_unref (chatroom);
116 END_TEST
118 static void
119 favorite_changed (EmpathyChatroom *chatroom,
120 GParamSpec *spec,
121 gboolean *changed)
123 *changed = TRUE;
126 START_TEST (test_change_favorite)
128 EmpathyChatroom *chatroom;
129 gboolean changed = FALSE;
131 chatroom = create_chatroom ();
133 g_signal_connect (chatroom, "notify::favorite", G_CALLBACK (favorite_changed),
134 &changed);
136 /* change favorite to TRUE */
137 g_object_set (chatroom, "favorite", TRUE, NULL);
138 fail_if (!changed);
140 changed = FALSE;
142 /* change favorite to FALSE */
143 g_object_set (chatroom, "favorite", FALSE, NULL);
144 fail_if (!changed);
146 END_TEST
147 #endif
149 TCase *
150 make_empathy_chatroom_tcase (void)
152 TCase *tc = tcase_create ("empathy-chatroom");
154 tcase_add_test (tc, test_empathy_chatroom_new);
155 tcase_add_test (tc, test_favorite_and_auto_connect);
156 tcase_add_test (tc, test_change_favorite);
158 return tc;