2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-03 23:15:31 +00:00

[fenix] For https://github.com/mozilla-mobile/fenix/issues/18053 Change and fix Intermittent UI test verifyReaderViewToggle

This commit is contained in:
AndiAJ 2021-02-26 12:22:07 +02:00 committed by Oana Horvath
parent 9dbe4620d4
commit 9e6f2b7c64
2 changed files with 54 additions and 14 deletions

View File

@ -5,22 +5,22 @@
package org.mozilla.fenix.ui
import android.view.View
import androidx.test.espresso.IdlingRegistry
import okhttp3.mockwebserver.MockWebServer
import org.junit.After
import org.junit.Before
import org.junit.Ignore
import org.junit.Rule
import org.junit.Test
import org.mozilla.fenix.ui.robots.navigationToolbar
import androidx.test.espresso.IdlingRegistry
import org.junit.Ignore
import org.mozilla.fenix.FeatureFlags
import org.mozilla.fenix.R
import org.mozilla.fenix.helpers.AndroidAssetDispatcher
import org.mozilla.fenix.helpers.ViewVisibilityIdlingResource
import org.mozilla.fenix.helpers.HomeActivityIntentTestRule
import org.mozilla.fenix.helpers.TestAssetHelper
import org.mozilla.fenix.helpers.ViewVisibilityIdlingResource
import org.mozilla.fenix.ui.robots.browserScreen
import org.mozilla.fenix.ui.robots.mDevice
import org.mozilla.fenix.ui.robots.navigationToolbar
/**
* Tests for verifying basic functionality of content context menus
@ -125,6 +125,15 @@ class ReaderViewTest {
toggleReaderView()
mDevice.waitForIdle()
}
browserScreen {
verifyPageContent(estimatedReadingTime)
}
navigationToolbar {
verifyCloseReaderViewDetected(true)
toggleReaderView()
mDevice.waitForIdle()
verifyReaderViewDetected(true)
}
if (!FeatureFlags.toolbarMenuFeature) {
browserScreen {
@ -134,6 +143,7 @@ class ReaderViewTest {
}.closeBrowserMenuToBrowser { }
}
if (!FeatureFlags.toolbarMenuFeature) {
navigationToolbar {
toggleReaderView()
mDevice.waitForIdle()
@ -141,6 +151,7 @@ class ReaderViewTest {
verifyReaderViewAppearance(false)
}.close { }
}
}
@Test
@Ignore("To be re-implemented in https://github.com/mozilla-mobile/fenix/issues/17971")

View File

@ -11,7 +11,6 @@ import androidx.recyclerview.widget.RecyclerView
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.IdlingRegistry
import androidx.test.espresso.IdlingResource
import androidx.test.espresso.ViewInteraction
import androidx.test.espresso.action.ViewActions
import androidx.test.espresso.action.ViewActions.pressImeActionButton
import androidx.test.espresso.action.ViewActions.replaceText
@ -60,12 +59,21 @@ class NavigationToolbarRobot {
fun verifyTabButtonShortcutMenuItems() = assertTabButtonShortcutMenuItems()
fun verifyReaderViewDetected(visible: Boolean = false): ViewInteraction =
fun verifyReaderViewDetected(visible: Boolean = false) =
assertReaderViewDetected(visible)
fun verifyCloseReaderViewDetected(visible: Boolean = false) =
assertCloseReaderViewDetected(visible)
fun typeSearchTerm(searchTerm: String) = awesomeBar().perform(typeText(searchTerm))
fun toggleReaderView() = readerViewToggle().click()
fun toggleReaderView() {
mDevice.findObject(UiSelector()
.resourceId("$packageName:id/mozac_browser_toolbar_page_actions"))
.waitForExists(waitingTime)
readerViewToggle().click()
}
class Transition {
@ -312,7 +320,11 @@ private fun goBackButton() = mDevice.pressBack()
private fun readerViewToggle() =
onView(withParent(withId(R.id.mozac_browser_toolbar_page_actions)))
private fun assertReaderViewDetected(visible: Boolean) =
private fun assertReaderViewDetected(visible: Boolean) {
mDevice.findObject(UiSelector()
.description("Reader view"))
.waitForExists(waitingTime)
onView(
allOf(
withParent(withId(R.id.mozac_browser_toolbar_page_actions)),
@ -322,6 +334,23 @@ private fun assertReaderViewDetected(visible: Boolean) =
if (visible) matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))
else ViewAssertions.doesNotExist()
)
}
private fun assertCloseReaderViewDetected(visible: Boolean) {
mDevice.findObject(UiSelector()
.description("Close reader view"))
.waitForExists(waitingTime)
onView(
allOf(
withParent(withId(R.id.mozac_browser_toolbar_page_actions)),
withContentDescription("Close reader view")
)
).check(
if (visible) matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))
else ViewAssertions.doesNotExist()
)
}
inline fun runWithIdleRes(ir: IdlingResource?, pendingCheck: () -> Unit) {
try {