Commit 7219843d authored by Becky Zhou's avatar Becky Zhou Committed by Commit Bot

[Feed] Speculative fix for flaky render test on Feed NTP

+ NewTabPageTest#testRender_FocusFakeBox
+ NewTabPageTest#testRender_ArticleSectionHeader

Bug: 888129, 888997
Change-Id: Ic7d66bf90c1fe0a42c22224a5a889a04e6ffb7d1
Reviewed-on: https://chromium-review.googlesource.com/1249129Reviewed-by: default avatarTheresa <twellington@chromium.org>
Commit-Queue: Becky Zhou <huayinz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#594880}
parent a0f151d4
...@@ -14,6 +14,7 @@ import android.view.ViewGroup.LayoutParams; ...@@ -14,6 +14,7 @@ import android.view.ViewGroup.LayoutParams;
import android.view.ViewGroup.MarginLayoutParams; import android.view.ViewGroup.MarginLayoutParams;
import org.chromium.base.ApiCompatibilityUtils; import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.VisibleForTesting;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.util.MathUtils; import org.chromium.chrome.browser.util.MathUtils;
import org.chromium.chrome.browser.widget.animation.CancelAwareAnimatorListener; import org.chromium.chrome.browser.widget.animation.CancelAwareAnimatorListener;
...@@ -134,6 +135,9 @@ public class ScrimView extends View implements View.OnClickListener { ...@@ -134,6 +135,9 @@ public class ScrimView extends View implements View.OnClickListener {
/** The current set of params affecting the scrim. */ /** The current set of params affecting the scrim. */
private ScrimParams mActiveParams; private ScrimParams mActiveParams;
/** The duration for the fading animation. This can be overridden for testing. */
private int mFadeDurationMs;
/** /**
* @param context An Android {@link Context} for creating the view. * @param context An Android {@link Context} for creating the view.
* @param scrimDelegate A means of changing the scrim over the status bar. * @param scrimDelegate A means of changing the scrim over the status bar.
...@@ -146,6 +150,7 @@ public class ScrimView extends View implements View.OnClickListener { ...@@ -146,6 +150,7 @@ public class ScrimView extends View implements View.OnClickListener {
mParent = parent; mParent = parent;
mDefaultBackgroundColor = ApiCompatibilityUtils.getColor( mDefaultBackgroundColor = ApiCompatibilityUtils.getColor(
getResources(), R.color.omnibox_focused_fading_background_color); getResources(), R.color.omnibox_focused_fading_background_color);
mFadeDurationMs = FADE_DURATION_MS;
setAlpha(0.0f); setAlpha(0.0f);
setVisibility(View.GONE); setVisibility(View.GONE);
...@@ -245,7 +250,7 @@ public class ScrimView extends View implements View.OnClickListener { ...@@ -245,7 +250,7 @@ public class ScrimView extends View implements View.OnClickListener {
} }
if (mOverlayFadeInAnimator == null) { if (mOverlayFadeInAnimator == null) {
mOverlayFadeInAnimator = ObjectAnimator.ofFloat(this, ALPHA, 1f); mOverlayFadeInAnimator = ObjectAnimator.ofFloat(this, ALPHA, 1f);
mOverlayFadeInAnimator.setDuration(FADE_DURATION_MS); mOverlayFadeInAnimator.setDuration(mFadeDurationMs);
mOverlayFadeInAnimator.setInterpolator(BakedBezierInterpolator.FADE_IN_CURVE); mOverlayFadeInAnimator.setInterpolator(BakedBezierInterpolator.FADE_IN_CURVE);
} }
...@@ -258,7 +263,7 @@ public class ScrimView extends View implements View.OnClickListener { ...@@ -258,7 +263,7 @@ public class ScrimView extends View implements View.OnClickListener {
public void hideScrim(boolean fadeOut) { public void hideScrim(boolean fadeOut) {
if (mOverlayFadeOutAnimator == null) { if (mOverlayFadeOutAnimator == null) {
mOverlayFadeOutAnimator = ObjectAnimator.ofFloat(this, ALPHA, 0f); mOverlayFadeOutAnimator = ObjectAnimator.ofFloat(this, ALPHA, 0f);
mOverlayFadeOutAnimator.setDuration(FADE_DURATION_MS); mOverlayFadeOutAnimator.setDuration(mFadeDurationMs);
mOverlayFadeOutAnimator.setInterpolator(BakedBezierInterpolator.FADE_OUT_CURVE); mOverlayFadeOutAnimator.setInterpolator(BakedBezierInterpolator.FADE_OUT_CURVE);
mOverlayFadeOutAnimator.addListener(new CancelAwareAnimatorListener() { mOverlayFadeOutAnimator.addListener(new CancelAwareAnimatorListener() {
@Override @Override
...@@ -296,4 +301,9 @@ public class ScrimView extends View implements View.OnClickListener { ...@@ -296,4 +301,9 @@ public class ScrimView extends View implements View.OnClickListener {
if (mActiveParams == null || mActiveParams.observer == null) return; if (mActiveParams == null || mActiveParams.observer == null) return;
mActiveParams.observer.onScrimClick(); mActiveParams.observer.onScrimClick();
} }
@VisibleForTesting
public void disableAnimationForTesting(boolean disable) {
mFadeDurationMs = disable ? 0 : FADE_DURATION_MS;
}
} }
...@@ -61,6 +61,7 @@ import org.chromium.chrome.browser.preferences.PrefServiceBridge; ...@@ -61,6 +61,7 @@ import org.chromium.chrome.browser.preferences.PrefServiceBridge;
import org.chromium.chrome.browser.suggestions.SiteSuggestion; import org.chromium.chrome.browser.suggestions.SiteSuggestion;
import org.chromium.chrome.browser.tab.EmptyTabObserver; import org.chromium.chrome.browser.tab.EmptyTabObserver;
import org.chromium.chrome.browser.tab.Tab; import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.widget.ScrimView;
import org.chromium.chrome.test.ChromeJUnit4RunnerDelegate; import org.chromium.chrome.test.ChromeJUnit4RunnerDelegate;
import org.chromium.chrome.test.ChromeTabbedActivityTestRule; import org.chromium.chrome.test.ChromeTabbedActivityTestRule;
import org.chromium.chrome.test.util.ChromeTabUtils; import org.chromium.chrome.test.util.ChromeTabUtils;
...@@ -207,8 +208,12 @@ public class NewTabPageTest { ...@@ -207,8 +208,12 @@ public class NewTabPageTest {
@EnableFeatures({ChromeFeatureList.CONTENT_SUGGESTIONS_SCROLL_TO_LOAD}) @EnableFeatures({ChromeFeatureList.CONTENT_SUGGESTIONS_SCROLL_TO_LOAD})
@ParameterAnnotations.UseMethodParameter(InterestFeedParams.class) @ParameterAnnotations.UseMethodParameter(InterestFeedParams.class)
public void testRender_FocusFakeBox(boolean interestFeedEnabled) throws Exception { public void testRender_FocusFakeBox(boolean interestFeedEnabled) throws Exception {
ScrimView scrimView = mActivityTestRule.getActivity().getScrim();
scrimView.disableAnimationForTesting(true);
onView(withId(R.id.search_box)).perform(click()); onView(withId(R.id.search_box)).perform(click());
RenderTestRule.sanitize(mNtp.getView().getRootView());
mRenderTestRule.render(mNtp.getView().getRootView(), "focus_fake_box"); mRenderTestRule.render(mNtp.getView().getRootView(), "focus_fake_box");
scrimView.disableAnimationForTesting(false);
} }
@Test @Test
...@@ -225,10 +230,15 @@ public class NewTabPageTest { ...@@ -225,10 +230,15 @@ public class NewTabPageTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"NewTabPage", "FeedNewTabPage", "RenderTest"}) @Feature({"NewTabPage", "FeedNewTabPage", "RenderTest"})
@EnableFeatures({ChromeFeatureList.CONTENT_SUGGESTIONS_SCROLL_TO_LOAD})
@ParameterAnnotations.UseMethodParameter(InterestFeedParams.class) @ParameterAnnotations.UseMethodParameter(InterestFeedParams.class)
public void testRender_ArticleSectionHeader(boolean interestFeedEnabled) throws Exception { public void testRender_ArticleSectionHeader(boolean interestFeedEnabled) throws Exception {
// Scroll to the article section header in case it is not visible. // Scroll to the article section header in case it is not visible.
onView(instanceOf(RecyclerView.class)).perform(RecyclerViewActions.scrollToPosition(2)); onView(instanceOf(RecyclerView.class)).perform(RecyclerViewActions.scrollToPosition(2));
if (!interestFeedEnabled) {
RecyclerViewTestUtils.waitForStableRecyclerView(
mNtp.getNewTabPageView().getRecyclerView());
}
View view = mNtp.getSectionHeaderViewForTesting(); View view = mNtp.getSectionHeaderViewForTesting();
// Check header is expanded. // Check header is expanded.
...@@ -285,7 +295,6 @@ public class NewTabPageTest { ...@@ -285,7 +295,6 @@ public class NewTabPageTest {
*/ */
@Test @Test
@SmallTest @SmallTest
@DisabledTest(message = "https://crbug.com/888129")
@Feature({"NewTabPage", "FeedNewTabPage"}) @Feature({"NewTabPage", "FeedNewTabPage"})
@ParameterAnnotations.UseMethodParameter(InterestFeedParams.class) @ParameterAnnotations.UseMethodParameter(InterestFeedParams.class)
public void testFocusFakebox(boolean interestFeedEnabled) { public void testFocusFakebox(boolean interestFeedEnabled) {
......
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