7 #include "test-helper.h"
8 #include "empathy-chatroom.h"
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
);
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
,
35 fail_if (auto_connect
);
38 g_object_unref (empathy_chatroom_get_account (chatroom
));
39 g_object_unref (chatroom
);
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
,
58 fail_if (!auto_connect
);
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
,
68 fail_if (auto_connect
);
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
,
78 fail_if (auto_connect
);
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
,
88 fail_if (auto_connect
);
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
,
98 fail_if (!auto_connect
);
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
,
108 fail_if (auto_connect
);
111 g_object_unref (empathy_chatroom_get_account (chatroom
));
112 g_object_unref (chatroom
);
117 favorite_changed (EmpathyChatroom
*chatroom
,
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
),
134 /* change favorite to TRUE */
135 g_object_set (chatroom
, "favorite", TRUE
, NULL
);
140 /* change favorite to FALSE */
141 g_object_set (chatroom
, "favorite", FALSE
, NULL
);
153 test_init (argc
, argv
);
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
);
162 result
= g_test_run ();