Skip to content

Commit

Permalink
Tab swiping: Integration of the new tab management (#5322)
Browse files Browse the repository at this point in the history
Task/Issue URL:
https://app.asana.com/0/72649045549333/1208648123066962/f

### Description

This PR includes the complete implementation of the tab-swiping
functionality.

### Steps to test this PR

**Make sure you’ve completed the onboarding!**

#### New tab from long press
- [x] Long press on a tabs button
- [x] Verify a new tab is opened

#### New tab from the menu
- [x] Tap on the New tab menu item
- [x] Verify a new tab is opened

#### New tab from tab switcher
- [x] Go to tab switcher
- [x] Tap on the New tab button
- [x] Verify a new tab is opened

#### New tab recreation
- [x] Open a few tabs
- [x] Go to the tab switcher
- [x] Add a new tab
- [x] Verify a new tab is correctly displayed
- [x] Go back to the tab switcher
- [x] Close the NTP
- [x] Tap on the new tab button
- [x] Verify the new tab is correctly opened

#### Swiping position
- [x] Open at least 3 tabs
- [x] Select the 1st one in the tab switcher
- [x] Swipe to the last one
- [x] Go to tab switcher and verify the correct tab is selected
- [x] Tap on the 2nd tab
- [x] Verify the correct tab is opened

#### New link
- [x] Open any website
- [x] Long press on a link to open in new tab
- [x] Verify the link is opened in a new tab

#### New link in the background
- [x] Open any website
- [x] Long press on a link to open in background tab
- [x] Verify the link is opened in a new tab in the background

#### New link in the background
- [x] Make sure the DDG app is the default browser app
- [x] Open an app that can open links in custom tabs (i.e. Twitter,
Facebook)
- [x] Open a link in a custom tab
- [x] Verify the link opens correctly
- [x] Move the tab to the app
- [x] Verify the tab is correctly displayed within the app

#### Switch to tab
- [x] Start typing a site address that’s already opened in another tab
- [x] Tap on the “Switch to tab” item
- [x] Verify the existing tab with the link is shown instead of opening
a new tab

#### Changing the omnibar position
- [x] Open a few tabs
- [x] Go to settings and change the omnibar position
- [x] The app will reload (the cached sites are cleared)
- [x] Swipe through the tabs and verify the load correctly

#### Bookmarks
- [x] Load a site
- [x] Add it to the boorkmarks
- [x] Open a different tab
- [x] Go to Bookmarks and select the saved boormark
- [x] Verify the bookmark loads correctly

#### Default site
- [x] Set some default URL in Settings -> General -> Show on App Launch
- [x] Kill the app and relaunch it
- [x] Verify the default site is correctly loaded in a new tab
- [x] Kill the app and relaunch it
- [x] Verify the default site is loaded in the same tab as before (no
new tab is added)
  • Loading branch information
0nko authored Dec 20, 2024
1 parent 0f06a07 commit 2ee109f
Show file tree
Hide file tree
Showing 27 changed files with 2,019 additions and 355 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -503,10 +503,15 @@ class BrowserTabViewModelTest {
private val extendedOnboardingFeatureToggles = FeatureToggles.Builder(FakeToggleStore(), featureName = "extendedOnboarding").build()
.create(ExtendedOnboardingFeatureToggles::class.java)
private val extendedOnboardingPixelsPlugin = ExtendedOnboardingPixelsPlugin(extendedOnboardingFeatureToggles)
private val swipingTabsFeature = FakeFeatureToggleFactory.create(SwipingTabsFeature::class.java)
private val swipingTabsFeatureProvider = SwipingTabsFeatureProvider(swipingTabsFeature)

@Before
fun before() = runTest {
MockitoAnnotations.openMocks(this)

swipingTabsFeature.self().setRawStoredState(State(enable = true))

db = Room.inMemoryDatabaseBuilder(context, AppDatabase::class.java)
.allowMainThreadQueries()
.build()
Expand Down Expand Up @@ -675,6 +680,7 @@ class BrowserTabViewModelTest {
toggleReports = mockToggleReports,
brokenSitePrompt = mockBrokenSitePrompt,
tabStatsBucketing = mockTabStatsBucketing,
swipingTabsFeature = swipingTabsFeatureProvider,
)

testee.loadData("abc", null, false, false)
Expand Down Expand Up @@ -2445,14 +2451,29 @@ class BrowserTabViewModelTest {
}

@Test
fun whenUserRequestedToOpenNewTabThenNewTabCommandIssued() {
fun whenUserRequestedToOpenNewTabAndNoEmptyTabExistsThenNewTabCommandIssued() {
tabsLiveData.value = listOf(TabEntity("1", "https://example.com", position = 0))
testee.userRequestedOpeningNewTab()
verify(mockCommandObserver, atLeastOnce()).onChanged(commandCaptor.capture())
val command = commandCaptor.lastValue
assertTrue(command is Command.LaunchNewTab)
verify(mockPixel, never()).fire(AppPixelName.TAB_MANAGER_NEW_TAB_LONG_PRESSED)
}

@Test
fun whenUserRequestedToOpenNewTabAndEmptyTabExistsThenSelectTheEmptyTab() = runTest {
val emptyTabId = "EMPTY_TAB"
tabsLiveData.value = listOf(TabEntity(emptyTabId))
testee.userRequestedOpeningNewTab()

verify(mockCommandObserver, atLeastOnce()).onChanged(commandCaptor.capture())
val command = commandCaptor.lastValue
assertFalse(command is Command.LaunchNewTab)

verify(mockTabRepository).select(emptyTabId)
verify(mockPixel, never()).fire(AppPixelName.TAB_MANAGER_NEW_TAB_LONG_PRESSED)
}

@Test
fun whenUserRequestedToOpenNewTabByLongPressThenPixelFired() {
testee.userRequestedOpeningNewTab(longPress = true)
Expand Down
Loading

0 comments on commit 2ee109f

Please sign in to comment.