Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1004)

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/toolbar/ToolbarTest.java

Issue 2860843002: Revert of Reland: Convert ChromeActivityTestCaseBase direct children to JUnit4 (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/javatests/src/org/chromium/chrome/browser/toolbar/ToolbarTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/toolbar/ToolbarTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/toolbar/ToolbarTest.java
index 73edd89b4d1b7c96874e17737584e02332606920..42838fd0021d33993ddc5739e73b9bb64d17bf23 100644
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/toolbar/ToolbarTest.java
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/toolbar/ToolbarTest.java
@@ -4,28 +4,18 @@
package org.chromium.chrome.browser.toolbar;
-import android.support.test.InstrumentationRegistry;
import android.support.test.filters.MediumTest;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
import org.chromium.base.ThreadUtils;
-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.R;
import org.chromium.chrome.browser.ChromeActivity;
-import org.chromium.chrome.browser.ChromeSwitches;
import org.chromium.chrome.browser.UrlConstants;
import org.chromium.chrome.browser.omnibox.UrlBar;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.widget.findinpage.FindToolbar;
-import org.chromium.chrome.test.ChromeActivityTestRule;
-import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
+import org.chromium.chrome.test.ChromeActivityTestCaseBase;
import org.chromium.chrome.test.util.ChromeRestriction;
import org.chromium.chrome.test.util.MenuUtils;
import org.chromium.chrome.test.util.OmniboxTestUtils;
@@ -37,24 +27,21 @@
/**
* Tests for toolbar manager behavior.
*/
-@RunWith(ChromeJUnit4ClassRunner.class)
-@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE,
- ChromeActivityTestRule.DISABLE_NETWORK_PREDICTION_FLAG})
-public class ToolbarTest {
- @Rule
- public ChromeActivityTestRule<ChromeActivity> mActivityTestRule =
- new ChromeActivityTestRule<>(ChromeActivity.class);
-
+public class ToolbarTest extends ChromeActivityTestCaseBase<ChromeActivity> {
private static final String TEST_PAGE = "/chrome/test/data/android/test.html";
- @Before
- public void setUp() throws InterruptedException {
- mActivityTestRule.startMainActivityOnBlankPage();
+ public ToolbarTest() {
+ super(ChromeActivity.class);
+ }
+
+ @Override
+ public void startMainActivity() throws InterruptedException {
+ startMainActivityOnBlankPage();
}
private void findInPageFromMenu() {
- MenuUtils.invokeCustomMenuActionSync(InstrumentationRegistry.getInstrumentation(),
- mActivityTestRule.getActivity(), R.id.find_in_page_id);
+ MenuUtils.invokeCustomMenuActionSync(getInstrumentation(),
+ getActivity(), R.id.find_in_page_id);
waitForFindInPageVisibility(true);
}
@@ -63,9 +50,8 @@
CriteriaHelper.pollUiThread(new Criteria() {
@Override
public boolean isSatisfied() {
- FindToolbar findToolbar =
- (FindToolbar) mActivityTestRule.getActivity().findViewById(
- R.id.find_toolbar);
+ FindToolbar findToolbar = (FindToolbar) getActivity().findViewById(
+ R.id.find_toolbar);
boolean isVisible = findToolbar != null && findToolbar.isShown();
return (visible == isVisible) && !findToolbar.isAnimating();
@@ -84,19 +70,18 @@
return isShowingError[0];
}
- @Test
@MediumTest
public void testNTPNavigatesToErrorPageOnDisconnectedNetwork() throws Exception {
- EmbeddedTestServer testServer = EmbeddedTestServer.createAndStartServer(
- InstrumentationRegistry.getInstrumentation().getContext());
+ EmbeddedTestServer testServer =
+ EmbeddedTestServer.createAndStartServer(getInstrumentation().getContext());
String testUrl = testServer.getURL(TEST_PAGE);
- Tab tab = mActivityTestRule.getActivity().getActivityTab();
+ Tab tab = getActivity().getActivityTab();
// Load new tab page.
- mActivityTestRule.loadUrl(UrlConstants.NTP_URL);
- Assert.assertEquals(UrlConstants.NTP_URL, tab.getUrl());
- Assert.assertFalse(isErrorPage(tab));
+ loadUrl(UrlConstants.NTP_URL);
+ assertEquals(UrlConstants.NTP_URL, tab.getUrl());
+ assertFalse(isErrorPage(tab));
// Stop the server and also disconnect the network.
testServer.stopAndDestroyServer();
@@ -107,19 +92,18 @@
}
});
- mActivityTestRule.loadUrl(testUrl);
- Assert.assertEquals(testUrl, tab.getUrl());
- Assert.assertTrue(isErrorPage(tab));
+ loadUrl(testUrl);
+ assertEquals(testUrl, tab.getUrl());
+ assertTrue(isErrorPage(tab));
}
- @Test
@MediumTest
@Restriction(ChromeRestriction.RESTRICTION_TYPE_TABLET)
@Feature({"Omnibox"})
public void testFindInPageDismissedOnOmniboxFocus() {
findInPageFromMenu();
- UrlBar urlBar = (UrlBar) mActivityTestRule.getActivity().findViewById(R.id.url_bar);
+ UrlBar urlBar = (UrlBar) getActivity().findViewById(R.id.url_bar);
OmniboxTestUtils.toggleUrlBarFocus(urlBar, true);
OmniboxTestUtils.waitForFocusAndKeyboardActive(urlBar, true);

Powered by Google App Engine
This is Rietveld 408576698