diff options
author | Not Zed <NotZed@Ximian.com> | 2002-09-04 16:13:38 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2002-09-04 16:13:38 +0800 |
commit | a52720a9213d760bb8a9c21b354ab46de7b763dd (patch) | |
tree | 984be336497cf1bca255d02a0ea00428ed9e3924 /camel/tests/lib | |
parent | d27b52023b0ed91a777bc838e4f9b898ca7e2201 (diff) | |
download | gsoc2013-evolution-a52720a9213d760bb8a9c21b354ab46de7b763dd.tar.gz gsoc2013-evolution-a52720a9213d760bb8a9c21b354ab46de7b763dd.tar.zst gsoc2013-evolution-a52720a9213d760bb8a9c21b354ab46de7b763dd.zip |
clear nonfatal stuff.
2002-09-04 Not Zed <NotZed@Ximian.com>
* tests/folder/test4.c (main): clear nonfatal stuff.
* tests/folder/test6.c (main): check inbox and 'another folder'
because some servers do different things w/ inbox.
* providers/imap/camel-imap-message-cache.c
(camel_imap_message_cache_get): Dont try to open the directory
instead of an empty "" uid.
* providers/imap/camel-imap-folder.c (imap_get_message): we dont
want to g_return_if_fail, we need to set an exception and always
handle the case.
(get_message_simple): Set an exception if we get a construct
failure.
(imap_refresh_info): if we're refreshing inbox, force a reselect.
this is required for at least cryus. CHECK doesnt work either :(
* tests/lib/folders.c (test_folder_basic): for non-local stores,
the folder will have an extra ref for selection, take this into
account when checking ref leaks.
(test_folder_message_ops): Dont try to delete folder with messages
in it, it works generally with imap. also, change params so we
can test different mailbox types.
(test_folder_message_ops): disconnect remote services before
finishing off. doesn't need to stricly but makes ref count
checking more accurate.
(test_folder_message_ops): removed explicit remote sync, imap does
it itself now ...
* providers/imap/camel-imap-store.c:
(camel_imap_store_finalize): call service_disconnect, so it isn't
called later in the finalise chain, to properly cleanup on exit.
svn path=/trunk/; revision=17962
Diffstat (limited to 'camel/tests/lib')
-rw-r--r-- | camel/tests/lib/folders.c | 94 | ||||
-rw-r--r-- | camel/tests/lib/folders.h | 2 |
2 files changed, 70 insertions, 26 deletions
diff --git a/camel/tests/lib/folders.c b/camel/tests/lib/folders.c index e7de6b2397..a670576564 100644 --- a/camel/tests/lib/folders.c +++ b/camel/tests/lib/folders.c @@ -146,19 +146,24 @@ test_folder_not_message(CamelFolder *folder, const char *uid) CamelException *ex = camel_exception_new(); int found; - push("uid %s is not in folder", uid); + push("uid '%s' is not in folder", uid); /* first try getting info */ + push("no message info"); info = camel_folder_get_message_info(folder, uid); check(info == NULL); + pull(); /* then, getting message */ + push("no message"); msg = camel_folder_get_message(folder, uid, ex); check(camel_exception_is_set(ex)); check(msg == NULL); camel_exception_clear(ex); + pull(); /* see if it is not in the summary (only once) */ + push("not in summary list"); s = camel_folder_get_summary(folder); check(s != NULL); found = 0; @@ -169,8 +174,10 @@ test_folder_not_message(CamelFolder *folder, const char *uid) } check(found == 0); camel_folder_free_summary(folder, s); + pull(); /* check it is not in the uid list */ + push("not in uid list"); s = camel_folder_get_uids(folder); check(s != NULL); found = 0; @@ -180,6 +187,7 @@ test_folder_not_message(CamelFolder *folder, const char *uid) } check(found == 0); camel_folder_free_uids(folder, s); + pull(); camel_exception_free(ex); @@ -215,7 +223,7 @@ test_folder_basic(CamelSession *session, const char *storename, int local, int s } else { check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex)); check(folder != NULL); - check_unref(folder, 1); + check_unref(folder, 2); } pull(); @@ -231,14 +239,20 @@ test_folder_basic(CamelSession *session, const char *storename, int local, int s folder = camel_store_get_folder(store, "testbox", CAMEL_STORE_FOLDER_CREATE, ex); check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex)); check(folder != NULL); - check_unref(folder, 1); + if (local) + check_unref(folder, 1); + else + check_unref(folder, 2); pull(); push("getting an existing folder"); folder = camel_store_get_folder(store, "testbox", 0, ex); check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex)); check(folder != NULL); - check_unref(folder, 1); + if (local) + check_unref(folder, 1); + else + check_unref(folder, 2); pull(); push("renaming a non-existant folder"); @@ -263,7 +277,10 @@ test_folder_basic(CamelSession *session, const char *storename, int local, int s folder = camel_store_get_folder(store, "testbox2", 0, ex); check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex)); check(folder != NULL); - check_unref(folder, 1); + if (local) + check_unref(folder, 1); + else + check_unref(folder, 2); pull(); } @@ -298,7 +315,7 @@ test_folder_basic(CamelSession *session, const char *storename, int local, int s /* todo: cross-check everything with folder_info checks as well */ /* this should probably take a folder instead of a session ... */ void -test_folder_message_ops(CamelSession *session, const char *name, int local, int spool) +test_folder_message_ops(CamelSession *session, const char *name, int local, const char *mailbox) { CamelStore *store; CamelException *ex = camel_exception_new(); @@ -308,12 +325,6 @@ test_folder_message_ops(CamelSession *session, const char *name, int local, int int indexed, max; GPtrArray *uids; CamelMessageInfo *info; - char *mailbox; - - if (spool) - mailbox = "INBOX"; - else - mailbox = "testbox"; max=local?2:1; @@ -336,6 +347,16 @@ test_folder_message_ops(CamelSession *session, const char *name, int local, int else flags = CAMEL_STORE_FOLDER_CREATE; folder = camel_store_get_folder(store, mailbox, flags, ex); + + /* we can't create mailbox outside of namespace, since we have no api for it, try + using inbox namespace, works for courier */ + if (folder == NULL) { + char *mbox = g_strdup_printf("INBOX/%s", mailbox); + mailbox = mbox; + camel_exception_clear(ex); + folder = camel_store_get_folder(store, mailbox, flags, ex); + } + check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex)); check(folder != NULL); @@ -361,6 +382,7 @@ test_folder_message_ops(CamelSession *session, const char *name, int local, int camel_folder_append_message(folder, msg, NULL, NULL, ex); check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex)); +#if 0 /* sigh, this shouldn't be required, but the imap code is too dumb to do it itself */ if (!local) { push("forcing a refresh of folder updates"); @@ -368,44 +390,56 @@ test_folder_message_ops(CamelSession *session, const char *name, int local, int check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex)); pull(); } - - if (!local) - camel_test_nonfatal("unread counts dont seem right for imap"); +#endif + /*if (!local) + camel_test_nonfatal("unread counts dont seem right for imap");*/ test_folder_counts(folder, j+1, j+1); - if (!local) - camel_test_fatal(); + /*if (!local) + camel_test_fatal();*/ push("checking it is in the right uid slot & exists"); uids = camel_folder_get_uids(folder); check(uids != NULL); check(uids->len == j+1); - test_folder_message(folder, uids->pdata[j]); + if (uids->len > j) + test_folder_message(folder, uids->pdata[j]); pull(); push("checking it is the right message (subject): %s", subject); - info = camel_folder_get_message_info(folder, uids->pdata[j]); - check_msg(strcmp(camel_message_info_subject(info), subject)==0, - "info->subject %s", camel_message_info_subject(info)); + if (uids->len > j) { + info = camel_folder_get_message_info(folder, uids->pdata[j]); + check(info != NULL); + check_msg(strcmp(camel_message_info_subject(info), subject)==0, + "info->subject %s", camel_message_info_subject(info)); + camel_folder_free_message_info(folder, info); + } camel_folder_free_uids(folder, uids); - camel_folder_free_message_info(folder, info); pull(); test_free(subject); + /*if (!local) + camel_test_fatal();*/ + check_unref(msg, 1); pull(); } - check_unref(folder, 1); + if (local) + check_unref(folder, 1); + else + check_unref(folder, 2); pull(); +#if 0 push("deleting test folder, with messages in it"); camel_store_delete_folder(store, mailbox, ex); check(camel_exception_is_set(ex)); camel_exception_clear(ex); pull(); +#endif push("re-opening folder"); folder = camel_store_get_folder(store, mailbox, flags, ex); @@ -506,16 +540,26 @@ test_folder_message_ops(CamelSession *session, const char *name, int local, int camel_folder_free_uids(folder, uids); pull(); - check_unref(folder, 1); + if (local) + check_unref(folder, 1); + else + check_unref(folder, 2); pull(); /* re-opening folder */ - if (!spool) { + if (strcasecmp(mailbox, "INBOX") != 0) { push("deleting test folder, with no messages in it"); camel_store_delete_folder(store, mailbox, ex); check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex)); pull(); } + if (!local) { + push("disconneect service"); + camel_service_disconnect((CamelService *)store, TRUE, ex); + check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex)); + pull(); + } + check_unref(store, 1); camel_test_end(); } diff --git a/camel/tests/lib/folders.h b/camel/tests/lib/folders.h index d3c9686dc2..ae981611d3 100644 --- a/camel/tests/lib/folders.h +++ b/camel/tests/lib/folders.h @@ -17,4 +17,4 @@ void test_folder_not_message(CamelFolder *folder, const char *uid); /* test basic folder ops on a store */ void test_folder_basic(CamelSession *session, const char *storename, int local, int spool); /* test basic message operations on a folder */ -void test_folder_message_ops(CamelSession *session, const char *storename, int local, int spool); +void test_folder_message_ops(CamelSession *session, const char *storename, int local, const char *foldername); |