projects
/
modest
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix some unit tests.
[modest]
/
tests
/
check_account-mgr.c
diff --git
a/tests/check_account-mgr.c
b/tests/check_account-mgr.c
index
25fc1cf
..
369ac3b
100644
(file)
--- a/
tests/check_account-mgr.c
+++ b/
tests/check_account-mgr.c
@@
-29,9
+29,11
@@
#include <check.h>
#include <string.h>
#include <check.h>
#include <string.h>
+#include <modest-defs.h>
#include <modest-conf.h>
#include <modest-account-mgr.h>
#include <modest-conf.h>
#include <modest-account-mgr.h>
-#include <modest-protocol-info.h>
+#include <gtk/gtk.h>
+#include <modest-init.h>
/* ----------------------- Defines ---------------------- */
/* ----------------------- Defines ---------------------- */
@@
-46,15
+48,13
@@
static ModestAccountMgr *account_mgr = NULL;
static void
fx_setup_default_account_mgr ()
{
static void
fx_setup_default_account_mgr ()
{
- ModestConf *conf = NULL;
+ fail_unless (gtk_init_check (NULL, NULL));
- g_type_init ();
+ fail_unless (g_setenv (MODEST_DIR_ENV, ".modesttest", TRUE));
+ fail_unless (g_setenv (MODEST_NAMESPACE_ENV, "/apps/modesttest", TRUE));
+ fail_unless (modest_init (0, NULL), "Failed running modest_init");
- conf = modest_conf_new ();
- fail_unless (MODEST_IS_CONF (conf),
- "modest_conf_new failed");
-
- account_mgr = modest_account_mgr_new (conf);
+ account_mgr = modest_runtime_get_account_mgr ();
fail_unless (MODEST_IS_ACCOUNT_MGR (account_mgr),
"modest_account_mgr_new failed");
fail_unless (MODEST_IS_ACCOUNT_MGR (account_mgr),
"modest_account_mgr_new failed");
@@
-63,20
+63,13
@@
fx_setup_default_account_mgr ()
TEST_MODEST_ACCOUNT_NAME,
FALSE))
modest_account_mgr_remove_account (account_mgr,
TEST_MODEST_ACCOUNT_NAME,
FALSE))
modest_account_mgr_remove_account (account_mgr,
- TEST_MODEST_ACCOUNT_NAME,
- FALSE);
+ TEST_MODEST_ACCOUNT_NAME);
if (modest_account_mgr_account_exists(account_mgr,
TEST_MODEST_ACCOUNT_NAME,
if (modest_account_mgr_account_exists(account_mgr,
TEST_MODEST_ACCOUNT_NAME,
- TRUE))
- modest_account_mgr_remove_account (account_mgr,
- TEST_MODEST_ACCOUNT_NAME,
- TRUE);
-}
-
-static void
-fx_teardown_default_account_mgr ()
-{
- g_object_unref (account_mgr);
+ TRUE)) {
+ modest_account_mgr_remove_server_account (account_mgr,
+ TEST_MODEST_ACCOUNT_NAME);
+ }
}
/* ---------- add/exists/remove account tests ---------- */
}
/* ---------- add/exists/remove account tests ---------- */
@@
-104,7
+97,8
@@
START_TEST (test_add_exists_remove_account_regular)
gchar *hostname = NULL;
gchar *username = NULL;
gchar *password = NULL;
gchar *hostname = NULL;
gchar *username = NULL;
gchar *password = NULL;
- ModestProtocol proto;
+ gint portnum;
+ ModestProtocolType proto;
gboolean result;
name = g_strdup (TEST_MODEST_ACCOUNT_NAME);
gboolean result;
name = g_strdup (TEST_MODEST_ACCOUNT_NAME);
@@
-113,12
+107,16
@@
START_TEST (test_add_exists_remove_account_regular)
transport_account = g_strdup ("local-smtp");
result = modest_account_mgr_add_account (account_mgr,
name,
transport_account = g_strdup ("local-smtp");
result = modest_account_mgr_add_account (account_mgr,
name,
+ "test display name",
+ "user fullname",
+ "user@email.com",
+ MODEST_ACCOUNT_RETRIEVE_HEADERS_ONLY,
store_account,
store_account,
- transport_account);
+ transport_account, TRUE);
fail_unless (result,
"modest_account_mgr_add_account failed:\n" \
"name: %s\nstore: %s\ntransport: %s\n",
fail_unless (result,
"modest_account_mgr_add_account failed:\n" \
"name: %s\nstore: %s\ntransport: %s\n",
- name, store_account, transport_account);
+ name, store_account, transport_account, TRUE);
g_free (store_account);
g_free (transport_account);
g_free (store_account);
g_free (transport_account);
@@
-134,8
+132,7
@@
START_TEST (test_add_exists_remove_account_regular)
/* Test 3 */
result = modest_account_mgr_remove_account (account_mgr,
/* Test 3 */
result = modest_account_mgr_remove_account (account_mgr,
- name,
- FALSE);
+ name);
fail_unless (result,
"modest_account_mgr_remove_account failed:\nname: %s\nerror: %s",
name);
fail_unless (result,
"modest_account_mgr_remove_account failed:\nname: %s\nerror: %s",
name);
@@
-145,16
+142,20
@@
START_TEST (test_add_exists_remove_account_regular)
hostname = g_strdup ("myhostname.mydomain.com");
username = g_strdup ("myusername");
password = g_strdup ("mypassword");
hostname = g_strdup ("myhostname.mydomain.com");
username = g_strdup ("myusername");
password = g_strdup ("mypassword");
- proto = MODEST_PROTOCOL_TRANSPORT_SMTP;
+ proto = MODEST_PROTOCOLS_TRANSPORT_SMTP;
+ portnum = 25;
result = modest_account_mgr_add_server_account (account_mgr,
name,
hostname,
result = modest_account_mgr_add_server_account (account_mgr,
name,
hostname,
+ portnum,
username,
password,
username,
password,
- proto);
+ proto,
+ MODEST_PROTOCOLS_CONNECTION_NONE,
+ MODEST_PROTOCOLS_AUTH_NONE);
fail_unless (result,
"modest_account_mgr_add_server_account failed:\n" \
fail_unless (result,
"modest_account_mgr_add_server_account failed:\n" \
- "name: %s\nhostname: %s\nusername: %s\npassword: %s\nproto: %s",
+ "name: %s\nhostname: %s\nusername: %s\npassword: %s\nproto: %d",
name, hostname, username, password, proto);
g_free (hostname);
name, hostname, username, password, proto);
g_free (hostname);
@@
-168,11
+169,10
@@
START_TEST (test_add_exists_remove_account_regular)
"Server account with name \"%s\" should exist. Error: %s", name);
/* Test 6 */
"Server account with name \"%s\" should exist. Error: %s", name);
/* Test 6 */
- result = modest_account_mgr_remove_account (account_mgr,
- name,
- TRUE);
+ result = modest_account_mgr_remove_server_account (account_mgr,
+ name);
fail_unless (result,
fail_unless (result,
- "modest_account_mgr_remove_account failed:\nname: %s\nerror: %s",
+ "modest_account_mgr_remove_server_account failed:\nname: %s\nerror: %s",
name);
name);
@@
-180,7
+180,7
@@
START_TEST (test_add_exists_remove_account_regular)
result = modest_account_mgr_account_exists (account_mgr,
"a_name_that_does_not_exist",
FALSE);
result = modest_account_mgr_account_exists (account_mgr,
"a_name_that_does_not_exist",
FALSE);
- fail_unless (result,
+ fail_unless (!result,
"modest_account_mgr_exists_account does not return " \
"FALSE when passing an account that does not exist");
"modest_account_mgr_exists_account does not return " \
"FALSE when passing an account that does not exist");
@@
-188,7
+188,7
@@
START_TEST (test_add_exists_remove_account_regular)
result = modest_account_mgr_account_exists (account_mgr,
"a_name_that_does_not_exist",
TRUE);
result = modest_account_mgr_account_exists (account_mgr,
"a_name_that_does_not_exist",
TRUE);
- fail_unless (result,
+ fail_unless (!result,
"modest_account_mgr_exists_account does not return " \
"FALSE when passing a server account that does not exist");
"modest_account_mgr_exists_account does not return " \
"FALSE when passing a server account that does not exist");
@@
-209,7
+209,7
@@
END_TEST
* - Test 5: Create server account with NULL name
* - Test 6: Create server account with invalid name string
* - Test 7: Remove a non-existing account
* - Test 5: Create server account with NULL name
* - Test 6: Create server account with invalid name string
* - Test 7: Remove a non-existing account
- * - Test 8: Remove a non-existing server account
+ * - Test 8: Remove a non-existing server account (REMOVED)
* - Test 9: Remove with NULL acount manager
* - Test 10: Remove with NULL name
* - Test 11: Check if an account exists with NULL account_mgr
* - Test 9: Remove with NULL acount manager
* - Test 10: Remove with NULL name
* - Test 11: Check if an account exists with NULL account_mgr
@@
-224,8
+224,12
@@
START_TEST (test_add_exists_remove_account_invalid)
/* Test 1 */
result = modest_account_mgr_add_account (NULL,
TEST_MODEST_ACCOUNT_NAME,
/* Test 1 */
result = modest_account_mgr_add_account (NULL,
TEST_MODEST_ACCOUNT_NAME,
+ "test display name",
+ "user fullname",
+ "user@email.com",
+ MODEST_ACCOUNT_RETRIEVE_HEADERS_ONLY,
"store_account",
"store_account",
- "transport_account");
+ "transport_account", TRUE);
fail_unless (!result,
"modest_account_mgr_add_account does not return FALSE when" \
"passing a NULL ModestAccountMgr");
fail_unless (!result,
"modest_account_mgr_add_account does not return FALSE when" \
"passing a NULL ModestAccountMgr");
@@
-233,8
+237,12
@@
START_TEST (test_add_exists_remove_account_invalid)
/* Test 2 */
result = modest_account_mgr_add_account (account_mgr,
NULL,
/* Test 2 */
result = modest_account_mgr_add_account (account_mgr,
NULL,
+ "test display name",
+ "user fullname",
+ "user@email.com",
+ MODEST_ACCOUNT_RETRIEVE_HEADERS_ONLY,
"store_account",
"store_account",
- "transport_account");
+ "transport_account", TRUE);
fail_unless (!result,
"modest_account_mgr_add_account does not return FALSE when" \
"passing a NULL account name");
fail_unless (!result,
"modest_account_mgr_add_account does not return FALSE when" \
"passing a NULL account name");
@@
-242,8
+250,12
@@
START_TEST (test_add_exists_remove_account_invalid)
/* Test 3*/
result = modest_account_mgr_add_account (account_mgr,
"ïnválid//accountñ//nÄméç",
/* Test 3*/
result = modest_account_mgr_add_account (account_mgr,
"ïnválid//accountñ//nÄméç",
+ "test display name",
+ "user fullname",
+ "user@email.com",
+ MODEST_ACCOUNT_RETRIEVE_HEADERS_ONLY,
"store_account",
"store_account",
- "transport_account");
+ "transport_account", TRUE);
fail_unless (!result,
"modest_account_mgr_add_account does not return FALSE when" \
"passing an invalid account name");
fail_unless (!result,
"modest_account_mgr_add_account does not return FALSE when" \
"passing an invalid account name");
@@
-252,9
+264,12
@@
START_TEST (test_add_exists_remove_account_invalid)
result = modest_account_mgr_add_server_account (NULL,
TEST_MODEST_ACCOUNT_NAME,
"hostname",
result = modest_account_mgr_add_server_account (NULL,
TEST_MODEST_ACCOUNT_NAME,
"hostname",
+ 143,
"username",
"password",
"username",
"password",
- MODEST_PROTOCOL_STORE_IMAP);
+ MODEST_PROTOCOLS_STORE_IMAP,
+ MODEST_PROTOCOLS_CONNECTION_NONE,
+ MODEST_PROTOCOLS_AUTH_NONE);
fail_unless (!result,
"modest_account_mgr_add_server_account does not return " \
"FALSE when passing a NULL ModestAccountMgr");
fail_unless (!result,
"modest_account_mgr_add_server_account does not return " \
"FALSE when passing a NULL ModestAccountMgr");
@@
-263,9
+278,12
@@
START_TEST (test_add_exists_remove_account_invalid)
result = modest_account_mgr_add_server_account (account_mgr,
NULL,
"hostname",
result = modest_account_mgr_add_server_account (account_mgr,
NULL,
"hostname",
+ 143,
"username",
"password",
"username",
"password",
- MODEST_PROTOCOL_STORE_IMAP);
+ MODEST_PROTOCOLS_STORE_IMAP,
+ MODEST_PROTOCOLS_CONNECTION_NONE,
+ MODEST_PROTOCOLS_AUTH_NONE);
fail_unless (!result,
"modest_account_mgr_add_server_account does not return " \
"FALSE when passing a NULL account name");
fail_unless (!result,
"modest_account_mgr_add_server_account does not return " \
"FALSE when passing a NULL account name");
@@
-274,41
+292,33
@@
START_TEST (test_add_exists_remove_account_invalid)
result = modest_account_mgr_add_server_account (account_mgr,
"ïnválid//accountñ//nÄméç",
"hostname",
result = modest_account_mgr_add_server_account (account_mgr,
"ïnválid//accountñ//nÄméç",
"hostname",
+ 143,
"username",
"password",
"username",
"password",
- MODEST_PROTOCOL_STORE_IMAP);
+ MODEST_PROTOCOLS_STORE_IMAP,
+ MODEST_PROTOCOLS_CONNECTION_NONE,
+ MODEST_PROTOCOLS_AUTH_NONE);
fail_unless (!result,
"modest_account_mgr_add_server_account does not return " \
"FALSE when passing an invalid account name");
/* Test 7 */
result = modest_account_mgr_remove_account (account_mgr,
fail_unless (!result,
"modest_account_mgr_add_server_account does not return " \
"FALSE when passing an invalid account name");
/* Test 7 */
result = modest_account_mgr_remove_account (account_mgr,
- "a_name_that_does_not_exist",
- FALSE);
+ "a_name_that_does_not_exist");
fail_unless (!result,
"modest_account_mgr_remove_acccount does not return FALSE " \
"when trying to remove an account that does not exist");
fail_unless (!result,
"modest_account_mgr_remove_acccount does not return FALSE " \
"when trying to remove an account that does not exist");
- /* Test 8 */
- result = modest_account_mgr_remove_account (account_mgr,
- "a_name_that_does_not_exist",
- TRUE);
- fail_unless (!result,
- "modest_account_mgr_remove_acccount does not return FALSE " \
- "when trying to remove a server account that does not exist");
-
/* Test 9 */
result = modest_account_mgr_remove_account (NULL,
/* Test 9 */
result = modest_account_mgr_remove_account (NULL,
- TEST_MODEST_ACCOUNT_NAME,
- FALSE);
+ TEST_MODEST_ACCOUNT_NAME);
fail_unless (!result,
"modest_account_mgr_remove_acccount does not return " \
"FALSE when passing a NULL ModestAccountMgr");
/* Test 10 */
result = modest_account_mgr_remove_account (account_mgr,
fail_unless (!result,
"modest_account_mgr_remove_acccount does not return " \
"FALSE when passing a NULL ModestAccountMgr");
/* Test 10 */
result = modest_account_mgr_remove_account (account_mgr,
- NULL,
- FALSE);
+ NULL);
fail_unless (!result,
"modest_account_mgr_remove_acccount does not return " \
"FALSE when passing a NULL account name");
fail_unless (!result,
"modest_account_mgr_remove_acccount does not return " \
"FALSE when passing a NULL account name");
@@
-357,9
+367,8
@@
account_mgr_suite (void)
/* Tests case for "add/exists/remove account" */
tc = tcase_create ("add_exists_remove_account");
/* Tests case for "add/exists/remove account" */
tc = tcase_create ("add_exists_remove_account");
- tcase_add_checked_fixture (tc,
- fx_setup_default_account_mgr,
- fx_teardown_default_account_mgr);
+ tcase_add_unchecked_fixture (tc,
+ fx_setup_default_account_mgr, NULL);
tcase_add_test (tc, test_add_exists_remove_account_regular);
tcase_add_test (tc, test_add_exists_remove_account_invalid);
suite_add_tcase (suite, tc);
tcase_add_test (tc, test_add_exists_remove_account_regular);
tcase_add_test (tc, test_add_exists_remove_account_invalid);
suite_add_tcase (suite, tc);