Commit 840efdd2 authored by gogerald's avatar gogerald Committed by Commit Bot

[StartSurface] Sort Tabs in descending order of the last shown time

The tabs are ordered from the most recent to the least recent ones
in the tab grid and carousel in start surfaces.

Bug: 982018
Change-Id: I974c492555751c5f2d7eebe8c6d871d05a41fb22
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1746907Reviewed-by: default avatarWei-Yin Chen (陳威尹) <wychen@chromium.org>
Commit-Queue: Ganggui Tang <gogerald@chromium.org>
Auto-Submit: Ganggui Tang <gogerald@chromium.org>
Cr-Commit-Position: refs/heads/master@{#688515}
parent 47d432e7
...@@ -190,7 +190,8 @@ public class TabGridDialogMediator { ...@@ -190,7 +190,8 @@ public class TabGridDialogMediator {
private void updateGridTabSwitcher() { private void updateGridTabSwitcher() {
if (!isVisible() || mTabSwitcherResetHandler == null) return; if (!isVisible() || mTabSwitcherResetHandler == null) return;
mTabSwitcherResetHandler.resetWithTabList( mTabSwitcherResetHandler.resetWithTabList(
mTabModelSelector.getTabModelFilterProvider().getCurrentTabModelFilter(), false); mTabModelSelector.getTabModelFilterProvider().getCurrentTabModelFilter(), false,
false);
} }
private void updateDialog() { private void updateDialog() {
......
...@@ -229,18 +229,18 @@ public class TabListCoordinator implements Destroyable { ...@@ -229,18 +229,18 @@ public class TabListCoordinator implements Destroyable {
} }
/** /**
* @see TabListMediator#resetWithListOfTabs(List, boolean) * @see TabListMediator#resetWithListOfTabs(List, boolean, boolean)
*/ */
boolean resetWithListOfTabs(@Nullable List<Tab> tabs, boolean quickMode) { boolean resetWithListOfTabs(@Nullable List<Tab> tabs, boolean quickMode, boolean mruMode) {
if (mMode == TabListMode.STRIP && tabs != null && tabs.size() > 1) { if (mMode == TabListMode.STRIP && tabs != null && tabs.size() > 1) {
TabGroupUtils.maybeShowIPH( TabGroupUtils.maybeShowIPH(
FeatureConstants.TAB_GROUPS_TAP_TO_SEE_ANOTHER_TAB_FEATURE, mRecyclerView); FeatureConstants.TAB_GROUPS_TAP_TO_SEE_ANOTHER_TAB_FEATURE, mRecyclerView);
} }
return mMediator.resetWithListOfTabs(tabs, quickMode); return mMediator.resetWithListOfTabs(tabs, quickMode, mruMode);
} }
boolean resetWithListOfTabs(@Nullable List<Tab> tabs) { boolean resetWithListOfTabs(@Nullable List<Tab> tabs) {
return resetWithListOfTabs(tabs, false); return resetWithListOfTabs(tabs, false, false);
} }
void softCleanup() { void softCleanup() {
......
...@@ -51,6 +51,8 @@ import org.chromium.ui.modelutil.PropertyModel; ...@@ -51,6 +51,8 @@ import org.chromium.ui.modelutil.PropertyModel;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -62,6 +64,10 @@ import java.util.Map; ...@@ -62,6 +64,10 @@ import java.util.Map;
* TODO(yusufo): Move some of the logic here to a parent component to make the above true. * TODO(yusufo): Move some of the logic here to a parent component to make the above true.
*/ */
class TabListMediator { class TabListMediator {
// Comparator to sort Tabs in descending order of the last shown time.
private static final Comparator<Tab> LAST_SHOWN_COMPARATOR =
(a, b) -> (Long.compare(b.getTimestampMillis(), a.getTimestampMillis()));
private boolean mVisible; private boolean mVisible;
private boolean mShownIPH; private boolean mShownIPH;
...@@ -742,30 +748,38 @@ class TabListMediator { ...@@ -742,30 +748,38 @@ class TabListMediator {
* Initialize the component with a list of tabs to show in a grid. * Initialize the component with a list of tabs to show in a grid.
* @param tabs The list of tabs to be shown. * @param tabs The list of tabs to be shown.
* @param quickMode Whether to skip capturing the selected live tab for the thumbnail. * @param quickMode Whether to skip capturing the selected live tab for the thumbnail.
* @param mruMode Whether to sort the Tabs in MRU order.
* @return Whether the {@link TabListRecyclerView} can be shown quickly. * @return Whether the {@link TabListRecyclerView} can be shown quickly.
*/ */
boolean resetWithListOfTabs(@Nullable List<Tab> tabs, boolean quickMode) { boolean resetWithListOfTabs(@Nullable List<Tab> tabs, boolean quickMode, boolean mruMode) {
mVisible = tabs != null; List<Tab> tabsList = tabs;
if (areTabsUnchanged(tabs)) { if (tabs != null && mruMode) {
if (tabs == null) return true; // Make a copy to sort since the input may be unmodifiable.
tabsList = new ArrayList<>(tabs);
Collections.sort(tabsList, LAST_SHOWN_COMPARATOR);
}
for (int i = 0; i < tabs.size(); i++) { mVisible = tabsList != null;
Tab tab = tabs.get(i); if (areTabsUnchanged(tabsList)) {
if (tabsList == null) return true;
for (int i = 0; i < tabsList.size(); i++) {
Tab tab = tabsList.get(i);
boolean isSelected = mTabModelSelector.getCurrentTab() == tab; boolean isSelected = mTabModelSelector.getCurrentTab() == tab;
updateTab(i, tab, isSelected, false, quickMode); updateTab(i, tab, isSelected, false, quickMode);
} }
return true; return true;
} }
mModel.set(new ArrayList<>()); mModel.set(new ArrayList<>());
if (tabs == null) { if (tabsList == null) {
return true; return true;
} }
Tab currentTab = mTabModelSelector.getCurrentTab(); Tab currentTab = mTabModelSelector.getCurrentTab();
if (currentTab == null) return false; if (currentTab == null) return false;
for (int i = 0; i < tabs.size(); i++) { for (int i = 0; i < tabsList.size(); i++) {
addTabInfoToModel( addTabInfoToModel(
tabs.get(i), i, isSelectedTab(tabs.get(i).getId(), currentTab.getId())); tabsList.get(i), i, isSelectedTab(tabsList.get(i).getId(), currentTab.getId()));
} }
return false; return false;
} }
...@@ -976,13 +990,11 @@ class TabListMediator { ...@@ -976,13 +990,11 @@ class TabListMediator {
return mTabModelSelector.getCurrentTabId(); return mTabModelSelector.getCurrentTabId();
} }
// Find the index of the currently selected tab in the TabListRecyclerView.
// Note that Tabs may have different index in TabListModel/TabListRecyclerView and
// mTabModelSelector, like when resetWithListOfTabs is called with 'mruMode = true'.
int indexOfSelected() { int indexOfSelected() {
Tab nextTab = TabModelUtils.getTabById(mTabModelSelector.getCurrentModel(), mNextTabId); return mModel.indexFromId(selectedTabId());
if (nextTab != null) {
return getIndexOfTab(nextTab, !mActionsOnAllRelatedTabs);
}
return mTabModelSelector.getTabModelFilterProvider().getCurrentTabModelFilter().index();
} }
@VisibleForTesting @VisibleForTesting
......
...@@ -215,7 +215,7 @@ public class TabSwitcherCoordinator implements Destroyable, TabSwitcher, ...@@ -215,7 +215,7 @@ public class TabSwitcherCoordinator implements Destroyable, TabSwitcher,
// ResetHandler implementation. // ResetHandler implementation.
@Override @Override
public boolean resetWithTabList(@Nullable TabList tabList, boolean quickMode) { public boolean resetWithTabList(@Nullable TabList tabList, boolean quickMode, boolean mruMode) {
List<Tab> tabs = null; List<Tab> tabs = null;
if (tabList != null) { if (tabList != null) {
tabs = new ArrayList<>(); tabs = new ArrayList<>();
...@@ -223,7 +223,8 @@ public class TabSwitcherCoordinator implements Destroyable, TabSwitcher, ...@@ -223,7 +223,8 @@ public class TabSwitcherCoordinator implements Destroyable, TabSwitcher,
tabs.add(tabList.getTabAt(i)); tabs.add(tabList.getTabAt(i));
} }
} }
return mTabListCoordinator.resetWithListOfTabs(tabs, quickMode);
return mTabListCoordinator.resetWithListOfTabs(tabs, quickMode, mruMode);
} }
private Rect getTabGridCardPosition(int index) { private Rect getTabGridCardPosition(int index) {
......
...@@ -122,6 +122,8 @@ class TabSwitcherMediator implements TabSwitcher.Controller, TabListRecyclerView ...@@ -122,6 +122,8 @@ class TabSwitcherMediator implements TabSwitcher.Controller, TabListRecyclerView
private int mTabIdwhenShown; private int mTabIdwhenShown;
private int mIndexInNewModelWhenSwitched; private int mIndexInNewModelWhenSwitched;
private boolean mShowTabsInMruOrder;
/** /**
* Interface to delegate resetting the tab grid. * Interface to delegate resetting the tab grid.
*/ */
...@@ -130,9 +132,10 @@ class TabSwitcherMediator implements TabSwitcher.Controller, TabListRecyclerView ...@@ -130,9 +132,10 @@ class TabSwitcherMediator implements TabSwitcher.Controller, TabListRecyclerView
* Reset the tab grid with the given {@link TabList}, which can be null. * Reset the tab grid with the given {@link TabList}, which can be null.
* @param tabList The {@link TabList} to show the tabs for in the grid. * @param tabList The {@link TabList} to show the tabs for in the grid.
* @param quickMode Whether to skip capturing the selected live tab for the thumbnail. * @param quickMode Whether to skip capturing the selected live tab for the thumbnail.
* @param mruMode Whether order the Tabs by MRU.
* @return Whether the {@link TabListRecyclerView} can be shown quickly. * @return Whether the {@link TabListRecyclerView} can be shown quickly.
*/ */
boolean resetWithTabList(@Nullable TabList tabList, boolean quickMode); boolean resetWithTabList(@Nullable TabList tabList, boolean quickMode, boolean mruMode);
/** /**
* Release the thumbnail {@link Bitmap} but keep the {@link TabGridViewHolder}. * Release the thumbnail {@link Bitmap} but keep the {@link TabGridViewHolder}.
...@@ -175,7 +178,7 @@ class TabSwitcherMediator implements TabSwitcher.Controller, TabListRecyclerView ...@@ -175,7 +178,7 @@ class TabSwitcherMediator implements TabSwitcher.Controller, TabListRecyclerView
TabList currentTabModelFilter = TabList currentTabModelFilter =
mTabModelSelector.getTabModelFilterProvider().getCurrentTabModelFilter(); mTabModelSelector.getTabModelFilterProvider().getCurrentTabModelFilter();
mResetHandler.resetWithTabList(currentTabModelFilter, false); mResetHandler.resetWithTabList(currentTabModelFilter, false, mShowTabsInMruOrder);
mContainerViewModel.set(IS_INCOGNITO, currentTabModelFilter.isIncognito()); mContainerViewModel.set(IS_INCOGNITO, currentTabModelFilter.isIncognito());
if (mTabGridDialogResetHandler != null) { if (mTabGridDialogResetHandler != null) {
mTabGridDialogResetHandler.hideDialog(false); mTabGridDialogResetHandler.hideDialog(false);
...@@ -243,9 +246,16 @@ class TabSwitcherMediator implements TabSwitcher.Controller, TabListRecyclerView ...@@ -243,9 +246,16 @@ class TabSwitcherMediator implements TabSwitcher.Controller, TabListRecyclerView
mContainerView = containerView; mContainerView = containerView;
mSoftClearTabListRunnable = mResetHandler::softCleanup; mSoftClearTabListRunnable = mResetHandler::softCleanup;
mClearTabListRunnable = () -> mResetHandler.resetWithTabList(null, false); mClearTabListRunnable =
() -> mResetHandler.resetWithTabList(null, false, mShowTabsInMruOrder);
mHandler = new Handler(); mHandler = new Handler();
mTabSelectionEditorController = tabSelectionEditorController; mTabSelectionEditorController = tabSelectionEditorController;
// TODO(crbug.com/982018): Let the start surface pass in the parameter and add unit test for
// it. This is a temporary solution to keep this change minimum.
String feature = ChromeFeatureList.getFieldTrialParamByFeature(
ChromeFeatureList.START_SURFACE_ANDROID, "start_surface_variation");
mShowTabsInMruOrder = feature.equals("twopanes") || feature.equals("single");
} }
void setBottomControlsHeight(int bottomControlsHeight) { void setBottomControlsHeight(int bottomControlsHeight) {
...@@ -388,13 +398,16 @@ class TabSwitcherMediator implements TabSwitcher.Controller, TabListRecyclerView ...@@ -388,13 +398,16 @@ class TabSwitcherMediator implements TabSwitcher.Controller, TabListRecyclerView
boolean quick = false; boolean quick = false;
if (FeatureUtilities.isTabToGtsAnimationEnabled()) { if (FeatureUtilities.isTabToGtsAnimationEnabled()) {
quick = mResetHandler.resetWithTabList( quick = mResetHandler.resetWithTabList(
mTabModelSelector.getTabModelFilterProvider().getCurrentTabModelFilter(), mTabModelSelector.getTabModelFilterProvider().getCurrentTabModelFilter(), false,
false); mShowTabsInMruOrder);
} }
int initialPosition = Math.max( int initialPosition = Math.max(
mTabModelSelector.getTabModelFilterProvider().getCurrentTabModelFilter().index() mTabModelSelector.getTabModelFilterProvider().getCurrentTabModelFilter().index()
- INITIAL_SCROLL_INDEX_OFFSET, - INITIAL_SCROLL_INDEX_OFFSET,
0); 0);
// In MRU order, selected Tab is always at the first position.
if (mShowTabsInMruOrder) initialPosition = 0;
mContainerViewModel.set(INITIAL_SCROLL_INDEX, initialPosition); mContainerViewModel.set(INITIAL_SCROLL_INDEX, initialPosition);
return quick; return quick;
} }
...@@ -403,7 +416,7 @@ class TabSwitcherMediator implements TabSwitcher.Controller, TabListRecyclerView ...@@ -403,7 +416,7 @@ class TabSwitcherMediator implements TabSwitcher.Controller, TabListRecyclerView
public void showOverview(boolean animate) { public void showOverview(boolean animate) {
mResetHandler.resetWithTabList( mResetHandler.resetWithTabList(
mTabModelSelector.getTabModelFilterProvider().getCurrentTabModelFilter(), mTabModelSelector.getTabModelFilterProvider().getCurrentTabModelFilter(),
FeatureUtilities.isTabToGtsAnimationEnabled()); FeatureUtilities.isTabToGtsAnimationEnabled(), mShowTabsInMruOrder);
if (!animate) mContainerViewModel.set(ANIMATE_VISIBILITY_CHANGES, false); if (!animate) mContainerViewModel.set(ANIMATE_VISIBILITY_CHANGES, false);
setVisibility(true); setVisibility(true);
mModelIndexWhenShown = mTabModelSelector.getCurrentModelIndex(); mModelIndexWhenShown = mTabModelSelector.getCurrentModelIndex();
......
...@@ -346,7 +346,7 @@ public class GridTabSwitcherMediatorUnitTest { ...@@ -346,7 +346,7 @@ public class GridTabSwitcherMediatorUnitTest {
mMediator.setCleanupDelayForTesting(0); mMediator.setCleanupDelayForTesting(0);
mMediator.postHiding(); mMediator.postHiding();
verify(mResetHandler).softCleanup(); verify(mResetHandler).softCleanup();
verify(mResetHandler).resetWithTabList(eq(null), eq(false)); verify(mResetHandler).resetWithTabList(eq(null), eq(false), eq(false));
} }
@Test @Test
...@@ -357,7 +357,7 @@ public class GridTabSwitcherMediatorUnitTest { ...@@ -357,7 +357,7 @@ public class GridTabSwitcherMediatorUnitTest {
doReturn(true).when(mTabModelFilter).isIncognito(); doReturn(true).when(mTabModelFilter).isIncognito();
mTabModelSelectorObserverCaptor.getValue().onTabModelSelected(mTabModel, null); mTabModelSelectorObserverCaptor.getValue().onTabModelSelected(mTabModel, null);
verify(mResetHandler).resetWithTabList(eq(mTabModelFilter), eq(false)); verify(mResetHandler).resetWithTabList(eq(mTabModelFilter), eq(false), eq(false));
verify(mTabGridDialogResetHandler).hideDialog(eq(false)); verify(mTabGridDialogResetHandler).hideDialog(eq(false));
assertThat(mModel.get(TabListContainerProperties.IS_INCOGNITO), equalTo(true)); assertThat(mModel.get(TabListContainerProperties.IS_INCOGNITO), equalTo(true));
...@@ -371,7 +371,7 @@ public class GridTabSwitcherMediatorUnitTest { ...@@ -371,7 +371,7 @@ public class GridTabSwitcherMediatorUnitTest {
doReturn(true).when(mTabModelFilter).isIncognito(); doReturn(true).when(mTabModelFilter).isIncognito();
mTabModelSelectorObserverCaptor.getValue().onTabModelSelected(mTabModel, null); mTabModelSelectorObserverCaptor.getValue().onTabModelSelected(mTabModel, null);
verify(mResetHandler).resetWithTabList(eq(mTabModelFilter), eq(false)); verify(mResetHandler).resetWithTabList(eq(mTabModelFilter), eq(false), eq(false));
verify(mTabGridDialogResetHandler, never()).hideDialog(eq(false)); verify(mTabGridDialogResetHandler, never()).hideDialog(eq(false));
assertThat(mModel.get(TabListContainerProperties.IS_INCOGNITO), equalTo(true)); assertThat(mModel.get(TabListContainerProperties.IS_INCOGNITO), equalTo(true));
......
...@@ -250,7 +250,7 @@ public class TabGridDialogMediatorUnitTest { ...@@ -250,7 +250,7 @@ public class TabGridDialogMediatorUnitTest {
// Current tab ID should not update. // Current tab ID should not update.
assertThat(mMediator.getCurrentTabIdForTest(), equalTo(TAB1_ID)); assertThat(mMediator.getCurrentTabIdForTest(), equalTo(TAB1_ID));
assertThat(mModel.get(TabGridSheetProperties.HEADER_TITLE), equalTo(DIALOG_TITLE1)); assertThat(mModel.get(TabGridSheetProperties.HEADER_TITLE), equalTo(DIALOG_TITLE1));
verify(mTabSwitcherResetHandler).resetWithTabList(mTabGroupModelFilter, false); verify(mTabSwitcherResetHandler).resetWithTabList(mTabGroupModelFilter, false, false);
} }
@Test @Test
...@@ -270,7 +270,7 @@ public class TabGridDialogMediatorUnitTest { ...@@ -270,7 +270,7 @@ public class TabGridDialogMediatorUnitTest {
// Current tab ID should be updated to TAB1_ID now. // Current tab ID should be updated to TAB1_ID now.
assertThat(mMediator.getCurrentTabIdForTest(), equalTo(TAB1_ID)); assertThat(mMediator.getCurrentTabIdForTest(), equalTo(TAB1_ID));
assertThat(mModel.get(TabGridSheetProperties.HEADER_TITLE), equalTo(DIALOG_TITLE1)); assertThat(mModel.get(TabGridSheetProperties.HEADER_TITLE), equalTo(DIALOG_TITLE1));
verify(mTabSwitcherResetHandler).resetWithTabList(mTabGroupModelFilter, false); verify(mTabSwitcherResetHandler).resetWithTabList(mTabGroupModelFilter, false, false);
} }
@Test @Test
...@@ -288,7 +288,8 @@ public class TabGridDialogMediatorUnitTest { ...@@ -288,7 +288,8 @@ public class TabGridDialogMediatorUnitTest {
assertThat(mMediator.getCurrentTabIdForTest(), equalTo(Tab.INVALID_TAB_ID)); assertThat(mMediator.getCurrentTabIdForTest(), equalTo(Tab.INVALID_TAB_ID));
assertThat(mModel.get(TabGridSheetProperties.ANIMATION_SOURCE_RECT), equalTo(null)); assertThat(mModel.get(TabGridSheetProperties.ANIMATION_SOURCE_RECT), equalTo(null));
verify(mDialogResetHandler).resetWithListOfTabs(null); verify(mDialogResetHandler).resetWithListOfTabs(null);
verify(mTabSwitcherResetHandler, never()).resetWithTabList(mTabGroupModelFilter, false); verify(mTabSwitcherResetHandler, never())
.resetWithTabList(mTabGroupModelFilter, false, false);
} }
@Test @Test
...@@ -310,7 +311,8 @@ public class TabGridDialogMediatorUnitTest { ...@@ -310,7 +311,8 @@ public class TabGridDialogMediatorUnitTest {
assertThat(mModel.get(TabGridSheetProperties.HEADER_TITLE), equalTo(DIALOG_TITLE1)); assertThat(mModel.get(TabGridSheetProperties.HEADER_TITLE), equalTo(DIALOG_TITLE1));
// Dialog should still be hidden. // Dialog should still be hidden.
assertThat(mModel.get(TabGridSheetProperties.IS_DIALOG_VISIBLE), equalTo(false)); assertThat(mModel.get(TabGridSheetProperties.IS_DIALOG_VISIBLE), equalTo(false));
verify(mTabSwitcherResetHandler, never()).resetWithTabList(mTabGroupModelFilter, false); verify(mTabSwitcherResetHandler, never())
.resetWithTabList(mTabGroupModelFilter, false, false);
} }
@Test @Test
...@@ -323,7 +325,7 @@ public class TabGridDialogMediatorUnitTest { ...@@ -323,7 +325,7 @@ public class TabGridDialogMediatorUnitTest {
mTabModelObserverCaptor.getValue().tabClosureUndone(mTab1); mTabModelObserverCaptor.getValue().tabClosureUndone(mTab1);
assertThat(mModel.get(TabGridSheetProperties.HEADER_TITLE), equalTo(DIALOG_TITLE1)); assertThat(mModel.get(TabGridSheetProperties.HEADER_TITLE), equalTo(DIALOG_TITLE1));
verify(mTabSwitcherResetHandler).resetWithTabList(mTabGroupModelFilter, false); verify(mTabSwitcherResetHandler).resetWithTabList(mTabGroupModelFilter, false, false);
} }
@Test @Test
...@@ -338,7 +340,8 @@ public class TabGridDialogMediatorUnitTest { ...@@ -338,7 +340,8 @@ public class TabGridDialogMediatorUnitTest {
assertThat(mModel.get(TabGridSheetProperties.HEADER_TITLE), equalTo(DIALOG_TITLE1)); assertThat(mModel.get(TabGridSheetProperties.HEADER_TITLE), equalTo(DIALOG_TITLE1));
// Dialog should still be hidden. // Dialog should still be hidden.
assertThat(mModel.get(TabGridSheetProperties.IS_DIALOG_VISIBLE), equalTo(false)); assertThat(mModel.get(TabGridSheetProperties.IS_DIALOG_VISIBLE), equalTo(false));
verify(mTabSwitcherResetHandler, never()).resetWithTabList(mTabGroupModelFilter, false); verify(mTabSwitcherResetHandler, never())
.resetWithTabList(mTabGroupModelFilter, false, false);
} }
@Test @Test
......
...@@ -741,7 +741,7 @@ public class TabListMediatorUnitTest { ...@@ -741,7 +741,7 @@ public class TabListMediatorUnitTest {
// Assume that two tabs are in the same group before ungroup. // Assume that two tabs are in the same group before ungroup.
List<Tab> tabs = new ArrayList<>(Arrays.asList(mTab2)); List<Tab> tabs = new ArrayList<>(Arrays.asList(mTab2));
mMediator.resetWithListOfTabs(tabs, false); mMediator.resetWithListOfTabs(tabs, false, false);
assertThat(mModel.size(), equalTo(1)); assertThat(mModel.size(), equalTo(1));
assertThat(mModel.get(0).get(TabProperties.TAB_ID), equalTo(TAB2_ID)); assertThat(mModel.get(0).get(TabProperties.TAB_ID), equalTo(TAB2_ID));
...@@ -773,7 +773,7 @@ public class TabListMediatorUnitTest { ...@@ -773,7 +773,7 @@ public class TabListMediatorUnitTest {
// Assume that two tabs are in the same group before ungroup. // Assume that two tabs are in the same group before ungroup.
List<Tab> tabs = new ArrayList<>(Arrays.asList(mTab1)); List<Tab> tabs = new ArrayList<>(Arrays.asList(mTab1));
mMediator.resetWithListOfTabs(tabs, false); mMediator.resetWithListOfTabs(tabs, false, false);
assertThat(mModel.size(), equalTo(1)); assertThat(mModel.size(), equalTo(1));
assertThat(mModel.get(0).get(TabProperties.TAB_ID), equalTo(TAB1_ID)); assertThat(mModel.get(0).get(TabProperties.TAB_ID), equalTo(TAB1_ID));
...@@ -971,7 +971,7 @@ public class TabListMediatorUnitTest { ...@@ -971,7 +971,7 @@ public class TabListMediatorUnitTest {
// Assume there are 3 tabs in TabModel, mTab2 just grouped with mTab1; // Assume there are 3 tabs in TabModel, mTab2 just grouped with mTab1;
Tab tab3 = prepareTab(TAB3_ID, TAB3_TITLE); Tab tab3 = prepareTab(TAB3_ID, TAB3_TITLE);
List<Tab> tabs = new ArrayList<>(Arrays.asList(mTab1, tab3)); List<Tab> tabs = new ArrayList<>(Arrays.asList(mTab1, tab3));
mMediator.resetWithListOfTabs(tabs, false); mMediator.resetWithListOfTabs(tabs, false, false);
assertThat(mModel.size(), equalTo(2)); assertThat(mModel.size(), equalTo(2));
// Assume undo grouping mTab2 with mTab1. // Assume undo grouping mTab2 with mTab1.
...@@ -995,7 +995,7 @@ public class TabListMediatorUnitTest { ...@@ -995,7 +995,7 @@ public class TabListMediatorUnitTest {
// Assume there are 3 tabs in TabModel, tab3 just grouped with mTab1; // Assume there are 3 tabs in TabModel, tab3 just grouped with mTab1;
Tab tab3 = prepareTab(TAB3_ID, TAB3_TITLE); Tab tab3 = prepareTab(TAB3_ID, TAB3_TITLE);
List<Tab> tabs = new ArrayList<>(Arrays.asList(mTab1, mTab2)); List<Tab> tabs = new ArrayList<>(Arrays.asList(mTab1, mTab2));
mMediator.resetWithListOfTabs(tabs, false); mMediator.resetWithListOfTabs(tabs, false, false);
assertThat(mModel.size(), equalTo(2)); assertThat(mModel.size(), equalTo(2));
// Assume undo grouping tab3 with mTab1. // Assume undo grouping tab3 with mTab1.
...@@ -1019,7 +1019,7 @@ public class TabListMediatorUnitTest { ...@@ -1019,7 +1019,7 @@ public class TabListMediatorUnitTest {
// Assume there are 3 tabs in TabModel, mTab1 just grouped with mTab2; // Assume there are 3 tabs in TabModel, mTab1 just grouped with mTab2;
Tab tab3 = prepareTab(TAB3_ID, TAB3_TITLE); Tab tab3 = prepareTab(TAB3_ID, TAB3_TITLE);
List<Tab> tabs = new ArrayList<>(Arrays.asList(mTab2, tab3)); List<Tab> tabs = new ArrayList<>(Arrays.asList(mTab2, tab3));
mMediator.resetWithListOfTabs(tabs, false); mMediator.resetWithListOfTabs(tabs, false, false);
assertThat(mModel.size(), equalTo(2)); assertThat(mModel.size(), equalTo(2));
// Assume undo grouping tab3 with mTab1. // Assume undo grouping tab3 with mTab1.
...@@ -1089,7 +1089,7 @@ public class TabListMediatorUnitTest { ...@@ -1089,7 +1089,7 @@ public class TabListMediatorUnitTest {
for (int i = 0; i < mTabModel.getCount(); i++) { for (int i = 0; i < mTabModel.getCount(); i++) {
tabs.add(mTabModel.getTabAt(i)); tabs.add(mTabModel.getTabAt(i));
} }
mMediator.resetWithListOfTabs(tabs, false); mMediator.resetWithListOfTabs(tabs, false, false);
for (Callback<Drawable> callback : mCallbackCaptor.getAllValues()) { for (Callback<Drawable> callback : mCallbackCaptor.getAllValues()) {
callback.onResult(new ColorDrawable(Color.RED)); callback.onResult(new ColorDrawable(Color.RED));
} }
......
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