Commit 23a5ac69 authored by David Maunder's avatar David Maunder Committed by Chromium LUCI CQ

Batch InterceptNavigationDelegateTest

Speedup: 48997ms -> 21318ms (56% speedup)

Bug: 1166399
Change-Id: I296c5c40d9136a816c8b881c904f19b5baa1e5bb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2627629Reviewed-by: default avatarMichael Thiessen <mthiesse@chromium.org>
Commit-Queue: David Maunder <davidjm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#843555}
parent b2f288ae
...@@ -13,10 +13,12 @@ import org.hamcrest.Matchers; ...@@ -13,10 +13,12 @@ import org.hamcrest.Matchers;
import org.junit.After; import org.junit.After;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.chromium.base.test.util.Batch;
import org.chromium.base.test.util.CommandLineFlags; import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.Criteria; import org.chromium.base.test.util.Criteria;
import org.chromium.base.test.util.CriteriaHelper; import org.chromium.base.test.util.CriteriaHelper;
...@@ -25,6 +27,7 @@ import org.chromium.chrome.browser.externalnav.ExternalNavigationDelegateImpl; ...@@ -25,6 +27,7 @@ import org.chromium.chrome.browser.externalnav.ExternalNavigationDelegateImpl;
import org.chromium.chrome.browser.flags.ChromeSwitches; import org.chromium.chrome.browser.flags.ChromeSwitches;
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.batch.BlankCTATabInitialStateRule;
import org.chromium.components.external_intents.ExternalNavigationHandler; import org.chromium.components.external_intents.ExternalNavigationHandler;
import org.chromium.components.external_intents.ExternalNavigationParams; import org.chromium.components.external_intents.ExternalNavigationParams;
import org.chromium.components.external_intents.InterceptNavigationDelegateImpl; import org.chromium.components.external_intents.InterceptNavigationDelegateImpl;
...@@ -42,9 +45,15 @@ import java.util.concurrent.TimeoutException; ...@@ -42,9 +45,15 @@ import java.util.concurrent.TimeoutException;
*/ */
@RunWith(ChromeJUnit4ClassRunner.class) @RunWith(ChromeJUnit4ClassRunner.class)
@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE}) @CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE})
@Batch(Batch.PER_CLASS)
public class InterceptNavigationDelegateTest { public class InterceptNavigationDelegateTest {
@ClassRule
public static ChromeTabbedActivityTestRule sActivityTestRule =
new ChromeTabbedActivityTestRule();
@Rule @Rule
public ChromeTabbedActivityTestRule mActivityTestRule = new ChromeTabbedActivityTestRule(); public BlankCTATabInitialStateRule mInitialStateRule =
new BlankCTATabInitialStateRule(sActivityTestRule, false);
private static final String BASE_PAGE = "/chrome/test/data/navigation_interception/"; private static final String BASE_PAGE = "/chrome/test/data/navigation_interception/";
private static final String NAVIGATION_FROM_TIMEOUT_PAGE = private static final String NAVIGATION_FROM_TIMEOUT_PAGE =
...@@ -90,8 +99,7 @@ public class InterceptNavigationDelegateTest { ...@@ -90,8 +99,7 @@ public class InterceptNavigationDelegateTest {
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
mActivityTestRule.startMainActivityOnBlankPage(); mActivity = sActivityTestRule.getActivity();
mActivity = mActivityTestRule.getActivity();
final Tab tab = mActivity.getActivityTab(); final Tab tab = mActivity.getActivityTab();
TestThreadUtils.runOnUiThreadBlocking(() -> { TestThreadUtils.runOnUiThreadBlocking(() -> {
InterceptNavigationDelegateClientImpl client = InterceptNavigationDelegateClientImpl client =
...@@ -118,7 +126,7 @@ public class InterceptNavigationDelegateTest { ...@@ -118,7 +126,7 @@ public class InterceptNavigationDelegateTest {
@Test @Test
@SmallTest @SmallTest
public void testNavigationFromTimer() { public void testNavigationFromTimer() {
mActivityTestRule.loadUrl(mTestServer.getURL(NAVIGATION_FROM_TIMEOUT_PAGE)); sActivityTestRule.loadUrl(mTestServer.getURL(NAVIGATION_FROM_TIMEOUT_PAGE));
Assert.assertEquals(1, mNavParamHistory.size()); Assert.assertEquals(1, mNavParamHistory.size());
waitTillExpectedCallsComplete(2, DEFAULT_MAX_TIME_TO_WAIT_IN_MS); waitTillExpectedCallsComplete(2, DEFAULT_MAX_TIME_TO_WAIT_IN_MS);
...@@ -129,7 +137,7 @@ public class InterceptNavigationDelegateTest { ...@@ -129,7 +137,7 @@ public class InterceptNavigationDelegateTest {
@Test @Test
@SmallTest @SmallTest
public void testNavigationFromUserGesture() throws TimeoutException { public void testNavigationFromUserGesture() throws TimeoutException {
mActivityTestRule.loadUrl(mTestServer.getURL(NAVIGATION_FROM_USER_GESTURE_PAGE)); sActivityTestRule.loadUrl(mTestServer.getURL(NAVIGATION_FROM_USER_GESTURE_PAGE));
Assert.assertEquals(1, mNavParamHistory.size()); Assert.assertEquals(1, mNavParamHistory.size());
DOMUtils.clickNode(mActivity.getActivityTab().getWebContents(), "first"); DOMUtils.clickNode(mActivity.getActivityTab().getWebContents(), "first");
...@@ -142,7 +150,7 @@ public class InterceptNavigationDelegateTest { ...@@ -142,7 +150,7 @@ public class InterceptNavigationDelegateTest {
@Test @Test
@SmallTest @SmallTest
public void testNavigationFromXHRCallback() throws TimeoutException { public void testNavigationFromXHRCallback() throws TimeoutException {
mActivityTestRule.loadUrl(mTestServer.getURL(NAVIGATION_FROM_XHR_CALLBACK_PAGE)); sActivityTestRule.loadUrl(mTestServer.getURL(NAVIGATION_FROM_XHR_CALLBACK_PAGE));
Assert.assertEquals(1, mNavParamHistory.size()); Assert.assertEquals(1, mNavParamHistory.size());
DOMUtils.clickNode(mActivity.getActivityTab().getWebContents(), "first"); DOMUtils.clickNode(mActivity.getActivityTab().getWebContents(), "first");
...@@ -155,7 +163,7 @@ public class InterceptNavigationDelegateTest { ...@@ -155,7 +163,7 @@ public class InterceptNavigationDelegateTest {
@Test @Test
@SmallTest @SmallTest
public void testNavigationFromXHRCallbackAndShortTimeout() throws TimeoutException { public void testNavigationFromXHRCallbackAndShortTimeout() throws TimeoutException {
mActivityTestRule.loadUrl( sActivityTestRule.loadUrl(
mTestServer.getURL(NAVIGATION_FROM_XHR_CALLBACK_AND_SHORT_TIMEOUT_PAGE)); mTestServer.getURL(NAVIGATION_FROM_XHR_CALLBACK_AND_SHORT_TIMEOUT_PAGE));
Assert.assertEquals(1, mNavParamHistory.size()); Assert.assertEquals(1, mNavParamHistory.size());
...@@ -169,7 +177,7 @@ public class InterceptNavigationDelegateTest { ...@@ -169,7 +177,7 @@ public class InterceptNavigationDelegateTest {
@Test @Test
@SmallTest @SmallTest
public void testNavigationFromXHRCallbackAndLongTimeout() throws TimeoutException { public void testNavigationFromXHRCallbackAndLongTimeout() throws TimeoutException {
mActivityTestRule.loadUrl( sActivityTestRule.loadUrl(
mTestServer.getURL(NAVIGATION_FROM_XHR_CALLBACK_AND_LONG_TIMEOUT_PAGE)); mTestServer.getURL(NAVIGATION_FROM_XHR_CALLBACK_AND_LONG_TIMEOUT_PAGE));
Assert.assertEquals(1, mNavParamHistory.size()); Assert.assertEquals(1, mNavParamHistory.size());
...@@ -182,7 +190,7 @@ public class InterceptNavigationDelegateTest { ...@@ -182,7 +190,7 @@ public class InterceptNavigationDelegateTest {
@Test @Test
@SmallTest @SmallTest
public void testNavigationFromImageOnLoad() throws TimeoutException { public void testNavigationFromImageOnLoad() throws TimeoutException {
mActivityTestRule.loadUrl(mTestServer.getURL(NAVIGATION_FROM_IMAGE_ONLOAD_PAGE)); sActivityTestRule.loadUrl(mTestServer.getURL(NAVIGATION_FROM_IMAGE_ONLOAD_PAGE));
Assert.assertEquals(1, mNavParamHistory.size()); Assert.assertEquals(1, mNavParamHistory.size());
DOMUtils.clickNode(mActivity.getActivityTab().getWebContents(), "first"); DOMUtils.clickNode(mActivity.getActivityTab().getWebContents(), "first");
...@@ -195,7 +203,7 @@ public class InterceptNavigationDelegateTest { ...@@ -195,7 +203,7 @@ public class InterceptNavigationDelegateTest {
@Test @Test
@MediumTest @MediumTest
public void testExternalAppIframeNavigation() throws TimeoutException { public void testExternalAppIframeNavigation() throws TimeoutException {
mActivityTestRule.loadUrl(mTestServer.getURL(NAVIGATION_FROM_USER_GESTURE_IFRAME_PAGE)); sActivityTestRule.loadUrl(mTestServer.getURL(NAVIGATION_FROM_USER_GESTURE_IFRAME_PAGE));
Assert.assertEquals(1, mNavParamHistory.size()); Assert.assertEquals(1, mNavParamHistory.size());
DOMUtils.clickNode(mActivity.getActivityTab().getWebContents(), "first"); DOMUtils.clickNode(mActivity.getActivityTab().getWebContents(), "first");
......
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