From 65124587840b840bc00ddb6d8670018a92644739 Mon Sep 17 00:00:00 2001 From: Marc Blank Date: Sun, 4 Jul 2010 18:17:54 -0700 Subject: [PATCH] DO NOT MERGE: Make sure signature is added to reply/forward * Add this to processSourceMessage in the reply/forward cases * Add unit tests for reply and forward case Backport of I6be8383fe5f217a4bda8e669cb69f439bc8e96b6 Bug: 2734321 Change-Id: Ia59e8c4e2f9663f2a10cff066eddeff80bc06cef --- .../email/activity/MessageCompose.java | 2 + ...ionTests.java => MessageComposeTests.java} | 56 +++++++++++++++++-- 2 files changed, 54 insertions(+), 4 deletions(-) rename tests/src/com/android/email/activity/{MessageComposeInstrumentationTests.java => MessageComposeTests.java} (94%) diff --git a/src/com/android/email/activity/MessageCompose.java b/src/com/android/email/activity/MessageCompose.java index eb1d3110f..17bc60777 100644 --- a/src/com/android/email/activity/MessageCompose.java +++ b/src/com/android/email/activity/MessageCompose.java @@ -1507,10 +1507,12 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus mSubjectView.setText(subject); } displayQuotedText(message.mText, message.mHtml); + setInitialComposeText(null, (account != null) ? account.mSignature : null); } else if (ACTION_FORWARD.equals(mAction)) { mSubjectView.setText(subject != null && !subject.toLowerCase().startsWith("fwd:") ? "Fwd: " + subject : subject); displayQuotedText(message.mText, message.mHtml); + setInitialComposeText(null, (account != null) ? account.mSignature : null); // TODO: re-enable loadAttachments below // if (!loadAttachments(message, 0)) { // mHandler.sendEmptyMessage(MSG_SKIPPED_ATTACHMENTS); diff --git a/tests/src/com/android/email/activity/MessageComposeInstrumentationTests.java b/tests/src/com/android/email/activity/MessageComposeTests.java similarity index 94% rename from tests/src/com/android/email/activity/MessageComposeInstrumentationTests.java rename to tests/src/com/android/email/activity/MessageComposeTests.java index caf8b02df..1a6c1c033 100644 --- a/tests/src/com/android/email/activity/MessageComposeInstrumentationTests.java +++ b/tests/src/com/android/email/activity/MessageComposeTests.java @@ -40,9 +40,12 @@ import android.widget.MultiAutoCompleteTextView; * Various instrumentation tests for MessageCompose. * * It might be possible to convert these to ActivityUnitTest, which would be faster. + * + * You can run this entire test case with: + * runtest -c com.android.email.activity.MessageComposeTests email */ @LargeTest -public class MessageComposeInstrumentationTests +public class MessageComposeTests extends ActivityInstrumentationTestCase2 { private MultiAutoCompleteTextView mToView; @@ -104,7 +107,7 @@ public class MessageComposeInstrumentationTests private static final String ACTION_FORWARD = "com.android.email.intent.action.FORWARD"; private static final String ACTION_EDIT_DRAFT = "com.android.email.intent.action.EDIT_DRAFT"; - public MessageComposeInstrumentationTests() { + public MessageComposeTests() { super(MessageCompose.class); } @@ -177,7 +180,6 @@ public class MessageComposeInstrumentationTests * TODO test REPLY_ALL */ public void testProcessSourceMessageReply() throws MessagingException, Throwable { - final Message message = buildTestMessage(RECIPIENT_TO, SENDER, SUBJECT, BODY); Intent intent = new Intent(ACTION_REPLY); final MessageCompose a = getActivity(); @@ -204,6 +206,51 @@ public class MessageComposeInstrumentationTests }); } + public void testProcessSourceMessageReplyWithSignature() throws MessagingException, Throwable { + final Message message = buildTestMessage(RECIPIENT_TO, SENDER, SUBJECT, BODY); + Intent intent = new Intent(ACTION_REPLY); + final MessageCompose a = getActivity(); + a.setIntent(intent); + final Account account = new Account(); + account.mSignature = SIGNATURE; + runTestOnUiThread(new Runnable() { + public void run() { + a.processSourceMessage(message, account); + checkFields(SENDER + ", ", null, null, "Re: " + SUBJECT, null, SIGNATURE); + checkFocused(mMessageView); + } + }); + + message.mFrom = null; + message.mReplyTo = Address.parseAndPack(REPLYTO); + + runTestOnUiThread(new Runnable() { + public void run() { + resetViews(); + a.processSourceMessage(message, account); + checkFields(REPLYTO + ", ", null, null, "Re: " + SUBJECT, null, SIGNATURE); + checkFocused(mMessageView); + } + }); + } + + public void testProcessSourceMessageForwardWithSignature() + throws MessagingException, Throwable { + final Message message = buildTestMessage(RECIPIENT_TO, SENDER, SUBJECT, BODY); + Intent intent = new Intent(ACTION_FORWARD); + final MessageCompose a = getActivity(); + a.setIntent(intent); + final Account account = new Account(); + account.mSignature = SIGNATURE; + runTestOnUiThread(new Runnable() { + public void run() { + a.processSourceMessage(message, account); + checkFields(null, null, null, "Fwd: " + SUBJECT, null, SIGNATURE); + checkFocused(mToView); + } + }); + } + /** * Test reply to utf-16 name and address */ @@ -692,9 +739,10 @@ public class MessageComposeInstrumentationTests } String contentText = mMessageView.getText().toString(); - if (content == null) { + if (content == null && signature == null) { assertEquals(0, contentText.length()); } else { + if (content == null) content = ""; if (signature != null) { int textLength = content.length(); if (textLength == 0 || content.charAt(textLength - 1) != '\n') {