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

Unified Diff: android_webview/javatests/src/org/chromium/android_webview/test/AwZoomTest.java

Issue 445553002: Merge 281052 "[android_webview] Add a zoomBy method to AwContents." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/2062/src/
Patch Set: Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « android_webview/javatests/src/org/chromium/android_webview/test/AwContentsClientOnScaleChangedTest.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: android_webview/javatests/src/org/chromium/android_webview/test/AwZoomTest.java
===================================================================
--- android_webview/javatests/src/org/chromium/android_webview/test/AwZoomTest.java (revision 287507)
+++ android_webview/javatests/src/org/chromium/android_webview/test/AwZoomTest.java (working copy)
@@ -24,6 +24,7 @@
public class AwZoomTest extends AwTestBase {
private TestAwContentsClient mContentsClient;
private AwContents mAwContents;
+ private float MAXIMUM_SCALE = 2.0f;
@Override
public void setUp() throws Exception {
@@ -37,11 +38,11 @@
private String getZoomableHtml(float scale) {
final int divWidthPercent = (int)(100.0f / scale);
return String.format(Locale.US, "<html><head><meta name=\"viewport\" content=\"" +
- "width=device-width, minimum-scale=%f, maximum-scale=2.0, initial-scale=%f" +
+ "width=device-width, minimum-scale=%f, maximum-scale=%f, initial-scale=%f" +
"\"/></head><body style='margin:0'>" +
"<div style='width:%d%%;height:100px;border:1px solid black'>Zoomable</div>" +
"</body></html>",
- scale, scale, divWidthPercent);
+ scale, MAXIMUM_SCALE, scale, divWidthPercent);
}
private String getNonZoomableHtml() {
@@ -114,6 +115,18 @@
waitForScaleChange(previousScale);
}
+ private void zoomByOnUiThreadAndWait(final float delta) throws Throwable {
+ final float previousScale = getPixelScaleOnUiThread(mAwContents);
+ assertTrue(runTestOnUiThreadAndGetResult(new Callable<Boolean>() {
+ @Override
+ public Boolean call() throws Exception {
+ return mAwContents.zoomBy(delta);
+ }
+ }));
+ // The zoom level is updated asynchronously.
+ waitForScaleChange(previousScale);
+ }
+
private void waitForScaleChange(final float previousScale) throws Throwable {
poll(new Callable<Boolean>() {
@Override
@@ -161,6 +174,15 @@
zoomOutOnUiThreadAndWait();
}
assertTrue("Should be able to zoom in", canZoomInOnUiThread(mAwContents));
+
+ zoomByOnUiThreadAndWait(4.0f);
+ waitForScaleToBecome(MAXIMUM_SCALE);
+
+ zoomByOnUiThreadAndWait(0.5f);
+ waitForScaleToBecome(MAXIMUM_SCALE * 0.5f);
+
+ zoomByOnUiThreadAndWait(0.01f);
+ waitForScaleToBecome(pageMinimumScale);
}
@SmallTest
« no previous file with comments | « android_webview/javatests/src/org/chromium/android_webview/test/AwContentsClientOnScaleChangedTest.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698