aboutsummaryrefslogtreecommitdiffstats
path: root/tests/check-empathy-chatroom.c
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@src.gnome.org>2008-10-13 15:53:36 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2008-10-13 15:53:36 +0800
commitb10ced9f645ddce18011e6ba04e98f557c382491 (patch)
tree4391ed1783bd806df1f3f7ae4dcfd064b5664194 /tests/check-empathy-chatroom.c
parentc1a9949c8c94bf7392b99320d0ead6836d429293 (diff)
downloadgsoc2013-empathy-b10ced9f645ddce18011e6ba04e98f557c382491.tar
gsoc2013-empathy-b10ced9f645ddce18011e6ba04e98f557c382491.tar.gz
gsoc2013-empathy-b10ced9f645ddce18011e6ba04e98f557c382491.tar.bz2
gsoc2013-empathy-b10ced9f645ddce18011e6ba04e98f557c382491.tar.lz
gsoc2013-empathy-b10ced9f645ddce18011e6ba04e98f557c382491.tar.xz
gsoc2013-empathy-b10ced9f645ddce18011e6ba04e98f557c382491.tar.zst
gsoc2013-empathy-b10ced9f645ddce18011e6ba04e98f557c382491.zip
add EmpathyChatroom tests
svn path=/trunk/; revision=1540
Diffstat (limited to 'tests/check-empathy-chatroom.c')
-rw-r--r--tests/check-empathy-chatroom.c128
1 files changed, 128 insertions, 0 deletions
diff --git a/tests/check-empathy-chatroom.c b/tests/check-empathy-chatroom.c
new file mode 100644
index 000000000..5a696e7aa
--- /dev/null
+++ b/tests/check-empathy-chatroom.c
@@ -0,0 +1,128 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <check.h>
+#include "check-helpers.h"
+#include "check-libempathy.h"
+
+#include <libempathy/empathy-chatroom.h>
+
+static EmpathyChatroom *
+create_chatroom (void)
+{
+ McProfile *profile;
+ McAccount *account;
+ EmpathyChatroom *chatroom;
+
+ /* FIXME: we should fake the profile */
+ profile = mc_profile_lookup ("jabber");
+ account = mc_account_create (profile);
+ chatroom = empathy_chatroom_new (account);
+ fail_if (chatroom == NULL);
+
+ g_object_unref (profile);
+
+ return chatroom;
+}
+
+START_TEST (test_empathy_chatroom_new)
+{
+ EmpathyChatroom *chatroom;
+ gboolean auto_connect, favorite;
+
+ chatroom = create_chatroom ();
+ fail_if (empathy_chatroom_get_auto_connect (chatroom));
+ g_object_get (chatroom,
+ "auto_connect", &auto_connect,
+ "favorite", &favorite,
+ NULL);
+ fail_if (auto_connect);
+ fail_if (favorite);
+
+ g_object_unref (chatroom);
+ /* FIXME: unref the account ? */
+}
+END_TEST
+
+START_TEST (test_favorite_and_auto_connect)
+{
+ /* auto connect implies favorite */
+ EmpathyChatroom *chatroom;
+ gboolean auto_connect, favorite;
+
+ chatroom = create_chatroom ();
+
+ /* set auto_connect so favorite as a side effect */
+ empathy_chatroom_set_auto_connect (chatroom, TRUE);
+ fail_if (!empathy_chatroom_get_auto_connect (chatroom));
+ g_object_get (chatroom,
+ "auto_connect", &auto_connect,
+ "favorite", &favorite,
+ NULL);
+ fail_if (!auto_connect);
+ fail_if (!favorite);
+
+ /* Remove auto_connect. Chatroom is still favorite */
+ empathy_chatroom_set_auto_connect (chatroom, FALSE);
+ fail_if (empathy_chatroom_get_auto_connect (chatroom));
+ g_object_get (chatroom,
+ "auto_connect", &auto_connect,
+ "favorite", &favorite,
+ NULL);
+ fail_if (auto_connect);
+ fail_if (!favorite);
+
+ /* Remove favorite too now */
+ g_object_set (chatroom, "favorite", FALSE, NULL);
+ fail_if (empathy_chatroom_get_auto_connect (chatroom));
+ g_object_get (chatroom,
+ "auto_connect", &auto_connect,
+ "favorite", &favorite,
+ NULL);
+ fail_if (auto_connect);
+ fail_if (favorite);
+
+ /* Just add favorite but not auto-connect */
+ g_object_set (chatroom, "favorite", TRUE, NULL);
+ fail_if (empathy_chatroom_get_auto_connect (chatroom));
+ g_object_get (chatroom,
+ "auto_connect", &auto_connect,
+ "favorite", &favorite,
+ NULL);
+ fail_if (auto_connect);
+ fail_if (!favorite);
+
+ /* ... and re-add auto_connect */
+ g_object_set (chatroom, "auto_connect", TRUE, NULL);
+ fail_if (!empathy_chatroom_get_auto_connect (chatroom));
+ g_object_get (chatroom,
+ "auto_connect", &auto_connect,
+ "favorite", &favorite,
+ NULL);
+ fail_if (!auto_connect);
+ fail_if (!favorite);
+
+ /* Remove favorite remove auto_connect too */
+ g_object_set (chatroom, "favorite", FALSE, NULL);
+ fail_if (empathy_chatroom_get_auto_connect (chatroom));
+ g_object_get (chatroom,
+ "auto_connect", &auto_connect,
+ "favorite", &favorite,
+ NULL);
+ fail_if (auto_connect);
+ fail_if (favorite);
+
+ g_object_unref (chatroom);
+ /* FIXME: unref the account ? */
+}
+END_TEST
+
+TCase *
+make_empathy_chatroom_tcase (void)
+{
+ TCase *tc = tcase_create ("empathy-chatroom");
+ tcase_add_test (tc, test_empathy_chatroom_new);
+ tcase_add_test (tc, test_favorite_and_auto_connect);
+ return tc;
+}