empathy r1577 - trunk/tests
- From: xclaesse svn gnome org
- To: svn-commits-list gnome org
- Subject: empathy r1577 - trunk/tests
- Date: Mon, 13 Oct 2008 07:55:36 +0000 (UTC)
Author: xclaesse
Date: Mon Oct 13 07:55:36 2008
New Revision: 1577
URL: http://svn.gnome.org/viewvc/empathy?rev=1577&view=rev
Log:
check-empathy-chatroom-manager.c: factor out change_account_name_in_file
Modified:
trunk/tests/check-empathy-chatroom-manager.c
Modified: trunk/tests/check-empathy-chatroom-manager.c
==============================================================================
--- trunk/tests/check-empathy-chatroom-manager.c (original)
+++ trunk/tests/check-empathy-chatroom-manager.c Mon Oct 13 07:55:36 2008
@@ -82,10 +82,29 @@
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_new)
{
EmpathyChatroomManager *mgr;
- gchar *cmd;
gchar *file;
McAccount *account;
struct chatroom_t chatrooms[] = {
@@ -97,17 +116,10 @@
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 */
- cmd = g_strdup_printf ("sed -i 's/CHANGE_ME/%s/' %s",
- mc_account_get_unique_name (account), file);
- if (system (cmd) == -1)
- {
- g_print ("system call failed\n");
- return;
- }
-
- g_free (cmd);
+ /* 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_new (file);
check_chatrooms_list (mgr, account, chatrooms, 2);
@@ -121,7 +133,6 @@
START_TEST (test_empathy_chatroom_manager_add)
{
EmpathyChatroomManager *mgr;
- gchar *cmd;
gchar *file;
McAccount *account;
struct chatroom_t chatrooms[] = {
@@ -136,11 +147,10 @@
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 */
- cmd = g_strdup_printf ("sed -i 's/CHANGE_ME/%s/' %s",
- mc_account_get_unique_name (account), file);
- system (cmd);
- g_free (cmd);
+ if (!change_account_name_in_file (account, file))
+ return;
mgr = empathy_chatroom_manager_new (file);
@@ -183,7 +193,6 @@
START_TEST (test_empathy_chatroom_manager_remove)
{
EmpathyChatroomManager *mgr;
- gchar *cmd;
gchar *file;
McAccount *account;
struct chatroom_t chatrooms[] = {
@@ -195,11 +204,10 @@
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 */
- cmd = g_strdup_printf ("sed -i 's/CHANGE_ME/%s/' %s",
- mc_account_get_unique_name (account), file);
- system (cmd);
- g_free (cmd);
+ if (!change_account_name_in_file (account, file))
+ return;
mgr = empathy_chatroom_manager_new (file);
@@ -239,7 +247,6 @@
START_TEST (test_empathy_chatroom_manager_change_favorite)
{
EmpathyChatroomManager *mgr;
- gchar *cmd;
gchar *file;
McAccount *account;
struct chatroom_t chatrooms[] = {
@@ -252,11 +259,10 @@
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 */
- cmd = g_strdup_printf ("sed -i 's/CHANGE_ME/%s/' %s",
- mc_account_get_unique_name (account), file);
- system (cmd);
- g_free (cmd);
+ if (!change_account_name_in_file (account, file))
+ return;
mgr = empathy_chatroom_manager_new (file);
@@ -303,7 +309,6 @@
START_TEST (test_empathy_chatroom_manager_change_chatroom)
{
EmpathyChatroomManager *mgr;
- gchar *cmd;
gchar *file;
McAccount *account;
struct chatroom_t chatrooms[] = {
@@ -313,19 +318,13 @@
account = get_test_account ();
- /*
- copy_xml_file (CHATROOM_SAMPLE, CHATROOM_FILE);
-
- file = get_user_xml_file (CHATROOM_FILE);
- */
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 */
- cmd = g_strdup_printf ("sed -i 's/CHANGE_ME/%s/' %s",
- mc_account_get_unique_name (account), file);
- system (cmd);
- g_free (cmd);
+ if (!change_account_name_in_file (account, file))
+ return;
mgr = empathy_chatroom_manager_new (file);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]