Commit 7d61e42d authored by Pavel Yatsuk's avatar Pavel Yatsuk Committed by Commit Bot

Disable toolbar animation for ChromeTabModalPresenterTest

Set animation duration to 0 to disable toolbar animations triggered by
displaying tab modal dialogs.

BUG=1026908
R=twellington@chromium.org

Change-Id: Idcc1fe2fc85f8ccccc3dad72a65da886e89fe9e8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2138556Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Commit-Queue: Pavel Yatsuk <pavely@chromium.org>
Cr-Commit-Position: refs/heads/master@{#757530}
parent 080bbab7
......@@ -32,6 +32,7 @@ import android.view.ViewGroup;
import org.hamcrest.Matchers;
import org.junit.Assert;
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
......@@ -62,6 +63,7 @@ import org.chromium.ui.modaldialog.ModalDialogManager;
import org.chromium.ui.modaldialog.ModalDialogManager.ModalDialogType;
import org.chromium.ui.modaldialog.ModalDialogProperties;
import org.chromium.ui.modelutil.PropertyModel;
import org.chromium.ui.test.util.DisableAnimationsTestRule;
import org.chromium.ui.test.util.UiRestriction;
/**
......@@ -93,6 +95,10 @@ public class ChromeTabModalPresenterTest {
}
}
// Disable animations to reduce flakiness.
@ClassRule
public static DisableAnimationsTestRule sNoAnimationsRule = new DisableAnimationsTestRule();
@Rule
public ChromeTabbedActivityTestRule mActivityTestRule = new ChromeTabbedActivityTestRule();
......@@ -114,7 +120,6 @@ public class ChromeTabModalPresenterTest {
.addUrlFocusChangeListener(mTestObserver);
mTabModalPresenter =
(ChromeTabModalPresenter) mManager.getPresenterForTest(ModalDialogType.TAB);
mTabModalPresenter.disableAnimationForTest();
}
@Test
......
......@@ -35,6 +35,7 @@ import org.chromium.ui.modelutil.PropertyModelChangeProcessor;
* Several abstract methods allow embedder-specific specializations.
*/
public abstract class TabModalPresenter extends ModalDialogManager.Presenter {
/** Enter and exit animation duration. */
private static final int ENTER_EXIT_ANIMATION_DURATION_MS = 200;
private final Context mContext;
......@@ -49,9 +50,6 @@ public abstract class TabModalPresenter extends ModalDialogManager.Presenter {
/** Whether the action bar on selected text is temporarily cleared for showing dialogs. */
private boolean mDidClearTextControls;
/** Enter and exit animation duration that can be overwritten in tests. */
private int mEnterExitAnimationDurationMs;
private class ViewBinder extends ModalDialogViewBinder {
@Override
public void bind(PropertyModel model, ModalDialogView view, PropertyKey propertyKey) {
......@@ -76,7 +74,6 @@ public abstract class TabModalPresenter extends ModalDialogManager.Presenter {
*/
public TabModalPresenter(Context context) {
mContext = context;
mEnterExitAnimationDurationMs = ENTER_EXIT_ANIMATION_DURATION_MS;
}
/**
......@@ -206,7 +203,7 @@ public abstract class TabModalPresenter extends ModalDialogManager.Presenter {
mDialogContainer.setAlpha(0f);
mDialogContainer.setVisibility(View.VISIBLE);
mDialogContainer.animate()
.setDuration(mEnterExitAnimationDurationMs)
.setDuration(ENTER_EXIT_ANIMATION_DURATION_MS)
.alpha(1f)
.setInterpolator(BakedBezierInterpolator.FADE_IN_CURVE)
.setListener(new AnimatorListenerAdapter() {
......@@ -224,7 +221,7 @@ public abstract class TabModalPresenter extends ModalDialogManager.Presenter {
dialogView.clearFocus();
mDialogContainer.animate().cancel();
mDialogContainer.animate()
.setDuration(mEnterExitAnimationDurationMs)
.setDuration(ENTER_EXIT_ANIMATION_DURATION_MS)
.alpha(0f)
.setInterpolator(BakedBezierInterpolator.FADE_OUT_CURVE)
.setListener(new AnimatorListenerAdapter() {
......@@ -241,9 +238,4 @@ public abstract class TabModalPresenter extends ModalDialogManager.Presenter {
public View getDialogContainerForTest() {
return mDialogContainer;
}
@VisibleForTesting
public void disableAnimationForTest() {
mEnterExitAnimationDurationMs = 0;
}
}
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