Extract utilities from provider tests for use elsewhere.

This commit is contained in:
Andrew Stadler 2009-07-06 10:49:38 -07:00
parent 45f9dd22e1
commit 28448e782b
2 changed files with 291 additions and 239 deletions

View File

@ -0,0 +1,239 @@
/*
* Copyright (C) 2009 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.email.provider;
import com.android.email.provider.EmailContent.Account;
import com.android.email.provider.EmailContent.Mailbox;
import com.android.email.provider.EmailContent.Message;
import android.content.Context;
import junit.framework.Assert;
public class ProviderTestUtils extends Assert {
/**
* No constructor - statics only
*/
private ProviderTestUtils() {
}
/**
* Create an account for test purposes
*/
public static Account setupAccount(String name, boolean saveIt, Context context) {
Account account = new Account();
account.mDisplayName = name;
account.mEmailAddress = name + "@android.com";
account.mSyncKey = "sync-key-" + name;
account.mSyncLookback = 1;
account.mSyncFrequency = EmailContent.Account.CHECK_INTERVAL_NEVER;
account.mHostAuthKeyRecv = 2;
account.mHostAuthKeySend = 3;
account.mFlags = 4;
account.mIsDefault = true;
account.mCompatibilityUuid = "test-uid-" + name;
account.mSenderName = name;
account.mRingtoneUri = "content://ringtone-" + name;
if (saveIt) {
account.saveOrUpdate(context);
}
return account;
}
/**
* Create a mailbox for test purposes
*/
public static Mailbox setupMailbox(String name, long accountId, boolean saveIt,
Context context) {
Mailbox box = new Mailbox();
box.mDisplayName = name;
box.mServerId = "serverid-" + name;
box.mParentServerId = "parent-serverid-" + name;
box.mAccountKey = accountId;
box.mType = Mailbox.TYPE_MAIL;
box.mDelimiter = 1;
box.mSyncKey = "sync-key-" + name;
box.mSyncLookback = 2;
box.mSyncFrequency = EmailContent.Account.CHECK_INTERVAL_NEVER;
box.mSyncTime = 3;
box.mUnreadCount = 4;
box.mFlagVisible = true;
box.mFlags = 5;
box.mVisibleLimit = 6;
if (saveIt) {
box.saveOrUpdate(context);
}
return box;
}
/**
* Create a message for test purposes
*
* TODO: body
* TODO: attachments
*/
public static Message setupMessage(String name, long accountId, long mailboxId,
boolean addBody, boolean saveIt, Context context) {
Message message = new Message();
message.mDisplayName = name;
message.mTimeStamp = 1;
message.mSubject = "subject " + name;
message.mPreview = "preview " + name;
message.mFlagRead = true;
message.mFlagLoaded = Message.NOT_LOADED;
message.mFlagFavorite = true;
message.mFlagAttachment = true;
message.mFlags = 2;
message.mTextInfo = "textinfo " + name;
message.mHtmlInfo = "htmlinfo " + name;
message.mServerId = "serverid " + name;
message.mServerIntId = 0;
message.mClientId = "clientid " + name;
message.mMessageId = "messageid " + name;
message.mThreadId = "threadid " + name;
message.mMailboxKey = mailboxId;
message.mAccountKey = accountId;
message.mReferenceKey = 4;
message.mSender = "sender " + name;
message.mFrom = "from " + name;
message.mTo = "to " + name;
message.mCc = "cc " + name;
message.mBcc = "bcc " + name;
message.mReplyTo = "replyto " + name;
message.mServerVersion = "serverversion " + name;
if (addBody) {
message.mText = "body text " + name;
message.mHtml = "body html " + name;
}
if (saveIt) {
message.saveOrUpdate(context);
}
return message;
}
/**
* Compare two accounts for equality
*
* TODO: check host auth?
*/
public static void assertAccountEqual(String caller, Account expect, Account actual) {
if (expect == actual) {
return;
}
assertEquals(caller + " mDisplayName", expect.mDisplayName, actual.mDisplayName);
assertEquals(caller + " mEmailAddress", expect.mEmailAddress, actual.mEmailAddress);
assertEquals(caller + " mSyncKey", expect.mSyncKey, actual.mSyncKey);
assertEquals(caller + " mSyncLookback", expect.mSyncLookback, actual.mSyncLookback);
assertEquals(caller + " mSyncFrequency", expect.mSyncFrequency, actual.mSyncFrequency);
assertEquals(caller + " mHostAuthKeyRecv", expect.mHostAuthKeyRecv,
actual.mHostAuthKeyRecv);
assertEquals(caller + " mHostAuthKeySend", expect.mHostAuthKeySend,
actual.mHostAuthKeySend);
assertEquals(caller + " mFlags", expect.mFlags, actual.mFlags);
assertEquals(caller + " mIsDefault", expect.mIsDefault, actual.mIsDefault);
assertEquals(caller + " mCompatibilityUuid", expect.mCompatibilityUuid,
actual.mCompatibilityUuid);
assertEquals(caller + " mSenderName", expect.mSenderName, actual.mSenderName);
assertEquals(caller + " mRingtoneUri", expect.mRingtoneUri, actual.mRingtoneUri);
}
/**
* Compare two mailboxes for equality
*/
public static void assertMailboxEqual(String caller, Mailbox expect, Mailbox actual) {
if (expect == actual) {
return;
}
assertEquals(caller + " mDisplayName", expect.mDisplayName, actual.mDisplayName);
assertEquals(caller + " mServerId", expect.mServerId, actual.mServerId);
assertEquals(caller + " mParentServerId", expect.mParentServerId, actual.mParentServerId);
assertEquals(caller + " mAccountKey", expect.mAccountKey, actual.mAccountKey);
assertEquals(caller + " mType", expect.mType, actual.mType);
assertEquals(caller + " mDelimiter", expect.mDelimiter, actual.mDelimiter);
assertEquals(caller + " mSyncKey", expect.mSyncKey, actual.mSyncKey);
assertEquals(caller + " mSyncLookback", expect.mSyncLookback, actual.mSyncLookback);
assertEquals(caller + " mSyncFrequency", expect.mSyncFrequency, actual.mSyncFrequency);
assertEquals(caller + " mSyncTime", expect.mSyncTime, actual.mSyncTime);
assertEquals(caller + " mUnreadCount", expect.mUnreadCount, actual.mUnreadCount);
assertEquals(caller + " mFlagVisible", expect.mFlagVisible, actual.mFlagVisible);
assertEquals(caller + " mFlags", expect.mFlags, actual.mFlags);
assertEquals(caller + " mVisibleLimit", expect.mVisibleLimit, actual.mVisibleLimit);
}
/**
* Compare two messages for equality
*
* TODO: body?
* TODO: attachments?
*/
public static void assertMessageEqual(String caller, Message expect, Message actual) {
if (expect == actual) {
return;
}
assertEquals(caller + " mDisplayName", expect.mDisplayName, actual.mDisplayName);
assertEquals(caller + " mTimeStamp", expect.mTimeStamp, actual.mTimeStamp);
assertEquals(caller + " mSubject", expect.mSubject, actual.mSubject);
assertEquals(caller + " mPreview", expect.mPreview, actual.mPreview);
assertEquals(caller + " mFlagRead = false", expect.mFlagRead, actual.mFlagRead);
assertEquals(caller + " mFlagLoaded", expect.mFlagLoaded, actual.mFlagLoaded);
assertEquals(caller + " mFlagFavorite", expect.mFlagFavorite, actual.mFlagFavorite);
assertEquals(caller + " mFlagAttachment", expect.mFlagAttachment, actual.mFlagAttachment);
assertEquals(caller + " mFlags", expect.mFlags, actual.mFlags);
assertEquals(caller + " mTextInfo", expect.mTextInfo, actual.mTextInfo);
assertEquals(caller + " mHtmlInfo", expect.mHtmlInfo, actual.mHtmlInfo);
assertEquals(caller + " mServerId", expect.mServerId, actual.mServerId);
assertEquals(caller + " mServerIntId", expect.mServerIntId, actual.mServerIntId);
assertEquals(caller + " mClientId", expect.mClientId, actual.mClientId);
assertEquals(caller + " mMessageId", expect.mMessageId, actual.mMessageId);
assertEquals(caller + " mThreadId", expect.mThreadId, actual.mThreadId);
assertEquals(caller + " mMailboxKey", expect.mMailboxKey, actual.mMailboxKey);
assertEquals(caller + " mAccountKey", expect.mAccountKey, actual.mAccountKey);
assertEquals(caller + " mReferenceKey", expect.mReferenceKey, actual.mReferenceKey);
assertEquals(caller + " mSender", expect.mSender, actual.mSender);
assertEquals(caller + " mFrom", expect.mFrom, actual.mFrom);
assertEquals(caller + " mTo", expect.mTo, actual.mTo);
assertEquals(caller + " mCc", expect.mCc, actual.mCc);
assertEquals(caller + " mBcc", expect.mBcc, actual.mBcc);
assertEquals(caller + " mReplyTo", expect.mReplyTo, actual.mReplyTo);
assertEquals(caller + " mServerVersion", expect.mServerVersion, actual.mServerVersion);
assertEquals(caller + " mText", expect.mText, actual.mText);
assertEquals(caller + " mHtml", expect.mHtml, actual.mHtml);
}
}

