diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/BookmarksTest.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/BookmarksTest.kt index 6c352d07cd..216562458d 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/BookmarksTest.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/BookmarksTest.kt @@ -340,7 +340,7 @@ class BookmarksTest { } multipleSelectionToolbar { - }.clickOpenNewTab { }.openTabDrawer { + }.clickOpenNewTab { verifyNormalModeSelected() verifyExistingTabList() } @@ -363,7 +363,7 @@ class BookmarksTest { } multipleSelectionToolbar { - }.clickOpenPrivateTab { }.openTabDrawer { + }.clickOpenPrivateTab { verifyPrivateModeSelected() verifyExistingTabList() } diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/HistoryTest.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/HistoryTest.kt index 0538540dcb..30ab196ef8 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/HistoryTest.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/HistoryTest.kt @@ -216,7 +216,7 @@ class HistoryTest { } multipleSelectionToolbar { - }.clickOpenNewTab { }.openTabDrawer { + }.clickOpenNewTab { verifyExistingTabList() verifyNormalModeSelected() } @@ -236,7 +236,7 @@ class HistoryTest { } multipleSelectionToolbar { - }.clickOpenPrivateTab { }.openTabDrawer { + }.clickOpenPrivateTab { verifyPrivateModeSelected() verifyExistingTabList() } diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/LibrarySubMenusMultipleSelectionToolbarRobot.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/LibrarySubMenusMultipleSelectionToolbarRobot.kt index 50fe185221..e12c5242fd 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/LibrarySubMenusMultipleSelectionToolbarRobot.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/LibrarySubMenusMultipleSelectionToolbarRobot.kt @@ -85,23 +85,26 @@ class LibrarySubMenusMultipleSelectionToolbarRobot { return BookmarksRobot.Transition() } - fun clickOpenNewTab(interact: HomeScreenRobot.() -> Unit): HomeScreenRobot.Transition { + fun clickOpenNewTab(interact: TabDrawerRobot.() -> Unit): TabDrawerRobot.Transition { openInNewTabButton().click() - mDevice.waitNotNull(Until.findObject(By.text("Collections")), waitingTime) - - HomeScreenRobot().interact() - return HomeScreenRobot.Transition() - } - - fun clickOpenPrivateTab(interact: HomeScreenRobot.() -> Unit): HomeScreenRobot.Transition { - openInPrivateTabButton().click() mDevice.waitNotNull( - Until.findObject(By.text(PRIVATE_SESSION_MESSAGE)), + Until.findObject(By.res("org.mozilla.fenix.debug:id/tab_layout")), waitingTime ) - HomeScreenRobot().interact() - return HomeScreenRobot.Transition() + TabDrawerRobot().interact() + return TabDrawerRobot.Transition() + } + + fun clickOpenPrivateTab(interact: TabDrawerRobot.() -> Unit): TabDrawerRobot.Transition { + openInPrivateTabButton().click() + mDevice.waitNotNull( + Until.findObject(By.res("org.mozilla.fenix.debug:id/tab_layout")), + waitingTime + ) + + TabDrawerRobot().interact() + return TabDrawerRobot.Transition() } } } diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/TabDrawerRobot.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/TabDrawerRobot.kt index 6af77c3439..5ac8bf2d43 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/TabDrawerRobot.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/TabDrawerRobot.kt @@ -26,6 +26,7 @@ import androidx.test.platform.app.InstrumentationRegistry import androidx.test.uiautomator.By import androidx.test.uiautomator.By.text import androidx.test.uiautomator.UiDevice +import androidx.test.uiautomator.Until import androidx.test.uiautomator.Until.findObject import org.hamcrest.CoreMatchers.allOf import org.mozilla.fenix.R @@ -104,6 +105,20 @@ class TabDrawerRobot { return ThreeDotMenuMainRobot.Transition() } + fun openTabDrawer(interact: TabDrawerRobot.() -> Unit): TabDrawerRobot.Transition { + org.mozilla.fenix.ui.robots.mDevice.waitForIdle() + + tabsCounter().click() + + org.mozilla.fenix.ui.robots.mDevice.waitNotNull( + Until.findObject(By.res("org.mozilla.fenix.debug:id/tab_layout")), + waitingTime + ) + + TabDrawerRobot().interact() + return TabDrawerRobot.Transition() + } + fun openHomeScreen(interact: HomeScreenRobot.() -> Unit): HomeScreenRobot.Transition { mDevice.waitForIdle() @@ -196,3 +211,5 @@ private fun tab(title: String) = withText(title) ) ) + +private fun tabsCounter() = onView(withId(R.id.tab_button)) diff --git a/app/src/main/java/org/mozilla/fenix/library/bookmarks/BookmarkFragment.kt b/app/src/main/java/org/mozilla/fenix/library/bookmarks/BookmarkFragment.kt index eecd9923ec..6507c86689 100644 --- a/app/src/main/java/org/mozilla/fenix/library/bookmarks/BookmarkFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/library/bookmarks/BookmarkFragment.kt @@ -204,14 +204,14 @@ class BookmarkFragment : LibraryPageFragment(), UserInteractionHan R.id.open_bookmarks_in_new_tabs_multi_select -> { openItemsInNewTab { node -> node.url } - navigate(BookmarkFragmentDirections.actionGlobalHome()) + navigate(BookmarkFragmentDirections.actionGlobalTabTrayDialogFragment()) metrics?.track(Event.OpenedBookmarksInNewTabs) true } R.id.open_bookmarks_in_private_tabs_multi_select -> { openItemsInNewTab(private = true) { node -> node.url } - navigate(BookmarkFragmentDirections.actionGlobalHome()) + navigate(BookmarkFragmentDirections.actionGlobalTabTrayDialogFragment()) metrics?.track(Event.OpenedBookmarksInPrivateTabs) true } diff --git a/app/src/main/java/org/mozilla/fenix/library/history/HistoryFragment.kt b/app/src/main/java/org/mozilla/fenix/library/history/HistoryFragment.kt index f5fdd90272..a6796f1d6e 100644 --- a/app/src/main/java/org/mozilla/fenix/library/history/HistoryFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/library/history/HistoryFragment.kt @@ -183,7 +183,7 @@ class HistoryFragment : LibraryPageFragment(), UserInteractionHandl nav( R.id.historyFragment, - HistoryFragmentDirections.actionGlobalHome() + HistoryFragmentDirections.actionGlobalTabTrayDialogFragment() ) true } @@ -199,7 +199,7 @@ class HistoryFragment : LibraryPageFragment(), UserInteractionHandl } nav( R.id.historyFragment, - HistoryFragmentDirections.actionGlobalHome() + HistoryFragmentDirections.actionGlobalTabTrayDialogFragment() ) true }