Don't display the salut page if there is no need to create the account
[empathy-mirror.git] / tests / empathy-chatroom-test.c
blob3826411a52430b9e731917a7c08af1d919d89e21
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <string.h>
5 #include "test-helper.h"
7 #include <libempathy/empathy-chatroom.h>
9 #if 0
10 static EmpathyChatroom *
11 create_chatroom (void)
13 EmpathyAccount *account;
14 EmpathyChatroom *chatroom;
16 account = get_test_account ();
17 chatroom = empathy_chatroom_new (account);
18 fail_if (chatroom == NULL);
20 return chatroom;
23 START_TEST (test_empathy_chatroom_new)
25 EmpathyChatroom *chatroom;
26 gboolean auto_connect, favorite;
28 chatroom = create_chatroom ();
29 fail_if (empathy_chatroom_get_auto_connect (chatroom));
30 g_object_get (chatroom,
31 "auto_connect", &auto_connect,
32 "favorite", &favorite,
33 NULL);
34 fail_if (auto_connect);
35 fail_if (favorite);
37 g_object_unref (empathy_chatroom_get_account (chatroom));
38 g_object_unref (chatroom);
40 END_TEST
42 START_TEST (test_favorite_and_auto_connect)
44 /* auto connect implies favorite */
45 EmpathyChatroom *chatroom;
46 gboolean auto_connect, favorite;
48 chatroom = create_chatroom ();
50 /* set auto_connect so favorite as a side effect */
51 empathy_chatroom_set_auto_connect (chatroom, TRUE);
52 fail_if (!empathy_chatroom_get_auto_connect (chatroom));
53 g_object_get (chatroom,
54 "auto_connect", &auto_connect,
55 "favorite", &favorite,
56 NULL);
57 fail_if (!auto_connect);
58 fail_if (!favorite);
60 /* Remove auto_connect. Chatroom is still favorite */
61 empathy_chatroom_set_auto_connect (chatroom, FALSE);
62 fail_if (empathy_chatroom_get_auto_connect (chatroom));
63 g_object_get (chatroom,
64 "auto_connect", &auto_connect,
65 "favorite", &favorite,
66 NULL);
67 fail_if (auto_connect);
68 fail_if (!favorite);
70 /* Remove favorite too now */
71 g_object_set (chatroom, "favorite", FALSE, NULL);
72 fail_if (empathy_chatroom_get_auto_connect (chatroom));
73 g_object_get (chatroom,
74 "auto_connect", &auto_connect,
75 "favorite", &favorite,
76 NULL);
77 fail_if (auto_connect);
78 fail_if (favorite);
80 /* Just add favorite but not auto-connect */
81 g_object_set (chatroom, "favorite", TRUE, NULL);
82 fail_if (empathy_chatroom_get_auto_connect (chatroom));
83 g_object_get (chatroom,
84 "auto_connect", &auto_connect,
85 "favorite", &favorite,
86 NULL);
87 fail_if (auto_connect);
88 fail_if (!favorite);
90 /* ... and re-add auto_connect */
91 g_object_set (chatroom, "auto_connect", TRUE, NULL);
92 fail_if (!empathy_chatroom_get_auto_connect (chatroom));
93 g_object_get (chatroom,
94 "auto_connect", &auto_connect,
95 "favorite", &favorite,
96 NULL);
97 fail_if (!auto_connect);
98 fail_if (!favorite);
100 /* Remove favorite remove auto_connect too */
101 g_object_set (chatroom, "favorite", FALSE, NULL);
102 fail_if (empathy_chatroom_get_auto_connect (chatroom));
103 g_object_get (chatroom,
104 "auto_connect", &auto_connect,
105 "favorite", &favorite,
106 NULL);
107 fail_if (auto_connect);
108 fail_if (favorite);
110 g_object_unref (empathy_chatroom_get_account (chatroom));
111 g_object_unref (chatroom);
113 END_TEST
115 static void
116 favorite_changed (EmpathyChatroom *chatroom,
117 GParamSpec *spec,
118 gboolean *changed)
120 *changed = TRUE;
123 START_TEST (test_change_favorite)
125 EmpathyChatroom *chatroom;
126 gboolean changed = FALSE;
128 chatroom = create_chatroom ();
130 g_signal_connect (chatroom, "notify::favorite", G_CALLBACK (favorite_changed),
131 &changed);
133 /* change favorite to TRUE */
134 g_object_set (chatroom, "favorite", TRUE, NULL);
135 fail_if (!changed);
137 changed = FALSE;
139 /* change favorite to FALSE */
140 g_object_set (chatroom, "favorite", FALSE, NULL);
141 fail_if (!changed);
143 END_TEST
144 #endif
147 main (int argc,
148 char **argv)
150 int result;
152 test_init (argc, argv);
154 #if 0
155 g_test_add_func ("/chatroom/new", test_empathy_chatroom_new);
156 g_test_add_func ("/chatroom/favorite-and-auto-connect",
157 test_favorite_and_auto_connect);
158 g_test_add_func ("/chatroom/change-favorite", test_change_favorite);
159 #endif
161 result = g_test_run ();
162 test_deinit ();
163 return result;