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