Commit cad502cc authored by Theresa's avatar Theresa Committed by Commit Bot

Enable some FeedNewTabPage instrumentation tests

This reverts commit 79a6ffe5 and
introduces test implementations of the scheduler and network client.
These test implementations ensure the Feed stops trying to load content
so that Chrome can finish starting up.

BUG=854866

Change-Id: I41da8b433a7ab3b7a6786a3be2960598f3e3479e
Reviewed-on: https://chromium-review.googlesource.com/1162771
Commit-Queue: Theresa <twellington@chromium.org>
Reviewed-by: default avatarSky Malice <skym@chromium.org>
Reviewed-by: default avatarFilip Gorski <fgorski@chromium.org>
Cr-Commit-Position: refs/heads/master@{#581254}
parent ff89d6eb
...@@ -22,6 +22,7 @@ import com.google.android.libraries.feed.host.stream.SnackbarApi; ...@@ -22,6 +22,7 @@ import com.google.android.libraries.feed.host.stream.SnackbarApi;
import com.google.android.libraries.feed.host.stream.StreamConfiguration; import com.google.android.libraries.feed.host.stream.StreamConfiguration;
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.ChromeActivity; import org.chromium.chrome.browser.ChromeActivity;
import org.chromium.chrome.browser.NativePageHost; import org.chromium.chrome.browser.NativePageHost;
...@@ -256,4 +257,20 @@ public class FeedNewTabPage extends NewTabPage implements TouchEnabledDelegate { ...@@ -256,4 +257,20 @@ public class FeedNewTabPage extends NewTabPage implements TouchEnabledDelegate {
public void setTouchEnabled(boolean enabled) { public void setTouchEnabled(boolean enabled) {
// TODO(twellington): implement this method. // TODO(twellington): implement this method.
} }
/**
* Configures the {@link FeedNewTabPage} for testing.
* @param inTestMode Whether test mode is enabled. If true, test implementations of Feed
* interfaces will be used to create the {@link FeedProcessScope}. If false,
* the FeedProcessScope will be reset.
*/
@VisibleForTesting
public static void setInTestMode(boolean inTestMode) {
if (inTestMode) {
FeedProcessScopeFactory.createFeedProcessScopeForTesting(
new TestFeedScheduler(), new TestNetworkClient());
} else {
FeedProcessScopeFactory.clearFeedProcessScopeForTesting();
}
}
} }
...@@ -10,8 +10,10 @@ import com.google.android.libraries.feed.feedapplifecyclelistener.FeedAppLifecyc ...@@ -10,8 +10,10 @@ import com.google.android.libraries.feed.feedapplifecyclelistener.FeedAppLifecyc
import com.google.android.libraries.feed.host.config.Configuration; import com.google.android.libraries.feed.host.config.Configuration;
import com.google.android.libraries.feed.host.config.Configuration.ConfigKey; import com.google.android.libraries.feed.host.config.Configuration.ConfigKey;
import com.google.android.libraries.feed.host.config.DebugBehavior; import com.google.android.libraries.feed.host.config.DebugBehavior;
import com.google.android.libraries.feed.host.network.NetworkClient;
import com.google.android.libraries.feed.hostimpl.logging.LoggingApiImpl; import com.google.android.libraries.feed.hostimpl.logging.LoggingApiImpl;
import org.chromium.base.VisibleForTesting;
import org.chromium.chrome.browser.profiles.Profile; import org.chromium.chrome.browser.profiles.Profile;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
...@@ -21,7 +23,7 @@ import java.util.concurrent.Executors; ...@@ -21,7 +23,7 @@ import java.util.concurrent.Executors;
*/ */
public class FeedProcessScopeFactory { public class FeedProcessScopeFactory {
private static FeedProcessScope sFeedProcessScope; private static FeedProcessScope sFeedProcessScope;
private static FeedSchedulerBridge sFeedSchedulerBridge; private static FeedScheduler sFeedScheduler;
/** /**
* @return The shared {@link FeedProcessScope} instance. * @return The shared {@link FeedProcessScope} instance.
...@@ -36,33 +38,71 @@ public class FeedProcessScopeFactory { ...@@ -36,33 +38,71 @@ public class FeedProcessScopeFactory {
/** /**
* @return The {@link FeedSchedulerBridge} that was given to the {@link FeedProcessScope}. * @return The {@link FeedSchedulerBridge} that was given to the {@link FeedProcessScope}.
*/ */
public static FeedSchedulerBridge getFeedSchedulerBridge() { public static FeedScheduler getFeedSchedulerBridge() {
if (sFeedSchedulerBridge == null) { if (sFeedScheduler == null) {
initialize(); initialize();
} }
return sFeedSchedulerBridge; return sFeedScheduler;
} }
private static void initialize() { private static void initialize() {
assert sFeedSchedulerBridge == null && sFeedProcessScope == null; assert sFeedScheduler == null && sFeedProcessScope == null;
Profile profile = Profile.getLastUsedProfile().getOriginalProfile(); Profile profile = Profile.getLastUsedProfile().getOriginalProfile();
Configuration configHostApi = Configuration configHostApi = createConfiguration();
new Configuration.Builder()
.put(ConfigKey.FEED_SERVER_HOST, "https://www.google.com") FeedSchedulerBridge schedulerBridge = new FeedSchedulerBridge(profile);
.put(ConfigKey.FEED_SERVER_PATH_AND_PARAMS, sFeedScheduler = schedulerBridge;
"/httpservice/noretry/NowStreamService/FeedQuery")
.put(ConfigKey.SESSION_LIFETIME_MS, 300000L)
.build();
sFeedSchedulerBridge = new FeedSchedulerBridge(profile);
FeedAppLifecycleListener lifecycleListener = FeedAppLifecycleListener lifecycleListener =
new FeedAppLifecycleListener(new ThreadUtils()); new FeedAppLifecycleListener(new ThreadUtils());
sFeedProcessScope = sFeedProcessScope =
new FeedProcessScope new FeedProcessScope
.Builder(configHostApi, Executors.newSingleThreadExecutor(), .Builder(configHostApi, Executors.newSingleThreadExecutor(),
new LoggingApiImpl(), new FeedNetworkBridge(profile), new LoggingApiImpl(), new FeedNetworkBridge(profile),
sFeedSchedulerBridge, lifecycleListener, DebugBehavior.SILENT) schedulerBridge, lifecycleListener, DebugBehavior.SILENT)
.build(); .build();
sFeedSchedulerBridge.initializeFeedDependencies( schedulerBridge.initializeFeedDependencies(
sFeedProcessScope.getRequestManager(), sFeedProcessScope.getSessionManager()); sFeedProcessScope.getRequestManager(), sFeedProcessScope.getSessionManager());
} }
private static Configuration createConfiguration() {
return new Configuration.Builder()
.put(ConfigKey.FEED_SERVER_HOST, "https://www.google.com")
.put(ConfigKey.FEED_SERVER_PATH_AND_PARAMS,
"/httpservice/noretry/NowStreamService/FeedQuery")
.put(ConfigKey.SESSION_LIFETIME_MS, 300000L)
.build();
}
/**
* Creates a {@link FeedProcessScope} using the provided {@link FeedScheduler} and
* {@link NetworkClient}. Call {@link #clearFeedProcessScopeForTesting()} to reset the
* FeedProcessScope after testing is complete.
*
* @param feedScheduler A {@link FeedScheduler} to use for testing.
* @param networkClient A {@link NetworkClient} to use for testing.
*/
@VisibleForTesting
static void createFeedProcessScopeForTesting(
FeedScheduler feedScheduler, NetworkClient networkClient) {
Configuration configHostApi = createConfiguration();
FeedAppLifecycleListener lifecycleListener =
new FeedAppLifecycleListener(new ThreadUtils());
sFeedScheduler = feedScheduler;
sFeedProcessScope = new FeedProcessScope
.Builder(configHostApi, Executors.newSingleThreadExecutor(),
new LoggingApiImpl(), networkClient, sFeedScheduler,
lifecycleListener, DebugBehavior.SILENT)
.build();
}
/** Resets the FeedProcessScope after testing is complete. */
@VisibleForTesting
static void clearFeedProcessScopeForTesting() {
if (sFeedScheduler != null) {
sFeedScheduler.destroy();
sFeedScheduler = null;
}
sFeedProcessScope = null;
}
} }
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.chrome.browser.feed;
import com.google.android.libraries.feed.host.scheduler.SchedulerApi;
/**
* An extension of the {@link SchedulerApi} with additional methods needed for scheduling logic
* in Chromium.
*/
public interface FeedScheduler extends SchedulerApi {
void destroy();
void onForegrounded();
void onFixedTimer(Runnable onCompletion);
void onTaskReschedule();
void onSuggestionConsumed();
}
...@@ -22,7 +22,7 @@ import org.chromium.components.feed.NativeRequestBehavior; ...@@ -22,7 +22,7 @@ import org.chromium.components.feed.NativeRequestBehavior;
* Provides access to native implementations of SchedulerApi. * Provides access to native implementations of SchedulerApi.
*/ */
@JNINamespace("feed") @JNINamespace("feed")
public class FeedSchedulerBridge implements SchedulerApi { public class FeedSchedulerBridge implements FeedScheduler {
private long mNativeBridge; private long mNativeBridge;
private RequestManager mRequestManager; private RequestManager mRequestManager;
private SessionManager mSessionManager; private SessionManager mSessionManager;
...@@ -37,6 +37,7 @@ public class FeedSchedulerBridge implements SchedulerApi { ...@@ -37,6 +37,7 @@ public class FeedSchedulerBridge implements SchedulerApi {
} }
/** Cleans up the native half of this bridge. */ /** Cleans up the native half of this bridge. */
@Override
public void destroy() { public void destroy() {
assert mNativeBridge != 0; assert mNativeBridge != 0;
nativeDestroy(mNativeBridge); nativeDestroy(mNativeBridge);
...@@ -103,22 +104,26 @@ public class FeedSchedulerBridge implements SchedulerApi { ...@@ -103,22 +104,26 @@ public class FeedSchedulerBridge implements SchedulerApi {
nativeOnRequestError(mNativeBridge, networkResponseCode); nativeOnRequestError(mNativeBridge, networkResponseCode);
} }
@Override
public void onForegrounded() { public void onForegrounded() {
assert mNativeBridge != 0; assert mNativeBridge != 0;
nativeOnForegrounded(mNativeBridge); nativeOnForegrounded(mNativeBridge);
} }
@Override
public void onFixedTimer(Runnable onCompletion) { public void onFixedTimer(Runnable onCompletion) {
assert mNativeBridge != 0; assert mNativeBridge != 0;
// Convert to single argument Callback to make invoking from native more convenient. // Convert to single argument Callback to make invoking from native more convenient.
nativeOnFixedTimer(mNativeBridge, (Void ignored) -> onCompletion.run()); nativeOnFixedTimer(mNativeBridge, (Void ignored) -> onCompletion.run());
} }
@Override
public void onTaskReschedule() { public void onTaskReschedule() {
assert mNativeBridge != 0; assert mNativeBridge != 0;
nativeOnTaskReschedule(mNativeBridge); nativeOnTaskReschedule(mNativeBridge);
} }
@Override
public void onSuggestionConsumed() { public void onSuggestionConsumed() {
assert mNativeBridge != 0; assert mNativeBridge != 0;
nativeOnSuggestionConsumed(mNativeBridge); nativeOnSuggestionConsumed(mNativeBridge);
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.chrome.browser.feed;
import com.google.android.libraries.feed.host.scheduler.SchedulerApi;
/** A {@link FeedScheduler} implementation for use in testing. */
class TestFeedScheduler implements FeedScheduler {
@Override
public void destroy() {}
@Override
public void onForegrounded() {}
@Override
public void onFixedTimer(Runnable onCompletion) {}
@Override
public void onTaskReschedule() {}
@Override
public void onSuggestionConsumed() {}
@Override
public int shouldSessionRequestData(SessionManagerState sessionManagerState) {
return SchedulerApi.RequestBehavior.NO_REQUEST_WITH_CONTENT;
}
@Override
public void onReceiveNewContent(long contentCreationDateTimeMs) {}
@Override
public void onRequestError(int networkResponseCode) {}
}
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.chrome.browser.feed;
import com.google.android.libraries.feed.common.functional.Consumer;
import com.google.android.libraries.feed.host.network.HttpRequest;
import com.google.android.libraries.feed.host.network.HttpResponse;
import com.google.android.libraries.feed.host.network.NetworkClient;
/** A {@link NetworkClient} implementation for use in testing. */
class TestNetworkClient implements NetworkClient {
@Override
public void send(HttpRequest request, Consumer<HttpResponse> responseConsumer) {}
@Override
public void close() throws Exception {}
}
...@@ -23,4 +23,12 @@ public class FeedNewTabPage extends NewTabPage { ...@@ -23,4 +23,12 @@ public class FeedNewTabPage extends NewTabPage {
TabModelSelector tabModelSelector) { TabModelSelector tabModelSelector) {
super(activity, nativePageHost, tabModelSelector); super(activity, nativePageHost, tabModelSelector);
} }
/**
* Configures the FeedNewTabPage for testing.
* @param inTestMode Whether test mode is enabled. If true, test implementations of Feed
* interfaces will be used to create the {@link FeedProcessScope}. If false,
* the FeedProcessScope will be reset.
*/
public static void setInTestMode(boolean inTestMode) {}
} }
...@@ -19,9 +19,12 @@ if (enable_feed_in_chrome) { ...@@ -19,9 +19,12 @@ if (enable_feed_in_chrome) {
"//chrome/android/feed/core/java/src/org/chromium/chrome/browser/feed/FeedNewTabPageMediator.java", "//chrome/android/feed/core/java/src/org/chromium/chrome/browser/feed/FeedNewTabPageMediator.java",
"//chrome/android/feed/core/java/src/org/chromium/chrome/browser/feed/FeedProcessScopeFactory.java", "//chrome/android/feed/core/java/src/org/chromium/chrome/browser/feed/FeedProcessScopeFactory.java",
"//chrome/android/feed/core/java/src/org/chromium/chrome/browser/feed/FeedRefreshTask.java", "//chrome/android/feed/core/java/src/org/chromium/chrome/browser/feed/FeedRefreshTask.java",
"//chrome/android/feed/core/java/src/org/chromium/chrome/browser/feed/FeedScheduler.java",
"//chrome/android/feed/core/java/src/org/chromium/chrome/browser/feed/FeedSchedulerBridge.java", "//chrome/android/feed/core/java/src/org/chromium/chrome/browser/feed/FeedSchedulerBridge.java",
"//chrome/android/feed/core/java/src/org/chromium/chrome/browser/feed/FeedStorageBridge.java", "//chrome/android/feed/core/java/src/org/chromium/chrome/browser/feed/FeedStorageBridge.java",
"//chrome/android/feed/core/java/src/org/chromium/chrome/browser/feed/StreamLifecycleManager.java", "//chrome/android/feed/core/java/src/org/chromium/chrome/browser/feed/StreamLifecycleManager.java",
"//chrome/android/feed/core/java/src/org/chromium/chrome/browser/feed/TestFeedScheduler.java",
"//chrome/android/feed/core/java/src/org/chromium/chrome/browser/feed/TestNetworkClient.java",
"//chrome/android/feed/core/java/src/org/chromium/chrome/browser/feed/action/FeedActionHandler.java", "//chrome/android/feed/core/java/src/org/chromium/chrome/browser/feed/action/FeedActionHandler.java",
] ]
......
...@@ -46,6 +46,7 @@ import org.chromium.chrome.browser.ChromeSwitches; ...@@ -46,6 +46,7 @@ import org.chromium.chrome.browser.ChromeSwitches;
import org.chromium.chrome.browser.UrlConstants; import org.chromium.chrome.browser.UrlConstants;
import org.chromium.chrome.browser.bookmarks.BookmarkActivity; import org.chromium.chrome.browser.bookmarks.BookmarkActivity;
import org.chromium.chrome.browser.download.DownloadActivity; import org.chromium.chrome.browser.download.DownloadActivity;
import org.chromium.chrome.browser.feed.FeedNewTabPage;
import org.chromium.chrome.browser.ntp.cards.NewTabPageAdapter; import org.chromium.chrome.browser.ntp.cards.NewTabPageAdapter;
import org.chromium.chrome.browser.ntp.cards.NewTabPageRecyclerView; import org.chromium.chrome.browser.ntp.cards.NewTabPageRecyclerView;
import org.chromium.chrome.browser.ntp.cards.SignInPromo; import org.chromium.chrome.browser.ntp.cards.SignInPromo;
...@@ -70,6 +71,7 @@ import org.chromium.chrome.test.util.NewTabPageTestUtils; ...@@ -70,6 +71,7 @@ import org.chromium.chrome.test.util.NewTabPageTestUtils;
import org.chromium.chrome.test.util.OmniboxTestUtils; import org.chromium.chrome.test.util.OmniboxTestUtils;
import org.chromium.chrome.test.util.RenderTestRule; import org.chromium.chrome.test.util.RenderTestRule;
import org.chromium.chrome.test.util.browser.ChromeModernDesign; import org.chromium.chrome.test.util.browser.ChromeModernDesign;
import org.chromium.chrome.test.util.browser.Features;
import org.chromium.chrome.test.util.browser.Features.DisableFeatures; import org.chromium.chrome.test.util.browser.Features.DisableFeatures;
import org.chromium.chrome.test.util.browser.Features.EnableFeatures; import org.chromium.chrome.test.util.browser.Features.EnableFeatures;
import org.chromium.chrome.test.util.browser.RecyclerViewTestUtils; import org.chromium.chrome.test.util.browser.RecyclerViewTestUtils;
...@@ -129,8 +131,18 @@ public class NewTabPageTest { ...@@ -129,8 +131,18 @@ public class NewTabPageTest {
} }
} }
/** Parameter provider for enabling/disabling "Interest Feed Content Suggestions". */
public static class InterestFeedParams implements ParameterProvider {
@Override
public Iterable<ParameterSet> getParameters() {
return Arrays.asList(new ParameterSet().value(false).name("DisableInterestFeed"),
new ParameterSet().value(true).name("EnableInterestFeed"));
}
}
private static final String TEST_PAGE = "/chrome/test/data/android/navigate/simple.html"; private static final String TEST_PAGE = "/chrome/test/data/android/navigate/simple.html";
private boolean mInterestFeedEnabled;
private Tab mTab; private Tab mTab;
private NewTabPage mNtp; private NewTabPage mNtp;
private View mFakebox; private View mFakebox;
...@@ -151,6 +163,17 @@ public class NewTabPageTest { ...@@ -151,6 +163,17 @@ public class NewTabPageTest {
mChromeModernProcessor.clearTestState(); mChromeModernProcessor.clearTestState();
} }
@ParameterAnnotations.UseMethodParameterBefore(InterestFeedParams.class)
public void setupInterestFeed(boolean interestFeedEnabled) {
mInterestFeedEnabled = interestFeedEnabled;
if (mInterestFeedEnabled) {
Features.getInstance().enable(ChromeFeatureList.INTEREST_FEED_CONTENT_SUGGESTIONS);
FeedNewTabPage.setInTestMode(true);
} else {
Features.getInstance().disable(ChromeFeatureList.INTEREST_FEED_CONTENT_SUGGESTIONS);
}
}
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
mTestServer = EmbeddedTestServer.createAndStartServer(InstrumentationRegistry.getContext()); mTestServer = EmbeddedTestServer.createAndStartServer(InstrumentationRegistry.getContext());
...@@ -199,6 +222,7 @@ public class NewTabPageTest { ...@@ -199,6 +222,7 @@ public class NewTabPageTest {
@After @After
public void tearDown() throws Exception { public void tearDown() throws Exception {
mTestServer.stopAndDestroyServer(); mTestServer.stopAndDestroyServer();
if (mInterestFeedEnabled) FeedNewTabPage.setInTestMode(false);
} }
@Test @Test
...@@ -235,7 +259,8 @@ public class NewTabPageTest { ...@@ -235,7 +259,8 @@ public class NewTabPageTest {
@Feature({"NewTabPage", "FeedNewTabPage"}) @Feature({"NewTabPage", "FeedNewTabPage"})
@EnableFeatures({ChromeFeatureList.SIMPLIFIED_NTP}) @EnableFeatures({ChromeFeatureList.SIMPLIFIED_NTP})
@Restriction(UiRestriction.RESTRICTION_TYPE_PHONE) @Restriction(UiRestriction.RESTRICTION_TYPE_PHONE)
public void testSimplifiedNtp_BookmarksShortcuts() { @ParameterAnnotations.UseMethodParameter(InterestFeedParams.class)
public void testSimplifiedNtp_BookmarksShortcuts(boolean interestFeedEnabled) {
ActivityMonitor activityMonitor = InstrumentationRegistry.getInstrumentation().addMonitor( ActivityMonitor activityMonitor = InstrumentationRegistry.getInstrumentation().addMonitor(
BookmarkActivity.class.getName(), BookmarkActivity.class.getName(),
new Instrumentation.ActivityResult(Activity.RESULT_OK, null), true); new Instrumentation.ActivityResult(Activity.RESULT_OK, null), true);
...@@ -253,7 +278,8 @@ public class NewTabPageTest { ...@@ -253,7 +278,8 @@ public class NewTabPageTest {
@Feature({"NewTabPage", "FeedNewTabPage"}) @Feature({"NewTabPage", "FeedNewTabPage"})
@EnableFeatures({ChromeFeatureList.SIMPLIFIED_NTP}) @EnableFeatures({ChromeFeatureList.SIMPLIFIED_NTP})
@Restriction(UiRestriction.RESTRICTION_TYPE_PHONE) @Restriction(UiRestriction.RESTRICTION_TYPE_PHONE)
public void testSimplifiedNtp_DownloadsShortcuts() { @ParameterAnnotations.UseMethodParameter(InterestFeedParams.class)
public void testSimplifiedNtp_DownloadsShortcuts(boolean interestFeedEnabled) {
ActivityMonitor activityMonitor = InstrumentationRegistry.getInstrumentation().addMonitor( ActivityMonitor activityMonitor = InstrumentationRegistry.getInstrumentation().addMonitor(
DownloadActivity.class.getName(), DownloadActivity.class.getName(),
new Instrumentation.ActivityResult(Activity.RESULT_OK, null), true); new Instrumentation.ActivityResult(Activity.RESULT_OK, null), true);
...@@ -271,7 +297,9 @@ public class NewTabPageTest { ...@@ -271,7 +297,9 @@ public class NewTabPageTest {
@Feature({"NewTabPage", "FeedNewTabPage"}) @Feature({"NewTabPage", "FeedNewTabPage"})
@EnableFeatures({ChromeFeatureList.SIMPLIFIED_NTP}) @EnableFeatures({ChromeFeatureList.SIMPLIFIED_NTP})
@Restriction(UiRestriction.RESTRICTION_TYPE_PHONE) @Restriction(UiRestriction.RESTRICTION_TYPE_PHONE)
public void testSimplifiedNtp_DefaultSearchEngineChange() throws Exception { @ParameterAnnotations.UseMethodParameter(InterestFeedParams.class)
public void testSimplifiedNtp_DefaultSearchEngineChange(boolean interestFeedEnabled)
throws Exception {
View logo = mNtp.getView().findViewById(R.id.search_provider_logo); View logo = mNtp.getView().findViewById(R.id.search_provider_logo);
View shortcuts = mNtp.getView().findViewById(R.id.shortcuts); View shortcuts = mNtp.getView().findViewById(R.id.shortcuts);
Assert.assertEquals(View.VISIBLE, logo.getVisibility()); Assert.assertEquals(View.VISIBLE, logo.getVisibility());
...@@ -381,7 +409,7 @@ public class NewTabPageTest { ...@@ -381,7 +409,7 @@ public class NewTabPageTest {
*/ */
@Test @Test
@SmallTest @SmallTest
@Feature({"NewTabPage", "FeedNewTabPage"}) @Feature({"NewTabPage"})
public void testClickMostVisitedItem() throws InterruptedException { public void testClickMostVisitedItem() throws InterruptedException {
ChromeTabUtils.waitForTabPageLoaded(mTab, new Runnable() { ChromeTabUtils.waitForTabPageLoaded(mTab, new Runnable() {
@Override @Override
...@@ -412,7 +440,8 @@ public class NewTabPageTest { ...@@ -412,7 +440,8 @@ public class NewTabPageTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"NewTabPage", "FeedNewTabPage"}) @Feature({"NewTabPage", "FeedNewTabPage"})
public void testOpenMostVisitedItemInIncognitoTab() @ParameterAnnotations.UseMethodParameter(InterestFeedParams.class)
public void testOpenMostVisitedItemInIncognitoTab(boolean interestFeedEnabled)
throws InterruptedException, ExecutionException { throws InterruptedException, ExecutionException {
ChromeTabUtils.invokeContextMenuAndOpenInANewTab(mActivityTestRule, ChromeTabUtils.invokeContextMenuAndOpenInANewTab(mActivityTestRule,
mTileGridLayout.getChildAt(0), mTileGridLayout.getChildAt(0),
...@@ -426,7 +455,8 @@ public class NewTabPageTest { ...@@ -426,7 +455,8 @@ public class NewTabPageTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"NewTabPage", "FeedNewTabPage"}) @Feature({"NewTabPage", "FeedNewTabPage"})
public void testRemoveMostVisitedItem() throws ExecutionException { @ParameterAnnotations.UseMethodParameter(InterestFeedParams.class)
public void testRemoveMostVisitedItem(boolean interestFeedEnabled) throws ExecutionException {
SiteSuggestion testSite = mSiteSuggestions.get(0); SiteSuggestion testSite = mSiteSuggestions.get(0);
View mostVisitedItem = mTileGridLayout.getChildAt(0); View mostVisitedItem = mTileGridLayout.getChildAt(0);
ArrayList<View> views = new ArrayList<>(); ArrayList<View> views = new ArrayList<>();
...@@ -443,7 +473,7 @@ public class NewTabPageTest { ...@@ -443,7 +473,7 @@ public class NewTabPageTest {
@Test @Test
@MediumTest @MediumTest
@Feature({"NewTabPage", "FeedNewTabPage"}) @Feature({"NewTabPage"})
public void testUrlFocusAnimationsDisabledOnLoad() throws InterruptedException { public void testUrlFocusAnimationsDisabledOnLoad() throws InterruptedException {
Assert.assertFalse(getUrlFocusAnimationsDisabled()); Assert.assertFalse(getUrlFocusAnimationsDisabled());
ChromeTabUtils.waitForTabPageLoaded(mTab, new Runnable() { ChromeTabUtils.waitForTabPageLoaded(mTab, new Runnable() {
...@@ -468,7 +498,7 @@ public class NewTabPageTest { ...@@ -468,7 +498,7 @@ public class NewTabPageTest {
@Test @Test
@LargeTest @LargeTest
@Feature({"NewTabPage", "FeedNewTabPage"}) @Feature({"NewTabPage"})
public void testUrlFocusAnimationsEnabledOnFailedLoad() throws Exception { public void testUrlFocusAnimationsEnabledOnFailedLoad() throws Exception {
// TODO(jbudorick): switch this to EmbeddedTestServer. // TODO(jbudorick): switch this to EmbeddedTestServer.
TestWebServer webServer = TestWebServer.start(); TestWebServer webServer = TestWebServer.start();
...@@ -536,7 +566,8 @@ public class NewTabPageTest { ...@@ -536,7 +566,8 @@ public class NewTabPageTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"NewTabPage", "FeedNewTabPage"}) @Feature({"NewTabPage", "FeedNewTabPage"})
public void testSetSearchProviderInfo() throws Throwable { @ParameterAnnotations.UseMethodParameter(InterestFeedParams.class)
public void testSetSearchProviderInfo(boolean interestFeedEnabled) throws Throwable {
mActivityTestRule.runOnUiThread(new Runnable() { mActivityTestRule.runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
...@@ -558,7 +589,8 @@ public class NewTabPageTest { ...@@ -558,7 +589,8 @@ public class NewTabPageTest {
@Test @Test
@SmallTest @SmallTest
@Feature({"NewTabPage", "FeedNewTabPage"}) @Feature({"NewTabPage", "FeedNewTabPage"})
public void testPlaceholder() { @ParameterAnnotations.UseMethodParameter(InterestFeedParams.class)
public void testPlaceholder(boolean interestFeedEnabled) {
final NewTabPageLayout ntpLayout = mNtp.getNewTabPageLayout(); final NewTabPageLayout ntpLayout = mNtp.getNewTabPageLayout();
final View logoView = ntpLayout.findViewById(R.id.search_provider_logo); final View logoView = ntpLayout.findViewById(R.id.search_provider_logo);
final View searchBoxView = ntpLayout.findViewById(R.id.search_box); final View searchBoxView = ntpLayout.findViewById(R.id.search_box);
......
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