Patch: folder-remove test
- From: Antia Puentes Felpeto <apuentes igalia com>
- To: tinymail-devel-list <tinymail-devel-list gnome org>
- Subject: Patch: folder-remove test
- Date: Tue, 12 Jun 2007 18:28:52 +0200
Hi,
a patch for the folder-remove test.
Regards,
Antía.
Index: tests/functional/folder-remove.c
===================================================================
--- tests/functional/folder-remove.c (revisión: 0)
+++ tests/functional/folder-remove.c (revisión: 0)
@@ -0,0 +1,159 @@
+/* tinymail - Tiny Mail
+ * Copyright (C) 2006-2007 Antia Puentes Felpeto <apuentes igalia com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with self program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <string.h>
+
+#include <glib.h>
+#include <stdlib.h>
+
+#include <tny-list.h>
+#include <tny-iterator.h>
+#include <tny-simple-list.h>
+#include <tny-account-store.h>
+#include <tny-store-account.h>
+#include <tny-folder.h>
+#include <tny-folder-store.h>
+#include <tny-folder-store-query.h>
+
+#include <account-store.h>
+
+static gchar *cachedir=NULL;
+static gboolean online=FALSE;
+static const gchar *src_name = NULL;
+static TnyFolder *src_folder = NULL;
+static gint recursion_level=0;
+
+
+static const GOptionEntry options[] = {
+ { "name", 'n', 0, G_OPTION_ARG_STRING, &src_name,
+ "Name folder", NULL},
+ { "cachedir", 'c', 0, G_OPTION_ARG_STRING, &cachedir,
+ "Cache directory", NULL },
+ { "online", 'o', 0, G_OPTION_ARG_NONE, &online,
+ "Online or offline", NULL },
+ { NULL }
+};
+
+static void
+recurse_folders (TnyFolderStore *store, TnyFolderStoreQuery *query)
+{
+ TnyIterator *iter;
+ TnyList *folders = tny_simple_list_new ();
+
+ tny_folder_store_get_folders (store, folders, query, NULL);
+ iter = tny_list_create_iterator (folders);
+
+ while (!tny_iterator_is_done (iter))
+ {
+ TnyFolderStore *folder = (TnyFolderStore*) tny_iterator_get_current (iter);
+ gint i=0;
+ const gchar *folder_name = NULL;
+
+ for (i=0; i<recursion_level; i++)
+ g_print ("\t");
+
+ folder_name = tny_folder_get_name (TNY_FOLDER (folder));
+ g_print ("%s\n", folder_name);
+
+ if (!strcmp (folder_name, src_name))
+ src_folder = g_object_ref (folder);
+
+ recursion_level++;
+ recurse_folders (folder, query);
+ recursion_level--;
+
+ g_object_unref (G_OBJECT (folder));
+
+ tny_iterator_next (iter);
+ }
+
+ g_object_unref (G_OBJECT (iter));
+ g_object_unref (G_OBJECT (folders));
+}
+
+int
+main (int argc, char **argv)
+{
+ GOptionContext *context;
+ TnyAccountStore *account_store;
+ TnyList *accounts;
+ TnyStoreAccount *account;
+ TnyIterator *iter;
+ gint i;
+ GError *err = NULL;
+
+ free (malloc (10));
+
+ g_type_init ();
+
+ context = g_option_context_new ("- The tinymail functional tester");
+ g_option_context_add_main_entries (context, options, "tinymail");
+ g_option_context_parse (context, &argc, &argv, NULL);
+
+ account_store = tny_test_account_store_new (online, cachedir);
+
+ if (cachedir)
+ g_print ("Using %s as cache directory\n", cachedir);
+
+ g_option_context_free (context);
+ accounts = tny_simple_list_new ();
+
+ tny_account_store_get_accounts (account_store, accounts,
+ TNY_ACCOUNT_STORE_STORE_ACCOUNTS);
+ g_object_unref (G_OBJECT (account_store));
+ iter = tny_list_create_iterator (accounts);
+ account = (TnyStoreAccount*) tny_iterator_get_current (iter);
+
+ recursion_level = 0;
+ for (i=0; i<1; i++)
+ recurse_folders (TNY_FOLDER_STORE (account), NULL);
+
+
+ if (!(src_folder)) {
+ g_message ("Folder not found");
+ goto cleanup;
+ }
+
+ g_print ("Remove folder %s\n",
+ tny_folder_get_name (src_folder));
+
+ TnyFolderStore *folder_store = tny_folder_get_folder_store (src_folder);
+
+ if (!(folder_store)) {
+ g_message ("Folderstore not found");
+ goto cleanup;
+ }
+
+ tny_folder_store_remove_folder (folder_store, src_folder, &err);
+ g_object_unref (G_OBJECT (src_folder));
+
+ if (err)
+ g_warning ("%s", err->message);
+
+ for (i=0; i<1; i++)
+ recurse_folders (TNY_FOLDER_STORE (account), NULL);
+
+
+ cleanup:
+ g_object_unref (G_OBJECT (account));
+ g_object_unref (G_OBJECT (iter));
+ g_object_unref (G_OBJECT (accounts));
+ return 0;
+
+}
+
Index: tests/functional/Makefile.am
===================================================================
--- tests/functional/Makefile.am (revisión: 2068)
+++ tests/functional/Makefile.am (copia de trabajo)
@@ -15,7 +15,7 @@
INCLUDES += -DMOZEMBED
endif
-bin_PROGRAMS = folder-lister folder-lister-async msg-transfer msg-sender anything folder-transfer account-refresh
+bin_PROGRAMS = folder-lister folder-lister-async msg-transfer msg-sender anything folder-transfer account-refresh folder-remove
anything_SOURCES = anything.c
anything_LDADD = \
@@ -79,3 +79,12 @@
$(top_builddir)/libtinymailui-gtk/libtinymailui-gtk-$(API_VERSION).la \
$(top_builddir)/libtinymail-camel/libtinymail-camel-$(API_VERSION).la \
$(top_builddir)/tests/shared/libtestsshared.a
+
+folder_remove_SOURCES = folder-remove.c
+folder_remove_LDADD = \
+ $(TINYMAIL_LIBS) $(LIBTINYMAIL_GNOME_DESKTOP_LIBS) \
+ $(top_builddir)/libtinymail/libtinymail-$(API_VERSION).la \
+ $(top_builddir)/libtinymailui/libtinymailui-$(API_VERSION).la \
+ $(top_builddir)/libtinymailui-gtk/libtinymailui-gtk-$(API_VERSION).la \
+ $(top_builddir)/libtinymail-camel/libtinymail-camel-$(API_VERSION).la \
+ $(top_builddir)/tests/shared/libtestsshared.a
Index: tests/shared/account-store.c
===================================================================
--- tests/shared/account-store.c (revisión: 2068)
+++ tests/shared/account-store.c (copia de trabajo)
@@ -51,9 +51,9 @@
per_account_get_pass_func (TnyAccount *account, const gchar *prompt, gboolean *cancel)
{
if (strstr (tny_account_get_name (account), "SMTP"))
- return g_strdup ("unittest");
+ return g_strdup ("local");
else
- return g_strdup ("tnytest");
+ return g_strdup ("local");
}
static void
@@ -116,15 +116,35 @@
tny_camel_account_set_session (TNY_CAMEL_ACCOUNT (account), me->session);
camel_session_set_online ((CamelSession*)me->session, me->force_online);
tny_camel_account_set_online (TNY_CAMEL_ACCOUNT (account), me->force_online, NULL);
-
+ /*
tny_account_set_proto (account, "imap");
- tny_account_set_name (account, "imap1.tinymail.org");
+ tny_account_set_name (account, "imap2.tinymail.org");
tny_account_set_user (account, "tnytest");
- tny_account_set_hostname (account, "imap1.tinymail.org");
- tny_account_set_id (account, "tnytest imap1 tinymail org");
+ tny_account_set_hostname (account, "imap2.tinymail.org");
+ tny_account_set_id (account, "tnytest imap2 tinymail org");
tny_account_set_forget_pass_func (account, per_account_forget_pass_func);
tny_account_set_pass_func (account, per_account_get_pass_func);
+ */
+ /* gmail account */
+ /*
+ tny_account_set_proto (account, "pop");
+ tny_account_set_name (account, "TinymailTest");
+ tny_account_set_user (account, "tiny.testing");
+ tny_account_set_hostname (account, "pop.gmail.com");
+ tny_account_set_id (account, "tiny testing gmail com");
+ */
+ /* uml account */
+
+ tny_account_set_proto (account, "imap");
+ tny_account_set_name (account, "local localhost");
+ tny_account_set_user (account, "local");
+ tny_account_set_hostname (account, "192.168.3.2");
+ tny_account_set_id (account, "local localhost");
+
+
+ tny_account_set_forget_pass_func (account, per_account_forget_pass_func);
+ tny_account_set_pass_func (account, per_account_get_pass_func);
tny_list_prepend (list, (GObject*)account);
g_object_unref (G_OBJECT (account));
}
@@ -136,12 +156,21 @@
tny_camel_account_set_session (TNY_CAMEL_ACCOUNT (account), me->session);
camel_session_set_online ((CamelSession*)me->session, me->force_online);
tny_camel_account_set_online (TNY_CAMEL_ACCOUNT (account), me->force_online, NULL);
-
+ /*
tny_account_set_proto (account, "something");
tny_account_set_name (account, "SMTP unit test account");
tny_account_set_id (account, "unique_smtp");
tny_account_set_url_string (account, "smtp://tinymailunittest;auth=PLAIN mail tinymail org:2222/;use_ssl=always");
+ */
+ /* gmail account */
+ /*
+ tny_account_set_proto (account, "smtp");
+ tny_account_set_name (account, "TinymailSMTP");
+ tny_account_set_id (account, "other_id");
+ tny_account_set_url_string (account, "smtp://tiny.testing;auth=PLAIN smtp gmail com:587;use_ssl=always");
+ */
+
tny_account_set_forget_pass_func (account, per_account_forget_pass_func);
tny_account_set_pass_func (account, per_account_get_pass_func);
Index: ChangeLog
===================================================================
--- ChangeLog (revisión: 2068)
+++ ChangeLog (copia de trabajo)
@@ -1,3 +1,6 @@
+2007-06-12 Antia Puentes Felpeto <apuentes igalia com>
+ * Added a test in tests/functional that tests removing folders
+
2007-06-01 Murray Cumming <murrayc murrayc com>
* libtinymail-camel/tny-camel-folder.c:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]