Commit 58a93801 authored by Anna Malova's avatar Anna Malova Committed by Commit Bot

Fix tests which fail when animation is disabled.

Bug: 878176
Change-Id: I93ccf352800b60caadbc2a20d857d6122e634789
Reviewed-on: https://chromium-review.googlesource.com/1199487Reviewed-by: default avatarBernhard Bauer <bauerb@chromium.org>
Reviewed-by: default avatarPeter Conn <peconn@chromium.org>
Commit-Queue: Anna Malova <amalova@chromium.org>
Cr-Commit-Position: refs/heads/master@{#588415}
parent e187144a
...@@ -267,6 +267,12 @@ public class ChromeAnimation<T> { ...@@ -267,6 +267,12 @@ public class ChromeAnimation<T> {
} }
} }
public static void unsetAnimationMultiplierForTesting() {
synchronized (sLock) {
sAnimationMultiplier = null;
}
}
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public static float getAnimationMultiplier() { public static float getAnimationMultiplier() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) return 1f; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) return 1f;
......
...@@ -5,9 +5,11 @@ ...@@ -5,9 +5,11 @@
package org.chromium.chrome.browser.infobar; package org.chromium.chrome.browser.infobar;
import android.content.Context; import android.content.Context;
import android.support.annotation.Nullable;
import android.view.View; import android.view.View;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.download.DownloadInfoBarController;
import org.chromium.chrome.browser.download.DownloadManagerService; import org.chromium.chrome.browser.download.DownloadManagerService;
import org.chromium.chrome.browser.feature_engagement.TrackerFactory; import org.chromium.chrome.browser.feature_engagement.TrackerFactory;
import org.chromium.chrome.browser.infobar.IPHInfoBarSupport.PopupState; import org.chromium.chrome.browser.infobar.IPHInfoBarSupport.PopupState;
...@@ -65,15 +67,16 @@ class IPHBubbleDelegateImpl implements IPHInfoBarSupport.IPHBubbleDelegate { ...@@ -65,15 +67,16 @@ class IPHBubbleDelegateImpl implements IPHInfoBarSupport.IPHBubbleDelegate {
} }
} }
private TrackerParameters getTrackerParameters(@InfoBarIdentifier int infoBarId) { private @Nullable TrackerParameters getTrackerParameters(@InfoBarIdentifier int infoBarId) {
switch (infoBarId) { switch (infoBarId) {
case InfoBarIdentifier.DATA_REDUCTION_PROXY_PREVIEW_INFOBAR_DELEGATE: case InfoBarIdentifier.DATA_REDUCTION_PROXY_PREVIEW_INFOBAR_DELEGATE:
return new TrackerParameters(FeatureConstants.DATA_SAVER_PREVIEW_FEATURE, return new TrackerParameters(FeatureConstants.DATA_SAVER_PREVIEW_FEATURE,
R.string.iph_data_saver_preview_text, R.string.iph_data_saver_preview_text); R.string.iph_data_saver_preview_text, R.string.iph_data_saver_preview_text);
case InfoBarIdentifier.DOWNLOAD_PROGRESS_INFOBAR_ANDROID: case InfoBarIdentifier.DOWNLOAD_PROGRESS_INFOBAR_ANDROID:
return DownloadManagerService.getDownloadManagerService() DownloadInfoBarController controller =
.getInfoBarController(Profile.getLastUsedProfile().isOffTheRecord()) DownloadManagerService.getDownloadManagerService()
.getTrackerParameters(); .getInfoBarController(Profile.getLastUsedProfile().isOffTheRecord());
return controller != null ? controller.getTrackerParameters() : null;
default: default:
return null; return null;
} }
......
...@@ -82,17 +82,14 @@ public class AutofillProfileEditorPreference extends Preference { ...@@ -82,17 +82,14 @@ public class AutofillProfileEditorPreference extends Preference {
if (mGUID != null) { if (mGUID != null) {
mAutofillAddress = new AutofillAddress( mAutofillAddress = new AutofillAddress(
mActivity, PersonalDataManager.getInstance().getProfile(mGUID)); mActivity, PersonalDataManager.getInstance().getProfile(mGUID));
runnable = new Runnable() { runnable = () -> {
@Override if (mGUID != null) {
public void run() { PersonalDataManager.getInstance().deleteProfile(mGUID);
if (mGUID != null) { SettingsAutofillAndPaymentsObserver.getInstance().notifyOnAddressDeleted(
PersonalDataManager.getInstance().deleteProfile(mGUID); mGUID);
SettingsAutofillAndPaymentsObserver.getInstance().notifyOnAddressDeleted( }
mGUID); if (mObserverForTest != null) {
} mObserverForTest.onEditorReadyToEdit();
if (mObserverForTest != null) {
mObserverForTest.onEditorReadyToEdit();
}
} }
}; };
} }
......
...@@ -10,6 +10,7 @@ import android.os.SystemClock; ...@@ -10,6 +10,7 @@ import android.os.SystemClock;
import android.support.annotation.IntDef; import android.support.annotation.IntDef;
import android.support.test.filters.SmallTest; import android.support.test.filters.SmallTest;
import org.junit.After;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
...@@ -46,6 +47,12 @@ public class ChromeAnimationTest implements Animatable { ...@@ -46,6 +47,12 @@ public class ChromeAnimationTest implements Animatable {
public void setUp() throws Exception { public void setUp() throws Exception {
mHasFinishedFastAnimation = false; mHasFinishedFastAnimation = false;
mHasFinishedSlowAnimation = false; mHasFinishedSlowAnimation = false;
ChromeAnimation.Animation.setAnimationMultiplierForTesting(1f);
}
@After
public void tearDown() {
ChromeAnimation.Animation.unsetAnimationMultiplierForTesting();
} }
@Override @Override
......
...@@ -79,23 +79,13 @@ public class ContextMenuTest implements CustomMainActivityStart { ...@@ -79,23 +79,13 @@ public class ContextMenuTest implements CustomMainActivityStart {
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
ThreadUtils.runOnUiThreadBlocking(new Runnable() { ThreadUtils.runOnUiThreadBlocking(() -> FirstRunStatus.setFirstRunFlowComplete(true));
@Override
public void run() {
FirstRunStatus.setFirstRunFlowComplete(true);
}
});
} }
@After @After
public void tearDown() throws Exception { public void tearDown() throws Exception {
mTestServer.stopAndDestroyServer(); mTestServer.stopAndDestroyServer();
ThreadUtils.runOnUiThreadBlocking(new Runnable() { ThreadUtils.runOnUiThreadBlocking(() -> FirstRunStatus.setFirstRunFlowComplete(false));
@Override
public void run() {
FirstRunStatus.setFirstRunFlowComplete(false);
}
});
deleteTestFiles(); deleteTestFiles();
} }
......
...@@ -322,7 +322,7 @@ public class DownloadTest implements CustomMainActivityStart { ...@@ -322,7 +322,7 @@ public class DownloadTest implements CustomMainActivityStart {
final int count = model.getCount(); final int count = model.getCount();
InstrumentationRegistry.getInstrumentation().runOnMainSync( InstrumentationRegistry.getInstrumentation().runOnMainSync(
(Runnable) () -> TabModelUtils.setIndex(model, count - 1)); () -> TabModelUtils.setIndex(model, count - 1));
CriteriaHelper.pollUiThread(new Criteria() { CriteriaHelper.pollUiThread(new Criteria() {
@Override @Override
...@@ -353,7 +353,7 @@ public class DownloadTest implements CustomMainActivityStart { ...@@ -353,7 +353,7 @@ public class DownloadTest implements CustomMainActivityStart {
@Override @Override
public boolean isSatisfied() { public boolean isSatisfied() {
CompositorViewHolder compositorViewHolder = CompositorViewHolder compositorViewHolder =
(CompositorViewHolder) mDownloadTestRule.getActivity().findViewById( mDownloadTestRule.getActivity().findViewById(
R.id.compositor_view_holder); R.id.compositor_view_holder);
LayoutManager layoutManager = compositorViewHolder.getLayoutManager(); LayoutManager layoutManager = compositorViewHolder.getLayoutManager();
......
...@@ -50,16 +50,16 @@ class AutofillTestRule extends ChromeBrowserTestRule implements EditorObserverFo ...@@ -50,16 +50,16 @@ class AutofillTestRule extends ChromeBrowserTestRule implements EditorObserverFo
protected void clickInEditorAndWait(final int resourceId) protected void clickInEditorAndWait(final int resourceId)
throws InterruptedException, TimeoutException { throws InterruptedException, TimeoutException {
int callCount = mClickUpdate.getCallCount(); int callCount = mClickUpdate.getCallCount();
ThreadUtils.runOnUiThreadBlocking( ThreadUtils.runOnUiThreadBlockingNoException(
(Runnable) () -> mEditorDialog.findViewById(resourceId).performClick()); () -> mEditorDialog.findViewById(resourceId).performClick());
mClickUpdate.waitForCallback(callCount); mClickUpdate.waitForCallback(callCount);
} }
protected void clickInEditorAndWaitForValidationError(final int resourceId) protected void clickInEditorAndWaitForValidationError(final int resourceId)
throws InterruptedException, TimeoutException { throws InterruptedException, TimeoutException {
int callCount = mValidationUpdate.getCallCount(); int callCount = mValidationUpdate.getCallCount();
ThreadUtils.runOnUiThreadBlocking( ThreadUtils.runOnUiThreadBlockingNoException(
(Runnable) () -> mEditorDialog.findViewById(resourceId).performClick()); () -> mEditorDialog.findViewById(resourceId).performClick());
mValidationUpdate.waitForCallback(callCount); mValidationUpdate.waitForCallback(callCount);
} }
...@@ -80,8 +80,11 @@ class AutofillTestRule extends ChromeBrowserTestRule implements EditorObserverFo ...@@ -80,8 +80,11 @@ class AutofillTestRule extends ChromeBrowserTestRule implements EditorObserverFo
mPreferenceUpdate.waitForCallback(callCount); mPreferenceUpdate.waitForCallback(callCount);
} }
protected void setEditorDialog(EditorDialog editorDialog) { protected void setEditorDialogAndWait(EditorDialog editorDialog)
throws TimeoutException, InterruptedException {
int callCount = mClickUpdate.getCallCount();
mEditorDialog = editorDialog; mEditorDialog = editorDialog;
mClickUpdate.waitForCallback(callCount);
} }
@Override @Override
......
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