Update MessageComposetests with latest refactors

Change-Id: I7ab1275f4f4a803588619952f55fd81520036526
This commit is contained in:
Ben Komalo 2011-05-04 16:34:32 -07:00
parent c7c0b6791c
commit c6beaaea59
2 changed files with 40 additions and 49 deletions

View File

@ -106,8 +106,6 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus
"com.android.email.activity.MessageCompose.ccShown";
private static final String STATE_KEY_QUOTED_TEXT_SHOWN =
"com.android.email.activity.MessageCompose.quotedTextShown";
private static final String STATE_KEY_SOURCE_MESSAGE_PROCED =
"com.android.email.activity.MessageCompose.stateKeySourceMessageProced";
private static final String STATE_KEY_DRAFT_ID =
"com.android.email.activity.MessageCompose.draftId";
private static final String STATE_KEY_LAST_SAVE_TASK_ID =
@ -152,13 +150,6 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus
*/
private String mAction;
/**
* Indicates that the source message has been processed at least once and should not
* be processed on any subsequent loads. This protects us from adding attachments that
* have already been added from the restore of the view state.
*/
private boolean mSourceMessageProcessed = false;
private TextView mFromView;
private MultiAutoCompleteTextView mToView;
private MultiAutoCompleteTextView mCcView;
@ -343,7 +334,6 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus
initFromIntent(intent);
setDraftNeedsSaving(true);
mMessageLoaded = true;
mSourceMessageProcessed = true;
} else if (ACTION_REPLY.equals(mAction)
|| ACTION_REPLY_ALL.equals(mAction)
|| ACTION_FORWARD.equals(mAction)) {
@ -361,7 +351,6 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus
setInitialComposeText(null, getAccountSignature(mAccount));
mMessageLoaded = true;
mSourceMessageProcessed = true;
}
}
@ -443,7 +432,6 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus
outState.putBoolean(STATE_KEY_CC_SHOWN, mCcBccContainer.getVisibility() == View.VISIBLE);
outState.putBoolean(STATE_KEY_QUOTED_TEXT_SHOWN,
mQuotedTextBar.getVisibility() == View.VISIBLE);
outState.putBoolean(STATE_KEY_SOURCE_MESSAGE_PROCED, mSourceMessageProcessed);
// If there are any outstanding save requests, ensure that it's noted in case it hasn't
// finished by the time the activity is restored.
@ -648,34 +636,38 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus
mDraft = message;
loadAttachments(message.mId, mAccount);
if (restoreViews) {
mSubjectView.setText(message.mSubject);
addAddresses(mToView, Address.unpack(message.mTo));
Address[] cc = Address.unpack(message.mCc);
if (cc.length > 0) {
addAddresses(mCcView, cc);
}
Address[] bcc = Address.unpack(message.mBcc);
if (bcc.length > 0) {
addAddresses(mBccView, bcc);
}
mMessageContentView.setText(message.mText);
showCcBccFieldsIfFilled();
setNewMessageFocus();
}
setDraftNeedsSaving(false);
// The quoted text must always be restored.
displayQuotedText(message.mTextReply, message.mHtmlReply);
setIncludeQuotedText(
(mDraft.mFlags & Message.FLAG_NOT_INCLUDE_QUOTED_TEXT) == 0, false);
processDraftMessage(message, restoreViews);
}
}).executeParallel((Void[]) null);
}
@VisibleForTesting
void processDraftMessage(Message message, boolean restoreViews) {
if (restoreViews) {
mSubjectView.setText(message.mSubject);
addAddresses(mToView, Address.unpack(message.mTo));
Address[] cc = Address.unpack(message.mCc);
if (cc.length > 0) {
addAddresses(mCcView, cc);
}
Address[] bcc = Address.unpack(message.mBcc);
if (bcc.length > 0) {
addAddresses(mBccView, bcc);
}
mMessageContentView.setText(message.mText);
showCcBccFieldsIfFilled();
setNewMessageFocus();
}
setDraftNeedsSaving(false);
// The quoted text must always be restored.
displayQuotedText(message.mTextReply, message.mHtmlReply);
setIncludeQuotedText(
(mDraft.mFlags & Message.FLAG_NOT_INCLUDE_QUOTED_TEXT) == 0, false);
}
/**
* Asynchronously loads a source message (to be replied or forwarded in this current view),
* populating text fields and quoted text fields as appropriate when the load finishes.

View File

@ -357,7 +357,7 @@ public class MessageComposeTests
*
* TODO check CC and BCC handling too
*/
public void testProcessSourceMessageDraft() throws MessagingException, Throwable {
public void testProcessDraftMessage() throws MessagingException, Throwable {
final Message message = buildTestMessage(RECIPIENT_TO, SENDER, SUBJECT, BODY);
Intent intent = new Intent(ACTION_EDIT_DRAFT);
@ -366,7 +366,7 @@ public class MessageComposeTests
runTestOnUiThread(new Runnable() {
public void run() {
a.processSourceMessage(message, null);
a.processDraftMessage(message, true);
checkFields(RECIPIENT_TO + ", ", null, null, SUBJECT, BODY, null);
checkFocused(mMessageView);
}
@ -379,7 +379,7 @@ public class MessageComposeTests
runTestOnUiThread(new Runnable() {
public void run() {
resetViews();
a.processSourceMessage(message, null);
a.processDraftMessage(message, true);
checkFields(RECIPIENT_TO + ", ", null, null, null, BODY, null);
checkFocused(mSubjectView);
}
@ -388,10 +388,10 @@ public class MessageComposeTests
}
/**
* Test processSourceMessage() for EDIT_DRAFT with utf-16 name and address
* Test processDraftMessage() for EDIT_DRAFT with utf-16 name and address
* TODO check CC and BCC handling too
*/
public void testProcessSourceMessageDraftWithUtf16() throws MessagingException, Throwable {
public void testProcessDraftMessageWithUtf16() throws MessagingException, Throwable {
final Message message = buildTestMessage(UTF16_RECIPIENT_TO, UTF16_SENDER,
UTF16_SUBJECT, UTF16_BODY);
@ -401,7 +401,7 @@ public class MessageComposeTests
runTestOnUiThread(new Runnable() {
public void run() {
a.processSourceMessage(message, null);
a.processDraftMessage(message, true);
checkFields(UTF16_RECIPIENT_TO + ", ",
null, null, UTF16_SUBJECT, UTF16_BODY, null);
checkFocused(mMessageView);
@ -415,7 +415,7 @@ public class MessageComposeTests
runTestOnUiThread(new Runnable() {
public void run() {
resetViews();
a.processSourceMessage(message, null);
a.processDraftMessage(message, true);
checkFields(UTF16_RECIPIENT_TO + ", ", null, null, null, UTF16_BODY, null);
checkFocused(mSubjectView);
}
@ -424,10 +424,10 @@ public class MessageComposeTests
}
/**
* Test processSourceMessage() for EDIT_DRAFT with utf-32 name and address
* Test processDraftMessage() for EDIT_DRAFT with utf-32 name and address
* TODO check CC and BCC handling too
*/
public void testProcessSourceMessageDraftWithUtf32() throws MessagingException, Throwable {
public void testProcessDraftMessageWithUtf32() throws MessagingException, Throwable {
final Message message = buildTestMessage(UTF32_RECIPIENT_TO, UTF32_SENDER,
UTF32_SUBJECT, UTF32_BODY);
@ -437,7 +437,7 @@ public class MessageComposeTests
runTestOnUiThread(new Runnable() {
public void run() {
a.processSourceMessage(message, null);
a.processDraftMessage(message, true);
checkFields(UTF32_RECIPIENT_TO + ", ",
null, null, UTF32_SUBJECT, UTF32_BODY, null);
checkFocused(mMessageView);
@ -451,7 +451,7 @@ public class MessageComposeTests
runTestOnUiThread(new Runnable() {
public void run() {
resetViews();
a.processSourceMessage(message, null);
a.processDraftMessage(message, true);
checkFields(UTF32_RECIPIENT_TO + ", ", null, null, null, UTF32_BODY, null);
checkFocused(mSubjectView);
}
@ -823,8 +823,7 @@ public class MessageComposeTests
* @param content Content of the message
* @return a complete Message object
*/
private Message buildTestMessage(String to, String sender, String subject, String content)
throws MessagingException {
private Message buildTestMessage(String to, String sender, String subject, String content) {
Message message = new Message();
if (to != null) {