| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.android_webview.test; | 5 package org.chromium.android_webview.test; |
| 6 | 6 |
| 7 import android.content.Context; | 7 import android.content.Context; |
| 8 import android.os.Build; | 8 import android.os.Build; |
| 9 import android.test.suitebuilder.annotation.SmallTest; | 9 import android.test.suitebuilder.annotation.SmallTest; |
| 10 import android.webkit.WebSettings; | 10 import android.webkit.WebSettings; |
| 11 | 11 |
| 12 import org.apache.http.Header; | 12 import org.apache.http.Header; |
| 13 import org.apache.http.HttpRequest; | 13 import org.apache.http.HttpRequest; |
| 14 import org.chromium.android_webview.AndroidProtocolHandler; | 14 import org.chromium.android_webview.AndroidProtocolHandler; |
| 15 import org.chromium.android_webview.AwContents; | 15 import org.chromium.android_webview.AwContents; |
| 16 import org.chromium.android_webview.AwSettings; | 16 import org.chromium.android_webview.AwSettings; |
| 17 import org.chromium.android_webview.test.util.CommonResources; | 17 import org.chromium.android_webview.test.util.CommonResources; |
| 18 import org.chromium.android_webview.test.util.ImagePageGenerator; | 18 import org.chromium.android_webview.test.util.ImagePageGenerator; |
| 19 import org.chromium.base.test.util.Feature; | 19 import org.chromium.base.test.util.Feature; |
| 20 import org.chromium.base.test.util.TestFileUtil; | 20 import org.chromium.base.test.util.TestFileUtil; |
| 21 import org.chromium.base.test.util.UrlUtils; | 21 import org.chromium.base.test.util.UrlUtils; |
| 22 import org.chromium.content.browser.ContentSettings; | 22 import org.chromium.content.browser.ContentSettings; |
| 23 import org.chromium.content.browser.ContentSettings.LayoutAlgorithm; | 23 import org.chromium.content.browser.ContentSettings.LayoutAlgorithm; |
| 24 import org.chromium.content.browser.ContentViewCore; | 24 import org.chromium.content.browser.ContentViewCore; |
| 25 import org.chromium.content.browser.test.util.CallbackHelper; | 25 import org.chromium.content.browser.test.util.CallbackHelper; |
| 26 import org.chromium.content.browser.test.util.Criteria; | 26 import org.chromium.content.browser.test.util.Criteria; |
| 27 import org.chromium.content.browser.test.util.CriteriaHelper; | 27 import org.chromium.content.browser.test.util.CriteriaHelper; |
| 28 import org.chromium.content.browser.test.util.HistoryUtils; | 28 import org.chromium.content.browser.test.util.HistoryUtils; |
| 29 import org.chromium.content.common.DeviceInfo; | |
| 30 import org.chromium.net.test.util.TestWebServer; | 29 import org.chromium.net.test.util.TestWebServer; |
| 30 import org.chromium.ui.gfx.DeviceInfo; |
| 31 | 31 |
| 32 import java.util.regex.Matcher; | 32 import java.util.regex.Matcher; |
| 33 import java.util.regex.Pattern; | 33 import java.util.regex.Pattern; |
| 34 import java.util.ArrayList; | 34 import java.util.ArrayList; |
| 35 import java.util.List; | 35 import java.util.List; |
| 36 | 36 |
| 37 /** | 37 /** |
| 38 * A test suite for ContentSettings class. The key objective is to verify that e
ach | 38 * A test suite for ContentSettings class. The key objective is to verify that e
ach |
| 39 * settings applies either to each individual view or to all views of the | 39 * settings applies either to each individual view or to all views of the |
| 40 * application | 40 * application |
| (...skipping 2052 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2093 final String pageNoViewport = String.format(pageTemplate, ""); | 2093 final String pageNoViewport = String.format(pageTemplate, ""); |
| 2094 final String pageViewportDeviceWidth = String.format( | 2094 final String pageViewportDeviceWidth = String.format( |
| 2095 pageTemplate, | 2095 pageTemplate, |
| 2096 "<meta name='viewport' content='width=device-width' />"); | 2096 "<meta name='viewport' content='width=device-width' />"); |
| 2097 final String viewportTagSpecifiedWidth = "3000"; | 2097 final String viewportTagSpecifiedWidth = "3000"; |
| 2098 final String pageViewportSpecifiedWidth = String.format( | 2098 final String pageViewportSpecifiedWidth = String.format( |
| 2099 pageTemplate, | 2099 pageTemplate, |
| 2100 "<meta name='viewport' content='width=" + viewportTagSpecifiedWi
dth + "' />"); | 2100 "<meta name='viewport' content='width=" + viewportTagSpecifiedWi
dth + "' />"); |
| 2101 | 2101 |
| 2102 DeviceInfo deviceInfo = DeviceInfo.create(getInstrumentation().getTarget
Context()); | 2102 DeviceInfo deviceInfo = DeviceInfo.create(getInstrumentation().getTarget
Context()); |
| 2103 int displayWidth = (int) (deviceInfo.getWidth() / deviceInfo.getDPIScale
()); | 2103 int displayWidth = (int) (deviceInfo.getDisplayWidth() / deviceInfo.getD
IPScale()); |
| 2104 | 2104 |
| 2105 settings.setJavaScriptEnabled(true); | 2105 settings.setJavaScriptEnabled(true); |
| 2106 assertFalse(settings.getUseWideViewPort()); | 2106 assertFalse(settings.getUseWideViewPort()); |
| 2107 // When UseWideViewPort is off, "meta viewport" tags are ignored, | 2107 // When UseWideViewPort is off, "meta viewport" tags are ignored, |
| 2108 // and the layout width is set to device width in CSS pixels. | 2108 // and the layout width is set to device width in CSS pixels. |
| 2109 // Thus, all 3 pages will have the same body width. | 2109 // Thus, all 3 pages will have the same body width. |
| 2110 loadDataSync(awContents, onPageFinishedHelper, pageNoViewport, "text/htm
l", false); | 2110 loadDataSync(awContents, onPageFinishedHelper, pageNoViewport, "text/htm
l", false); |
| 2111 int actualWidth = Integer.parseInt(getTitleOnUiThread(awContents)); | 2111 int actualWidth = Integer.parseInt(getTitleOnUiThread(awContents)); |
| 2112 // Avoid rounding errors. | 2112 // Avoid rounding errors. |
| 2113 assertTrue("Expected: " + displayWidth + ", Actual: " + actualWidth, | 2113 assertTrue("Expected: " + displayWidth + ", Actual: " + actualWidth, |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2256 AndroidProtocolHandler.setResourceContextForTesting(getInstrumentation()
.getContext()); | 2256 AndroidProtocolHandler.setResourceContextForTesting(getInstrumentation()
.getContext()); |
| 2257 } | 2257 } |
| 2258 | 2258 |
| 2259 /** | 2259 /** |
| 2260 * Configure the browser to load resources from the browser application. | 2260 * Configure the browser to load resources from the browser application. |
| 2261 */ | 2261 */ |
| 2262 private void resetResourceContext() { | 2262 private void resetResourceContext() { |
| 2263 AndroidProtocolHandler.setResourceContextForTesting(null); | 2263 AndroidProtocolHandler.setResourceContextForTesting(null); |
| 2264 } | 2264 } |
| 2265 } | 2265 } |
| OLD | NEW |