FileDocCategorySizeDatePackage
FolderMessageListUnitTests.javaAPI DocAndroid 1.5 API5313Wed May 06 22:42:46 BST 2009com.android.email.activity

FolderMessageListUnitTests

public class FolderMessageListUnitTests extends android.test.AndroidTestCase
This is a series of unit tests for the Preferences class. This is just unit tests of simple statics - the activity is not instantiated

Fields Summary
private com.android.email.Preferences
mPreferences
private String
mUuid
private com.android.email.Account
mAccount
Constructors Summary
Methods Summary
private voidcheckIntent(android.content.Intent i, android.net.Uri expectData, com.android.email.Account expectAccount, java.lang.String expectFolder)
Check the values in a generated intent

        
        Uri resultUri = i.getData();
        assertEquals(expectData, resultUri);
        
        Account resultAccount = (Account) i.getSerializableExtra("account");
        assertEquals(expectAccount, resultAccount);
        
        String resultFolder = i.getStringExtra("initialFolder");
        assertEquals(expectFolder, resultFolder);
    
private voidcreateTestAccount()
Create a dummy account with minimal fields

        mAccount = new Account(getContext());
        mAccount.save(mPreferences);
        
        mUuid = mAccount.getUuid();
    
protected voidsetUp()

        super.setUp();
        
        mPreferences = Preferences.getPreferences(getContext());
    
protected voidtearDown()
Delete any dummy accounts we set up for this test

        super.tearDown();
        
        if (mAccount != null && mPreferences != null) {
            mAccount.delete(mPreferences);
        }
    
public voidtestActionHandleAccount()
Test of actionHandleAccount() variants. Make sure they generate correct intents and then call startActivity() with them.

        // Create a dummy account
        createTestAccount();
        
        // Create a mock context to catch the startActivity calls
        MyContext mockContext = new MyContext(getContext());
        
        // First, try with no initial folder
        FolderMessageList.actionHandleAccount(mockContext, mAccount);
        Intent i = mockContext.startActivityIntent;
        assertNotNull(i);
        checkIntent(i, null, mAccount, null);
        
        // Next try with initial folder specified
        FolderMessageList.actionHandleAccount(mockContext, mAccount, "test-folder-name");
        i = mockContext.startActivityIntent;
        assertNotNull(i);
        checkIntent(i, null, mAccount, "test-folder-name");
    
public voidtestActionHandleAccountIntent()
Test of actionHandleAccountIntent(). Make sure it generates correct intents.

        // Create a dummy account
        createTestAccount();
        
        // First try with no initial folder
        Intent result = FolderMessageList.actionHandleAccountIntent(
                getContext(), mAccount, null);
        checkIntent(result, null, mAccount, null);
        
        // now try with a specified initial folder
        result = FolderMessageList.actionHandleAccountIntent(
                getContext(), mAccount, "test-folder-name");
        checkIntent(result, null, mAccount, "test-folder-name");
    
public voidtestActionHandleAccountUriIntent()
Test of actionHandleAccountUriIntent(). Make sure it generates correct intents.

        // Create a dummy account
        createTestAccount();
        
        // First try with no initial folder
        Intent result = FolderMessageList.actionHandleAccountUriIntent(
                getContext(), mAccount, null);
        checkIntent(result, mAccount.getContentUri(), null, null);
        
        // now try with a specified initial folder
        result = FolderMessageList.actionHandleAccountUriIntent(
                getContext(), mAccount, "test-folder-name");
        checkIntent(result, mAccount.getContentUri(), null, "test-folder-name");