| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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.test.suitebuilder.annotation.MediumTest; | 7 import android.test.suitebuilder.annotation.MediumTest; |
| 8 | 8 |
| 9 import org.chromium.android_webview.AwContents; | 9 import org.chromium.android_webview.AwContents; |
| 10 import org.chromium.android_webview.AwContentsClient; | 10 import org.chromium.android_webview.AwContentsClient; |
| 11 import org.chromium.android_webview.AwSettings; | 11 import org.chromium.android_webview.AwSettings; |
| 12 import org.chromium.base.annotations.SuppressFBWarnings; | 12 import org.chromium.base.annotations.SuppressFBWarnings; |
| 13 import org.chromium.base.test.util.Feature; | 13 import org.chromium.base.test.util.Feature; |
| 14 import org.chromium.base.test.util.parameter.ParameterizedTest; |
| 14 import org.chromium.content.browser.test.util.CallbackHelper; | 15 import org.chromium.content.browser.test.util.CallbackHelper; |
| 15 import org.chromium.ui.gfx.DeviceDisplayInfo; | 16 import org.chromium.ui.gfx.DeviceDisplayInfo; |
| 16 | 17 |
| 17 import java.util.Locale; | 18 import java.util.Locale; |
| 18 import java.util.concurrent.Callable; | 19 import java.util.concurrent.Callable; |
| 19 | 20 |
| 20 /** | 21 /** |
| 21 * Tests for legacy quirks (compatibility with WebView Classic). | 22 * Tests for legacy quirks (compatibility with WebView Classic). |
| 22 */ | 23 */ |
| 23 public class AwLegacyQuirksTest extends AwTestBase { | 24 public class AwLegacyQuirksTest extends AwTestBase { |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 settings.setJavaScriptEnabled(true); | 236 settings.setJavaScriptEnabled(true); |
| 236 settings.setUseWideViewPort(true); | 237 settings.setUseWideViewPort(true); |
| 237 | 238 |
| 238 loadDataSync(awContents, onPageFinishedHelper, page, "text/html", false)
; | 239 loadDataSync(awContents, onPageFinishedHelper, page, "text/html", false)
; |
| 239 int width = Integer.parseInt(getTitleOnUiThread(awContents)); | 240 int width = Integer.parseInt(getTitleOnUiThread(awContents)); |
| 240 assertEquals(pageWidth, width); | 241 assertEquals(pageWidth, width); |
| 241 } | 242 } |
| 242 | 243 |
| 243 @MediumTest | 244 @MediumTest |
| 244 @Feature({"AndroidWebView"}) | 245 @Feature({"AndroidWebView"}) |
| 246 // Run in single-process mode only. Blocked by rendering support crbug.com/5
26842. |
| 247 @ParameterizedTest.Set |
| 245 public void testInitialScaleClobberQuirk() throws Throwable { | 248 public void testInitialScaleClobberQuirk() throws Throwable { |
| 246 final TestAwContentsClient contentClient = new TestAwContentsClient(); | 249 final TestAwContentsClient contentClient = new TestAwContentsClient(); |
| 247 final AwTestContainerView testContainerView = | 250 final AwTestContainerView testContainerView = |
| 248 createAwTestContainerViewOnMainSyncInQuirksMode(contentClient); | 251 createAwTestContainerViewOnMainSyncInQuirksMode(contentClient); |
| 249 final AwContents awContents = testContainerView.getAwContents(); | 252 final AwContents awContents = testContainerView.getAwContents(); |
| 250 AwSettings settings = getAwSettingsOnUiThread(awContents); | 253 AwSettings settings = getAwSettingsOnUiThread(awContents); |
| 251 CallbackHelper onPageFinishedHelper = contentClient.getOnPageFinishedHel
per(); | 254 CallbackHelper onPageFinishedHelper = contentClient.getOnPageFinishedHel
per(); |
| 252 | 255 |
| 253 final String pageTemplate = "<html><head>" | 256 final String pageTemplate = "<html><head>" |
| 254 + "<meta name='viewport' content='initial-scale=%d' />" | 257 + "<meta name='viewport' content='initial-scale=%d' />" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 269 // The following call to set initial scale will be ignored. However, a t
emporary | 272 // The following call to set initial scale will be ignored. However, a t
emporary |
| 270 // page scale change may occur, and this makes the usual onScaleChanged-
based workflow | 273 // page scale change may occur, and this makes the usual onScaleChanged-
based workflow |
| 271 // flaky. So instead, we are just polling the scale until it becomes 1.0
. | 274 // flaky. So instead, we are just polling the scale until it becomes 1.0
. |
| 272 settings.setInitialPageScale(50); | 275 settings.setInitialPageScale(50); |
| 273 loadDataSync(awContents, onPageFinishedHelper, page, "text/html", false)
; | 276 loadDataSync(awContents, onPageFinishedHelper, page, "text/html", false)
; |
| 274 ensureScaleBecomes(1.0f, awContents); | 277 ensureScaleBecomes(1.0f, awContents); |
| 275 } | 278 } |
| 276 | 279 |
| 277 @MediumTest | 280 @MediumTest |
| 278 @Feature({"AndroidWebView"}) | 281 @Feature({"AndroidWebView"}) |
| 282 // Run in single-process mode only. Blocked by rendering support crbug.com/5
26842. |
| 283 @ParameterizedTest.Set |
| 279 public void testNoUserScalableQuirk() throws Throwable { | 284 public void testNoUserScalableQuirk() throws Throwable { |
| 280 final TestAwContentsClient contentClient = new TestAwContentsClient(); | 285 final TestAwContentsClient contentClient = new TestAwContentsClient(); |
| 281 final AwTestContainerView testContainerView = | 286 final AwTestContainerView testContainerView = |
| 282 createAwTestContainerViewOnMainSyncInQuirksMode(contentClient); | 287 createAwTestContainerViewOnMainSyncInQuirksMode(contentClient); |
| 283 final AwContents awContents = testContainerView.getAwContents(); | 288 final AwContents awContents = testContainerView.getAwContents(); |
| 284 CallbackHelper onPageFinishedHelper = contentClient.getOnPageFinishedHel
per(); | 289 CallbackHelper onPageFinishedHelper = contentClient.getOnPageFinishedHel
per(); |
| 285 | 290 |
| 286 final String pageScale4 = "<html><head>" | 291 final String pageScale4 = "<html><head>" |
| 287 + "<meta name='viewport' content='initial-scale=4' />" | 292 + "<meta name='viewport' content='initial-scale=4' />" |
| 288 + "</head><body>" | 293 + "</head><body>" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 private void ensureScaleBecomes(final float targetScale, final AwContents aw
Contents) | 352 private void ensureScaleBecomes(final float targetScale, final AwContents aw
Contents) |
| 348 throws Throwable { | 353 throws Throwable { |
| 349 poll(new Callable<Boolean>() { | 354 poll(new Callable<Boolean>() { |
| 350 @Override | 355 @Override |
| 351 public Boolean call() throws Exception { | 356 public Boolean call() throws Exception { |
| 352 return targetScale == getScaleOnUiThread(awContents); | 357 return targetScale == getScaleOnUiThread(awContents); |
| 353 } | 358 } |
| 354 }); | 359 }); |
| 355 } | 360 } |
| 356 } | 361 } |
| OLD | NEW |