From d98cb7b53f4fc3ed3278a3345662409c6268ca0f Mon Sep 17 00:00:00 2001 From: Rhodey Orbits Date: Fri, 12 Jun 2015 15:04:17 -0700 Subject: [PATCH] added test for forward of text message, detects #3413 and validates #3414 Closes #3416 // FREEBIE --- .../ConversationActivityActions.java | 10 ++++ .../securesms/ConversationActivityTest.java | 54 +++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 test/androidTestEspresso/java/org/thoughtcrime/securesms/ConversationActivityTest.java diff --git a/test/androidTestEspresso/java/org/thoughtcrime/securesms/ConversationActivityActions.java b/test/androidTestEspresso/java/org/thoughtcrime/securesms/ConversationActivityActions.java index b0be6884f5..238bbe9e84 100644 --- a/test/androidTestEspresso/java/org/thoughtcrime/securesms/ConversationActivityActions.java +++ b/test/androidTestEspresso/java/org/thoughtcrime/securesms/ConversationActivityActions.java @@ -20,6 +20,7 @@ import android.content.Context; import static android.support.test.espresso.Espresso.onView; import static android.support.test.espresso.Espresso.openActionBarOverflowOrOptionsMenu; +import static android.support.test.espresso.Espresso.openContextualActionModeOverflowMenu; import static android.support.test.espresso.action.ViewActions.click; import static android.support.test.espresso.matcher.ViewMatchers.withId; import static android.support.test.espresso.matcher.ViewMatchers.withText; @@ -42,6 +43,11 @@ public class ConversationActivityActions { onView(withText(R.string.conversation__menu_delete_thread)).perform(click()); } + public static void clickForwardMessage() throws Exception { + openContextualActionModeOverflowMenu(); + onView(withText(R.string.conversation_context__menu_forward_message)).perform(click()); + } + public static void toggleEmojiKeyboard() throws Exception { onView(withId(R.id.emoji_toggle)).perform(click()); } @@ -50,4 +56,8 @@ public class ConversationActivityActions { typeTextAndCloseKeyboard(onView(withId(R.id.embedded_text_editor)), message); } + public static void clickSend() throws Exception { + onView(withId(R.id.send_button)).perform(click()); + } + } diff --git a/test/androidTestEspresso/java/org/thoughtcrime/securesms/ConversationActivityTest.java b/test/androidTestEspresso/java/org/thoughtcrime/securesms/ConversationActivityTest.java new file mode 100644 index 0000000000..b0a7bbdadf --- /dev/null +++ b/test/androidTestEspresso/java/org/thoughtcrime/securesms/ConversationActivityTest.java @@ -0,0 +1,54 @@ +package org.thoughtcrime.securesms; + +import android.test.suitebuilder.annotation.LargeTest; + +import static android.support.test.espresso.Espresso.onView; +import static android.support.test.espresso.action.ViewActions.click; +import static android.support.test.espresso.action.ViewActions.longClick; +import static android.support.test.espresso.assertion.ViewAssertions.matches; +import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; +import static android.support.test.espresso.matcher.ViewMatchers.withId; +import static android.support.test.espresso.matcher.ViewMatchers.withText; +import static org.thoughtcrime.securesms.EspressoUtil.addContact; +import static org.thoughtcrime.securesms.EspressoUtil.waitOn; + +/** + * rhodey + */ +@LargeTest +public class ConversationActivityTest extends TextSecureEspressoTestCase { + + public ConversationActivityTest() { + super(ConversationListActivity.class); + } + + public void testForwardMessage() throws Exception { + final String[] CONTACT_NAMES = new String[] {"Clement Duval", "Masha Kolenkia"}; + final String[] CONTACT_NUMBERS = new String[] {"55555555555", "33333333333"}; + final String MESSAGE = "I struck him in the name of liberty"; + + addContact(getContext(), CONTACT_NAMES[0], CONTACT_NUMBERS[0]); + addContact(getContext(), CONTACT_NAMES[1], CONTACT_NUMBERS[1]); + loadActivity(ConversationListActivity.class, STATE_REGISTERED); + + ConversationListActivityActions.clickNewConversation(); + waitOn(NewConversationActivity.class); + NewConversationActivityActions.clickContactWithName(CONTACT_NAMES[0]); + waitOn(ConversationActivity.class); + ConversationActivityActions.typeMessage(MESSAGE); + ConversationActivityActions.clickSend(); + + onView(withText(MESSAGE)).perform(longClick()); + ConversationActivityActions.clickForwardMessage(); + + waitOn(ShareActivity.class); + onView(withId(R.id.menu_new_message)).perform(click()); + waitOn(NewConversationActivity.class); + NewConversationActivityActions.filterNameOrNumber(CONTACT_NAMES[1]); + NewConversationActivityActions.clickContactWithName(CONTACT_NAMES[1]); + + waitOn(ConversationActivity.class); + onView(withText(MESSAGE)).check(matches(isDisplayed())); + } + +}