Commit 4227807a authored by Arthur Wang's avatar Arthur Wang Committed by Commit Bot

Disable Signin Promo for Feed Card Render tests.

R=carlosk@chromium.org, harringtond@chromium.org

Bug: 1028976
Change-Id: I63e361cae052c1fb274cfefa9791b20ea9f596cf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1949449Reviewed-by: default avatarDan H <harringtond@chromium.org>
Commit-Queue: Arthur Wang <wuwang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#721578}
parent 559a78d5
......@@ -18,6 +18,7 @@ import org.chromium.base.test.util.UrlUtils;
import org.chromium.chrome.browser.feed.library.api.client.stream.Stream;
import org.chromium.chrome.browser.feed.library.hostimpl.storage.testing.InMemoryContentStorage;
import org.chromium.chrome.browser.feed.library.hostimpl.storage.testing.InMemoryJournalStorage;
import org.chromium.chrome.browser.ntp.cards.SignInPromo;
import org.chromium.content_public.browser.test.util.TestThreadUtils;
import java.io.IOException;
......@@ -65,10 +66,27 @@ import java.util.concurrent.TimeoutException;
*/
final class FeedDataInjectRule extends TestWatcher {
private static final String TAG = "FeedDataInjectRule";
public static final int FIRST_CARD_POSITION = 3;
private static final int FIRST_CARD_BASE_POSITION = 2;
private TestNetworkClient mClient;
private boolean mTestCaseDataFileInjected;
private int mFirstCardIndexOffset;
public FeedDataInjectRule(boolean disableSigninPromo) {
// Disable Signin Promo to disable flakiness due to uncertainty in Signin Promo loading.
// More context see crbug/1028997.
if (disableSigninPromo) {
SignInPromo.setDisablePromoForTests(true);
mFirstCardIndexOffset = 0;
} else {
// Once we enable Signin Promo, the FIRST_CARD_POSITION becomes 3.
mFirstCardIndexOffset = 1;
}
}
public int getFirstCardPosition() {
return FIRST_CARD_BASE_POSITION + mFirstCardIndexOffset;
}
@Override
protected void starting(Description desc) {
......@@ -124,7 +142,7 @@ final class FeedDataInjectRule extends TestWatcher {
@Override
public void onContentChanged() {
if (mRecyclerViewAdapter.getItemViewType(FIRST_CARD_POSITION) == TYPE_CARD) {
if (mRecyclerViewAdapter.getItemViewType(getFirstCardPosition()) == TYPE_CARD) {
firstCardShownCallback.notifyCalled();
}
}
......
......@@ -21,7 +21,6 @@ import org.junit.runner.RunWith;
import org.chromium.base.ThreadUtils;
import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.DisabledTest;
import org.chromium.base.test.util.Feature;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.ChromeFeatureList;
......@@ -67,7 +66,7 @@ public class FeedNewTabPageCardRenderTest {
new RenderTestRule("chrome/test/data/android/render_tests");
@Rule
public FeedDataInjectRule mFeedDataInjector = new FeedDataInjectRule();
public FeedDataInjectRule mFeedDataInjector = new FeedDataInjectRule(true);
@Rule
public EmbeddedTestServerRule mTestServer = new EmbeddedTestServerRule();
......@@ -96,7 +95,6 @@ public class FeedNewTabPageCardRenderTest {
Assert.assertEquals(mSiteSuggestions.size(), mTileGridLayout.getChildCount());
}
@DisabledTest(message = "crbug.com/1029059")
@Test
@MediumTest
@Feature({"FeedNewTabPage", "RenderTest"})
......@@ -110,8 +108,6 @@ public class FeedNewTabPageCardRenderTest {
SectionHeader firstHeader = mNtp.getMediatorForTesting().getSectionHeaderForTesting();
RecyclerView recycleView =
(RecyclerView) mNtp.getCoordinatorForTesting().getStream().getView();
RecyclerView.Adapter adapter1 =
((RecyclerView) mNtp.getCoordinatorForTesting().getStream().getView()).getAdapter();
// Check header is expanded.
Assert.assertTrue(firstHeader.isExpandable() && firstHeader.isExpanded());
......@@ -123,19 +119,23 @@ public class FeedNewTabPageCardRenderTest {
// Scroll to the first feed card.
onView(instanceOf(RecyclerView.class))
.perform(RecyclerViewActions.scrollToPosition(
FeedDataInjectRule.FIRST_CARD_POSITION));
mFeedDataInjector.getFirstCardPosition()));
RecyclerViewTestUtils.waitForStableRecyclerView(recycleView);
mRenderTestRule.render(
recycleView, String.format("render_feed_cards_top_%s", scenarioName));
// Scroll to the bottom.
RecyclerViewTestUtils.scrollToBottom(recycleView);
RecyclerViewTestUtils.waitForStableRecyclerView(recycleView);
mRenderTestRule.render(
recycleView, String.format("render_feed_cards_bottom_%s", scenarioName));
// Scroll to the first feed card again.
onView(instanceOf(RecyclerView.class))
.perform(RecyclerViewActions.scrollToPosition(
FeedDataInjectRule.FIRST_CARD_POSITION));
mFeedDataInjector.getFirstCardPosition()));
RecyclerViewTestUtils.waitForStableRecyclerView(recycleView);
mRenderTestRule.render(
recycleView, String.format("render_feed_cards_top_again_%s", scenarioName));
}
......
325b5db2c40e508b3607ab90aac9f4e283a84212
\ No newline at end of file
03ff57d50e9e4fdfbf4300819e52d0ee54ea2680
\ No newline at end of file
47b40ed19fbab4628fcde2db1b5b8e629d2c535e
\ No newline at end of file
61dbfc645c260bd4cbc4c2216f51666c1abbac50
\ No newline at end of file
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