6
#include "check-helpers.h"
7
#include "check-libempathy.h"
8
#include "check-empathy-helpers.h"
10
#include <libempathy/empathy-chatroom.h>
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);
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,
37
fail_if (auto_connect);
40
g_object_unref (empathy_chatroom_get_account (chatroom));
41
g_object_unref (chatroom);
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,
60
fail_if (!auto_connect);
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,
70
fail_if (auto_connect);
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,
80
fail_if (auto_connect);
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,
90
fail_if (auto_connect);
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,
100
fail_if (!auto_connect);
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,
110
fail_if (auto_connect);
113
g_object_unref (empathy_chatroom_get_account (chatroom));
114
g_object_unref (chatroom);
119
favorite_changed (EmpathyChatroom *chatroom,
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),
136
/* change favorite to TRUE */
137
g_object_set (chatroom, "favorite", TRUE, NULL);
142
/* change favorite to FALSE */
143
g_object_set (chatroom, "favorite", FALSE, NULL);
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);