6 #include "check-helpers.h"
7 #include "check-libempathy.h"
8 #include "check-empathy-helpers.h"
10 #include <libempathy/empathy-chatroom.h>
12 static EmpathyChatroom
*
13 create_chatroom (void)
16 EmpathyChatroom
*chatroom
;
18 account
= get_test_account ();
19 chatroom
= empathy_chatroom_new (account
);
20 fail_if (chatroom
== NULL
);
25 START_TEST (test_empathy_chatroom_new
)
27 EmpathyChatroom
*chatroom
;
28 gboolean auto_connect
, favorite
;
30 chatroom
= create_chatroom ();
31 fail_if (empathy_chatroom_get_auto_connect (chatroom
));
32 g_object_get (chatroom
,
33 "auto_connect", &auto_connect
,
34 "favorite", &favorite
,
36 fail_if (auto_connect
);
39 g_object_unref (empathy_chatroom_get_account (chatroom
));
40 g_object_unref (chatroom
);
44 START_TEST (test_favorite_and_auto_connect
)
46 /* auto connect implies favorite */
47 EmpathyChatroom
*chatroom
;
48 gboolean auto_connect
, favorite
;
50 chatroom
= create_chatroom ();
52 /* set auto_connect so favorite as a side effect */
53 empathy_chatroom_set_auto_connect (chatroom
, TRUE
);
54 fail_if (!empathy_chatroom_get_auto_connect (chatroom
));
55 g_object_get (chatroom
,
56 "auto_connect", &auto_connect
,
57 "favorite", &favorite
,
59 fail_if (!auto_connect
);
62 /* Remove auto_connect. Chatroom is still favorite */
63 empathy_chatroom_set_auto_connect (chatroom
, FALSE
);
64 fail_if (empathy_chatroom_get_auto_connect (chatroom
));
65 g_object_get (chatroom
,
66 "auto_connect", &auto_connect
,
67 "favorite", &favorite
,
69 fail_if (auto_connect
);
72 /* Remove favorite too now */
73 g_object_set (chatroom
, "favorite", FALSE
, NULL
);
74 fail_if (empathy_chatroom_get_auto_connect (chatroom
));
75 g_object_get (chatroom
,
76 "auto_connect", &auto_connect
,
77 "favorite", &favorite
,
79 fail_if (auto_connect
);
82 /* Just add favorite but not auto-connect */
83 g_object_set (chatroom
, "favorite", TRUE
, NULL
);
84 fail_if (empathy_chatroom_get_auto_connect (chatroom
));
85 g_object_get (chatroom
,
86 "auto_connect", &auto_connect
,
87 "favorite", &favorite
,
89 fail_if (auto_connect
);
92 /* ... and re-add auto_connect */
93 g_object_set (chatroom
, "auto_connect", TRUE
, NULL
);
94 fail_if (!empathy_chatroom_get_auto_connect (chatroom
));
95 g_object_get (chatroom
,
96 "auto_connect", &auto_connect
,
97 "favorite", &favorite
,
99 fail_if (!auto_connect
);
102 /* Remove favorite remove auto_connect too */
103 g_object_set (chatroom
, "favorite", FALSE
, NULL
);
104 fail_if (empathy_chatroom_get_auto_connect (chatroom
));
105 g_object_get (chatroom
,
106 "auto_connect", &auto_connect
,
107 "favorite", &favorite
,
109 fail_if (auto_connect
);
112 g_object_unref (empathy_chatroom_get_account (chatroom
));
113 g_object_unref (chatroom
);
118 favorite_changed (EmpathyChatroom
*chatroom
,
125 START_TEST (test_change_favorite
)
127 EmpathyChatroom
*chatroom
;
128 gboolean changed
= FALSE
;
130 chatroom
= create_chatroom ();
132 g_signal_connect (chatroom
, "notify::favorite", G_CALLBACK (favorite_changed
),
135 /* change favorite to TRUE */
136 g_object_set (chatroom
, "favorite", TRUE
, NULL
);
141 /* change favorite to FALSE */
142 g_object_set (chatroom
, "favorite", FALSE
, NULL
);
148 make_empathy_chatroom_tcase (void)
150 TCase
*tc
= tcase_create ("empathy-chatroom");
151 tcase_add_test (tc
, test_empathy_chatroom_new
);
152 tcase_add_test (tc
, test_favorite_and_auto_connect
);
153 tcase_add_test (tc
, test_change_favorite
);