From 91237e9dcb0a948f17488b464edabcea0f259d31 Mon Sep 17 00:00:00 2001 From: Makoto Onuki Date: Tue, 2 Feb 2010 15:06:52 -0800 Subject: Adding script for building Email app without exchange. remove-exchange-support.sh makes it possible to build the email app without exchange support. This script: - removes all packages under com.android.exchange. - removes all lines surrounded by EXCHANGE-REMOVE-SECTION-START and EXCHANGE-REMOVE-SECTION-END And the resulting source should still build and run fine. Bug: 2369784 --- .../setup/AccountSetupAccountTypeUnitTests.java | 30 +++++++++++++--------- .../activity/setup/AccountSetupExchangeTests.java | 28 ++++++++++---------- 2 files changed, 33 insertions(+), 25 deletions(-) (limited to 'tests') diff --git a/tests/src/com/android/email/activity/setup/AccountSetupAccountTypeUnitTests.java b/tests/src/com/android/email/activity/setup/AccountSetupAccountTypeUnitTests.java index d5c5d6277..13ea7551a 100644 --- a/tests/src/com/android/email/activity/setup/AccountSetupAccountTypeUnitTests.java +++ b/tests/src/com/android/email/activity/setup/AccountSetupAccountTypeUnitTests.java @@ -35,16 +35,16 @@ import java.util.HashSet; * This is a series of unit tests for the AccountSetupAccountType class. */ @SmallTest -public class AccountSetupAccountTypeUnitTests +public class AccountSetupAccountTypeUnitTests extends ActivityUnitTestCase { // Borrowed from AccountSetupAccountType private static final String EXTRA_ACCOUNT = "account"; Context mContext; - + private HashSet mAccounts = new HashSet(); - + public AccountSetupAccountTypeUnitTests() { super(AccountSetupAccountType.class); } @@ -52,7 +52,7 @@ public class AccountSetupAccountTypeUnitTests @Override protected void setUp() throws Exception { super.setUp(); - + mContext = this.getInstrumentation().getTargetContext(); } @@ -65,11 +65,11 @@ public class AccountSetupAccountTypeUnitTests Uri uri = ContentUris.withAppendedId(Account.CONTENT_URI, account.mId); mContext.getContentResolver().delete(uri, null, null); } - + // must call last because it scrubs member variables super.tearDown(); } - + /** * Test store type limit enforcement */ @@ -77,7 +77,7 @@ public class AccountSetupAccountTypeUnitTests EmailContent.Account acct1 = createTestAccount("scheme1"); EmailContent.Account acct2 = createTestAccount("scheme1"); EmailContent.Account acct3 = createTestAccount("scheme2"); - + AccountSetupAccountType activity = startActivity(getTestIntent(acct1), null, null); // Test with no limit @@ -85,24 +85,30 @@ public class AccountSetupAccountTypeUnitTests info.mAccountInstanceLimit = -1; info.mScheme = "scheme1"; assertTrue("no limit", activity.checkAccountInstanceLimit(info)); - + // Test with limit, but not reached info.mAccountInstanceLimit = 3; assertTrue("limit, but not reached", activity.checkAccountInstanceLimit(info)); - + // Test with limit, reached info.mAccountInstanceLimit = 2; assertFalse("limit, reached", activity.checkAccountInstanceLimit(info)); } /** - * Confirm that EAS is presented (supported in this release) + * Confirm that EAS is presented, when supported. */ public void testEasOffered() { Account acct1 = createTestAccount("scheme1"); AccountSetupAccountType activity = startActivity(getTestIntent(acct1), null, null); View exchangeButton = activity.findViewById(R.id.exchange); - assertEquals(View.VISIBLE, exchangeButton.getVisibility()); + + int expected = View.GONE; // Default is hidden + //EXCHANGE-REMOVE-SECTION-START + expected = View.VISIBLE; // Will be visible if supported. + //EXCHANGE-REMOVE-SECTION-END + + assertEquals(expected, exchangeButton.getVisibility()); } /** @@ -115,7 +121,7 @@ public class AccountSetupAccountTypeUnitTests mAccounts.add(account); return account; } - + /** * Create an intent with the Account in it */ diff --git a/tests/src/com/android/email/activity/setup/AccountSetupExchangeTests.java b/tests/src/com/android/email/activity/setup/AccountSetupExchangeTests.java index 45413e380..d64ff10aa 100644 --- a/tests/src/com/android/email/activity/setup/AccountSetupExchangeTests.java +++ b/tests/src/com/android/email/activity/setup/AccountSetupExchangeTests.java @@ -37,17 +37,19 @@ import android.widget.EditText; @MediumTest public class AccountSetupExchangeTests extends ActivityInstrumentationTestCase2 { - + //EXCHANGE-REMOVE-SECTION-START private AccountSetupExchange mActivity; private EditText mServerView; private Button mNextButton; private CheckBox mSslRequiredCheckbox; private CheckBox mTrustAllCertificatesCheckbox; - + //EXCHANGE-REMOVE-SECTION-END + public AccountSetupExchangeTests() { super("com.android.email", AccountSetupExchange.class); } + //EXCHANGE-REMOVE-SECTION-START /** * Common setup code for all tests. Sets up a default launch intent, which some tests * will use (others will override). @@ -62,7 +64,7 @@ public class AccountSetupExchangeTests extends Intent i = getTestIntent("eas://user:password@server.com"); setActivityIntent(i); } - + /** * Test processing with a complete, good URI -> good fields */ @@ -72,7 +74,7 @@ public class AccountSetupExchangeTests extends getActivityAndFields(); assertTrue(mNextButton.isEnabled()); } - + // TODO Add tests for valid usernames in eas // They would be or \ or / or a valid email address @@ -85,7 +87,7 @@ public class AccountSetupExchangeTests extends getActivityAndFields(); assertFalse(mNextButton.isEnabled()); } - + /** * No password is not OK - not enabled */ @@ -95,7 +97,7 @@ public class AccountSetupExchangeTests extends getActivityAndFields(); assertFalse(mNextButton.isEnabled()); } - + /** * Test for non-standard but OK server names */ @@ -103,11 +105,11 @@ public class AccountSetupExchangeTests extends public void testGoodServerVariants() { getActivityAndFields(); assertTrue(mNextButton.isEnabled()); - + mServerView.setText(" server.com "); assertTrue(mNextButton.isEnabled()); } - + /** * Test for non-empty but non-OK server names */ @@ -115,10 +117,10 @@ public class AccountSetupExchangeTests extends public void testBadServerVariants() { getActivityAndFields(); assertTrue(mNextButton.isEnabled()); - + mServerView.setText(" "); assertFalse(mNextButton.isEnabled()); - + mServerView.setText("serv$er.com"); assertFalse(mNextButton.isEnabled()); } @@ -161,7 +163,7 @@ public class AccountSetupExchangeTests extends /** * TODO: Directly test validateFields() checking boolean result */ - + /** * Get the activity (which causes it to be started, using our intent) and get the UI fields */ @@ -173,7 +175,7 @@ public class AccountSetupExchangeTests extends mTrustAllCertificatesCheckbox = (CheckBox) mActivity.findViewById(R.id.account_trust_certificates); } - + /** * Create an intent with the Account in it */ @@ -185,5 +187,5 @@ public class AccountSetupExchangeTests extends i.putExtra(AccountSetupExchange.EXTRA_DISABLE_AUTO_DISCOVER, true); return i; } - + //EXCHANGE-REMOVE-SECTION-END } -- cgit v1.2.3