Help: Use stable 'if' namespace instead of experimental
[empathy-mirror.git] / tests / empathy-chatroom-test.c
blob26603b563152994a94fd2a7e4d3b250a99e5a0c0
1 #include "config.h"
3 #include <stdlib.h>
4 #include <stdio.h>
5 #include <string.h>
7 #include "test-helper.h"
8 #include "empathy-chatroom.h"
10 #if 0
11 static EmpathyChatroom *
12 create_chatroom (void)
14 EmpathyAccount *account;
15 EmpathyChatroom *chatroom;
17 account = get_test_account ();
18 chatroom = empathy_chatroom_new (account);
19 fail_if (chatroom == NULL);
21 return chatroom;
24 START_TEST (test_empathy_chatroom_new)
26 EmpathyChatroom *chatroom;
27 gboolean auto_connect, favorite;
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);
38 g_object_unref (empathy_chatroom_get_account (chatroom));
39 g_object_unref (chatroom);
41 END_TEST
43 START_TEST (test_favorite_and_auto_connect)
45 /* auto connect implies favorite */
46 EmpathyChatroom *chatroom;
47 gboolean auto_connect, favorite;
49 chatroom = create_chatroom ();
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);
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);
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);
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);
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);
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);
111 g_object_unref (empathy_chatroom_get_account (chatroom));
112 g_object_unref (chatroom);
114 END_TEST
116 static void
117 favorite_changed (EmpathyChatroom *chatroom,
118 GParamSpec *spec,
119 gboolean *changed)
121 *changed = TRUE;
124 START_TEST (test_change_favorite)
126 EmpathyChatroom *chatroom;
127 gboolean changed = FALSE;
129 chatroom = create_chatroom ();
131 g_signal_connect (chatroom, "notify::favorite", G_CALLBACK (favorite_changed),
132 &changed);
134 /* change favorite to TRUE */
135 g_object_set (chatroom, "favorite", TRUE, NULL);
136 fail_if (!changed);
138 changed = FALSE;
140 /* change favorite to FALSE */
141 g_object_set (chatroom, "favorite", FALSE, NULL);
142 fail_if (!changed);
144 END_TEST
145 #endif
148 main (int argc,
149 char **argv)
151 int result;
153 test_init (argc, argv);
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
162 result = g_test_run ();
163 test_deinit ();
164 return result;