diff options
author | Marc Blank <mblank@google.com> | 2010-07-08 10:08:47 -0700 |
---|---|---|
committer | Marc Blank <mblank@google.com> | 2010-07-21 19:01:41 -0700 |
commit | e6cc662abc0b5fffe223cda5e980b4f05a4e91dd (patch) | |
tree | 98b87c591883c4cc2b5c8cf0200a96cacf1b170e /tests/src/com/android/email/activity | |
parent | d6a2978857e0866d7441f8e140338477545d59a5 (diff) | |
download | android_packages_apps_Email-e6cc662abc0b5fffe223cda5e980b4f05a4e91dd.tar.gz android_packages_apps_Email-e6cc662abc0b5fffe223cda5e980b4f05a4e91dd.tar.bz2 android_packages_apps_Email-e6cc662abc0b5fffe223cda5e980b4f05a4e91dd.zip |
Use AccountManager for POP/IMAP; refactor setup classes
There are two major, interrelated parts to this CL:
1) Clean up the activities to reduce the use of Intents to pass
information between activities; instead, we use a common
SetupData structure that automatically saved/restored as necessary
during the setup flow. A fair amount of code and inconsistent
use of Bundle extras has been eliminated in the process.
* Create SetupData structure, setters/getters, and initialization
methods to simplify the preservation of state during setup flow
* Remove all state/flow extras from Intents; Intents now only
specify the Activity to be started, which should greatly simplify
the transition to Fragments.
* Remove all state/flow fields from Activities
* Modify existing setup activity unit tests and confirm tests pass
2) Create AccountManager accounts for POP/IMAP email accounts to
provide consistency in user experience. Also, internal flows are
now identical as between account types.
* Move account reconciliation from SyncManager to MailService, so
that reconciliation is consistent between email and exchange
accounts; move unit tests as appropriate
* Add a "Sync Email" setting for POP/IMAP/EAS
* Change MailService to respect the "Sync Email" setting in
Settings -> Accounts & sync
* Create PopImapSyncAdapterService to handle manual POP/IMAP sync as
requested by SyncManager; add EmailSyncAdapterService to perform
the same function for EAS
* Use new PopImapAuthenticatorService to add AccountManager accounts
for POP/IMAP accounts; setup appropriate stanzas in AndroidManifest
and add related xml files
* Update AccountSettings to use SetupData
Miscellaneous other changes:
* Only allow valid port numbers in incoming/outgoing setup
Bug: 1712475
Change-Id: Ibdac52fb2c5578b86bf3992ddb1acd10f162391a
Diffstat (limited to 'tests/src/com/android/email/activity')
-rw-r--r-- | tests/src/com/android/email/activity/setup/AccountSetupAccountTypeTests.java (renamed from tests/src/com/android/email/activity/setup/AccountSetupAccountTypeUnitTests.java) | 31 | ||||
-rw-r--r-- | tests/src/com/android/email/activity/setup/AccountSetupExchangeTests.java | 6 | ||||
-rw-r--r-- | tests/src/com/android/email/activity/setup/AccountSetupIncomingTests.java | 10 | ||||
-rw-r--r-- | tests/src/com/android/email/activity/setup/AccountSetupNamesTests.java | 12 | ||||
-rw-r--r-- | tests/src/com/android/email/activity/setup/AccountSetupOptionsTests.java | 10 | ||||
-rw-r--r-- | tests/src/com/android/email/activity/setup/AccountSetupOutgoingTests.java | 7 |
6 files changed, 33 insertions, 43 deletions
diff --git a/tests/src/com/android/email/activity/setup/AccountSetupAccountTypeUnitTests.java b/tests/src/com/android/email/activity/setup/AccountSetupAccountTypeTests.java index 13ea7551a..dd4aaf45c 100644 --- a/tests/src/com/android/email/activity/setup/AccountSetupAccountTypeUnitTests.java +++ b/tests/src/com/android/email/activity/setup/AccountSetupAccountTypeTests.java @@ -18,7 +18,6 @@ package com.android.email.activity.setup; import com.android.email.R; import com.android.email.mail.Store; -import com.android.email.provider.EmailContent; import com.android.email.provider.EmailContent.Account; import android.content.ContentUris; @@ -33,26 +32,23 @@ import java.util.HashSet; /** * This is a series of unit tests for the AccountSetupAccountType class. + * You can run this entire test case with: + * runtest -c com.android.email.activity.setup.AccountSetupAccountTypeTests email */ @SmallTest -public class AccountSetupAccountTypeUnitTests +public class AccountSetupAccountTypeTests extends ActivityUnitTestCase<AccountSetupAccountType> { - // Borrowed from AccountSetupAccountType - private static final String EXTRA_ACCOUNT = "account"; - Context mContext; - private HashSet<Account> mAccounts = new HashSet<Account>(); - public AccountSetupAccountTypeUnitTests() { + public AccountSetupAccountTypeTests() { super(AccountSetupAccountType.class); } @Override protected void setUp() throws Exception { super.setUp(); - mContext = this.getInstrumentation().getTargetContext(); } @@ -74,11 +70,11 @@ public class AccountSetupAccountTypeUnitTests * Test store type limit enforcement */ public void testStoreTypeLimits() { - EmailContent.Account acct1 = createTestAccount("scheme1"); - EmailContent.Account acct2 = createTestAccount("scheme1"); - EmailContent.Account acct3 = createTestAccount("scheme2"); + createTestAccount("scheme1"); + createTestAccount("scheme1"); + createTestAccount("scheme2"); - AccountSetupAccountType activity = startActivity(getTestIntent(acct1), null, null); + AccountSetupAccountType activity = startActivity(getTestIntent(), null, null); // Test with no limit Store.StoreInfo info = new Store.StoreInfo(); @@ -99,8 +95,8 @@ public class AccountSetupAccountTypeUnitTests * Confirm that EAS is presented, when supported. */ public void testEasOffered() { - Account acct1 = createTestAccount("scheme1"); - AccountSetupAccountType activity = startActivity(getTestIntent(acct1), null, null); + createTestAccount("scheme1"); + AccountSetupAccountType activity = startActivity(getTestIntent(), null, null); View exchangeButton = activity.findViewById(R.id.exchange); int expected = View.GONE; // Default is hidden @@ -119,16 +115,15 @@ public class AccountSetupAccountTypeUnitTests account.setStoreUri(mContext, scheme + "://user:pass@server.com:123"); account.save(mContext); mAccounts.add(account); + SetupData.init(SetupData.FLOW_MODE_NORMAL, account); return account; } /** * Create an intent with the Account in it */ - private Intent getTestIntent(EmailContent.Account account) { - Intent i = new Intent(Intent.ACTION_MAIN); - i.putExtra(EXTRA_ACCOUNT, account); - return i; + private Intent getTestIntent() { + return new Intent(Intent.ACTION_MAIN); } } diff --git a/tests/src/com/android/email/activity/setup/AccountSetupExchangeTests.java b/tests/src/com/android/email/activity/setup/AccountSetupExchangeTests.java index c4b15f831..d6b3a0921 100644 --- a/tests/src/com/android/email/activity/setup/AccountSetupExchangeTests.java +++ b/tests/src/com/android/email/activity/setup/AccountSetupExchangeTests.java @@ -33,6 +33,8 @@ import android.widget.EditText; /** * Tests of the basic UI logic in the Account Setup Incoming (IMAP / POP3) screen. + * You can run this entire test case with: + * runtest -c com.android.email.activity.setup.AccountSetupExchangeTests email */ @MediumTest public class AccountSetupExchangeTests extends @@ -183,8 +185,8 @@ public class AccountSetupExchangeTests extends EmailContent.Account account = new EmailContent.Account(); account.setStoreUri(getInstrumentation().getTargetContext(), storeUriString); Intent i = new Intent(Intent.ACTION_MAIN); - i.putExtra(AccountSetupExchange.EXTRA_ACCOUNT, account); - i.putExtra(AccountSetupExchange.EXTRA_DISABLE_AUTO_DISCOVER, true); + SetupData.init(SetupData.FLOW_MODE_NORMAL, account); + SetupData.setAllowAutodiscover(false); return i; } //EXCHANGE-REMOVE-SECTION-END diff --git a/tests/src/com/android/email/activity/setup/AccountSetupIncomingTests.java b/tests/src/com/android/email/activity/setup/AccountSetupIncomingTests.java index 96753f489..7498de2a2 100644 --- a/tests/src/com/android/email/activity/setup/AccountSetupIncomingTests.java +++ b/tests/src/com/android/email/activity/setup/AccountSetupIncomingTests.java @@ -28,14 +28,13 @@ import android.widget.EditText; /** * Tests of the basic UI logic in the Account Setup Incoming (IMAP / POP3) screen. + * You can run this entire test case with: + * runtest -c com.android.email.activity.setup.AccountSetupIncomingTests email */ @MediumTest public class AccountSetupIncomingTests extends ActivityInstrumentationTestCase2<AccountSetupIncoming> { - // borrowed from AccountSetupIncoming - private static final String EXTRA_ACCOUNT = "account"; - private AccountSetupIncoming mActivity; private EditText mServerView; private Button mNextButton; @@ -146,9 +145,8 @@ public class AccountSetupIncomingTests extends private Intent getTestIntent(String storeUriString) { EmailContent.Account account = new EmailContent.Account(); account.setStoreUri(getInstrumentation().getTargetContext(), storeUriString); - Intent i = new Intent(Intent.ACTION_MAIN); - i.putExtra(EXTRA_ACCOUNT, account); - return i; + SetupData.init(SetupData.FLOW_MODE_NORMAL, account); + return new Intent(Intent.ACTION_MAIN); } } diff --git a/tests/src/com/android/email/activity/setup/AccountSetupNamesTests.java b/tests/src/com/android/email/activity/setup/AccountSetupNamesTests.java index 448982d70..1245635f1 100644 --- a/tests/src/com/android/email/activity/setup/AccountSetupNamesTests.java +++ b/tests/src/com/android/email/activity/setup/AccountSetupNamesTests.java @@ -30,13 +30,11 @@ import android.widget.Button; /** * Tests of basic UI logic in the AccountSetupNamesTest screen. + * You can run this entire test case with: + * runtest -c com.android.email.activity.setup.AccountSetupNamesTests email */ @MediumTest public class AccountSetupNamesTests extends ActivityInstrumentationTestCase2<AccountSetupNames> { - - // borrowed from AccountSetupNames - private static final String EXTRA_ACCOUNT_ID = "accountId"; - private long mAccountId; private EmailContent.Account mAccount; @@ -129,9 +127,7 @@ public class AccountSetupNamesTests extends ActivityInstrumentationTestCase2<Acc mAccount.mHostAuthRecv = hostAuth; mAccount.save(mContext); mAccountId = mAccount.mId; - - Intent i = new Intent(Intent.ACTION_MAIN); - i.putExtra(EXTRA_ACCOUNT_ID, mAccountId); - return i; + SetupData.init(SetupData.FLOW_MODE_NORMAL, mAccount); + return new Intent(Intent.ACTION_MAIN); } } diff --git a/tests/src/com/android/email/activity/setup/AccountSetupOptionsTests.java b/tests/src/com/android/email/activity/setup/AccountSetupOptionsTests.java index 5e6cdcbf7..8e7bc82b6 100644 --- a/tests/src/com/android/email/activity/setup/AccountSetupOptionsTests.java +++ b/tests/src/com/android/email/activity/setup/AccountSetupOptionsTests.java @@ -28,14 +28,13 @@ import android.widget.SpinnerAdapter; /** * Tests of basic UI logic in the AccountSetupOptions screen. + * You can run this entire test case with: + * runtest -c com.android.email.activity.setup.AccountSetupOptionsTests email */ @MediumTest public class AccountSetupOptionsTests extends ActivityInstrumentationTestCase2<AccountSetupOptions> { - // borrowed from AccountSetupOptions - private static final String EXTRA_ACCOUNT = "account"; - private AccountSetupOptions mActivity; private Spinner mCheckFrequencyView; @@ -118,9 +117,8 @@ public class AccountSetupOptionsTests EmailContent.Account account = new EmailContent.Account(); account.setSenderName(name); account.setStoreUri(getInstrumentation().getTargetContext(), storeUri); - Intent i = new Intent(Intent.ACTION_MAIN); - i.putExtra(EXTRA_ACCOUNT, account); - return i; + SetupData.init(SetupData.FLOW_MODE_NORMAL, account); + return new Intent(Intent.ACTION_MAIN); } } diff --git a/tests/src/com/android/email/activity/setup/AccountSetupOutgoingTests.java b/tests/src/com/android/email/activity/setup/AccountSetupOutgoingTests.java index d1f0a0a46..4a60c83d6 100644 --- a/tests/src/com/android/email/activity/setup/AccountSetupOutgoingTests.java +++ b/tests/src/com/android/email/activity/setup/AccountSetupOutgoingTests.java @@ -28,6 +28,8 @@ import android.widget.EditText; /** * Tests of the basic UI logic in the Account Setup Outgoing (SMTP) screen. + * You can run this entire test case with: + * runtest -c com.android.email.activity.setup.AccountSetupOutgoingTests email */ @MediumTest public class AccountSetupOutgoingTests extends @@ -140,9 +142,8 @@ public class AccountSetupOutgoingTests extends private Intent getTestIntent(String senderUriString) { EmailContent.Account account = new EmailContent.Account(); account.setSenderUri(this.getInstrumentation().getTargetContext(), senderUriString); - Intent i = new Intent(Intent.ACTION_MAIN); - i.putExtra("account", account); // AccountSetupNames.EXTRA_ACCOUNT == "account" - return i; + SetupData.init(SetupData.FLOW_MODE_NORMAL, account); + return new Intent(Intent.ACTION_MAIN); } } |