summaryrefslogtreecommitdiffstats
path: root/android_webview/javatests
diff options
context:
space:
mode:
authormnaganov@chromium.org <mnaganov@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-17 03:12:16 +0000
committermnaganov@chromium.org <mnaganov@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-17 03:12:16 +0000
commit5f0a8ee7cedb10313a956caa7a6414928e7e39e6 (patch)
treeff877788f2966008a39d90a0a2b753d29e9ef734 /android_webview/javatests
parent670f62a894c86a35e3a2b279ef884b5e785f11c9 (diff)
downloadchromium_src-5f0a8ee7cedb10313a956caa7a6414928e7e39e6.zip
chromium_src-5f0a8ee7cedb10313a956caa7a6414928e7e39e6.tar.gz
chromium_src-5f0a8ee7cedb10313a956caa7a6414928e7e39e6.tar.bz2
[Android WebView] Enable the Blink quirk for returning screen sizes in physical pixels
This enables the browser to return screen.width / availWidth (and height), @media device-width (and height), window.outerWidth (and height), but not window.innerWidth (and height) in physical rather than CSS pixels. BUG=305236 Review URL: https://codereview.chromium.org/26460004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@229023 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'android_webview/javatests')
-rw-r--r--android_webview/javatests/src/org/chromium/android_webview/test/AwViewportTest.java55
1 files changed, 55 insertions, 0 deletions
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/AwViewportTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/AwViewportTest.java
index 0a76166..efe253a 100644
--- a/android_webview/javatests/src/org/chromium/android_webview/test/AwViewportTest.java
+++ b/android_webview/javatests/src/org/chromium/android_webview/test/AwViewportTest.java
@@ -107,4 +107,59 @@ public class AwViewportTest extends AwTestBase {
assertEquals(displayWidth, (float)actualWidth, 10f);
assertEquals(1.0f, getScaleOnUiThread(awContents));
}
+
+ @MediumTest
+ @Feature({"AndroidWebView"})
+ public void testScreenSizeInPhysicalPixelsQuirk() throws Throwable {
+ final TestAwContentsClient contentClient = new TestAwContentsClient();
+ final AwTestContainerView testContainerView =
+ createAwTestContainerViewOnMainSync(contentClient);
+ final AwContents awContents = testContainerView.getAwContents();
+ AwSettings settings = getAwSettingsOnUiThread(awContents);
+ CallbackHelper onPageFinishedHelper = contentClient.getOnPageFinishedHelper();
+
+ settings.setJavaScriptEnabled(true);
+
+ loadUrlSync(awContents, onPageFinishedHelper, "about:blank");
+
+ DeviceDisplayInfo deviceInfo =
+ DeviceDisplayInfo.create(getInstrumentation().getTargetContext());
+ float dipScale = (float)deviceInfo.getDIPScale();
+ float physicalDisplayWidth = deviceInfo.getDisplayWidth();
+ float cssDisplayWidth = physicalDisplayWidth / dipScale;
+ float physicalDisplayHeight = deviceInfo.getDisplayHeight();
+ float cssDisplayHeight = physicalDisplayHeight / dipScale;
+
+ float screenWidth = Integer.parseInt(
+ executeJavaScriptAndWaitForResult(awContents, contentClient, "screen.width"));
+ assertEquals(physicalDisplayWidth, screenWidth, 10f);
+ float screenAvailWidth = Integer.parseInt(
+ executeJavaScriptAndWaitForResult(awContents, contentClient, "screen.availWidth"));
+ assertEquals(physicalDisplayWidth, screenAvailWidth, 10f);
+ float outerWidth = Integer.parseInt(
+ executeJavaScriptAndWaitForResult(awContents, contentClient, "outerWidth"));
+ float innerWidth = Integer.parseInt(
+ executeJavaScriptAndWaitForResult(awContents, contentClient, "innerWidth"));
+ assertEquals(innerWidth * dipScale, outerWidth, 10f);
+ String deviceWidthEqualsScreenWidth = executeJavaScriptAndWaitForResult(awContents,
+ contentClient,
+ "matchMedia(\"screen and (device-width:" + (int)screenWidth + "px)\").matches");
+ assertEquals("true", deviceWidthEqualsScreenWidth);
+
+ float screenHeight = Integer.parseInt(
+ executeJavaScriptAndWaitForResult(awContents, contentClient, "screen.height"));
+ assertEquals(physicalDisplayHeight, screenHeight, 10f);
+ float screenAvailHeight = Integer.parseInt(
+ executeJavaScriptAndWaitForResult(awContents, contentClient, "screen.availHeight"));
+ assertEquals(physicalDisplayHeight, screenAvailHeight, 10f);
+ float outerHeight = Integer.parseInt(
+ executeJavaScriptAndWaitForResult(awContents, contentClient, "outerHeight"));
+ float innerHeight = Integer.parseInt(
+ executeJavaScriptAndWaitForResult(awContents, contentClient, "innerHeight"));
+ assertEquals(innerHeight * dipScale, outerHeight, 10f);
+ String deviceHeightEqualsScreenHeight = executeJavaScriptAndWaitForResult(awContents,
+ contentClient,
+ "matchMedia(\"screen and (device-height:" + (int)screenHeight + "px)\").matches");
+ assertEquals("true", deviceHeightEqualsScreenHeight);
+ }
}