]> git.0d.be Git - empathy.git/commitdiff
add EmpathyChatroom tests
authorXavier Claessens <xclaesse@src.gnome.org>
Mon, 13 Oct 2008 07:53:36 +0000 (07:53 +0000)
committerXavier Claessens <xclaesse@src.gnome.org>
Mon, 13 Oct 2008 07:53:36 +0000 (07:53 +0000)
svn path=/trunk/; revision=1540

tests/Makefile.am
tests/check-empathy-chatroom.c [new file with mode: 0644]
tests/check-libempathy.h
tests/check-main.c

index 5f8cbb6e4da5cf6f97c3d5aad3a4200c2be2ee00..6709a6a40ecbd54b8953ce137e2e06d6ba0f90ae 100644 (file)
@@ -37,7 +37,8 @@ check_main_SOURCES =                             \
     check-irc-helper.c                           \
     check-empathy-irc-server.c                   \
     check-empathy-irc-network.c                  \
-    check-empathy-irc-network-manager.c
+    check-empathy-irc-network-manager.c          \
+    check-empathy-chatroom.c
 
 check_main_LDADD = \
     @CHECK_LIBS@ \
diff --git a/tests/check-empathy-chatroom.c b/tests/check-empathy-chatroom.c
new file mode 100644 (file)
index 0000000..5a696e7
--- /dev/null
@@ -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;
+}
index 0f9388dcff4e2b261768ebf4bbd67abde7beb1ca..48c58b81b2c1516062ff1f9af128dc6126c6b040 100644 (file)
@@ -5,5 +5,6 @@ TCase * make_empathy_utils_tcase (void);
 TCase * make_empathy_irc_server_tcase (void);
 TCase * make_empathy_irc_network_tcase (void);
 TCase * make_empathy_irc_network_manager_tcase (void);
+TCase * make_empathy_chatroom_tcase (void);
 
 #endif /* #ifndef __CHECK_LIBEMPATHY__ */
index f0e366d0394abc5399c72b90c0981e2bcdfeb306..9c497a7656f6ad5addffb1c283379e58922e9685 100644 (file)
@@ -19,6 +19,7 @@ make_libempathy_suite (void)
     suite_add_tcase (s, make_empathy_irc_server_tcase ());
     suite_add_tcase (s, make_empathy_irc_network_tcase ());
     suite_add_tcase (s, make_empathy_irc_network_manager_tcase ());
+    suite_add_tcase (s, make_empathy_chatroom_tcase ());
 
     return s;
 }