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

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

Issue 672533002: Enable separatorWrap module in CheckStyle and fix all the issues. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Undo mojo changes Created 6 years, 2 months 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
« no previous file with comments | « no previous file | android_webview/javatests/src/org/chromium/android_webview/test/CookieManagerTest.java » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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.graphics.Point; 8 import android.graphics.Point;
9 import android.net.http.SslError; 9 import android.net.http.SslError;
10 import android.os.Build; 10 import android.os.Build;
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 mAwSettings.setStandardFontFamily(value); 281 mAwSettings.setStandardFontFamily(value);
282 } 282 }
283 283
284 @Override 284 @Override
285 protected void doEnsureSettingHasValue(String value) throws Throwable { 285 protected void doEnsureSettingHasValue(String value) throws Throwable {
286 loadDataSync(getData()); 286 loadDataSync(getData());
287 assertEquals(value, getTitleOnUiThread()); 287 assertEquals(value, getTitleOnUiThread());
288 } 288 }
289 289
290 private String getData() { 290 private String getData() {
291 return "<html><body onload=\"document.title = " + 291 return "<html><body onload=\"document.title = "
292 "getComputedStyle(document.body).getPropertyValue('font-fami ly');\">" 292 + "getComputedStyle(document.body).getPropertyValue('font-fa mily');\">"
293 + "</body></html>"; 293 + "</body></html>";
294 } 294 }
295 } 295 }
296 296
297 class AwSettingsDefaultFontSizeTestHelper extends AwSettingsTestHelper<Integ er> { 297 class AwSettingsDefaultFontSizeTestHelper extends AwSettingsTestHelper<Integ er> {
298 AwSettingsDefaultFontSizeTestHelper( 298 AwSettingsDefaultFontSizeTestHelper(
299 AwTestContainerView containerView, 299 AwTestContainerView containerView,
300 TestAwContentsClient contentViewClient) throws Throwable { 300 TestAwContentsClient contentViewClient) throws Throwable {
301 super(containerView, contentViewClient, true); 301 super(containerView, contentViewClient, true);
302 } 302 }
(...skipping 18 matching lines...) Expand all
321 mAwSettings.setDefaultFontSize(value); 321 mAwSettings.setDefaultFontSize(value);
322 } 322 }
323 323
324 @Override 324 @Override
325 protected void doEnsureSettingHasValue(Integer value) throws Throwable { 325 protected void doEnsureSettingHasValue(Integer value) throws Throwable {
326 loadDataSync(getData()); 326 loadDataSync(getData());
327 assertEquals(value.toString() + "px", getTitleOnUiThread()); 327 assertEquals(value.toString() + "px", getTitleOnUiThread());
328 } 328 }
329 329
330 private String getData() { 330 private String getData() {
331 return "<html><body onload=\"document.title = " + 331 return "<html><body onload=\"document.title = "
332 "getComputedStyle(document.body).getPropertyValue('font-size ');\">" 332 + "getComputedStyle(document.body).getPropertyValue('font-si ze');\">"
333 + "</body></html>"; 333 + "</body></html>";
334 } 334 }
335 } 335 }
336 336
337 class AwSettingsLoadImagesAutomaticallyTestHelper extends AwSettingsTestHelp er<Boolean> { 337 class AwSettingsLoadImagesAutomaticallyTestHelper extends AwSettingsTestHelp er<Boolean> {
338 private ImagePageGenerator mGenerator; 338 private ImagePageGenerator mGenerator;
339 339
340 AwSettingsLoadImagesAutomaticallyTestHelper( 340 AwSettingsLoadImagesAutomaticallyTestHelper(
341 AwTestContainerView containerView, 341 AwTestContainerView containerView,
342 TestAwContentsClient contentViewClient, 342 TestAwContentsClient contentViewClient,
(...skipping 18 matching lines...) Expand all
361 } 361 }
362 362
363 @Override 363 @Override
364 protected void setCurrentValue(Boolean value) { 364 protected void setCurrentValue(Boolean value) {
365 mAwSettings.setLoadsImagesAutomatically(value); 365 mAwSettings.setLoadsImagesAutomatically(value);
366 } 366 }
367 367
368 @Override 368 @Override
369 protected void doEnsureSettingHasValue(Boolean value) throws Throwable { 369 protected void doEnsureSettingHasValue(Boolean value) throws Throwable {
370 loadDataSync(mGenerator.getPageSource()); 370 loadDataSync(mGenerator.getPageSource());
371 assertEquals(value == ENABLED ? 371 assertEquals(value == ENABLED
372 ImagePageGenerator.IMAGE_LOADED_STRING : 372 ? ImagePageGenerator.IMAGE_LOADED_STRING
373 ImagePageGenerator.IMAGE_NOT_LOADED_STRING, 373 : ImagePageGenerator.IMAGE_NOT_LOADED_STRING,
374 getTitleOnUiThread()); 374 getTitleOnUiThread());
375 } 375 }
376 } 376 }
377 377
378 378
379 class AwSettingsImagesEnabledHelper extends AwSettingsTestHelper<Boolean> { 379 class AwSettingsImagesEnabledHelper extends AwSettingsTestHelper<Boolean> {
380 380
381 AwSettingsImagesEnabledHelper( 381 AwSettingsImagesEnabledHelper(
382 AwTestContainerView containerView, 382 AwTestContainerView containerView,
383 TestAwContentsClient contentViewClient, 383 TestAwContentsClient contentViewClient,
384 TestWebServer webServer, 384 TestWebServer webServer,
(...skipping 23 matching lines...) Expand all
408 mAwSettings.setImagesEnabled(value); 408 mAwSettings.setImagesEnabled(value);
409 } 409 }
410 410
411 @Override 411 @Override
412 protected void doEnsureSettingHasValue(Boolean value) throws Throwable { 412 protected void doEnsureSettingHasValue(Boolean value) throws Throwable {
413 final String httpImageUrl = mGenerator.getPageUrl(mWebServer); 413 final String httpImageUrl = mGenerator.getPageUrl(mWebServer);
414 AwSettingsTest.this.loadUrlSync( 414 AwSettingsTest.this.loadUrlSync(
415 mAwContents, 415 mAwContents,
416 mContentViewClient.getOnPageFinishedHelper(), 416 mContentViewClient.getOnPageFinishedHelper(),
417 httpImageUrl); 417 httpImageUrl);
418 assertEquals(value == ENABLED ? 418 assertEquals(value == ENABLED
419 ImagePageGenerator.IMAGE_LOADED_STRING : 419 ? ImagePageGenerator.IMAGE_LOADED_STRING
420 ImagePageGenerator.IMAGE_NOT_LOADED_STRING, 420 : ImagePageGenerator.IMAGE_NOT_LOADED_STRING,
421 getTitleOnUiThread()); 421 getTitleOnUiThread());
422 } 422 }
423 423
424 private TestWebServer mWebServer; 424 private TestWebServer mWebServer;
425 private ImagePageGenerator mGenerator; 425 private ImagePageGenerator mGenerator;
426 } 426 }
427 427
428 class AwSettingsDefaultTextEncodingTestHelper extends AwSettingsTestHelper<S tring> { 428 class AwSettingsDefaultTextEncodingTestHelper extends AwSettingsTestHelper<S tring> {
429 AwSettingsDefaultTextEncodingTestHelper( 429 AwSettingsDefaultTextEncodingTestHelper(
430 AwTestContainerView containerView, 430 AwTestContainerView containerView,
431 TestAwContentsClient contentViewClient) throws Throwable { 431 TestAwContentsClient contentViewClient) throws Throwable {
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 mAwSettings.setAllowContentAccess(value); 881 mAwSettings.setAllowContentAccess(value);
882 } 882 }
883 883
884 @Override 884 @Override
885 protected void doEnsureSettingHasValue(Boolean value) throws Throwable { 885 protected void doEnsureSettingHasValue(Boolean value) throws Throwable {
886 AwSettingsTest.this.resetResourceRequestCountInContentProvider(TARGE T); 886 AwSettingsTest.this.resetResourceRequestCountInContentProvider(TARGE T);
887 final String fileName = mTempDir + "/" + TARGET + ".html"; 887 final String fileName = mTempDir + "/" + TARGET + ".html";
888 try { 888 try {
889 TestFileUtil.createNewHtmlFile(fileName, 889 TestFileUtil.createNewHtmlFile(fileName,
890 TARGET, 890 TARGET,
891 "<img src=\"" + 891 "<img src=\""
892 // Adding a query avoids hitting a cached image, and als o verifies 892 // Adding a query avoids hitting a cached image, and als o verifies
893 // that content URL query parameters are ignored when ac cessing 893 // that content URL query parameters are ignored when ac cessing
894 // a content provider. 894 // a content provider.
895 AwSettingsTest.this.createContentUrl(TARGET + "?id=" + m Index) + "\">"); 895 + AwSettingsTest.this.createContentUrl(TARGET + "?id=" + mIndex) + "\">");
896 mIndex += 2; 896 mIndex += 2;
897 loadUrlSync("file://" + fileName); 897 loadUrlSync("file://" + fileName);
898 if (value == ENABLED) { 898 if (value == ENABLED) {
899 AwSettingsTest.this.ensureResourceRequestCountInContentProvi der(TARGET, 1); 899 AwSettingsTest.this.ensureResourceRequestCountInContentProvi der(TARGET, 1);
900 } else { 900 } else {
901 AwSettingsTest.this.ensureResourceRequestCountInContentProvi der(TARGET, 0); 901 AwSettingsTest.this.ensureResourceRequestCountInContentProvi der(TARGET, 0);
902 } 902 }
903 } finally { 903 } finally {
904 TestFileUtil.deleteFile(fileName); 904 TestFileUtil.deleteFile(fileName);
905 } 905 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 mNeedToWaitForFontSizeChange = false; 947 mNeedToWaitForFontSizeChange = false;
948 } 948 }
949 return Float.parseFloat(getTitleOnUiThread()); 949 return Float.parseFloat(getTitleOnUiThread());
950 } 950 }
951 951
952 protected String getData() { 952 protected String getData() {
953 DeviceDisplayInfo deviceInfo = DeviceDisplayInfo.create(mContext); 953 DeviceDisplayInfo deviceInfo = DeviceDisplayInfo.create(mContext);
954 int displayWidth = (int) (deviceInfo.getDisplayWidth() / deviceInfo. getDIPScale()); 954 int displayWidth = (int) (deviceInfo.getDisplayWidth() / deviceInfo. getDIPScale());
955 int layoutWidth = (int) (displayWidth * 2.5f); // Use 2.5 as autosiz ing layout tests do. 955 int layoutWidth = (int) (displayWidth * 2.5f); // Use 2.5 as autosiz ing layout tests do.
956 StringBuilder sb = new StringBuilder(); 956 StringBuilder sb = new StringBuilder();
957 sb.append("<html>" + 957 sb.append("<html>"
958 "<head>" + 958 + "<head>"
959 "<meta name=\"viewport\" content=\"width=" + layoutWidth + " \">" + 959 + "<meta name=\"viewport\" content=\"width=" + layoutWidth + "\">"
960 "<style>" + 960 + "<style>"
961 "body { width: " + layoutWidth + "px; margin: 0; overflow-y: hidden; }" + 961 + "body { width: " + layoutWidth + "px; margin: 0; overflow- y: hidden; }"
962 "</style>" + 962 + "</style>"
963 "<script>" + 963 + "<script>"
964 "function setTitleToActualFontSize() {" + 964 + "function setTitleToActualFontSize() {"
965 // parseFloat is used to trim out the "px" suffix. 965 // parseFloat is used to trim out the "px" suffix.
966 " document.title = parseFloat(getComputedStyle(" + 966 + " document.title = parseFloat(getComputedStyle("
967 " document.getElementById('par')).getPropertyValue('font- size'));" + 967 + " document.getElementById('par')).getPropertyValue('fon t-size'));"
968 "}</script></head>" + 968 + "}</script></head>"
969 "<body>" + 969 + "<body>"
970 "<p id=\"par\" style=\"font-size:"); 970 + "<p id=\"par\" style=\"font-size:");
971 sb.append(PARAGRAPH_FONT_SIZE); 971 sb.append(PARAGRAPH_FONT_SIZE);
972 sb.append("px;\">"); 972 sb.append("px;\">");
973 // Make the paragraph wide enough for being processed by the font au tosizer. 973 // Make the paragraph wide enough for being processed by the font au tosizer.
974 for (int i = 0; i < 500; i++) { 974 for (int i = 0; i < 500; i++) {
975 sb.append("Hello, World! "); 975 sb.append("Hello, World! ");
976 } 976 }
977 sb.append("</p></body></html>"); 977 sb.append("</p></body></html>");
978 return sb.toString(); 978 return sb.toString();
979 } 979 }
980 980
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1058 super.setCurrentValue(value); 1058 super.setCurrentValue(value);
1059 mAwSettings.setTextZoom(value); 1059 mAwSettings.setTextZoom(value);
1060 } 1060 }
1061 1061
1062 @Override 1062 @Override
1063 protected void doEnsureSettingHasValue(Integer value) throws Throwable { 1063 protected void doEnsureSettingHasValue(Integer value) throws Throwable {
1064 final float actualFontSize = getActualFontSize(); 1064 final float actualFontSize = getActualFontSize();
1065 // Ensure that actual vs. initial font size ratio is similar to actu al vs. initial 1065 // Ensure that actual vs. initial font size ratio is similar to actu al vs. initial
1066 // text zoom values ratio. 1066 // text zoom values ratio.
1067 final float ratiosDelta = Math.abs( 1067 final float ratiosDelta = Math.abs(
1068 (actualFontSize / mInitialActualFontSize) - 1068 (actualFontSize / mInitialActualFontSize)
1069 (value / (float) INITIAL_TEXT_ZOOM)); 1069 - (value / (float) INITIAL_TEXT_ZOOM));
1070 assertTrue( 1070 assertTrue(
1071 "|(" + actualFontSize + " / " + mInitialActualFontSize + ") - (" + 1071 "|(" + actualFontSize + " / " + mInitialActualFontSize + ") - ("
1072 value + " / " + INITIAL_TEXT_ZOOM + ")| = " + ratiosDelta, 1072 + value + " / " + INITIAL_TEXT_ZOOM + ")| = " + ratiosDelta,
1073 ratiosDelta <= 0.2f); 1073 ratiosDelta <= 0.2f);
1074 } 1074 }
1075 } 1075 }
1076 1076
1077 class AwSettingsTextZoomAutosizingTestHelper 1077 class AwSettingsTextZoomAutosizingTestHelper
1078 extends AwSettingsTextAutosizingTestHelper<Integer> { 1078 extends AwSettingsTextAutosizingTestHelper<Integer> {
1079 private static final int INITIAL_TEXT_ZOOM = 100; 1079 private static final int INITIAL_TEXT_ZOOM = 100;
1080 private final float mInitialActualFontSize; 1080 private final float mInitialActualFontSize;
1081 1081
1082 AwSettingsTextZoomAutosizingTestHelper( 1082 AwSettingsTextZoomAutosizingTestHelper(
(...skipping 26 matching lines...) Expand all
1109 super.setCurrentValue(value); 1109 super.setCurrentValue(value);
1110 mAwSettings.setTextZoom(value); 1110 mAwSettings.setTextZoom(value);
1111 } 1111 }
1112 1112
1113 @Override 1113 @Override
1114 protected void doEnsureSettingHasValue(Integer value) throws Throwable { 1114 protected void doEnsureSettingHasValue(Integer value) throws Throwable {
1115 final float actualFontSize = getActualFontSize(); 1115 final float actualFontSize = getActualFontSize();
1116 // Ensure that actual vs. initial font size ratio is similar to actu al vs. initial 1116 // Ensure that actual vs. initial font size ratio is similar to actu al vs. initial
1117 // text zoom values ratio. 1117 // text zoom values ratio.
1118 final float ratiosDelta = Math.abs( 1118 final float ratiosDelta = Math.abs(
1119 (actualFontSize / mInitialActualFontSize) - 1119 (actualFontSize / mInitialActualFontSize)
1120 (value / (float) INITIAL_TEXT_ZOOM)); 1120 - (value / (float) INITIAL_TEXT_ZOOM));
1121 assertTrue( 1121 assertTrue(
1122 "|(" + actualFontSize + " / " + mInitialActualFontSize + ") - (" + 1122 "|(" + actualFontSize + " / " + mInitialActualFontSize + ") - ("
1123 value + " / " + INITIAL_TEXT_ZOOM + ")| = " + ratiosDelta, 1123 + value + " / " + INITIAL_TEXT_ZOOM + ")| = " + ratiosDelta,
1124 ratiosDelta <= 0.2f); 1124 ratiosDelta <= 0.2f);
1125 } 1125 }
1126 } 1126 }
1127 1127
1128 class AwSettingsJavaScriptPopupsTestHelper extends AwSettingsTestHelper<Bool ean> { 1128 class AwSettingsJavaScriptPopupsTestHelper extends AwSettingsTestHelper<Bool ean> {
1129 private static final String POPUP_ENABLED = "Popup enabled"; 1129 private static final String POPUP_ENABLED = "Popup enabled";
1130 private static final String POPUP_BLOCKED = "Popup blocked"; 1130 private static final String POPUP_BLOCKED = "Popup blocked";
1131 1131
1132 AwSettingsJavaScriptPopupsTestHelper( 1132 AwSettingsJavaScriptPopupsTestHelper(
1133 AwTestContainerView containerView, 1133 AwTestContainerView containerView,
(...skipping 30 matching lines...) Expand all
1164 public Boolean call() throws Exception { 1164 public Boolean call() throws Exception {
1165 String title = getTitleOnUiThread(); 1165 String title = getTitleOnUiThread();
1166 return expectPopupEnabled ? POPUP_ENABLED.equals(title) : 1166 return expectPopupEnabled ? POPUP_ENABLED.equals(title) :
1167 POPUP_BLOCKED.equals(title); 1167 POPUP_BLOCKED.equals(title);
1168 } 1168 }
1169 }); 1169 });
1170 assertEquals(value ? POPUP_ENABLED : POPUP_BLOCKED, getTitleOnUiThre ad()); 1170 assertEquals(value ? POPUP_ENABLED : POPUP_BLOCKED, getTitleOnUiThre ad());
1171 } 1171 }
1172 1172
1173 private String getData() { 1173 private String getData() {
1174 return "<html><head>" + 1174 return "<html><head>"
1175 "<script>" + 1175 + "<script>"
1176 " function tryOpenWindow() {" + 1176 + " function tryOpenWindow() {"
1177 " var newWindow = window.open(" + 1177 + " var newWindow = window.open("
1178 " 'data:text/html;charset=utf-8," + 1178 + " 'data:text/html;charset=utf-8,"
1179 " <html><head><title>" + POPUP_ENABLED + "</title> </head></html>');" + 1179 + " <html><head><title>" + POPUP_ENABLED + "</titl e></head></html>');"
1180 " if (!newWindow) document.title = '" + POPUP_BLOCKED + "';" + 1180 + " if (!newWindow) document.title = '" + POPUP_BLOCK ED + "';"
1181 " }" + 1181 + " }"
1182 "</script></head>" + 1182 + "</script></head>"
1183 "<body onload='tryOpenWindow()'></body></html>"; 1183 + "<body onload='tryOpenWindow()'></body></html>";
1184 } 1184 }
1185 } 1185 }
1186 1186
1187 class AwSettingsCacheModeTestHelper extends AwSettingsTestHelper<Integer> { 1187 class AwSettingsCacheModeTestHelper extends AwSettingsTestHelper<Integer> {
1188 1188
1189 AwSettingsCacheModeTestHelper( 1189 AwSettingsCacheModeTestHelper(
1190 AwTestContainerView containerView, 1190 AwTestContainerView containerView,
1191 TestAwContentsClient contentViewClient, 1191 TestAwContentsClient contentViewClient,
1192 int index, 1192 int index,
1193 TestWebServer webServer) throws Throwable { 1193 TestWebServer webServer) throws Throwable {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1275 loadDataSync(getData()); 1275 loadDataSync(getData());
1276 final String bodyWidth = getTitleOnUiThread(); 1276 final String bodyWidth = getTitleOnUiThread();
1277 if (value) { 1277 if (value) {
1278 assertTrue(bodyWidth, VIEWPORT_TAG_LAYOUT_WIDTH.equals(bodyWidth )); 1278 assertTrue(bodyWidth, VIEWPORT_TAG_LAYOUT_WIDTH.equals(bodyWidth ));
1279 } else { 1279 } else {
1280 assertFalse(bodyWidth, VIEWPORT_TAG_LAYOUT_WIDTH.equals(bodyWidt h)); 1280 assertFalse(bodyWidth, VIEWPORT_TAG_LAYOUT_WIDTH.equals(bodyWidt h));
1281 } 1281 }
1282 } 1282 }
1283 1283
1284 private String getData() { 1284 private String getData() {
1285 return "<html><head>" + 1285 return "<html><head>"
1286 "<meta name='viewport' content='width=" + VIEWPORT_TAG_LAYOU T_WIDTH + "' />" + 1286 + "<meta name='viewport' content='width=" + VIEWPORT_TAG_LAY OUT_WIDTH + "' />"
1287 "</head>" + 1287 + "</head>"
1288 "<body onload='document.title=document.body.clientWidth'></b ody></html>"; 1288 + "<body onload='document.title=document.body.clientWidth'>< /body></html>";
1289 } 1289 }
1290 } 1290 }
1291 1291
1292 class AwSettingsLoadWithOverviewModeTestHelper extends AwSettingsTestHelper< Boolean> { 1292 class AwSettingsLoadWithOverviewModeTestHelper extends AwSettingsTestHelper< Boolean> {
1293 private static final float DEFAULT_PAGE_SCALE = 1.0f; 1293 private static final float DEFAULT_PAGE_SCALE = 1.0f;
1294 1294
1295 AwSettingsLoadWithOverviewModeTestHelper( 1295 AwSettingsLoadWithOverviewModeTestHelper(
1296 AwTestContainerView containerView, 1296 AwTestContainerView containerView,
1297 TestAwContentsClient contentViewClient, 1297 TestAwContentsClient contentViewClient,
1298 boolean withViewPortTag) throws Throwable { 1298 boolean withViewPortTag) throws Throwable {
(...skipping 24 matching lines...) Expand all
1323 mOnScaleChangedCallCount = 1323 mOnScaleChangedCallCount =
1324 mContentViewClient.getOnScaleChangedHelper().getCallCoun t(); 1324 mContentViewClient.getOnScaleChangedHelper().getCallCoun t();
1325 } 1325 }
1326 mAwSettings.setLoadWithOverviewMode(value); 1326 mAwSettings.setLoadWithOverviewMode(value);
1327 } 1327 }
1328 1328
1329 @Override 1329 @Override
1330 protected void doEnsureSettingHasValue(Boolean value) throws Throwable { 1330 protected void doEnsureSettingHasValue(Boolean value) throws Throwable {
1331 loadDataSync(getData()); 1331 loadDataSync(getData());
1332 if (mExpectScaleChange) { 1332 if (mExpectScaleChange) {
1333 mContentViewClient.getOnScaleChangedHelper(). 1333 mContentViewClient.getOnScaleChangedHelper()
1334 waitForCallback(mOnScaleChangedCallCount); 1334 .waitForCallback(mOnScaleChangedCallCount);
1335 mExpectScaleChange = false; 1335 mExpectScaleChange = false;
1336 } 1336 }
1337 float currentScale = AwSettingsTest.this.getScaleOnUiThread(mAwConte nts); 1337 float currentScale = AwSettingsTest.this.getScaleOnUiThread(mAwConte nts);
1338 if (value) { 1338 if (value) {
1339 assertTrue("Expected: " + currentScale + " < " + DEFAULT_PAGE_SC ALE, 1339 assertTrue("Expected: " + currentScale + " < " + DEFAULT_PAGE_SC ALE,
1340 currentScale < DEFAULT_PAGE_SCALE); 1340 currentScale < DEFAULT_PAGE_SCALE);
1341 } else { 1341 } else {
1342 assertEquals(DEFAULT_PAGE_SCALE, currentScale); 1342 assertEquals(DEFAULT_PAGE_SCALE, currentScale);
1343 } 1343 }
1344 } 1344 }
1345 1345
1346 private String getData() { 1346 private String getData() {
1347 return "<html><head>" + 1347 return "<html><head>"
1348 (mWithViewPortTag ? "<meta name='viewport' content='width=30 00' />" : "") + 1348 + (mWithViewPortTag ? "<meta name='viewport' content='width= 3000' />" : "")
1349 "</head>" + 1349 + "</head>"
1350 "<body></body></html>"; 1350 + "<body></body></html>";
1351 } 1351 }
1352 1352
1353 private final boolean mWithViewPortTag; 1353 private final boolean mWithViewPortTag;
1354 private boolean mExpectScaleChange; 1354 private boolean mExpectScaleChange;
1355 private int mOnScaleChangedCallCount; 1355 private int mOnScaleChangedCallCount;
1356 } 1356 }
1357 1357
1358 class AwSettingsForceZeroLayoutHeightTestHelper extends AwSettingsTestHelper <Boolean> { 1358 class AwSettingsForceZeroLayoutHeightTestHelper extends AwSettingsTestHelper <Boolean> {
1359 1359
1360 AwSettingsForceZeroLayoutHeightTestHelper( 1360 AwSettingsForceZeroLayoutHeightTestHelper(
(...skipping 30 matching lines...) Expand all
1391 loadDataSync(getData()); 1391 loadDataSync(getData());
1392 int height = Integer.parseInt(getTitleOnUiThread()); 1392 int height = Integer.parseInt(getTitleOnUiThread());
1393 if (value) { 1393 if (value) {
1394 assertEquals(0, height); 1394 assertEquals(0, height);
1395 } else { 1395 } else {
1396 assertTrue("Div should be at least 50px high, was: " + height, h eight >= 50); 1396 assertTrue("Div should be at least 50px high, was: " + height, h eight >= 50);
1397 } 1397 }
1398 } 1398 }
1399 1399
1400 private String getData() { 1400 private String getData() {
1401 return "<html><head>" + 1401 return "<html><head>"
1402 (mWithViewPortTag ? "<meta name='viewport' content='height=3 000' />" : "") + 1402 + (mWithViewPortTag ? "<meta name='viewport' content='height =3000' />" : "")
1403 " <script type='text/javascript'> " + 1403 + " <script type='text/javascript'> "
1404 " window.addEventListener('load', function(event) { " + 1404 + " window.addEventListener('load', function(event) { "
1405 " document.title = document.getElementById('testDiv'). clientHeight; " + 1405 + " document.title = document.getElementById('testDiv' ).clientHeight; "
1406 " }); " + 1406 + " }); "
1407 " </script> " + 1407 + " </script> "
1408 "</head>" + 1408 + "</head>"
1409 "<body> " + 1409 + "<body> "
1410 " <div style='height:50px;'>test</div> " + 1410 + " <div style='height:50px;'>test</div> "
1411 " <div id='testDiv' style='height:100%;'></div> " + 1411 + " <div id='testDiv' style='height:100%;'></div> "
1412 "</body></html>"; 1412 + "</body></html>";
1413 } 1413 }
1414 1414
1415 private final boolean mWithViewPortTag; 1415 private final boolean mWithViewPortTag;
1416 } 1416 }
1417 1417
1418 class AwSettingsZeroLayoutHeightDisablesViewportQuirkTestHelper extends 1418 class AwSettingsZeroLayoutHeightDisablesViewportQuirkTestHelper extends
1419 AwSettingsTestHelper<Boolean> { 1419 AwSettingsTestHelper<Boolean> {
1420 1420
1421 AwSettingsZeroLayoutHeightDisablesViewportQuirkTestHelper( 1421 AwSettingsZeroLayoutHeightDisablesViewportQuirkTestHelper(
1422 AwTestContainerView containerView, 1422 AwTestContainerView containerView,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1454 loadDataSync(getData()); 1454 loadDataSync(getData());
1455 int width = Integer.parseInt(getTitleOnUiThread()); 1455 int width = Integer.parseInt(getTitleOnUiThread());
1456 if (value) { 1456 if (value) {
1457 assertEquals(displayWidth, width); 1457 assertEquals(displayWidth, width);
1458 } else { 1458 } else {
1459 assertEquals(3000, width); 1459 assertEquals(3000, width);
1460 } 1460 }
1461 } 1461 }
1462 1462
1463 private String getData() { 1463 private String getData() {
1464 return "<html><head>" + 1464 return "<html><head>"
1465 "<meta name='viewport' content='width=3000' />" + 1465 + "<meta name='viewport' content='width=3000' />"
1466 " <script type='text/javascript'> " + 1466 + " <script type='text/javascript'> "
1467 " window.addEventListener('load', function(event) { " + 1467 + " window.addEventListener('load', function(event) { "
1468 " document.title = document.documentElement.clientWidt h; " + 1468 + " document.title = document.documentElement.clientWi dth; "
1469 " }); " + 1469 + " }); "
1470 " </script> " + 1470 + " </script> "
1471 "</head>" + 1471 + "</head>"
1472 "<body> " + 1472 + "<body> "
1473 " <div style='height:50px;'>test</div> " + 1473 + " <div style='height:50px;'>test</div> "
1474 " <div id='testDiv' style='height:100%;'></div> " + 1474 + " <div id='testDiv' style='height:100%;'></div> "
1475 "</body></html>"; 1475 + "</body></html>";
1476 } 1476 }
1477 } 1477 }
1478 1478
1479 // The test verifies that JavaScript is disabled upon WebView 1479 // The test verifies that JavaScript is disabled upon WebView
1480 // creation without accessing AwSettings. If the test passes, 1480 // creation without accessing AwSettings. If the test passes,
1481 // it means that WebView-specific web preferences configuration 1481 // it means that WebView-specific web preferences configuration
1482 // is applied on WebView creation. JS state is used, because it is 1482 // is applied on WebView creation. JS state is used, because it is
1483 // enabled by default in Chrome, but must be disabled by default 1483 // enabled by default in Chrome, but must be disabled by default
1484 // in WebView. 1484 // in WebView.
1485 @SmallTest 1485 @SmallTest
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
1619 @Feature({"AndroidWebView", "Preferences"}) 1619 @Feature({"AndroidWebView", "Preferences"})
1620 public void testUserAgentStringDefault() throws Throwable { 1620 public void testUserAgentStringDefault() throws Throwable {
1621 final TestAwContentsClient contentClient = new TestAwContentsClient(); 1621 final TestAwContentsClient contentClient = new TestAwContentsClient();
1622 final AwTestContainerView testContainerView = 1622 final AwTestContainerView testContainerView =
1623 createAwTestContainerViewOnMainSync(contentClient); 1623 createAwTestContainerViewOnMainSync(contentClient);
1624 final AwContents awContents = testContainerView.getAwContents(); 1624 final AwContents awContents = testContainerView.getAwContents();
1625 AwSettings settings = getAwSettingsOnUiThread(awContents); 1625 AwSettings settings = getAwSettingsOnUiThread(awContents);
1626 final String actualUserAgentString = settings.getUserAgentString(); 1626 final String actualUserAgentString = settings.getUserAgentString();
1627 assertEquals(actualUserAgentString, AwSettings.getDefaultUserAgent()); 1627 assertEquals(actualUserAgentString, AwSettings.getDefaultUserAgent());
1628 final String patternString = 1628 final String patternString =
1629 "Mozilla/5\\.0 \\(Linux;( U;)? Android ([^;]+);( (\\w+)-(\\w+);) ?" + 1629 "Mozilla/5\\.0 \\(Linux;( U;)? Android ([^;]+);( (\\w+)-(\\w+);) ?"
1630 "\\s?(.*)\\sBuild/(.+)\\) AppleWebKit/(\\d+)\\.(\\d+) \\(KHTML, like Gecko\\) " + 1630 + "\\s?(.*)\\sBuild/(.+)\\) AppleWebKit/(\\d+)\\.(\\d+) \\(KHTML , like Gecko\\) "
1631 "Version/\\d+\\.\\d Chrome/\\d+\\.\\d+\\.\\d+\\.\\d+" + 1631 + "Version/\\d+\\.\\d Chrome/\\d+\\.\\d+\\.\\d+\\.\\d+"
1632 "( Mobile)? Safari/(\\d+)\\.(\\d+)"; 1632 + "( Mobile)? Safari/(\\d+)\\.(\\d+)";
1633 final Pattern userAgentExpr = Pattern.compile(patternString); 1633 final Pattern userAgentExpr = Pattern.compile(patternString);
1634 Matcher patternMatcher = userAgentExpr.matcher(actualUserAgentString); 1634 Matcher patternMatcher = userAgentExpr.matcher(actualUserAgentString);
1635 assertTrue(String.format("User agent string did not match expected patte rn. %nExpected " + 1635 assertTrue(String.format("User agent string did not match expected patte rn. %nExpected "
1636 "pattern:%n%s%nActual:%n%s", patternString, actualUserAg entString), 1636 + "pattern:%n%s%nActual:%n%s", patternString, actualUser AgentString),
1637 patternMatcher.find()); 1637 patternMatcher.find());
1638 // No country-language code token. 1638 // No country-language code token.
1639 assertEquals(null, patternMatcher.group(3)); 1639 assertEquals(null, patternMatcher.group(3));
1640 if ("REL".equals(Build.VERSION.CODENAME)) { 1640 if ("REL".equals(Build.VERSION.CODENAME)) {
1641 // Model is only added in release builds 1641 // Model is only added in release builds
1642 assertEquals(Build.MODEL, patternMatcher.group(6)); 1642 assertEquals(Build.MODEL, patternMatcher.group(6));
1643 // Release version is valid only in release builds 1643 // Release version is valid only in release builds
1644 assertEquals(Build.VERSION.RELEASE, patternMatcher.group(2)); 1644 assertEquals(Build.VERSION.RELEASE, patternMatcher.group(2));
1645 } 1645 }
1646 assertEquals(Build.ID, patternMatcher.group(7)); 1646 assertEquals(Build.ID, patternMatcher.group(7));
1647 } 1647 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1685 final AwContents awContents = testContainerView.getAwContents(); 1685 final AwContents awContents = testContainerView.getAwContents();
1686 final WebContents webContents = awContents.getWebContents(); 1686 final WebContents webContents = awContents.getWebContents();
1687 CallbackHelper onPageFinishedHelper = contentClient.getOnPageFinishedHel per(); 1687 CallbackHelper onPageFinishedHelper = contentClient.getOnPageFinishedHel per();
1688 AwSettings settings = getAwSettingsOnUiThread(awContents); 1688 AwSettings settings = getAwSettingsOnUiThread(awContents);
1689 settings.setJavaScriptEnabled(true); 1689 settings.setJavaScriptEnabled(true);
1690 final String defaultUserAgentString = settings.getUserAgentString(); 1690 final String defaultUserAgentString = settings.getUserAgentString();
1691 final String customUserAgentString = "AwSettingsTest"; 1691 final String customUserAgentString = "AwSettingsTest";
1692 // We are using different page titles to make sure that we are really 1692 // We are using different page titles to make sure that we are really
1693 // going back and forward between them. 1693 // going back and forward between them.
1694 final String pageTemplate = 1694 final String pageTemplate =
1695 "<html><head><title>%s</title></head>" + 1695 "<html><head><title>%s</title></head>"
1696 "<body onload='document.title+=navigator.userAgent'></body>" + 1696 + "<body onload='document.title+=navigator.userAgent'></body>"
1697 "</html>"; 1697 + "</html>";
1698 final String page1Title = "Page1"; 1698 final String page1Title = "Page1";
1699 final String page2Title = "Page2"; 1699 final String page2Title = "Page2";
1700 final String page1 = String.format(pageTemplate, page1Title); 1700 final String page1 = String.format(pageTemplate, page1Title);
1701 final String page2 = String.format(pageTemplate, page2Title); 1701 final String page2 = String.format(pageTemplate, page2Title);
1702 settings.setUserAgentString(customUserAgentString); 1702 settings.setUserAgentString(customUserAgentString);
1703 loadDataSync( 1703 loadDataSync(
1704 awContents, onPageFinishedHelper, page1, "text/html", false); 1704 awContents, onPageFinishedHelper, page1, "text/html", false);
1705 assertEquals(page1Title + customUserAgentString, getTitleOnUiThread(awCo ntents)); 1705 assertEquals(page1Title + customUserAgentString, getTitleOnUiThread(awCo ntents));
1706 loadDataSync( 1706 loadDataSync(
1707 awContents, onPageFinishedHelper, page2, "text/html", false); 1707 awContents, onPageFinishedHelper, page2, "text/html", false);
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
1885 } 1885 }
1886 1886
1887 @SmallTest 1887 @SmallTest
1888 @Feature({"AndroidWebView", "Preferences", "Navigation"}) 1888 @Feature({"AndroidWebView", "Preferences", "Navigation"})
1889 public void testBlockingContentUrlsFromDataUrls() throws Throwable { 1889 public void testBlockingContentUrlsFromDataUrls() throws Throwable {
1890 final TestAwContentsClient contentClient = new TestAwContentsClient(); 1890 final TestAwContentsClient contentClient = new TestAwContentsClient();
1891 final AwTestContainerView testContainerView = 1891 final AwTestContainerView testContainerView =
1892 createAwTestContainerViewOnMainSync(contentClient); 1892 createAwTestContainerViewOnMainSync(contentClient);
1893 final AwContents awContents = testContainerView.getAwContents(); 1893 final AwContents awContents = testContainerView.getAwContents();
1894 final String target = "content_from_data"; 1894 final String target = "content_from_data";
1895 final String page = "<html><body>" + 1895 final String page = "<html><body>"
1896 "<img src=\"" + 1896 + "<img src=\""
1897 createContentUrl(target) + "\">" + 1897 + createContentUrl(target) + "\">"
1898 "</body></html>"; 1898 + "</body></html>";
1899 resetResourceRequestCountInContentProvider(target); 1899 resetResourceRequestCountInContentProvider(target);
1900 loadDataSync( 1900 loadDataSync(
1901 awContents, 1901 awContents,
1902 contentClient.getOnPageFinishedHelper(), 1902 contentClient.getOnPageFinishedHelper(),
1903 page, 1903 page,
1904 "text/html", 1904 "text/html",
1905 false); 1905 false);
1906 ensureResourceRequestCountInContentProvider(target, 0); 1906 ensureResourceRequestCountInContentProvider(target, 0);
1907 } 1907 }
1908 1908
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
2006 String fileName = null; 2006 String fileName = null;
2007 TestWebServer webServer = TestWebServer.start(); 2007 TestWebServer webServer = TestWebServer.start();
2008 try { 2008 try {
2009 // Set up http image. 2009 // Set up http image.
2010 final String httpPath = "/image.png"; 2010 final String httpPath = "/image.png";
2011 final String imageUrl = webServer.setResponseBase64( 2011 final String imageUrl = webServer.setResponseBase64(
2012 httpPath, generator.getImageSourceNoAdvance(), 2012 httpPath, generator.getImageSourceNoAdvance(),
2013 CommonResources.getImagePngHeaders(true)); 2013 CommonResources.getImagePngHeaders(true));
2014 2014
2015 // Set up file html that loads http iframe. 2015 // Set up file html that loads http iframe.
2016 String pageHtml = "<img src='" + imageUrl + "' " + 2016 String pageHtml = "<img src='" + imageUrl + "' "
2017 "onload=\"document.title='img_onload_fired';\" " + 2017 + "onload=\"document.title='img_onload_fired';\" "
2018 "onerror=\"document.title='img_onerror_fired';\" />"; 2018 + "onerror=\"document.title='img_onerror_fired';\" />";
2019 Context context = getInstrumentation().getTargetContext(); 2019 Context context = getInstrumentation().getTargetContext();
2020 fileName = context.getCacheDir() + "/block_network_loads_test.html"; 2020 fileName = context.getCacheDir() + "/block_network_loads_test.html";
2021 TestFileUtil.deleteFile(fileName); // Remove leftover file if any. 2021 TestFileUtil.deleteFile(fileName); // Remove leftover file if any.
2022 TestFileUtil.createNewHtmlFile(fileName, "unset", pageHtml); 2022 TestFileUtil.createNewHtmlFile(fileName, "unset", pageHtml);
2023 2023
2024 // Actual test. Blocking should trigger onerror handler. 2024 // Actual test. Blocking should trigger onerror handler.
2025 awSettings.setBlockNetworkLoads(true); 2025 awSettings.setBlockNetworkLoads(true);
2026 loadUrlSync( 2026 loadUrlSync(
2027 awContents, 2027 awContents,
2028 contentClient.getOnPageFinishedHelper(), 2028 contentClient.getOnPageFinishedHelper(),
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
2072 final CallbackHelper callback = new CallbackHelper(); 2072 final CallbackHelper callback = new CallbackHelper();
2073 awSettings.setJavaScriptEnabled(true); 2073 awSettings.setJavaScriptEnabled(true);
2074 2074
2075 TestWebServer webServer = TestWebServer.start(); 2075 TestWebServer webServer = TestWebServer.start();
2076 try { 2076 try {
2077 final String httpPath = "/audio.mp3"; 2077 final String httpPath = "/audio.mp3";
2078 // Don't care about the response is correct or not, just want 2078 // Don't care about the response is correct or not, just want
2079 // to know whether Url is accessed. 2079 // to know whether Url is accessed.
2080 final String audioUrl = webServer.setResponse(httpPath, "1", null); 2080 final String audioUrl = webServer.setResponse(httpPath, "1", null);
2081 2081
2082 String pageHtml = "<html><body><audio controls src='" + audioUrl + " ' " + 2082 String pageHtml = "<html><body><audio controls src='" + audioUrl + " ' "
2083 "oncanplay=\"AudioEvent.onCanPlay();\" " + 2083 + "oncanplay=\"AudioEvent.onCanPlay();\" "
2084 "onerror=\"AudioEvent.onError();\" /> </body></html>"; 2084 + "onerror=\"AudioEvent.onError();\" /> </body></html>";
2085 // Actual test. Blocking should trigger onerror handler. 2085 // Actual test. Blocking should trigger onerror handler.
2086 awSettings.setBlockNetworkLoads(true); 2086 awSettings.setBlockNetworkLoads(true);
2087 runTestOnUiThread(new Runnable() { 2087 runTestOnUiThread(new Runnable() {
2088 @Override 2088 @Override
2089 public void run() { 2089 public void run() {
2090 awContents.addPossiblyUnsafeJavascriptInterface( 2090 awContents.addPossiblyUnsafeJavascriptInterface(
2091 new AudioEvent(callback), "AudioEvent", null); 2091 new AudioEvent(callback), "AudioEvent", null);
2092 } 2092 }
2093 }); 2093 });
2094 int count = callback.getCallCount(); 2094 int count = callback.getCallCount();
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
2496 new AwSettingsUseWideViewportTestHelper(views.getContainer0(), v iews.getClient0()), 2496 new AwSettingsUseWideViewportTestHelper(views.getContainer0(), v iews.getClient0()),
2497 new AwSettingsUseWideViewportTestHelper(views.getContainer1(), v iews.getClient1())); 2497 new AwSettingsUseWideViewportTestHelper(views.getContainer1(), v iews.getClient1()));
2498 } 2498 }
2499 2499
2500 private void useWideViewportLayoutWidthTest( 2500 private void useWideViewportLayoutWidthTest(
2501 AwTestContainerView testContainer, CallbackHelper onPageFinishedHelp er) 2501 AwTestContainerView testContainer, CallbackHelper onPageFinishedHelp er)
2502 throws Throwable { 2502 throws Throwable {
2503 final AwContents awContents = testContainer.getAwContents(); 2503 final AwContents awContents = testContainer.getAwContents();
2504 AwSettings settings = getAwSettingsOnUiThread(awContents); 2504 AwSettings settings = getAwSettingsOnUiThread(awContents);
2505 2505
2506 final String pageTemplate = "<html><head>%s</head>" + 2506 final String pageTemplate = "<html><head>%s</head>"
2507 "<body onload='document.title=document.body.clientWidth'></body> </html>"; 2507 + "<body onload='document.title=document.body.clientWidth'></bod y></html>";
2508 final String pageNoViewport = String.format(pageTemplate, ""); 2508 final String pageNoViewport = String.format(pageTemplate, "");
2509 final String pageViewportDeviceWidth = String.format( 2509 final String pageViewportDeviceWidth = String.format(
2510 pageTemplate, 2510 pageTemplate,
2511 "<meta name='viewport' content='width=device-width' />"); 2511 "<meta name='viewport' content='width=device-width' />");
2512 final String viewportTagSpecifiedWidth = "3000"; 2512 final String viewportTagSpecifiedWidth = "3000";
2513 final String pageViewportSpecifiedWidth = String.format( 2513 final String pageViewportSpecifiedWidth = String.format(
2514 pageTemplate, 2514 pageTemplate,
2515 "<meta name='viewport' content='width=" + viewportTagSpecifiedWi dth + "' />"); 2515 "<meta name='viewport' content='width=" + viewportTagSpecifiedWi dth + "' />");
2516 2516
2517 DeviceDisplayInfo deviceInfo = DeviceDisplayInfo.create(testContainer.ge tContext()); 2517 DeviceDisplayInfo deviceInfo = DeviceDisplayInfo.create(testContainer.ge tContext());
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
2579 createAwTestContainerViewOnMainSync(contentClient); 2579 createAwTestContainerViewOnMainSync(contentClient);
2580 final AwContents awContents = testContainerView.getAwContents(); 2580 final AwContents awContents = testContainerView.getAwContents();
2581 CallbackHelper onPageFinishedHelper = contentClient.getOnPageFinishedHel per(); 2581 CallbackHelper onPageFinishedHelper = contentClient.getOnPageFinishedHel per();
2582 AwSettings settings = getAwSettingsOnUiThread(awContents); 2582 AwSettings settings = getAwSettingsOnUiThread(awContents);
2583 settings.setBuiltInZoomControls(true); 2583 settings.setBuiltInZoomControls(true);
2584 2584
2585 DeviceDisplayInfo deviceInfo = 2585 DeviceDisplayInfo deviceInfo =
2586 DeviceDisplayInfo.create(testContainerView.getContext()); 2586 DeviceDisplayInfo.create(testContainerView.getContext());
2587 int displayWidth = (int) (deviceInfo.getDisplayWidth() / deviceInfo.getD IPScale()); 2587 int displayWidth = (int) (deviceInfo.getDisplayWidth() / deviceInfo.getD IPScale());
2588 int layoutWidth = displayWidth * 2; 2588 int layoutWidth = displayWidth * 2;
2589 final String page = "<html>" + 2589 final String page = "<html>"
2590 "<head><meta name='viewport' content='width=" + layoutWidth + "' >" + 2590 + "<head><meta name='viewport' content='width=" + layoutWidth + "'>"
2591 "<style> body { width: " + layoutWidth + "px; }</style></head>" + 2591 + "<style> body { width: " + layoutWidth + "px; }</style></head> "
2592 "<body>Page Text</body></html>"; 2592 + "<body>Page Text</body></html>";
2593 2593
2594 assertFalse(settings.getUseWideViewPort()); 2594 assertFalse(settings.getUseWideViewPort());
2595 // Without wide viewport the <meta viewport> tag will be ignored by WebV iew, 2595 // Without wide viewport the <meta viewport> tag will be ignored by WebV iew,
2596 // but it doesn't really matter as we don't expect double tap to change the scale. 2596 // but it doesn't really matter as we don't expect double tap to change the scale.
2597 loadDataSync(awContents, onPageFinishedHelper, page, "text/html", false) ; 2597 loadDataSync(awContents, onPageFinishedHelper, page, "text/html", false) ;
2598 final float initialScale = getScaleOnUiThread(awContents); 2598 final float initialScale = getScaleOnUiThread(awContents);
2599 simulateDoubleTapCenterOfWebViewOnUiThread(testContainerView); 2599 simulateDoubleTapCenterOfWebViewOnUiThread(testContainerView);
2600 Thread.sleep(1000); 2600 Thread.sleep(1000);
2601 assertEquals(initialScale, getScaleOnUiThread(awContents)); 2601 assertEquals(initialScale, getScaleOnUiThread(awContents));
2602 2602
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
2675 final AwSettings awSettings = getAwSettingsOnUiThread(awContents); 2675 final AwSettings awSettings = getAwSettingsOnUiThread(awContents);
2676 CallbackHelper onPageFinishedHelper = contentClient.getOnPageFinishedHel per(); 2676 CallbackHelper onPageFinishedHelper = contentClient.getOnPageFinishedHel per();
2677 2677
2678 WindowManager wm = (WindowManager) getInstrumentation().getTargetContext () 2678 WindowManager wm = (WindowManager) getInstrumentation().getTargetContext ()
2679 .getSystemService(Context.WINDOW_SERVICE); 2679 .getSystemService(Context.WINDOW_SERVICE);
2680 Point screenSize = new Point(); 2680 Point screenSize = new Point();
2681 wm.getDefaultDisplay().getSize(screenSize); 2681 wm.getDefaultDisplay().getSize(screenSize);
2682 // Make sure after 50% scale, page width still larger than screen. 2682 // Make sure after 50% scale, page width still larger than screen.
2683 int height = screenSize.y * 2 + 1; 2683 int height = screenSize.y * 2 + 1;
2684 int width = screenSize.x * 2 + 1; 2684 int width = screenSize.x * 2 + 1;
2685 final String page = "<html><body>" + 2685 final String page = "<html><body>"
2686 "<p style='height:" + height + "px;width:" + width + "px'>" + 2686 + "<p style='height:" + height + "px;width:" + width + "px'>"
2687 "testSetInitialScale</p></body></html>"; 2687 + "testSetInitialScale</p></body></html>";
2688 final float defaultScale = 2688 final float defaultScale =
2689 getInstrumentation().getTargetContext().getResources().getDispla yMetrics().density; 2689 getInstrumentation().getTargetContext().getResources().getDispla yMetrics().density;
2690 2690
2691 assertEquals(defaultScale, getPixelScaleOnUiThread(awContents), .01f); 2691 assertEquals(defaultScale, getPixelScaleOnUiThread(awContents), .01f);
2692 loadDataSync(awContents, onPageFinishedHelper, page, "text/html", false) ; 2692 loadDataSync(awContents, onPageFinishedHelper, page, "text/html", false) ;
2693 assertEquals(defaultScale, getPixelScaleOnUiThread(awContents), .01f); 2693 assertEquals(defaultScale, getPixelScaleOnUiThread(awContents), .01f);
2694 2694
2695 int onScaleChangedCallCount = contentClient.getOnScaleChangedHelper().ge tCallCount(); 2695 int onScaleChangedCallCount = contentClient.getOnScaleChangedHelper().ge tCallCount();
2696 awSettings.setInitialPageScale(50); 2696 awSettings.setInitialPageScale(50);
2697 loadDataSync(awContents, onPageFinishedHelper, page, "text/html", false) ; 2697 loadDataSync(awContents, onPageFinishedHelper, page, "text/html", false) ;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
2749 getInstrumentation().runOnMainSync(new Runnable() { 2749 getInstrumentation().runOnMainSync(new Runnable() {
2750 @Override 2750 @Override
2751 public void run() { 2751 public void run() {
2752 AwSettings awSettings = awContents.getSettings(); 2752 AwSettings awSettings = awContents.getSettings();
2753 awSettings.setDefaultVideoPosterURL(defaultVideoPosterUrl); 2753 awSettings.setDefaultVideoPosterURL(defaultVideoPosterUrl);
2754 } 2754 }
2755 }); 2755 });
2756 VideoTestWebServer webServer = new VideoTestWebServer( 2756 VideoTestWebServer webServer = new VideoTestWebServer(
2757 getInstrumentation().getTargetContext()); 2757 getInstrumentation().getTargetContext());
2758 try { 2758 try {
2759 String data = "<html><head><body>" + 2759 String data = "<html><head><body>"
2760 "<video id='video' control src='" + 2760 + "<video id='video' control src='"
2761 webServer.getOnePixelOneFrameWebmURL() + "' /> </body></html >"; 2761 + webServer.getOnePixelOneFrameWebmURL() + "' /> </body></ht ml>";
2762 loadDataAsync(awContents, data, "text/html", false); 2762 loadDataAsync(awContents, data, "text/html", false);
2763 videoPosterAccessedCallbackHelper.waitForCallback(0, 1, 20, TimeUnit .SECONDS); 2763 videoPosterAccessedCallbackHelper.waitForCallback(0, 1, 20, TimeUnit .SECONDS);
2764 } finally { 2764 } finally {
2765 if (webServer.getTestWebServer() != null) { 2765 if (webServer.getTestWebServer() != null) {
2766 webServer.getTestWebServer().shutdown(); 2766 webServer.getTestWebServer().shutdown();
2767 } 2767 }
2768 } 2768 }
2769 } 2769 }
2770 2770
2771 @SmallTest 2771 @SmallTest
(...skipping 17 matching lines...) Expand all
2789 try { 2789 try {
2790 httpsServer = TestWebServer.startSsl(); 2790 httpsServer = TestWebServer.startSsl();
2791 httpServer = TestWebServer.start(); 2791 httpServer = TestWebServer.start();
2792 2792
2793 final String jsUrl = "/insecure.js"; 2793 final String jsUrl = "/insecure.js";
2794 final String imageUrl = "/insecure.png"; 2794 final String imageUrl = "/insecure.png";
2795 final String secureUrl = "/secure.html"; 2795 final String secureUrl = "/secure.html";
2796 httpServer.setResponse(jsUrl, "window.loaded_js = 42;", null); 2796 httpServer.setResponse(jsUrl, "window.loaded_js = 42;", null);
2797 httpServer.setResponseBase64(imageUrl, CommonResources.FAVICON_DATA_ BASE64, null); 2797 httpServer.setResponseBase64(imageUrl, CommonResources.FAVICON_DATA_ BASE64, null);
2798 2798
2799 final String jsHtml = "<script src=\"" + httpServer.getResponseUrl(j sUrl) + 2799 final String jsHtml = "<script src=\"" + httpServer.getResponseUrl(j sUrl)
2800 "\"></script>"; 2800 + "\"></script>";
2801 final String imageHtml = "<img src=\"" + httpServer.getResponseUrl(i mageUrl) + "\" />"; 2801 final String imageHtml = "<img src=\"" + httpServer.getResponseUrl(i mageUrl) + "\" />";
2802 final String secureHtml = "<body>" + imageHtml + " " + jsHtml + "</b ody>"; 2802 final String secureHtml = "<body>" + imageHtml + " " + jsHtml + "</b ody>";
2803 2803
2804 String fullSecureUrl = httpsServer.setResponse(secureUrl, secureHtml , null); 2804 String fullSecureUrl = httpsServer.setResponse(secureUrl, secureHtml , null);
2805 2805
2806 awSettings.setMixedContentMode(AwSettings.MIXED_CONTENT_NEVER_ALLOW) ; 2806 awSettings.setMixedContentMode(AwSettings.MIXED_CONTENT_NEVER_ALLOW) ;
2807 loadUrlSync(awContents, contentClient.getOnPageFinishedHelper(), ful lSecureUrl); 2807 loadUrlSync(awContents, contentClient.getOnPageFinishedHelper(), ful lSecureUrl);
2808 assertEquals(1, httpsServer.getRequestCount(secureUrl)); 2808 assertEquals(1, httpsServer.getRequestCount(secureUrl));
2809 assertEquals(0, httpServer.getRequestCount(jsUrl)); 2809 assertEquals(0, httpServer.getRequestCount(jsUrl));
2810 assertEquals(0, httpServer.getRequestCount(imageUrl)); 2810 assertEquals(0, httpServer.getRequestCount(imageUrl));
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
2929 return new ViewPair( 2929 return new ViewPair(
2930 createAwTestContainerViewOnMainSync(client0, supportsLegacyQuirks), 2930 createAwTestContainerViewOnMainSync(client0, supportsLegacyQuirks),
2931 client0, 2931 client0,
2932 createAwTestContainerViewOnMainSync(client1, supportsLegacyQuirks), 2932 createAwTestContainerViewOnMainSync(client1, supportsLegacyQuirks),
2933 client1); 2933 client1);
2934 } 2934 }
2935 2935
2936 static void assertFileIsReadable(String filePath) { 2936 static void assertFileIsReadable(String filePath) {
2937 File file = new File(filePath); 2937 File file = new File(filePath);
2938 try { 2938 try {
2939 assertTrue("Test file \"" + filePath + "\" is not readable." + 2939 assertTrue("Test file \"" + filePath + "\" is not readable."
2940 "Please make sure that files from android_webview/test/data/ device_files/ " + 2940 + "Please make sure that files from android_webview/test/dat a/device_files/ "
2941 "has been pushed to the device before testing", 2941 + "has been pushed to the device before testing",
2942 file.canRead()); 2942 file.canRead());
2943 } catch (SecurityException e) { 2943 } catch (SecurityException e) {
2944 fail("Got a SecurityException for \"" + filePath + "\": " + e.toStri ng()); 2944 fail("Got a SecurityException for \"" + filePath + "\": " + e.toStri ng());
2945 } 2945 }
2946 } 2946 }
2947 2947
2948 /** 2948 /**
2949 * Verifies the number of resource requests made to the content provider. 2949 * Verifies the number of resource requests made to the content provider.
2950 * @param resource Resource name 2950 * @param resource Resource name
2951 * @param expectedCount Expected resource requests count 2951 * @param expectedCount Expected resource requests count
(...skipping 20 matching lines...) Expand all
2972 final AwContents awContents = webView.getAwContents(); 2972 final AwContents awContents = webView.getAwContents();
2973 runTestOnUiThread(new Runnable() { 2973 runTestOnUiThread(new Runnable() {
2974 @Override 2974 @Override
2975 public void run() { 2975 public void run() {
2976 awContents.getContentViewCore().sendDoubleTapForTest( 2976 awContents.getContentViewCore().sendDoubleTapForTest(
2977 SystemClock.uptimeMillis(), x, y); 2977 SystemClock.uptimeMillis(), x, y);
2978 } 2978 }
2979 }); 2979 });
2980 } 2980 }
2981 } 2981 }
OLDNEW
« no previous file with comments | « no previous file | android_webview/javatests/src/org/chromium/android_webview/test/CookieManagerTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698