FolderMessageListUnitTestspublic 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 |
Methods Summary |
---|
private void | checkIntent(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 void | createTestAccount()Create a dummy account with minimal fields
mAccount = new Account(getContext());
mAccount.save(mPreferences);
mUuid = mAccount.getUuid();
| protected void | setUp()
super.setUp();
mPreferences = Preferences.getPreferences(getContext());
| protected void | tearDown()Delete any dummy accounts we set up for this test
super.tearDown();
if (mAccount != null && mPreferences != null) {
mAccount.delete(mPreferences);
}
| public void | testActionHandleAccount()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 void | testActionHandleAccountIntent()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 void | testActionHandleAccountUriIntent()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");
|
|