| 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | package org.chromium.android_webview.test; |
| 6 | |
| 7 | import android.test.suitebuilder.annotation.SmallTest; |
| 8 | |
| 9 | import org.chromium.android_webview.AwContents; |
| 10 | import org.chromium.base.test.util.DisabledTest; |
| 11 | import org.chromium.content.browser.ContentViewCore; |
| 12 | import org.chromium.content.browser.test.util.CallbackHelper; |
| 13 | import org.chromium.android_webview.test.util.CommonResources; |
| 14 | |
| 15 | import android.util.Log; |
| 16 | |
| 17 | /** |
| 18 | * Tests for the WebViewClient.onScaleChanged. |
| 19 | */ |
| 20 | public class AwContentsClientOnScaleChangedTest extends AwTestBase { |
| 21 | private TestAwContentsClient mContentsClient; |
| 22 | private AwContents mAwContents; |
| 23 | |
| 24 | @Override |
| 25 | protected void setUp() throws Exception { |
| 26 | super.setUp(); |
| 27 | mContentsClient = new TestAwContentsClient(); |
| 28 | AwTestContainerView testContainerView = |
| 29 | createAwTestContainerViewOnMainSync(mContentsClient); |
| 30 | mAwContents = testContainerView.getAwContents(); |
| 31 | } |
| 32 | |
| 33 | @Override |
| 34 | protected void tearDown() throws Exception { |
| 35 | super.tearDown(); |
| 36 | } |
| 37 | |
| 38 | /* |
| 39 | @SmallTest |
| 40 | This test is timing out on ICS bots including cq. See crbug.com/175854. |
| 41 | */ |
| 42 | @DisabledTest |
| 43 | public void testScaleUp() throws Throwable { |
| 44 | getAwSettingsOnUiThread(mAwContents).setUseWideViewPort(true); |
| 45 | loadDataSync(mAwContents, mContentsClient.getOnPageFinishedHelper(), |
| 46 | CommonResources.ABOUT_HTML, "text/html", false); |
| 47 | ContentViewCore core = mAwContents.getContentViewCore(); |
| 48 | int callCount = mContentsClient.getOnScaleChangedHelper().getCallCount(); |
| 49 | core.onSizeChanged( |
| 50 | core.getViewportWidthPix() / 2, core.getViewportHeightPix() / 2, |
| 51 | core.getViewportWidthPix(), core.getViewportHeightPix()); |
| 52 | // TODO: Investigate on using core.zoomIn(); |
| 53 | mContentsClient.getOnScaleChangedHelper().waitForCallback(callCount); |
| 54 | assertTrue("Scale ratio:" + mContentsClient.getOnScaleChangedHelper().getLastScaleRatio(), |
| 55 | mContentsClient.getOnScaleChangedHelper().getLastScaleRatio() < 1); |
| 56 | } |
| 57 | } |