View File

@ -60,12 +60,12 @@ public class ProviderTests extends ProviderTestCase2<EmailProvider> {
* Test simple account save/retrieve
*/
public void testAccountSave() {
Account account1 = setupAccount("account-save", true);
Account account1 = ProviderTestUtils.setupAccount("account-save", true, mMockContext);
long account1Id = account1.mId;
Account account2 = EmailContent.Account.restoreAccountWithId(mMockContext, account1Id);
assertAccountEqual("testAccountSave", account1, account2);
ProviderTestUtils.assertAccountEqual("testAccountSave", account1, account2);
}
/**
@ -76,14 +76,15 @@ public class ProviderTests extends ProviderTestCase2<EmailProvider> {
* Test simple mailbox save/retrieve
*/
public void testMailboxSave() {
Account account1 = setupAccount("mailbox-save", true);
Account account1 = ProviderTestUtils.setupAccount("mailbox-save", true, mMockContext);
long account1Id = account1.mId;
Mailbox box1 = setupMailbox("box1", account1Id, true);
Mailbox box1 = ProviderTestUtils.setupMailbox("box1", account1Id, true,
mMockContext);
long box1Id = box1.mId;
Mailbox box2 = EmailContent.Mailbox.restoreMailboxWithId(mMockContext, box1Id);
assertMailboxEqual("testMailboxSave", box1, box2);
ProviderTestUtils.assertMailboxEqual("testMailboxSave", box1, box2);
}
/**
@ -93,27 +94,29 @@ public class ProviderTests extends ProviderTestCase2<EmailProvider> {
* TODO: serverId vs. serverIntId
*/
public void testMessageSave() {
Account account1 = setupAccount("message-save", true);
Account account1 = ProviderTestUtils.setupAccount("message-save", true, mMockContext);
long account1Id = account1.mId;
Mailbox box1 = setupMailbox("box1", account1Id, true);
Mailbox box1 = ProviderTestUtils.setupMailbox("box1", account1Id, true, mMockContext);
long box1Id = box1.mId;
// Test a simple message (saved with no body)
Message message1 = setupMessage("message1", account1Id, box1Id, false, true);
Message message1 = ProviderTestUtils.setupMessage("message1", account1Id, box1Id, false,
true, mMockContext);
long message1Id = message1.mId;
Message message1get = EmailContent.Message.restoreMessageWithId(mMockContext, message1Id);
assertMessageEqual("testMessageSave", message1, message1get);
ProviderTestUtils.assertMessageEqual("testMessageSave", message1, message1get);
// Test a message saved with a body
// Note that it will read back w/o the text & html so we must extract those
Message message2 = setupMessage("message1", account1Id, box1Id, true, true);
Message message2 = ProviderTestUtils.setupMessage("message1", account1Id, box1Id, true,
true, mMockContext);
long message2Id = message2.mId;
String text2 = message2.mText;
String html2 = message2.mHtml;
message2.mText = null;
message2.mHtml = null;
Message message2get = EmailContent.Message.restoreMessageWithId(mMockContext, message2Id);
assertMessageEqual("testMessageSave", message2, message2get);
ProviderTestUtils.assertMessageEqual("testMessageSave", message2, message2get);
// Now see if there's a body saved with the right stuff
// TODO it might make sense to add a function to restore the body with the message id
@ -155,9 +158,9 @@ public class ProviderTests extends ProviderTestCase2<EmailProvider> {
* TODO: hostauth
*/
public void testAccountDelete() {
Account account1 = setupAccount("account-delete-1", true);
Account account1 = ProviderTestUtils.setupAccount("account-delete-1", true, mMockContext);
long account1Id = account1.mId;
Account account2 = setupAccount("account-delete-2", true);
Account account2 = ProviderTestUtils.setupAccount("account-delete-2", true, mMockContext);
long account2Id = account2.mId;
// make sure there are two accounts
@ -185,11 +188,11 @@ public class ProviderTests extends ProviderTestCase2<EmailProvider> {
* Test delete mailbox
*/
public void testMailboxDelete() {
Account account1 = setupAccount("mailbox-delete", true);
Account account1 = ProviderTestUtils.setupAccount("mailbox-delete", true, mMockContext);
long account1Id = account1.mId;
Mailbox box1 = setupMailbox("box1", account1Id, true);
Mailbox box1 = ProviderTestUtils.setupMailbox("box1", account1Id, true, mMockContext);
long box1Id = box1.mId;
Mailbox box2 = setupMailbox("box2", account1Id, true);
Mailbox box2 = ProviderTestUtils.setupMailbox("box2", account1Id, true, mMockContext);
long box2Id = box2.mId;
String selection = EmailContent.MailboxColumns.ACCOUNT_KEY + "=?";
@ -222,13 +225,15 @@ public class ProviderTests extends ProviderTestCase2<EmailProvider> {
* TODO: attachments
*/
public void testMessageDelete() {
Account account1 = setupAccount("message-delete", true);
Account account1 = ProviderTestUtils.setupAccount("message-delete", true, mMockContext);
long account1Id = account1.mId;
Mailbox box1 = setupMailbox("box1", account1Id, true);
Mailbox box1 = ProviderTestUtils.setupMailbox("box1", account1Id, true, mMockContext);
long box1Id = box1.mId;
Message message1 = setupMessage("message1", account1Id, box1Id, false, true);
Message message1 = ProviderTestUtils.setupMessage("message1", account1Id, box1Id, false,
true, mMockContext);
long message1Id = message1.mId;
Message message2 = setupMessage("message2", account1Id, box1Id, false, true);
Message message2 = ProviderTestUtils.setupMessage("message2", account1Id, box1Id, false,
true, mMockContext);
long message2Id = message2.mId;
String selection = EmailContent.MessageColumns.ACCOUNT_KEY + "=? AND " +
@ -262,13 +267,16 @@ public class ProviderTests extends ProviderTestCase2<EmailProvider> {
* TODO: attachments
*/
public void testSyncedMessageDelete() {
Account account1 = setupAccount("synced-message-delete", true);
Account account1 = ProviderTestUtils.setupAccount("synced-message-delete", true,
mMockContext);
long account1Id = account1.mId;
Mailbox box1 = setupMailbox("box1", account1Id, true);
Mailbox box1 = ProviderTestUtils.setupMailbox("box1", account1Id, true, mMockContext);
long box1Id = box1.mId;
Message message1 = setupMessage("message1", account1Id, box1Id, false, true);
Message message1 = ProviderTestUtils.setupMessage("message1", account1Id, box1Id, false,
true, mMockContext);
long message1Id = message1.mId;
Message message2 = setupMessage("message2", account1Id, box1Id, false, true);
Message message2 = ProviderTestUtils.setupMessage("message2", account1Id, box1Id, false,
true, mMockContext);
long message2Id = message2.mId;
String selection = EmailContent.MessageColumns.ACCOUNT_KEY + "=? AND "
@ -319,13 +327,15 @@ public class ProviderTests extends ProviderTestCase2<EmailProvider> {
* TODO: attachments
*/
public void testMessageUpdate() {
Account account1 = setupAccount("message-update", true);
Account account1 = ProviderTestUtils.setupAccount("message-update", true, mMockContext);
long account1Id = account1.mId;
Mailbox box1 = setupMailbox("box1", account1Id, true);
Mailbox box1 = ProviderTestUtils.setupMailbox("box1", account1Id, true, mMockContext);
long box1Id = box1.mId;
Message message1 = setupMessage("message1", account1Id, box1Id, false, true);
Message message1 = ProviderTestUtils.setupMessage("message1", account1Id, box1Id, false,
true, mMockContext);
long message1Id = message1.mId;
Message message2 = setupMessage("message2", account1Id, box1Id, false, true);
Message message2 = ProviderTestUtils.setupMessage("message2", account1Id, box1Id, false,
true, mMockContext);
long message2Id = message2.mId;
ContentResolver cr = mMockContext.getContentResolver();
@ -406,12 +416,15 @@ public class ProviderTests extends ProviderTestCase2<EmailProvider> {
* TODO: create other account, mailbox & messages and confirm the right objects were deleted
*/
public void testCascadeDeleteAccount() {
Account account1 = setupAccount("account-delete-cascade", true);
Account account1 = ProviderTestUtils.setupAccount("account-delete-cascade", true,
mMockContext);
long account1Id = account1.mId;
Mailbox box1 = setupMailbox("box1", account1Id, true);
Mailbox box1 = ProviderTestUtils.setupMailbox("box1", account1Id, true, mMockContext);
long box1Id = box1.mId;
/* Message message1 = */ setupMessage("message1", account1Id, box1Id, false, true);
/* Message message2 = */ setupMessage("message2", account1Id, box1Id, false, true);
/* Message message1 = */ ProviderTestUtils.setupMessage("message1", account1Id, box1Id,
false, true, mMockContext);
/* Message message2 = */ ProviderTestUtils.setupMessage("message2", account1Id, box1Id,
false, true, mMockContext);
// make sure there is one account, one mailbox, and two messages
int numAccounts = EmailContent.count(mMockContext, Account.CONTENT_URI, null, null);
@ -441,12 +454,15 @@ public class ProviderTests extends ProviderTestCase2<EmailProvider> {
* TODO: create other mailbox & messages and confirm the right objects were deleted
*/
public void testCascadeDeleteMailbox() {
Account account1 = setupAccount("mailbox-delete-cascade", true);
Account account1 = ProviderTestUtils.setupAccount("mailbox-delete-cascade", true,
mMockContext);
long account1Id = account1.mId;
Mailbox box1 = setupMailbox("box1", account1Id, true);
Mailbox box1 = ProviderTestUtils.setupMailbox("box1", account1Id, true, mMockContext);
long box1Id = box1.mId;
/* Message message1 = */ setupMessage("message1", account1Id, box1Id, false, true);
/* Message message2 = */ setupMessage("message2", account1Id, box1Id, false, true);
/* Message message1 = */ ProviderTestUtils.setupMessage("message1", account1Id, box1Id,
false, true, mMockContext);
/* Message message2 = */ ProviderTestUtils.setupMessage("message2", account1Id, box1Id,
false, true, mMockContext);
String selection = EmailContent.MessageColumns.ACCOUNT_KEY + "=? AND " +
EmailContent.MessageColumns.MAILBOX_KEY + "=?";
@ -470,208 +486,5 @@ public class ProviderTests extends ProviderTestCase2<EmailProvider> {
* TODO: body
* TODO: attachments
*/
/**
* Create an account for test purposes
*/
private Account setupAccount(String name, boolean saveIt) {
Account account = new Account();
account.mDisplayName = name;
account.mEmailAddress = name + "@android.com";
account.mSyncKey = "sync-key-" + name;
account.mSyncLookback = 1;
account.mSyncFrequency = EmailContent.Account.CHECK_INTERVAL_NEVER;
account.mHostAuthKeyRecv = 2;
account.mHostAuthKeySend = 3;
account.mFlags = 4;
account.mIsDefault = true;
account.mCompatibilityUuid = "test-uid-" + name;
account.mSenderName = name;
account.mRingtoneUri = "content://ringtone-" + name;
if (saveIt) {
account.saveOrUpdate(mMockContext);
}
return account;
}
/**
* Create a mailbox for test purposes
*/
private Mailbox setupMailbox(String name, long accountId, boolean saveIt) {
Mailbox box = new Mailbox();
box.mDisplayName = name;
box.mServerId = "serverid-" + name;
box.mParentServerId = "parent-serverid-" + name;
box.mAccountKey = accountId;
box.mType = Mailbox.TYPE_MAIL;
box.mDelimiter = 1;
box.mSyncKey = "sync-key-" + name;
box.mSyncLookback = 2;
box.mSyncFrequency = EmailContent.Account.CHECK_INTERVAL_NEVER;
box.mSyncTime = 3;
box.mUnreadCount = 4;
box.mFlagVisible = true;
box.mFlags = 5;
box.mVisibleLimit = 6;
if (saveIt) {
box.saveOrUpdate(mMockContext);
}
return box;
}
/**
* Create a message for test purposes
*
* TODO: body
* TODO: attachments
*/
private Message setupMessage(String name, long accountId, long mailboxId, boolean addBody,
boolean saveIt) {
Message message = new Message();
message.mDisplayName = name;
message.mTimeStamp = 1;
message.mSubject = "subject " + name;
message.mPreview = "preview " + name;
message.mFlagRead = true;
message.mFlagLoaded = Message.NOT_LOADED;
message.mFlagFavorite = true;
message.mFlagAttachment = true;
message.mFlags = 2;
message.mTextInfo = "textinfo " + name;
message.mHtmlInfo = "htmlinfo " + name;
message.mServerId = "serverid " + name;
message.mServerIntId = 0;
message.mClientId = "clientid " + name;
message.mMessageId = "messageid " + name;
message.mThreadId = "threadid " + name;
message.mMailboxKey = mailboxId;
message.mAccountKey = accountId;
message.mReferenceKey = 4;
message.mSender = "sender " + name;
message.mFrom = "from " + name;
message.mTo = "to " + name;
message.mCc = "cc " + name;
message.mBcc = "bcc " + name;
message.mReplyTo = "replyto " + name;
message.mServerVersion = "serverversion " + name;
if (addBody) {
message.mText = "body text " + name;
message.mHtml = "body html " + name;
}
if (saveIt) {
message.saveOrUpdate(mMockContext);
}
return message;
}
/**
* Compare two accounts for equality
*
* TODO: check host auth?
*/
private void assertAccountEqual(String caller, Account expect, Account actual) {
if (expect == actual) {
return;
}
assertEquals(caller + " mDisplayName", expect.mDisplayName, actual.mDisplayName);
assertEquals(caller + " mEmailAddress", expect.mEmailAddress, actual.mEmailAddress);
assertEquals(caller + " mSyncKey", expect.mSyncKey, actual.mSyncKey);
assertEquals(caller + " mSyncLookback", expect.mSyncLookback, actual.mSyncLookback);
assertEquals(caller + " mSyncFrequency", expect.mSyncFrequency, actual.mSyncFrequency);
assertEquals(caller + " mHostAuthKeyRecv", expect.mHostAuthKeyRecv,
actual.mHostAuthKeyRecv);
assertEquals(caller + " mHostAuthKeySend", expect.mHostAuthKeySend,
actual.mHostAuthKeySend);
assertEquals(caller + " mFlags", expect.mFlags, actual.mFlags);
assertEquals(caller + " mIsDefault", expect.mIsDefault, actual.mIsDefault);
assertEquals(caller + " mCompatibilityUuid", expect.mCompatibilityUuid,
actual.mCompatibilityUuid);
assertEquals(caller + " mSenderName", expect.mSenderName, actual.mSenderName);
assertEquals(caller + " mRingtoneUri", expect.mRingtoneUri, actual.mRingtoneUri);
}
/**
* Compare two mailboxes for equality
*/
private void assertMailboxEqual(String caller, Mailbox expect, Mailbox actual) {
if (expect == actual) {
return;
}
assertEquals(caller + " mDisplayName", expect.mDisplayName, actual.mDisplayName);
assertEquals(caller + " mServerId", expect.mServerId, actual.mServerId);
assertEquals(caller + " mParentServerId", expect.mParentServerId, actual.mParentServerId);
assertEquals(caller + " mAccountKey", expect.mAccountKey, actual.mAccountKey);
assertEquals(caller + " mType", expect.mType, actual.mType);
assertEquals(caller + " mDelimiter", expect.mDelimiter, actual.mDelimiter);
assertEquals(caller + " mSyncKey", expect.mSyncKey, actual.mSyncKey);
assertEquals(caller + " mSyncLookback", expect.mSyncLookback, actual.mSyncLookback);
assertEquals(caller + " mSyncFrequency", expect.mSyncFrequency, actual.mSyncFrequency);
assertEquals(caller + " mSyncTime", expect.mSyncTime, actual.mSyncTime);
assertEquals(caller + " mUnreadCount", expect.mUnreadCount, actual.mUnreadCount);
assertEquals(caller + " mFlagVisible", expect.mFlagVisible, actual.mFlagVisible);
assertEquals(caller + " mFlags", expect.mFlags, actual.mFlags);
assertEquals(caller + " mVisibleLimit", expect.mVisibleLimit, actual.mVisibleLimit);
}
/**
* Compare two messages for equality
*
* TODO: body?
* TODO: attachments?
*/
private void assertMessageEqual(String caller, Message expect, Message actual) {
if (expect == actual) {
return;
}
assertEquals(caller + " mDisplayName", expect.mDisplayName, actual.mDisplayName);
assertEquals(caller + " mTimeStamp", expect.mTimeStamp, actual.mTimeStamp);
assertEquals(caller + " mSubject", expect.mSubject, actual.mSubject);
assertEquals(caller + " mPreview", expect.mPreview, actual.mPreview);
assertEquals(caller + " mFlagRead = false", expect.mFlagRead, actual.mFlagRead);
assertEquals(caller + " mFlagLoaded", expect.mFlagLoaded, actual.mFlagLoaded);
assertEquals(caller + " mFlagFavorite", expect.mFlagFavorite, actual.mFlagFavorite);
assertEquals(caller + " mFlagAttachment", expect.mFlagAttachment, actual.mFlagAttachment);
assertEquals(caller + " mFlags", expect.mFlags, actual.mFlags);
assertEquals(caller + " mTextInfo", expect.mTextInfo, actual.mTextInfo);
assertEquals(caller + " mHtmlInfo", expect.mHtmlInfo, actual.mHtmlInfo);
assertEquals(caller + " mServerId", expect.mServerId, actual.mServerId);
assertEquals(caller + " mServerIntId", expect.mServerIntId, actual.mServerIntId);
assertEquals(caller + " mClientId", expect.mClientId, actual.mClientId);
assertEquals(caller + " mMessageId", expect.mMessageId, actual.mMessageId);
assertEquals(caller + " mThreadId", expect.mThreadId, actual.mThreadId);
assertEquals(caller + " mMailboxKey", expect.mMailboxKey, actual.mMailboxKey);
assertEquals(caller + " mAccountKey", expect.mAccountKey, actual.mAccountKey);
assertEquals(caller + " mReferenceKey", expect.mReferenceKey, actual.mReferenceKey);
assertEquals(caller + " mSender", expect.mSender, actual.mSender);
assertEquals(caller + " mFrom", expect.mFrom, actual.mFrom);
assertEquals(caller + " mTo", expect.mTo, actual.mTo);
assertEquals(caller + " mCc", expect.mCc, actual.mCc);
assertEquals(caller + " mBcc", expect.mBcc, actual.mBcc);
assertEquals(caller + " mReplyTo", expect.mReplyTo, actual.mReplyTo);
assertEquals(caller + " mServerVersion", expect.mServerVersion, actual.mServerVersion);
assertEquals(caller + " mText", expect.mText, actual.mText);
assertEquals(caller + " mHtml", expect.mHtml, actual.mHtml);
}
}