Index: chrome/android/javatests/src/org/chromium/chrome/browser/widget/ToolbarProgressBarTest.java |
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/widget/ToolbarProgressBarTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/widget/ToolbarProgressBarTest.java |
index 7bf8b32ceac48f2348ab59de579326f6fded507a..27c7ac69f303bbfe446851897503a882248f38b1 100644 |
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/widget/ToolbarProgressBarTest.java |
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/widget/ToolbarProgressBarTest.java |
@@ -6,25 +6,15 @@ |
import android.animation.Animator; |
import android.animation.Animator.AnimatorListener; |
-import android.support.test.InstrumentationRegistry; |
import android.support.test.filters.MediumTest; |
import android.view.View; |
-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.base.test.util.RetryOnFailure; |
-import org.chromium.chrome.browser.ChromeActivity; |
-import org.chromium.chrome.browser.ChromeSwitches; |
-import org.chromium.chrome.test.ChromeActivityTestRule; |
-import org.chromium.chrome.test.ChromeJUnit4ClassRunner; |
+import org.chromium.chrome.browser.ChromeTabbedActivity; |
+import org.chromium.chrome.test.ChromeActivityTestCaseBase; |
import org.chromium.chrome.test.util.ChromeRestriction; |
import org.chromium.content.browser.test.util.Criteria; |
import org.chromium.content.browser.test.util.CriteriaHelper; |
@@ -42,36 +32,35 @@ |
/** |
* Tests related to the ToolbarProgressBar. |
*/ |
-@RunWith(ChromeJUnit4ClassRunner.class) |
@RetryOnFailure |
-@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE, |
- ChromeActivityTestRule.DISABLE_NETWORK_PREDICTION_FLAG}) |
-public class ToolbarProgressBarTest { |
- @Rule |
- public ChromeActivityTestRule<ChromeActivity> mActivityTestRule = |
- new ChromeActivityTestRule<>(ChromeActivity.class); |
+public class ToolbarProgressBarTest extends ChromeActivityTestCaseBase<ChromeTabbedActivity> { |
static final int TEST_WAIT_TIME_MS = 60000; |
private static final String TEST_PAGE = "/chrome/test/data/android/progressbar_test.html"; |
- @Before |
- public void setUp() throws InterruptedException { |
- mActivityTestRule.startMainActivityOnBlankPage(); |
+ public ToolbarProgressBarTest() { |
+ super(ChromeTabbedActivity.class); |
+ } |
+ |
+ @Override |
+ public void startMainActivity() throws InterruptedException { |
+ startMainActivityOnBlankPage(); |
} |
/** |
* Test that the progress bar only traverses the page a single time per navigation. |
*/ |
- @Test |
@Feature({"Android-Toolbar"}) |
@MediumTest |
@Restriction(ChromeRestriction.RESTRICTION_TYPE_PHONE) |
- public void testToolbarTraversesScreenOnce() throws InterruptedException, TimeoutException { |
+ public void testToolbarTraversesScreenOnce() |
+ throws InterruptedException, TimeoutException { |
+ |
EmbeddedTestServer testServer = EmbeddedTestServer.createAndStartServer( |
- InstrumentationRegistry.getInstrumentation().getContext()); |
+ getInstrumentation().getContext()); |
final WebContents webContents = |
- mActivityTestRule.getActivity().getActivityTab().getWebContents(); |
+ getActivity().getActivityTab().getWebContents(); |
TestWebContentsObserver observer = new TestWebContentsObserver(webContents); |
// Start and stop load events are carefully tracked; there should be two start-stop pairs |
@@ -79,19 +68,17 @@ |
OnPageStartedHelper startHelper = observer.getOnPageStartedHelper(); |
OnPageFinishedHelper finishHelper = observer.getOnPageFinishedHelper(); |
- ToolbarProgressBar progressBar = mActivityTestRule.getActivity() |
- .getToolbarManager() |
- .getToolbarLayout() |
- .getProgressBar(); |
+ ToolbarProgressBar progressBar = |
+ getActivity().getToolbarManager().getToolbarLayout().getProgressBar(); |
// Reset progress bar start count in case anything else triggered it. |
progressBar.resetStartCountForTesting(); |
// Ensure no load events have occured yet. |
- Assert.assertEquals(0, startHelper.getCallCount()); |
- Assert.assertEquals(0, finishHelper.getCallCount()); |
+ assertEquals(0, startHelper.getCallCount()); |
+ assertEquals(0, finishHelper.getCallCount()); |
- mActivityTestRule.loadUrl(testServer.getURL(TEST_PAGE)); |
+ loadUrl(testServer.getURL(TEST_PAGE)); |
// Wait for the initial page to be loaded if it hasn't already. |
if (finishHelper.getCallCount() == 0) { |
@@ -99,23 +86,23 @@ |
} |
// Exactly one start load and one finish load event should have occured. |
- Assert.assertEquals(1, startHelper.getCallCount()); |
- Assert.assertEquals(1, finishHelper.getCallCount()); |
+ assertEquals(1, startHelper.getCallCount()); |
+ assertEquals(1, finishHelper.getCallCount()); |
// Load content in the iframe of the test page to trigger another load. |
JavaScriptUtils.executeJavaScript(webContents, "loadIframeInPage();"); |
// A load start will be triggered. |
startHelper.waitForCallback(startHelper.getCallCount(), 1); |
- Assert.assertEquals(2, startHelper.getCallCount()); |
+ assertEquals(2, startHelper.getCallCount()); |
// Wait for the iframe to finish loading. |
finishHelper.waitForCallback(finishHelper.getCallCount(), 1); |
- Assert.assertEquals(2, finishHelper.getCallCount()); |
+ assertEquals(2, finishHelper.getCallCount()); |
// Though the page triggered two load events, the progress bar should have only appeared a |
// single time. |
- Assert.assertEquals(1, progressBar.getStartCountForTesting()); |
+ assertEquals(1, progressBar.getStartCountForTesting()); |
} |
/** |
@@ -123,7 +110,6 @@ |
* results in a hidden progress bar. |
* @throws InterruptedException |
*/ |
- @Test |
@Feature({"Android-Toolbar"}) |
@MediumTest |
@Restriction(ChromeRestriction.RESTRICTION_TYPE_PHONE) |
@@ -136,10 +122,8 @@ |
ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
@Override |
public void run() { |
- progressBar.set(mActivityTestRule.getActivity() |
- .getToolbarManager() |
- .getToolbarLayout() |
- .getProgressBar()); |
+ progressBar.set( |
+ getActivity().getToolbarManager().getToolbarLayout().getProgressBar()); |
progressBar.get().setAlphaAnimationDuration(10); |
progressBar.get().setHidingDelay(10); |
progressBar.get().animate().setListener(new AnimatorListener() { |
@@ -188,8 +172,8 @@ |
while (!animationEnded.get() && System.currentTimeMillis() < deadline) { |
onAnimationEnd.wait(deadline - System.currentTimeMillis()); |
} |
- Assert.assertEquals(1.0f, progressBar.get().getAlpha(), 0); |
- Assert.assertEquals(View.VISIBLE, progressBar.get().getVisibility()); |
+ assertEquals(1.0f, progressBar.get().getAlpha()); |
+ assertEquals(View.VISIBLE, progressBar.get().getVisibility()); |
} |
// Clear progress and check that the progress bar is hidden. |
@@ -206,8 +190,8 @@ |
while (!animationEnded.get() && System.currentTimeMillis() < deadline) { |
onAnimationEnd.wait(deadline - System.currentTimeMillis()); |
} |
- Assert.assertEquals(0.0f, progressBar.get().getAlpha(), 0); |
- Assert.assertNotSame(View.VISIBLE, progressBar.get().getVisibility()); |
+ assertEquals(0.0f, progressBar.get().getAlpha()); |
+ assertNotSame(View.VISIBLE, progressBar.get().getVisibility()); |
} |
} |
} |