* modest-presets:
authorDirk-Jan C. Binnema <dirk-jan.binnema@nokia.com>
Wed, 13 Dec 2006 15:31:14 +0000 (15:31 +0000)
committerDirk-Jan C. Binnema <dirk-jan.binnema@nokia.com>
Wed, 13 Dec 2006 15:31:14 +0000 (15:31 +0000)
  - added first trivial test cases
  - enabled build

pmo-trunk-r553

src/Makefile.am
src/modest-presets.c
src/modest-presets.h
tests/Makefile.am
tests/check_modest-presets.c [new file with mode: 0644]
tests/provider-data-test.keyfile [new file with mode: 0644]

index b5c99c4..8b7c895 100644 (file)
@@ -46,6 +46,8 @@ modest_SOURCES=\
        modest-tny-account-store.c\
        modest-tny-msg-actions.h\
        modest-tny-msg-actions.c\
        modest-tny-account-store.c\
        modest-tny-msg-actions.h\
        modest-tny-msg-actions.c\
+       modest-presets.c\
+       modest-presets.h\
        modest-protocol-mgr.h\
        modest-protocol-mgr.c\
        modest-ui.h\
        modest-protocol-mgr.h\
        modest-protocol-mgr.c\
        modest-ui.h\
index 081a9b4..dd2527c 100644 (file)
@@ -170,7 +170,8 @@ modest_presets_get_info (ModestPresets *self, const gchar *provider, gboolean in
 void
 modest_presets_destroy (ModestPresets *self)
 {
 void
 modest_presets_destroy (ModestPresets *self)
 {
-       g_return_if_fail (self);
+       if (!self)
+               return;
 
        g_key_file_free (self->keyfile);
        self->keyfile = NULL;
 
        g_key_file_free (self->keyfile);
        self->keyfile = NULL;
index 307d9f0..d10bb0a 100644 (file)
@@ -112,10 +112,9 @@ ModestPresetsInfo          modest_presets_get_info (ModestPresets *self,
 
 /**
  * modest_presets_destroy:
 
 /**
  * modest_presets_destroy:
- * @self: a valid ModestPresets instance
+ * @self: a valid ModestPresets instance (ie. must not be NULL)
  *
  * destroy ModestPresets instance; this is required after you're done with it.
  *
  * destroy ModestPresets instance; this is required after you're done with it.
- *
  */
 void                      modest_presets_destroy         (ModestPresets *self);
 
  */
 void                      modest_presets_destroy         (ModestPresets *self);
 
index 167a1ba..7f6bacb 100644 (file)
@@ -10,13 +10,15 @@ TESTS                   =                           \
                         check_folder-xfer           \
                         check_update-account        \
                        check_modest-conf           \
                         check_folder-xfer           \
                         check_update-account        \
                        check_modest-conf           \
-                       check_text-utils
+                       check_text-utils            \
+                       check_modest-presets     
 
 noinst_PROGRAMS=                                   \
                        check_folder-xfer           \
                        check_update-account        \
                        check_modest-conf           \
 
 noinst_PROGRAMS=                                   \
                        check_folder-xfer           \
                        check_update-account        \
                        check_modest-conf           \
-                       check_text-utils
+                       check_text-utils            \
+                       check_modest-presets     
 
 INCLUDES=\
        @CHECK_CFLAGS@ \
 
 INCLUDES=\
        @CHECK_CFLAGS@ \
@@ -39,6 +41,7 @@ objects=\
         ${top_srcdir}/src/modest-conf.o \
         ${top_srcdir}/src/modest-protocol-mgr.o \
         ${top_srcdir}/src/modest-formatter.o \
         ${top_srcdir}/src/modest-conf.o \
         ${top_srcdir}/src/modest-protocol-mgr.o \
         ${top_srcdir}/src/modest-formatter.o \
+        ${top_srcdir}/src/modest-presets.o \
         ${top_srcdir}/src/modest-pair.o \
         ${top_srcdir}/src/modest-marshal.o \
         ${top_srcdir}/src/modest-tny-account-store.o \
         ${top_srcdir}/src/modest-pair.o \
         ${top_srcdir}/src/modest-marshal.o \
         ${top_srcdir}/src/modest-tny-account-store.o \
@@ -63,3 +66,7 @@ check_modest_conf_LDADD = $(objects)
 check_text_utils_SOURCES=\
        check_text-utils.c
 check_text_utils_LDADD = $(objects)
 check_text_utils_SOURCES=\
        check_text-utils.c
 check_text_utils_LDADD = $(objects)
+
+check_modest_presets_SOURCES=\
+       check_modest-presets.c
+check_modest_presets_LDADD = $(objects)
diff --git a/tests/check_modest-presets.c b/tests/check_modest-presets.c
new file mode 100644 (file)
index 0000000..9a6ba9e
--- /dev/null
@@ -0,0 +1,81 @@
+/* Copyright (c) 2006, Nokia Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Nokia Corporation nor the names of its
+ *   contributors may be used to endorse or promote products derived from
+ *   this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <check.h>
+#include <glib.h>
+#include <modest-presets.h>
+
+START_TEST (test_modest_presets_new)
+{
+       ModestPresets *presets;
+       
+       presets = modest_presets_new ("provider-data-test.keyfile");
+       fail_unless (presets,
+                    "modest_presets_new should return a valid ModestPresets*");
+       modest_presets_destroy (presets);
+
+       presets = modest_presets_new ("/foo/bar/cuux");
+       fail_unless (!presets,
+                    "modest_presets_new should return NULL when given an invalid file");
+       if (presets)
+               modest_presets_destroy (presets);       
+}
+END_TEST
+
+
+static Suite*
+modest_presets_suite (void)
+{
+       Suite *suite = suite_create ("ModestPresets");
+
+       TCase *tc_core = tcase_create ("core");
+       tcase_add_test (tc_core, test_modest_presets_new);
+
+       suite_add_tcase (suite, tc_core);
+
+       return suite;
+}
+
+
+int
+main ()
+{
+       SRunner *srunner;
+       Suite   *suite;
+       int     failures;
+
+       suite   = modest_presets_suite ();
+       srunner = srunner_create (suite);
+
+       srunner_run_all (srunner, CK_NORMAL);
+       failures = srunner_ntests_failed (srunner);
+       srunner_free (srunner);
+       
+       return failures;
+}
diff --git a/tests/provider-data-test.keyfile b/tests/provider-data-test.keyfile
new file mode 100644 (file)
index 0000000..f01f06e
--- /dev/null
@@ -0,0 +1,24 @@
+[Bla]
+OutgoingMailServer=smtp.bla.com
+SecureSmtp=true
+IncomingMailServer=pop.bla.com:995
+IncomingSecurity=2
+MailboxType=pop
+[Foo]
+OutgoingMailServer=mail.foo.com
+IncomingMailServer=smtp.foo.com
+IncomingSecurity=0
+MailboxType=pop
+[XXX]
+MCC=244
+OutgoingMailServer=smtp.xxx.fi
+IncomingMailServer=mail.xxx.fi
+IncomingSecurity=0
+MailboxType=imap
+[YYY]
+MCC=244
+OutgoingMailServer=smtp.kolumbus.fi
+IncomingMailServer=mail.kolumbus.fi
+IncomingSecurity=0
+MailboxType=pop
+