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

Batch RepostFormWarningTest

Speedup: 28191ms -> 11164ms (60% speedup)

Bug: 1166842
Change-Id: Ifbc1584870be6effa7a47970499d4e1a96836fcf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2630298Reviewed-by: default avatarMichael Thiessen <mthiesse@chromium.org>
Commit-Queue: David Maunder <davidjm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#844085}
parent e9b0c0d1
...@@ -10,13 +10,14 @@ import androidx.test.filters.MediumTest; ...@@ -10,13 +10,14 @@ import androidx.test.filters.MediumTest;
import androidx.test.filters.SmallTest; import androidx.test.filters.SmallTest;
import org.hamcrest.Matchers; import org.hamcrest.Matchers;
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 +26,7 @@ import org.chromium.chrome.R; ...@@ -25,6 +26,7 @@ import org.chromium.chrome.R;
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.content_public.browser.LoadUrlParams; import org.chromium.content_public.browser.LoadUrlParams;
import org.chromium.content_public.browser.test.util.TestCallbackHelperContainer; import org.chromium.content_public.browser.test.util.TestCallbackHelperContainer;
import org.chromium.content_public.browser.test.util.TestThreadUtils; import org.chromium.content_public.browser.test.util.TestThreadUtils;
...@@ -40,11 +42,17 @@ import java.util.concurrent.TimeoutException; ...@@ -40,11 +42,17 @@ 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 RepostFormWarningTest { public class RepostFormWarningTest {
// Active tab. // Active tab.
@ClassRule
public static ChromeTabbedActivityTestRule sActivityTestRule =
new ChromeTabbedActivityTestRule();
@Rule @Rule
public ChromeTabbedActivityTestRule mActivityTestRule = new ChromeTabbedActivityTestRule(); public BlankCTATabInitialStateRule mInitialStateRule =
new BlankCTATabInitialStateRule(sActivityTestRule, false);
private Tab mTab; private Tab mTab;
// Callback helper that manages waiting for pageloads to finish. // Callback helper that manages waiting for pageloads to finish.
...@@ -54,16 +62,9 @@ public class RepostFormWarningTest { ...@@ -54,16 +62,9 @@ public class RepostFormWarningTest {
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
mActivityTestRule.startMainActivityOnBlankPage(); mTab = sActivityTestRule.getActivity().getActivityTab();
mTab = mActivityTestRule.getActivity().getActivityTab();
mCallbackHelper = new TestCallbackHelperContainer(mTab.getWebContents()); mCallbackHelper = new TestCallbackHelperContainer(mTab.getWebContents());
mTestServer = EmbeddedTestServer.createAndStartServer(InstrumentationRegistry.getContext()); mTestServer = sActivityTestRule.getTestServer();
}
@After
public void tearDown() {
mTestServer.stopAndDestroyServer();
} }
/** Verifies that the form resubmission warning is not displayed upon first POST navigation. */ /** Verifies that the form resubmission warning is not displayed upon first POST navigation. */
...@@ -148,7 +149,8 @@ public class RepostFormWarningTest { ...@@ -148,7 +149,8 @@ public class RepostFormWarningTest {
waitForRepostFormWarningDialog(); waitForRepostFormWarningDialog();
TestThreadUtils.runOnUiThreadBlocking( TestThreadUtils.runOnUiThreadBlocking(
(Runnable) () -> mActivityTestRule.getActivity().getCurrentTabModel().closeTab(mTab)); (Runnable) ()
-> sActivityTestRule.getActivity().getCurrentTabModel().closeTab(mTab));
waitForNoReportFormWarningDialog(); waitForNoReportFormWarningDialog();
} }
...@@ -156,7 +158,7 @@ public class RepostFormWarningTest { ...@@ -156,7 +158,7 @@ public class RepostFormWarningTest {
private PropertyModel getCurrentModalDialog() { private PropertyModel getCurrentModalDialog() {
return TestThreadUtils.runOnUiThreadBlockingNoException( return TestThreadUtils.runOnUiThreadBlockingNoException(
() ()
-> mActivityTestRule.getActivity() -> sActivityTestRule.getActivity()
.getModalDialogManager() .getModalDialogManager()
.getCurrentDialogForTest()); .getCurrentDialogForTest());
} }
...@@ -174,7 +176,7 @@ public class RepostFormWarningTest { ...@@ -174,7 +176,7 @@ public class RepostFormWarningTest {
Criteria.checkThat("No modal dialog shown", dialogModel, Matchers.notNullValue()); Criteria.checkThat("No modal dialog shown", dialogModel, Matchers.notNullValue());
Criteria.checkThat("Modal dialog is not a HTTP post dialog", Criteria.checkThat("Modal dialog is not a HTTP post dialog",
dialogModel.get(ModalDialogProperties.TITLE), dialogModel.get(ModalDialogProperties.TITLE),
Matchers.is(mActivityTestRule.getActivity().getString( Matchers.is(sActivityTestRule.getActivity().getString(
R.string.http_post_warning_title))); R.string.http_post_warning_title)));
}); });
return getCurrentModalDialog(); return getCurrentModalDialog();
......
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