Skip to content

Commit

Permalink
New test
Browse files Browse the repository at this point in the history
  • Loading branch information
max-kammerer committed May 26, 2024
1 parent d34c8bd commit c095083
Showing 1 changed file with 35 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import androidx.test.espresso.action.GeneralSwipeAction
import androidx.test.espresso.action.Press
import androidx.test.espresso.action.Swipe
import androidx.test.espresso.action.Tap
import androidx.test.espresso.action.ViewActions
import androidx.test.espresso.matcher.ViewMatchers.withId
import org.junit.Assert.assertEquals
import org.junit.Test
Expand All @@ -19,11 +20,14 @@ import universe.constellation.orion.viewer.R
import universe.constellation.orion.viewer.test.framework.BookFile
import universe.constellation.orion.viewer.test.framework.checkEquals
import universe.constellation.orion.viewer.test.framework.checkTrue
import universe.constellation.orion.viewer.test.framework.onActivity
import universe.constellation.orion.viewer.test.framework.toOpenIntentWithNewUI

@RunWith(Parameterized::class)
open class PageSeekerTest(bookDescription: BookFile): BaseViewerActivityTest(bookDescription, bookDescription.toOpenIntentWithNewUI()) {

open fun configure() {}

@Test
fun testSlowSwipe() {
testGotoSwipe(Swipe.SLOW)
Expand All @@ -34,10 +38,6 @@ open class PageSeekerTest(bookDescription: BookFile): BaseViewerActivityTest(boo
testGotoSwipe(Swipe.FAST)
}

open fun configure() {

}

private fun testGotoSwipe(swipe: Swipe) {
configure()
openGoTo()
Expand All @@ -62,7 +62,6 @@ open class PageSeekerTest(bookDescription: BookFile): BaseViewerActivityTest(boo
checkPages(lastPageNumber, false)

assertEquals(0, currentPage0)

}

private fun checkPages(lastPageNumber: Int, last: Boolean) {
Expand All @@ -83,4 +82,35 @@ open class PageSeekerTest(bookDescription: BookFile): BaseViewerActivityTest(boo
)
}
}

@Test
fun testStepByStep() {
configure()
openGoTo()

onView(withId(R.id.page_picker_seeker)).perform(GeneralClickAction(Tap.SINGLE, GeneralLocation.CENTER_LEFT, Press.PINPOINT, InputDevice.SOURCE_TOUCHSCREEN,
MotionEvent.BUTTON_PRIMARY))

checkEquals(
"Wrong page",
0, currentPage0
)

for (i in 1..lastPageNumber0) {
onView(withId(R.id.page_picker_plus)).perform(ViewActions.click())
checkEquals(
"Wrong page",
i, currentPage0
)
}

for (i in lastPageNumber0-1 downTo 0) {
onView(withId(R.id.page_picker_minus)).perform(ViewActions.click())
checkEquals(
"Wrong page",
i, currentPage0
)
}
}

}

0 comments on commit c095083

Please sign in to comment.