FileDocCategorySizeDatePackage
AccountSetupIncomingTests.javaAPI DocAndroid 1.5 API4839Wed May 06 22:42:46 BST 2009com.android.email.activity.setup

AccountSetupIncomingTests

public class AccountSetupIncomingTests extends android.test.ActivityInstrumentationTestCase2
Tests of the basic UI logic in the Account Setup Incoming (IMAP / POP3) screen.

Fields Summary
private AccountSetupIncoming
mActivity
private android.widget.EditText
mServerView
private android.widget.Button
mNextButton
Constructors Summary
public AccountSetupIncomingTests()

        super("com.android.email", AccountSetupIncoming.class);
    
Methods Summary
private voidgetActivityAndFields()
Get the activity (which causes it to be started, using our intent) and get the UI fields

        mActivity = getActivity();
        mServerView = (EditText) mActivity.findViewById(R.id.account_server);
        mNextButton = (Button) mActivity.findViewById(R.id.next);
    
private android.content.IntentgetTestIntent(java.lang.String storeUriString)
Create an intent with the Account in it

        Account account = new Account(this.getInstrumentation().getTargetContext());
        account.setStoreUri(storeUriString);
        Intent i = new Intent(Intent.ACTION_MAIN);
        i.putExtra("account", account);     // AccountSetupNames.EXTRA_ACCOUNT == "account"
        return i;
    
protected voidsetUp()
Common setup code for all tests. Sets up a default launch intent, which some tests will use (others will override).

        super.setUp();

        // This sets up a default URI which can be used by any of the test methods below.
        // Individual test methods can replace this with a custom URI if they wish
        // (except those that run on the UI thread - for them, it's too late to change it.)
        Intent i = getTestIntent("imap://user:password@server.com:999");
        setActivityIntent(i);
    
public voidtestBadServerVariants()
Test for non-empty but non-OK server names

        getActivityAndFields();
        assertTrue(mNextButton.isEnabled());
        
        mServerView.setText("  ");
        assertFalse(mNextButton.isEnabled());
        
        mServerView.setText("serv$er.com");
        assertFalse(mNextButton.isEnabled());
    
public voidtestBadUriNoPassword()
No password is not OK - not enabled

        Intent i = getTestIntent("imap://user@server.com:999");
        setActivityIntent(i);
        getActivityAndFields();
        assertFalse(mNextButton.isEnabled());
    
public voidtestBadUriNoUser()
No user is not OK - not enabled

        Intent i = getTestIntent("imap://:password@server.com:999");
        setActivityIntent(i);
        getActivityAndFields();
        assertFalse(mNextButton.isEnabled());
    
public voidtestGoodServerVariants()
Test for non-standard but OK server names

        getActivityAndFields();
        assertTrue(mNextButton.isEnabled());
        
        mServerView.setText("  server.com  ");
        assertTrue(mNextButton.isEnabled());
    
public voidtestGoodUri()
Test processing with a complete, good URI -> good fields

        Intent i = getTestIntent("imap://user:password@server.com:999");
        setActivityIntent(i);
        getActivityAndFields();
        assertTrue(mNextButton.isEnabled());
    
public voidtestGoodUriNoPort()
No port is OK - still enabled

        Intent i = getTestIntent("imap://user:password@server.com");
        setActivityIntent(i);
        getActivityAndFields();
        assertTrue(mNextButton.isEnabled());