diff options
author | Not Zed <NotZed@HelixCode.com> | 2000-11-28 21:13:23 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2000-11-28 21:13:23 +0800 |
commit | 3998a03ae925f47cd1ffcf31fca0a4701f8c75da (patch) | |
tree | 2e4abfb292e1e76da06af4ce5676fd7ae79d2c75 /camel/tests/lib | |
parent | f306b8b912a19e1a0321af66a29faf23664f2077 (diff) | |
download | gsoc2013-evolution-3998a03ae925f47cd1ffcf31fca0a4701f8c75da.tar.gz gsoc2013-evolution-3998a03ae925f47cd1ffcf31fca0a4701f8c75da.tar.zst gsoc2013-evolution-3998a03ae925f47cd1ffcf31fca0a4701f8c75da.zip |
Set the info size's properly, oops!
2000-11-28 Not Zed <NotZed@HelixCode.com>
* providers/local/camel-maildir-summary.c
(camel_maildir_summary_init): Set the info size's properly, oops!
* tests/lib/folders.[ch]: Folder testing helpers.
* tests/folder/test2.c: Test basic message ops on folders.
* tests/folder/test1.c (main): Test basic folder ops on (local)
stores.
* providers/local/camel-local-provider.c
(camel_provider_module_init): Removed some debug.
* providers/local/camel-maildir-folder.c
(camel_maildir_folder_class_init): fix parent class.
* providers/local/camel-mh-folder.c (camel_mh_folder_class_init):
Fix parent class (damn cut & paste).
* providers/local/camel-maildir-store.c (get_folder): Call parent
impl.
(camel_maildir_store_class_init): Fix parent class setup.
(delete_folder): Check the folder exists before trying to delete
it.
(delete_folder): Try and make the delete operation atomic/rollback
failures. e.g. if one directory isn't empty, then create the
other empty ones back. Also clear the tmp directory fully first.
* providers/local/camel-mbox-store.c (get_folder): Call parent
impl.
(camel_mbox_store_class_init): parent class is camel_local_store,
not camel_folder, oops.
(delete_folder): Return an error if it doesn't exist, rather than
covering it up.
* providers/local/camel-mh-store.c (get_folder): Call parent impl.
(camel_mh_store_class_init): fix parent class setup.
(delete_folder): Error if it doesn't exist now.
* camel-folder.c (camel_folder_move_message_to):
(camel_folder_copy_message_to): Added warnings as these functions
are going to be removed later.
* camel-store.c (camel_store_get_root_folder): Fix for an early
api change. We want CAMEL_STORE_FOLDER_CREATE, not TRUE, since
its a flag.
(camel_store_get_default_folder): And here too.
* providers/local/camel-local-store.c (xrename): Handle renaming
folders differently to renaming files.
(get_default_folder_name): local stores dont have a default
folder, so make it so. Or at least, it doesn't seem to make sense
to have one.
(get_root_folder_name): Same for root.
(get_folder): Added parent implementation, that makes sure the
service path exists, if we are creating a new folder (but doesn't
create the folder).
2000-11-27 Not Zed <NotZed@HelixCode.com>
* providers/local/camel-local-store.c (xrename): Fixed races. Use
link/unlink, rather than rename, to properly detect overwriting
another file. And allow some files to be missing.
* providers/Makefile.am: Removed mh, mbox, added local, to the default.
svn path=/trunk/; revision=6693
Diffstat (limited to 'camel/tests/lib')
-rw-r--r-- | camel/tests/lib/Makefile.am | 4 | ||||
-rw-r--r-- | camel/tests/lib/folders.c | 183 | ||||
-rw-r--r-- | camel/tests/lib/folders.h | 13 |
3 files changed, 199 insertions, 1 deletions
diff --git a/camel/tests/lib/Makefile.am b/camel/tests/lib/Makefile.am index 1fae79671d..db09b0cf5e 100644 --- a/camel/tests/lib/Makefile.am +++ b/camel/tests/lib/Makefile.am @@ -4,7 +4,9 @@ check_LIBRARIES = libcameltest.a libcameltest_a_SOURCES = \ camel-test.c camel-test.h \ messages.c messages.h \ - addresses.c addresses.h + addresses.c addresses.h \ + folders.c folders.h + diff --git a/camel/tests/lib/folders.c b/camel/tests/lib/folders.c new file mode 100644 index 0000000000..738f8d2913 --- /dev/null +++ b/camel/tests/lib/folders.c @@ -0,0 +1,183 @@ + +#include "camel-test.h" +#include "folders.h" + +#include "camel/camel-exception.h" + +/* check the total/unread is what we think it should be */ +void +test_folder_counts(CamelFolder *folder, int total, int unread) +{ + GPtrArray *s; + int i, myunread; + const CamelMessageInfo *info; + + push("test folder counts %d total %d unread", total, unread); + + /* first, use the standard functions */ + check(camel_folder_get_message_count(folder) == total); + check(camel_folder_get_unread_message_count(folder) == total); + + /* next, use the summary */ + s = camel_folder_get_summary(folder); + check(s != NULL); + check(s->len == total); + myunread = s->len; + for (i=0;i<s->len;i++) { + info = s->pdata[i]; + if (info->flags & CAMEL_MESSAGE_SEEN) + myunread--; + } + check(unread == myunread); + camel_folder_free_summary(folder, s); + + /* last, use the uid list */ + s = camel_folder_get_uids(folder); + check(s != NULL); + check(s->len == total); + myunread = s->len; + for (i=0;i<s->len;i++) { + info = camel_folder_get_message_info(folder, s->pdata[i]); + if (info->flags & CAMEL_MESSAGE_SEEN) + myunread--; + } + check(unread == myunread); + camel_folder_free_uids(folder, s); + + pull(); +} + +static int +safe_strcmp(const char *a, const char *b) +{ + if (a == NULL && b == NULL) + return 0; + if (a == NULL) + return 1; + if (b == NULL) + return -1; + return strcmp(a, b); +} + +void +test_message_info(CamelMimeMessage *msg, const CamelMessageInfo *info) +{ + check_msg(safe_strcmp(info->subject, camel_mime_message_get_subject(msg)) == 0, + "info->subject = '%s', get_subject() = '%s'", info->subject, camel_mime_message_get_subject(msg)); + + /* FIXME: testing from/cc/to, etc is more tricky */ + + check(info->date_sent == camel_mime_message_get_date(msg, NULL)); + + /* date received isn't set for messages that haven't been sent anywhere ... */ + /*check(info->date_received == camel_mime_message_get_date_received(msg, NULL));*/ + + /* so is messageid/references, etc */ +} + +/* check a message is present */ +void +test_folder_message(CamelFolder *folder, const char *uid) +{ + CamelMimeMessage *msg; + const CamelMessageInfo *info; + GPtrArray *s; + int i; + CamelException *ex = camel_exception_new(); + int found; + + push("uid %s is in folder", uid); + + /* first try getting info */ + info = camel_folder_get_message_info(folder, uid); + check(info != NULL); + check(strcmp(info->uid, uid) == 0); + + /* then, getting message */ + msg = camel_folder_get_message(folder, uid, ex); + check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex)); + check(msg != NULL); + + /* cross check with info */ + test_message_info(msg, info); + + camel_object_unref((CamelObject *)msg); + + /* see if it is in the summary (only once) */ + s = camel_folder_get_summary(folder); + check(s != NULL); + found = 0; + for (i=0;i<s->len;i++) { + info = s->pdata[i]; + if (strcmp(info->uid, uid) == 0) + found++; + } + check(found == 1); + camel_folder_free_summary(folder, s); + + /* check it is in the uid list */ + s = camel_folder_get_uids(folder); + check(s != NULL); + found = 0; + for (i=0;i<s->len;i++) { + if (strcmp(s->pdata[i], uid) == 0) + found++; + } + check(found == 1); + camel_folder_free_uids(folder, s); + + camel_exception_free(ex); + + pull(); +} + +/* check message not present */ +void +test_folder_not_message(CamelFolder *folder, const char *uid) +{ + CamelMimeMessage *msg; + const CamelMessageInfo *info; + GPtrArray *s; + int i; + CamelException *ex = camel_exception_new(); + int found; + + push("uid %s is not in folder", uid); + + /* first try getting info */ + info = camel_folder_get_message_info(folder, uid); + check(info == NULL); + + /* then, getting message */ + msg = camel_folder_get_message(folder, uid, ex); + check(camel_exception_is_set(ex)); + check(msg == NULL); + camel_exception_clear(ex); + + /* see if it is not in the summary (only once) */ + s = camel_folder_get_summary(folder); + check(s != NULL); + found = 0; + for (i=0;i<s->len;i++) { + info = s->pdata[i]; + if (strcmp(info->uid, uid) == 0) + found++; + } + check(found == 0); + camel_folder_free_summary(folder, s); + + /* check it is not in the uid list */ + s = camel_folder_get_uids(folder); + check(s != NULL); + found = 0; + for (i=0;i<s->len;i++) { + if (strcmp(s->pdata[i], uid) == 0) + found++; + } + check(found == 0); + camel_folder_free_uids(folder, s); + + camel_exception_free(ex); + + pull(); +} diff --git a/camel/tests/lib/folders.h b/camel/tests/lib/folders.h new file mode 100644 index 0000000000..55c80e0872 --- /dev/null +++ b/camel/tests/lib/folders.h @@ -0,0 +1,13 @@ + +#include <camel/camel-folder.h> +#include <camel/camel-folder-summary.h> +#include <camel/camel-mime-message.h> + +/* check the total/unread is what we think it should be, everywhere it can be determined */ +void test_folder_counts(CamelFolder *folder, int total, int unread); +/* cross-check info/msg */ +void test_message_info(CamelMimeMessage *msg, const CamelMessageInfo *info); +/* check a message is present everywhere it should be */ +void test_folder_message(CamelFolder *folder, const char *uid); +/* check message not present everywhere it shouldn't be */ +void test_folder_not_message(CamelFolder *folder, const char *uid); |