For #26286 new home screen UI tests
This commit is contained in:
parent
3d1924eb93
commit
26a8f02233
|
@ -8,15 +8,20 @@ import androidx.test.platform.app.InstrumentationRegistry
|
||||||
import androidx.test.uiautomator.By
|
import androidx.test.uiautomator.By
|
||||||
import androidx.test.uiautomator.UiDevice
|
import androidx.test.uiautomator.UiDevice
|
||||||
import androidx.test.uiautomator.Until
|
import androidx.test.uiautomator.Until
|
||||||
|
import okhttp3.mockwebserver.MockWebServer
|
||||||
|
import org.junit.After
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Rule
|
import org.junit.Rule
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.mozilla.fenix.ext.settings
|
import org.mozilla.fenix.helpers.AndroidAssetDispatcher
|
||||||
|
import org.mozilla.fenix.helpers.FeatureSettingsHelper
|
||||||
import org.mozilla.fenix.helpers.HomeActivityTestRule
|
import org.mozilla.fenix.helpers.HomeActivityTestRule
|
||||||
import org.mozilla.fenix.helpers.RetryTestRule
|
import org.mozilla.fenix.helpers.RetryTestRule
|
||||||
|
import org.mozilla.fenix.helpers.TestAssetHelper
|
||||||
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime
|
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime
|
||||||
import org.mozilla.fenix.helpers.ext.waitNotNull
|
import org.mozilla.fenix.helpers.ext.waitNotNull
|
||||||
import org.mozilla.fenix.ui.robots.homeScreen
|
import org.mozilla.fenix.ui.robots.homeScreen
|
||||||
|
import org.mozilla.fenix.ui.robots.navigationToolbar
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for verifying the presence of home screen and first-run homescreen elements
|
* Tests for verifying the presence of home screen and first-run homescreen elements
|
||||||
|
@ -29,6 +34,8 @@ class HomeScreenTest {
|
||||||
/* ktlint-disable no-blank-line-before-rbrace */ // This imposes unreadable grouping.
|
/* ktlint-disable no-blank-line-before-rbrace */ // This imposes unreadable grouping.
|
||||||
|
|
||||||
private lateinit var mDevice: UiDevice
|
private lateinit var mDevice: UiDevice
|
||||||
|
private lateinit var mockWebServer: MockWebServer
|
||||||
|
private val featureSettingsHelper = FeatureSettingsHelper()
|
||||||
|
|
||||||
@get:Rule
|
@get:Rule
|
||||||
val activityTestRule = HomeActivityTestRule()
|
val activityTestRule = HomeActivityTestRule()
|
||||||
|
@ -40,6 +47,19 @@ class HomeScreenTest {
|
||||||
@Before
|
@Before
|
||||||
fun setUp() {
|
fun setUp() {
|
||||||
mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
|
mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
|
||||||
|
|
||||||
|
mockWebServer = MockWebServer().apply {
|
||||||
|
dispatcher = AndroidAssetDispatcher()
|
||||||
|
start()
|
||||||
|
}
|
||||||
|
|
||||||
|
featureSettingsHelper.setTCPCFREnabled(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
fun tearDown() {
|
||||||
|
mockWebServer.shutdown()
|
||||||
|
featureSettingsHelper.resetAllFeatureFlags()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -129,8 +149,8 @@ class HomeScreenTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun dismissOnboardingUsingHelpTest() {
|
fun dismissOnboardingUsingHelpTest() {
|
||||||
val settings = activityTestRule.activity.applicationContext.settings()
|
featureSettingsHelper.setJumpBackCFREnabled(false)
|
||||||
settings.shouldShowJumpBackInCFR = false
|
|
||||||
homeScreen {
|
homeScreen {
|
||||||
verifyWelcomeHeader()
|
verifyWelcomeHeader()
|
||||||
}.openThreeDotMenu {
|
}.openThreeDotMenu {
|
||||||
|
@ -153,4 +173,47 @@ class HomeScreenTest {
|
||||||
verifyWelcomeHeader()
|
verifyWelcomeHeader()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun verifyPocketHomepageStoriesTest() {
|
||||||
|
featureSettingsHelper.setRecentTabsFeatureEnabled(false)
|
||||||
|
featureSettingsHelper.setRecentlyVisitedFeatureEnabled(false)
|
||||||
|
|
||||||
|
homeScreen {
|
||||||
|
}.dismissOnboarding()
|
||||||
|
|
||||||
|
homeScreen {
|
||||||
|
verifyThoughtProvokingStories(true)
|
||||||
|
verifyStoriesByTopic(true)
|
||||||
|
}.openThreeDotMenu {
|
||||||
|
}.openCustomizeHome {
|
||||||
|
clickPocketButton()
|
||||||
|
}.goBack {
|
||||||
|
verifyThoughtProvokingStories(false)
|
||||||
|
verifyStoriesByTopic(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun verifyCustomizeHomepageTest() {
|
||||||
|
val defaultWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
|
||||||
|
featureSettingsHelper.setJumpBackCFREnabled(false)
|
||||||
|
|
||||||
|
navigationToolbar {
|
||||||
|
}.enterURLAndEnterToBrowser(defaultWebPage.url) {
|
||||||
|
}.goToHomescreen {
|
||||||
|
}.openCustomizeHomepage {
|
||||||
|
clickJumpBackInButton()
|
||||||
|
clickRecentBookmarksButton()
|
||||||
|
clickRecentSearchesButton()
|
||||||
|
clickPocketButton()
|
||||||
|
}.goBack {
|
||||||
|
verifyCustomizeHomepageButton(false)
|
||||||
|
}.openThreeDotMenu {
|
||||||
|
}.openCustomizeHome {
|
||||||
|
clickJumpBackInButton()
|
||||||
|
}.goBack {
|
||||||
|
verifyCustomizeHomepageButton(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -222,6 +222,74 @@ class HomeScreenRobot {
|
||||||
|
|
||||||
fun clickFirefoxLogo() = homepageWordmark.click()
|
fun clickFirefoxLogo() = homepageWordmark.click()
|
||||||
|
|
||||||
|
fun verifyThoughtProvokingStories(enabled: Boolean) {
|
||||||
|
if (enabled) {
|
||||||
|
scrollToElementByText(getStringResource(R.string.pocket_stories_header_1))
|
||||||
|
assertTrue(
|
||||||
|
mDevice.findObject(
|
||||||
|
UiSelector()
|
||||||
|
.textContains(
|
||||||
|
getStringResource(R.string.pocket_stories_header_1)
|
||||||
|
)
|
||||||
|
).waitForExists(waitingTime)
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
homeScreenList().scrollToEnd(LISTS_MAXSWIPES)
|
||||||
|
assertFalse(
|
||||||
|
mDevice.findObject(
|
||||||
|
UiSelector()
|
||||||
|
.textContains(
|
||||||
|
getStringResource(R.string.pocket_stories_header_1)
|
||||||
|
)
|
||||||
|
).waitForExists(waitingTime)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun verifyStoriesByTopic(enabled: Boolean) {
|
||||||
|
if (enabled) {
|
||||||
|
scrollToElementByText(getStringResource(R.string.pocket_stories_categories_header))
|
||||||
|
assertTrue(
|
||||||
|
mDevice.findObject(
|
||||||
|
UiSelector()
|
||||||
|
.textContains(
|
||||||
|
getStringResource(R.string.pocket_stories_categories_header)
|
||||||
|
)
|
||||||
|
).waitForExists(waitingTime)
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
homeScreenList().scrollToEnd(LISTS_MAXSWIPES)
|
||||||
|
assertFalse(
|
||||||
|
mDevice.findObject(
|
||||||
|
UiSelector()
|
||||||
|
.textContains(
|
||||||
|
getStringResource(R.string.pocket_stories_categories_header)
|
||||||
|
)
|
||||||
|
).waitForExists(waitingTime)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun verifyCustomizeHomepageButton(enabled: Boolean) {
|
||||||
|
if (enabled) {
|
||||||
|
scrollToElementByText(getStringResource(R.string.browser_menu_customize_home_1))
|
||||||
|
assertTrue(
|
||||||
|
mDevice.findObject(
|
||||||
|
UiSelector()
|
||||||
|
.textContains("Customize homepage")
|
||||||
|
).waitForExists(waitingTime)
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
homeScreenList().scrollToEnd(LISTS_MAXSWIPES)
|
||||||
|
assertFalse(
|
||||||
|
mDevice.findObject(
|
||||||
|
UiSelector()
|
||||||
|
.textContains("Customize homepage")
|
||||||
|
).waitForExists(waitingTime)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class Transition {
|
class Transition {
|
||||||
|
|
||||||
fun openTabDrawer(interact: TabDrawerRobot.() -> Unit): TabDrawerRobot.Transition {
|
fun openTabDrawer(interact: TabDrawerRobot.() -> Unit): TabDrawerRobot.Transition {
|
||||||
|
@ -416,6 +484,19 @@ class HomeScreenRobot {
|
||||||
HistoryRobot().interact()
|
HistoryRobot().interact()
|
||||||
return HistoryRobot.Transition()
|
return HistoryRobot.Transition()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun openCustomizeHomepage(interact: SettingsSubMenuHomepageRobot.() -> Unit): SettingsSubMenuHomepageRobot.Transition {
|
||||||
|
homeScreenList().scrollToEnd(LISTS_MAXSWIPES)
|
||||||
|
mDevice.findObject(
|
||||||
|
UiSelector()
|
||||||
|
.textContains(
|
||||||
|
"Customize homepage"
|
||||||
|
)
|
||||||
|
).clickAndWaitForNewWindow(waitingTime)
|
||||||
|
|
||||||
|
SettingsSubMenuHomepageRobot().interact()
|
||||||
|
return SettingsSubMenuHomepageRobot.Transition()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,10 @@ class SettingsSubMenuHomepageRobot {
|
||||||
|
|
||||||
fun clickRecentBookmarksButton() = recentBookmarksButton().click()
|
fun clickRecentBookmarksButton() = recentBookmarksButton().click()
|
||||||
|
|
||||||
|
fun clickRecentSearchesButton() = recentSearchesButton().click()
|
||||||
|
|
||||||
|
fun clickPocketButton() = pocketButton().click()
|
||||||
|
|
||||||
fun clickStartOnHomepageButton() = homepageButton().click()
|
fun clickStartOnHomepageButton() = homepageButton().click()
|
||||||
|
|
||||||
fun clickStartOnLastTabButton() = lastTabButton().click()
|
fun clickStartOnLastTabButton() = lastTabButton().click()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user