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

Fix AutofillUpstreamTest and DisplayCutoutTest after DeferredStartupHandler changes

These tests "started" the same Activity instance multiple times,
unnecessarily.

Bug: 1144769
Change-Id: If64cbd0638a62273e98b6502112c6e7dbbba0de9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2514742
Commit-Queue: Michael Thiessen <mthiesse@chromium.org>
Commit-Queue: Andrew Grieve <agrieve@chromium.org>
Auto-Submit: Michael Thiessen <mthiesse@chromium.org>
Reviewed-by: default avatarAndrew Grieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#823268}
parent 5c0b7ff6
...@@ -21,7 +21,6 @@ import org.chromium.chrome.browser.flags.ChromeSwitches; ...@@ -21,7 +21,6 @@ import org.chromium.chrome.browser.flags.ChromeSwitches;
import org.chromium.chrome.browser.infobar.AutofillSaveCardInfoBar; import org.chromium.chrome.browser.infobar.AutofillSaveCardInfoBar;
import org.chromium.chrome.browser.sync.SyncTestRule; import org.chromium.chrome.browser.sync.SyncTestRule;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner; import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.ChromeTabbedActivityTestRule;
import org.chromium.components.infobars.InfoBar; import org.chromium.components.infobars.InfoBar;
import org.chromium.components.infobars.InfoBarLayout; import org.chromium.components.infobars.InfoBarLayout;
import org.chromium.content_public.browser.WebContents; import org.chromium.content_public.browser.WebContents;
...@@ -48,16 +47,13 @@ public class AutofillUpstreamTest { ...@@ -48,16 +47,13 @@ public class AutofillUpstreamTest {
private static final String CONTINUE_BUTTON_LABEL = "Continue"; private static final String CONTINUE_BUTTON_LABEL = "Continue";
@Rule @Rule
public SyncTestRule mSyncTestRule = new SyncTestRule(); public SyncTestRule mActivityTestRule = new SyncTestRule();
@Rule
public ChromeTabbedActivityTestRule mActivityTestRule = new ChromeTabbedActivityTestRule();
private EmbeddedTestServer mServer; private EmbeddedTestServer mServer;
@Before @Before
public void setUp() { public void setUp() {
mSyncTestRule.setUpAccountAndEnableSyncForTesting(); mActivityTestRule.setUpAccountAndEnableSyncForTesting();
mServer = new EmbeddedTestServer(); mServer = new EmbeddedTestServer();
mServer.initializeNative(InstrumentationRegistry.getContext(), mServer.initializeNative(InstrumentationRegistry.getContext(),
EmbeddedTestServer.ServerHTTPSSetting.USE_HTTP); EmbeddedTestServer.ServerHTTPSSetting.USE_HTTP);
...@@ -109,7 +105,7 @@ public class AutofillUpstreamTest { ...@@ -109,7 +105,7 @@ public class AutofillUpstreamTest {
@MediumTest @MediumTest
@Restriction(Restriction.RESTRICTION_TYPE_INTERNET) @Restriction(Restriction.RESTRICTION_TYPE_INTERNET)
public void testSaveCardInfoBarWithAllFieldsFilled() throws TimeoutException { public void testSaveCardInfoBarWithAllFieldsFilled() throws TimeoutException {
mActivityTestRule.startMainActivityWithURL(mServer.getURL(TEST_FORM_URL)); mActivityTestRule.loadUrl(mServer.getURL(TEST_FORM_URL));
final WebContents webContents = mActivityTestRule.getActivity().getCurrentWebContents(); final WebContents webContents = mActivityTestRule.getActivity().getCurrentWebContents();
DOMUtils.clickNode(webContents, "fill_form"); DOMUtils.clickNode(webContents, "fill_form");
...@@ -123,7 +119,7 @@ public class AutofillUpstreamTest { ...@@ -123,7 +119,7 @@ public class AutofillUpstreamTest {
@MediumTest @MediumTest
@Restriction(Restriction.RESTRICTION_TYPE_INTERNET) @Restriction(Restriction.RESTRICTION_TYPE_INTERNET)
public void testSaveCardInfoBarWithEmptyMonth() throws TimeoutException { public void testSaveCardInfoBarWithEmptyMonth() throws TimeoutException {
mActivityTestRule.startMainActivityWithURL(mServer.getURL(TEST_FORM_URL)); mActivityTestRule.loadUrl(mServer.getURL(TEST_FORM_URL));
final WebContents webContents = mActivityTestRule.getActivity().getCurrentWebContents(); final WebContents webContents = mActivityTestRule.getActivity().getCurrentWebContents();
DOMUtils.clickNode(webContents, "fill_form"); DOMUtils.clickNode(webContents, "fill_form");
...@@ -139,7 +135,7 @@ public class AutofillUpstreamTest { ...@@ -139,7 +135,7 @@ public class AutofillUpstreamTest {
@MediumTest @MediumTest
@Restriction(Restriction.RESTRICTION_TYPE_INTERNET) @Restriction(Restriction.RESTRICTION_TYPE_INTERNET)
public void testSaveCardInfoBarWithEmptyYear() throws TimeoutException { public void testSaveCardInfoBarWithEmptyYear() throws TimeoutException {
mActivityTestRule.startMainActivityWithURL(mServer.getURL(TEST_FORM_URL)); mActivityTestRule.loadUrl(mServer.getURL(TEST_FORM_URL));
final WebContents webContents = mActivityTestRule.getActivity().getCurrentWebContents(); final WebContents webContents = mActivityTestRule.getActivity().getCurrentWebContents();
DOMUtils.clickNode(webContents, "fill_form"); DOMUtils.clickNode(webContents, "fill_form");
...@@ -155,7 +151,7 @@ public class AutofillUpstreamTest { ...@@ -155,7 +151,7 @@ public class AutofillUpstreamTest {
@MediumTest @MediumTest
@Restriction(Restriction.RESTRICTION_TYPE_INTERNET) @Restriction(Restriction.RESTRICTION_TYPE_INTERNET)
public void testSaveCardInfoBarWithEmptyMonthAndYear() throws TimeoutException { public void testSaveCardInfoBarWithEmptyMonthAndYear() throws TimeoutException {
mActivityTestRule.startMainActivityWithURL(mServer.getURL(TEST_FORM_URL)); mActivityTestRule.loadUrl(mServer.getURL(TEST_FORM_URL));
final WebContents webContents = mActivityTestRule.getActivity().getCurrentWebContents(); final WebContents webContents = mActivityTestRule.getActivity().getCurrentWebContents();
DOMUtils.clickNode(webContents, "fill_form"); DOMUtils.clickNode(webContents, "fill_form");
...@@ -172,7 +168,7 @@ public class AutofillUpstreamTest { ...@@ -172,7 +168,7 @@ public class AutofillUpstreamTest {
@Restriction(Restriction.RESTRICTION_TYPE_INTERNET) @Restriction(Restriction.RESTRICTION_TYPE_INTERNET)
public void testSaveCardInfoBarContinueButton_EmptyExpDate_launchesExpDateFixFlow() public void testSaveCardInfoBarContinueButton_EmptyExpDate_launchesExpDateFixFlow()
throws TimeoutException { throws TimeoutException {
mActivityTestRule.startMainActivityWithURL(mServer.getURL(TEST_FORM_URL)); mActivityTestRule.loadUrl(mServer.getURL(TEST_FORM_URL));
final WebContents webContents = mActivityTestRule.getActivity().getCurrentWebContents(); final WebContents webContents = mActivityTestRule.getActivity().getCurrentWebContents();
DOMUtils.clickNode(webContents, "fill_form"); DOMUtils.clickNode(webContents, "fill_form");
...@@ -193,7 +189,7 @@ public class AutofillUpstreamTest { ...@@ -193,7 +189,7 @@ public class AutofillUpstreamTest {
@MediumTest @MediumTest
@Restriction(Restriction.RESTRICTION_TYPE_INTERNET) @Restriction(Restriction.RESTRICTION_TYPE_INTERNET)
public void testSaveCardInfoBarWithEmptyName() throws TimeoutException { public void testSaveCardInfoBarWithEmptyName() throws TimeoutException {
mActivityTestRule.startMainActivityWithURL(mServer.getURL(TEST_FORM_URL)); mActivityTestRule.loadUrl(mServer.getURL(TEST_FORM_URL));
final WebContents webContents = mActivityTestRule.getActivity().getCurrentWebContents(); final WebContents webContents = mActivityTestRule.getActivity().getCurrentWebContents();
DOMUtils.clickNode(webContents, "fill_form"); DOMUtils.clickNode(webContents, "fill_form");
...@@ -210,7 +206,7 @@ public class AutofillUpstreamTest { ...@@ -210,7 +206,7 @@ public class AutofillUpstreamTest {
@Restriction(Restriction.RESTRICTION_TYPE_INTERNET) @Restriction(Restriction.RESTRICTION_TYPE_INTERNET)
public void testSaveCardInfoBarContinueButton_EmptyName_launchesNameFixFlow() public void testSaveCardInfoBarContinueButton_EmptyName_launchesNameFixFlow()
throws TimeoutException { throws TimeoutException {
mActivityTestRule.startMainActivityWithURL(mServer.getURL(TEST_FORM_URL)); mActivityTestRule.loadUrl(mServer.getURL(TEST_FORM_URL));
final WebContents webContents = mActivityTestRule.getActivity().getCurrentWebContents(); final WebContents webContents = mActivityTestRule.getActivity().getCurrentWebContents();
DOMUtils.clickNode(webContents, "fill_form"); DOMUtils.clickNode(webContents, "fill_form");
......
...@@ -9,6 +9,7 @@ import android.view.WindowManager; ...@@ -9,6 +9,7 @@ import android.view.WindowManager;
import androidx.test.filters.LargeTest; import androidx.test.filters.LargeTest;
import org.junit.After;
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;
...@@ -20,6 +21,7 @@ import org.chromium.blink.mojom.ViewportFit; ...@@ -20,6 +21,7 @@ import org.chromium.blink.mojom.ViewportFit;
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.ChromeJUnit4ClassRunner; import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.util.ApplicationTestUtils;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;
...@@ -35,6 +37,11 @@ public class DisplayCutoutTest { ...@@ -35,6 +37,11 @@ public class DisplayCutoutTest {
public DisplayCutoutTestRule mTestRule = public DisplayCutoutTestRule mTestRule =
new DisplayCutoutTestRule<ChromeActivity>(ChromeActivity.class); new DisplayCutoutTestRule<ChromeActivity>(ChromeActivity.class);
@After
public void tearDown() throws Exception {
ApplicationTestUtils.finishActivity(mTestRule.getActivity());
}
/** /**
* Test that no safe area is applied when we have viewport fit auto * Test that no safe area is applied when we have viewport fit auto
*/ */
......
...@@ -20,7 +20,6 @@ import org.junit.runner.Description; ...@@ -20,7 +20,6 @@ import org.junit.runner.Description;
import org.junit.runners.model.Statement; import org.junit.runners.model.Statement;
import org.chromium.base.Promise; import org.chromium.base.Promise;
import org.chromium.chrome.browser.app.ChromeActivity;
import org.chromium.chrome.browser.autofill.PersonalDataManager; import org.chromium.chrome.browser.autofill.PersonalDataManager;
import org.chromium.chrome.browser.autofill.PersonalDataManager.CreditCard; import org.chromium.chrome.browser.autofill.PersonalDataManager.CreditCard;
import org.chromium.chrome.browser.profiles.Profile; import org.chromium.chrome.browser.profiles.Profile;
...@@ -28,7 +27,7 @@ import org.chromium.chrome.browser.signin.UnifiedConsentServiceBridge; ...@@ -28,7 +27,7 @@ import org.chromium.chrome.browser.signin.UnifiedConsentServiceBridge;
import org.chromium.chrome.browser.uid.UniqueIdentificationGenerator; import org.chromium.chrome.browser.uid.UniqueIdentificationGenerator;
import org.chromium.chrome.browser.uid.UniqueIdentificationGeneratorFactory; import org.chromium.chrome.browser.uid.UniqueIdentificationGeneratorFactory;
import org.chromium.chrome.browser.uid.UuidBasedUniqueIdentificationGenerator; import org.chromium.chrome.browser.uid.UuidBasedUniqueIdentificationGenerator;
import org.chromium.chrome.test.ChromeActivityTestRule; import org.chromium.chrome.test.ChromeTabbedActivityTestRule;
import org.chromium.chrome.test.util.browser.signin.AccountManagerTestRule; import org.chromium.chrome.test.util.browser.signin.AccountManagerTestRule;
import org.chromium.chrome.test.util.browser.signin.SigninTestUtil; import org.chromium.chrome.test.util.browser.signin.SigninTestUtil;
import org.chromium.chrome.test.util.browser.sync.SyncTestUtil; import org.chromium.chrome.test.util.browser.sync.SyncTestUtil;
...@@ -52,7 +51,7 @@ import java.util.concurrent.Callable; ...@@ -52,7 +51,7 @@ import java.util.concurrent.Callable;
/** /**
* TestRule for common functionality between sync tests. * TestRule for common functionality between sync tests.
*/ */
public class SyncTestRule extends ChromeActivityTestRule<ChromeActivity> { public class SyncTestRule extends ChromeTabbedActivityTestRule {
private static final String TAG = "SyncTestBase"; private static final String TAG = "SyncTestBase";
private static final String CLIENT_ID = "Client_ID"; private static final String CLIENT_ID = "Client_ID";
...@@ -142,9 +141,7 @@ public class SyncTestRule extends ChromeActivityTestRule<ChromeActivity> { ...@@ -142,9 +141,7 @@ public class SyncTestRule extends ChromeActivityTestRule<ChromeActivity> {
ProfileSyncService.resetForTests(); ProfileSyncService.resetForTests();
} }
public SyncTestRule() { public SyncTestRule() {}
super(ChromeActivity.class);
}
/**Getters for Test variables */ /**Getters for Test variables */
public Context getTargetContext() { public Context getTargetContext() {
......
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