Merge branch 'edit_fix' into 'master'

Add tests

See merge request pixeldroid/PixelDroid!330
This commit is contained in:
Matthieu 2021-04-22 09:20:20 +00:00
commit 1cf85fc624
1 changed files with 38 additions and 2 deletions

View File

@ -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