Commit d0de4ea8 authored by Michael Thiessen's avatar Michael Thiessen Committed by Commit Bot

Deprecate direct usage of ChromeActivityTestRule

I'm doing a series of cleanups on ChromeActivityTestRule.
1. ActivityTestRules are supposed to take in the exact class to be
launched - we hack around this in ChromeActivityTestRule, but we really
don't need to and it's confusing for those familiar with
ActivityTestRule. To this end I plan to prevent directly using
ChromeActivityTestRule in favor of derived classes specific to the
Activity you actually want to launch.
2. (Almost) All existing usage of ChromeActivityTestRule is actually
using ChromeTabbedActivity, and so should be using
ChromeTabbedActivityTestRule.
3. A bunch of functions on ChromeActivityTestRule only apply to
ChromeTabbedActivity, so I'll be moving the functions to
ChromeTabbedActivityTestRule instead.
4. Right now some types of ActivityTestRule will finish the Activity
between tests, and some won't (for batched tests). I intend to make this
behavior consistent for all ActivityTestRules.

This change kicks this off by deprecating the public
ChromeActivityTestRule constructor and migrating some of the usages.
A few followups will get the remainder of the usages as there are many.

Bug: 989569
Change-Id: Ia16a252f0d77a053dc9e1733d52d8ea290574a48
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2435724Reviewed-by: default avatarAndrew Grieve <agrieve@chromium.org>
Commit-Queue: Michael Thiessen <mthiesse@chromium.org>
Cr-Commit-Position: refs/heads/master@{#811860}
parent 43857450
......@@ -25,7 +25,6 @@ import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.IntegrationTest;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.ChromeTabbedActivity;
import org.chromium.chrome.browser.flags.ChromeFeatureList;
import org.chromium.chrome.browser.flags.ChromeSwitches;
import org.chromium.chrome.browser.ntp.NewTabPage;
......@@ -34,8 +33,8 @@ import org.chromium.chrome.browser.preferences.Pref;
import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.suggestions.SiteSuggestion;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.test.ChromeActivityTestRule;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.ChromeTabbedActivityTestRule;
import org.chromium.chrome.test.util.ChromeRenderTestRule;
import org.chromium.chrome.test.util.NewTabPageTestUtils;
import org.chromium.chrome.test.util.browser.Features;
......@@ -65,8 +64,7 @@ public class FeedNewTabPageCardRenderTest {
private static final String TEST_FEED_DATA_BASE_PATH = "/chrome/test/data/android/feed/";
@Rule
public ChromeActivityTestRule<ChromeTabbedActivity> mActivityTestRule =
new ChromeActivityTestRule(ChromeTabbedActivity.class);
public ChromeTabbedActivityTestRule mActivityTestRule = new ChromeTabbedActivityTestRule();
@Rule
public SuggestionsDependenciesRule mSuggestionsDeps = new SuggestionsDependenciesRule();
......
......@@ -22,12 +22,10 @@ import org.chromium.base.test.util.FlakyTest;
import org.chromium.base.test.util.Restriction;
import org.chromium.base.test.util.UrlUtils;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.app.ChromeActivity;
import org.chromium.chrome.browser.compositor.layouts.LayoutManager;
import org.chromium.chrome.browser.compositor.layouts.eventfilter.EdgeSwipeHandler;
import org.chromium.chrome.browser.compositor.layouts.eventfilter.ScrollDirection;
import org.chromium.chrome.browser.flags.ChromeSwitches;
import org.chromium.chrome.test.ChromeActivityTestRule;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.ChromeTabbedActivityTestRule;
import org.chromium.chrome.test.util.ChromeTabUtils;
......@@ -52,12 +50,7 @@ import java.util.ArrayDeque;
@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE})
public class ContentViewFocusTest {
@Rule
public ChromeTabbedActivityTestRule mChromeTabbedActivityTestRule =
new ChromeTabbedActivityTestRule();
@Rule
public ChromeActivityTestRule<? extends ChromeActivity> mActivityTestRule =
new ChromeActivityTestRule(ChromeTabbedActivity.class);
public ChromeTabbedActivityTestRule mActivityTestRule = new ChromeTabbedActivityTestRule();
private static final int WAIT_RESPONSE_MS = 2000;
......@@ -107,14 +100,14 @@ public class ContentViewFocusTest {
@Test
@FlakyTest(message = "http://crbug.com/172473")
public void testHideSelectionOnPhoneTabSwiping() throws Exception {
mChromeTabbedActivityTestRule.startMainActivityOnBlankPage();
mActivityTestRule.startMainActivityOnBlankPage();
// Setup
ChromeTabUtils.newTabsFromMenu(InstrumentationRegistry.getInstrumentation(),
mChromeTabbedActivityTestRule.getActivity(), 2);
ChromeTabUtils.newTabsFromMenu(
InstrumentationRegistry.getInstrumentation(), mActivityTestRule.getActivity(), 2);
String url = UrlUtils.getIsolatedTestFileUrl(
"chrome/test/data/android/content_view_focus/content_view_focus_long_text.html");
mChromeTabbedActivityTestRule.loadUrl(url);
View view = mChromeTabbedActivityTestRule.getActivity().getActivityTab().getContentView();
mActivityTestRule.loadUrl(url);
View view = mActivityTestRule.getActivity().getActivityTab().getContentView();
// Give the content view focus
TestTouchUtils.longClickView(InstrumentationRegistry.getInstrumentation(), view, 50, 10);
......@@ -122,16 +115,15 @@ public class ContentViewFocusTest {
// Start the swipe
addFocusChangedListener(view);
final EdgeSwipeHandler edgeSwipeHandler = mChromeTabbedActivityTestRule.getActivity()
.getLayoutManager()
.getToolbarSwipeHandler();
final EdgeSwipeHandler edgeSwipeHandler =
mActivityTestRule.getActivity().getLayoutManager().getToolbarSwipeHandler();
PostTask.runOrPostTask(UiThreadTaskTraits.DEFAULT, () -> {
edgeSwipeHandler.swipeStarted(ScrollDirection.RIGHT, 0, 0);
edgeSwipeHandler.swipeUpdated(100, 0, 100, 0, 100, 0);
});
CriteriaHelper.pollUiThread(() -> {
LayoutManager driver = mChromeTabbedActivityTestRule.getActivity().getLayoutManager();
LayoutManager driver = mActivityTestRule.getActivity().getLayoutManager();
return !driver.getActiveLayout().shouldDisplayContentOverlay();
}, "Layout still requesting Tab Android view be attached");
......@@ -143,7 +135,7 @@ public class ContentViewFocusTest {
PostTask.runOrPostTask(UiThreadTaskTraits.DEFAULT, () -> edgeSwipeHandler.swipeFinished());
CriteriaHelper.pollUiThread(() -> {
LayoutManager driver = mChromeTabbedActivityTestRule.getActivity().getLayoutManager();
LayoutManager driver = mActivityTestRule.getActivity().getLayoutManager();
return driver.getActiveLayout().shouldDisplayContentOverlay();
}, "Layout not requesting Tab Android view be attached");
......@@ -163,22 +155,21 @@ public class ContentViewFocusTest {
@Restriction(UiRestriction.RESTRICTION_TYPE_PHONE)
@FlakyTest(message = "http://crbug.com/967128")
public void testHideSelectionOnPhoneTabSwitcher() throws Exception {
mChromeTabbedActivityTestRule.startMainActivityOnBlankPage();
mActivityTestRule.startMainActivityOnBlankPage();
// Setup
OverviewModeBehaviorWatcher showWatcher = new OverviewModeBehaviorWatcher(
mChromeTabbedActivityTestRule.getActivity().getLayoutManager(), true, false);
mActivityTestRule.getActivity().getLayoutManager(), true, false);
OverviewModeBehaviorWatcher hideWatcher = new OverviewModeBehaviorWatcher(
mChromeTabbedActivityTestRule.getActivity().getLayoutManager(), false, true);
View currentView =
mChromeTabbedActivityTestRule.getActivity().getActivityTab().getContentView();
mActivityTestRule.getActivity().getLayoutManager(), false, true);
View currentView = mActivityTestRule.getActivity().getActivityTab().getContentView();
addFocusChangedListener(currentView);
// Enter the tab switcher
View tabSwitcherButton =
mChromeTabbedActivityTestRule.getActivity().findViewById(R.id.tab_switcher_button);
mActivityTestRule.getActivity().findViewById(R.id.tab_switcher_button);
Assert.assertNotNull("'tab_switcher_button' view is not found.", tabSwitcherButton);
TouchCommon.singleClickView(
mChromeTabbedActivityTestRule.getActivity().findViewById(R.id.tab_switcher_button));
mActivityTestRule.getActivity().findViewById(R.id.tab_switcher_button));
showWatcher.waitForBehavior();
// Make sure the view loses focus. It is immediately given focus back
......@@ -186,11 +177,10 @@ public class ContentViewFocusTest {
Assert.assertFalse("Content view didn't lose focus", blockForFocusChanged());
// Hide the tab switcher
tabSwitcherButton =
mChromeTabbedActivityTestRule.getActivity().findViewById(R.id.tab_switcher_button);
tabSwitcherButton = mActivityTestRule.getActivity().findViewById(R.id.tab_switcher_button);
Assert.assertNotNull("'tab_switcher_button' view is not found.", tabSwitcherButton);
TouchCommon.singleClickView(
mChromeTabbedActivityTestRule.getActivity().findViewById(R.id.tab_switcher_button));
mActivityTestRule.getActivity().findViewById(R.id.tab_switcher_button));
hideWatcher.waitForBehavior();
Assert.assertTrue("Content view didn't regain focus", blockForFocusChanged());
......
......@@ -14,11 +14,10 @@ import org.junit.runner.RunWith;
import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.Restriction;
import org.chromium.chrome.browser.app.ChromeActivity;
import org.chromium.chrome.browser.flags.ChromeSwitches;
import org.chromium.chrome.browser.test.ScreenShooter;
import org.chromium.chrome.test.ChromeActivityTestRule;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.ChromeTabbedActivityTestRule;
import org.chromium.ui.test.util.UiRestriction;
/**
......@@ -29,8 +28,7 @@ import org.chromium.ui.test.util.UiRestriction;
@Restriction(UiRestriction.RESTRICTION_TYPE_PHONE) // Tab switcher button only exists on phones.
public class ExampleUiCaptureTest {
@Rule
public ChromeActivityTestRule<? extends ChromeActivity> mActivityTestRule =
new ChromeActivityTestRule(ChromeTabbedActivity.class);
public ChromeTabbedActivityTestRule mActivityTestRule = new ChromeTabbedActivityTestRule();
@Rule
public ScreenShooter mScreenShooter = new ScreenShooter();
......
......@@ -16,10 +16,9 @@ import org.junit.runner.RunWith;
import org.chromium.base.CommandLine;
import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.chrome.browser.app.ChromeActivity;
import org.chromium.chrome.browser.flags.ChromeSwitches;
import org.chromium.chrome.test.ChromeActivityTestRule;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.ChromeTabbedActivityTestRule;
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.EnableFeatures;
......@@ -35,8 +34,7 @@ import java.util.List;
@CommandLineFlags.Add(ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE)
public class FeaturesAnnotationsTest {
@Rule
public ChromeActivityTestRule<? extends ChromeActivity> mActivityRule =
new ChromeActivityTestRule(ChromeTabbedActivity.class);
public ChromeTabbedActivityTestRule mActivityTestRule = new ChromeTabbedActivityTestRule();
/**
* Tests that {@link EnableFeatures} and {@link DisableFeatures} can alter the flags registered
......@@ -47,7 +45,7 @@ public class FeaturesAnnotationsTest {
@EnableFeatures("One")
@DisableFeatures("Two")
public void testFeaturesSetExistingFlags() throws InterruptedException {
mActivityRule.startMainActivityOnBlankPage();
mActivityTestRule.startMainActivityOnBlankPage();
List<String> finalEnabledList = getFeatureList(true);
assertThat(finalEnabledList, hasItems("One"));
......@@ -70,7 +68,7 @@ public class FeaturesAnnotationsTest {
@CommandLineFlags.Add("enable-features=One,Two,Three")
@EnableFeatures("Two")
public void testFeaturesDoNotRemoveExistingFlags() throws InterruptedException {
mActivityRule.startMainActivityOnBlankPage();
mActivityTestRule.startMainActivityOnBlankPage();
List<String> finalEnabledList = getFeatureList(true);
assertThat(finalEnabledList, hasItems("One", "Two", "Three"));
......@@ -88,7 +86,7 @@ public class FeaturesAnnotationsTest {
@CommandLineFlags.Add("enable-features=One,Two,Three")
@EnableFeatures({"Three", "Four"})
public void testFeaturesAddToExistingFlags() throws InterruptedException {
mActivityRule.startMainActivityOnBlankPage();
mActivityTestRule.startMainActivityOnBlankPage();
List<String> finalEnabledList = getFeatureList(true);
assertThat(finalEnabledList, hasItems("Four"));
......
......@@ -17,10 +17,9 @@ import org.junit.runner.RunWith;
import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.Feature;
import org.chromium.chrome.browser.app.ChromeActivity;
import org.chromium.chrome.browser.flags.ChromeSwitches;
import org.chromium.chrome.test.ChromeActivityTestRule;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.ChromeTabbedActivityTestRule;
import org.chromium.net.test.EmbeddedTestServer;
import org.chromium.net.test.ServerCertificate;
import org.chromium.network.mojom.ReferrerPolicy;
......@@ -33,8 +32,7 @@ import org.chromium.network.mojom.ReferrerPolicy;
public class HTTPSTabsOpenedFromExternalAppTest {
@Rule
public ChromeActivityTestRule<? extends ChromeActivity> mActivityTestRule =
new ChromeActivityTestRule(ChromeTabbedActivity.class);
public ChromeTabbedActivityTestRule mActivityTestRule = new ChromeTabbedActivityTestRule();
private EmbeddedTestServer mTestServer;
......
......@@ -17,12 +17,11 @@ import org.junit.runner.RunWith;
import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.UrlUtils;
import org.chromium.chrome.browser.app.ChromeActivity;
import org.chromium.chrome.browser.customtabs.CustomTabActivityTestRule;
import org.chromium.chrome.browser.flags.ChromeSwitches;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.test.ChromeActivityTestRule;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.ChromeTabbedActivityTestRule;
import org.chromium.chrome.test.util.ChromeTabUtils;
import org.chromium.content_public.browser.test.util.JavaScriptUtils;
import org.chromium.content_public.browser.test.util.TestThreadUtils;
......@@ -36,8 +35,7 @@ import java.util.concurrent.TimeoutException;
@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE})
public class JavaScriptEvalChromeTest {
@Rule
public ChromeActivityTestRule<? extends ChromeActivity> mActivityTestRule =
new ChromeActivityTestRule(ChromeTabbedActivity.class);
public ChromeTabbedActivityTestRule mActivityTestRule = new ChromeTabbedActivityTestRule();
@Rule
public CustomTabActivityTestRule mCustomTabActivityTestRule = new CustomTabActivityTestRule();
......
......@@ -28,12 +28,12 @@ import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.FlakyTest;
import org.chromium.base.test.util.UrlUtils;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.app.ChromeActivity;
import org.chromium.chrome.browser.flags.ChromeSwitches;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.tabmodel.TabModelUtils;
import org.chromium.chrome.test.ChromeActivityTestRule;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.ChromeTabbedActivityTestRule;
import org.chromium.chrome.test.util.ApplicationTestUtils;
import org.chromium.chrome.test.util.ChromeTabUtils;
import org.chromium.chrome.test.util.browser.contextmenu.RevampedContextMenuUtils;
......@@ -56,8 +56,7 @@ import java.util.concurrent.TimeoutException;
@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE})
public class TabsOpenedFromExternalAppTest {
@Rule
public ChromeActivityTestRule<? extends ChromeActivity> mActivityTestRule =
new ChromeActivityTestRule(ChromeTabbedActivity.class);
public ChromeTabbedActivityTestRule mActivityTestRule = new ChromeTabbedActivityTestRule();
static final String HTTP_REFERRER = "http://chromium.org/";
......
......@@ -18,12 +18,10 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.chrome.browser.ChromeTabbedActivity;
import org.chromium.chrome.browser.app.ChromeActivity;
import org.chromium.chrome.browser.compositor.layouts.LayoutRenderHost;
import org.chromium.chrome.browser.flags.ChromeSwitches;
import org.chromium.chrome.test.ChromeActivityTestRule;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.ChromeTabbedActivityTestRule;
import org.chromium.ui.resources.ResourceManager;
/**
......@@ -33,8 +31,7 @@ import org.chromium.ui.resources.ResourceManager;
@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE})
public class CompositorVisibilityTest {
@Rule
public ChromeActivityTestRule<? extends ChromeActivity> mActivityTestRule =
new ChromeActivityTestRule(ChromeTabbedActivity.class);
public ChromeTabbedActivityTestRule mActivityTestRule = new ChromeTabbedActivityTestRule();
private CompositorView mCompositorView;
......
......@@ -26,7 +26,6 @@ import org.chromium.base.ApplicationStatus;
import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.Feature;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.ChromeTabbedActivity;
import org.chromium.chrome.browser.LaunchIntentDispatcher;
import org.chromium.chrome.browser.customtabs.CustomTabDelegateFactory.CustomTabNavigationDelegate;
import org.chromium.chrome.browser.flags.ChromeSwitches;
......@@ -34,8 +33,8 @@ import org.chromium.chrome.browser.tab.InterceptNavigationDelegateTabHelper;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.tab.TabDelegateFactory;
import org.chromium.chrome.browser.tab.TabTestUtils;
import org.chromium.chrome.test.ChromeActivityTestRule;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.ChromeTabbedActivityTestRule;
import org.chromium.components.external_intents.ExternalNavigationHandler.OverrideUrlLoadingResult;
import org.chromium.components.external_intents.InterceptNavigationDelegateImpl;
import org.chromium.content_public.browser.test.util.Criteria;
......@@ -57,8 +56,8 @@ public class CustomTabFromChromeExternalNavigationTest {
public CustomTabActivityTestRule mActivityRule = new CustomTabActivityTestRule();
@Rule
public ChromeActivityTestRule mChromeActivityTestRule =
new ChromeActivityTestRule(ChromeTabbedActivity.class);
public ChromeTabbedActivityTestRule mChromeActivityTestRule =
new ChromeTabbedActivityTestRule();
public EmbeddedTestServerRule mServerRule = new EmbeddedTestServerRule();
......
......@@ -22,14 +22,12 @@ import org.junit.runner.RunWith;
import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.MinAndroidSdkLevel;
import org.chromium.chrome.browser.ChromeTabbedActivity;
import org.chromium.chrome.browser.app.ChromeActivity;
import org.chromium.chrome.browser.flags.ChromeSwitches;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.tab.TabLaunchType;
import org.chromium.chrome.browser.tabmodel.TabModelSelector;
import org.chromium.chrome.test.ChromeActivityTestRule;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.ChromeTabbedActivityTestRule;
import org.chromium.content_public.browser.test.util.TestThreadUtils;
import java.util.ArrayList;
......@@ -41,8 +39,7 @@ import java.util.List;
@MinAndroidSdkLevel(Build.VERSION_CODES.N)
public class CloseTabDirectActionHandlerTest {
@Rule
public ChromeActivityTestRule<? extends ChromeActivity> mActivityTestRule =
new ChromeActivityTestRule(ChromeTabbedActivity.class);
public ChromeTabbedActivityTestRule mActivityTestRule = new ChromeTabbedActivityTestRule();
private TabModelSelector mSelector;
private CloseTabDirectActionHandler mHandler;
......
......@@ -27,11 +27,10 @@ import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.MetricsUtils.HistogramDelta;
import org.chromium.base.test.util.MinAndroidSdkLevel;
import org.chromium.base.test.util.UserActionTester;
import org.chromium.chrome.browser.ChromeTabbedActivity;
import org.chromium.chrome.browser.app.ChromeActivity;
import org.chromium.chrome.browser.flags.ChromeSwitches;
import org.chromium.chrome.test.ChromeActivityTestRule;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.ChromeTabbedActivityTestRule;
import org.chromium.content_public.browser.test.util.TestThreadUtils;
/**
......@@ -45,8 +44,7 @@ import org.chromium.content_public.browser.test.util.TestThreadUtils;
@TargetApi(24) // For java.util.function.Consumer.
public class DirectActionsInActivityTest {
@Rule
public ChromeActivityTestRule<? extends ChromeActivity> mActivityTestRule =
new ChromeActivityTestRule(ChromeTabbedActivity.class);
public ChromeTabbedActivityTestRule mActivityTestRule = new ChromeTabbedActivityTestRule();
@Rule
public DirectActionTestRule mDirectActionRule = new DirectActionTestRule();
......
......@@ -19,15 +19,13 @@ import org.chromium.base.Callback;
import org.chromium.base.test.util.CallbackHelper;
import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.Restriction;
import org.chromium.chrome.browser.ChromeTabbedActivity;
import org.chromium.chrome.browser.app.ChromeActivity;
import org.chromium.chrome.browser.customtabs.CustomTabActivityTestRule;
import org.chromium.chrome.browser.flags.ChromeSwitches;
import org.chromium.chrome.browser.tab.SadTab;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.tab.TabLaunchType;
import org.chromium.chrome.test.ChromeActivityTestRule;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.ChromeTabbedActivityTestRule;
import org.chromium.chrome.test.util.ChromeTabUtils;
import org.chromium.content_public.browser.test.util.Criteria;
import org.chromium.content_public.browser.test.util.CriteriaHelper;
......@@ -44,8 +42,7 @@ import java.util.concurrent.atomic.AtomicReference;
@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE})
public class ChromeHttpAuthHandlerTest {
@Rule
public ChromeActivityTestRule<? extends ChromeActivity> mActivityTestRule =
new ChromeActivityTestRule(ChromeTabbedActivity.class);
public ChromeTabbedActivityTestRule mActivityTestRule = new ChromeTabbedActivityTestRule();
@Rule
public CustomTabActivityTestRule mCustomTabActivityTestRule = new CustomTabActivityTestRule();
......
......@@ -14,10 +14,8 @@ import org.junit.rules.TestRule;
import org.junit.runner.RunWith;
import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.chrome.browser.ChromeTabbedActivity;
import org.chromium.chrome.browser.app.ChromeActivity;
import org.chromium.chrome.test.ChromeActivityTestRule;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.ChromeTabbedActivityTestRule;
import org.chromium.chrome.test.util.browser.Features;
import org.chromium.chrome.test.util.browser.FieldTrials;
......@@ -31,15 +29,14 @@ public final class FieldTrialsInstrumentationTest {
private static final String sFeature2 = ChromeFeatureList.TEST_DEFAULT_ENABLED;
@Rule
public ChromeActivityTestRule<? extends ChromeActivity> mActivityRule =
new ChromeActivityTestRule(ChromeTabbedActivity.class);
public ChromeTabbedActivityTestRule mActivityTestRule = new ChromeTabbedActivityTestRule();
@Rule
public TestRule mProcessor = new Features.InstrumentationProcessor();
@Before
public void setup() {
mActivityRule.startMainActivityOnBlankPage();
mActivityTestRule.startMainActivityOnBlankPage();
}
@Test
......
......@@ -95,11 +95,15 @@ public class ChromeActivityTestRule<T extends ChromeActivity> extends ActivityTe
@Rule
private EmbeddedTestServerRule mTestServerRule = new EmbeddedTestServerRule();
/**
* @deprecated Please use a derived rule directly. ChromeActivity is never directly launched.
*/
@Deprecated
public ChromeActivityTestRule(Class<T> activityClass) {
this(activityClass, false);
}
public ChromeActivityTestRule(Class<T> activityClass, boolean initialTouchMode) {
protected ChromeActivityTestRule(Class<T> activityClass, boolean initialTouchMode) {
super(activityClass, initialTouchMode, false);
mChromeActivityClass = activityClass;
}
......
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