Commit 400f50fe authored by gogerald's avatar gogerald Committed by Commit Bot

[StartSurface] Rename GridTabSwitcher to TabSwitcher

This CL renamed GridTabSwitcher to TabSwitcher to generalize it
for creating carousel TabSwitcher.

It also renamed GridTabSwitcherCoordinator, GridTabSwitcherMediator
and TabGridContainerViewBinder accordingly.

Note that this CL didn't intend to rename all the files thoroughly at once.

We do not expect any functional changes in this CL.

Bug: 982018
Change-Id: I4595a0140cd27035f7b1dad30acdde91654fb86f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1736178
Commit-Queue: Pavel Shmakov <pshmakov@chromium.org>
Reviewed-by: default avatarPavel Shmakov <pshmakov@chromium.org>
Reviewed-by: default avatarYusuf Ozuysal <yusufo@chromium.org>
Reviewed-by: default avatarWei-Yin Chen (陳威尹) <wychen@chromium.org>
Auto-Submit: Ganggui Tang <gogerald@chromium.org>
Cr-Commit-Position: refs/heads/master@{#684372}
parent 3fad2e15
......@@ -14,8 +14,8 @@ import org.chromium.chrome.browser.ChromeActivity;
import org.chromium.chrome.browser.ChromeFeatureList;
import org.chromium.chrome.browser.tasks.ReturnToChromeExperimentsUtil;
import org.chromium.chrome.browser.tasks.TasksSurface;
import org.chromium.chrome.browser.tasks.tab_management.GridTabSwitcher;
import org.chromium.chrome.browser.tasks.tab_management.TabManagementModuleProvider;
import org.chromium.chrome.browser.tasks.tab_management.TabSwitcher;
import org.chromium.chrome.browser.util.FeatureUtilities;
import org.chromium.chrome.start_surface.R;
import org.chromium.ui.modelutil.PropertyModel;
......@@ -45,7 +45,7 @@ public class StartSurfaceCoordinator implements StartSurface {
int bottomBarHeight =
ContextUtils.getApplicationContext().getResources().getDimensionPixelSize(
R.dimen.ss_bottom_bar_height);
mTasksSurface.getTabGridDelegate().setBottomControlsHeight(bottomBarHeight);
mTasksSurface.getTabListDelegate().setBottomControlsHeight(bottomBarHeight);
mPropertyModel = new PropertyModel(StartSurfaceProperties.ALL_KEYS);
mPropertyModel.set(BOTTOM_BAR_HEIGHT, bottomBarHeight);
......@@ -69,7 +69,7 @@ public class StartSurfaceCoordinator implements StartSurface {
activity, exploreSurfaceContainer, mPropertyModel);
}
mStartSurfaceMediator = new StartSurfaceMediator(mTasksSurface.getGridController(),
mStartSurfaceMediator = new StartSurfaceMediator(mTasksSurface.getController(),
activity.getTabModelSelector(), mPropertyModel,
mExploreSurfaceCoordinator == null
? null
......@@ -88,7 +88,7 @@ public class StartSurfaceCoordinator implements StartSurface {
}
@Override
public GridTabSwitcher.TabGridDelegate getTabGridDelegate() {
return mTasksSurface.getTabGridDelegate();
public TabSwitcher.TabListDelegate getTabListDelegate() {
return mTasksSurface.getTabListDelegate();
}
}
......@@ -36,7 +36,7 @@ import org.chromium.chrome.browser.compositor.scene_layer.SceneLayer;
import org.chromium.chrome.browser.compositor.scene_layer.TabListSceneLayer;
import org.chromium.chrome.browser.fullscreen.ChromeFullscreenManager;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.tasks.tab_management.GridTabSwitcher;
import org.chromium.chrome.browser.tasks.tab_management.TabSwitcher;
import org.chromium.chrome.browser.util.FeatureUtilities;
import org.chromium.ui.resources.ResourceManager;
import org.chromium.ui.widget.Toast;
......@@ -49,7 +49,7 @@ import java.util.List;
import java.util.Locale;
/**
* A {@link Layout} that shows all tabs in one grid view.
* A {@link Layout} that shows all tabs in one grid or carousel view.
*/
public class StartSurfaceLayout extends Layout implements StartSurface.OverviewModeObserver {
private static final String TAG = "SSLayout";
......@@ -69,7 +69,7 @@ public class StartSurfaceLayout extends Layout implements StartSurface.OverviewM
private final TabListSceneLayer mSceneLayer = new TabListSceneLayer();
private final StartSurface mStartSurface;
private final StartSurface.Controller mController;
private final GridTabSwitcher.TabGridDelegate mTabGridDelegate;
private final TabSwitcher.TabListDelegate mTabListDelegate;
// To force Toolbar finishes its animation when this Layout finished hiding.
private final LayoutTab mDummyLayoutTab;
......@@ -97,10 +97,10 @@ public class StartSurfaceLayout extends Layout implements StartSurface.OverviewM
mStartSurface.setOnTabSelectingListener(this::onTabSelecting);
mController = mStartSurface.getController();
mController.addOverviewModeObserver(this);
mTabGridDelegate = mStartSurface.getTabGridDelegate();
mTabListDelegate = mStartSurface.getTabListDelegate();
}
// StartSurface.GridOverviewModeObserver implementation.
// StartSurface.OverviewModeObserver implementation.
@Override
public void startedShowing() {}
......@@ -130,7 +130,7 @@ public class StartSurfaceLayout extends Layout implements StartSurface.OverviewM
}
// If we are doing GTS-to-Tab transition animation, we start showing the Bitmap version of
// the GTS overview in the background while expanding the thumbnail to the viewport.
expandTab(mTabGridDelegate.getThumbnailLocationOfCurrentTab(true));
expandTab(mTabListDelegate.getThumbnailLocationOfCurrentTab(true));
}
// Layout implementation.
......@@ -151,7 +151,7 @@ public class StartSurfaceLayout extends Layout implements StartSurface.OverviewM
super.show(time, animate);
boolean showShrinkingAnimation = animate && FeatureUtilities.isTabToGtsAnimationEnabled();
boolean quick = mTabGridDelegate.prepareOverview();
boolean quick = mTabListDelegate.prepareOverview();
Log.d(TAG, "SkipSlowZooming = " + getSkipSlowZooming());
if (getSkipSlowZooming()) {
showShrinkingAnimation &= quick;
......@@ -170,7 +170,7 @@ public class StartSurfaceLayout extends Layout implements StartSurface.OverviewM
return;
}
shrinkTab(() -> mTabGridDelegate.getThumbnailLocationOfCurrentTab(false));
shrinkTab(() -> mTabListDelegate.getThumbnailLocationOfCurrentTab(false));
}
@Override
......@@ -363,7 +363,7 @@ public class StartSurfaceLayout extends Layout implements StartSurface.OverviewM
}
private void postHiding() {
mTabGridDelegate.postHiding();
mTabListDelegate.postHiding();
mIsAnimating = false;
doneHiding();
}
......@@ -381,7 +381,7 @@ public class StartSurfaceLayout extends Layout implements StartSurface.OverviewM
private void reportAnimationPerf(boolean isShrinking) {
int frameRendered = mFrameCount - mStartFrame;
long elapsedMs = SystemClock.elapsedRealtime() - mStartTime;
long lastDirty = mTabGridDelegate.getLastDirtyTimeForTesting();
long lastDirty = mTabListDelegate.getLastDirtyTimeForTesting();
int dirtySpan = (int) (lastDirty - mStartTime);
float fps = 1000.f * frameRendered / elapsedMs;
String message = String.format(Locale.US,
......@@ -404,6 +404,8 @@ public class StartSurfaceLayout extends Layout implements StartSurface.OverviewM
} else {
suffix = ".Expand";
}
// TODO(crbug.com/982018): Separate histograms for carousel tab switcher.
RecordHistogram.recordCount100Histogram(
"GridTabSwitcher.FramePerSecond" + suffix, (int) fps);
RecordHistogram.recordTimesHistogram(
......@@ -433,7 +435,7 @@ public class StartSurfaceLayout extends Layout implements StartSurface.OverviewM
// The content viewport is intentionally sent as both params below.
mSceneLayer.pushLayers(getContext(), contentViewport, contentViewport, this,
layerTitleCache, tabContentManager, resourceManager, fullscreenManager,
FeatureUtilities.isTabToGtsAnimationEnabled() ? mTabGridDelegate.getResourceId()
FeatureUtilities.isTabToGtsAnimationEnabled() ? mTabListDelegate.getResourceId()
: 0,
mBackgroundAlpha);
mFrameCount++;
......
......@@ -18,23 +18,22 @@ import org.chromium.chrome.browser.feed.FeedSurfaceCoordinator;
import org.chromium.chrome.browser.tabmodel.EmptyTabModelSelectorObserver;
import org.chromium.chrome.browser.tabmodel.TabModel;
import org.chromium.chrome.browser.tabmodel.TabModelSelector;
import org.chromium.chrome.browser.tasks.tab_management.GridTabSwitcher;
import org.chromium.chrome.browser.tasks.tab_management.TabSwitcher;
import org.chromium.ui.modelutil.PropertyModel;
/** The mediator implements the logic to interact with the surfaces and caller. */
class StartSurfaceMediator
implements StartSurface.Controller, GridTabSwitcher.GridOverviewModeObserver {
class StartSurfaceMediator implements StartSurface.Controller, TabSwitcher.OverviewModeObserver {
private final ObserverList<StartSurface.OverviewModeObserver> mObservers = new ObserverList<>();
private final GridTabSwitcher.GridController mGridController;
private final TabSwitcher.Controller mController;
@Nullable
private final PropertyModel mPropertyModel;
@Nullable
private final ExploreSurfaceCoordinator.FeedSurfaceCreator mFeedSurfaceCreator;
StartSurfaceMediator(GridTabSwitcher.GridController gridController,
TabModelSelector tabModelSelector, @Nullable PropertyModel propertyModel,
StartSurfaceMediator(TabSwitcher.Controller controller, TabModelSelector tabModelSelector,
@Nullable PropertyModel propertyModel,
@Nullable ExploreSurfaceCoordinator.FeedSurfaceCreator feedSurfaceCreator) {
mGridController = gridController;
mController = controller;
mPropertyModel = propertyModel;
mFeedSurfaceCreator = feedSurfaceCreator;
......@@ -67,13 +66,13 @@ class StartSurfaceMediator
updateIncognitoMode(tabModelSelector.isIncognitoSelected());
}
mGridController.addOverviewModeObserver(this);
mController.addOverviewModeObserver(this);
}
// Implements StartSurface.Controller
@Override
public boolean overviewVisible() {
return mGridController.overviewVisible();
return mController.overviewVisible();
}
@Override
......@@ -88,12 +87,12 @@ class StartSurfaceMediator
@Override
public void hideOverview(boolean animate) {
mGridController.hideOverview(animate);
mController.hideOverview(animate);
}
@Override
public void showOverview(boolean animate) {
mGridController.showOverview(animate);
mController.showOverview(animate);
// TODO(crbug.com/982018): Animate the bottom bar together with the Tab Grid view.
if (mPropertyModel != null) {
......@@ -115,10 +114,10 @@ class StartSurfaceMediator
setExploreSurfaceVisibility(false);
return true;
}
return mGridController.onBackPressed();
return mController.onBackPressed();
}
// Implements GridTabSwitcher.GridOverviewModeObserver.
// Implements TabSwitcher.OverviewModeObserver.
@Override
public void startedShowing() {
for (StartSurface.OverviewModeObserver observer : mObservers) {
......
......@@ -44,7 +44,7 @@ import org.chromium.chrome.browser.compositor.layouts.Layout;
import org.chromium.chrome.browser.compositor.layouts.content.TabContentManager;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.tabmodel.TabSelectionType;
import org.chromium.chrome.browser.tasks.tab_management.GridTabSwitcher;
import org.chromium.chrome.browser.tasks.tab_management.TabSwitcher;
import org.chromium.chrome.browser.util.FeatureUtilities;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.ChromeTabbedActivityTestRule;
......@@ -102,8 +102,8 @@ public class StartSurfaceLayoutTest {
mUrl = testServer.getURL("/chrome/test/data/android/navigate/simple.html");
mRepeat = 3;
GridTabSwitcher.TabGridDelegate delegate =
mStartSurfaceLayout.getStartSurfaceForTesting().getTabGridDelegate();
TabSwitcher.TabListDelegate delegate =
mStartSurfaceLayout.getStartSurfaceForTesting().getTabListDelegate();
delegate.setBitmapCallbackForTesting(mBitmapListener);
Assert.assertEquals(0, delegate.getBitmapFetchCountForTesting());
......@@ -115,8 +115,8 @@ public class StartSurfaceLayoutTest {
@MediumTest
@CommandLineFlags.Add({BASE_PARAMS})
public void testTabToGridFromLiveTab() throws InterruptedException {
GridTabSwitcher.TabGridDelegate delegate =
mStartSurfaceLayout.getStartSurfaceForTesting().getTabGridDelegate();
TabSwitcher.TabListDelegate delegate =
mStartSurfaceLayout.getStartSurfaceForTesting().getTabListDelegate();
assertEquals(0, delegate.getSoftCleanupDelayForTesting());
assertEquals(0, delegate.getCleanupDelayForTesting());
......@@ -143,8 +143,8 @@ public class StartSurfaceLayoutTest {
@MediumTest
@CommandLineFlags.Add({BASE_PARAMS + "/soft-cleanup-delay/10000/cleanup-delay/10000"})
public void testTabToGridFromLiveTabWarm() throws InterruptedException {
GridTabSwitcher.TabGridDelegate delegate =
mStartSurfaceLayout.getStartSurfaceForTesting().getTabGridDelegate();
TabSwitcher.TabListDelegate delegate =
mStartSurfaceLayout.getStartSurfaceForTesting().getTabListDelegate();
assertEquals(10000, delegate.getSoftCleanupDelayForTesting());
assertEquals(10000, delegate.getCleanupDelayForTesting());
......@@ -427,8 +427,8 @@ public class StartSurfaceLayoutTest {
@CommandLineFlags.Add({BASE_PARAMS})
public void testRestoredTabsDontFetch() throws Exception {
prepareTabs(2, mUrl);
GridTabSwitcher.TabGridDelegate delegate =
mStartSurfaceLayout.getStartSurfaceForTesting().getTabGridDelegate();
TabSwitcher.TabListDelegate delegate =
mStartSurfaceLayout.getStartSurfaceForTesting().getTabListDelegate();
int oldCount = delegate.getBitmapFetchCountForTesting();
// Restart Chrome.
......@@ -608,7 +608,7 @@ public class StartSurfaceLayoutTest {
/**
* Should be the same as {@link ValueAnimator#areAnimatorsEnabled}, which requires API level 26.
* TODO(crbug.com/982018): put this interface in a place to share with
* TabGridContainerViewBinderTest.areAnimatorsEnabled.
* TabListContainerViewBinderTest.areAnimatorsEnabled.
*/
private static boolean areAnimatorsEnabled() {
// We default to assuming that animations are enabled in case ANIMATOR_DURATION_SCALE is not
......
......@@ -4,17 +4,17 @@
package org.chromium.chrome.features.start_surface;
import org.chromium.chrome.browser.tasks.tab_management.GridTabSwitcher;
import org.chromium.chrome.browser.tasks.tab_management.TabSwitcher;
/** Interface to communicate with the start surface. */
public interface StartSurface {
/**
* Defines an interface to pass out tab selecting event.
*/
interface OnTabSelectingListener extends GridTabSwitcher.OnTabSelectingListener {}
interface OnTabSelectingListener extends TabSwitcher.OnTabSelectingListener {}
/**
* Set the listener to get the {@link Layout#onTabSelecting} event from the Grid Tab Switcher.
* Set the listener to get the {@link Layout#onTabSelecting} event from the Tab Switcher.
* @param listener The {@link OnTabSelectingListener} to use.
*/
void setOnTabSelectingListener(OnTabSelectingListener listener);
......@@ -76,8 +76,8 @@ public interface StartSurface {
void showOverview(boolean animate);
/**
* Called by the GridTabSwitcherLayout when the system back button is pressed.
* @return Whether or not the GridTabSwitcher consumed the event.
* Called by the TabSwitcherLayout when the system back button is pressed.
* @return Whether or not the TabSwitcher consumed the event.
*/
boolean onBackPressed();
}
......@@ -89,7 +89,7 @@ public interface StartSurface {
Controller getController();
/**
* @return TabGridDelegate implementation that can be used to access the Tab Grid.
* @return TabListDelegate implementation that can be used to access the Tab List.
*/
GridTabSwitcher.TabGridDelegate getTabGridDelegate();
TabSwitcher.TabListDelegate getTabListDelegate();
}
\ No newline at end of file
......@@ -23,13 +23,10 @@ android_library("java") {
"java/src/org/chromium/chrome/browser/tasks/TasksSurfaceCoordinator.java",
"java/src/org/chromium/chrome/browser/tasks/tab_groups/TabGroupUtils.java",
"java/src/org/chromium/chrome/browser/tasks/tab_management/ClosableTabGridViewHolder.java",
"java/src/org/chromium/chrome/browser/tasks/tab_management/GridTabSwitcherCoordinator.java",
"java/src/org/chromium/chrome/browser/tasks/tab_management/GridTabSwitcherMediator.java",
"java/src/org/chromium/chrome/browser/tasks/tab_management/MultiThumbnailCardProvider.java",
"java/src/org/chromium/chrome/browser/tasks/tab_management/SelectableTabGridView.java",
"java/src/org/chromium/chrome/browser/tasks/tab_management/SelectableTabGridViewHolder.java",
"java/src/org/chromium/chrome/browser/tasks/tab_management/TabCarouselViewHolder.java",
"java/src/org/chromium/chrome/browser/tasks/tab_management/TabGridContainerViewBinder.java",
"java/src/org/chromium/chrome/browser/tasks/tab_management/TabGridDialogCoordinator.java",
"java/src/org/chromium/chrome/browser/tasks/tab_management/TabGridDialogMediator.java",
"java/src/org/chromium/chrome/browser/tasks/tab_management/TabGridDialogParent.java",
......@@ -48,6 +45,7 @@ android_library("java") {
"java/src/org/chromium/chrome/browser/tasks/tab_management/TabGroupUiToolbarView.java",
"java/src/org/chromium/chrome/browser/tasks/tab_management/TabGroupUiToolbarViewBinder.java",
"java/src/org/chromium/chrome/browser/tasks/tab_management/TabListContainerProperties.java",
"java/src/org/chromium/chrome/browser/tasks/tab_management/TabListContainerViewBinder.java",
"java/src/org/chromium/chrome/browser/tasks/tab_management/TabListCoordinator.java",
"java/src/org/chromium/chrome/browser/tasks/tab_management/TabListFaviconProvider.java",
"java/src/org/chromium/chrome/browser/tasks/tab_management/TabListMediator.java",
......@@ -65,6 +63,8 @@ android_library("java") {
"java/src/org/chromium/chrome/browser/tasks/tab_management/TabStripToolbarViewProperties.java",
"java/src/org/chromium/chrome/browser/tasks/tab_management/TabStripViewBinder.java",
"java/src/org/chromium/chrome/browser/tasks/tab_management/TabStripViewHolder.java",
"java/src/org/chromium/chrome/browser/tasks/tab_management/TabSwitcherCoordinator.java",
"java/src/org/chromium/chrome/browser/tasks/tab_management/TabSwitcherMediator.java",
"java/src/org/chromium/chrome/browser/tasks/tab_management/UndoGroupSnackbarController.java",
]
......
include_rules = [
"+chrome/lib/lifecycle/public/android/java/src/org/chromium/chrome/browser/lifecycle",
"+components/feature_engagement/public/android/java/src/org/chromium/components/feature_engagement",
"+components/module_installer",
......
......@@ -5,7 +5,7 @@
package org.chromium.chrome.browser.tasks;
import org.chromium.chrome.browser.compositor.layouts.Layout;
import org.chromium.chrome.browser.tasks.tab_management.GridTabSwitcher;
import org.chromium.chrome.browser.tasks.tab_management.TabSwitcher;
/**
* Interface for the Tasks-related Start Surface. The tasks surface displays information related to
......@@ -15,17 +15,17 @@ import org.chromium.chrome.browser.tasks.tab_management.GridTabSwitcher;
public interface TasksSurface {
/**
* Set the listener to get the {@link Layout#onTabSelecting} event from the Grid Tab Switcher.
* @param listener The {@link GridTabSwitcher.OnTabSelectingListener} to use.
* @param listener The {@link TabSwitcher.OnTabSelectingListener} to use.
*/
void setOnTabSelectingListener(GridTabSwitcher.OnTabSelectingListener listener);
void setOnTabSelectingListener(TabSwitcher.OnTabSelectingListener listener);
/**
* @return Controller implementation for overview observation and visibility changes.
*/
GridTabSwitcher.GridController getGridController();
TabSwitcher.Controller getController();
/**
* @return TabGridDelegate implementation to access the tab grid.
* @return TabListDelegate implementation to access the tab grid.
*/
GridTabSwitcher.TabGridDelegate getTabGridDelegate();
TabSwitcher.TabListDelegate getTabListDelegate();
}
......@@ -8,15 +8,15 @@ import android.widget.FrameLayout;
import android.widget.LinearLayout;
import org.chromium.chrome.browser.ChromeActivity;
import org.chromium.chrome.browser.tasks.tab_management.GridTabSwitcher;
import org.chromium.chrome.browser.tasks.tab_management.TabManagementModuleProvider;
import org.chromium.chrome.browser.tasks.tab_management.TabSwitcher;
/**
* Coordinator for displaying task-related surfaces (Grid Tab Switcher, MV Tiles, Omnibox, etc.).
* Coordinator for displaying task-related surfaces (Tab Switcher, MV Tiles, Omnibox, etc.).
* Concrete implementation of {@link TasksSurface}.
*/
public class TasksSurfaceCoordinator implements TasksSurface {
private final GridTabSwitcher mGridTabSwitcher;
private final TabSwitcher mGridTabSwitcher;
private final LinearLayout mLayout;
private final FrameLayout mGridContainerLayout;
......@@ -39,17 +39,17 @@ public class TasksSurfaceCoordinator implements TasksSurface {
}
@Override
public void setOnTabSelectingListener(GridTabSwitcher.OnTabSelectingListener listener) {
public void setOnTabSelectingListener(TabSwitcher.OnTabSelectingListener listener) {
mGridTabSwitcher.setOnTabSelectingListener(listener);
}
@Override
public GridTabSwitcher.GridController getGridController() {
return mGridTabSwitcher.getGridController();
public TabSwitcher.Controller getController() {
return mGridTabSwitcher.getController();
}
@Override
public GridTabSwitcher.TabGridDelegate getTabGridDelegate() {
return mGridTabSwitcher.getTabGridDelegate();
public TabSwitcher.TabListDelegate getTabListDelegate() {
return mGridTabSwitcher.getTabListDelegate();
}
}
......@@ -35,7 +35,7 @@ public class TabGridDialogCoordinator implements TabGridDialogMediator.ResetHand
TabGridDialogCoordinator(Context context, TabModelSelector tabModelSelector,
TabContentManager tabContentManager, TabCreatorManager tabCreatorManager,
CompositorViewHolder compositorViewHolder,
GridTabSwitcherMediator.ResetHandler resetHandler,
TabSwitcherMediator.ResetHandler resetHandler,
TabListMediator.GridCardOnClickListenerProvider gridCardOnClickListenerProvider,
TabGridDialogMediator.AnimationOriginProvider animationOriginProvider) {
mContext = context;
......
......@@ -74,21 +74,21 @@ public class TabGridDialogMediator {
private final TabModelObserver mTabModelObserver;
private final TabCreatorManager mTabCreatorManager;
private final ResetHandler mDialogResetHandler;
private final GridTabSwitcherMediator.ResetHandler mGridTabSwitcherResetHandler;
private final TabSwitcherMediator.ResetHandler mTabSwitcherResetHandler;
private final AnimationOriginProvider mAnimationOriginProvider;
private final DialogHandler mTabGridDialogHandler;
private int mCurrentTabId = Tab.INVALID_TAB_ID;
TabGridDialogMediator(Context context, ResetHandler dialogResetHandler, PropertyModel model,
TabModelSelector tabModelSelector, TabCreatorManager tabCreatorManager,
GridTabSwitcherMediator.ResetHandler gridTabSwitcherResetHandler,
TabSwitcherMediator.ResetHandler tabSwitcherResetHandler,
AnimationOriginProvider animationOriginProvider) {
mContext = context;
mModel = model;
mTabModelSelector = tabModelSelector;
mTabCreatorManager = tabCreatorManager;
mDialogResetHandler = dialogResetHandler;
mGridTabSwitcherResetHandler = gridTabSwitcherResetHandler;
mTabSwitcherResetHandler = tabSwitcherResetHandler;
mAnimationOriginProvider = animationOriginProvider;
mTabGridDialogHandler = new DialogHandler();
......@@ -187,8 +187,8 @@ public class TabGridDialogMediator {
}
private void updateGridTabSwitcher() {
if (!isVisible() || mGridTabSwitcherResetHandler == null) return;
mGridTabSwitcherResetHandler.resetWithTabList(
if (!isVisible() || mTabSwitcherResetHandler == null) return;
mTabSwitcherResetHandler.resetWithTabList(
mTabModelSelector.getTabModelFilterProvider().getCurrentTabModelFilter(), false);
}
......
......@@ -22,9 +22,9 @@ import org.chromium.ui.modelutil.PropertyKey;
import org.chromium.ui.modelutil.PropertyModel;
/**
* ViewBinder for TabGridContainer.
* ViewBinder for TabListRecyclerView.
*/
class TabGridContainerViewBinder {
class TabListContainerViewBinder {
/**
* Bind the given model to the given view, updating the payload in propertyKey.
* @param model The model to use.
......
......@@ -612,7 +612,7 @@ class TabListMediator {
from = TabClosedFrom.TAB_STRIP;
} else if (fromComponent.equals(TabGridSheetCoordinator.COMPONENT_NAME)) {
from = TabClosedFrom.TAB_GRID_SHEET;
} else if (fromComponent.equals(GridTabSwitcherCoordinator.COMPONENT_NAME)) {
} else if (fromComponent.equals(TabSwitcherCoordinator.COMPONENT_NAME)) {
from = TabClosedFrom.GRID_TAB_SWITCHER;
} else {
Log.w(TAG, "Attempting to close tab from Unknown UI");
......
......@@ -33,12 +33,20 @@ public interface TabManagementDelegate {
TasksSurface createTasksSurface(ChromeActivity activity);
/**
* Create the {@link GridTabSwitcher}.
* Create the {@link TabSwitcher} to display Tabs in grid.
* @param context The {@link Context} of this switcher.
* @param containerView The {@link ViewGroup} to add the switcher to.
* @return The {@link GridTabSwitcher}.
* @return The {@link TabSwitcher}.
*/
GridTabSwitcher createGridTabSwitcher(ChromeActivity context, ViewGroup containerView);
TabSwitcher createGridTabSwitcher(ChromeActivity context, ViewGroup containerView);
/**
* Create the {@link TabSwitcher} to display Tabs in carousel.
* @param context The {@link Context} of this switcher.
* @param containerView The {@link ViewGroup} to add the switcher to.
* @return The {@link TabSwitcher}.
*/
TabSwitcher createCarouselTabSwitcher(ChromeActivity context, ViewGroup containerView);
/**
* Create the {@link TabGroupUi}.
......
......@@ -36,16 +36,26 @@ public class TabManagementDelegateImpl implements TabManagementDelegate {
}
@Override
public GridTabSwitcher createGridTabSwitcher(ChromeActivity activity, ViewGroup containerView) {
public TabSwitcher createGridTabSwitcher(ChromeActivity activity, ViewGroup containerView) {
if (UmaSessionStats.isMetricsServiceAvailable()) {
UmaSessionStats.registerSyntheticFieldTrial(
ChromeFeatureList.TAB_GRID_LAYOUT_ANDROID + SYNTHETIC_TRIAL_POSTFIX,
"Downloaded_Enabled");
}
return new GridTabSwitcherCoordinator(activity, activity.getLifecycleDispatcher(),
return new TabSwitcherCoordinator(activity, activity.getLifecycleDispatcher(),
activity.getTabModelSelector(), activity.getTabContentManager(),
activity.getCompositorViewHolder(), activity.getFullscreenManager(), activity,
activity.getMenuOrKeyboardActionController(), activity, containerView);
activity.getMenuOrKeyboardActionController(), activity, containerView,
TabListCoordinator.TabListMode.GRID);
}
@Override
public TabSwitcher createCarouselTabSwitcher(ChromeActivity activity, ViewGroup containerView) {
return new TabSwitcherCoordinator(activity, activity.getLifecycleDispatcher(),
activity.getTabModelSelector(), activity.getTabContentManager(),
activity.getCompositorViewHolder(), activity.getFullscreenManager(), activity,
activity.getMenuOrKeyboardActionController(), activity, containerView,
TabListCoordinator.TabListMode.CAROUSEL);
}
@Override
......
......@@ -15,9 +15,9 @@ import org.chromium.chrome.browser.tab.Tab;
import org.chromium.ui.resources.dynamics.ViewResourceAdapter;
/**
* Interface for the Grid Tab Switcher.
* Interface for the Tab Switcher.
*/
public interface GridTabSwitcher {
public interface TabSwitcher {
/**
* Defines an interface to pass out tab selecting event.
*/
......@@ -32,16 +32,16 @@ public interface GridTabSwitcher {
}
/**
* Set the listener to get the {@link Layout#onTabSelecting} event from the Grid Tab Switcher.
* Set the listener to get the {@link Layout#onTabSelecting} event from the Tab Switcher.
* @param listener The {@link OnTabSelectingListener} to use.
*/
void setOnTabSelectingListener(OnTabSelectingListener listener);
// TODO(960196): Remove the following interfaces when the associated bug is resolved.
/**
* An observer that is notified when the GridTabSwitcher view state changes.
* An observer that is notified when the TabSwitcher view state changes.
*/
interface GridOverviewModeObserver {
interface OverviewModeObserver {
/**
* Called when overview mode starts showing.
*/
......@@ -64,9 +64,9 @@ public interface GridTabSwitcher {
}
/**
* Interface to control the GridTabSwitcher.
* Interface to control the TabSwitcher.
*/
interface GridController {
interface Controller {
/**
* @return Whether or not the overview {@link Layout} is visible.
*/
......@@ -75,12 +75,12 @@ public interface GridTabSwitcher {
/**
* @param listener Registers {@code listener} for overview mode status changes.
*/
void addOverviewModeObserver(GridOverviewModeObserver listener);
void addOverviewModeObserver(OverviewModeObserver listener);
/**
* @param listener Unregisters {@code listener} for overview mode status changes.
*/
void removeOverviewModeObserver(GridOverviewModeObserver listener);
void removeOverviewModeObserver(OverviewModeObserver listener);
/**
* Hide the overview.
......@@ -96,23 +96,23 @@ public interface GridTabSwitcher {
/**
* Called by the StartSurfaceLayout when the system back button is pressed.
* @return Whether or not the GridTabSwitcher consumed the event.
* @return Whether or not the TabSwitcher consumed the event.
*/
boolean onBackPressed();
}
/**
* @return GridController implementation that can be used for controlling
* grid visibility changes.
* @return Controller implementation that can be used for controlling
* visibility changes.
*/
GridController getGridController();
Controller getController();
/**
* Interface to access the Tab Grid.
* Interface to access the Tab List.
*/
interface TabGridDelegate {
interface TabListDelegate {
/**
* @return The dynamic resource ID of the GridTabSwitcher RecyclerView.
* @return The dynamic resource ID of the TabSwitcher RecyclerView.
*/
int getResourceId();
......@@ -129,8 +129,8 @@ public interface GridTabSwitcher {
void setBottomControlsHeight(int bottomControlsHeight);
/**
* Before calling {@link GridController#showOverview} to start showing the
* GridTabSwitcher {@link TabListRecyclerView}, call this to populate it without making it
* Before calling {@link Controller#showOverview} to start showing the
* TabSwitcher {@link TabListRecyclerView}, call this to populate it without making it
* visible.
* @return Whether the {@link TabListRecyclerView} can be shown quickly.
*/
......@@ -138,7 +138,7 @@ public interface GridTabSwitcher {
/**
* This is called after the compositor animation is done, for potential clean-up work.
* {@link GridOverviewModeObserver#finishedHiding} happens after
* {@link OverviewModeObserver#finishedHiding} happens after
* the Android View animation, but before the compositor animation.
*/
void postHiding();
......@@ -147,7 +147,7 @@ public interface GridTabSwitcher {
* @param forceUpdate Whether to measure the current location again. If not, return the last
* location measured on last layout, which can be wrong after scrolling.
* @return The {@link Rect} of the thumbnail of the current tab, relative to the
* GridTabSwitcher {@link TabListRecyclerView} coordinates.
* TabSwitcher {@link TabListRecyclerView} coordinates.
*/
@NonNull
Rect getThumbnailLocationOfCurrentTab(boolean forceUpdate);
......@@ -180,7 +180,7 @@ public interface GridTabSwitcher {
}
/**
* @return The {@link TabGridDelegate}.
* @return The {@link TabListDelegate}.
*/
TabGridDelegate getTabGridDelegate();
TabListDelegate getTabListDelegate();
}
......@@ -34,24 +34,27 @@ import java.util.ArrayList;
import java.util.List;
/**
* Parent coordinator that is responsible for showing a grid of tabs for the main TabSwitcher UI.
* Parent coordinator that is responsible for showing a grid or carousel of tabs for the main
* TabSwitcher UI.
*/
public class GridTabSwitcherCoordinator implements Destroyable, GridTabSwitcher,
GridTabSwitcher.TabGridDelegate,
GridTabSwitcherMediator.ResetHandler {
public class TabSwitcherCoordinator implements Destroyable, TabSwitcher,
TabSwitcher.TabListDelegate,
TabSwitcherMediator.ResetHandler {
// TODO(crbug.com/982018): Rename 'COMPONENT_NAME' so as to add different metrics for carousel
// tab switcher.
final static String COMPONENT_NAME = "GridTabSwitcher";
private final PropertyModelChangeProcessor mContainerViewChangeProcessor;
private final ActivityLifecycleDispatcher mLifecycleDispatcher;
private final MenuOrKeyboardActionController mMenuOrKeyboardActionController;
private final TabListCoordinator mTabGridCoordinator;
private final GridTabSwitcherMediator mMediator;
private final TabListCoordinator mTabListCoordinator;
private final TabSwitcherMediator mMediator;
private final MultiThumbnailCardProvider mMultiThumbnailCardProvider;
private final TabGridDialogCoordinator mTabGridDialogCoordinator;
private final TabSelectionEditorCoordinator mTabSelectionEditorCoordinator;
private final UndoGroupSnackbarController mUndoGroupSnackbarController;
private final MenuOrKeyboardActionController
.MenuOrKeyboardActionHandler mGridTabSwitcherMenuActionHandler =
.MenuOrKeyboardActionHandler mTabSwitcherMenuActionHandler =
new MenuOrKeyboardActionController.MenuOrKeyboardActionHandler() {
@Override
public boolean handleMenuOrKeyboardAction(int id, boolean fromMenu) {
......@@ -64,18 +67,19 @@ public class GridTabSwitcherCoordinator implements Destroyable, GridTabSwitcher,
}
};
public GridTabSwitcherCoordinator(Context context,
ActivityLifecycleDispatcher lifecycleDispatcher, TabModelSelector tabModelSelector,
TabContentManager tabContentManager, CompositorViewHolder compositorViewHolder,
ChromeFullscreenManager fullscreenManager, TabCreatorManager tabCreatorManager,
public TabSwitcherCoordinator(Context context, ActivityLifecycleDispatcher lifecycleDispatcher,
TabModelSelector tabModelSelector, TabContentManager tabContentManager,
CompositorViewHolder compositorViewHolder, ChromeFullscreenManager fullscreenManager,
TabCreatorManager tabCreatorManager,
MenuOrKeyboardActionController menuOrKeyboardActionController,
SnackbarManager.SnackbarManageable snackbarManageable, @Nullable ViewGroup container) {
SnackbarManager.SnackbarManageable snackbarManageable, @Nullable ViewGroup container,
@TabListCoordinator.TabListMode int mode) {
PropertyModel containerViewModel = new PropertyModel(TabListContainerProperties.ALL_KEYS);
mTabSelectionEditorCoordinator = new TabSelectionEditorCoordinator(
context, compositorViewHolder, tabModelSelector, tabContentManager);
mMediator = new GridTabSwitcherMediator(this, containerViewModel, tabModelSelector,
mMediator = new TabSwitcherMediator(this, containerViewModel, tabModelSelector,
fullscreenManager, compositorViewHolder,
mTabSelectionEditorCoordinator.getController());
......@@ -106,35 +110,35 @@ public class GridTabSwitcherCoordinator implements Destroyable, GridTabSwitcher,
};
ViewGroup tabListContainerView = container != null ? container : compositorViewHolder;
mTabGridCoordinator = new TabListCoordinator(TabListCoordinator.TabListMode.GRID, context,
tabModelSelector, mMultiThumbnailCardProvider, titleProvider, true,
mMediator::getCreateGroupButtonOnClickListener, mMediator, null, null, null,
tabListContainerView, compositorViewHolder.getDynamicResourceLoader(), true,
COMPONENT_NAME);
mTabListCoordinator =
new TabListCoordinator(mode, context, tabModelSelector, mMultiThumbnailCardProvider,
titleProvider, true, mMediator::getCreateGroupButtonOnClickListener,
mMediator, null, null, null, tabListContainerView,
compositorViewHolder.getDynamicResourceLoader(), true, COMPONENT_NAME);
mContainerViewChangeProcessor = PropertyModelChangeProcessor.create(containerViewModel,
mTabGridCoordinator.getContainerView(), TabGridContainerViewBinder::bind);
mTabListCoordinator.getContainerView(), TabListContainerViewBinder::bind);
mMenuOrKeyboardActionController = menuOrKeyboardActionController;
mMenuOrKeyboardActionController.registerMenuOrKeyboardActionHandler(
mGridTabSwitcherMenuActionHandler);
mTabSwitcherMenuActionHandler);
mLifecycleDispatcher = lifecycleDispatcher;
mLifecycleDispatcher.register(this);
}
// GridTabSwitcher implementation.
// TabSwitcher implementation.
@Override
public void setOnTabSelectingListener(OnTabSelectingListener listener) {
mMediator.setOnTabSelectingListener(listener);
}
@Override
public GridController getGridController() {
public Controller getController() {
return mMediator;
}
@Override
public TabGridDelegate getTabGridDelegate() {
public TabListDelegate getTabListDelegate() {
return this;
}
......@@ -146,13 +150,13 @@ public class GridTabSwitcherCoordinator implements Destroyable, GridTabSwitcher,
@Override
public boolean prepareOverview() {
boolean quick = mMediator.prepareOverview();
mTabGridCoordinator.prepareOverview();
mTabListCoordinator.prepareOverview();
return quick;
}
@Override
public void postHiding() {
mTabGridCoordinator.postHiding();
mTabListCoordinator.postHiding();
mMediator.postHiding();
}
......@@ -163,22 +167,22 @@ public class GridTabSwitcherCoordinator implements Destroyable, GridTabSwitcher,
assert forceUpdate;
Rect thumbnail = mTabGridDialogCoordinator.getGlobalLocationOfCurrentThumbnail();
// Adjust to the relative coordinate.
Rect root = mTabGridCoordinator.getRecyclerViewLocation();
Rect root = mTabListCoordinator.getRecyclerViewLocation();
thumbnail.offset(-root.left, -root.top);
return thumbnail;
}
if (forceUpdate) mTabGridCoordinator.updateThumbnailLocation();
return mTabGridCoordinator.getThumbnailLocationOfCurrentTab();
if (forceUpdate) mTabListCoordinator.updateThumbnailLocation();
return mTabListCoordinator.getThumbnailLocationOfCurrentTab();
}
@Override
public int getResourceId() {
return mTabGridCoordinator.getResourceId();
return mTabListCoordinator.getResourceId();
}
@Override
public long getLastDirtyTimeForTesting() {
return mTabGridCoordinator.getLastDirtyTimeForTesting();
return mTabListCoordinator.getLastDirtyTimeForTesting();
}
@Override
......@@ -215,24 +219,24 @@ public class GridTabSwitcherCoordinator implements Destroyable, GridTabSwitcher,
tabs.add(tabList.getTabAt(i));
}
}
return mTabGridCoordinator.resetWithListOfTabs(tabs, quickMode);
return mTabListCoordinator.resetWithListOfTabs(tabs, quickMode);
}
private Rect getTabGridCardPosition(int index) {
return mTabGridCoordinator.getContainerView().getRectOfCurrentTabGridCard(index);
return mTabListCoordinator.getContainerView().getRectOfCurrentTabGridCard(index);
}
@Override
public void softCleanup() {
mTabGridCoordinator.softCleanup();
mTabListCoordinator.softCleanup();
}
// ResetHandler implementation.
@Override
public void destroy() {
mMenuOrKeyboardActionController.unregisterMenuOrKeyboardActionHandler(
mGridTabSwitcherMenuActionHandler);
mTabGridCoordinator.destroy();
mTabSwitcherMenuActionHandler);
mTabListCoordinator.destroy();
mContainerViewChangeProcessor.destroy();
if (mTabGridDialogCoordinator != null) {
mTabGridDialogCoordinator.destroy();
......
......@@ -52,13 +52,12 @@ import org.chromium.ui.modelutil.PropertyModel;
import java.util.List;
/**
* The Mediator that is responsible for resetting the tab grid based on visibility and model
* changes.
* The Mediator that is responsible for resetting the tab grid or carousel based on visibility and
* model changes.
*/
class GridTabSwitcherMediator implements GridTabSwitcher.GridController,
TabListRecyclerView.VisibilityListener,
TabListMediator.GridCardOnClickListenerProvider {
private static final String TAG = "GTSMediator";
class TabSwitcherMediator implements TabSwitcher.Controller, TabListRecyclerView.VisibilityListener,
TabListMediator.GridCardOnClickListenerProvider {
private static final String TAG = "TabSwitcherMediator";
// This should be the same as TabListCoordinator.GRID_LAYOUT_SPAN_COUNT for the selected tab
// to be on the 2nd row.
......@@ -86,8 +85,7 @@ class GridTabSwitcherMediator implements GridTabSwitcher.GridController,
private final TabModelSelector mTabModelSelector;
private final TabModelObserver mTabModelObserver;
private final TabModelSelectorObserver mTabModelSelectorObserver;
private final ObserverList<GridTabSwitcher.GridOverviewModeObserver> mObservers =
new ObserverList<>();
private final ObserverList<TabSwitcher.OverviewModeObserver> mObservers = new ObserverList<>();
private final ChromeFullscreenManager mFullscreenManager;
private TabGridDialogMediator.ResetHandler mTabGridDialogResetHandler;
private final ChromeFullscreenManager.FullscreenListener mFullscreenListener =
......@@ -109,9 +107,9 @@ class GridTabSwitcherMediator implements GridTabSwitcher.GridController,
};
private final CompositorViewHolder mCompositorViewHolder;
private GridTabSwitcher.OnTabSelectingListener mOnTabSelectingListener;
private final TabSelectionEditorCoordinator
.TabSelectionEditorController mTabSelectionEditorController;
private TabSwitcher.OnTabSelectingListener mOnTabSelectingListener;
/**
* In cases where a didSelectTab was due to switching models with a toggle,
......@@ -145,14 +143,14 @@ class GridTabSwitcherMediator implements GridTabSwitcher.GridController,
* Basic constructor for the Mediator.
* @param resetHandler The {@link ResetHandler} that handles reset for this Mediator.
* @param containerViewModel The {@link PropertyModel} to keep state on the View containing the
* grid.
* grid or carousel.
* @param tabModelSelector {@link TabModelSelector} to observer for model and selection changes.
* @param fullscreenManager {@link FullscreenManager} to use.
* @param compositorViewHolder {@link CompositorViewHolder} to use.
* @param tabSelectionEditorController The controller that can control the visibility of the
* TabSelectionEditor.
*/
GridTabSwitcherMediator(ResetHandler resetHandler, PropertyModel containerViewModel,
TabSwitcherMediator(ResetHandler resetHandler, PropertyModel containerViewModel,
TabModelSelector tabModelSelector, ChromeFullscreenManager fullscreenManager,
CompositorViewHolder compositorViewHolder,
TabSelectionEditorCoordinator
......@@ -319,7 +317,7 @@ class GridTabSwitcherMediator implements GridTabSwitcher.GridController,
if (tab.getId() == mTabIdwhenShown) {
RecordUserAction.record("MobileTabReturnedToCurrentTab");
RecordHistogram.recordSparseHistogram(
"Tabs.TabOffsetOfSwitch." + GridTabSwitcherCoordinator.COMPONENT_NAME, 0);
"Tabs.TabOffsetOfSwitch." + TabSwitcherCoordinator.COMPONENT_NAME, 0);
} else {
int fromIndex = mTabModelSelector.getTabModelFilterProvider()
.getCurrentTabModelFilter()
......@@ -330,9 +328,9 @@ class GridTabSwitcherMediator implements GridTabSwitcher.GridController,
if (fromIndex != toIndex || fromTab.getId() == tab.getId()) {
RecordUserAction.record(
"MobileTabSwitched." + GridTabSwitcherCoordinator.COMPONENT_NAME);
"MobileTabSwitched." + TabSwitcherCoordinator.COMPONENT_NAME);
RecordHistogram.recordSparseHistogram(
"Tabs.TabOffsetOfSwitch." + GridTabSwitcherCoordinator.COMPONENT_NAME,
"Tabs.TabOffsetOfSwitch." + TabSwitcherCoordinator.COMPONENT_NAME,
fromIndex - toIndex);
}
}
......@@ -347,8 +345,7 @@ class GridTabSwitcherMediator implements GridTabSwitcher.GridController,
// here.
RecordUserAction.record("MobileTabSwitched");
}
RecordUserAction.record(
"MobileTabSwitched." + GridTabSwitcherCoordinator.COMPONENT_NAME);
RecordUserAction.record("MobileTabSwitched." + TabSwitcherCoordinator.COMPONENT_NAME);
}
}
......@@ -358,12 +355,12 @@ class GridTabSwitcherMediator implements GridTabSwitcher.GridController,
}
@Override
public void addOverviewModeObserver(GridTabSwitcher.GridOverviewModeObserver observer) {
public void addOverviewModeObserver(TabSwitcher.OverviewModeObserver observer) {
mObservers.addObserver(observer);
}
@Override
public void removeOverviewModeObserver(GridTabSwitcher.GridOverviewModeObserver observer) {
public void removeOverviewModeObserver(TabSwitcher.OverviewModeObserver observer) {
mObservers.removeObserver(observer);
}
......@@ -413,14 +410,14 @@ class GridTabSwitcherMediator implements GridTabSwitcher.GridController,
@Override
public void startedShowing(boolean isAnimating) {
for (GridTabSwitcher.GridOverviewModeObserver observer : mObservers) {
for (TabSwitcher.OverviewModeObserver observer : mObservers) {
observer.startedShowing();
}
}
@Override
public void finishedShowing() {
for (GridTabSwitcher.GridOverviewModeObserver observer : mObservers) {
for (TabSwitcher.OverviewModeObserver observer : mObservers) {
observer.finishedShowing();
}
setContentOverlayVisibility(false);
......@@ -429,14 +426,14 @@ class GridTabSwitcherMediator implements GridTabSwitcher.GridController,
@Override
public void startedHiding(boolean isAnimating) {
setContentOverlayVisibility(true);
for (GridTabSwitcher.GridOverviewModeObserver observer : mObservers) {
for (TabSwitcher.OverviewModeObserver observer : mObservers) {
observer.startedHiding();
}
}
@Override
public void finishedHiding() {
for (GridTabSwitcher.GridOverviewModeObserver observer : mObservers) {
for (TabSwitcher.OverviewModeObserver observer : mObservers) {
observer.finishedHiding();
}
}
......@@ -456,7 +453,7 @@ class GridTabSwitcherMediator implements GridTabSwitcher.GridController,
/**
* Do clean-up work after the overview hiding animation is finished.
* @see GridTabSwitcher#postHiding
* @see TabSwitcher#postHiding
*/
void postHiding() {
Log.d(TAG, "SoftCleanupDelay = " + getSoftCleanupDelay());
......@@ -489,7 +486,7 @@ class GridTabSwitcherMediator implements GridTabSwitcher.GridController,
mTabModelObserver);
}
void setOnTabSelectingListener(GridTabSwitcher.OnTabSelectingListener listener) {
void setOnTabSelectingListener(TabSwitcher.OnTabSelectingListener listener) {
mOnTabSelectingListener = listener;
}
......
......@@ -41,10 +41,10 @@ import org.chromium.ui.modelutil.PropertyModel;
import org.chromium.ui.modelutil.PropertyModelChangeProcessor;
/**
* Tests for {@link TabListRecyclerView} and {@link TabGridContainerViewBinder}
* Tests for {@link TabListRecyclerView} and {@link TabListContainerViewBinder}
*/
@RunWith(ChromeJUnit4ClassRunner.class)
public class TabGridContainerViewBinderTest extends DummyUiActivityTestCase {
public class TabListContainerViewBinderTest extends DummyUiActivityTestCase {
/**
* DummyUiActivityTestCase also needs {@link ChromeFeatureList}'s
* internal test-only feature map, not the {@link CommandLine} provided by
......@@ -54,7 +54,7 @@ public class TabGridContainerViewBinderTest extends DummyUiActivityTestCase {
public TestRule mProcessor = new Features.JUnitProcessor();
private static final int CONTAINER_HEIGHT = 56;
private TabGridContainerViewBinder mTabGridContainerViewHolder;
private TabListContainerViewBinder mTabListContainerViewHolder;
private PropertyModel mContainerModel;
private PropertyModelChangeProcessor mMCP;
private TabListRecyclerView mRecyclerView;
......@@ -110,7 +110,7 @@ public class TabGridContainerViewBinderTest extends DummyUiActivityTestCase {
mContainerModel = new PropertyModel(TabListContainerProperties.ALL_KEYS);
mMCP = PropertyModelChangeProcessor.create(
mContainerModel, mRecyclerView, TabGridContainerViewBinder::bind);
mContainerModel, mRecyclerView, TabListContainerViewBinder::bind);
}
@Test
......
......@@ -92,7 +92,7 @@ public class GridTabSwitcherMediatorUnitTest {
private static final int TAB4_ID = 357;
@Mock
GridTabSwitcherMediator.ResetHandler mResetHandler;
TabSwitcherMediator.ResetHandler mResetHandler;
@Mock
TabContentManager mTabContentManager;
@Mock
......@@ -112,7 +112,7 @@ public class GridTabSwitcherMediatorUnitTest {
@Mock
PropertyObservable.PropertyObserver<PropertyKey> mPropertyObserver;
@Mock
GridTabSwitcher.GridOverviewModeObserver mOverviewModeObserver;
TabSwitcher.OverviewModeObserver mOverviewModeObserver;
@Mock
CompositorViewHolder mCompositorViewHolder;
@Mock
......@@ -130,7 +130,7 @@ public class GridTabSwitcherMediatorUnitTest {
private Tab mTab1;
private Tab mTab2;
private Tab mTab3;
private GridTabSwitcherMediator mMediator;
private TabSwitcherMediator mMediator;
private PropertyModel mModel;
@Before
......@@ -182,7 +182,7 @@ public class GridTabSwitcherMediatorUnitTest {
mModel = new PropertyModel(TabListContainerProperties.ALL_KEYS);
mModel.addObserver(mPropertyObserver);
mMediator = new GridTabSwitcherMediator(mResetHandler, mModel, mTabModelSelector,
mMediator = new TabSwitcherMediator(mResetHandler, mModel, mTabModelSelector,
mFullscreenManager, mCompositorViewHolder, null);
mMediator.addOverviewModeObserver(mOverviewModeObserver);
mMediator.setOnTabSelectingListener(mLayout::onTabSelecting);
......@@ -229,10 +229,10 @@ public class GridTabSwitcherMediatorUnitTest {
assertThat(mMediator.overviewVisible(), equalTo(true));
assertThat(ShadowRecordHistogram.getHistogramValueCountForTesting(
GridTabSwitcherMediator.TAB_COUNT_HISTOGRAM, 3),
TabSwitcherMediator.TAB_COUNT_HISTOGRAM, 3),
equalTo(1));
assertThat(ShadowRecordHistogram.getHistogramValueCountForTesting(
GridTabSwitcherMediator.TAB_ENTRIES_HISTOGRAM, 3),
TabSwitcherMediator.TAB_ENTRIES_HISTOGRAM, 3),
equalTo(1));
}
......@@ -257,10 +257,10 @@ public class GridTabSwitcherMediatorUnitTest {
assertThat(mMediator.overviewVisible(), equalTo(true));
assertThat(ShadowRecordHistogram.getHistogramValueCountForTesting(
GridTabSwitcherMediator.TAB_COUNT_HISTOGRAM, 3),
TabSwitcherMediator.TAB_COUNT_HISTOGRAM, 3),
equalTo(1));
assertThat(ShadowRecordHistogram.getHistogramValueCountForTesting(
GridTabSwitcherMediator.TAB_ENTRIES_HISTOGRAM, 2),
TabSwitcherMediator.TAB_ENTRIES_HISTOGRAM, 2),
equalTo(1));
}
......@@ -489,7 +489,7 @@ public class GridTabSwitcherMediatorUnitTest {
private void initAndAssertAllProperties() {
assertThat(mModel.get(TabListContainerProperties.VISIBILITY_LISTENER),
instanceOf(GridTabSwitcherMediator.class));
instanceOf(TabSwitcherMediator.class));
assertThat(
mModel.get(TabListContainerProperties.ANIMATE_VISIBILITY_CHANGES), equalTo(true));
assertThat(mModel.get(TabListContainerProperties.IS_INCOGNITO),
......
......@@ -93,7 +93,7 @@ public class TabGridDialogMediatorUnitTest {
@Mock
TabCreatorManager.TabCreator mTabCreator;
@Mock
GridTabSwitcherMediator.ResetHandler mGridTabSwitcherResetHandler;
TabSwitcherMediator.ResetHandler mTabSwitcherResetHandler;
@Mock
TabGridDialogMediator.AnimationOriginProvider mAnimationOriginProvider;
@Mock
......@@ -160,7 +160,7 @@ public class TabGridDialogMediatorUnitTest {
mModel = new PropertyModel(TabGridSheetProperties.ALL_KEYS);
mMediator =
new TabGridDialogMediator(mContext, mDialogResetHandler, mModel, mTabModelSelector,
mTabCreatorManager, mGridTabSwitcherResetHandler, mAnimationOriginProvider);
mTabCreatorManager, mTabSwitcherResetHandler, mAnimationOriginProvider);
}
@After
......@@ -251,7 +251,7 @@ public class TabGridDialogMediatorUnitTest {
// Current tab ID should not update.
assertThat(mMediator.getCurrentTabIdForTest(), equalTo(TAB1_ID));
assertThat(mModel.get(TabGridSheetProperties.HEADER_TITLE), equalTo(DIALOG_TITLE1));
verify(mGridTabSwitcherResetHandler).resetWithTabList(mTabGroupModelFilter, false);
verify(mTabSwitcherResetHandler).resetWithTabList(mTabGroupModelFilter, false);
}
@Test
......@@ -271,7 +271,7 @@ public class TabGridDialogMediatorUnitTest {
// Current tab ID should be updated to TAB1_ID now.
assertThat(mMediator.getCurrentTabIdForTest(), equalTo(TAB1_ID));
assertThat(mModel.get(TabGridSheetProperties.HEADER_TITLE), equalTo(DIALOG_TITLE1));
verify(mGridTabSwitcherResetHandler).resetWithTabList(mTabGroupModelFilter, false);
verify(mTabSwitcherResetHandler).resetWithTabList(mTabGroupModelFilter, false);
}
@Test
......@@ -289,7 +289,7 @@ public class TabGridDialogMediatorUnitTest {
assertThat(mMediator.getCurrentTabIdForTest(), equalTo(Tab.INVALID_TAB_ID));
assertThat(mModel.get(TabGridSheetProperties.ANIMATION_SOURCE_RECT), equalTo(null));
verify(mDialogResetHandler).resetWithListOfTabs(null);
verify(mGridTabSwitcherResetHandler, never()).resetWithTabList(mTabGroupModelFilter, false);
verify(mTabSwitcherResetHandler, never()).resetWithTabList(mTabGroupModelFilter, false);
}
@Test
......@@ -311,7 +311,7 @@ public class TabGridDialogMediatorUnitTest {
assertThat(mModel.get(TabGridSheetProperties.HEADER_TITLE), equalTo(DIALOG_TITLE1));
// Dialog should still be hidden.
assertThat(mModel.get(TabGridSheetProperties.IS_DIALOG_VISIBLE), equalTo(false));
verify(mGridTabSwitcherResetHandler, never()).resetWithTabList(mTabGroupModelFilter, false);
verify(mTabSwitcherResetHandler, never()).resetWithTabList(mTabGroupModelFilter, false);
}
@Test
......@@ -324,7 +324,7 @@ public class TabGridDialogMediatorUnitTest {
mTabModelObserverCaptor.getValue().tabClosureUndone(mTab1);
assertThat(mModel.get(TabGridSheetProperties.HEADER_TITLE), equalTo(DIALOG_TITLE1));
verify(mGridTabSwitcherResetHandler).resetWithTabList(mTabGroupModelFilter, false);
verify(mTabSwitcherResetHandler).resetWithTabList(mTabGroupModelFilter, false);
}
@Test
......@@ -339,7 +339,7 @@ public class TabGridDialogMediatorUnitTest {
assertThat(mModel.get(TabGridSheetProperties.HEADER_TITLE), equalTo(DIALOG_TITLE1));
// Dialog should still be hidden.
assertThat(mModel.get(TabGridSheetProperties.IS_DIALOG_VISIBLE), equalTo(false));
verify(mGridTabSwitcherResetHandler, never()).resetWithTabList(mTabGroupModelFilter, false);
verify(mTabSwitcherResetHandler, never()).resetWithTabList(mTabGroupModelFilter, false);
}
@Test
......
......@@ -8,18 +8,18 @@ import(
public_tab_management_java_sources = [
"//chrome/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/TasksSurface.java",
"//chrome/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_groups/TabGroupModelFilter.java",
"//chrome/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_management/GridTabSwitcher.java",
"//chrome/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_management/SilenceLintErrors.java",
"//chrome/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_management/TabGroupUi.java",
"//chrome/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_management/TabManagementDelegate.java",
"//chrome/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_management/TabManagementModuleProvider.java",
"//chrome/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_management/TabSwitcher.java",
]
public_tab_management_java_sources += start_surface_public_java_sources
tab_management_test_java_sources = [
"//chrome/android/features/tab_ui/javatests/src/org/chromium/chrome/browser/tasks/tab_management/TabGridContainerViewBinderTest.java",
"//chrome/android/features/tab_ui/javatests/src/org/chromium/chrome/browser/tasks/tab_management/TabGridDialogParentTest.java",
"//chrome/android/features/tab_ui/javatests/src/org/chromium/chrome/browser/tasks/tab_management/TabListContainerViewBinderTest.java",
"//chrome/android/features/tab_ui/javatests/src/org/chromium/chrome/browser/tasks/tab_management/TabListViewHolderTest.java",
"//chrome/android/features/tab_ui/javatests/src/org/chromium/chrome/browser/tasks/tab_management/TestRecyclerViewSimpleViewBinder.java",
]
......
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