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 Bug: 2734321 Change-Id: I6be8383fe5f217a4bda8e669cb69f439bc8e96b6
This commit is contained in:
parent
18452ba28c
commit
ec29471c73
|
@ -1445,10 +1445,12 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus
|
||||||
mSubjectView.setText(subject);
|
mSubjectView.setText(subject);
|
||||||
}
|
}
|
||||||
displayQuotedText(message.mText, message.mHtml);
|
displayQuotedText(message.mText, message.mHtml);
|
||||||
|
setInitialComposeText(null, (account != null) ? account.mSignature : null);
|
||||||
} else if (ACTION_FORWARD.equals(mAction)) {
|
} else if (ACTION_FORWARD.equals(mAction)) {
|
||||||
mSubjectView.setText(subject != null && !subject.toLowerCase().startsWith("fwd:") ?
|
mSubjectView.setText(subject != null && !subject.toLowerCase().startsWith("fwd:") ?
|
||||||
"Fwd: " + subject : subject);
|
"Fwd: " + subject : subject);
|
||||||
displayQuotedText(message.mText, message.mHtml);
|
displayQuotedText(message.mText, message.mHtml);
|
||||||
|
setInitialComposeText(null, (account != null) ? account.mSignature : null);
|
||||||
// TODO: re-enable loadAttachments below
|
// TODO: re-enable loadAttachments below
|
||||||
// if (!loadAttachments(message, 0)) {
|
// if (!loadAttachments(message, 0)) {
|
||||||
// Utility.showToast(this, R.string.message_compose_attachments_skipped_toast);
|
// Utility.showToast(this, R.string.message_compose_attachments_skipped_toast);
|
||||||
|
|
|
@ -40,9 +40,12 @@ import android.widget.MultiAutoCompleteTextView;
|
||||||
* Various instrumentation tests for MessageCompose.
|
* Various instrumentation tests for MessageCompose.
|
||||||
*
|
*
|
||||||
* It might be possible to convert these to ActivityUnitTest, which would be faster.
|
* 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
|
@LargeTest
|
||||||
public class MessageComposeInstrumentationTests
|
public class MessageComposeTests
|
||||||
extends ActivityInstrumentationTestCase2<MessageCompose> {
|
extends ActivityInstrumentationTestCase2<MessageCompose> {
|
||||||
|
|
||||||
private MultiAutoCompleteTextView mToView;
|
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_FORWARD = "com.android.email.intent.action.FORWARD";
|
||||||
private static final String ACTION_EDIT_DRAFT = "com.android.email.intent.action.EDIT_DRAFT";
|
private static final String ACTION_EDIT_DRAFT = "com.android.email.intent.action.EDIT_DRAFT";
|
||||||
|
|
||||||
public MessageComposeInstrumentationTests() {
|
public MessageComposeTests() {
|
||||||
super(MessageCompose.class);
|
super(MessageCompose.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,7 +180,6 @@ public class MessageComposeInstrumentationTests
|
||||||
* TODO test REPLY_ALL
|
* TODO test REPLY_ALL
|
||||||
*/
|
*/
|
||||||
public void testProcessSourceMessageReply() throws MessagingException, Throwable {
|
public void testProcessSourceMessageReply() throws MessagingException, Throwable {
|
||||||
|
|
||||||
final Message message = buildTestMessage(RECIPIENT_TO, SENDER, SUBJECT, BODY);
|
final Message message = buildTestMessage(RECIPIENT_TO, SENDER, SUBJECT, BODY);
|
||||||
Intent intent = new Intent(ACTION_REPLY);
|
Intent intent = new Intent(ACTION_REPLY);
|
||||||
final MessageCompose a = getActivity();
|
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
|
* Test reply to utf-16 name and address
|
||||||
*/
|
*/
|
||||||
|
@ -692,9 +739,10 @@ public class MessageComposeInstrumentationTests
|
||||||
}
|
}
|
||||||
|
|
||||||
String contentText = mMessageView.getText().toString();
|
String contentText = mMessageView.getText().toString();
|
||||||
if (content == null) {
|
if (content == null && signature == null) {
|
||||||
assertEquals(0, contentText.length());
|
assertEquals(0, contentText.length());
|
||||||
} else {
|
} else {
|
||||||
|
if (content == null) content = "";
|
||||||
if (signature != null) {
|
if (signature != null) {
|
||||||
int textLength = content.length();
|
int textLength = content.length();
|
||||||
if (textLength == 0 || content.charAt(textLength - 1) != '\n') {
|
if (textLength == 0 || content.charAt(textLength - 1) != '\n') {
|
Loading…
Reference in New Issue