diff options
author | Xavier Claessens <xclaesse@src.gnome.org> | 2009-03-17 02:34:54 +0800 |
---|---|---|
committer | Xavier Claessens <xclaesse@src.gnome.org> | 2009-03-17 02:34:54 +0800 |
commit | 2baaa7ae3c3ac983a8019cd93a73426c7e081735 (patch) | |
tree | 482c49b5b4f5b3d6b4427642ba8609114503fade /gnome-2-26/tests | |
parent | bbacde3ff32a1983e7f37eea2986ccfe8f660f3f (diff) | |
download | gsoc2013-empathy-2baaa7ae3c3ac983a8019cd93a73426c7e081735.tar gsoc2013-empathy-2baaa7ae3c3ac983a8019cd93a73426c7e081735.tar.gz gsoc2013-empathy-2baaa7ae3c3ac983a8019cd93a73426c7e081735.tar.bz2 gsoc2013-empathy-2baaa7ae3c3ac983a8019cd93a73426c7e081735.tar.lz gsoc2013-empathy-2baaa7ae3c3ac983a8019cd93a73426c7e081735.tar.xz gsoc2013-empathy-2baaa7ae3c3ac983a8019cd93a73426c7e081735.tar.zst gsoc2013-empathy-2baaa7ae3c3ac983a8019cd93a73426c7e081735.zip |
Tagged for release 2.26.0.
svn path=/tags/EMPATHY_2_26_0/; revision=2700
Diffstat (limited to 'gnome-2-26/tests')
29 files changed, 3448 insertions, 0 deletions
diff --git a/gnome-2-26/tests/.gitignore b/gnome-2-26/tests/.gitignore new file mode 100644 index 000000000..08278b7bc --- /dev/null +++ b/gnome-2-26/tests/.gitignore @@ -0,0 +1,6 @@ +check-main +contact-manager +contact-run-until-ready +contact-run-until-ready-2 +*.log +empetit diff --git a/gnome-2-26/tests/Makefile.am b/gnome-2-26/tests/Makefile.am new file mode 100644 index 000000000..9a91e9d92 --- /dev/null +++ b/gnome-2-26/tests/Makefile.am @@ -0,0 +1,65 @@ +SUBDIRS = xml + +CLEANFILES= + +include $(top_srcdir)/rules/check.mak + +SUPPRESSIONS=valgrind.supp dlopen.supp + +EXTRA_DIST = \ + test.manager \ + test.profile + +AM_CPPFLAGS = \ + -I$(top_srcdir) \ + -DPKGDATADIR=\""$(pkgdatadir)"\" \ + $(EMPATHY_CFLAGS) \ + $(WARN_CFLAGS) + +LDADD = \ + $(top_builddir)/libempathy-gtk/libempathy-gtk.la \ + $(top_builddir)/libempathy/libempathy.la \ + $(EMPATHY_LIBS) + +noinst_PROGRAMS = \ + contact-manager \ + contact-run-until-ready \ + contact-run-until-ready-2 \ + empetit + +contact_manager_SOURCES = contact-manager.c +contact_run_until_ready_SOURCES = contact-run-until-ready.c +contact_run_until_ready_2_SOURCES = contact-run-until-ready-2.c +empetit_SOURCES = empetit.c + +check_PROGRAMS = check-main +TESTS = check-main +check_main_SOURCES = \ + check-main.c \ + check-helpers.c \ + check-helpers.h \ + check-libempathy.h \ + check-empathy-utils.c \ + check-empathy-helpers.h \ + check-empathy-helpers.c \ + check-irc-helper.h \ + check-irc-helper.c \ + check-empathy-irc-server.c \ + check-empathy-irc-network.c \ + check-empathy-irc-network-manager.c \ + check-empathy-chatroom.c \ + check-empathy-chatroom-manager.c + +check_main_LDADD = \ + @CHECK_LIBS@ \ + $(top_builddir)/libempathy-gtk/libempathy-gtk.la \ + $(top_builddir)/libempathy/libempathy.la \ + $(AM_LDFLAGS) + +check_main_CFLAGS = \ + @CHECK_CFLAGS@ \ + $(AM_CFLAGS) + +TESTS_ENVIRONMENT = EMPATHY_SRCDIR=@abs_top_srcdir@ \ + MC_PROFILE_DIR=@abs_top_srcdir@/tests \ + MC_MANAGER_DIR=@abs_top_srcdir@/tests diff --git a/gnome-2-26/tests/check-empathy-chatroom-manager.c b/gnome-2-26/tests/check-empathy-chatroom-manager.c new file mode 100644 index 000000000..ef5c77618 --- /dev/null +++ b/gnome-2-26/tests/check-empathy-chatroom-manager.c @@ -0,0 +1,385 @@ +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <glib/gstdio.h> + +#include <gconf/gconf.h> +#include <gconf/gconf-client.h> +#include <telepathy-glib/util.h> +#include <check.h> + +#include "check-helpers.h" +#include "check-libempathy.h" +#include "check-empathy-helpers.h" + +#include <libempathy/empathy-chatroom-manager.h> + +#define CHATROOM_SAMPLE "chatrooms-sample.xml" +#define CHATROOM_FILE "chatrooms.xml" + +static void +check_chatroom (EmpathyChatroom *chatroom, + const gchar *name, + const gchar *room, + gboolean auto_connect, + gboolean favorite) +{ + gboolean _favorite; + + fail_if (tp_strdiff (empathy_chatroom_get_name (chatroom), name)); + fail_if (tp_strdiff (empathy_chatroom_get_room (chatroom), room)); + fail_if (empathy_chatroom_get_auto_connect (chatroom) != auto_connect); + g_object_get (chatroom, "favorite", &_favorite, NULL); + fail_if (favorite != _favorite); +} + +struct chatroom_t +{ + gchar *name; + gchar *room; + gboolean auto_connect; + gboolean favorite; +}; + +static void +check_chatrooms_list (EmpathyChatroomManager *mgr, + McAccount *account, + struct chatroom_t *_chatrooms, + guint nb_chatrooms) +{ + GList *chatrooms, *l; + guint i; + GHashTable *found; + + fail_if (empathy_chatroom_manager_get_count (mgr, account) != nb_chatrooms); + + found = g_hash_table_new (g_str_hash, g_str_equal); + for (i = 0; i < nb_chatrooms; i++) + { + g_hash_table_insert (found, _chatrooms[i].room, &_chatrooms[i]); + } + + chatrooms = empathy_chatroom_manager_get_chatrooms (mgr, account); + fail_if (g_list_length (chatrooms) != nb_chatrooms); + + for (l = chatrooms; l != NULL; l = g_list_next (l)) + { + EmpathyChatroom *chatroom = l->data; + struct chatroom_t *tmp; + + tmp = g_hash_table_lookup (found, empathy_chatroom_get_room (chatroom)); + fail_if (tmp == NULL); + + check_chatroom (chatroom, tmp->name, tmp->room, tmp->auto_connect, + tmp->favorite); + + g_hash_table_remove (found, empathy_chatroom_get_room (chatroom)); + } + + fail_if (g_hash_table_size (found) != 0); + + g_list_free (chatrooms); + g_hash_table_destroy (found); +} + +static gboolean +change_account_name_in_file (McAccount *account, + const gchar *file) +{ + gchar *cmd; + + cmd = g_strdup_printf ("sed -i 's/CHANGE_ME/%s/' %s", + mc_account_get_unique_name (account), file); + + if (system (cmd) == -1) + { + g_print ("'%s' call failed\n", cmd); + g_free (cmd); + return FALSE; + } + + g_free (cmd); + return TRUE; +} + +START_TEST (test_empathy_chatroom_manager_dup_singleton) +{ + EmpathyChatroomManager *mgr; + gchar *file; + McAccount *account; + struct chatroom_t chatrooms[] = { + { "name1", "room1", TRUE, TRUE }, + { "name2", "room2", FALSE, TRUE }}; + + account = get_test_account (); + + copy_xml_file (CHATROOM_SAMPLE, CHATROOM_FILE); + + file = get_user_xml_file (CHATROOM_FILE); + + /* change the chatrooms XML file to use the account we just created */ + if (!change_account_name_in_file (account, file)) + return; + + mgr = empathy_chatroom_manager_dup_singleton (file); + check_chatrooms_list (mgr, account, chatrooms, 2); + + g_free (file); + g_object_unref (mgr); + g_object_unref (account); +} +END_TEST + +START_TEST (test_empathy_chatroom_manager_add) +{ + EmpathyChatroomManager *mgr; + gchar *file; + McAccount *account; + struct chatroom_t chatrooms[] = { + { "name1", "room1", TRUE, TRUE }, + { "name2", "room2", FALSE, TRUE }, + { "name3", "room3", FALSE, TRUE }, + { "name4", "room4", FALSE, FALSE }}; + EmpathyChatroom *chatroom; + + account = get_test_account (); + + copy_xml_file (CHATROOM_SAMPLE, CHATROOM_FILE); + + file = get_user_xml_file (CHATROOM_FILE); + + /* change the chatrooms XML file to use the account we just created */ + if (!change_account_name_in_file (account, file)) + return; + + mgr = empathy_chatroom_manager_dup_singleton (file); + + /* add a favorite chatroom */ + chatroom = empathy_chatroom_new_full (account, "room3", "name3", FALSE); + g_object_set (chatroom, "favorite", TRUE, NULL); + empathy_chatroom_manager_add (mgr, chatroom); + g_object_unref (chatroom); + + check_chatrooms_list (mgr, account, chatrooms, 3); + + /* reload chatrooms file */ + g_object_unref (mgr); + mgr = empathy_chatroom_manager_dup_singleton (file); + + /* chatroom has been added to the XML file as it's a favorite */ + check_chatrooms_list (mgr, account, chatrooms, 3); + + /* add a non favorite chatroom */ + chatroom = empathy_chatroom_new_full (account, "room4", "name4", FALSE); + g_object_set (chatroom, "favorite", FALSE, NULL); + empathy_chatroom_manager_add (mgr, chatroom); + g_object_unref (chatroom); + + check_chatrooms_list (mgr, account, chatrooms, 4); + + /* reload chatrooms file */ + g_object_unref (mgr); + mgr = empathy_chatroom_manager_dup_singleton (file); + + /* chatrooms has not been added to the XML file */ + check_chatrooms_list (mgr, account, chatrooms, 3); + + g_object_unref (mgr); + g_free (file); + g_object_unref (account); +} +END_TEST + +START_TEST (test_empathy_chatroom_manager_remove) +{ + EmpathyChatroomManager *mgr; + gchar *file; + McAccount *account; + struct chatroom_t chatrooms[] = { + { "name2", "room2", FALSE, TRUE }}; + EmpathyChatroom *chatroom; + + account = get_test_account (); + + copy_xml_file (CHATROOM_SAMPLE, CHATROOM_FILE); + + file = get_user_xml_file (CHATROOM_FILE); + + /* change the chatrooms XML file to use the account we just created */ + if (!change_account_name_in_file (account, file)) + return; + + mgr = empathy_chatroom_manager_dup_singleton (file); + + /* remove room1 */ + chatroom = empathy_chatroom_manager_find (mgr, account, "room1"); + fail_if (chatroom == NULL); + empathy_chatroom_manager_remove (mgr, chatroom); + + check_chatrooms_list (mgr, account, chatrooms, 1); + + /* reload chatrooms file */ + g_object_unref (mgr); + mgr = empathy_chatroom_manager_dup_singleton (file); + + check_chatrooms_list (mgr, account, chatrooms, 1); + + /* remove room1 */ + chatroom = empathy_chatroom_manager_find (mgr, account, "room2"); + fail_if (chatroom == NULL); + + empathy_chatroom_manager_remove (mgr, chatroom); + + check_chatrooms_list (mgr, account, chatrooms, 0); + + /* reload chatrooms file */ + g_object_unref (mgr); + mgr = empathy_chatroom_manager_dup_singleton (file); + + check_chatrooms_list (mgr, account, chatrooms, 0); + + g_object_unref (mgr); + g_free (file); + g_object_unref (account); +} +END_TEST + +START_TEST (test_empathy_chatroom_manager_change_favorite) +{ + EmpathyChatroomManager *mgr; + gchar *file; + McAccount *account; + struct chatroom_t chatrooms[] = { + { "name1", "room1", TRUE, TRUE }, + { "name2", "room2", FALSE, FALSE }}; + EmpathyChatroom *chatroom; + + account = get_test_account (); + + copy_xml_file (CHATROOM_SAMPLE, CHATROOM_FILE); + + file = get_user_xml_file (CHATROOM_FILE); + + /* change the chatrooms XML file to use the account we just created */ + if (!change_account_name_in_file (account, file)) + return; + + mgr = empathy_chatroom_manager_dup_singleton (file); + + /* room2 is not favorite anymore */ + chatroom = empathy_chatroom_manager_find (mgr, account, "room2"); + fail_if (chatroom == NULL); + g_object_set (chatroom, "favorite", FALSE, NULL); + + check_chatrooms_list (mgr, account, chatrooms, 2); + + /* reload chatrooms file */ + g_object_unref (mgr); + mgr = empathy_chatroom_manager_dup_singleton (file); + + /* room2 is not present in the XML file anymore as it's not a favorite */ + check_chatrooms_list (mgr, account, chatrooms, 1); + + /* re-add room2 */ + chatroom = empathy_chatroom_new_full (account, "room2", "name2", FALSE); + empathy_chatroom_manager_add (mgr, chatroom); + + check_chatrooms_list (mgr, account, chatrooms, 2); + + /* set room2 as favorite */ + g_object_set (chatroom, "favorite", TRUE, NULL); + + chatrooms[1].favorite = TRUE; + check_chatrooms_list (mgr, account, chatrooms, 2); + + /* reload chatrooms file */ + g_object_unref (mgr); + mgr = empathy_chatroom_manager_dup_singleton (file); + + /* room2 is back in the XML file now */ + check_chatrooms_list (mgr, account, chatrooms, 2); + + g_object_unref (mgr); + g_object_unref (chatroom); + g_free (file); + g_object_unref (account); +} +END_TEST + +START_TEST (test_empathy_chatroom_manager_change_chatroom) +{ + EmpathyChatroomManager *mgr; + gchar *file; + McAccount *account; + struct chatroom_t chatrooms[] = { + { "name1", "room1", TRUE, TRUE }, + { "name2", "room2", FALSE, TRUE }}; + EmpathyChatroom *chatroom; + + account = get_test_account (); + + copy_xml_file (CHATROOM_SAMPLE, "foo.xml"); + + file = get_user_xml_file ("foo.xml"); + + /* change the chatrooms XML file to use the account we just created */ + if (!change_account_name_in_file (account, file)) + return; + + mgr = empathy_chatroom_manager_dup_singleton (file); + + check_chatrooms_list (mgr, account, chatrooms, 2); + + /* change room2 name */ + chatroom = empathy_chatroom_manager_find (mgr, account, "room2"); + fail_if (chatroom == NULL); + empathy_chatroom_set_name (chatroom, "new_name"); + + /* reload chatrooms file */ + g_object_unref (mgr); + mgr = empathy_chatroom_manager_dup_singleton (file); + + chatrooms[1].name = "new_name"; + check_chatrooms_list (mgr, account, chatrooms, 2); + + /* change room2 auto-connect status */ + chatroom = empathy_chatroom_manager_find (mgr, account, "room2"); + fail_if (chatroom == NULL); + empathy_chatroom_set_auto_connect (chatroom, TRUE); + + /* reload chatrooms file */ + g_object_unref (mgr); + mgr = empathy_chatroom_manager_dup_singleton (file); + + chatrooms[1].auto_connect = TRUE; + check_chatrooms_list (mgr, account, chatrooms, 2); + + /* change room2 room */ + chatroom = empathy_chatroom_manager_find (mgr, account, "room2"); + fail_if (chatroom == NULL); + empathy_chatroom_set_room (chatroom, "new_room"); + + /* reload chatrooms file */ + g_object_unref (mgr); + mgr = empathy_chatroom_manager_dup_singleton (file); + + chatrooms[1].room = "new_room"; + check_chatrooms_list (mgr, account, chatrooms, 2); + + g_object_unref (mgr); + g_free (file); + g_object_unref (account); +} +END_TEST + +TCase * +make_empathy_chatroom_manager_tcase (void) +{ + TCase *tc = tcase_create ("empathy-chatroom-manager"); + tcase_add_test (tc, test_empathy_chatroom_manager_dup_singleton); + tcase_add_test (tc, test_empathy_chatroom_manager_add); + tcase_add_test (tc, test_empathy_chatroom_manager_remove); + tcase_add_test (tc, test_empathy_chatroom_manager_change_favorite); + tcase_add_test (tc, test_empathy_chatroom_manager_change_chatroom); + return tc; +} diff --git a/gnome-2-26/tests/check-empathy-chatroom.c b/gnome-2-26/tests/check-empathy-chatroom.c new file mode 100644 index 000000000..a4adf6ce1 --- /dev/null +++ b/gnome-2-26/tests/check-empathy-chatroom.c @@ -0,0 +1,155 @@ +#include <stdlib.h> +#include <stdio.h> +#include <string.h> + +#include <check.h> +#include "check-helpers.h" +#include "check-libempathy.h" +#include "check-empathy-helpers.h" + +#include <libempathy/empathy-chatroom.h> + +static EmpathyChatroom * +create_chatroom (void) +{ + McAccount *account; + EmpathyChatroom *chatroom; + + account = get_test_account (); + chatroom = empathy_chatroom_new (account); + fail_if (chatroom == NULL); + + 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 (empathy_chatroom_get_account (chatroom)); + g_object_unref (chatroom); +} +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 (empathy_chatroom_get_account (chatroom)); + g_object_unref (chatroom); +} +END_TEST + +static void +favorite_changed (EmpathyChatroom *chatroom, + GParamSpec *spec, + gboolean *changed) +{ + *changed = TRUE; +} + +START_TEST (test_change_favorite) +{ + EmpathyChatroom *chatroom; + gboolean changed = FALSE; + + chatroom = create_chatroom (); + + g_signal_connect (chatroom, "notify::favorite", G_CALLBACK (favorite_changed), + &changed); + + /* change favorite to TRUE */ + g_object_set (chatroom, "favorite", TRUE, NULL); + fail_if (!changed); + + changed = FALSE; + + /* change favorite to FALSE */ + g_object_set (chatroom, "favorite", FALSE, NULL); + fail_if (!changed); +} +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); + tcase_add_test (tc, test_change_favorite); + return tc; +} diff --git a/gnome-2-26/tests/check-empathy-helpers.c b/gnome-2-26/tests/check-empathy-helpers.c new file mode 100644 index 000000000..2e808c0e7 --- /dev/null +++ b/gnome-2-26/tests/check-empathy-helpers.c @@ -0,0 +1,156 @@ +/* + * check-empathy-helpers.c - Source for some check helpers + * Copyright (C) 2007-2008 Collabora Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include <stdio.h> +#include <stdlib.h> + +#include <glib/gstdio.h> +#include <gconf/gconf.h> +#include <gconf/gconf-client.h> + +#include "check-helpers.h" +#include "check-empathy-helpers.h" + +gchar * +get_xml_file (const gchar *filename) +{ + return g_build_filename (g_getenv ("EMPATHY_SRCDIR"), "tests", "xml", + filename, NULL); +} + +gchar * +get_user_xml_file (const gchar *filename) +{ + return g_build_filename (g_get_tmp_dir (), filename, NULL); +} + +void +copy_xml_file (const gchar *orig, + const gchar *dest) +{ + gboolean result; + gchar *buffer; + gsize length; + gchar *sample; + gchar *file; + + sample = get_xml_file (orig); + result = g_file_get_contents (sample, &buffer, &length, NULL); + fail_if (!result); + + file = get_user_xml_file (dest); + result = g_file_set_contents (file, buffer, length, NULL); + fail_if (!result); + + g_free (sample); + g_free (file); + g_free (buffer); +} + +McAccount * +get_test_account (void) +{ + McProfile *profile; + McAccount *account; + GList *accounts; + + profile = mc_profile_lookup ("test"); + accounts = mc_accounts_list_by_profile (profile); + if (g_list_length (accounts) == 0) + { + /* need to create a test account */ + account = mc_account_create (profile); + } + else + { + /* reuse an existing test account */ + account = accounts->data; + } + + g_object_unref (profile); + + return account; +} + +/* Not used for now as there is no API to remove completely gconf keys. + * So we reuse existing accounts instead of creating new ones */ +void +destroy_test_account (McAccount *account) +{ + GConfClient *client; + gchar *path; + GError *error = NULL; + GSList *entries = NULL, *l; + + client = gconf_client_get_default (); + path = g_strdup_printf ("/apps/telepathy/mc/accounts/%s", + mc_account_get_unique_name (account)); + + entries = gconf_client_all_entries (client, path, &error); + if (error != NULL) + { + g_print ("failed to list entries in %s: %s\n", path, error->message); + g_error_free (error); + error = NULL; + } + + for (l = entries; l != NULL; l = g_slist_next (l)) + { + GConfEntry *entry = l->data; + + if (g_str_has_suffix (entry->key, "data_dir")) + { + gchar *dir; + + dir = gconf_client_get_string (client, entry->key, &error); + if (error != NULL) + { + g_print ("get data_dir string failed: %s\n", entry->key); + g_error_free (error); + error = NULL; + } + else + { + if (g_rmdir (dir) != 0) + g_print ("can't remove %s\n", dir); + } + + g_free (dir); + } + + /* FIXME: this doesn't remove the key */ + gconf_client_unset (client, entry->key, &error); + if (error != NULL) + { + g_print ("unset of %s failed: %s\n", path, error->message); + g_error_free (error); + error = NULL; + } + + gconf_entry_free (entry); + } + + g_slist_free (entries); + + g_object_unref (client); + g_free (path); + + mc_account_delete (account); + g_object_unref (account); +} diff --git a/gnome-2-26/tests/check-empathy-helpers.h b/gnome-2-26/tests/check-empathy-helpers.h new file mode 100644 index 000000000..4d52c04e5 --- /dev/null +++ b/gnome-2-26/tests/check-empathy-helpers.h @@ -0,0 +1,31 @@ +/* + * check-empathy-helpers.c - Source for some check helpers + * Copyright (C) 2007 Collabora Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +#ifndef __CHECK_EMPATHY_HELPERS_H__ +#define __CHECK_EMPATHY_HELPERS_H__ + +#include <glib.h> +#include <libmissioncontrol/mc-account.h> + +gchar * get_xml_file (const gchar *filename); +gchar * get_user_xml_file (const gchar *filename); +void copy_xml_file (const gchar *orig, const gchar *dest); +McAccount * get_test_account (void); +void destroy_test_account (McAccount *account); + +#endif /* #ifndef __CHECK_EMPATHY_HELPERS_H__ */ diff --git a/gnome-2-26/tests/check-empathy-irc-network-manager.c b/gnome-2-26/tests/check-empathy-irc-network-manager.c new file mode 100644 index 000000000..44d6f7f82 --- /dev/null +++ b/gnome-2-26/tests/check-empathy-irc-network-manager.c @@ -0,0 +1,844 @@ +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <glib/gstdio.h> + +#include <check.h> +#include "check-helpers.h" +#include "check-libempathy.h" +#include "check-irc-helper.h" +#include "check-empathy-helpers.h" + +#include <libempathy/empathy-irc-network-manager.h> + +#define GLOBAL_SAMPLE "default-irc-networks-sample.xml" +#define USER_SAMPLE "user-irc-networks-sample.xml" +#define USER_FILE "user-irc-networks.xml" + +START_TEST (test_empathy_irc_network_manager_add) +{ + EmpathyIrcNetworkManager *mgr; + EmpathyIrcNetwork *network; + GSList *networks; + gchar *name; + + mgr = empathy_irc_network_manager_new (NULL, NULL); + fail_if (mgr == NULL); + + networks = empathy_irc_network_manager_get_networks (mgr); + fail_if (networks != NULL); + + /* add a network */ + network = empathy_irc_network_new ("My Network"); + fail_if (network == NULL); + empathy_irc_network_manager_add (mgr, network); + g_object_unref (network); + + networks = empathy_irc_network_manager_get_networks (mgr); + fail_if (g_slist_length (networks) != 1); + g_object_get (networks->data, "name", &name, NULL); + fail_if (name == NULL || strcmp (name, "My Network") != 0); + g_free (name); + g_slist_foreach (networks, (GFunc) g_object_unref, NULL); + g_slist_free (networks); + + /* add another network having the same name */ + network = empathy_irc_network_new ("My Network"); + fail_if (network == NULL); + empathy_irc_network_manager_add (mgr, network); + g_object_unref (network); + + networks = empathy_irc_network_manager_get_networks (mgr); + fail_if (g_slist_length (networks) != 2); + g_object_get (networks->data, "name", &name, NULL); + fail_if (name == NULL || strcmp (name, "My Network") != 0); + g_free (name); + g_object_get (g_slist_next(networks)->data, "name", &name, NULL); + fail_if (name == NULL || strcmp (name, "My Network") != 0); + g_free (name); + g_slist_foreach (networks, (GFunc) g_object_unref, NULL); + g_slist_free (networks); + + g_object_unref (mgr); +} +END_TEST + +START_TEST (test_load_global_file) +{ + EmpathyIrcNetworkManager *mgr; + gchar *global_file, *user_file; + GSList *networks, *l; + struct server_t freenode_servers[] = { + { "irc.freenode.net", 6667, FALSE }, + { "irc.eu.freenode.net", 6667, FALSE }}; + struct server_t gimpnet_servers[] = { + { "irc.gimp.org", 6667, FALSE }, + { "irc.us.gimp.org", 6667, FALSE }}; + struct server_t test_servers[] = { + { "irc.test.org", 6669, TRUE }}; + struct server_t undernet_servers[] = { + { "eu.undernet.org", 6667, FALSE }}; + gboolean network_checked[4]; + gchar *global_file_orig; + + global_file_orig = get_xml_file (GLOBAL_SAMPLE); + mgr = empathy_irc_network_manager_new (global_file_orig, NULL); + + g_object_get (mgr, + "global-file", &global_file, + "user-file", &user_file, + NULL); + fail_if (global_file == NULL || strcmp (global_file, global_file_orig) != 0); + fail_if (user_file != NULL); + g_free (global_file); + g_free (global_file_orig); + g_free (user_file); + + networks = empathy_irc_network_manager_get_networks (mgr); + fail_if (g_slist_length (networks) != 4); + + network_checked[0] = network_checked[1] = network_checked[2] = + network_checked[3] = FALSE; + /* check networks and servers */ + for (l = networks; l != NULL; l = g_slist_next (l)) + { + gchar *name; + + g_object_get (l->data, "name", &name, NULL); + fail_if (name == NULL); + + if (strcmp (name, "Freenode") == 0) + { + check_network (l->data, "Freenode", "UTF-8", freenode_servers, 2); + network_checked[0] = TRUE; + } + else if (strcmp (name, "GIMPNet") == 0) + { + check_network (l->data, "GIMPNet", "UTF-8", gimpnet_servers, 2); + network_checked[1] = TRUE; + } + else if (strcmp (name, "Test Server") == 0) + { + check_network (l->data, "Test Server", "ISO-8859-1", test_servers, 1); + network_checked[2] = TRUE; + } + else if (strcmp (name, "Undernet") == 0) + { + check_network (l->data, "Undernet", "UTF-8", undernet_servers, 1); + network_checked[3] = TRUE; + } + else + { + fail_if (TRUE); + } + + g_free (name); + } + fail_if (!network_checked[0] || !network_checked[1] || !network_checked[2] || + !network_checked[3]); + + g_slist_foreach (networks, (GFunc) g_object_unref, NULL); + g_slist_free (networks); + g_object_unref (mgr); +} +END_TEST + +static gboolean +remove_network_named (EmpathyIrcNetworkManager *mgr, + const gchar *network_name) +{ + GSList *networks, *l; + gboolean removed = FALSE; + + networks = empathy_irc_network_manager_get_networks (mgr); + + /* check networks and servers */ + for (l = networks; l != NULL && !removed; l = g_slist_next (l)) + { + EmpathyIrcNetwork *network = l->data; + gchar *name; + + g_object_get (network, "name", &name, NULL); + fail_if (name == NULL); + + if (strcmp (name, network_name) == 0) + { + empathy_irc_network_manager_remove (mgr, network); + removed = TRUE; + } + + g_free (name); + } + + g_slist_foreach (networks, (GFunc) g_object_unref, NULL); + g_slist_free (networks); + + return removed; +} + +START_TEST (test_empathy_irc_network_manager_remove) +{ + EmpathyIrcNetworkManager *mgr; + GSList *networks, *l; + struct server_t freenode_servers[] = { + { "irc.freenode.net", 6667, FALSE }, + { "irc.eu.freenode.net", 6667, FALSE }}; + struct server_t test_servers[] = { + { "irc.test.org", 6669, TRUE }}; + struct server_t undernet_servers[] = { + { "eu.undernet.org", 6667, FALSE }}; + gboolean network_checked[3]; + gboolean result; + gchar *global_file_orig; + + global_file_orig = get_xml_file (GLOBAL_SAMPLE); + mgr = empathy_irc_network_manager_new (global_file_orig, NULL); + g_free (global_file_orig); + + result = remove_network_named (mgr, "GIMPNet"); + fail_if (!result); + + networks = empathy_irc_network_manager_get_networks (mgr); + fail_if (g_slist_length (networks) != 3); + + network_checked[0] = network_checked[1] = network_checked[2] = FALSE; + /* check networks and servers */ + for (l = networks; l != NULL; l = g_slist_next (l)) + { + gchar *name; + + g_object_get (l->data, "name", &name, NULL); + fail_if (name == NULL); + + if (strcmp (name, "Freenode") == 0) + { + check_network (l->data, "Freenode", "UTF-8", freenode_servers, 2); + network_checked[0] = TRUE; + } + else if (strcmp (name, "Test Server") == 0) + { + check_network (l->data, "Test Server", "ISO-8859-1", test_servers, 1); + network_checked[1] = TRUE; + } + else if (strcmp (name, "Undernet") == 0) + { + check_network (l->data, "Undernet", "UTF-8", undernet_servers, 1); + network_checked[2] = TRUE; + } + else + { + fail_if (TRUE); + } + + g_free (name); + } + fail_if (!network_checked[0] || !network_checked[1] || !network_checked[2]); + + g_slist_foreach (networks, (GFunc) g_object_unref, NULL); + g_slist_free (networks); + g_object_unref (mgr); +} +END_TEST + +START_TEST (test_load_user_file) +{ + EmpathyIrcNetworkManager *mgr; + gchar *global_file, *user_file; + GSList *networks, *l; + struct server_t gimpnet_servers[] = { + { "irc.gimp.org", 6667, FALSE }, + { "irc.us.gimp.org", 6667, FALSE }, + { "irc.au.gimp.org", 6667, FALSE }}; + struct server_t my_server[] = { + { "irc.mysrv.net", 7495, TRUE }}; + struct server_t another_server[] = { + { "irc.anothersrv.be", 6660, FALSE }}; + gboolean network_checked[3]; + gchar *user_file_orig; + + copy_xml_file (USER_SAMPLE, USER_FILE); + user_file_orig = get_user_xml_file (USER_FILE); + mgr = empathy_irc_network_manager_new (NULL, user_file_orig); + + g_object_get (mgr, + "global-file", &global_file, + "user-file", &user_file, + NULL); + fail_if (global_file != NULL); + fail_if (user_file == NULL || strcmp (user_file, user_file_orig) != 0); + g_free (global_file); + g_free (user_file); + g_free (user_file_orig); + + networks = empathy_irc_network_manager_get_networks (mgr); + fail_if (g_slist_length (networks) != 3); + + network_checked[0] = network_checked[1] = network_checked[2] = FALSE; + /* check networks and servers */ + for (l = networks; l != NULL; l = g_slist_next (l)) + { + gchar *name; + + g_object_get (l->data, "name", &name, NULL); + fail_if (name == NULL); + + if (strcmp (name, "GIMPNet") == 0) + { + check_network (l->data, "GIMPNet", "UTF-8", gimpnet_servers, 3); + network_checked[0] = TRUE; + } + else if (strcmp (name, "My Server") == 0) + { + check_network (l->data, "My Server", "UTF-8", my_server, 1); + network_checked[1] = TRUE; + } + else if (strcmp (name, "Another Server") == 0) + { + check_network (l->data, "Another Server", "UTF-8", another_server, 1); + network_checked[2] = TRUE; + } + else + { + fail_if (TRUE); + } + + g_free (name); + } + fail_if (!network_checked[0] || !network_checked[1] || !network_checked[2]); + + g_slist_foreach (networks, (GFunc) g_object_unref, NULL); + g_slist_free (networks); + g_object_unref (mgr); +} +END_TEST + +START_TEST (test_load_both_files) +{ + EmpathyIrcNetworkManager *mgr; + gchar *global_file, *user_file; + GSList *networks, *l; + struct server_t freenode_servers[] = { + { "irc.freenode.net", 6667, FALSE }, + { "irc.eu.freenode.net", 6667, FALSE }}; + struct server_t gimpnet_servers[] = { + { "irc.gimp.org", 6667, FALSE }, + { "irc.us.gimp.org", 6667, FALSE }, + { "irc.au.gimp.org", 6667, FALSE }}; + struct server_t my_server[] = { + { "irc.mysrv.net", 7495, TRUE }}; + struct server_t another_server[] = { + { "irc.anothersrv.be", 6660, FALSE }}; + struct server_t undernet_servers[] = { + { "eu.undernet.org", 6667, FALSE }}; + gboolean network_checked[5]; + gchar *global_file_orig, *user_file_orig; + + global_file_orig = get_xml_file (GLOBAL_SAMPLE); + user_file_orig = get_user_xml_file (USER_FILE); + mgr = empathy_irc_network_manager_new (global_file_orig, user_file_orig); + + g_object_get (mgr, + "global-file", &global_file, + "user-file", &user_file, + NULL); + fail_if (global_file == NULL || strcmp (global_file, global_file_orig) != 0); + fail_if (user_file == NULL || strcmp (user_file, user_file_orig) != 0); + g_free (global_file); + g_free (global_file_orig); + g_free (user_file); + g_free (user_file_orig); + + networks = empathy_irc_network_manager_get_networks (mgr); + fail_if (g_slist_length (networks) != 5); + + network_checked[0] = network_checked[1] = network_checked[2] = + network_checked[3] = network_checked[4] = FALSE; + /* check networks and servers */ + for (l = networks; l != NULL; l = g_slist_next (l)) + { + gchar *name; + + g_object_get (l->data, "name", &name, NULL); + fail_if (name == NULL); + + if (strcmp (name, "Freenode") == 0) + { + check_network (l->data, "Freenode", "UTF-8", freenode_servers, 2); + network_checked[0] = TRUE; + } + else if (strcmp (name, "GIMPNet") == 0) + { + check_network (l->data, "GIMPNet", "UTF-8", gimpnet_servers, 3); + network_checked[1] = TRUE; + } + else if (strcmp (name, "My Server") == 0) + { + check_network (l->data, "My Server", "UTF-8", my_server, 1); + network_checked[2] = TRUE; + } + else if (strcmp (name, "Another Server") == 0) + { + check_network (l->data, "Another Server", "UTF-8", another_server, 1); + network_checked[3] = TRUE; + } + else if (strcmp (name, "Undernet") == 0) + { + check_network (l->data, "Undernet", "UTF-8", undernet_servers, 1); + network_checked[4] = TRUE; + } + else + { + fail_if (TRUE); + } + + g_free (name); + } + fail_if (!network_checked[0] || !network_checked[1] || !network_checked[2] || + !network_checked[3] || !network_checked[4]); + + g_slist_foreach (networks, (GFunc) g_object_unref, NULL); + g_slist_free (networks); + g_object_unref (mgr); +} +END_TEST + +START_TEST (test_modify_user_file) +{ + EmpathyIrcNetworkManager *mgr; + EmpathyIrcNetwork *network; + EmpathyIrcServer *server; + gchar *global_file, *user_file; + GSList *networks, *l; + struct server_t gimpnet_servers[] = { + { "irc.gimp.org", 6667, TRUE }, + { "irc.us.gimp.org", 6668, FALSE }}; + struct server_t great_server[] = { + { "irc.greatserver.com", 7873, TRUE }}; + struct server_t another_server[] = { + { "irc.anothersrv.be", 6660, FALSE }}; + gboolean network_modified[2]; + gboolean network_checked[3]; + gchar *user_file_orig; + + copy_xml_file (USER_SAMPLE, USER_FILE); + user_file_orig = get_user_xml_file (USER_FILE); + mgr = empathy_irc_network_manager_new (NULL, user_file_orig); + + g_object_get (mgr, + "global-file", &global_file, + "user-file", &user_file, + NULL); + fail_if (global_file != NULL); + fail_if (user_file == NULL || strcmp (user_file, user_file_orig) != 0); + g_free (global_file); + g_free (user_file); + + networks = empathy_irc_network_manager_get_networks (mgr); + fail_if (g_slist_length (networks) != 3); + + network_modified[0] = network_modified[1] = FALSE; + /* check networks and servers */ + for (l = networks; l != NULL; l = g_slist_next (l)) + { + EmpathyIrcNetwork *network; + gchar *name; + + network = l->data; + g_object_get (network, "name", &name, NULL); + fail_if (name == NULL); + + if (strcmp (name, "GIMPNet") == 0) + { + GSList *servers, *ll; + + /* change charset */ + g_object_set (network, "charset", "ISO-8859-1", NULL); + + servers = empathy_irc_network_get_servers (network); + for (ll = servers; ll != NULL; ll = g_slist_next (ll)) + { + EmpathyIrcServer *server; + gchar *address; + + server = ll->data; + g_object_get (server, "address", &address, NULL); + if (strcmp (address, "irc.gimp.org") == 0) + { + /* change SSL */ + g_object_set (server, "ssl", TRUE, NULL); + } + else if (strcmp (address, "irc.us.gimp.org") == 0) + { + /* change port */ + g_object_set (server, "port", 6668, NULL); + } + else if (strcmp (address, "irc.au.gimp.org") == 0) + { + /* remove this server */ + empathy_irc_network_remove_server (network, server); + } + else + { + fail_if (TRUE); + } + + g_free (address); + } + + network_modified[0] = TRUE; + + g_slist_foreach (servers, (GFunc) g_object_unref, NULL); + g_slist_free (servers); + } + else if (strcmp (name, "My Server") == 0) + { + /* remove this network */ + empathy_irc_network_manager_remove (mgr, network); + network_modified[1] = TRUE; + } + else if (strcmp (name, "Another Server") == 0) + { + /* Don't change this one */ + } + else + { + fail_if (TRUE); + } + + g_free (name); + } + fail_if (!network_modified[0] || !network_modified[1]); + + /* Add a new network */ + network = empathy_irc_network_new ("Great Server"); + server = empathy_irc_server_new ("irc.greatserver.com", 7873, TRUE); + empathy_irc_network_append_server (network, server); + empathy_irc_network_manager_add (mgr, network); + g_object_unref (server); + g_object_unref (network); + + g_slist_foreach (networks, (GFunc) g_object_unref, NULL); + g_slist_free (networks); + g_object_unref (mgr); + + + /* Now let's reload the file and check its contain */ + mgr = empathy_irc_network_manager_new (NULL, user_file_orig); + g_free (user_file_orig); + + networks = empathy_irc_network_manager_get_networks (mgr); + fail_if (g_slist_length (networks) != 3); + + network_checked[0] = network_checked[1] = network_checked[2] = FALSE; + /* check networks and servers */ + for (l = networks; l != NULL; l = g_slist_next (l)) + { + gchar *name; + + g_object_get (l->data, "name", &name, NULL); + fail_if (name == NULL); + + if (strcmp (name, "GIMPNet") == 0) + { + check_network (l->data, "GIMPNet", "ISO-8859-1", gimpnet_servers, 2); + network_checked[0] = TRUE; + } + else if (strcmp (name, "Great Server") == 0) + { + check_network (l->data, "Great Server", "UTF-8", great_server, 1); + network_checked[1] = TRUE; + } + else if (strcmp (name, "Another Server") == 0) + { + check_network (l->data, "Another Server", "UTF-8", another_server, 1); + network_checked[2] = TRUE; + } + else + { + fail_if (TRUE); + } + + g_free (name); + } + fail_if (!network_checked[0] || !network_checked[1] || !network_checked[2]); + + g_slist_foreach (networks, (GFunc) g_object_unref, NULL); + g_slist_free (networks); + g_object_unref (mgr); +} +END_TEST + +START_TEST (test_modify_both_files) +{ + EmpathyIrcNetworkManager *mgr; + EmpathyIrcNetwork *network; + EmpathyIrcServer *server; + gchar *global_file, *user_file; + GSList *networks, *l; + struct server_t gimpnet_servers[] = { + { "irc.gimp.org", 6667, TRUE }, + { "irc.us.gimp.org", 6668, FALSE }}; + struct server_t great_server[] = { + { "irc.greatserver.com", 7873, TRUE }}; + struct server_t another_server[] = { + { "irc.anothersrv.be", 6660, FALSE }}; + struct server_t undernet_servers[] = { + { "eu.undernet.org", 6667, FALSE }, + { "us.undernet.org", 6667, FALSE }}; + gboolean network_modified[4]; + gboolean network_checked[4]; + gchar *global_file_orig, *user_file_orig; + + copy_xml_file (USER_SAMPLE, USER_FILE); + global_file_orig = get_xml_file (GLOBAL_SAMPLE); + user_file_orig = get_user_xml_file (USER_FILE); + mgr = empathy_irc_network_manager_new (global_file_orig, user_file_orig); + + g_object_get (mgr, + "global-file", &global_file, + "user-file", &user_file, + NULL); + fail_if (global_file == NULL || strcmp (global_file, global_file_orig) != 0); + fail_if (user_file == NULL || strcmp (user_file, user_file_orig) != 0); + g_free (global_file); + g_free (global_file_orig); + g_free (user_file); + g_free (user_file_orig); + + networks = empathy_irc_network_manager_get_networks (mgr); + fail_if (g_slist_length (networks) != 5); + + network_modified[0] = network_modified[1] = network_modified[2] = + network_modified[3] = FALSE; + /* check networks and servers */ + for (l = networks; l != NULL; l = g_slist_next (l)) + { + EmpathyIrcNetwork *network; + gchar *name; + + network = l->data; + g_object_get (network, "name", &name, NULL); + fail_if (name == NULL); + + if (strcmp (name, "GIMPNet") == 0) + { + /* Modify user network */ + GSList *servers, *ll; + + servers = empathy_irc_network_get_servers (network); + for (ll = servers; ll != NULL; ll = g_slist_next (ll)) + { + EmpathyIrcServer *server; + gchar *address; + + server = ll->data; + g_object_get (server, "address", &address, NULL); + if (strcmp (address, "irc.gimp.org") == 0) + { + /* change SSL */ + g_object_set (server, "ssl", TRUE, NULL); + } + else if (strcmp (address, "irc.us.gimp.org") == 0) + { + /* change port */ + g_object_set (server, "port", 6668, NULL); + } + else if (strcmp (address, "irc.au.gimp.org") == 0) + { + /* remove this server */ + empathy_irc_network_remove_server (network, server); + } + else + { + fail_if (TRUE); + } + + g_free (address); + } + + network_modified[0] = TRUE; + + g_slist_foreach (servers, (GFunc) g_object_unref, NULL); + g_slist_free (servers); + } + else if (strcmp (name, "My Server") == 0) + { + /* remove user network */ + empathy_irc_network_manager_remove (mgr, network); + network_modified[1] = TRUE; + } + else if (strcmp (name, "Freenode") == 0) + { + /* remove global network */ + empathy_irc_network_manager_remove (mgr, network); + network_modified[2] = TRUE; + } + else if (strcmp (name, "Undernet") == 0) + { + /* modify global network */ + EmpathyIrcServer *server; + + server = empathy_irc_server_new ("us.undernet.org", 6667, FALSE); + empathy_irc_network_append_server (network, server); + g_object_unref (server); + + network_modified[3] = TRUE; + } + else if (strcmp (name, "Another Server") == 0) + { + /* Don't change this one */ + } + else + { + fail_if (TRUE); + } + + g_free (name); + } + fail_if (!network_modified[0] || !network_modified[1] || !network_modified[2] + || !network_modified[3]); + + /* Add a new network */ + network = empathy_irc_network_new ("Great Server"); + server = empathy_irc_server_new ("irc.greatserver.com", 7873, TRUE); + empathy_irc_network_append_server (network, server); + empathy_irc_network_manager_add (mgr, network); + g_object_unref (server); + g_object_unref (network); + + g_slist_foreach (networks, (GFunc) g_object_unref, NULL); + g_slist_free (networks); + g_object_unref (mgr); + + + /* Now let's reload the file and check its contain */ + global_file_orig = get_xml_file (GLOBAL_SAMPLE); + user_file_orig = get_user_xml_file (USER_FILE); + mgr = empathy_irc_network_manager_new (global_file_orig, user_file_orig); + g_free (global_file_orig); + g_free (user_file_orig); + + networks = empathy_irc_network_manager_get_networks (mgr); + fail_if (g_slist_length (networks) != 4); + + network_checked[0] = network_checked[1] = network_checked[2] = + network_checked[3] = FALSE; + /* check networks and servers */ + for (l = networks; l != NULL; l = g_slist_next (l)) + { + gchar *name; + + g_object_get (l->data, "name", &name, NULL); + fail_if (name == NULL); + + if (strcmp (name, "GIMPNet") == 0) + { + check_network (l->data, "GIMPNet", "UTF-8", gimpnet_servers, 2); + network_checked[0] = TRUE; + } + else if (strcmp (name, "Great Server") == 0) + { + check_network (l->data, "Great Server", "UTF-8", great_server, 1); + network_checked[1] = TRUE; + } + else if (strcmp (name, "Another Server") == 0) + { + check_network (l->data, "Another Server", "UTF-8", another_server, 1); + network_checked[2] = TRUE; + } + else if (strcmp (name, "Undernet") == 0) + { + check_network (l->data, "Undernet", "UTF-8", undernet_servers, 2); + network_checked[3] = TRUE; + } + else + { + fail_if (TRUE); + } + + g_free (name); + } + fail_if (!network_checked[0] || !network_checked[1] || !network_checked[2] || + !network_checked[3]); + + g_slist_foreach (networks, (GFunc) g_object_unref, NULL); + g_slist_free (networks); + g_object_unref (mgr); +} +END_TEST + +START_TEST (test_empathy_irc_network_manager_find_network_by_address) +{ + EmpathyIrcNetworkManager *mgr; + EmpathyIrcNetwork *network; + struct server_t freenode_servers[] = { + { "irc.freenode.net", 6667, FALSE }, + { "irc.eu.freenode.net", 6667, FALSE }}; + gchar *global_file_orig; + + global_file_orig = get_xml_file (GLOBAL_SAMPLE); + mgr = empathy_irc_network_manager_new (global_file_orig, NULL); + g_free (global_file_orig); + + network = empathy_irc_network_manager_find_network_by_address (mgr, + "irc.freenode.net"); + fail_if (network == NULL); + check_network (network, "Freenode", "UTF-8", freenode_servers, 2); + + network = empathy_irc_network_manager_find_network_by_address (mgr, + "irc.eu.freenode.net"); + fail_if (network == NULL); + check_network (network, "Freenode", "UTF-8", freenode_servers, 2); + + network = empathy_irc_network_manager_find_network_by_address (mgr, + "unknown"); + fail_if (network != NULL); + + g_object_unref (mgr); +} +END_TEST + +START_TEST (test_no_modify_with_empty_user_file) +{ + EmpathyIrcNetworkManager *mgr; + GSList *networks; + gchar *global_file_orig; + gchar *user_file_orig; + + /* user don't have a networks file yet */ + user_file_orig = get_user_xml_file (USER_FILE); + g_unlink (user_file_orig); + + global_file_orig = get_xml_file (GLOBAL_SAMPLE); + mgr = empathy_irc_network_manager_new (global_file_orig, user_file_orig); + g_free (global_file_orig); + g_object_unref (mgr); + + /* We didn't modify anything so USER_FILE should be empty */ + mgr = empathy_irc_network_manager_new (NULL, user_file_orig); + g_free (user_file_orig); + + networks = empathy_irc_network_manager_get_networks (mgr); + fail_if (g_slist_length (networks) != 0); + + g_slist_foreach (networks, (GFunc) g_object_unref, NULL); + g_slist_free (networks); + g_object_unref (mgr); +} +END_TEST + +TCase * +make_empathy_irc_network_manager_tcase (void) +{ + TCase *tc = tcase_create ("empathy-irc-network-manager"); + tcase_add_test (tc, test_empathy_irc_network_manager_add); + tcase_add_test (tc, test_load_global_file); + tcase_add_test (tc, test_empathy_irc_network_manager_remove); + tcase_add_test (tc, test_load_user_file); + tcase_add_test (tc, test_load_both_files); + tcase_add_test (tc, test_modify_user_file); + tcase_add_test (tc, test_modify_both_files); + tcase_add_test (tc, test_empathy_irc_network_manager_find_network_by_address); + tcase_add_test (tc, test_no_modify_with_empty_user_file); + return tc; +} diff --git a/gnome-2-26/tests/check-empathy-irc-network.c b/gnome-2-26/tests/check-empathy-irc-network.c new file mode 100644 index 000000000..b8124a305 --- /dev/null +++ b/gnome-2-26/tests/check-empathy-irc-network.c @@ -0,0 +1,240 @@ +#include <stdlib.h> +#include <stdio.h> +#include <string.h> + +#include <check.h> +#include "check-helpers.h" +#include "check-libempathy.h" +#include "check-irc-helper.h" + +#include <libempathy/empathy-irc-network.h> + +START_TEST (test_empathy_irc_network_new) +{ + EmpathyIrcNetwork *network; + + network = empathy_irc_network_new ("Network1"); + check_network (network, "Network1", "UTF-8", NULL, 0); + + g_object_unref (network); +} +END_TEST + +START_TEST (test_property_change) +{ + EmpathyIrcNetwork *network; + + network = empathy_irc_network_new ("Network1"); + check_network (network, "Network1", "UTF-8", NULL, 0); + + g_object_set (network, + "name", "Network2", + "charset", "ISO-8859-1", + NULL); + + check_network (network, "Network2", "ISO-8859-1", NULL, 0); + + g_object_unref (network); + +} +END_TEST + +static gboolean modified; + +static void +modified_cb (EmpathyIrcNetwork *network, + gpointer unused) +{ + modified = TRUE; +} + +START_TEST (test_modified_signal) +{ + EmpathyIrcNetwork *network; + + network = empathy_irc_network_new ("Network1"); + check_network (network, "Network1", "UTF-8", NULL, 0); + + modified = FALSE; + g_signal_connect (network, "modified", G_CALLBACK (modified_cb), NULL); + + g_object_set (network, "name", "Network2", NULL); + fail_if (!modified); + modified = FALSE; + g_object_set (network, "name", "Network2", NULL); + fail_if (modified); + + g_object_unref (network); +} +END_TEST + +static void +add_servers (EmpathyIrcNetwork *network, + struct server_t *servers, + guint nb_servers) +{ + guint i; + + for (i = 0; i < nb_servers; i ++) + { + EmpathyIrcServer *server; + + server = empathy_irc_server_new (servers[i].address, + servers[i].port, servers[i].ssl); + modified = FALSE; + empathy_irc_network_append_server (network, server); + fail_if (!modified); + g_object_unref (server); + } +} + +START_TEST (test_add_server) +{ + EmpathyIrcNetwork *network; + EmpathyIrcServer *server; + GSList *servers, *l; + struct server_t test_servers[] = { + { "server1", 6667, FALSE }, + { "server2", 6668, TRUE }, + { "server3", 6667, FALSE }, + { "server4", 6669, TRUE }}; + struct server_t servers_without_3[] = { + { "server1", 6667, FALSE }, + { "server2", 6668, TRUE }, + { "server4", 6669, TRUE }}; + + network = empathy_irc_network_new ("Network1"); + check_network (network, "Network1", "UTF-8", NULL, 0); + + modified = FALSE; + g_signal_connect (network, "modified", G_CALLBACK (modified_cb), NULL); + + check_network (network, "Network1", "UTF-8", NULL, 0); + + /* add the servers */ + add_servers (network, test_servers, 4); + + check_network (network, "Network1", "UTF-8", test_servers, 4); + + /* Now let's remove the 3rd server */ + servers = empathy_irc_network_get_servers (network); + l = g_slist_nth (servers, 2); + fail_if (l == NULL); + server = l->data; + modified = FALSE; + empathy_irc_network_remove_server (network, server); + fail_if (!modified); + + /* free the list */ + g_slist_foreach (servers, (GFunc) g_object_unref, NULL); + g_slist_free (servers); + + /* The 3rd server should have disappear */ + check_network (network, "Network1", "UTF-8", servers_without_3, 3); + + g_object_unref (network); +} +END_TEST + +START_TEST (test_modified_signal_because_of_server) +{ + EmpathyIrcNetwork *network; + EmpathyIrcServer *server; + + network = empathy_irc_network_new ("Network1"); + check_network (network, "Network1", "UTF-8", NULL, 0); + + g_signal_connect (network, "modified", G_CALLBACK (modified_cb), NULL); + + server = empathy_irc_server_new ("server1", 6667, FALSE); + empathy_irc_network_append_server (network, server); + + /* Change server properties */ + modified = FALSE; + g_object_set (server, "address", "server2", NULL); + fail_if (!modified); + modified = FALSE; + g_object_set (server, "port", 6668, NULL); + fail_if (!modified); + modified = FALSE; + g_object_set (server, "ssl", TRUE, NULL); + fail_if (!modified); + + empathy_irc_network_remove_server (network, server); + modified = FALSE; + g_object_set (server, "address", "server3", NULL); + /* We removed the server so the network is not modified anymore */ + fail_if (modified); + + g_object_unref (network); +} +END_TEST + +START_TEST (test_empathy_irc_network_set_server_position) +{ + EmpathyIrcNetwork *network; + GSList *servers, *l; + struct server_t test_servers[] = { + { "server1", 6667, FALSE }, + { "server2", 6668, TRUE }, + { "server3", 6667, FALSE }, + { "server4", 6669, TRUE }}; + struct server_t test_servers_sorted[] = { + { "server2", 6668, TRUE }, + { "server4", 6669, TRUE }, + { "server3", 6667, FALSE }, + { "server1", 6667, FALSE }}; + + network = empathy_irc_network_new ("Network1"); + check_network (network, "Network1", "UTF-8", NULL, 0); + + modified = FALSE; + g_signal_connect (network, "modified", G_CALLBACK (modified_cb), NULL); + + /* add the servers */ + add_servers (network, test_servers, 4); + check_network (network, "Network1", "UTF-8", test_servers, 4); + + /* get servers list */ + servers = empathy_irc_network_get_servers (network); + fail_if (g_slist_length (servers) != 4); + modified = FALSE; + + /* server1 go to the last position */ + empathy_irc_network_set_server_position (network, servers->data, -1); + + /* server2 go to the first position */ + l = servers->next; + empathy_irc_network_set_server_position (network, l->data, 0); + + /* server3 go to the third position */ + l = l->next; + empathy_irc_network_set_server_position (network, l->data, 2); + + /* server4 go to the second position*/ + l = l->next; + empathy_irc_network_set_server_position (network, l->data, 1); + + fail_if (!modified); + + /* free the list */ + g_slist_foreach (servers, (GFunc) g_object_unref, NULL); + g_slist_free (servers); + + /* Check if servers are sorted */ + check_network (network, "Network1", "UTF-8", test_servers_sorted, 4); +} +END_TEST + +TCase * +make_empathy_irc_network_tcase (void) +{ + TCase *tc = tcase_create ("empathy-irc-network"); + tcase_add_test (tc, test_empathy_irc_network_new); + tcase_add_test (tc, test_property_change); + tcase_add_test (tc, test_modified_signal); + tcase_add_test (tc, test_add_server); + tcase_add_test (tc, test_modified_signal_because_of_server); + tcase_add_test (tc, test_empathy_irc_network_set_server_position); + return tc; +} diff --git a/gnome-2-26/tests/check-empathy-irc-server.c b/gnome-2-26/tests/check-empathy-irc-server.c new file mode 100644 index 000000000..52607f221 --- /dev/null +++ b/gnome-2-26/tests/check-empathy-irc-server.c @@ -0,0 +1,93 @@ +#include <stdlib.h> +#include <stdio.h> +#include <string.h> + +#include <check.h> +#include "check-helpers.h" +#include "check-libempathy.h" +#include "check-irc-helper.h" + +#include <libempathy/empathy-irc-server.h> + +START_TEST (test_empathy_irc_server_new) +{ + EmpathyIrcServer *server; + + server = empathy_irc_server_new ("test.localhost", 6667, TRUE); + check_server (server, "test.localhost", 6667, TRUE); + + g_object_unref (server); +} +END_TEST + +START_TEST (test_property_change) +{ + EmpathyIrcServer *server; + + server = empathy_irc_server_new ("test.localhost", 6667, TRUE); + fail_if (server == NULL); + + g_object_set (server, + "address", "test2.localhost", + "port", 6668, + "ssl", FALSE, + NULL); + + check_server (server, "test2.localhost", 6668, FALSE); + + g_object_unref (server); +} +END_TEST + +static gboolean modified = FALSE; + +static void +modified_cb (EmpathyIrcServer *server, + gpointer unused) +{ + modified = TRUE; +} + +START_TEST (test_modified_signal) +{ + EmpathyIrcServer *server; + + server = empathy_irc_server_new ("test.localhost", 6667, TRUE); + fail_if (server == NULL); + + g_signal_connect (server, "modified", G_CALLBACK (modified_cb), NULL); + + /* address */ + g_object_set (server, "address", "test2.localhost", NULL); + fail_if (!modified); + modified = FALSE; + g_object_set (server, "address", "test2.localhost", NULL); + fail_if (modified); + + /* port */ + g_object_set (server, "port", 6668, NULL); + fail_if (!modified); + modified = FALSE; + g_object_set (server, "port", 6668, NULL); + fail_if (modified); + + /* ssl */ + g_object_set (server, "ssl", FALSE, NULL); + fail_if (!modified); + modified = FALSE; + g_object_set (server, "ssl", FALSE, NULL); + fail_if (modified); + + g_object_unref (server); +} +END_TEST + +TCase * +make_empathy_irc_server_tcase (void) +{ + TCase *tc = tcase_create ("empathy-irc-server"); + tcase_add_test (tc, test_empathy_irc_server_new); + tcase_add_test (tc, test_property_change); + tcase_add_test (tc, test_modified_signal); + return tc; +} diff --git a/gnome-2-26/tests/check-empathy-utils.c b/gnome-2-26/tests/check-empathy-utils.c new file mode 100644 index 000000000..faf261058 --- /dev/null +++ b/gnome-2-26/tests/check-empathy-utils.c @@ -0,0 +1,29 @@ +#include <stdlib.h> +#include <stdio.h> +#include <string.h> + +#include <check.h> +#include "check-helpers.h" +#include "check-libempathy.h" + +#include <libempathy/empathy-utils.h> + +START_TEST (test_empathy_substring) +{ + gchar *tmp; + + tmp = empathy_substring ("empathy", 2, 6); + fail_if (tmp == NULL); + fail_if (strcmp (tmp, "path") != 0); + + g_free (tmp); +} +END_TEST + +TCase * +make_empathy_utils_tcase (void) +{ + TCase *tc = tcase_create ("empathy-utils"); + tcase_add_test (tc, test_empathy_substring); + return tc; +} diff --git a/gnome-2-26/tests/check-helpers.c b/gnome-2-26/tests/check-helpers.c new file mode 100644 index 000000000..5f1f32fdd --- /dev/null +++ b/gnome-2-26/tests/check-helpers.c @@ -0,0 +1,67 @@ +/* + * check-helpers.c - Source for some check helpers + * Copyright (C) 2007-2008 Collabora Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include <stdio.h> +#include <stdlib.h> + +#include <glib/gstdio.h> +#include <gconf/gconf.h> +#include <gconf/gconf-client.h> + +#include "check-helpers.h" + +static gboolean expecting_critical = FALSE; +static gboolean received_critical = FALSE; + +static void +check_helper_log_critical_func (const gchar *log_damain, + GLogLevelFlags log_level, + const gchar *message, + gpointer user_data) +{ + + if (!expecting_critical) + { + fail("Unexpected critical message: %s\n", message); + } + + g_assert (log_level & G_LOG_LEVEL_CRITICAL); + + received_critical = TRUE; +} + +gboolean +got_critical (void) +{ + return received_critical; +} + +void +expect_critical (gboolean expected) +{ + expecting_critical = expected; + received_critical = FALSE; +} + +void +check_helpers_init (void) +{ + g_log_set_handler (NULL, G_LOG_LEVEL_CRITICAL, + check_helper_log_critical_func, NULL); +} diff --git a/gnome-2-26/tests/check-helpers.h b/gnome-2-26/tests/check-helpers.h new file mode 100644 index 000000000..3e0783811 --- /dev/null +++ b/gnome-2-26/tests/check-helpers.h @@ -0,0 +1,44 @@ +/* + * check-helpers.c - Source for some check helpers + * Copyright (C) 2007 Collabora Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +#ifndef __CHECK_HELPERS_H__ +#define __CHECK_HELPERS_H__ + +#include <glib.h> +#include <check.h> +#include <libmissioncontrol/mc-account.h> + +void +check_helpers_init (void); + +void +expect_critical (gboolean expected); + +gboolean +got_critical (void); + +#define fail_unless_critical(expr, ...) \ +G_STMT_START { \ + expect_critical (TRUE); \ + expr; \ + _fail_unless (got_critical (), __FILE__, __LINE__, \ + "Expected g_critical, got none", ## __VA_ARGS__, NULL); \ + expect_critical (FALSE); \ +} G_STMT_END; + +#endif /* #ifndef __CHECK_HELPERS_H__ */ diff --git a/gnome-2-26/tests/check-irc-helper.c b/gnome-2-26/tests/check-irc-helper.c new file mode 100644 index 000000000..477b134c2 --- /dev/null +++ b/gnome-2-26/tests/check-irc-helper.c @@ -0,0 +1,80 @@ +#include "check-irc-helper.h" + +void +check_server (EmpathyIrcServer *server, + const gchar *_address, + guint _port, + gboolean _ssl) +{ + gchar *address; + guint port; + gboolean ssl; + + fail_if (server == NULL); + + g_object_get (server, + "address", &address, + "port", &port, + "ssl", &ssl, + NULL); + + fail_if (address == NULL || strcmp (address, _address) != 0); + fail_if (port != _port); + fail_if (ssl != _ssl); + + g_free (address); +} + +void +check_network (EmpathyIrcNetwork *network, + const gchar *_name, + const gchar *_charset, + struct server_t *_servers, + guint nb_servers) +{ + gchar *name, *charset; + GSList *servers, *l; + guint i; + + fail_if (network == NULL); + + g_object_get (network, + "name", &name, + "charset", &charset, + NULL); + + fail_if (name == NULL || strcmp (name, _name) != 0); + fail_if (charset == NULL || strcmp (charset, _charset) != 0); + + servers = empathy_irc_network_get_servers (network); + fail_if (g_slist_length (servers) != nb_servers); + + /* Is that the right servers ? */ + for (l = servers, i = 0; l != NULL; l = g_slist_next (l), i++) + { + EmpathyIrcServer *server; + gchar *address; + guint port; + gboolean ssl; + + server = l->data; + + g_object_get (server, + "address", &address, + "port", &port, + "ssl", &ssl, + NULL); + + fail_if (address == NULL || strcmp (address, _servers[i].address) + != 0); + fail_if (port != _servers[i].port); + fail_if (ssl != _servers[i].ssl); + + g_free (address); + } + + g_slist_foreach (servers, (GFunc) g_object_unref, NULL); + g_slist_free (servers); + g_free (name); + g_free (charset); +} diff --git a/gnome-2-26/tests/check-irc-helper.h b/gnome-2-26/tests/check-irc-helper.h new file mode 100644 index 000000000..32a34b60d --- /dev/null +++ b/gnome-2-26/tests/check-irc-helper.h @@ -0,0 +1,27 @@ +#include <stdlib.h> +#include <string.h> + +#include <check.h> +#include "check-helpers.h" + +#include <libempathy/empathy-irc-server.h> +#include <libempathy/empathy-irc-network.h> +#include <libempathy/empathy-irc-network-manager.h> + +#ifndef __CHECK_IRC_HELPER_H__ +#define __CHECK_IRC_HELPER_H__ + +struct server_t +{ + gchar *address; + guint port; + gboolean ssl; +}; + +void check_server (EmpathyIrcServer *server, const gchar *_address, + guint _port, gboolean _ssl); + +void check_network (EmpathyIrcNetwork *network, const gchar *_name, + const gchar *_charset, struct server_t *_servers, guint nb_servers); + +#endif /* __CHECK_IRC_HELPER_H__ */ diff --git a/gnome-2-26/tests/check-libempathy.h b/gnome-2-26/tests/check-libempathy.h new file mode 100644 index 000000000..5dcb2b17a --- /dev/null +++ b/gnome-2-26/tests/check-libempathy.h @@ -0,0 +1,11 @@ +#ifndef __CHECK_LIBEMPATHY__ +#define __CHECK_LIBEMPATHY__ + +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); +TCase * make_empathy_chatroom_manager_tcase (void); + +#endif /* #ifndef __CHECK_LIBEMPATHY__ */ diff --git a/gnome-2-26/tests/check-main.c b/gnome-2-26/tests/check-main.c new file mode 100644 index 000000000..7adbc15df --- /dev/null +++ b/gnome-2-26/tests/check-main.c @@ -0,0 +1,47 @@ +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <glib-object.h> + +#include <check.h> + +#include "check-helpers.h" +#include "check-libempathy.h" +#include <libempathy/empathy-utils.h> + +#include "config.h" + +static Suite * +make_libempathy_suite (void) +{ + Suite *s = suite_create ("libempathy"); + + suite_add_tcase (s, make_empathy_utils_tcase ()); + 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 ()); + suite_add_tcase (s, make_empathy_chatroom_manager_tcase ()); + + return s; +} + +int +main (void) +{ + int number_failed = 0; + Suite *s; + SRunner *sr; + + check_helpers_init (); + g_type_init (); + empathy_init (); + + s = make_libempathy_suite (); + sr = srunner_create (s); + srunner_run_all (sr, CK_NORMAL); + number_failed += srunner_ntests_failed (sr); + srunner_free (sr); + + return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; +} diff --git a/gnome-2-26/tests/contact-manager.c b/gnome-2-26/tests/contact-manager.c new file mode 100644 index 000000000..7793b44d9 --- /dev/null +++ b/gnome-2-26/tests/contact-manager.c @@ -0,0 +1,44 @@ +#include <stdlib.h> + +#include <glib.h> +#include <gtk/gtk.h> +#include <libempathy/empathy-contact-manager.h> +#include <libempathy/empathy-debug.h> + +#include <libempathy-gtk/empathy-contact-list-store.h> +#include <libempathy-gtk/empathy-ui-utils.h> + +int +main (int argc, char **argv) +{ + EmpathyContactManager *manager; + GMainLoop *main_loop; + EmpathyContactListStore *store; + GtkWidget *combo; + GtkWidget *window; + GtkCellRenderer *renderer; + + gtk_init (&argc, &argv); + empathy_gtk_init (); + + empathy_debug_set_flags (g_getenv ("EMPATHY_DEBUG")); + main_loop = g_main_loop_new (NULL, FALSE); + manager = empathy_contact_manager_dup_singleton (); + store = empathy_contact_list_store_new (EMPATHY_CONTACT_LIST (manager)); + empathy_contact_list_store_set_is_compact (store, TRUE); + empathy_contact_list_store_set_show_groups (store, FALSE); + combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store)); + renderer = gtk_cell_renderer_text_new (); + gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE); + gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combo), renderer, "text", EMPATHY_CONTACT_LIST_STORE_COL_NAME); + window = gtk_window_new (GTK_WINDOW_TOPLEVEL); + gtk_container_add (GTK_CONTAINER (window), combo); + gtk_widget_show (combo); + gtk_widget_show (window); + g_object_unref (manager); + + gtk_main (); + + return EXIT_SUCCESS; +} + diff --git a/gnome-2-26/tests/contact-run-until-ready-2.c b/gnome-2-26/tests/contact-run-until-ready-2.c new file mode 100644 index 000000000..426534116 --- /dev/null +++ b/gnome-2-26/tests/contact-run-until-ready-2.c @@ -0,0 +1,63 @@ +#include <stdlib.h> + +#include <glib.h> +#include <gtk/gtk.h> +#include <libempathy/empathy-contact-factory.h> +#include <libempathy/empathy-contact-manager.h> +#include <libmissioncontrol/mc-account.h> + +static void +pending_cb (EmpathyContactManager *manager, + EmpathyContact *contact, + EmpathyContact *actor, + guint reason, + gchar *message, + gboolean is_pending, + gpointer data) +{ + if (!is_pending) { + return; + } + + g_print ("Contact handle=%d alias=%s\n", + empathy_contact_get_handle (contact), + empathy_contact_get_name (contact)); + + empathy_contact_run_until_ready (contact, + EMPATHY_CONTACT_READY_NAME, + NULL); + + g_print ("Contact ready: handle=%d alias=%s ready=%d\n", + empathy_contact_get_handle (contact), + empathy_contact_get_name (contact), + empathy_contact_get_ready (contact)); + + g_object_unref (manager); + gtk_main_quit (); +} + +static gboolean +callback (gpointer data) +{ + EmpathyContactManager *manager; + + manager = empathy_contact_manager_dup_singleton (); + g_signal_connect (manager, "pendings-changed", + G_CALLBACK (pending_cb), + NULL); + + return FALSE; +} + +int +main (int argc, char **argv) +{ + gtk_init (&argc, &argv); + + g_idle_add (callback, NULL); + + gtk_main (); + + return EXIT_SUCCESS; +} + diff --git a/gnome-2-26/tests/contact-run-until-ready.c b/gnome-2-26/tests/contact-run-until-ready.c new file mode 100644 index 000000000..13fad63a7 --- /dev/null +++ b/gnome-2-26/tests/contact-run-until-ready.c @@ -0,0 +1,53 @@ +#include <stdlib.h> + +#include <glib.h> +#include <gtk/gtk.h> +#include <libempathy/empathy-contact-factory.h> +#include <libmissioncontrol/mc-account.h> + +static gboolean +callback (gpointer data) +{ + EmpathyContactFactory *factory; + McAccount *account; + EmpathyContact *contact; + EmpathyContactReady ready_flags; + + factory = empathy_contact_factory_dup_singleton (); + account = mc_account_lookup ("jabber0"); + contact = empathy_contact_factory_get_from_handle (factory, account, 2); + + g_print ("Contact handle=%d alias=%s\n", + empathy_contact_get_handle (contact), + empathy_contact_get_name (contact)); + + ready_flags = EMPATHY_CONTACT_READY_HANDLE | EMPATHY_CONTACT_READY_NAME; + empathy_contact_run_until_ready (contact, ready_flags, NULL); + + g_print ("Contact ready: handle=%d alias=%s ready=%d needed-ready=%d\n", + empathy_contact_get_handle (contact), + empathy_contact_get_name (contact), + empathy_contact_get_ready (contact), + ready_flags); + + g_object_unref (factory); + g_object_unref (account); + g_object_unref (contact); + + gtk_main_quit (); + + return FALSE; +} + +int +main (int argc, char **argv) +{ + gtk_init (&argc, &argv); + + g_idle_add (callback, NULL); + + gtk_main (); + + return EXIT_SUCCESS; +} + diff --git a/gnome-2-26/tests/dlopen.supp b/gnome-2-26/tests/dlopen.supp new file mode 100644 index 000000000..f6300a3a7 --- /dev/null +++ b/gnome-2-26/tests/dlopen.supp @@ -0,0 +1,127 @@ +{ + <dlopen> + Addrcheck,Memcheck:Cond + obj:/lib/ld-2.5.so + obj:/lib/ld-2.5.so + obj:/lib/ld-2.5.so + obj:/lib/i686/cmov/libdl-2.5.so + obj:/lib/ld-2.5.so + obj:/lib/i686/cmov/libdl-2.5.so + fun:dlopen +} +{ + <dlopen> + Addrcheck,Memcheck:Addr4 + obj:/lib/ld-2.5.so + obj:/lib/ld-2.5.so + obj:/lib/ld-2.5.so + obj:/lib/ld-2.5.so + obj:/lib/ld-2.5.so + obj:/lib/ld-2.5.so + obj:/lib/i686/cmov/libdl-2.5.so + obj:/lib/ld-2.5.so + obj:/lib/i686/cmov/libdl-2.5.so + fun:dlopen +} +{ + <dlopen> + Addrcheck,Memcheck:Cond + obj:/lib/ld-2.5.so + obj:/lib/ld-2.5.so + obj:/lib/ld-2.5.so + obj:/lib/ld-2.5.so + obj:/lib/i686/cmov/libdl-2.5.so + obj:/lib/ld-2.5.so + obj:/lib/i686/cmov/libdl-2.5.so + fun:dlopen +} +{ + <dlsym> + Addrcheck,Memcheck:Addr4 + obj:/lib/ld-2.5.so + obj:/lib/ld-2.5.so + obj:/lib/ld-2.5.so + obj:/lib/i686/cmov/libc-2.5.so + fun:_dl_sym + obj:/lib/i686/cmov/libdl-2.5.so + obj:/lib/ld-2.5.so + obj:/lib/i686/cmov/libdl-2.5.so + fun:dlsym +} +{ + <dlsym> + Addrcheck,Memcheck:Cond + obj:/lib/ld-2.5.so + obj:/lib/ld-2.5.so + obj:/lib/ld-2.5.so + obj:/lib/i686/cmov/libc-2.5.so + fun:_dl_sym + obj:/lib/i686/cmov/libdl-2.5.so + obj:/lib/ld-2.5.so + obj:/lib/i686/cmov/libdl-2.5.so + fun:dlsym +} +{ + <dlopen> + Addrcheck,Memcheck:Addr1 + fun:malloc + obj:/lib/ld-2.5.so + obj:/lib/ld-2.5.so + obj:/lib/ld-2.5.so + obj:/lib/ld-2.5.so + obj:/lib/ld-2.5.so + obj:/lib/ld-2.5.so + obj:/lib/ld-2.5.so + obj:/lib/i686/cmov/libdl-2.5.so + obj:/lib/ld-2.5.so + obj:/lib/i686/cmov/libdl-2.5.so + fun:dlopen +} +{ + <dlopen> + Addrcheck,Memcheck:Addr1 + fun:malloc + obj:/lib/ld-2.5.so + obj:/lib/ld-2.5.so + obj:/lib/ld-2.5.so + obj:/lib/ld-2.5.so + obj:/lib/ld-2.5.so + obj:/lib/ld-2.5.so + obj:/lib/ld-2.5.so + obj:/lib/i686/cmov/libdl-2.5.so + obj:/lib/ld-2.5.so + obj:/lib/i686/cmov/libdl-2.5.so + fun:dlopen +} +{ + <dlopen> + Addrcheck,Memcheck:Addr1 + fun:malloc + obj:/lib/ld-2.5.so + obj:/lib/ld-2.5.so + obj:/lib/ld-2.5.so + obj:/lib/ld-2.5.so + obj:/lib/ld-2.5.so + obj:/lib/ld-2.5.so + obj:/lib/ld-2.5.so + obj:/lib/i686/cmov/libdl-2.5.so + obj:/lib/ld-2.5.so + obj:/lib/i686/cmov/libdl-2.5.so + fun:dlopen +} +{ + <libdl> + Addrcheck,Memcheck:Addr4 + obj:/lib/ld-2.5.so + obj:/lib/ld-2.5.so + obj:/lib/ld-2.5.so + obj:/lib/ld-2.5.so + obj:/lib/ld-2.5.so + obj:/lib/ld-2.5.so + obj:/lib/ld-2.5.so + obj:/lib/ld-2.5.so + obj:/lib/ld-2.5.so + obj:/lib/i686/cmov/libdl-2.5.so + obj:/lib/ld-2.5.so + obj:/lib/i686/cmov/libdl-2.5.so +} diff --git a/gnome-2-26/tests/empetit.c b/gnome-2-26/tests/empetit.c new file mode 100644 index 000000000..2c69d101d --- /dev/null +++ b/gnome-2-26/tests/empetit.c @@ -0,0 +1,85 @@ +#include "config.h" + +#include <gtk/gtk.h> + +#include <libempathy/empathy-contact-manager.h> +#include <libempathy/empathy-dispatcher.h> + +#include <libempathy-gtk/empathy-ui-utils.h> +#include <libempathy-gtk/empathy-contact-list-store.h> +#include <libempathy-gtk/empathy-contact-selector.h> + +static GtkWidget *window = NULL; + +static void +chat_cb (EmpathyDispatchOperation *dispatch, + const GError *error, + gpointer user_data) +{ + GtkWidget *dialog; + + if (error != NULL) + { + dialog = gtk_message_dialog_new (GTK_WINDOW (window), GTK_DIALOG_MODAL, + GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "%s", + error->message ? error->message : "No error message"); + + gtk_dialog_run (GTK_DIALOG (dialog)); + } + + gtk_widget_destroy (window); +} + +static void +clicked_cb (GtkButton *button, + gpointer data) +{ + EmpathyContactSelector *selector = EMPATHY_CONTACT_SELECTOR (data); + EmpathyContact *contact; + + contact = empathy_contact_selector_dup_selected (selector); + + if (!contact) + return; + + empathy_dispatcher_chat_with_contact (contact, chat_cb, NULL); + + g_object_unref (contact); +} + +int main (int argc, + char *argv[]) +{ + EmpathyContactManager *manager; + GtkWidget *vbox, *button, *selector; + + gtk_init (&argc, &argv); + + empathy_gtk_init (); + + manager = empathy_contact_manager_dup_singleton (); + selector = empathy_contact_selector_new (EMPATHY_CONTACT_LIST (manager)); + + vbox = gtk_vbox_new (FALSE, 2); + + gtk_box_pack_start (GTK_BOX (vbox), selector, FALSE, FALSE, 5); + + button = gtk_button_new_with_label ("Chat"); + g_signal_connect (G_OBJECT (button), "clicked", + G_CALLBACK (clicked_cb), (gpointer) selector); + gtk_box_pack_start(GTK_BOX (vbox), button, FALSE, FALSE, 5); + + window = gtk_window_new (GTK_WINDOW_TOPLEVEL); + g_signal_connect (G_OBJECT (window), "destroy", + gtk_main_quit, NULL); + gtk_window_set_title (GTK_WINDOW (window),"Empetit"); + gtk_container_set_border_width (GTK_CONTAINER (window), 5); + gtk_container_add (GTK_CONTAINER (window), vbox); + gtk_widget_show_all (window); + + gtk_main (); + + g_object_unref (manager); + + return 0; +} diff --git a/gnome-2-26/tests/test.manager b/gnome-2-26/tests/test.manager new file mode 100644 index 000000000..8a49c3267 --- /dev/null +++ b/gnome-2-26/tests/test.manager @@ -0,0 +1,5 @@ +[ConnectionManager] +BusName=org.freedesktop.Telepathy.ConnectionManager.test +ObjectPath=/org/freedesktop/Telepathy/ConnectionManager/test + +[Protocol test] diff --git a/gnome-2-26/tests/test.profile b/gnome-2-26/tests/test.profile new file mode 100644 index 000000000..20e552a1a --- /dev/null +++ b/gnome-2-26/tests/test.profile @@ -0,0 +1,4 @@ +[Profile] +Manager = test +Protocol = test +DisplayName = test diff --git a/gnome-2-26/tests/valgrind.supp b/gnome-2-26/tests/valgrind.supp new file mode 100644 index 000000000..29bb04547 --- /dev/null +++ b/gnome-2-26/tests/valgrind.supp @@ -0,0 +1,711 @@ +### this file contains suppressions for valgrind when running +### the gibber/telepathy-salut unit tests based on the gstreamer one + +### syscall suppressions + +{ + <clone on Wim's Debian> + Memcheck:Param + clone(parent_tidptr) + fun:clone + fun:clone +} + +{ + <clone on Wim's Debian> + Memcheck:Param + clone(child_tidptr) + fun:clone + fun:clone +} + +{ + <clone on Wim's Debian> + Memcheck:Param + clone(tlsinfo) + fun:clone + fun:clone +} + +### glibc suppressions + +{ + <conditional jump on wim's debian 2/2/06> + Memcheck:Cond + obj:/lib/ld-2.3.*.so + fun:dl_open_worker + obj:/lib/ld-2.3.*.so + fun:_dl_open + fun:dlopen_doit + obj:/lib/ld-2.3.*.so + fun:_dlerror_run + fun:dlopen@@GLIBC_2.1 + fun:g_module_open +} + +# glibc does not deallocate thread-local storage + +{ + <tls> + Memcheck:Leak + fun:calloc + fun:_dl_allocate_tls + fun:pthread_create@@* +} + +# I get an extra stack entry on x86/dapper +{ + <tls> + Memcheck:Leak + fun:calloc + obj:/lib/ld-2.3.*.so + fun:_dl_allocate_tls + fun:pthread_create@@* +} + + +{ + <pthread strstr> + Memcheck:Cond + fun:strstr + fun:__pthread_initialize_minimal + obj:/lib/libpthread-*.so + obj:/lib/libpthread-*.so + fun:call_init + fun:_dl_init + obj:/lib/ld-*.so +} + +# a thread-related free problem in glibc from Edgard +{ + __libc_freeres_rw_acess + Memcheck:Addr4 + obj:* + obj:* + obj:* + obj:* + obj:* + fun:__libc_freeres +} + +{ + <a conditional jump on wim's debian> + Memcheck:Cond + obj:/lib/ld-2.3.*.so + obj:/lib/ld-2.3.*.so + obj:/lib/ld-2.3.*.so + obj:/lib/ld-2.3.*.so + obj:/lib/ld-2.3.*.so +} + +# g_module_open-related problems +{ + <started showing up on fc4-quick> + Memcheck:Addr2 + fun:memcpy + fun:_dl_map_object_deps + fun:dl_open_worker + fun:_dl_catch_error + fun:_dl_open + fun:dlopen_doit + fun:_dl_catch_error + fun:_dlerror_run + fun:dlopen@@GLIBC_2.1 + fun:g_module_open +} + +{ + <started showing up on fc4-quick> + Memcheck:Addr4 + fun:memcpy + fun:_dl_map_object_deps + fun:dl_open_worker + fun:_dl_catch_error + fun:_dl_open + fun:dlopen_doit + fun:_dl_catch_error + fun:_dlerror_run + fun:dlopen@@GLIBC_2.1 + fun:g_module_open +} + +{ + <g_module_open on wim's debian> + Memcheck:Cond + obj:/lib/ld-2.3.*.so + obj:/lib/ld-2.3.*.so + obj:/lib/ld-2.3.*.so + fun:do_sym + fun:_dl_sym + fun:dlsym_doit + obj:/lib/ld-2.3.*.so + fun:_dlerror_run + fun:dlsym + fun:g_module_symbol + fun:g_module_open +} + +{ + <g_module_open on wim's debian> + Memcheck:Cond + obj:/lib/ld-2.3.*.so + obj:/lib/ld-2.3.*.so + obj:/lib/ld-2.3.*.so + fun:dl_open_worker + obj:/lib/ld-2.3.*.so + fun:_dl_open + fun:dlopen_doit + obj:/lib/ld-2.3.*.so + fun:_dlerror_run + fun:dlopen@@GLIBC_2.1 + fun:g_module_open +} +{ + <g_module_open on wim's debian> + Memcheck:Cond + obj:/lib/ld-2.3.*.so + fun:dl_open_worker + obj:/lib/ld-2.3.*.so + fun:_dl_open + fun:dlopen_doit + obj:/lib/ld-2.3.*.so + fun:_dlerror_run + fun:dlopen@@GLIBC_2.1 + fun:g_module_open +} + +{ + <leak on wim's debian in g_module_open> + Memcheck:Leak + fun:malloc + obj:/lib/ld-2.3.*.so + fun:dl_open_worker + obj:/lib/ld-2.3.*.so + fun:_dl_open + fun:dlopen_doit + obj:/lib/ld-2.3.*.so + fun:_dlerror_run + fun:dlopen@@GLIBC_2.1 + fun:g_module_open +} + +{ + <invalid read on wim's debian> + Memcheck:Addr4 + obj:/lib/ld-2.3.*.so + obj:/lib/ld-2.3.*.so + obj:/lib/ld-2.3.*.so + obj:/lib/ld-2.3.*.so + obj:/lib/ld-2.3.*.so + obj:/lib/ld-2.3.*.so + obj:/lib/ld-2.3.*.so + fun:dl_open_worker + obj:/lib/ld-2.3.*.so + fun:_dl_open + fun:dlopen_doit + obj:/lib/ld-2.3.*.so +} + +{ + <invalid read on wim's debian> + Memcheck:Addr4 + obj:/lib/ld-2.3.*.so + obj:/lib/ld-2.3.*.so + obj:/lib/ld-2.3.*.so + obj:/lib/ld-2.3.*.so + obj:/lib/ld-2.3.*.so + obj:/lib/ld-2.3.*.so + fun:dl_open_worker + obj:/lib/ld-2.3.*.so + fun:_dl_open + fun:dlopen_doit + obj:/lib/ld-2.3.*.so + fun:_dlerror_run +} + +{ + <invalid read on wim's debian - 2006-02-02> + Memcheck:Addr4 + obj:/lib/ld-2.3.*.so + obj:/lib/ld-2.3.*.so + obj:/lib/ld-2.3.*.so + fun:dl_open_worker + obj:/lib/ld-2.3.*.so + fun:_dl_open + fun:dlopen_doit + obj:/lib/ld-2.3.*.so + fun:_dlerror_run + fun:dlopen@@GLIBC_2.1 + fun:g_module_open +} + +{ + <invalid read on wim's debian - 2006-02-02> + Memcheck:Addr4 + obj:/lib/ld-2.3.*.so + obj:/lib/ld-2.3.*.so + fun:dl_open_worker + obj:/lib/ld-2.3.*.so + fun:_dl_open + fun:dlopen_doit + obj:/lib/ld-2.3.*.so + fun:_dlerror_run + fun:dlopen@@GLIBC_2.1 + fun:g_module_open +} + +{ + <invalid read on wim's debian - 2006-02-02> + Memcheck:Addr4 + obj:/lib/ld-2.3.*.so + obj:/lib/ld-2.3.*.so + obj:/lib/ld-2.3.*.so + fun:do_sym + fun:_dl_sym + fun:dlsym_doit + obj:/lib/ld-2.3.*.so + fun:_dlerror_run + fun:dlsym + fun:g_module_symbol + fun:g_module_open +} + +{ + <futex on Andy's 64-bit ubuntu> + Memcheck:Param + futex(uaddr2) + fun:pthread_once + obj:/lib/libc-2.3.*.so + obj:/lib/libc-2.3.*.so + fun:mbsnrtowcs + fun:vfprintf + fun:vsprintf + fun:sprintf + obj:/lib/libc-2.3.*.so +} + +# valgrind doesn't allow me to specify a suppression for Addr1, Addr2, Addr4 +# as Addr*, so 3 copies for that; and then 2 of each for that pesky memcpy +{ + <Invalid read of size 1, 2, 4 on thomas's FC4> + Memcheck:Addr1 + fun:_dl_signal_error + fun:_dl_map_object_deps + fun:dl_open_worker + fun:_dl_catch_error + fun:_dl_open + fun:dlopen_doit + fun:_dl_catch_error + fun:_dlerror_run + fun:dlopen@@GLIBC_2.1 + fun:g_module_open +} + +{ + <Invalid read of size 1, 2, 4 on thomas's FC4> + Memcheck:Addr2 + fun:_dl_signal_error + fun:_dl_map_object_deps + fun:dl_open_worker + fun:_dl_catch_error + fun:_dl_open + fun:dlopen_doit + fun:_dl_catch_error + fun:_dlerror_run + fun:dlopen@@GLIBC_2.1 + fun:g_module_open +} +{ + <Invalid read of size 1, 2, 4 on thomas's FC4> + Memcheck:Addr4 + fun:_dl_signal_error + fun:_dl_map_object_deps + fun:dl_open_worker + fun:_dl_catch_error + fun:_dl_open + fun:dlopen_doit + fun:_dl_catch_error + fun:_dlerror_run + fun:dlopen@@GLIBC_2.1 + fun:g_module_open +} + +{ + <Invalid read of size 1, 2, 4 on thomas's FC4> + Memcheck:Addr1 + fun:memcpy + fun:_dl_signal_error + fun:_dl_map_object_deps + fun:dl_open_worker + fun:_dl_catch_error + fun:_dl_open + fun:dlopen_doit + fun:_dl_catch_error + fun:_dlerror_run + fun:dlopen@@GLIBC_2.1 + fun:g_module_open +} + +{ + <Invalid read of size 1, 2, 4 on thomas's FC4> + Memcheck:Addr2 + fun:memcpy + fun:_dl_signal_error + fun:_dl_map_object_deps + fun:dl_open_worker + fun:_dl_catch_error + fun:_dl_open + fun:dlopen_doit + fun:_dl_catch_error + fun:_dlerror_run + fun:dlopen@@GLIBC_2.1 + fun:g_module_open +} +{ + <Invalid read of size 1, 2, 4 on thomas's FC4> + Memcheck:Addr4 + fun:memcpy + fun:_dl_signal_error + fun:_dl_map_object_deps + fun:dl_open_worker + fun:_dl_catch_error + fun:_dl_open + fun:dlopen_doit + fun:_dl_catch_error + fun:_dlerror_run + fun:dlopen@@GLIBC_2.1 + fun:g_module_open +} + +{ + <Addr8 on Andy's AMD64 ubuntu in dl_open> + Memcheck:Addr8 + obj:/lib/ld-2.3.*.so + obj:/lib/ld-2.3.*.so + obj:/lib/ld-2.3.*.so + obj:/lib/ld-2.3.*.so + obj:/lib/ld-2.3.*.so + obj:/lib/ld-2.3.*.so + obj:/lib/ld-2.3.*.so + obj:/lib/libc-2.3.*.so + obj:/lib/ld-2.3.*.so + fun:_dl_open + obj:/lib/libdl-2.3.*.so + obj:/lib/ld-2.3.*.so +} + +{ + <Conditional jump on Andy's AMD64 ubuntu> + Memcheck:Cond + obj:/lib/ld-2.3.*.so + obj:/lib/libc-2.3.*.so + obj:/lib/ld-2.3.*.so + fun:_dl_open + obj:/lib/libdl-2.3.*.so + obj:/lib/ld-2.3.*.so + obj:/lib/libdl-2.3.*.so + fun:dlopen + fun:g_module_open +} + +{ + <Mike's x86 dapper> + Memcheck:Addr4 + obj:/lib/ld-2.3.6.so + obj:/lib/ld-2.3.6.so + obj:/lib/tls/i686/cmov/libc-2.3.6.so + obj:/lib/ld-2.3.6.so + fun:_dl_open + obj:/lib/tls/i686/cmov/libdl-2.3.6.so + obj:/lib/ld-2.3.6.so + obj:/lib/tls/i686/cmov/libdl-2.3.6.so + fun:dlopen +} + +{ + <Mike's x86 dapper> + Memcheck:Cond + obj:/lib/ld-2.3.6.so + obj:/lib/tls/i686/cmov/libc-2.3.6.so + obj:/lib/ld-2.3.6.so + fun:_dl_open + obj:/lib/tls/i686/cmov/libdl-2.3.6.so + obj:/lib/ld-2.3.6.so + obj:/lib/tls/i686/cmov/libdl-2.3.6.so + fun:dlopen +} + +{ + <Another dapper one> + Memcheck:Cond + obj:/lib/ld-2.3.6.so + obj:/lib/ld-2.3.6.so + obj:/lib/ld-2.3.6.so + obj:/lib/tls/i686/cmov/libc-2.3.6.so + obj:/lib/ld-2.3.6.so + fun:_dl_open + obj:/lib/tls/i686/cmov/libdl-2.3.6.so + obj:/lib/ld-2.3.6.so + obj:/lib/tls/i686/cmov/libdl-2.3.6.so + fun:dlopen +} + +### glib suppressions +{ + <g_parse_debug_string> + Memcheck:Cond + fun:g_parse_debug_string + obj:/usr/lib*/libglib-2.0.so.* + fun:g_slice_alloc + fun:g_slice_alloc0 +} + +{ + <g_type_init malloc> + Memcheck:Leak + fun:malloc + fun:g_malloc + fun:g_strdup + fun:g_quark_from_string + obj:* + obj:* + fun:g_type_register_fundamental + obj:* + fun:g_type_init_with_debug_flags + fun:g_type_init +} + +{ + <g_type_init calloc> + Memcheck:Leak + fun:calloc + fun:g_malloc0 + obj:* + obj:* + fun:g_type_register_fundamental +} + +{ + <g_type_init calloc 2> + Memcheck:Leak + fun:calloc + fun:g_malloc0 + obj:* + obj:* + fun:g_type_init_with_debug_flags +} + +{ + <g_type_init calloc 3, GSlice version> + Memcheck:Leak + fun:calloc + fun:g_malloc0 + fun:g_slice_alloc + obj:* + obj:* + fun:g_type_init_with_debug_flags +} + +#pthread memleaks + +{ + Thread creation leak + Memcheck:Leak + fun:calloc + fun:allocate_dtv + fun:_dl_allocate* + fun:_dl_allocate* + fun:__pthread_initialize_minimal +} + +{ + Thread management leak + Memcheck:Leak + fun:calloc + fun:allocate_dtv + fun:_dl_allocate* + fun:_dl_allocate* + fun:__pthread_* +} + +{ + Thread management leak 2 + Memcheck:Leak + fun:memalign + fun:_dl_allocate* + fun:_dl_allocate* + fun:__pthread_* +} + +{ + pthread_create Syscall param write(buf) points to uninitialised byte(s) + Memcheck:Param + write(buf) + fun:pthread_create@@GLIBC_2.2.5 + fun:g_thread_create* + +} + +# nss_parse_* memleak (used by g_option_context_parse) +{ + nss_parse_* memleak + Memcheck:Leak + fun:malloc + fun:nss_parse_service_list + fun:__nss_database_lookup +} + +{ + <annoying read error inside dlopen stuff on Ubuntu Dapper x86_64> + Memcheck:Addr8 + obj:/lib/ld-2.3.6.so +} + +{ + <Ubuntu Dapper x86_64> + Memcheck:Param + futex(uaddr2) + fun:pthread_once + obj:/lib/libc-2.3.6.so + obj:/lib/libc-2.3.6.so + fun:setlocale + fun:init_pre + fun:g_option_context_parse +} + +{ + <Ubuntu Dapper x86_64 dlopen stuff again> + Memcheck:Cond + obj:/lib/ld-2.3.6.so + obj:/lib/ld-2.3.6.so + fun:_dl_open + obj:/lib/libdl-2.3.6.so + obj:/lib/ld-2.3.6.so + obj:/lib/libdl-2.3.6.so + fun:dlopen + fun:g_module_open +} +# this exists in a bunch of different variations, hence the short tail/trace +{ + <dlopen invalid read of size 4 suppression on tpm's Ubuntu edgy/x86> + Memcheck:Addr4 + obj:/lib/ld-2.4.so + obj:/lib/ld-2.4.so +} +{ + <and the same for 64bit systems> + Memcheck:Addr8 + obj:/lib/ld-2.4.so + obj:/lib/ld-2.4.so +} + +# More edgy suppressions (Mike) +{ + <dlopen Condition jump suppressions for Ubuntu Edgy/x86> + Memcheck:Cond + obj:/lib/ld-2.4.so + obj:/lib/ld-2.4.so + obj:/lib/ld-2.4.so + obj:/lib/ld-2.4.so + fun:dlopen_doit + obj:/lib/ld-2.4.so + fun:_dlerror_run + fun:dlopen@@GLIBC_2.1 +} + +{ + <dlopen Condition jump suppressions for Ubuntu Edgy/x86> + Memcheck:Cond + obj:/lib/ld-2.4.so + obj:/lib/ld-2.4.so + obj:/lib/ld-2.4.so + obj:/lib/ld-2.4.so + obj:/lib/ld-2.4.so + obj:/lib/ld-2.4.so + fun:dlopen_doit + obj:/lib/ld-2.4.so + fun:_dlerror_run + fun:dlopen@@GLIBC_2.1 +} + +{ + <dlopen Condition jump suppressions for Ubuntu Edgy/x86> + Memcheck:Cond + obj:/lib/ld-2.4.so + obj:/lib/ld-2.4.so + obj:/lib/ld-2.4.so + fun:do_sym + fun:_dl_sym +} + +# This one's overly general, but there's zero other information in the stack +# trace - just these five lines! +{ + <dlopen Condition jump suppressions for Ubuntu Edgy/x86> + Memcheck:Cond + obj:/lib/ld-2.4.so + obj:/lib/ld-2.4.so + obj:/lib/ld-2.4.so + obj:/lib/ld-2.4.so + obj:/lib/ld-2.4.so +} + +{ + <tls leaks on Edgy/x86> + Memcheck:Leak + fun:calloc + obj:/lib/ld-2.4.so + fun:_dl_allocate_tls + fun:pthread_create@@GLIBC_2.1 +} + +{ + <libcdio 0.76 leak> + Memcheck:Leak + fun:calloc + obj:/usr/lib/libcdio.so.6.0.1 + fun:cdio_open_am_linux + obj:/usr/lib/libcdio.so.6.0.1 + fun:cdio_open_am +} + +# TLS leaks for feisty/x86 +{ + <tls leaks on Feisty/x86> + Memcheck:Leak + fun:calloc + fun:allocate_dtv + fun:_dl_allocate_tls + fun:pthread_create@@GLIBC_2.1 +} + +{ + <Addr8 on Jan's AMD64 ubuntu Feisty in dl_open> + Memcheck:Addr8 + obj:/lib/ld-2.5.so +} + +{ + <GLib caching the home dir> + Memcheck:Leak + fun:malloc + obj:/lib/libc-*.so + fun:__nss_database_lookup + obj:* + obj:* + fun:getpwnam_r + fun:g_get_any_init_do + fun:g_get_home_dir +} +{ + <GLib caching the user name> + Memcheck:Leak + fun:malloc + obj:/lib/libc-*.so + fun:__nss_database_lookup + obj:* + obj:* + fun:getpwnam_r + fun:g_get_any_init_do + fun:g_get_user_name +} diff --git a/gnome-2-26/tests/xml/.gitignore b/gnome-2-26/tests/xml/.gitignore new file mode 100644 index 000000000..01af91dc1 --- /dev/null +++ b/gnome-2-26/tests/xml/.gitignore @@ -0,0 +1 @@ +user-irc-networks.xml diff --git a/gnome-2-26/tests/xml/Makefile.am b/gnome-2-26/tests/xml/Makefile.am new file mode 100644 index 000000000..a7cc0d7bd --- /dev/null +++ b/gnome-2-26/tests/xml/Makefile.am @@ -0,0 +1,4 @@ +EXTRA_DIST = \ + default-irc-networks-sample.xml \ + user-irc-networks-sample.xml \ + chatrooms-sample.xml diff --git a/gnome-2-26/tests/xml/chatrooms-sample.xml b/gnome-2-26/tests/xml/chatrooms-sample.xml new file mode 100644 index 000000000..e06c43e50 --- /dev/null +++ b/gnome-2-26/tests/xml/chatrooms-sample.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="utf-8"?> +<chatrooms> + <chatroom> + <name>name1</name> + <room>room1</room> + <account>CHANGE_ME</account> + <auto_connect>yes</auto_connect> + </chatroom> + <chatroom> + <name>name2</name> + <room>room2</room> + <account>CHANGE_ME</account> + <auto_connect>no</auto_connect> + </chatroom> +</chatrooms> diff --git a/gnome-2-26/tests/xml/default-irc-networks-sample.xml b/gnome-2-26/tests/xml/default-irc-networks-sample.xml new file mode 100644 index 000000000..257919c27 --- /dev/null +++ b/gnome-2-26/tests/xml/default-irc-networks-sample.xml @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="utf-8"?> + +<networks> + <network id="freenode" name="Freenode"> + <servers> + <server address="irc.freenode.net" port="6667" ssl="FALSE" /> + <server address="irc.eu.freenode.net" port="6667" ssl="FALSE" /> + </servers> + </network> + + <network id="gimpnet" name="GIMPNet"> + <servers> + <server address="irc.gimp.org" port="6667" ssl="FALSE" /> + <server address="irc.us.gimp.org" port="6667" ssl="FALSE" /> + </servers> + </network> + + <network id="testsrv" name="Test Server" network_charset="ISO-8859-1"> + <servers> + <server address="irc.test.org" port="6669" ssl="TRUE" /> + </servers> + </network> + + <network id="undernet" name="Undernet"> + <servers> + <server address="eu.undernet.org" port="6667" ssl="FALSE" /> + </servers> + </network> + +</networks> diff --git a/gnome-2-26/tests/xml/user-irc-networks-sample.xml b/gnome-2-26/tests/xml/user-irc-networks-sample.xml new file mode 100644 index 000000000..9e4f08693 --- /dev/null +++ b/gnome-2-26/tests/xml/user-irc-networks-sample.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="utf-8"?> + +<networks> + <network id="gimpnet" name="GIMPNet"> + <servers> + <server address="irc.gimp.org" port="6667" ssl="FALSE" /> + <server address="irc.us.gimp.org" port="6667" ssl="FALSE" /> + <server address="irc.au.gimp.org" port="6667" ssl="FALSE" /> + </servers> + </network> + + <network id="testsrv" name="Test Server" dropped="1"/> + + <network id="mysrv" name="My Server"> + <servers> + <server address="irc.mysrv.net" port="7495" ssl="TRUE" /> + </servers> + </network> + + <network id="anothersrv" name="Another Server"> + <servers> + <server address="irc.anothersrv.be" port="6660" ssl="FALSE" /> + </servers> + </network> + +</networks> |