1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 package org.mozilla.fenix.ui
7 import android.view.View
10 import org.mozilla.fenix.R
11 import org.mozilla.fenix.customannotations.SmokeTest
12 import org.mozilla.fenix.helpers.AppAndSystemHelper.registerAndCleanupIdlingResources
13 import org.mozilla.fenix.helpers.HomeActivityIntentTestRule
14 import org.mozilla.fenix.helpers.RetryTestRule
15 import org.mozilla.fenix.helpers.TestAssetHelper
16 import org.mozilla.fenix.helpers.TestHelper.mDevice
17 import org.mozilla.fenix.helpers.TestSetup
18 import org.mozilla.fenix.helpers.ViewVisibilityIdlingResource
19 import org.mozilla.fenix.ui.robots.browserScreen
20 import org.mozilla.fenix.ui.robots.navigationToolbar
23 * Tests for verifying basic functionality of content context menus
25 * - Verifies Reader View entry and detection when available UI and functionality
26 * - Verifies Reader View exit UI and functionality
27 * - Verifies Reader View appearance controls UI and functionality
31 class ReaderViewTest : TestSetup() {
32 private val estimatedReadingTime = "1 - 2 minutes"
35 val activityIntentTestRule = HomeActivityIntentTestRule.withDefaultSettingsOverrides()
39 val retryTestRule = RetryTestRule(3)
42 * Verify that Reader View capable pages
44 * - Show the toggle button in the navigation bar
47 // TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/250592
49 fun verifyReaderModePageDetectionTest() {
51 TestAssetHelper.getLoremIpsumAsset(mockWebServer)
53 TestAssetHelper.getGenericAsset(mockWebServer, 1)
56 }.enterURLAndEnterToBrowser(readerViewPage.url) {
60 registerAndCleanupIdlingResources(
61 ViewVisibilityIdlingResource(
62 activityIntentTestRule.activity.findViewById(R.id.mozac_browser_toolbar_page_actions),
68 verifyReaderViewDetected(true)
69 }.enterURLAndEnterToBrowser(genericPage.url) {
72 verifyReaderViewDetected(false)
76 // TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/250585
79 fun verifyReaderModeControlsTest() {
81 TestAssetHelper.getLoremIpsumAsset(mockWebServer)
84 }.enterURLAndEnterToBrowser(readerViewPage.url) {
88 registerAndCleanupIdlingResources(
89 ViewVisibilityIdlingResource(
90 activityIntentTestRule.activity.findViewById(R.id.mozac_browser_toolbar_page_actions),
96 verifyReaderViewDetected(true)
102 verifyPageContent(estimatedReadingTime)
104 verifyReaderViewAppearance(true)
105 }.openReaderViewAppearance {
106 verifyAppearanceFontGroup(true)
107 verifyAppearanceFontSansSerif(true)
108 verifyAppearanceFontSerif(true)
109 verifyAppearanceFontIncrease(true)
110 verifyAppearanceFontDecrease(true)
111 verifyAppearanceFontSize(3)
112 verifyAppearanceColorGroup(true)
113 verifyAppearanceColorDark(true)
114 verifyAppearanceColorLight(true)
115 verifyAppearanceColorSepia(true)
117 verifyAppearanceFontIsActive("SANSSERIF")
119 verifyAppearanceFontIsActive("SERIF")
120 }.toggleFontSizeIncrease {
121 verifyAppearanceFontSize(4)
122 }.toggleFontSizeIncrease {
123 verifyAppearanceFontSize(5)
124 }.toggleFontSizeIncrease {
125 verifyAppearanceFontSize(6)
126 }.toggleFontSizeDecrease {
127 verifyAppearanceFontSize(5)
128 }.toggleFontSizeDecrease {
129 verifyAppearanceFontSize(4)
130 }.toggleFontSizeDecrease {
131 verifyAppearanceFontSize(3)
132 }.toggleColorSchemeChangeDark {
133 verifyAppearanceColorSchemeChange("DARK")
134 }.toggleColorSchemeChangeSepia {
135 verifyAppearanceColorSchemeChange("SEPIA")
136 }.toggleColorSchemeChangeLight {
137 verifyAppearanceColorSchemeChange("LIGHT")
138 }.closeAppearanceMenu {
142 mDevice.waitForIdle()
143 verifyReaderViewDetected(true)
145 verifyReaderViewAppearance(false)