Skip to content

Commit

Permalink
Adds rule order
Browse files Browse the repository at this point in the history
  • Loading branch information
JoseAlcerreca committed Jan 18, 2024
1 parent b976d81 commit f1b3773
Showing 1 changed file with 9 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
package com.example.android.testing.espresso.EspressoDeviceSample

import androidx.test.espresso.Espresso.closeSoftKeyboard
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.matches
import androidx.test.espresso.device.DeviceInteraction.Companion.setBookMode
import androidx.test.espresso.device.DeviceInteraction.Companion.setClosedMode
import androidx.test.espresso.device.DeviceInteraction.Companion.setFlatMode
import androidx.test.espresso.device.DeviceInteraction.Companion.setTabletopMode
import androidx.test.espresso.device.EspressoDevice.Companion.onDevice
import androidx.test.espresso.device.action.ScreenOrientation
import androidx.test.espresso.device.action.setClosedMode
import androidx.test.espresso.device.action.setFlatMode
import androidx.test.espresso.device.action.setTabletopMode
import androidx.test.espresso.device.controller.DeviceMode.TABLETOP
import androidx.test.espresso.device.filter.RequiresDeviceMode
import androidx.test.espresso.device.rules.ScreenOrientationRule
Expand All @@ -31,22 +25,22 @@ import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
class OnDeviceTest {

@get:Rule var activityScenarioRule = activityScenarioRule<MainActivity>()
@get:Rule(order = 1) var activityScenarioRule = activityScenarioRule<MainActivity>()

@get:Rule val screenOrientationRule: ScreenOrientationRule =
ScreenOrientationRule(ScreenOrientation.PORTRAIT)
@get:Rule(order = 2) var screenOrientationRule: ScreenOrientationRule =
ScreenOrientationRule(ScreenOrientation.LANDSCAPE)

@Test
@RequiresDeviceMode(TABLETOP)
fun changeText_sameActivity() {
fun tabletopMode_playerIdDisplayed() {

onDevice().setBookMode()
// Type text and then press the button.
onView(withId(R.id.hello_tv)).check(matches(isDisplayed()))
onDevice().setTabletopMode()
onDevice().setClosedMode()
onView(withId(R.id.hello_tv)).check(matches(isDisplayed()))
onDevice().setFlatMode()
onView(withId(R.id.hello_tv)).check(matches(isDisplayed()))
// onDevice().setTabletopMode()
// onDevice().setClosedMode()
// onView(withId(R.id.hello_tv)).check(matches(isDisplayed()))
// onDevice().setFlatMode()
// onView(withId(R.id.hello_tv)).check(matches(isDisplayed()))
}
}

0 comments on commit f1b3773

Please sign in to comment.