Skip to content

Commit

Permalink
[116][Fixit][Tablet] Show tab switcher if no regular tab when toggle …
Browse files Browse the repository at this point in the history
…incognito

(cherry picked from commit e0b9d5b)

Bug: 1458710
Change-Id: Ie9fe078a0941f49375d835ff232826a4c5b54420
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4654995
Reviewed-by: Matthew Jones <mdjones@chromium.org>
Reviewed-by: Neil Coronado <nemco@google.com>
Code-Coverage: Findit <findit-for-me@appspot.gserviceaccount.com>
Commit-Queue: Mei Liang <meiliang@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#1164227}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4667874
Reviewed-by: Theresa Sullivan <twellington@chromium.org>
Cr-Commit-Position: refs/branch-heads/5845@{#329}
Cr-Branched-From: 5a5dff6-refs/heads/main@{#1160321}
  • Loading branch information
Mei Liang authored and Chromium LUCI CQ committed Jul 5, 2023
1 parent a7a8128 commit 3c00bec
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,33 @@ public void testGridTabSwitcherOnCloseAllTabs() throws ExecutionException {
.check(matches(withEffectiveVisibility(VISIBLE)));
}

@Test
@MediumTest
public void testGridTabSwitcherToggleIncognitoWithNoRegularTab() throws ExecutionException {
// Close all the regular tabs.
TestThreadUtils.runOnUiThreadBlocking(() -> {
sActivityTestRule.getActivity().getCurrentTabModel().closeTab(
sActivityTestRule.getActivity().getActivityTab());
});
assertEquals("Expected to be 0 tabs in regular model", 0,
sActivityTestRule.getActivity()
.getTabModelSelectorSupplier()
.get()
.getModel(false)
.getCount());
// Open an incognito tab.
prepareTabs(0, 1);
assertTrue("Expected to be in Incognito model",
sActivityTestRule.getActivity().getCurrentTabModel().isIncognito());
// Assert the grid tab switcher is not yet showing.
onView(withId(R.id.tab_switcher_view_holder)).check(matches(withEffectiveVisibility(GONE)));
// Toggle to normal switcher.
clickIncognitoToggleButton();
// Assert the grid tab switcher is shown automatically, since there is no regular tab.
onView(withId(R.id.tab_switcher_view_holder))
.check(matches(withEffectiveVisibility(VISIBLE)));
}

@Test
@MediumTest
@EnableFeatures({ChromeFeatureList.START_SURFACE_REFACTOR})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ public void onTabsAllClosing(boolean incognito) {
protected void tabModelSwitched(boolean incognito) {
super.tabModelSwitched(incognito);
getTabModelSelector().commitAllTabClosures();
if (getActiveLayout() == mStaticLayout && !incognito
&& getTabModelSelector().getModel(false).getCount() == 0) {
showLayout(LayoutType.TAB_SWITCHER, /*animate=*/false);
}
}

@Override
Expand Down

0 comments on commit 3c00bec

Please sign in to comment.