diff options
author | Xavier Claessens <xclaesse@src.gnome.org> | 2008-03-04 01:00:33 +0800 |
---|---|---|
committer | Xavier Claessens <xclaesse@src.gnome.org> | 2008-03-04 01:00:33 +0800 |
commit | ef3204306ca354568754d552ed147496547c4ba4 (patch) | |
tree | 9f2efb9321e0f26a8bc05c68c29c0929cf6cf5b4 | |
parent | 178e698e0db4be2cd2750b027284c3eaaa49d01e (diff) | |
download | gsoc2013-empathy-ef3204306ca354568754d552ed147496547c4ba4.tar gsoc2013-empathy-ef3204306ca354568754d552ed147496547c4ba4.tar.gz gsoc2013-empathy-ef3204306ca354568754d552ed147496547c4ba4.tar.bz2 gsoc2013-empathy-ef3204306ca354568754d552ed147496547c4ba4.tar.lz gsoc2013-empathy-ef3204306ca354568754d552ed147496547c4ba4.tar.xz gsoc2013-empathy-ef3204306ca354568754d552ed147496547c4ba4.tar.zst gsoc2013-empathy-ef3204306ca354568754d552ed147496547c4ba4.zip |
Don't hardcode path to uninstalled files, use EMPATHY_SRCDIR env var instead.
svn path=/trunk/; revision=693
-rw-r--r-- | configure.ac | 8 | ||||
-rw-r--r-- | libempathy-gtk/empathy-account-widget-irc.c | 4 | ||||
-rw-r--r-- | libempathy-gtk/empathy-ui-utils.c | 3 | ||||
-rw-r--r-- | libempathy/empathy-utils.c | 3 | ||||
-rw-r--r-- | tests/Makefile.am | 1 | ||||
-rw-r--r-- | tests/check-empathy-irc-network-manager.c | 101 |
6 files changed, 84 insertions, 36 deletions
diff --git a/configure.ac b/configure.ac index e970c8d40..234750c7b 100644 --- a/configure.ac +++ b/configure.ac @@ -295,14 +295,6 @@ fi AM_CONDITIONAL(HAVE_VOIP, test "x$enable_voip" = "xyes") - -# ----------------------------------------------------------- -# Misc -# ----------------------------------------------------------- -AC_DEFINE_UNQUOTED([UNINSTALLED_GLADE_DIR], ["`pwd`/libempathy-gtk"], [path to glade files]) -AC_DEFINE_UNQUOTED([UNINSTALLED_DTD_DIR], ["`pwd`/libempathy"], [path to dtd files]) -AC_DEFINE_UNQUOTED([UNINSTALLED_IRC_DIR], ["`pwd`/libempathy"], [path to IRC network file]) - # ----------------------------------------------------------- AC_OUTPUT([ diff --git a/libempathy-gtk/empathy-account-widget-irc.c b/libempathy-gtk/empathy-account-widget-irc.c index 35fa7697f..5c74e0958 100644 --- a/libempathy-gtk/empathy-account-widget-irc.c +++ b/libempathy-gtk/empathy-account-widget-irc.c @@ -442,8 +442,8 @@ empathy_account_widget_irc_new (McAccount *account) user_file_with_path = g_build_filename (dir, IRC_NETWORKS_FILENAME, NULL); g_free (dir); - global_file_with_path = g_build_filename (UNINSTALLED_IRC_DIR, - IRC_NETWORKS_FILENAME, NULL); + global_file_with_path = g_build_filename (g_getenv ("EMPATHY_SRCDIR"), + "libempathy-gtk", IRC_NETWORKS_FILENAME, NULL); if (!g_file_test (global_file_with_path, G_FILE_TEST_EXISTS)) { g_free (global_file_with_path); diff --git a/libempathy-gtk/empathy-ui-utils.c b/libempathy-gtk/empathy-ui-utils.c index d5747a0ee..80dcd4227 100644 --- a/libempathy-gtk/empathy-ui-utils.c +++ b/libempathy-gtk/empathy-ui-utils.c @@ -65,7 +65,8 @@ get_glade_file (const gchar *filename, const char *name; GtkWidget **widget_ptr; - path = g_build_filename (UNINSTALLED_GLADE_DIR, filename, NULL); + path = g_build_filename (g_getenv ("EMPATHY_SRCDIR"), "libempathy-gtk", + filename, NULL); if (!g_file_test (path, G_FILE_TEST_EXISTS)) { g_free (path); path = g_build_filename (DATADIR, "empathy", filename, NULL); diff --git a/libempathy/empathy-utils.c b/libempathy/empathy-utils.c index dacd1668b..415dd7aeb 100644 --- a/libempathy/empathy-utils.c +++ b/libempathy/empathy-utils.c @@ -210,7 +210,8 @@ empathy_xml_validate (xmlDoc *doc, xmlDtd *dtd; gboolean ret; - path = g_build_filename (UNINSTALLED_DTD_DIR, dtd_filename, NULL); + path = g_build_filename (g_getenv ("EMPATHY_SRCDIR"), "libempathy", + dtd_filename, NULL); if (!g_file_test (path, G_FILE_TEST_EXISTS)) { g_free (path); path = g_build_filename (DATADIR, "empathy", dtd_filename, NULL); diff --git a/tests/Makefile.am b/tests/Makefile.am index 49f270951..e7b162797 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -45,3 +45,4 @@ check_main_CFLAGS = \ @CHECK_CFLAGS@ \ $(AM_CFLAGS) +TESTS_ENVIRONMENT = EMPATHY_SRCDIR=@abs_top_srcdir@ diff --git a/tests/check-empathy-irc-network-manager.c b/tests/check-empathy-irc-network-manager.c index c3e853135..3244a8e2f 100644 --- a/tests/check-empathy-irc-network-manager.c +++ b/tests/check-empathy-irc-network-manager.c @@ -10,9 +10,21 @@ #include <libempathy/empathy-irc-network-manager.h> -#define GLOBAL_SAMPLE "xml/default-irc-networks-sample.xml" -#define USER_SAMPLE "xml/user-irc-networks-sample.xml" -#define USER_FILE "xml/user-irc-networks.xml" +#define GLOBAL_SAMPLE "default-irc-networks-sample.xml" +#define USER_SAMPLE "user-irc-networks-sample.xml" +#define USER_FILE "user-irc-networks.xml" + +static gchar * +get_xml_file (const gchar *filename) +{ + return g_build_filename (g_getenv ("EMPATHY_SRCDIR"), "tests", "xml", filename, NULL); +} + +static gchar * +get_user_xml_file (const gchar *filename) +{ + return g_build_filename (g_get_tmp_dir (), filename, NULL); +} START_TEST (test_empathy_irc_network_manager_add) { @@ -78,16 +90,19 @@ START_TEST (test_load_global_file) struct server_t undernet_servers[] = { { "eu.undernet.org", 6667, FALSE }}; gboolean network_checked[4]; + gchar *global_file_orig; - mgr = empathy_irc_network_manager_new (GLOBAL_SAMPLE, NULL); + 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_SAMPLE) != 0); + 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); @@ -185,8 +200,11 @@ START_TEST (test_empathy_irc_network_manager_remove) { "eu.undernet.org", 6667, FALSE }}; gboolean network_checked[3]; gboolean result; + gchar *global_file_orig; - mgr = empathy_irc_network_manager_new (GLOBAL_SAMPLE, NULL); + 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); @@ -239,13 +257,19 @@ copy_user_file (void) gboolean result; gchar *buffer; gsize length; + gchar *user_sample; + gchar *user_file; - result = g_file_get_contents (USER_SAMPLE, &buffer, &length, NULL); + user_sample = get_xml_file (USER_SAMPLE); + result = g_file_get_contents (user_sample, &buffer, &length, NULL); fail_if (!result); - result = g_file_set_contents (USER_FILE, buffer, length, NULL); + user_file = get_user_xml_file (USER_FILE); + result = g_file_set_contents (user_file, buffer, length, NULL); fail_if (!result); + g_free (user_sample); + g_free (user_file); g_free (buffer); } @@ -263,18 +287,21 @@ START_TEST (test_load_user_file) struct server_t another_server[] = { { "irc.anothersrv.be", 6660, FALSE }}; gboolean network_checked[3]; + gchar *user_file_orig; copy_user_file (); - mgr = empathy_irc_network_manager_new (NULL, 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) != 0); + 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); @@ -337,17 +364,22 @@ START_TEST (test_load_both_files) struct server_t undernet_servers[] = { { "eu.undernet.org", 6667, FALSE }}; gboolean network_checked[5]; + gchar *global_file_orig, *user_file_orig; - mgr = empathy_irc_network_manager_new (GLOBAL_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_SAMPLE) != 0); - fail_if (user_file == NULL || strcmp (user_file, USER_FILE) != 0); + 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); @@ -419,16 +451,18 @@ START_TEST (test_modify_user_file) { "irc.anothersrv.be", 6660, FALSE }}; gboolean network_modified[2]; gboolean network_checked[3]; + gchar *user_file_orig; copy_user_file (); - mgr = empathy_irc_network_manager_new (NULL, 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) != 0); + fail_if (user_file == NULL || strcmp (user_file, user_file_orig) != 0); g_free (global_file); g_free (user_file); @@ -522,7 +556,8 @@ START_TEST (test_modify_user_file) /* Now let's reload the file and check its contain */ - mgr = empathy_irc_network_manager_new (NULL, USER_FILE); + 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); @@ -585,18 +620,23 @@ START_TEST (test_modify_both_files) { "us.undernet.org", 6667, FALSE }}; gboolean network_modified[4]; gboolean network_checked[4]; + gchar *global_file_orig, *user_file_orig; copy_user_file (); - mgr = empathy_irc_network_manager_new (GLOBAL_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_SAMPLE) != 0); - fail_if (user_file == NULL || strcmp (user_file, USER_FILE) != 0); + 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); @@ -705,7 +745,11 @@ START_TEST (test_modify_both_files) /* Now let's reload the file and check its contain */ - mgr = empathy_irc_network_manager_new (GLOBAL_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_free (global_file_orig); + g_free (user_file_orig); networks = empathy_irc_network_manager_get_networks (mgr); fail_if (g_slist_length (networks) != 4); @@ -763,8 +807,11 @@ START_TEST (test_empathy_irc_network_manager_find_network_by_address) struct server_t freenode_servers[] = { { "irc.freenode.net", 6667, FALSE }, { "irc.eu.freenode.net", 6667, FALSE }}; + gchar *global_file_orig; - mgr = empathy_irc_network_manager_new (GLOBAL_SAMPLE, NULL); + 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"); @@ -788,15 +835,21 @@ 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 */ - g_unlink (USER_FILE); + user_file_orig = get_user_xml_file (USER_FILE); + g_unlink (user_file_orig); - mgr = empathy_irc_network_manager_new (GLOBAL_SAMPLE, USER_FILE); + 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); + 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); |