1
0
Fork 0

For #4094 - Improved original PR to fix screenshots tests API21 (#4144)

use robot for three dot menu screenshot
master
isabelrios 2019-07-22 18:58:53 +02:00 committed by Richard Pappalardo
parent 5ecdce6ba6
commit a984bb4799
3 changed files with 19 additions and 52 deletions

View File

@ -16,6 +16,7 @@ import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.UiDevice
import androidx.test.espresso.matcher.ViewMatchers.Visibility
import org.hamcrest.CoreMatchers
import org.mozilla.fenix.R
/**
* Implementation of Robot Pattern for the settings menu.
@ -50,3 +51,5 @@ private fun assertAdvancedHeading() = onView(ViewMatchers.withText("Advanced"))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
private fun goBackButton() = onView(CoreMatchers.allOf(withContentDescription("Navigate up")))
fun swipeToBottom() = onView(ViewMatchers.withId(R.id.recycler_view)).perform(ViewActions.swipeUp())

View File

@ -39,7 +39,7 @@ class ThreeDotMenuRobot {
private val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
fun openSettings(interact: SettingsRobot.() -> Unit): SettingsRobot.Transition {
mDevice.wait(Until.findObject(By.text("Settings")), waitingTime)
mDevice.wait(Until.findObject(By.text("R.string.settings")), waitingTime)
settingsButton().click()
SettingsRobot().interact()
@ -47,7 +47,7 @@ class ThreeDotMenuRobot {
}
fun openLibrary(interact: LibraryRobot.() -> Unit): LibraryRobot.Transition {
mDevice.wait(Until.findObject(By.text("Library")), waitingTime)
mDevice.wait(Until.findObject(By.text("R.string.Library")), waitingTime)
libraryButton().click()
LibraryRobot().interact()
@ -90,7 +90,7 @@ class ThreeDotMenuRobot {
private fun threeDotMenuRecyclerViewExists() {
onView(withId(R.id.mozac_browser_menu_recyclerView)).check(matches(isDisplayed()))
}
private fun settingsButton() = onView(allOf(withText("Settings")))
private fun settingsButton() = onView(allOf(withText(R.string.settings)))
private fun assertSettingsButton() = settingsButton()
.check(ViewAssertions.matches(ViewMatchers.withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))

View File

@ -9,19 +9,14 @@ import org.junit.Test
import org.mozilla.fenix.HomeActivity
import org.mozilla.fenix.R
import org.mozilla.fenix.helpers.HomeActivityTestRule
import org.mozilla.fenix.helpers.TestAssetHelper
import tools.fastlane.screengrab.Screengrab
import tools.fastlane.screengrab.locale.LocaleTestRule
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.action.ViewActions
import androidx.test.espresso.action.ViewActions.click
import androidx.test.espresso.action.ViewActions.swipeUp
import androidx.test.espresso.matcher.ViewMatchers.withId
import br.com.concretesolutions.kappuccino.actions.ClickActions
import org.hamcrest.Matchers.allOf
import org.mozilla.fenix.ui.robots.homeScreen
import org.mozilla.fenix.ui.robots.swipeToBottom
class ThreeDotMenuScreenShotTest : ScreenshotTest() {
@Rule @JvmField
@ -37,7 +32,8 @@ class ThreeDotMenuScreenShotTest : ScreenshotTest() {
@Test
fun threeDotMenu() {
onView(allOf(withId(R.id.menuButton))).perform(click())
homeScreen {
}.openThreeDotMenu { }
Screengrab.screenshot("three-dot-menu")
device.pressBack()
}
@ -46,11 +42,10 @@ class ThreeDotMenuScreenShotTest : ScreenshotTest() {
fun settingsTest() {
homeScreen {
}.openThreeDotMenu {
}
settingsButton2()
}.openSettings { }
Screengrab.screenshot("settings")
SystemClock.sleep(1000)
SystemClock.sleep(TestAssetHelper.waitingTime)
settingsAccount()
Screengrab.screenshot("settings-sync")
device.pressBack()
@ -76,58 +71,29 @@ class ThreeDotMenuScreenShotTest : ScreenshotTest() {
fun settingsAfterScrollMenusTest() {
homeScreen {
}.openThreeDotMenu {
}.openSettings {
swipeToBottom()
}
settingsButton2()
SystemClock.sleep(1000)
onView(withId(R.id.switch_widget)).perform(ViewActions.swipeUp())
onView(withId(R.id.switch_widget)).perform(ViewActions.swipeUp())
Screengrab.screenshot("settings-scroll")
SystemClock.sleep(2000)
Screengrab.screenshot("settings-scroll-to-bottom")
SystemClock.sleep(TestAssetHelper.waitingTime)
settingsRemoveData()
Screengrab.screenshot("settings-delete-browsing-data")
device.pressBack()
SystemClock.sleep(1000)
onView(withId(R.id.switch_widget)).perform(ViewActions.swipeUp())
onView(withId(R.id.switch_widget)).perform(ViewActions.swipeUp())
Screengrab.screenshot("settings-scroll")
SystemClock.sleep(3000)
SystemClock.sleep(TestAssetHelper.waitingTime)
settingsTelemetry()
Screengrab.screenshot("settings-telemetry")
device.pressBack()
}
@Test
fun settingsScrollToBottomTest() {
homeScreen {
}.openThreeDotMenu {
}
settingsButton2()
SystemClock.sleep(1000)
onView(withId(R.id.switch_widget)).perform(ViewActions.swipeUp())
onView(withId(R.id.switch_widget)).perform(ViewActions.swipeUp())
onView(withId(R.id.switch_widget)).perform(ViewActions.swipeUp())
Screengrab.screenshot("settings-scroll2")
SystemClock.sleep(1000)
onView(withId(R.id.switch_widget)).perform(ViewActions.swipeUp())
onView(withId(R.id.switch_widget)).perform(ViewActions.swipeUp())
Screengrab.screenshot("settings-scroll3")
SystemClock.sleep(1000)
onView(withId(R.id.recycler_view)).perform(swipeUp())
Screengrab.screenshot("settings-scroll4")
}
@Test
fun libraryTest() {
homeScreen {
}.openThreeDotMenu {
}
libraryButton()
}.openLibrary { }
Screengrab.screenshot("library")
bookmarksButton()
Screengrab.screenshot("library-bookmarks")
device.pressBack()
@ -136,8 +102,6 @@ class ThreeDotMenuScreenShotTest : ScreenshotTest() {
}
}
fun settingsButton2() = ClickActions.click { text(R.string.settings) }
fun libraryButton() = ClickActions.click { text(R.string.browser_menu_your_library) }
fun bookmarksButton() = ClickActions.click { text(R.string.library_bookmarks) }
fun historyButton() = ClickActions.click { text(R.string.library_history) }
fun settingsAccount() = ClickActions.click { text(R.string.preferences_sync) }