am 411334d4: Fix broken test cases

Merge commit '411334d4e5c8019e646287c102faec7f18b8a13a' into eclair-plus-aosp

* commit '411334d4e5c8019e646287c102faec7f18b8a13a':
  Fix broken test cases
This commit is contained in:
Marc Blank 2009-09-12 11:50:37 -07:00 committed by Android Git Automerger
commit 90a32e1f83

View File

@ -26,6 +26,8 @@ import com.android.email.mail.store.LocalStore;
import com.android.email.provider.EmailContent;
import com.android.email.provider.EmailContent.Account;
import android.content.ContentUris;
import android.content.Context;
import android.net.Uri;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.MediumTest;
@ -41,6 +43,7 @@ import java.io.IOException;
@MediumTest
public class EmailHtmlUtilTest extends AndroidTestCase {
private EmailContent.Account mAccount;
private long mCreatedAccountId = -1;
private static final String textTags = "<b>Plain</b> &";
private static final String textSpaces = "3 spaces end.";
@ -50,13 +53,35 @@ public class EmailHtmlUtilTest extends AndroidTestCase {
protected void setUp() throws Exception {
super.setUp();
// Force assignment of a default account, and retrieve it
long accountId = Account.getDefaultAccountId(getContext());
mAccount = Account.restoreAccountWithId(getContext(), accountId);
Context context = getContext();
// Force assignment of a default account
long accountId = Account.getDefaultAccountId(context);
if (accountId == -1) {
Account account = new Account();
account.mSenderName = "Bob Sender";
account.mEmailAddress = "bob@sender.com";
account.save(context);
accountId = account.mId;
mCreatedAccountId = accountId;
}
Account.restoreAccountWithId(context, accountId);
// This is needed for mime image bodypart.
BinaryTempFileBody.setTempDirectory(getContext().getCacheDir());
}
@Override
protected void tearDown() throws Exception {
super.tearDown();
Context context = getContext();
// If we created an account, delete it here
if (mCreatedAccountId > -1) {
context.getContentResolver().delete(
ContentUris.withAppendedId(Account.CONTENT_URI, mCreatedAccountId), null, null);
}
}
/**
* Tests for resolving inline image src cid: reference to content uri.
*/