Index: content/public/android/javatests/src/org/chromium/content/browser/ViewportTest.java |
diff --git a/content/public/android/javatests/src/org/chromium/content/browser/ViewportTest.java b/content/public/android/javatests/src/org/chromium/content/browser/ViewportTest.java |
index dfd6ade311faa4e608240ea35a30b287450e74da..2b86f8f0bb36ab4b9ad8ce92d374803c4446adc2 100644 |
--- a/content/public/android/javatests/src/org/chromium/content/browser/ViewportTest.java |
+++ b/content/public/android/javatests/src/org/chromium/content/browser/ViewportTest.java |
@@ -5,22 +5,32 @@ |
package org.chromium.content.browser; |
import android.content.Context; |
+import android.support.test.InstrumentationRegistry; |
import android.support.test.filters.MediumTest; |
import android.util.DisplayMetrics; |
import android.view.WindowManager; |
+import org.junit.Assert; |
+import org.junit.Rule; |
+import org.junit.Test; |
+import org.junit.runner.RunWith; |
+ |
+import org.chromium.base.test.BaseJUnit4ClassRunner; |
import org.chromium.base.test.util.Feature; |
import org.chromium.content.browser.test.util.JavaScriptUtils; |
-import org.chromium.content_shell_apk.ContentShellTestBase; |
+import org.chromium.content_shell_apk.ContentShellActivityTestRule; |
/** |
* Test suite for viewport-related properties. |
*/ |
-public class ViewportTest extends ContentShellTestBase { |
+@RunWith(BaseJUnit4ClassRunner.class) |
+public class ViewportTest { |
+ @Rule |
+ public ContentShellActivityTestRule mActivityTestRule = new ContentShellActivityTestRule(); |
protected String evaluateStringValue(String expression) throws Throwable { |
- return JavaScriptUtils.executeJavaScriptAndWaitForResult(getWebContents(), |
- expression); |
+ return JavaScriptUtils.executeJavaScriptAndWaitForResult( |
+ mActivityTestRule.getWebContents(), expression); |
} |
protected float evaluateFloatValue(String expression) throws Throwable { |
@@ -31,25 +41,27 @@ public class ViewportTest extends ContentShellTestBase { |
return Integer.parseInt(evaluateStringValue(expression)); |
} |
+ @Test |
@MediumTest |
@Feature({"Viewport", "InitialViewportSize"}) |
public void testDefaultViewportSize() throws Throwable { |
- launchContentShellWithUrl("about:blank"); |
- waitForActiveShellToBeDoneLoading(); |
+ mActivityTestRule.launchContentShellWithUrl("about:blank"); |
+ mActivityTestRule.waitForActiveShellToBeDoneLoading(); |
- Context context = getInstrumentation().getTargetContext(); |
+ Context context = InstrumentationRegistry.getInstrumentation().getTargetContext(); |
WindowManager winManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); |
DisplayMetrics metrics = new DisplayMetrics(); |
winManager.getDefaultDisplay().getMetrics(metrics); |
// window.devicePixelRatio should match the default display. Only check to 1 decimal place |
// to allow for rounding. |
- assertEquals(metrics.density, evaluateFloatValue("window.devicePixelRatio"), 0.1); |
+ Assert.assertEquals(metrics.density, evaluateFloatValue("window.devicePixelRatio"), 0.1); |
// Check that the viewport width is vaguely sensible. |
int viewportWidth = evaluateIntegerValue("document.documentElement.clientWidth"); |
- assertTrue(Math.abs(evaluateIntegerValue("window.innerWidth") - viewportWidth) <= 1); |
- assertTrue(viewportWidth >= 979); |
- assertTrue(viewportWidth <= Math.max(981, metrics.widthPixels / metrics.density + 1)); |
+ Assert.assertTrue(Math.abs(evaluateIntegerValue("window.innerWidth") - viewportWidth) <= 1); |
+ Assert.assertTrue(viewportWidth >= 979); |
+ Assert.assertTrue( |
+ viewportWidth <= Math.max(981, metrics.widthPixels / metrics.density + 1)); |
} |
} |