6 #include "check-helpers.h"
7 #include "check-libempathy.h"
9 #include <libempathy/empathy-chatroom.h>
11 static EmpathyChatroom *
12 create_chatroom (void)
16 EmpathyChatroom *chatroom;
18 profile = mc_profile_lookup ("test");
19 account = mc_account_create (profile);
20 chatroom = empathy_chatroom_new (account);
21 fail_if (chatroom == NULL);
23 /* destroy the account as we don't have to add it to the accounts
25 /* FIXME: the account is not really removed */
26 mc_account_delete (account);
27 g_object_unref (profile);
28 g_object_unref (account);
33 START_TEST (test_empathy_chatroom_new)
35 EmpathyChatroom *chatroom;
36 gboolean auto_connect, favorite;
38 chatroom = create_chatroom ();
39 fail_if (empathy_chatroom_get_auto_connect (chatroom));
40 g_object_get (chatroom,
41 "auto_connect", &auto_connect,
42 "favorite", &favorite,
44 fail_if (auto_connect);
47 g_object_unref (chatroom);
51 START_TEST (test_favorite_and_auto_connect)
53 /* auto connect implies favorite */
54 EmpathyChatroom *chatroom;
55 gboolean auto_connect, favorite;
57 chatroom = create_chatroom ();
59 /* set auto_connect so favorite as a side effect */
60 empathy_chatroom_set_auto_connect (chatroom, TRUE);
61 fail_if (!empathy_chatroom_get_auto_connect (chatroom));
62 g_object_get (chatroom,
63 "auto_connect", &auto_connect,
64 "favorite", &favorite,
66 fail_if (!auto_connect);
69 /* Remove auto_connect. Chatroom is still favorite */
70 empathy_chatroom_set_auto_connect (chatroom, FALSE);
71 fail_if (empathy_chatroom_get_auto_connect (chatroom));
72 g_object_get (chatroom,
73 "auto_connect", &auto_connect,
74 "favorite", &favorite,
76 fail_if (auto_connect);
79 /* Remove favorite too now */
80 g_object_set (chatroom, "favorite", FALSE, NULL);
81 fail_if (empathy_chatroom_get_auto_connect (chatroom));
82 g_object_get (chatroom,
83 "auto_connect", &auto_connect,
84 "favorite", &favorite,
86 fail_if (auto_connect);
89 /* Just add favorite but not auto-connect */
90 g_object_set (chatroom, "favorite", TRUE, NULL);
91 fail_if (empathy_chatroom_get_auto_connect (chatroom));
92 g_object_get (chatroom,
93 "auto_connect", &auto_connect,
94 "favorite", &favorite,
96 fail_if (auto_connect);
99 /* ... and re-add auto_connect */
100 g_object_set (chatroom, "auto_connect", TRUE, NULL);
101 fail_if (!empathy_chatroom_get_auto_connect (chatroom));
102 g_object_get (chatroom,
103 "auto_connect", &auto_connect,
104 "favorite", &favorite,
106 fail_if (!auto_connect);
109 /* Remove favorite remove auto_connect too */
110 g_object_set (chatroom, "favorite", FALSE, NULL);
111 fail_if (empathy_chatroom_get_auto_connect (chatroom));
112 g_object_get (chatroom,
113 "auto_connect", &auto_connect,
114 "favorite", &favorite,
116 fail_if (auto_connect);
119 g_object_unref (chatroom);
124 make_empathy_chatroom_tcase (void)
126 TCase *tc = tcase_create ("empathy-chatroom");
127 tcase_add_test (tc, test_empathy_chatroom_new);
128 tcase_add_test (tc, test_favorite_and_auto_connect);