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

Add null check for TabGridDialogResetHandler in GTS

https://crrev.com/c/1722779 This CL uses TabGridDialogResetHandler to
cancel dialog animation when tab model selection changes. However, the
reset handler can be null when #TabGroupUiImprovement flag is not
enabled. This CL fixes this issue.

Bug: 988362
Change-Id: Ic5f98ea97778617864f0e92c221a51739837d406
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1722208Reviewed-by: default avatarWei-Yin Chen (陳威尹) <wychen@chromium.org>
Commit-Queue: Yue Zhang <yuezhanggg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#681929}
parent f8842c88
......@@ -174,8 +174,10 @@ class GridTabSwitcherMediator implements GridTabSwitcher.GridController,
mTabModelSelector.getTabModelFilterProvider().getCurrentTabModelFilter();
mResetHandler.resetWithTabList(currentTabModelFilter, false);
mContainerViewModel.set(IS_INCOGNITO, currentTabModelFilter.isIncognito());
if (mTabGridDialogResetHandler != null) {
mTabGridDialogResetHandler.hideDialog(false);
}
}
};
mTabModelSelector.addObserver(mTabModelSelectorObserver);
......
......@@ -182,7 +182,6 @@ public class GridTabSwitcherMediatorUnitTest {
mFullscreenManager, mCompositorViewHolder, null);
mMediator.addOverviewModeObserver(mOverviewModeObserver);
mMediator.setOnTabSelectingListener(mLayout::onTabSelecting);
mMediator.setTabGridDialogResetHandler(mTabGridDialogResetHandler);
}
@After
......@@ -264,6 +263,7 @@ public class GridTabSwitcherMediatorUnitTest {
@Test
public void hidesWithAnimation() {
initAndAssertAllProperties();
mMediator.setTabGridDialogResetHandler(mTabGridDialogResetHandler);
mMediator.showOverview(true);
assertThat(
......@@ -282,6 +282,7 @@ public class GridTabSwitcherMediatorUnitTest {
@Test
public void hidesWithoutAnimation() {
initAndAssertAllProperties();
mMediator.setTabGridDialogResetHandler(mTabGridDialogResetHandler);
mMediator.showOverview(true);
assertThat(
......@@ -344,8 +345,10 @@ public class GridTabSwitcherMediatorUnitTest {
}
@Test
public void resetsAfterNewTabModelSelected() {
public void resetsAfterNewTabModelSelected_DialogEnabled() {
initAndAssertAllProperties();
// Setup dialog reset handler. Default setup is that dialog handler is null.
mMediator.setTabGridDialogResetHandler(mTabGridDialogResetHandler);
doReturn(true).when(mTabModelFilter).isIncognito();
mTabModelSelectorObserverCaptor.getValue().onTabModelSelected(mTabModel, null);
......@@ -357,6 +360,20 @@ public class GridTabSwitcherMediatorUnitTest {
assertThat(mModel.get(TabListContainerProperties.IS_VISIBLE), equalTo(false));
}
@Test
public void resetsAfterNewTabModelSelected_DialogNotEnabled() {
initAndAssertAllProperties();
doReturn(true).when(mTabModelFilter).isIncognito();
mTabModelSelectorObserverCaptor.getValue().onTabModelSelected(mTabModel, null);
verify(mResetHandler).resetWithTabList(eq(mTabModelFilter), eq(false));
verify(mTabGridDialogResetHandler, never()).hideDialog(eq(false));
assertThat(mModel.get(TabListContainerProperties.IS_INCOGNITO), equalTo(true));
// Switching TabModels by itself shouldn't cause visibility changes.
assertThat(mModel.get(TabListContainerProperties.IS_VISIBLE), equalTo(false));
}
@Test
public void updatesMarginWithBottomBarChanges() {
initAndAssertAllProperties();
......
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