Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Commit

Permalink
For #21611: Show the jump back in Contextual Hints independently of t…
Browse files Browse the repository at this point in the history
…he home onboarding dialog.

(cherry picked from commit 0f07703)
  • Loading branch information
Amejia481 authored and mergify-bot committed Oct 6, 2021
1 parent 0ccec3c commit d79aedc
Show file tree
Hide file tree
Showing 20 changed files with 144 additions and 98 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ class BookmarksTest {
dispatcher = AndroidAssetDispatcher()
start()
}
val settings = activityTestRule.activity.settings()
settings.shouldShowJumpBackInCFR = false
}

@After
Expand Down Expand Up @@ -346,7 +348,7 @@ class BookmarksTest {
@Test
fun openSelectionInNewTabTest() {
val settings = activityTestRule.activity.applicationContext.settings()
settings.hasShownHomeOnboardingDialog = true
settings.shouldShowJumpBackInCFR = false
val defaultWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)

browserScreen {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class CollectionTest {

@Before
fun setUp() {
activityTestRule.activity.applicationContext.settings().hasShownHomeOnboardingDialog = true
activityTestRule.activity.applicationContext.settings().shouldShowJumpBackInCFR = false

mockWebServer = MockWebServer().apply {
dispatcher = AndroidAssetDispatcher()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class HistoryTest {
@Before
fun setUp() {
InstrumentationRegistry.getInstrumentation().targetContext.settings()
.hasShownHomeOnboardingDialog = true
.shouldShowJumpBackInCFR = false

mockWebServer = MockWebServer().apply {
dispatcher = AndroidAssetDispatcher()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class HomeScreenTest {
@Test
fun dismissOnboardingUsingHelpTest() {
val settings = activityTestRule.activity.applicationContext.settings()
settings.hasShownHomeOnboardingDialog = true
settings.shouldShowJumpBackInCFR = false
homeScreen {
verifyWelcomeHeader()
}.openThreeDotMenu {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import org.junit.Before
import org.junit.Ignore
import org.junit.Rule
import org.junit.Test
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.helpers.AndroidAssetDispatcher
import org.mozilla.fenix.helpers.HomeActivityTestRule
import org.mozilla.fenix.helpers.TestAssetHelper
Expand Down Expand Up @@ -41,6 +42,8 @@ class NavigationToolbarTest {
dispatcher = AndroidAssetDispatcher()
start()
}
val settings = activityTestRule.activity.settings()
settings.shouldShowJumpBackInCFR = false
}

@After
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class NoNetworkAccessStartupTests {
fun networkInterruptedFromBrowserToHomeTest() {
val url = "example.com"
val settings = InstrumentationRegistry.getInstrumentation().targetContext.settings()
settings.hasShownHomeOnboardingDialog = true
settings.shouldShowJumpBackInCFR = false

activityTestRule.launchActivity(null)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class SettingsAboutTest {
@Test
fun verifyAboutFirefoxPreview() {
val settings = activityIntentTestRule.activity.settings()
settings.hasShownHomeOnboardingDialog = true
settings.shouldShowJumpBackInCFR = false
homeScreen {
}.openThreeDotMenu {
}.openSettings {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ class SettingsBasicsTest {
dispatcher = AndroidAssetDispatcher()
start()
}
val settings = activityIntentTestRule.activity.settings()
settings.shouldShowJumpBackInCFR = false
}

@After
Expand Down Expand Up @@ -157,7 +159,7 @@ class SettingsBasicsTest {
val fenixApp = activityIntentTestRule.activity.applicationContext as FenixApplication
val webpage = getLoremIpsumAsset(mockWebServer).url
val settings = fenixApp.applicationContext.settings()
settings.hasShownHomeOnboardingDialog = true
settings.shouldShowJumpBackInCFR = false

// This value will represent the text size percentage the webpage will scale to. The default value is 100%.
val textSizePercentage = 180
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class SettingsPrivacyTest {
}

val settings = activityTestRule.activity.applicationContext.settings()
settings.hasShownHomeOnboardingDialog = true
settings.shouldShowJumpBackInCFR = false
}

@After
Expand Down Expand Up @@ -223,7 +223,7 @@ class SettingsPrivacyTest {
fun neverSaveLoginFromPromptTest() {
val saveLoginTest = TestAssetHelper.getSaveLoginAsset(mockWebServer)
val settings = activityTestRule.activity.settings()
settings.hasShownHomeOnboardingDialog = true
settings.shouldShowJumpBackInCFR = false

navigationToolbar {
}.enterURLAndEnterToBrowser(saveLoginTest.url) {
Expand Down Expand Up @@ -330,7 +330,7 @@ class SettingsPrivacyTest {
@Test
fun launchLinksInPrivateToggleOffStateDoesntChangeTest() {
val settings = activityTestRule.activity.applicationContext.settings()
settings.hasShownHomeOnboardingDialog = true
settings.shouldShowJumpBackInCFR = false
val defaultWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)

setOpenLinksInPrivateOn()
Expand Down
18 changes: 9 additions & 9 deletions app/src/androidTest/java/org/mozilla/fenix/ui/SmokeTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class SmokeTest {
// So we are initializing this here instead of in all related tests.
browserStore = activityTestRule.activity.components.core.store

activityTestRule.activity.applicationContext.settings().hasShownHomeOnboardingDialog = true
activityTestRule.activity.applicationContext.settings().shouldShowJumpBackInCFR = false
mockWebServer = MockWebServer().apply {
dispatcher = AndroidAssetDispatcher()
start()
Expand Down Expand Up @@ -312,7 +312,7 @@ class SmokeTest {
// Verifies the Add to top sites option in a tab's 3 dot menu
fun openMainMenuAddTopSiteTest() {
val settings = activityTestRule.activity.applicationContext.settings()
settings.hasShownHomeOnboardingDialog = true
settings.shouldShowJumpBackInCFR = false

val defaultWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)

Expand Down Expand Up @@ -824,7 +824,7 @@ class SmokeTest {
@Ignore("https://github.com/mozilla-mobile/fenix/issues/21397")
fun createFirstCollectionTest() {
val settings = activityTestRule.activity.applicationContext.settings()
settings.hasShownHomeOnboardingDialog = true
settings.shouldShowJumpBackInCFR = false
val firstWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
val secondWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 2)

Expand Down Expand Up @@ -858,7 +858,7 @@ class SmokeTest {
@Ignore("https://github.com/mozilla-mobile/fenix/issues/21397")
fun verifyExpandedCollectionItemsTest() {
val settings = activityTestRule.activity.applicationContext.settings()
settings.hasShownHomeOnboardingDialog = true
settings.shouldShowJumpBackInCFR = false
val webPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)

navigationToolbar {
Expand Down Expand Up @@ -912,7 +912,7 @@ class SmokeTest {
@Test
fun shareCollectionTest() {
val settings = activityTestRule.activity.applicationContext.settings()
settings.hasShownHomeOnboardingDialog = true
settings.shouldShowJumpBackInCFR = false

val webPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)

Expand All @@ -938,7 +938,7 @@ class SmokeTest {
// caution when making changes to it, so they don't block the builds
fun deleteCollectionTest() {
val settings = activityTestRule.activity.applicationContext.settings()
settings.hasShownHomeOnboardingDialog = true
settings.shouldShowJumpBackInCFR = false
val webPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)

navigationToolbar {
Expand Down Expand Up @@ -1357,7 +1357,7 @@ class SmokeTest {
@Test
fun goToHomeScreenBottomToolbarTest() {
val settings = activityTestRule.activity.applicationContext.settings()
settings.hasShownHomeOnboardingDialog = true
settings.shouldShowJumpBackInCFR = false
val genericURL = TestAssetHelper.getGenericAsset(mockWebServer, 1)

navigationToolbar {
Expand All @@ -1371,7 +1371,7 @@ class SmokeTest {
@Test
fun goToHomeScreenTopToolbarTest() {
val settings = activityTestRule.activity.applicationContext.settings()
settings.hasShownHomeOnboardingDialog = true
settings.shouldShowJumpBackInCFR = false

val genericURL = TestAssetHelper.getGenericAsset(mockWebServer, 1)

Expand Down Expand Up @@ -1441,7 +1441,7 @@ class SmokeTest {
@Test
fun alwaysStartOnHomeTest() {
val settings = activityTestRule.activity.applicationContext.settings()
settings.hasShownHomeOnboardingDialog = true
settings.shouldShowJumpBackInCFR = false
val genericURL = TestAssetHelper.getGenericAsset(mockWebServer, 1)

navigationToolbar {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ class StrictEnhancedTrackingProtectionTest {
start()
}

activityTestRule.activity.settings().setStrictETP()
val settings = activityTestRule.activity.settings()
settings.setStrictETP()
settings.shouldShowJumpBackInCFR = false
}

@After
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,11 @@ class TabbedBrowsingTest {

@Before
fun setUp() {
activityTestRule.activity.applicationContext.settings().hasShownHomeOnboardingDialog = true
activityTestRule.activity.applicationContext.settings().shouldShowJumpBackInCFR = false
mockWebServer = MockWebServer().apply {
dispatcher = AndroidAssetDispatcher()
start()
}

val settings = activityTestRule.activity.applicationContext.settings()
settings.hasShownHomeOnboardingDialog = true
}

@After
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class ThreeDotMenuMainTest {

@Before
fun setUp() {
activityTestRule.activity.applicationContext.settings().hasShownHomeOnboardingDialog = true
activityTestRule.activity.applicationContext.settings().shouldShowJumpBackInCFR = false
mockWebServer = MockWebServer().apply {
dispatcher = AndroidAssetDispatcher()
start()
Expand Down
10 changes: 5 additions & 5 deletions app/src/androidTest/java/org/mozilla/fenix/ui/TopSitesTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class TopSitesTest {
@Test
fun verifyAddToFirefoxHome() {
val settings = activityIntentTestRule.activity.applicationContext.settings()
settings.hasShownHomeOnboardingDialog = true
settings.shouldShowJumpBackInCFR = false
val defaultWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
val defaultWebPageTitle = "Test_Page_1"

Expand All @@ -70,7 +70,7 @@ class TopSitesTest {
@Test
fun verifyOpenTopSiteNormalTab() {
val settings = activityIntentTestRule.activity.applicationContext.settings()
settings.hasShownHomeOnboardingDialog = true
settings.shouldShowJumpBackInCFR = false
val defaultWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
val defaultWebPageTitle = "Test_Page_1"

Expand Down Expand Up @@ -100,7 +100,7 @@ class TopSitesTest {
@Test
fun verifyOpenTopSitePrivateTab() {
val settings = activityIntentTestRule.activity.applicationContext.settings()
settings.hasShownHomeOnboardingDialog = true
settings.shouldShowJumpBackInCFR = false
val defaultWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
val defaultWebPageTitle = "Test_Page_1"

Expand All @@ -124,7 +124,7 @@ class TopSitesTest {
@Test
fun verifyRenameTopSite() {
val settings = activityIntentTestRule.activity.applicationContext.settings()
settings.hasShownHomeOnboardingDialog = true
settings.shouldShowJumpBackInCFR = false
val defaultWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
val defaultWebPageTitle = "Test_Page_1"
val defaultWebPageTitleNew = "Test_Page_2"
Expand All @@ -150,7 +150,7 @@ class TopSitesTest {
@Test
fun verifyRemoveTopSite() {
val settings = activityIntentTestRule.activity.applicationContext.settings()
settings.hasShownHomeOnboardingDialog = true
settings.shouldShowJumpBackInCFR = false
val defaultWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
val defaultWebPageTitle = "Test_Page_1"

Expand Down
2 changes: 1 addition & 1 deletion app/src/debug/res/raw/initial_experiments.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"value": {
"sections-enabled": {
"topSites": true,
"recentExplorations": false,
"recentExplorations": true,
"recentlySaved": false,
"jumpBackIn": false,
"pocket": false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import org.mozilla.fenix.home.HomeScreenViewModel
import org.mozilla.fenix.home.Mode
import org.mozilla.fenix.home.OnboardingState
import org.mozilla.fenix.home.recenttabs.RecentTab
import org.mozilla.fenix.onboarding.JumpBackInCFRDialog
import org.mozilla.fenix.utils.Settings

// This method got a little complex with the addition of the tab tray feature flag
Expand Down Expand Up @@ -197,7 +198,13 @@ class SessionControlView(
init {
view.apply {
adapter = sessionControlAdapter
layoutManager = LinearLayoutManager(containerView.context)
layoutManager = object : LinearLayoutManager(containerView.context) {
override fun onLayoutCompleted(state: RecyclerView.State?) {
super.onLayoutCompleted(state)

JumpBackInCFRDialog(view).showIfNeeded()
}
}
val itemTouchHelper =
ItemTouchHelper(
SwipeToDeleteCallback(
Expand Down
Loading

0 comments on commit d79aedc

Please sign in to comment.