Commit dfa14881 authored by Yue Zhang's avatar Yue Zhang Committed by Commit Bot

Properly update tab strip for tab selection

Currently, when user uses swipe gesture to switch from a single tab to
a tab in tab group, the tab strip doesn't show up. This is due to this
tab selection doesn't fire a reset tab strip event. This CL fixes this
issue and adds tests.

Bug: 1048824
Change-Id: I05ad51709eb6274afc41f4fc6ddbd8ce396640a4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2037844Reviewed-by: default avatarWei-Yin Chen (陳威尹) <wychen@chromium.org>
Commit-Queue: Yue Zhang <yuezhanggg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#738391}
parent 1b60b248
......@@ -117,7 +117,6 @@ public class TabGroupUiMediator {
mTabModelObserver = new EmptyTabModelObserver() {
@Override
public void didSelectTab(Tab tab, @TabSelectionType int type, int lastId) {
if (!mIsTabGroupUiVisible) return;
if (type == TabSelectionType.FROM_CLOSE) return;
if (getRelatedTabsForId(lastId).contains(tab)) return;
// TODO(995956): Optimization we can do here if we decided always hide the strip if
......
......@@ -335,7 +335,7 @@ public class TabGroupUiMediatorUnitTest {
}
@Test
public void tabSelection_NotSameGroup_SingleTab() {
public void tabSelection_NotSameGroup_GroupToSingleTab() {
initAndAssertProperties(mTab2);
// Mock selecting tab 1, and the last selected tab is tab 2 which is in different group.
......@@ -347,7 +347,7 @@ public class TabGroupUiMediatorUnitTest {
}
@Test
public void tabSelection_NotSameGroup_TabGroup() {
public void tabSelection_NotSameGroup_GroupToGroup() {
initAndAssertProperties(mTab2);
// Mock that tab 1 is not a single tab.
......@@ -363,6 +363,39 @@ public class TabGroupUiMediatorUnitTest {
verifyResetStrip(true, tabs);
}
@Test
public void tabSelection_NotSameGroup_SingleTabToGroup() {
initAndAssertProperties(mTab1);
// Mock that tab 2 is not a single tab.
List<Tab> tabGroup = mTabGroupModelFilter.getRelatedTabList(TAB2_ID);
assertThat(tabGroup.size(), equalTo(2));
// Mock selecting tab 2, and the last selected tab is tab 1 which is a single tab.
mTabModelObserverArgumentCaptor.getValue().didSelectTab(
mTab2, TabSelectionType.FROM_USER, TAB1_ID);
// Strip should be showing since we are selecting a group.
verifyResetStrip(true, tabGroup);
}
@Test
public void tabSelection_NotSameGroup_SingleTabToSingleTab() {
initAndAssertProperties(mTab1);
// Mock that new tab is a single tab.
TabImpl newTab = prepareTab(TAB4_ID, TAB4_ID);
List<Tab> tabs = new ArrayList<>(Arrays.asList(newTab));
doReturn(tabs).when(mTabGroupModelFilter).getRelatedTabList(TAB4_ID);
// Mock selecting new tab, and the last selected tab is tab 1 which is also a single tab.
mTabModelObserverArgumentCaptor.getValue().didSelectTab(
newTab, TabSelectionType.FROM_USER, TAB1_ID);
// Strip should not be showing since new tab is a single tab.
verifyResetStrip(false, null);
}
@Test
public void tabSelection_SameGroup_TabGroup() {
initAndAssertProperties(mTab2);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment