aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Desmottes <gdesmott@gnome.org>2008-01-20 21:56:21 +0800
committerGuillaume Desmottes <gdesmott@gnome.org>2008-01-20 21:56:21 +0800
commit92d531a581a3a7d04757fd45ef0affbb7f7d2733 (patch)
tree17fb39e5f184b7fe675e95eb603b2424d9ec4a9d
parentb49d436924f1e49ef7c01e1e07cc2ae9ab1694de (diff)
downloadgsoc2013-empathy-92d531a581a3a7d04757fd45ef0affbb7f7d2733.tar
gsoc2013-empathy-92d531a581a3a7d04757fd45ef0affbb7f7d2733.tar.gz
gsoc2013-empathy-92d531a581a3a7d04757fd45ef0affbb7f7d2733.tar.bz2
gsoc2013-empathy-92d531a581a3a7d04757fd45ef0affbb7f7d2733.tar.lz
gsoc2013-empathy-92d531a581a3a7d04757fd45ef0affbb7f7d2733.tar.xz
gsoc2013-empathy-92d531a581a3a7d04757fd45ef0affbb7f7d2733.tar.zst
gsoc2013-empathy-92d531a581a3a7d04757fd45ef0affbb7f7d2733.zip
start to test networks XML file save
-rw-r--r--tests/check-empathy-irc-network-manager.c153
1 files changed, 153 insertions, 0 deletions
diff --git a/tests/check-empathy-irc-network-manager.c b/tests/check-empathy-irc-network-manager.c
index 4c4933222..d8c72dd7b 100644
--- a/tests/check-empathy-irc-network-manager.c
+++ b/tests/check-empathy-irc-network-manager.c
@@ -363,6 +363,158 @@ START_TEST (test_load_both_files)
}
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 }};
+ gboolean network_modified[2];
+ gboolean network_checked[2];
+
+ copy_user_file ();
+ mgr = empathy_irc_network_manager_new (NULL, USER_FILE);
+
+ 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) != 0);
+ g_free (global_file);
+ g_free (user_file);
+
+ networks = empathy_irc_network_manager_get_networks (mgr);
+ fail_if (g_slist_length (networks) != 2);
+
+ 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;
+
+ 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
+ {
+ 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_add_server (network, server);
+ empathy_irc_network_manager_add (mgr, network);
+ g_object_unref (server);
+ g_object_unref (network);
+
+ empathy_irc_network_manager_store (mgr);
+
+ 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);
+
+ networks = empathy_irc_network_manager_get_networks (mgr);
+ fail_if (g_slist_length (networks) != 2);
+
+ network_checked[0] = network_checked[1] = 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", gimpnet_servers, 2);
+ network_checked[0] = TRUE;
+ }
+ else if (strcmp (name, "Great Server") == 0)
+ {
+ check_network (l->data, "Great Server", great_server, 1);
+ network_checked[1] = TRUE;
+ }
+ else
+ {
+ fail_if (TRUE);
+ }
+
+ g_free (name);
+ }
+ fail_if (!network_checked[0] || !network_checked[1]);
+
+ 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)
{
@@ -372,5 +524,6 @@ make_empathy_irc_network_manager_tcase (void)
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);
return tc;
}