List of usage examples for android.webkit WebSettings supportZoom
public abstract boolean supportZoom();
From source file:android.webkit.cts.WebViewTest.java
@UiThreadTest public void testInvokeZoomPicker() throws Exception { if (!NullWebViewUtils.isWebViewAvailable()) { return;//from w w w. j a va 2s . co m } WebSettings settings = mWebView.getSettings(); assertTrue(settings.supportZoom()); startWebServer(false); String url = mWebServer.getAssetUrl(TestHtmlConstants.HELLO_WORLD_URL); mOnUiThread.loadUrlAndWaitForCompletion(url); mWebView.invokeZoomPicker(); }
From source file:android.webkit.cts.WebViewTest.java
@SuppressWarnings("deprecation") @UiThreadTest// w ww .ja v a2s. c om public void testGetZoomControls() { if (!NullWebViewUtils.isWebViewAvailable()) { return; } WebSettings settings = mWebView.getSettings(); assertTrue(settings.supportZoom()); View zoomControls = mWebView.getZoomControls(); assertNotNull(zoomControls); // disable zoom support settings.setSupportZoom(false); assertFalse(settings.supportZoom()); assertNull(mWebView.getZoomControls()); }
From source file:android.webkit.cts.WebViewTest.java
public void testZoom() throws Throwable { if (!NullWebViewUtils.isWebViewAvailable()) { return;//from w ww. ja v a2 s . c om } // Pinch zoom is not supported in wrap_content layouts. mOnUiThread.setLayoutHeightToMatchParent(); final ScaleChangedWebViewClient webViewClient = new ScaleChangedWebViewClient(); mOnUiThread.setWebViewClient(webViewClient); mWebServer = new CtsTestServer(getActivity()); mOnUiThread.loadUrlAndWaitForCompletion(mWebServer.getAssetUrl(TestHtmlConstants.HELLO_WORLD_URL)); pollingCheckForCanZoomIn(); WebSettings settings = mOnUiThread.getSettings(); settings.setSupportZoom(false); assertFalse(settings.supportZoom()); float currScale = mOnUiThread.getScale(); float previousScale = currScale; // can zoom in or out although zoom support is disabled in web settings assertTrue(mOnUiThread.zoomIn()); webViewClient.waitForScaleChanged(); currScale = mOnUiThread.getScale(); assertTrue(currScale > previousScale); assertTrue(mOnUiThread.zoomOut()); previousScale = currScale; webViewClient.waitForScaleChanged(); currScale = mOnUiThread.getScale(); assertTrue(currScale < previousScale); mOnUiThread.zoomBy(1.25f); // zoom in previousScale = currScale; webViewClient.waitForScaleChanged(); currScale = mOnUiThread.getScale(); assertTrue(currScale > previousScale); mOnUiThread.zoomBy(0.8f); // zoom out previousScale = currScale; webViewClient.waitForScaleChanged(); currScale = mOnUiThread.getScale(); assertTrue(currScale < previousScale); // enable zoom support settings.setSupportZoom(true); assertTrue(settings.supportZoom()); previousScale = mOnUiThread.getScale(); assertTrue(mOnUiThread.zoomIn()); webViewClient.waitForScaleChanged(); currScale = mOnUiThread.getScale(); assertTrue(currScale > previousScale); // zoom in until it reaches maximum scale while (mOnUiThread.zoomIn()) { previousScale = currScale; webViewClient.waitForScaleChanged(); currScale = mOnUiThread.getScale(); assertTrue(currScale > previousScale); } previousScale = currScale; // can not zoom in further assertFalse(mOnUiThread.zoomIn()); // We sleep to assert to the best of our ability // that a scale change does *not* happen. Thread.sleep(500); currScale = mOnUiThread.getScale(); assertEquals(currScale, previousScale); assertTrue(mOnUiThread.zoomOut()); previousScale = currScale; webViewClient.waitForScaleChanged(); currScale = mOnUiThread.getScale(); assertTrue(currScale < previousScale); // zoom out until it reaches minimum scale while (mOnUiThread.zoomOut()) { previousScale = currScale; webViewClient.waitForScaleChanged(); currScale = mOnUiThread.getScale(); assertTrue(currScale < previousScale); } previousScale = currScale; assertFalse(mOnUiThread.zoomOut()); // We sleep to assert to the best of our ability // that a scale change does *not* happen. Thread.sleep(500); currScale = mOnUiThread.getScale(); assertEquals(currScale, previousScale); mOnUiThread.zoomBy(1.25f); previousScale = currScale; webViewClient.waitForScaleChanged(); currScale = mOnUiThread.getScale(); assertTrue(currScale > previousScale); // zoom in until it reaches maximum scale while (mOnUiThread.canZoomIn()) { previousScale = currScale; mOnUiThread.zoomBy(1.25f); webViewClient.waitForScaleChanged(); currScale = mOnUiThread.getScale(); assertTrue(currScale > previousScale); } previousScale = currScale; // We sleep to assert to the best of our ability // that a scale change does *not* happen. Thread.sleep(500); currScale = mOnUiThread.getScale(); assertEquals(currScale, previousScale); mOnUiThread.zoomBy(0.8f); previousScale = currScale; webViewClient.waitForScaleChanged(); currScale = mOnUiThread.getScale(); assertTrue(currScale < previousScale); // zoom out until it reaches minimum scale while (mOnUiThread.canZoomOut()) { previousScale = currScale; mOnUiThread.zoomBy(0.8f); webViewClient.waitForScaleChanged(); currScale = mOnUiThread.getScale(); assertTrue(currScale < previousScale); } previousScale = currScale; // We sleep to assert to the best of our ability // that a scale change does *not* happen. Thread.sleep(500); currScale = mOnUiThread.getScale(); assertEquals(currScale, previousScale); }