[evolution-data-server] Adapt Camel tests to recent API changes.



commit c83e9c003b749465d28b4f89d7db273e2b3faf8b
Author: Matthew Barnes <mbarnes redhat com>
Date:   Sun May 8 11:35:46 2011 -0400

    Adapt Camel tests to recent API changes.

 camel/tests/folder/test10.c |   12 +++++++++++-
 camel/tests/folder/test11.c |   38 +++++++++++++++++++++-----------------
 camel/tests/folder/test3.c  |   13 ++++++++++---
 camel/tests/folder/test8.c  |   12 ++++++++++--
 camel/tests/folder/test9.c  |   14 ++++++++++++--
 camel/tests/lib/folders.c   |   19 ++++++++++++-------
 camel/tests/lib/session.c   |    9 +++------
 camel/tests/message/test1.c |   21 +++++++++++----------
 camel/tests/smime/pgp.c     |    9 +++------
 9 files changed, 93 insertions(+), 54 deletions(-)
---
diff --git a/camel/tests/folder/test10.c b/camel/tests/folder/test10.c
index 16448b8..0243146 100644
--- a/camel/tests/folder/test10.c
+++ b/camel/tests/folder/test10.c
@@ -29,10 +29,20 @@ worker (gpointer d)
 {
 	gint i;
 	CamelStore *store;
+	CamelService *service;
 	CamelFolder *folder;
 
 	for (i=0;i<MAX_LOOP;i++) {
-		store = camel_session_get_store (session, path, NULL);
+		gchar *uid;
+
+		uid = g_strdup_printf ("test-uid-%d", i);
+		service = camel_session_add_service (
+			session, uid, path, CAMEL_PROVIDER_STORE, NULL);
+		g_free (uid);
+
+		check (CAMEL_IS_STORE (service));
+		store = CAMEL_STORE (service);
+
 		folder = camel_store_get_folder_sync (
 			store, "testbox",
 			CAMEL_STORE_FOLDER_CREATE, NULL, NULL);
diff --git a/camel/tests/folder/test11.c b/camel/tests/folder/test11.c
index b23ee28..021eb66 100644
--- a/camel/tests/folder/test11.c
+++ b/camel/tests/folder/test11.c
@@ -17,25 +17,25 @@ static CamelSession *session;
 /* FIXME: flags aren't really right yet */
 /* ASCII sorted on full_name */
 static CamelFolderInfo fi_list_1[] = {
-	{ NULL, NULL, NULL, "maildir:/tmp/camel-test/maildir#.", "Inbox", ".", CAMEL_FOLDER_SYSTEM|CAMEL_FOLDER_NOCHILDREN, -1, -1 },
-	{ NULL, NULL, NULL, "maildir:/tmp/camel-test/maildir#.%23evolution/Junk", "Junk", ".#evolution/Junk", CAMEL_FOLDER_SYSTEM|CAMEL_FOLDER_NOCHILDREN, -1, -1 },
-	{ NULL, NULL, NULL, "maildir:/tmp/camel-test/maildir#.%23evolution/Trash", "Trash", ".#evolution/Trash", CAMEL_FOLDER_SYSTEM|CAMEL_FOLDER_NOCHILDREN, -1, -1 },
-	{ NULL, NULL, NULL, "maildir:/tmp/camel-test/maildir#testbox", "testbox", "testbox", CAMEL_FOLDER_CHILDREN, -1, -1 },
-	{ NULL, NULL, NULL, "maildir:/tmp/camel-test/maildir#testbox/foo", "foo", "testbox/foo", CAMEL_FOLDER_NOCHILDREN, -1, -1 },
-	{ NULL, NULL, NULL, "maildir:/tmp/camel-test/maildir#testbox2", "testbox2", "testbox2", CAMEL_FOLDER_NOCHILDREN, -1, -1 },
+	{ NULL, NULL, NULL, ".", "Inbox", CAMEL_FOLDER_SYSTEM|CAMEL_FOLDER_NOCHILDREN, -1, -1 },
+	{ NULL, NULL, NULL, ".#evolution/Junk", "Junk", CAMEL_FOLDER_SYSTEM|CAMEL_FOLDER_NOCHILDREN, -1, -1 },
+	{ NULL, NULL, NULL, ".#evolution/Trash", "Trash", CAMEL_FOLDER_SYSTEM|CAMEL_FOLDER_NOCHILDREN, -1, -1 },
+	{ NULL, NULL, NULL, "testbox", "testbox", CAMEL_FOLDER_CHILDREN, -1, -1 },
+	{ NULL, NULL, NULL, "testbox/foo", "foo", CAMEL_FOLDER_NOCHILDREN, -1, -1 },
+	{ NULL, NULL, NULL, "testbox2", "testbox2", CAMEL_FOLDER_NOCHILDREN, -1, -1 },
 };
 
 static CamelFolderInfo fi_list_2[] = {
-	{ NULL, NULL, NULL, "maildir:/tmp/camel-test/maildir#.", "Inbox", ".", CAMEL_FOLDER_SYSTEM|CAMEL_FOLDER_NOCHILDREN, -1, -1 },
-	{ NULL, NULL, NULL, "maildir:/tmp/camel-test/maildir#.%23evolution/Junk", "Junk", ".#evolution/Junk", CAMEL_FOLDER_SYSTEM|CAMEL_FOLDER_NOCHILDREN, -1, -1 },
-	{ NULL, NULL, NULL, "maildir:/tmp/camel-test/maildir#.%23evolution/Trash", "Trash", ".#evolution/Trash", CAMEL_FOLDER_SYSTEM|CAMEL_FOLDER_NOCHILDREN, -1, -1 },
-	{ NULL, NULL, NULL, "maildir:/tmp/camel-test/maildir#testbox", "testbox", "testbox", CAMEL_FOLDER_NOCHILDREN, -1, -1 },
-	{ NULL, NULL, NULL, "maildir:/tmp/camel-test/maildir#testbox2", "testbox2", "testbox2", CAMEL_FOLDER_NOCHILDREN, -1, -1 },
+	{ NULL, NULL, NULL, ".", "Inbox", CAMEL_FOLDER_SYSTEM|CAMEL_FOLDER_NOCHILDREN, -1, -1 },
+	{ NULL, NULL, NULL, ".#evolution/Junk", "Junk", CAMEL_FOLDER_SYSTEM|CAMEL_FOLDER_NOCHILDREN, -1, -1 },
+	{ NULL, NULL, NULL, ".#evolution/Trash", "Trash", CAMEL_FOLDER_SYSTEM|CAMEL_FOLDER_NOCHILDREN, -1, -1 },
+	{ NULL, NULL, NULL, "testbox", "testbox", CAMEL_FOLDER_NOCHILDREN, -1, -1 },
+	{ NULL, NULL, NULL, "testbox2", "testbox2", CAMEL_FOLDER_NOCHILDREN, -1, -1 },
 };
 
 static CamelFolderInfo fi_list_3[] = {
-	{ NULL, NULL, NULL, "maildir:/tmp/camel-test/maildir#testbox", "testbox", "testbox", CAMEL_FOLDER_CHILDREN, -1, -1 },
-	{ NULL, NULL, NULL, "maildir:/tmp/camel-test/maildir#testbox/foo", "foo", "testbox/foo", CAMEL_FOLDER_NOCHILDREN, -1, -1 },
+	{ NULL, NULL, NULL, "testbox", "testbox", CAMEL_FOLDER_CHILDREN, -1, -1 },
+	{ NULL, NULL, NULL, "testbox/foo", "foo", CAMEL_FOLDER_NOCHILDREN, -1, -1 },
 };
 
 static gint
@@ -70,14 +70,13 @@ check_fi (CamelFolderInfo *fi, CamelFolderInfo *list, gint len)
 	for (i=0;i<len;i++) {
 		CamelFolderInfo *f = folders->pdata[i];
 
-		camel_test_push ("checking folder '%s'", list[i].uri);
+		camel_test_push ("checking folder '%s'", list[i].display_name);
 
-		check_msg (!strcmp (f->uri, list[i].uri), "got '%s' expecting '%s'", f->uri, list[i].uri);
 		check (!strcmp (f->full_name, list[i].full_name));
 
 		/* this might be translated, but we can't know */
 		camel_test_nonfatal ("Inbox not english");
-		check (!strcmp (f->name, list[i].name));
+		check (!strcmp (f->display_name, list[i].display_name));
 		camel_test_fatal ();
 
 		camel_test_nonfatal ("Flags mismatch");
@@ -95,6 +94,7 @@ main (gint argc, gchar **argv)
 {
 	CamelFolder *f1, *f2;
 	CamelStore *store;
+	CamelService *service;
 	CamelFolderInfo *fi;
 	GError *error = NULL;
 
@@ -105,7 +105,11 @@ main (gint argc, gchar **argv)
 	system ("/bin/rm -rf /tmp/camel-test");
 
 	session = camel_test_session_new ("/tmp/camel-test");
-	store = camel_session_get_store (session, "maildir:///tmp/camel-test/maildir", NULL);
+	service = camel_session_add_service (
+		session, "test-uid",
+		"maildir:///tmp/camel-test/maildir",
+		CAMEL_PROVIDER_STORE, NULL);
+	store = CAMEL_STORE (service);
 
 	camel_test_start ("Maildir backward compatability tests");
 
diff --git a/camel/tests/folder/test3.c b/camel/tests/folder/test3.c
index ed41d0d..97857f0 100644
--- a/camel/tests/folder/test3.c
+++ b/camel/tests/folder/test3.c
@@ -137,6 +137,7 @@ static const gchar *stores[] = {
 
 gint main (gint argc, gchar **argv)
 {
+	CamelService *service;
 	CamelSession *session;
 	CamelStore *store;
 	CamelFolder *folder;
@@ -162,15 +163,21 @@ gint main (gint argc, gchar **argv)
 		const gchar *name = stores[i];
 		for (indexed = 0;indexed<2;indexed++) {
 			gchar *what = g_strdup_printf ("folder search: %s (%sindexed)", name, indexed?"":"non-");
+			gchar *uid;
 			gint flags;
 
 			camel_test_start (what);
 			test_free (what);
 
 			push ("getting store");
-			store = camel_session_get_store (session, stores[i], &error);
-			check_msg (error == NULL, "getting store: %s", error->message);
-			check (store != NULL);
+			uid = g_strdup_printf ("test-uid-%d", i);
+			service = camel_session_add_service (
+				session, uid, stores[i],
+				CAMEL_PROVIDER_STORE, &error);
+			g_free (uid);
+			check_msg (error == NULL, "adding store: %s", error->message);
+			check (CAMEL_IS_STORE (service));
+			store = CAMEL_STORE (service);
 			g_clear_error (&error);
 			pull ();
 
diff --git a/camel/tests/folder/test8.c b/camel/tests/folder/test8.c
index f3bc4e0..14264b9 100644
--- a/camel/tests/folder/test8.c
+++ b/camel/tests/folder/test8.c
@@ -121,6 +121,7 @@ gint main (gint argc, gchar **argv)
 	gint i, j, index;
 	gchar *path;
 	CamelStore *store;
+	CamelService *service;
 	GThread *threads[MAX_THREADS];
 	struct _threadinfo *info;
 	CamelFolder *folder;
@@ -137,15 +138,22 @@ gint main (gint argc, gchar **argv)
 
 	for (j = 0; j < G_N_ELEMENTS (local_providers); j++) {
 		for (index=0;index<2;index++) {
+			gchar *uid;
+
 			path = g_strdup_printf ("method %s %s", local_providers[j], index?"indexed":"nonindexed");
 			camel_test_start (path);
 			test_free (path);
 
 			push ("trying %s index %d", local_providers[j], index);
+			uid = g_strdup_printf ("test-uid-%d", j);
 			path = g_strdup_printf ("%s:///tmp/camel-test/%s", local_providers[j], local_providers[j]);
-			store = camel_session_get_store (session, path, &error);
+			service = camel_session_add_service (
+				session, uid, path,
+				CAMEL_PROVIDER_STORE, &error);
+			g_free (uid);
 			check_msg (error == NULL, "%s", error->message);
-			g_clear_error (&error);
+			check (CAMEL_IS_STORE (service));
+			store = CAMEL_STORE (service);
 			test_free (path);
 
 			if (index == 0)
diff --git a/camel/tests/folder/test9.c b/camel/tests/folder/test9.c
index f077a3f..292b38f 100644
--- a/camel/tests/folder/test9.c
+++ b/camel/tests/folder/test9.c
@@ -82,6 +82,7 @@ get_folder (CamelFilterDriver *d,
 
 gint main (gint argc, gchar **argv)
 {
+	CamelService *service;
 	CamelSession *session;
 	CamelStore *store;
 	CamelFolder *folder;
@@ -105,9 +106,12 @@ gint main (gint argc, gchar **argv)
 	/* todo: work out how to do imap/pop/nntp tests */
 
 	push ("getting store");
-	store = camel_session_get_store (session, "mbox:///tmp/camel-test/mbox", &error);
+	service = camel_session_add_service (
+		session, "test-uid", "mbox:///tmp/camel-test/mbox",
+		CAMEL_PROVIDER_STORE, &error);
 	check_msg (error == NULL, "getting store: %s", error->message);
-	check (store != NULL);
+	check (CAMEL_IS_STORE (service));
+	store = CAMEL_STORE (service);
 	g_clear_error (&error);
 	pull ();
 
@@ -173,8 +177,10 @@ gint main (gint argc, gchar **argv)
 
 	push ("Executing filters");
 	camel_filter_driver_set_default_folder (driver, mailboxes[0].folder);
+#if 0  /* FIXME We no longer filter mbox files. */
 	camel_filter_driver_filter_mbox (
 		driver, "/tmp/camel-test/inbox", NULL, NULL, &error);
+#endif
 	check_msg (error == NULL, "%s", error->message);
 
 	/* now need to check the folder counts/etc */
@@ -190,8 +196,10 @@ gint main (gint argc, gchar **argv)
 		driver = camel_filter_driver_new (session);
 		camel_filter_driver_set_folder_func (driver, get_folder, NULL);
 		camel_filter_driver_add_rule (driver, brokens[i].name, brokens[i].match, brokens[i].action);
+#if 0  /* FIXME We no longer filter mbox files. */
 		camel_filter_driver_filter_mbox (
 			driver, "/tmp/camel-test/inbox", NULL, NULL, &error);
+#endif
 		check (error != NULL);
 		check_unref (driver, 1);
 		g_clear_error (&error);
@@ -205,8 +213,10 @@ gint main (gint argc, gchar **argv)
 		driver = camel_filter_driver_new (session);
 		camel_filter_driver_set_folder_func (driver, get_folder, NULL);
 		camel_filter_driver_add_rule (driver, brokena[i].name, brokena[i].match, brokena[i].action);
+#if 0  /* FIXME We no longer filter mbox files. */
 		camel_filter_driver_filter_mbox (
 			driver, "/tmp/camel-test/inbox", NULL, NULL, &error);
+#endif
 		check (error != NULL);
 		check_unref (driver, 1);
 		g_clear_error (&error);
diff --git a/camel/tests/lib/folders.c b/camel/tests/lib/folders.c
index 15e8919..6ccda3f 100644
--- a/camel/tests/lib/folders.c
+++ b/camel/tests/lib/folders.c
@@ -195,6 +195,7 @@ test_folder_basic (CamelSession *session, const gchar *storename, gint local, gi
 {
 	CamelStore *store;
 	CamelFolder *folder;
+	CamelService *service;
 	gchar *what = g_strdup_printf ("testing store: %s", storename);
 	GError *error = NULL;
 
@@ -202,10 +203,11 @@ test_folder_basic (CamelSession *session, const gchar *storename, gint local, gi
 	test_free (what);
 
 	push ("getting store");
-	store = camel_session_get_store (session, storename, &error);
-	check_msg (error == NULL, "getting store: %s", error->message);
-	check (store != NULL);
-	g_clear_error (&error);
+	service = camel_session_add_service (
+		session, storename, storename, CAMEL_PROVIDER_STORE, &error);
+	check_msg (error == NULL, "adding store: %s", error->message);
+	check (CAMEL_IS_STORE (service));
+	store = CAMEL_STORE (service);
 	pull ();
 
 	/* local providers == no inbox */
@@ -329,6 +331,7 @@ void
 test_folder_message_ops (CamelSession *session, const gchar *name, gint local, const gchar *mailbox)
 {
 	CamelStore *store;
+	CamelService *service;
 	CamelFolder *folder;
 	CamelMimeMessage *msg;
 	gint j;
@@ -347,9 +350,11 @@ test_folder_message_ops (CamelSession *session, const gchar *name, gint local, c
 		test_free (what);
 
 		push ("getting store");
-		store = camel_session_get_store (session, name, &error);
-		check_msg (error == NULL, "getting store: %s", error->message);
-		check (store != NULL);
+		service = camel_session_add_service (
+			session, name, name, CAMEL_PROVIDER_STORE, &error);
+		check_msg (error == NULL, "adding store: %s", error->message);
+		check (CAMEL_IS_STORE (service));
+		store = CAMEL_STORE (service);
 		g_clear_error (&error);
 		pull ();
 
diff --git a/camel/tests/lib/session.c b/camel/tests/lib/session.c
index b155069..4be1478 100644
--- a/camel/tests/lib/session.c
+++ b/camel/tests/lib/session.c
@@ -19,10 +19,7 @@ camel_test_session_init (CamelTestSession *test_session)
 CamelSession *
 camel_test_session_new (const gchar *path)
 {
-	CamelSession *session;
-
-	session = g_object_new (CAMEL_TYPE_TEST_SESSION, NULL);
-	camel_session_construct (session, path);
-
-	return session;
+	return g_object_new (
+		CAMEL_TYPE_TEST_SESSION,
+		"user-data-dir", path, NULL);
 }
diff --git a/camel/tests/message/test1.c b/camel/tests/message/test1.c
index 7c3b5a0..bb925fd 100644
--- a/camel/tests/message/test1.c
+++ b/camel/tests/message/test1.c
@@ -40,17 +40,17 @@ setup (void)
 	gchar *p;
 
 	/* setup various edge and other general cases */
-	texts[0].text = "";
+	texts[0].text = g_strdup ("");
 	texts[0].len = 0;
-	texts[1].text = "";
+	texts[1].text = g_strdup ("");
 	texts[1].len = 1;
-	texts[2].text = "\n";
+	texts[2].text = g_strdup ("\n");
 	texts[2].len = 1;
-	texts[3].text = "A";
+	texts[3].text = g_strdup ("A");
 	texts[3].len = 1;
-	texts[4].text = "This is a test.\n.";
+	texts[4].text = g_strdup ("This is a test.\n.");
 	texts[4].len = strlen (texts[4].text);
-	texts[5].text = "This is a test.\n\n.\n";
+	texts[5].text = g_strdup ("This is a test.\n\n.\n");
 	texts[5].len = strlen (texts[5].text);
 	texts[6].text = g_malloc0 (1024);
 	texts[6].len = 1024;
@@ -90,16 +90,17 @@ setup (void)
 	texts[13].len = 102400;
 }
 
-static void cleanup (void)
+static void
+cleanup (void)
 {
 	gint i;
 
-	for (i=6;i<14;i++) {
+	for (i = 0; i < MAX_TEXTS; i++)
 		g_free (texts[i].text);
-	}
 }
 
-gint main (gint argc, gchar **argv)
+gint
+main (gint argc, gchar **argv)
 {
 	CamelMimeMessage *msg, *msg2;
 	gint i, j;
diff --git a/camel/tests/smime/pgp.c b/camel/tests/smime/pgp.c
index f4f9482..be60920 100644
--- a/camel/tests/smime/pgp.c
+++ b/camel/tests/smime/pgp.c
@@ -80,12 +80,9 @@ camel_pgp_session_init (CamelPgpSession *session)
 static CamelSession *
 camel_pgp_session_new (const gchar *path)
 {
-	CamelSession *session;
-
-	session = g_object_new (CAMEL_TYPE_PGP_SESSION, NULL);
-	camel_session_construct (session, path);
-
-	return session;
+	return g_object_new (
+		CAMEL_TYPE_PGP_SESSION,
+		"user-data-dir", path, NULL);
 }
 
 gint main (gint argc, gchar **argv)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]