Commit 5c9e2756 authored by Theresa's avatar Theresa Committed by Commit Bot

Revert "Add an undo closure snack bar in TabGridDialog"

This reverts commit 114425f8.

Reason for revert: Failing on x86 bots

Original change's description:
> Add an undo closure snack bar in TabGridDialog
> 
> This CL adds a snack bar to TabGridDialog that handles closure within
> dialog. Note that this change doesn't prevent the original snack bar
> from showing when closure happens, so there will be two snack bars
> showing when a closure happens within dialog. This issue will be
> addressed by later CLs.
> 
> Bug: 1119899
> Change-Id: If0e5b010996a80c9a111c8bf2cb8af44feb63124
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2368236
> Commit-Queue: Yue Zhang <yuezhanggg@chromium.org>
> Reviewed-by: Wei-Yin Chen (陳威尹) <wychen@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#801037}

TBR=wychen@chromium.org,yuezhanggg@chromium.org

Change-Id: I1c2ccc03142c50c203ec08817d8817cfa614b519
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1119899,1121363
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2373232Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Commit-Queue: Theresa  <twellington@chromium.org>
Cr-Commit-Position: refs/heads/master@{#801169}
parent 6ea9e1a8
...@@ -17,6 +17,10 @@ ...@@ -17,6 +17,10 @@
android:focusable="true" android:focusable="true"
android:focusableInTouchMode="true" android:focusableInTouchMode="true"
android:background="@drawable/tab_grid_dialog_background"> android:background="@drawable/tab_grid_dialog_background">
<!-- Ignore useless parents here for two reasons:
1. Content recyclerView and toolbar view will be added programmatically later.
2. We need to keep the LinearLayout so that we can animate the ungroup textView and shadow
imageView together. -->
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
...@@ -24,7 +28,8 @@ ...@@ -24,7 +28,8 @@
android:orientation="vertical" android:orientation="vertical"
android:layout_alignParentBottom="true" android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" android:layout_centerHorizontal="true"
android:visibility="invisible"> android:visibility="invisible"
tools:ignore="UselessParent">
<ImageView <ImageView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/toolbar_shadow_height" android:layout_height="@dimen/toolbar_shadow_height"
...@@ -41,13 +46,6 @@ ...@@ -41,13 +46,6 @@
android:background="@drawable/ungroup_bar_background" android:background="@drawable/ungroup_bar_background"
android:gravity="center" /> android:gravity="center" />
</LinearLayout> </LinearLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/dialog_snack_bar_container_view"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true">
</FrameLayout>
</RelativeLayout> </RelativeLayout>
<View <View
android:layout_width="match_parent" android:layout_width="match_parent"
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
package org.chromium.chrome.browser.tasks.tab_management; package org.chromium.chrome.browser.tasks.tab_management;
import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.graphics.Rect; import android.graphics.Rect;
import android.view.LayoutInflater; import android.view.LayoutInflater;
...@@ -21,7 +20,6 @@ import org.chromium.chrome.browser.share.ShareDelegate; ...@@ -21,7 +20,6 @@ import org.chromium.chrome.browser.share.ShareDelegate;
import org.chromium.chrome.browser.tab.Tab; import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.tabmodel.TabCreatorManager; import org.chromium.chrome.browser.tabmodel.TabCreatorManager;
import org.chromium.chrome.browser.tabmodel.TabModelSelector; import org.chromium.chrome.browser.tabmodel.TabModelSelector;
import org.chromium.chrome.browser.ui.messages.snackbar.SnackbarManager;
import org.chromium.chrome.tab_ui.R; import org.chromium.chrome.tab_ui.R;
import org.chromium.components.browser_ui.widget.scrim.ScrimCoordinator; import org.chromium.components.browser_ui.widget.scrim.ScrimCoordinator;
import org.chromium.ui.modelutil.PropertyModel; import org.chromium.ui.modelutil.PropertyModel;
...@@ -65,13 +63,10 @@ public class TabGridDialogCoordinator implements TabGridDialogMediator.DialogCon ...@@ -65,13 +63,10 @@ public class TabGridDialogCoordinator implements TabGridDialogMediator.DialogCon
mDialogView = containerView.findViewById(R.id.dialog_parent_view); mDialogView = containerView.findViewById(R.id.dialog_parent_view);
mDialogView.setupScrimCoordinator(scrimCoordinator); mDialogView.setupScrimCoordinator(scrimCoordinator);
} }
Activity activity = (Activity) context;
SnackbarManager snackbarManager =
new SnackbarManager(activity, mDialogView.getSnackBarContainer(), null);
mMediator = new TabGridDialogMediator(context, this, mModel, tabModelSelector, mMediator = new TabGridDialogMediator(context, this, mModel, tabModelSelector,
tabCreatorManager, resetHandler, animationSourceViewProvider, shareDelegateSupplier, tabCreatorManager, resetHandler, animationSourceViewProvider, shareDelegateSupplier,
snackbarManager, mComponentName); mComponentName);
// TODO(crbug.com/1031349) : Remove the inline mode logic here, make the constructor to take // TODO(crbug.com/1031349) : Remove the inline mode logic here, make the constructor to take
// in a mode parameter instead. // in a mode parameter instead.
......
...@@ -35,8 +35,6 @@ import org.chromium.chrome.browser.tabmodel.TabModelObserver; ...@@ -35,8 +35,6 @@ import org.chromium.chrome.browser.tabmodel.TabModelObserver;
import org.chromium.chrome.browser.tabmodel.TabModelSelector; import org.chromium.chrome.browser.tabmodel.TabModelSelector;
import org.chromium.chrome.browser.tabmodel.TabModelSelectorObserver; import org.chromium.chrome.browser.tabmodel.TabModelSelectorObserver;
import org.chromium.chrome.browser.tasks.tab_groups.TabGroupModelFilter; import org.chromium.chrome.browser.tasks.tab_groups.TabGroupModelFilter;
import org.chromium.chrome.browser.ui.messages.snackbar.Snackbar;
import org.chromium.chrome.browser.ui.messages.snackbar.SnackbarManager;
import org.chromium.chrome.tab_ui.R; import org.chromium.chrome.tab_ui.R;
import org.chromium.components.browser_ui.share.ShareParams; import org.chromium.components.browser_ui.share.ShareParams;
import org.chromium.components.embedder_support.util.UrlConstants; import org.chromium.components.embedder_support.util.UrlConstants;
...@@ -51,7 +49,7 @@ import java.util.List; ...@@ -51,7 +49,7 @@ import java.util.List;
* with the components' coordinator as well as managing the business logic * with the components' coordinator as well as managing the business logic
* for dialog show/hide. * for dialog show/hide.
*/ */
public class TabGridDialogMediator implements SnackbarManager.SnackbarController { public class TabGridDialogMediator {
/** /**
* Defines an interface for a {@link TabGridDialogMediator} to control dialog. * Defines an interface for a {@link TabGridDialogMediator} to control dialog.
*/ */
...@@ -117,8 +115,7 @@ public class TabGridDialogMediator implements SnackbarManager.SnackbarController ...@@ -117,8 +115,7 @@ public class TabGridDialogMediator implements SnackbarManager.SnackbarController
TabModelSelector tabModelSelector, TabCreatorManager tabCreatorManager, TabModelSelector tabModelSelector, TabCreatorManager tabCreatorManager,
TabSwitcherMediator.ResetHandler tabSwitcherResetHandler, TabSwitcherMediator.ResetHandler tabSwitcherResetHandler,
AnimationSourceViewProvider animationSourceViewProvider, AnimationSourceViewProvider animationSourceViewProvider,
ObservableSupplier<ShareDelegate> shareDelegateSupplier, ObservableSupplier<ShareDelegate> shareDelegateSupplier, String componentName) {
SnackbarManager snackbarManager, String componentName) {
mContext = context; mContext = context;
mModel = model; mModel = model;
mTabModelSelector = tabModelSelector; mTabModelSelector = tabModelSelector;
...@@ -145,7 +142,6 @@ public class TabGridDialogMediator implements SnackbarManager.SnackbarController ...@@ -145,7 +142,6 @@ public class TabGridDialogMediator implements SnackbarManager.SnackbarController
public void tabClosureUndone(Tab tab) { public void tabClosureUndone(Tab tab) {
updateDialog(); updateDialog();
updateGridTabSwitcher(); updateGridTabSwitcher();
snackbarManager.dismissSnackbars(TabGridDialogMediator.this, tab.getId());
} }
@Override @Override
...@@ -172,22 +168,6 @@ public class TabGridDialogMediator implements SnackbarManager.SnackbarController ...@@ -172,22 +168,6 @@ public class TabGridDialogMediator implements SnackbarManager.SnackbarController
updateDialog(); updateDialog();
updateGridTabSwitcher(); updateGridTabSwitcher();
} }
@Override
public void tabPendingClosure(Tab tab) {
if (!mModel.get(TabGridPanelProperties.IS_DIALOG_VISIBLE)) return;
snackbarManager.showSnackbar(
Snackbar.make(tab.getTitle(), TabGridDialogMediator.this,
Snackbar.TYPE_ACTION, Snackbar.UMA_TAB_CLOSE_UNDO)
.setTemplateText(
mContext.getString(R.string.undo_bar_close_message))
.setAction(mContext.getString(R.string.undo), tab.getId()));
}
@Override
public void tabClosureCommitted(Tab tab) {
snackbarManager.dismissSnackbars(TabGridDialogMediator.this, tab.getId());
}
}; };
mTabModelSelectorObserver = new EmptyTabModelSelectorObserver() { mTabModelSelectorObserver = new EmptyTabModelSelectorObserver() {
...@@ -524,25 +504,6 @@ public class TabGridDialogMediator implements SnackbarManager.SnackbarController ...@@ -524,25 +504,6 @@ public class TabGridDialogMediator implements SnackbarManager.SnackbarController
return mTabGridDialogHandler; return mTabGridDialogHandler;
} }
// SnackbarManager.SnackbarController implementation.
@Override
public void onAction(Object actionData) {
int tabId = (int) actionData;
TabModel model = mTabModelSelector.getModelForTabId(tabId);
if (model != null) {
model.cancelTabClosure(tabId);
}
}
@Override
public void onDismissNoAction(Object actionData) {
int tabId = (int) actionData;
TabModel model = mTabModelSelector.getModelForTabId(tabId);
if (model != null) {
model.commitTabClosure(tabId);
}
}
/** /**
* A handler that handles TabGridDialog related changes originated from {@link TabListMediator} * A handler that handles TabGridDialog related changes originated from {@link TabListMediator}
* and {@link TabGridItemTouchHelperCallback}. * and {@link TabGridItemTouchHelperCallback}.
......
...@@ -74,7 +74,6 @@ public class TabGridDialogView extends FrameLayout ...@@ -74,7 +74,6 @@ public class TabGridDialogView extends FrameLayout
private View mAnimationCardView; private View mAnimationCardView;
private View mItemView; private View mItemView;
private View mUngroupBar; private View mUngroupBar;
private ViewGroup mSnackBarContainer;
private ViewGroup mParent; private ViewGroup mParent;
private TextView mUngroupBarTextView; private TextView mUngroupBarTextView;
private RelativeLayout mDialogContainerView; private RelativeLayout mDialogContainerView;
...@@ -158,7 +157,6 @@ public class TabGridDialogView extends FrameLayout ...@@ -158,7 +157,6 @@ public class TabGridDialogView extends FrameLayout
mBackgroundFrame = findViewById(R.id.dialog_frame); mBackgroundFrame = findViewById(R.id.dialog_frame);
mBackgroundFrame.setLayoutParams(mContainerParams); mBackgroundFrame.setLayoutParams(mContainerParams);
mAnimationCardView = findViewById(R.id.dialog_animation_card_view); mAnimationCardView = findViewById(R.id.dialog_animation_card_view);
mSnackBarContainer = findViewById(R.id.dialog_snack_bar_container_view);
updateDialogWithOrientation(mContext.getResources().getConfiguration().orientation); updateDialogWithOrientation(mContext.getResources().getConfiguration().orientation);
prepareAnimation(); prepareAnimation();
...@@ -676,7 +674,6 @@ public class TabGridDialogView extends FrameLayout ...@@ -676,7 +674,6 @@ public class TabGridDialogView extends FrameLayout
mDialogContainerView.addView(toolbarView); mDialogContainerView.addView(toolbarView);
mDialogContainerView.addView(recyclerView); mDialogContainerView.addView(recyclerView);
mDialogContainerView.addView(mUngroupBar); mDialogContainerView.addView(mUngroupBar);
mDialogContainerView.addView(mSnackBarContainer);
RelativeLayout.LayoutParams params = RelativeLayout.LayoutParams params =
(RelativeLayout.LayoutParams) recyclerView.getLayoutParams(); (RelativeLayout.LayoutParams) recyclerView.getLayoutParams();
params.setMargins(0, mToolbarHeight, 0, 0); params.setMargins(0, mToolbarHeight, 0, 0);
...@@ -807,13 +804,6 @@ public class TabGridDialogView extends FrameLayout ...@@ -807,13 +804,6 @@ public class TabGridDialogView extends FrameLayout
mUngroupBarTextAppearance = textAppearance; mUngroupBarTextAppearance = textAppearance;
} }
/**
* Return the container view for undo closure snack bar.
*/
ViewGroup getSnackBarContainer() {
return mSnackBarContainer;
}
@VisibleForTesting @VisibleForTesting
Animator getCurrentDialogAnimatorForTesting() { Animator getCurrentDialogAnimatorForTesting() {
return mCurrentDialogAnimator; return mCurrentDialogAnimator;
......
...@@ -52,7 +52,6 @@ import static org.chromium.chrome.browser.tasks.tab_management.TabUiTestHelper.v ...@@ -52,7 +52,6 @@ import static org.chromium.chrome.browser.tasks.tab_management.TabUiTestHelper.v
import static org.chromium.chrome.browser.tasks.tab_management.TabUiTestHelper.verifyTabSwitcherCardCount; import static org.chromium.chrome.browser.tasks.tab_management.TabUiTestHelper.verifyTabSwitcherCardCount;
import static org.chromium.chrome.features.start_surface.InstantStartTest.createTabStateFile; import static org.chromium.chrome.features.start_surface.InstantStartTest.createTabStateFile;
import static org.chromium.chrome.features.start_surface.InstantStartTest.createThumbnailBitmapAndWriteToFile; import static org.chromium.chrome.features.start_surface.InstantStartTest.createThumbnailBitmapAndWriteToFile;
import static org.chromium.chrome.test.util.ViewUtils.onViewWaiting;
import static org.chromium.chrome.test.util.ViewUtils.waitForView; import static org.chromium.chrome.test.util.ViewUtils.waitForView;
import android.content.Intent; import android.content.Intent;
...@@ -353,10 +352,7 @@ public class TabGridDialogTest { ...@@ -353,10 +352,7 @@ public class TabGridDialogTest {
// Exit dialog, wait for the undo bar showing and undo the closure. // Exit dialog, wait for the undo bar showing and undo the closure.
clickScrimToExitDialog(cta); clickScrimToExitDialog(cta);
waitForDialogHidingAnimationInTabSwitcher(cta); waitForDialogHidingAnimationInTabSwitcher(cta);
onViewWaiting( CriteriaHelper.pollInstrumentationThread(TabUiTestHelper::verifyUndoBarShowingAndClickUndo);
allOf(withId(R.id.snackbar_button), isDescendantOfA(withId(R.id.bottom_container)),
isCompletelyDisplayed()))
.perform(click());
// Verify the undo has happened. // Verify the undo has happened.
verifyFirstCardTitle("2 tabs"); verifyFirstCardTitle("2 tabs");
...@@ -390,50 +386,13 @@ public class TabGridDialogTest { ...@@ -390,50 +386,13 @@ public class TabGridDialogTest {
// Exit dialog, wait for the undo bar showing and undo the closure. // Exit dialog, wait for the undo bar showing and undo the closure.
clickScrimToExitDialog(cta); clickScrimToExitDialog(cta);
waitForDialogHidingAnimation(cta); waitForDialogHidingAnimation(cta);
onViewWaiting( CriteriaHelper.pollInstrumentationThread(TabUiTestHelper::verifyUndoBarShowingAndClickUndo);
allOf(withId(R.id.snackbar_button), isDescendantOfA(withId(R.id.bottom_container)),
isCompletelyDisplayed()))
.perform(click());
// Verify the undo has happened. // Verify the undo has happened.
verifyTabStripFaviconCount(cta, 2); verifyTabStripFaviconCount(cta, 2);
openDialogFromStripAndVerify(cta, 2, null); openDialogFromStripAndVerify(cta, 2, null);
} }
@Test
@MediumTest
public void testUndoClosureInDialog_DialogUndoBar() throws ExecutionException {
final ChromeTabbedActivity cta = mActivityTestRule.getActivity();
createTabs(cta, false, 2);
enterTabSwitcher(cta);
verifyTabSwitcherCardCount(cta, 2);
mergeAllNormalTabsToAGroup(cta);
verifyTabSwitcherCardCount(cta, 1);
openDialogFromTabSwitcherAndVerify(cta, 2, null);
// Verify close and undo in dialog from tab switcher.
closeFirstTabInDialog();
verifyShowingDialog(cta, 1, null);
onViewWaiting(allOf(withId(R.id.snackbar_button),
isDescendantOfA(withId(R.id.dialog_snack_bar_container_view)),
isCompletelyDisplayed()))
.perform(click());
verifyShowingDialog(cta, 2, null);
// Verify close and undo in dialog from tab strip.
clickFirstTabInDialog(cta);
openDialogFromStripAndVerify(cta, 2, null);
closeFirstTabInDialog();
verifyShowingDialog(cta, 1, null);
onViewWaiting(allOf(withId(R.id.snackbar_button),
isDescendantOfA(withId(R.id.dialog_snack_bar_container_view)),
isCompletelyDisplayed()))
.perform(click());
verifyShowingDialog(cta, 2, null);
clickScrimToExitDialog(cta);
verifyTabStripFaviconCount(cta, 2);
}
@Test @Test
@MediumTest @MediumTest
@Features.EnableFeatures(ChromeFeatureList.TAB_GROUPS_CONTINUATION_ANDROID) @Features.EnableFeatures(ChromeFeatureList.TAB_GROUPS_CONTINUATION_ANDROID)
......
...@@ -131,9 +131,8 @@ public class TabGridDialogViewTest extends DummyUiActivityTestCase { ...@@ -131,9 +131,8 @@ public class TabGridDialogViewTest extends DummyUiActivityTestCase {
mTabGridDialogView.resetDialog(toolbarView, recyclerView); mTabGridDialogView.resetDialog(toolbarView, recyclerView);
// It should contain four child views: top tool bar, recyclerview, ungroup bar and undo bar // It should contain three child views: top tool bar, recyclerview and ungroup bar.
// container. Assert.assertEquals(3, mTabGridDialogContainer.getChildCount());
Assert.assertEquals(4, mTabGridDialogContainer.getChildCount());
Assert.assertEquals(View.VISIBLE, recyclerView.getVisibility()); Assert.assertEquals(View.VISIBLE, recyclerView.getVisibility());
RelativeLayout.LayoutParams params = RelativeLayout.LayoutParams params =
(RelativeLayout.LayoutParams) recyclerView.getLayoutParams(); (RelativeLayout.LayoutParams) recyclerView.getLayoutParams();
......
...@@ -57,8 +57,6 @@ import org.chromium.chrome.browser.tabmodel.TabModelFilterProvider; ...@@ -57,8 +57,6 @@ import org.chromium.chrome.browser.tabmodel.TabModelFilterProvider;
import org.chromium.chrome.browser.tabmodel.TabModelObserver; import org.chromium.chrome.browser.tabmodel.TabModelObserver;
import org.chromium.chrome.browser.tabmodel.TabModelSelectorImpl; import org.chromium.chrome.browser.tabmodel.TabModelSelectorImpl;
import org.chromium.chrome.browser.tasks.tab_groups.TabGroupModelFilter; import org.chromium.chrome.browser.tasks.tab_groups.TabGroupModelFilter;
import org.chromium.chrome.browser.ui.messages.snackbar.Snackbar;
import org.chromium.chrome.browser.ui.messages.snackbar.SnackbarManager;
import org.chromium.chrome.tab_ui.R; import org.chromium.chrome.tab_ui.R;
import org.chromium.chrome.test.util.browser.Features; import org.chromium.chrome.test.util.browser.Features;
import org.chromium.content_public.browser.LoadUrlParams; import org.chromium.content_public.browser.LoadUrlParams;
...@@ -130,8 +128,6 @@ public class TabGridDialogMediatorUnitTest { ...@@ -130,8 +128,6 @@ public class TabGridDialogMediatorUnitTest {
Editable mEditable; Editable mEditable;
@Mock @Mock
ObservableSupplier<ShareDelegate> mShareDelegateSupplier; ObservableSupplier<ShareDelegate> mShareDelegateSupplier;
@Mock
SnackbarManager mSnackbarManager;
@Captor @Captor
ArgumentCaptor<TabModelObserver> mTabModelObserverCaptor; ArgumentCaptor<TabModelObserver> mTabModelObserverCaptor;
...@@ -196,7 +192,7 @@ public class TabGridDialogMediatorUnitTest { ...@@ -196,7 +192,7 @@ public class TabGridDialogMediatorUnitTest {
mModel = new PropertyModel(TabGridPanelProperties.ALL_KEYS); mModel = new PropertyModel(TabGridPanelProperties.ALL_KEYS);
mMediator = new TabGridDialogMediator(mContext, mDialogController, mModel, mMediator = new TabGridDialogMediator(mContext, mDialogController, mModel,
mTabModelSelector, mTabCreatorManager, mTabSwitcherResetHandler, mTabModelSelector, mTabCreatorManager, mTabSwitcherResetHandler,
mAnimationSourceViewProvider, mShareDelegateSupplier, mSnackbarManager, ""); mAnimationSourceViewProvider, mShareDelegateSupplier, "");
// TabModelObserver is registered when native is ready. // TabModelObserver is registered when native is ready.
assertThat(mTabModelObserverCaptor.getAllValues().isEmpty(), equalTo(true)); assertThat(mTabModelObserverCaptor.getAllValues().isEmpty(), equalTo(true));
...@@ -605,7 +601,6 @@ public class TabGridDialogMediatorUnitTest { ...@@ -605,7 +601,6 @@ public class TabGridDialogMediatorUnitTest {
assertThat(mModel.get(TabGridPanelProperties.HEADER_TITLE), equalTo(DIALOG_TITLE1)); assertThat(mModel.get(TabGridPanelProperties.HEADER_TITLE), equalTo(DIALOG_TITLE1));
verify(mTabSwitcherResetHandler).resetWithTabList(mTabGroupModelFilter, false, false); verify(mTabSwitcherResetHandler).resetWithTabList(mTabGroupModelFilter, false, false);
verify(mSnackbarManager).dismissSnackbars(eq(mMediator), eq(TAB1_ID));
} }
@Test @Test
...@@ -628,7 +623,6 @@ public class TabGridDialogMediatorUnitTest { ...@@ -628,7 +623,6 @@ public class TabGridDialogMediatorUnitTest {
assertThat( assertThat(
mModel.get(TabGridPanelProperties.HEADER_TITLE), equalTo(CUSTOMIZED_DIALOG_TITLE)); mModel.get(TabGridPanelProperties.HEADER_TITLE), equalTo(CUSTOMIZED_DIALOG_TITLE));
verify(mTabSwitcherResetHandler).resetWithTabList(mTabGroupModelFilter, false, false); verify(mTabSwitcherResetHandler).resetWithTabList(mTabGroupModelFilter, false, false);
verify(mSnackbarManager).dismissSnackbars(eq(mMediator), eq(TAB2_ID));
} }
@Test @Test
...@@ -645,32 +639,6 @@ public class TabGridDialogMediatorUnitTest { ...@@ -645,32 +639,6 @@ public class TabGridDialogMediatorUnitTest {
assertThat(mModel.get(TabGridPanelProperties.IS_DIALOG_VISIBLE), equalTo(false)); assertThat(mModel.get(TabGridPanelProperties.IS_DIALOG_VISIBLE), equalTo(false));
verify(mTabSwitcherResetHandler, never()) verify(mTabSwitcherResetHandler, never())
.resetWithTabList(mTabGroupModelFilter, false, false); .resetWithTabList(mTabGroupModelFilter, false, false);
verify(mSnackbarManager).dismissSnackbars(eq(mMediator), eq(TAB1_ID));
}
@Test
public void tabClosureCommitted() {
mTabModelObserverCaptor.getValue().tabClosureCommitted(mTab1);
verify(mSnackbarManager).dismissSnackbars(eq(mMediator), eq(TAB1_ID));
}
@Test
public void tabPendingClosure_DialogVisible() {
mModel.set(TabGridPanelProperties.IS_DIALOG_VISIBLE, true);
mTabModelObserverCaptor.getValue().tabPendingClosure(mTab1);
verify(mSnackbarManager).showSnackbar(any(Snackbar.class));
}
@Test
public void tabPendingClosure_DialogInVisible() {
mModel.set(TabGridPanelProperties.IS_DIALOG_VISIBLE, false);
mTabModelObserverCaptor.getValue().tabPendingClosure(mTab1);
verify(mSnackbarManager, never()).showSnackbar(any(Snackbar.class));
} }
@Test @Test
...@@ -914,7 +882,7 @@ public class TabGridDialogMediatorUnitTest { ...@@ -914,7 +882,7 @@ public class TabGridDialogMediatorUnitTest {
// the animationParamsProvider is null. // the animationParamsProvider is null.
mMediator = new TabGridDialogMediator(mContext, mDialogController, mModel, mMediator = new TabGridDialogMediator(mContext, mDialogController, mModel,
mTabModelSelector, mTabCreatorManager, mTabSwitcherResetHandler, null, mTabModelSelector, mTabCreatorManager, mTabSwitcherResetHandler, null,
mShareDelegateSupplier, mSnackbarManager, ""); mShareDelegateSupplier, "");
mMediator.initWithNative(mTabSelectionEditorController, mTabGroupTitleEditor); mMediator.initWithNative(mTabSelectionEditorController, mTabGroupTitleEditor);
// Mock that the dialog is hidden and animation source view, header title and scrim click // Mock that the dialog is hidden and animation source view, header title and scrim click
...@@ -945,7 +913,7 @@ public class TabGridDialogMediatorUnitTest { ...@@ -945,7 +913,7 @@ public class TabGridDialogMediatorUnitTest {
// the animationParamsProvider is null. // the animationParamsProvider is null.
mMediator = new TabGridDialogMediator(mContext, mDialogController, mModel, mMediator = new TabGridDialogMediator(mContext, mDialogController, mModel,
mTabModelSelector, mTabCreatorManager, mTabSwitcherResetHandler, null, mTabModelSelector, mTabCreatorManager, mTabSwitcherResetHandler, null,
mShareDelegateSupplier, mSnackbarManager, ""); mShareDelegateSupplier, "");
mMediator.initWithNative(mTabSelectionEditorController, mTabGroupTitleEditor); mMediator.initWithNative(mTabSelectionEditorController, mTabGroupTitleEditor);
// Mock that the dialog is hidden and animation source view, header title and scrim click // Mock that the dialog is hidden and animation source view, header title and scrim click
// runnable are all null. // runnable are all null.
...@@ -979,7 +947,7 @@ public class TabGridDialogMediatorUnitTest { ...@@ -979,7 +947,7 @@ public class TabGridDialogMediatorUnitTest {
// the animationParamsProvider is null. // the animationParamsProvider is null.
mMediator = new TabGridDialogMediator(mContext, mDialogController, mModel, mMediator = new TabGridDialogMediator(mContext, mDialogController, mModel,
mTabModelSelector, mTabCreatorManager, mTabSwitcherResetHandler, null, mTabModelSelector, mTabCreatorManager, mTabSwitcherResetHandler, null,
mShareDelegateSupplier, mSnackbarManager, ""); mShareDelegateSupplier, "");
mMediator.initWithNative(mTabSelectionEditorController, mTabGroupTitleEditor); mMediator.initWithNative(mTabSelectionEditorController, mTabGroupTitleEditor);
// Mock that the dialog is hidden and animation source view is set to some mock view for // Mock that the dialog is hidden and animation source view is set to some mock view for
// testing purpose. // testing purpose.
...@@ -1043,24 +1011,6 @@ public class TabGridDialogMediatorUnitTest { ...@@ -1043,24 +1011,6 @@ public class TabGridDialogMediatorUnitTest {
assertThat(shareString2, equalTo(mMediator.getTabGroupStringForSharingForTesting())); assertThat(shareString2, equalTo(mMediator.getTabGroupStringForSharingForTesting()));
} }
@Test
public void testSnackbarController_onAction() {
doReturn(mTabModel).when(mTabModelSelector).getModelForTabId(TAB1_ID);
mMediator.onAction(TAB1_ID);
verify(mTabModel).cancelTabClosure(eq(TAB1_ID));
}
@Test
public void testSnackbarController_onDismissNoAction() {
doReturn(mTabModel).when(mTabModelSelector).getModelForTabId(TAB1_ID);
mMediator.onDismissNoAction(TAB1_ID);
verify(mTabModel).commitTabClosure(eq(TAB1_ID));
}
@Test @Test
public void destroy() { public void destroy() {
mMediator.destroy(); mMediator.destroy();
......
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