From e25fc8dd558c071e9fc170397e022f088a6d601a Mon Sep 17 00:00:00 2001 From: Matthieu <24-artectrex@users.noreply.shinice.net> Date: Thu, 22 Apr 2021 09:20:20 +0000 Subject: [PATCH] Add tests --- .../h/pixeldroid/PostCreationActivityTest.kt | 40 ++++++++++++++++++- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/app/src/androidTest/java/com/h/pixeldroid/PostCreationActivityTest.kt b/app/src/androidTest/java/com/h/pixeldroid/PostCreationActivityTest.kt index 4e4de2af..85f72717 100644 --- a/app/src/androidTest/java/com/h/pixeldroid/PostCreationActivityTest.kt +++ b/app/src/androidTest/java/com/h/pixeldroid/PostCreationActivityTest.kt @@ -11,10 +11,10 @@ import androidx.core.net.toUri import androidx.test.core.app.ActivityScenario import androidx.test.espresso.Espresso.onView import androidx.test.espresso.action.ViewActions.click +import androidx.test.espresso.action.ViewActions.typeText import androidx.test.espresso.assertion.ViewAssertions.doesNotExist import androidx.test.espresso.assertion.ViewAssertions.matches -import androidx.test.espresso.matcher.ViewMatchers.isDisplayed -import androidx.test.espresso.matcher.ViewMatchers.withId +import androidx.test.espresso.matcher.ViewMatchers.* import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.platform.app.InstrumentationRegistry import androidx.test.rule.GrantPermissionRule @@ -154,6 +154,42 @@ class PostCreationActivityTest { onView(withId(R.id.addPhotoSquare)).check(matches(isDisplayed())) } + /** + * Type media description and check it's saved + */ + @Test + fun mediaDescription() { + waitForView(R.id.postTextInputLayout) + + + fun typeDescription(text: String) { + onView(withId(R.id.tv_caption)).perform(click()) + + waitForView(R.id.editTextMediaDescription) + + onView(withId(R.id.editTextMediaDescription)).perform(typeText(text)) + onView(withId(R.id.imageDescriptionButton)).perform(click()) + + onView(withId(R.id.tv_caption)).check(matches(withText(text))) + } + + val typedText1 = "Testi testo description" + typeDescription(typedText1) + + onView(withId(R.id.btn_next)).perform(click()) + + val typedText2 = "Description 2" + typeDescription(typedText2) + + onView(withId(R.id.btn_previous)).perform(click()) + + onView(withId(R.id.tv_caption)).check(matches(withText(typedText1))) + + onView(withId(R.id.btn_next)).perform(click()) + + onView(withId(R.id.tv_caption)).check(matches(withText(typedText2))) + } + /** * Makes sure the [com.h.pixeldroid.postCreation.camera.CameraActivity] is launched * when the add image button is pressed