Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: android_webview/javatests/src/org/chromium/android_webview/test/AwLegacyQuirksTest.java

Issue 689473005: aw: Do not merge kModeProcess into kModeDraw (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: style Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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.base.test.util.DisabledTest;
10 import org.chromium.android_webview.AwContents; 9 import org.chromium.android_webview.AwContents;
11 import org.chromium.android_webview.AwContentsClient; 10 import org.chromium.android_webview.AwContentsClient;
12 import org.chromium.android_webview.AwSettings; 11 import org.chromium.android_webview.AwSettings;
13 import org.chromium.base.test.util.Feature; 12 import org.chromium.base.test.util.Feature;
14 import org.chromium.content.browser.test.util.CallbackHelper; 13 import org.chromium.content.browser.test.util.CallbackHelper;
15 import org.chromium.ui.gfx.DeviceDisplayInfo; 14 import org.chromium.ui.gfx.DeviceDisplayInfo;
16 15
17 import java.util.Locale; 16 import java.util.Locale;
18 import java.util.concurrent.Callable; 17 import java.util.concurrent.Callable;
19 18
20 /** 19 /**
21 * Tests for legacy quirks (compatibility with WebView Classic). 20 * Tests for legacy quirks (compatibility with WebView Classic).
22 */ 21 */
23 public class AwLegacyQuirksTest extends AwTestBase { 22 public class AwLegacyQuirksTest extends AwTestBase {
24 23
25 @MediumTest 24 @MediumTest
26 @Feature({"AndroidWebView"}) 25 @Feature({"AndroidWebView"})
27 public void testTargetDensityDpi() throws Throwable { 26 public void testTargetDensityDpi() throws Throwable {
28 final TestAwContentsClient contentClient = new TestAwContentsClient(); 27 final TestAwContentsClient contentClient = new TestAwContentsClient();
29 final AwTestContainerView testContainerView = 28 final AwTestContainerView testContainerView =
30 createAwTestContainerViewOnMainSyncInQuirksMode(contentClient); 29 createAwTestContainerViewOnMainSyncInQuirksMode(contentClient);
31 final AwContents awContents = testContainerView.getAwContents(); 30 final AwContents awContents = testContainerView.getAwContents();
32 AwSettings settings = getAwSettingsOnUiThread(awContents); 31 AwSettings settings = getAwSettingsOnUiThread(awContents);
33 CallbackHelper onPageFinishedHelper = contentClient.getOnPageFinishedHel per(); 32 CallbackHelper onPageFinishedHelper = contentClient.getOnPageFinishedHel per();
34 33
35 final String pageTemplate = "<html><head>" + 34 final String pageTemplate = "<html><head>"
36 "<meta name='viewport' content='width=device-width, target-densi tyDpi=%s' />" + 35 + "<meta name='viewport' content='width=device-width, target-den sityDpi=%s' />"
37 "</head><body onload='document.title=document.body.clientWidth'> </body></html>"; 36 + "</head><body onload='document.title=document.body.clientWidth '></body></html>";
38 final String pageDeviceDpi = String.format((Locale) null, pageTemplate, "device-dpi"); 37 final String pageDeviceDpi = String.format((Locale) null, pageTemplate, "device-dpi");
39 final String pageHighDpi = String.format((Locale) null, pageTemplate, "h igh-dpi"); 38 final String pageHighDpi = String.format((Locale) null, pageTemplate, "h igh-dpi");
40 final String pageDpi100 = String.format((Locale) null, pageTemplate, "10 0"); 39 final String pageDpi100 = String.format((Locale) null, pageTemplate, "10 0");
41 40
42 settings.setJavaScriptEnabled(true); 41 settings.setJavaScriptEnabled(true);
43 42
44 DeviceDisplayInfo deviceInfo = 43 DeviceDisplayInfo deviceInfo =
45 DeviceDisplayInfo.create(getInstrumentation().getTargetContext() ); 44 DeviceDisplayInfo.create(getInstrumentation().getTargetContext() );
46 loadDataSync(awContents, onPageFinishedHelper, pageDeviceDpi, "text/html ", false); 45 loadDataSync(awContents, onPageFinishedHelper, pageDeviceDpi, "text/html ", false);
47 int actualWidth = Integer.parseInt(getTitleOnUiThread(awContents)); 46 int actualWidth = Integer.parseInt(getTitleOnUiThread(awContents));
(...skipping 14 matching lines...) Expand all
62 @MediumTest 61 @MediumTest
63 @Feature({"AndroidWebView"}) 62 @Feature({"AndroidWebView"})
64 public void testWideViewportInitialScaleDoesNotExpandFixedLayoutWidth() thro ws Throwable { 63 public void testWideViewportInitialScaleDoesNotExpandFixedLayoutWidth() thro ws Throwable {
65 final TestAwContentsClient contentClient = new TestAwContentsClient(); 64 final TestAwContentsClient contentClient = new TestAwContentsClient();
66 final AwTestContainerView testContainerView = 65 final AwTestContainerView testContainerView =
67 createAwTestContainerViewOnMainSyncInQuirksMode(contentClient); 66 createAwTestContainerViewOnMainSyncInQuirksMode(contentClient);
68 final AwContents awContents = testContainerView.getAwContents(); 67 final AwContents awContents = testContainerView.getAwContents();
69 AwSettings settings = getAwSettingsOnUiThread(awContents); 68 AwSettings settings = getAwSettingsOnUiThread(awContents);
70 CallbackHelper onPageFinishedHelper = contentClient.getOnPageFinishedHel per(); 69 CallbackHelper onPageFinishedHelper = contentClient.getOnPageFinishedHel per();
71 70
72 final String page = "<html><head>" + 71 final String page = "<html><head>"
73 "<meta name='viewport' content='width=device-width, initial-scal e=0.5' />" + 72 + "<meta name='viewport' content='width=device-width, initial-sc ale=0.5' />"
74 "</head><body onload='document.title=document.body.clientWidth'> </body></html>"; 73 + "</head><body onload='document.title=document.body.clientWidth '></body></html>";
75 74
76 settings.setJavaScriptEnabled(true); 75 settings.setJavaScriptEnabled(true);
77 settings.setUseWideViewPort(true); 76 settings.setUseWideViewPort(true);
78 77
79 DeviceDisplayInfo deviceInfo = 78 DeviceDisplayInfo deviceInfo =
80 DeviceDisplayInfo.create(getInstrumentation().getTargetContext() ); 79 DeviceDisplayInfo.create(getInstrumentation().getTargetContext() );
81 loadDataSync(awContents, onPageFinishedHelper, page, "text/html", false) ; 80 loadDataSync(awContents, onPageFinishedHelper, page, "text/html", false) ;
82 float displayWidth = (float) (deviceInfo.getDisplayWidth() / deviceInfo. getDIPScale()); 81 float displayWidth = (float) (deviceInfo.getDisplayWidth() / deviceInfo. getDIPScale());
83 int actualWidth = Integer.parseInt(getTitleOnUiThread(awContents)); 82 int actualWidth = Integer.parseInt(getTitleOnUiThread(awContents));
84 assertEquals(displayWidth, actualWidth, 10f); 83 assertEquals(displayWidth, actualWidth, 10f);
85 assertEquals(1.0f, getScaleOnUiThread(awContents)); 84 assertEquals(1.0f, getScaleOnUiThread(awContents));
86 } 85 }
87 86
88 @MediumTest 87 @MediumTest
89 @Feature({"AndroidWebView"}) 88 @Feature({"AndroidWebView"})
90 public void testZeroValuesQuirk() throws Throwable { 89 public void testZeroValuesQuirk() throws Throwable {
91 final TestAwContentsClient contentClient = new TestAwContentsClient(); 90 final TestAwContentsClient contentClient = new TestAwContentsClient();
92 final AwTestContainerView testContainerView = 91 final AwTestContainerView testContainerView =
93 createAwTestContainerViewOnMainSyncInQuirksMode(contentClient); 92 createAwTestContainerViewOnMainSyncInQuirksMode(contentClient);
94 final AwContents awContents = testContainerView.getAwContents(); 93 final AwContents awContents = testContainerView.getAwContents();
95 AwSettings settings = getAwSettingsOnUiThread(awContents); 94 AwSettings settings = getAwSettingsOnUiThread(awContents);
96 CallbackHelper onPageFinishedHelper = contentClient.getOnPageFinishedHel per(); 95 CallbackHelper onPageFinishedHelper = contentClient.getOnPageFinishedHel per();
97 96
98 final String page = "<html><head>" + 97 final String page = "<html><head>"
99 "<meta name='viewport' content='width=0, height=0, initial-scale =0.0, " + 98 + "<meta name='viewport' content='width=0, height=0, initial-sca le=0.0, "
100 " minimum-scale=0.0, maximum-scale=0.0' />" + 99 + " minimum-scale=0.0, maximum-scale=0.0' />"
101 "</head><body onload='document.title=document.body.clientWidth'> </body></html>"; 100 + "</head><body onload='document.title=document.body.clientWidth '></body></html>";
102 101
103 settings.setJavaScriptEnabled(true); 102 settings.setJavaScriptEnabled(true);
104 103
105 DeviceDisplayInfo deviceInfo = 104 DeviceDisplayInfo deviceInfo =
106 DeviceDisplayInfo.create(getInstrumentation().getTargetContext() ); 105 DeviceDisplayInfo.create(getInstrumentation().getTargetContext() );
107 loadDataSync(awContents, onPageFinishedHelper, page, "text/html", false) ; 106 loadDataSync(awContents, onPageFinishedHelper, page, "text/html", false) ;
108 float displayWidth = (float) (deviceInfo.getDisplayWidth() / deviceInfo. getDIPScale()); 107 float displayWidth = (float) (deviceInfo.getDisplayWidth() / deviceInfo. getDIPScale());
109 int actualWidth = Integer.parseInt(getTitleOnUiThread(awContents)); 108 int actualWidth = Integer.parseInt(getTitleOnUiThread(awContents));
110 assertEquals(displayWidth, actualWidth, 10f); 109 assertEquals(displayWidth, actualWidth, 10f);
111 assertEquals(1.0f, getScaleOnUiThread(awContents)); 110 assertEquals(1.0f, getScaleOnUiThread(awContents));
(...skipping 15 matching lines...) Expand all
127 AwSettings settings = getAwSettingsOnUiThread(awContents); 126 AwSettings settings = getAwSettingsOnUiThread(awContents);
128 CallbackHelper onPageFinishedHelper = contentClient.getOnPageFinishedHel per(); 127 CallbackHelper onPageFinishedHelper = contentClient.getOnPageFinishedHel per();
129 128
130 settings.setJavaScriptEnabled(true); 129 settings.setJavaScriptEnabled(true);
131 130
132 loadUrlSync(awContents, onPageFinishedHelper, "about:blank"); 131 loadUrlSync(awContents, onPageFinishedHelper, "about:blank");
133 132
134 DeviceDisplayInfo deviceInfo = 133 DeviceDisplayInfo deviceInfo =
135 DeviceDisplayInfo.create(getInstrumentation().getTargetContext() ); 134 DeviceDisplayInfo.create(getInstrumentation().getTargetContext() );
136 float dipScale = (float) deviceInfo.getDIPScale(); 135 float dipScale = (float) deviceInfo.getDIPScale();
137 float physicalDisplayWidth = deviceInfo.getPhysicalDisplayWidth() != 0 ? 136 float physicalDisplayWidth = deviceInfo.getPhysicalDisplayWidth() != 0
138 deviceInfo.getPhysicalDisplayWidth() : 137 ? deviceInfo.getPhysicalDisplayWidth()
139 deviceInfo.getDisplayWidth(); 138 : deviceInfo.getDisplayWidth();
140 float cssDisplayWidth = physicalDisplayWidth / dipScale; 139 float cssDisplayWidth = physicalDisplayWidth / dipScale;
141 float physicalDisplayHeight = deviceInfo.getPhysicalDisplayHeight() != 0 ? 140 float physicalDisplayHeight = deviceInfo.getPhysicalDisplayHeight() != 0
142 deviceInfo.getPhysicalDisplayHeight() : 141 ? deviceInfo.getPhysicalDisplayHeight()
143 deviceInfo.getDisplayHeight(); 142 : deviceInfo.getDisplayHeight();
144 float cssDisplayHeight = physicalDisplayHeight / dipScale; 143 float cssDisplayHeight = physicalDisplayHeight / dipScale;
145 144
146 float screenWidth = Integer.parseInt( 145 float screenWidth = Integer.parseInt(
147 executeJavaScriptAndWaitForResult(awContents, contentClient, "sc reen.width")); 146 executeJavaScriptAndWaitForResult(awContents, contentClient, "sc reen.width"));
148 assertEquals(physicalDisplayWidth, screenWidth, 10f); 147 assertEquals(physicalDisplayWidth, screenWidth, 10f);
149 float screenAvailWidth = Integer.parseInt( 148 float screenAvailWidth = Integer.parseInt(
150 executeJavaScriptAndWaitForResult(awContents, contentClient, "sc reen.availWidth")); 149 executeJavaScriptAndWaitForResult(awContents, contentClient, "sc reen.availWidth"));
151 assertEquals(physicalDisplayWidth, screenAvailWidth, 10f); 150 assertEquals(physicalDisplayWidth, screenAvailWidth, 10f);
152 float outerWidth = Integer.parseInt( 151 float outerWidth = Integer.parseInt(
153 executeJavaScriptAndWaitForResult(awContents, contentClient, "ou terWidth")); 152 executeJavaScriptAndWaitForResult(awContents, contentClient, "ou terWidth"));
(...skipping 27 matching lines...) Expand all
181 public void testMetaMergeContentQuirk() throws Throwable { 180 public void testMetaMergeContentQuirk() throws Throwable {
182 final TestAwContentsClient contentClient = new TestAwContentsClient(); 181 final TestAwContentsClient contentClient = new TestAwContentsClient();
183 final AwTestContainerView testContainerView = 182 final AwTestContainerView testContainerView =
184 createAwTestContainerViewOnMainSyncInQuirksMode(contentClient); 183 createAwTestContainerViewOnMainSyncInQuirksMode(contentClient);
185 final AwContents awContents = testContainerView.getAwContents(); 184 final AwContents awContents = testContainerView.getAwContents();
186 AwSettings settings = getAwSettingsOnUiThread(awContents); 185 AwSettings settings = getAwSettingsOnUiThread(awContents);
187 CallbackHelper onPageFinishedHelper = contentClient.getOnPageFinishedHel per(); 186 CallbackHelper onPageFinishedHelper = contentClient.getOnPageFinishedHel per();
188 187
189 final int pageWidth = 3000; 188 final int pageWidth = 3000;
190 final float pageScale = 1.0f; 189 final float pageScale = 1.0f;
191 final String page = String.format((Locale) null, "<html><head>" + 190 final String page = String.format((Locale) null, "<html><head>"
192 "<meta name='viewport' content='width=%d' />" + 191 + "<meta name='viewport' content='width=%d' />"
193 "<meta name='viewport' content='initial-scale=%.1f' />" + 192 + "<meta name='viewport' content='initial-scale=%.1f' />"
194 "<meta name='viewport' content='user-scalable=0' />" + 193 + "<meta name='viewport' content='user-scalable=0' />"
195 "</head><body onload='document.title=document.body.clientWidth'> </body></html>", 194 + "</head><body onload='document.title=document.body.clientWidth '></body></html>",
196 pageWidth, pageScale); 195 pageWidth, pageScale);
197 196
198 settings.setJavaScriptEnabled(true); 197 settings.setJavaScriptEnabled(true);
199 settings.setUseWideViewPort(true); 198 settings.setUseWideViewPort(true);
200 settings.setBuiltInZoomControls(true); 199 settings.setBuiltInZoomControls(true);
201 settings.setSupportZoom(true); 200 settings.setSupportZoom(true);
202 201
203 loadDataSync(awContents, onPageFinishedHelper, page, "text/html", false) ; 202 loadDataSync(awContents, onPageFinishedHelper, page, "text/html", false) ;
204 // ContentView must update itself according to the viewport setup. 203 // ContentView must update itself according to the viewport setup.
205 // As we specify 'user-scalable=0', the page must become non-zoomable. 204 // As we specify 'user-scalable=0', the page must become non-zoomable.
(...skipping 12 matching lines...) Expand all
218 @Feature({"AndroidWebView"}) 217 @Feature({"AndroidWebView"})
219 public void testMetaMergeContentQuirkOverrides() throws Throwable { 218 public void testMetaMergeContentQuirkOverrides() throws Throwable {
220 final TestAwContentsClient contentClient = new TestAwContentsClient(); 219 final TestAwContentsClient contentClient = new TestAwContentsClient();
221 final AwTestContainerView testContainerView = 220 final AwTestContainerView testContainerView =
222 createAwTestContainerViewOnMainSyncInQuirksMode(contentClient); 221 createAwTestContainerViewOnMainSyncInQuirksMode(contentClient);
223 final AwContents awContents = testContainerView.getAwContents(); 222 final AwContents awContents = testContainerView.getAwContents();
224 AwSettings settings = getAwSettingsOnUiThread(awContents); 223 AwSettings settings = getAwSettingsOnUiThread(awContents);
225 CallbackHelper onPageFinishedHelper = contentClient.getOnPageFinishedHel per(); 224 CallbackHelper onPageFinishedHelper = contentClient.getOnPageFinishedHel per();
226 225
227 final int pageWidth = 3000; 226 final int pageWidth = 3000;
228 final String page = String.format((Locale) null, "<html><head>" + 227 final String page = String.format((Locale) null, "<html><head>"
229 "<meta name='viewport' content='width=device-width' />" + 228 + "<meta name='viewport' content='width=device-width' />"
230 "<meta name='viewport' content='width=%d' />" + 229 + "<meta name='viewport' content='width=%d' />"
231 "</head><body onload='document.title=document.body.clientWidth'> </body></html>", 230 + "</head><body onload='document.title=document.body.clientWidth '></body></html>",
232 pageWidth); 231 pageWidth);
233 232
234 settings.setJavaScriptEnabled(true); 233 settings.setJavaScriptEnabled(true);
235 settings.setUseWideViewPort(true); 234 settings.setUseWideViewPort(true);
236 235
237 loadDataSync(awContents, onPageFinishedHelper, page, "text/html", false) ; 236 loadDataSync(awContents, onPageFinishedHelper, page, "text/html", false) ;
238 int width = Integer.parseInt(getTitleOnUiThread(awContents)); 237 int width = Integer.parseInt(getTitleOnUiThread(awContents));
239 assertEquals(pageWidth, width); 238 assertEquals(pageWidth, width);
240 } 239 }
241 240
242 @MediumTest 241 @MediumTest
243 @Feature({"AndroidWebView"}) 242 @Feature({"AndroidWebView"})
244 public void testInitialScaleClobberQuirk() throws Throwable { 243 public void testInitialScaleClobberQuirk() throws Throwable {
245 final TestAwContentsClient contentClient = new TestAwContentsClient(); 244 final TestAwContentsClient contentClient = new TestAwContentsClient();
246 final AwTestContainerView testContainerView = 245 final AwTestContainerView testContainerView =
247 createAwTestContainerViewOnMainSyncInQuirksMode(contentClient); 246 createAwTestContainerViewOnMainSyncInQuirksMode(contentClient);
248 final AwContents awContents = testContainerView.getAwContents(); 247 final AwContents awContents = testContainerView.getAwContents();
249 AwSettings settings = getAwSettingsOnUiThread(awContents); 248 AwSettings settings = getAwSettingsOnUiThread(awContents);
250 CallbackHelper onPageFinishedHelper = contentClient.getOnPageFinishedHel per(); 249 CallbackHelper onPageFinishedHelper = contentClient.getOnPageFinishedHel per();
251 250
252 final String pageTemplate = "<html><head>" + 251 final String pageTemplate = "<html><head>"
253 "<meta name='viewport' content='initial-scale=%d' />" + 252 + "<meta name='viewport' content='initial-scale=%d' />"
254 "</head><body>" + 253 + "</head><body>"
255 "<div style='width:10000px;height:200px'>A big div</div>" + 254 + "<div style='width:10000px;height:200px'>A big div</div>"
256 "</body></html>"; 255 + "</body></html>";
257 final String pageScale4 = String.format((Locale) null, pageTemplate, 4); 256 final String pageScale4 = String.format((Locale) null, pageTemplate, 4);
258 final String page = String.format((Locale) null, pageTemplate, 1); 257 final String page = String.format((Locale) null, pageTemplate, 1);
259 258
260 // Page scale updates are asynchronous. There is an issue that we can't 259 // Page scale updates are asynchronous. There is an issue that we can't
261 // reliably check, whether the scale as NOT changed (i.e. remains to be 1.0). 260 // reliably check, whether the scale as NOT changed (i.e. remains to be 1.0).
262 // So we first change the scale to some non-default value, and then wait 261 // So we first change the scale to some non-default value, and then wait
263 // until it gets back to 1.0. 262 // until it gets back to 1.0.
264 int onScaleChangedCallCount = contentClient.getOnScaleChangedHelper().ge tCallCount(); 263 int onScaleChangedCallCount = contentClient.getOnScaleChangedHelper().ge tCallCount();
265 loadDataSync(awContents, onPageFinishedHelper, pageScale4, "text/html", false); 264 loadDataSync(awContents, onPageFinishedHelper, pageScale4, "text/html", false);
266 contentClient.getOnScaleChangedHelper().waitForCallback(onScaleChangedCa llCount); 265 contentClient.getOnScaleChangedHelper().waitForCallback(onScaleChangedCa llCount);
267 assertEquals(4.0f, getScaleOnUiThread(awContents)); 266 assertEquals(4.0f, getScaleOnUiThread(awContents));
268 // The following call to set initial scale will be ignored. However, a t emporary 267 // The following call to set initial scale will be ignored. However, a t emporary
269 // page scale change may occur, and this makes the usual onScaleChanged- based workflow 268 // page scale change may occur, and this makes the usual onScaleChanged- based workflow
270 // flaky. So instead, we are just polling the scale until it becomes 1.0 . 269 // flaky. So instead, we are just polling the scale until it becomes 1.0 .
271 settings.setInitialPageScale(50); 270 settings.setInitialPageScale(50);
272 loadDataSync(awContents, onPageFinishedHelper, page, "text/html", false) ; 271 loadDataSync(awContents, onPageFinishedHelper, page, "text/html", false) ;
273 ensureScaleBecomes(1.0f, awContents); 272 ensureScaleBecomes(1.0f, awContents);
274 } 273 }
275 274
276 // This should not be run in software mode. crbug.com/428355.
277 @DisableHardwareAccelerationForTest
278 @MediumTest 275 @MediumTest
279 @Feature({"AndroidWebView"}) 276 @Feature({"AndroidWebView"})
280 public void testNoUserScalableQuirk() throws Throwable { 277 public void testNoUserScalableQuirk() throws Throwable {
281 final TestAwContentsClient contentClient = new TestAwContentsClient(); 278 final TestAwContentsClient contentClient = new TestAwContentsClient();
282 final AwTestContainerView testContainerView = 279 final AwTestContainerView testContainerView =
283 createAwTestContainerViewOnMainSyncInQuirksMode(contentClient); 280 createAwTestContainerViewOnMainSyncInQuirksMode(contentClient);
284 final AwContents awContents = testContainerView.getAwContents(); 281 final AwContents awContents = testContainerView.getAwContents();
285 CallbackHelper onPageFinishedHelper = contentClient.getOnPageFinishedHel per(); 282 CallbackHelper onPageFinishedHelper = contentClient.getOnPageFinishedHel per();
286 283
287 final String pageScale4 = "<html><head>" + 284 final String pageScale4 = "<html><head>"
288 "<meta name='viewport' content='initial-scale=4' />" + 285 + "<meta name='viewport' content='initial-scale=4' />"
289 "</head><body>" + 286 + "</head><body>"
290 "<div style='width:10000px;height:200px'>A big div</div>" + 287 + "<div style='width:10000px;height:200px'>A big div</div>"
291 "</body></html>"; 288 + "</body></html>";
292 final String page = "<html><head>" + 289 final String page = "<html><head>"
293 "<meta name='viewport' " + 290 + "<meta name='viewport' "
294 "content='width=device-width,initial-scale=2,user-scalable=no' / >" + 291 + "content='width=device-width,initial-scale=2,user-scalable=no' />"
295 "</head><body>" + 292 + "</head><body>"
296 "<div style='width:10000px;height:200px'>A big div</div>" + 293 + "<div style='width:10000px;height:200px'>A big div</div>"
297 "</body></html>"; 294 + "</body></html>";
298 295
299 // Page scale updates are asynchronous. There is an issue that we can't 296 // Page scale updates are asynchronous. There is an issue that we can't
300 // reliably check, whether the scale as NOT changed (i.e. remains to be 1.0). 297 // reliably check, whether the scale as NOT changed (i.e. remains to be 1.0).
301 // So we first change the scale to some non-default value, and then wait 298 // So we first change the scale to some non-default value, and then wait
302 // until it gets back to 1.0. 299 // until it gets back to 1.0.
303 int onScaleChangedCallCount = contentClient.getOnScaleChangedHelper().ge tCallCount(); 300 int onScaleChangedCallCount = contentClient.getOnScaleChangedHelper().ge tCallCount();
304 loadDataSync(awContents, onPageFinishedHelper, pageScale4, "text/html", false); 301 loadDataSync(awContents, onPageFinishedHelper, pageScale4, "text/html", false);
305 contentClient.getOnScaleChangedHelper().waitForCallback(onScaleChangedCa llCount); 302 contentClient.getOnScaleChangedHelper().waitForCallback(onScaleChangedCa llCount);
306 assertEquals(4.0f, getScaleOnUiThread(awContents)); 303 assertEquals(4.0f, getScaleOnUiThread(awContents));
307 onScaleChangedCallCount = contentClient.getOnScaleChangedHelper().getCal lCount(); 304 onScaleChangedCallCount = contentClient.getOnScaleChangedHelper().getCal lCount();
308 loadDataSync(awContents, onPageFinishedHelper, page, "text/html", false) ; 305 loadDataSync(awContents, onPageFinishedHelper, page, "text/html", false) ;
309 contentClient.getOnScaleChangedHelper().waitForCallback(onScaleChangedCa llCount); 306 contentClient.getOnScaleChangedHelper().waitForCallback(onScaleChangedCa llCount);
310 assertEquals(1.0f, getScaleOnUiThread(awContents)); 307 assertEquals(1.0f, getScaleOnUiThread(awContents));
311 } 308 }
312 309
313 // background shorthand property must not override background-size when 310 // background shorthand property must not override background-size when
314 // it's already set. 311 // it's already set.
315 @MediumTest 312 @MediumTest
316 @Feature({"AndroidWebView", "Preferences"}) 313 @Feature({"AndroidWebView", "Preferences"})
317 public void testUseLegacyBackgroundSizeShorthandBehavior() throws Throwable { 314 public void testUseLegacyBackgroundSizeShorthandBehavior() throws Throwable {
318 final TestAwContentsClient contentClient = new TestAwContentsClient(); 315 final TestAwContentsClient contentClient = new TestAwContentsClient();
319 final AwTestContainerView testContainerView = 316 final AwTestContainerView testContainerView =
320 createAwTestContainerViewOnMainSyncInQuirksMode(contentClient); 317 createAwTestContainerViewOnMainSyncInQuirksMode(contentClient);
321 final AwContents awContents = testContainerView.getAwContents(); 318 final AwContents awContents = testContainerView.getAwContents();
322 AwSettings settings = getAwSettingsOnUiThread(awContents); 319 AwSettings settings = getAwSettingsOnUiThread(awContents);
323 CallbackHelper onPageFinishedHelper = contentClient.getOnPageFinishedHel per(); 320 CallbackHelper onPageFinishedHelper = contentClient.getOnPageFinishedHel per();
324 final String expectedBackgroundSize = "cover"; 321 final String expectedBackgroundSize = "cover";
325 final String page = "<html><head>" + 322 final String page = "<html><head>"
326 "<script>" + 323 + "<script>"
327 "function getBackgroundSize() {" + 324 + "function getBackgroundSize() {"
328 " var e = document.getElementById('test'); " + 325 + " var e = document.getElementById('test'); "
329 " e.style.backgroundSize = '" + expectedBackgroundSize + "';" + 326 + " e.style.backgroundSize = '" + expectedBackgroundSize + "';"
330 " e.style.background = 'center red url(dummy://test.png) no-rep eat border-box'; " + 327 + " e.style.background = 'center red url(dummy://test.png) no-r epeat border-box'; "
331 " return e.style.backgroundSize; " + 328 + " return e.style.backgroundSize; "
332 "}" + 329 + "}"
333 "</script></head>" + 330 + "</script></head>"
334 "<body onload='document.title=getBackgroundSize()'>" + 331 + "<body onload='document.title=getBackgroundSize()'>"
335 " <div id='test'> </div>" + 332 + " <div id='test'> </div>"
336 "</body></html>"; 333 + "</body></html>";
337 settings.setJavaScriptEnabled(true); 334 settings.setJavaScriptEnabled(true);
338 loadDataSync(awContents, onPageFinishedHelper, page, "text/html", false) ; 335 loadDataSync(awContents, onPageFinishedHelper, page, "text/html", false) ;
339 String actualBackgroundSize = getTitleOnUiThread(awContents); 336 String actualBackgroundSize = getTitleOnUiThread(awContents);
340 assertEquals(expectedBackgroundSize, actualBackgroundSize); 337 assertEquals(expectedBackgroundSize, actualBackgroundSize);
341 } 338 }
342 339
343 private AwTestContainerView createAwTestContainerViewOnMainSyncInQuirksMode( 340 private AwTestContainerView createAwTestContainerViewOnMainSyncInQuirksMode(
344 final AwContentsClient client) throws Exception { 341 final AwContentsClient client) throws Exception {
345 return createAwTestContainerViewOnMainSync(client, true); 342 return createAwTestContainerViewOnMainSync(client, true);
346 } 343 }
347 344
348 private void ensureScaleBecomes(final float targetScale, final AwContents aw Contents) 345 private void ensureScaleBecomes(final float targetScale, final AwContents aw Contents)
349 throws Throwable { 346 throws Throwable {
350 poll(new Callable<Boolean>() { 347 poll(new Callable<Boolean>() {
351 @Override 348 @Override
352 public Boolean call() throws Exception { 349 public Boolean call() throws Exception {
353 return targetScale == getScaleOnUiThread(awContents); 350 return targetScale == getScaleOnUiThread(awContents);
354 } 351 }
355 }); 352 });
356 } 353 }
357 } 354 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698