b634fef8add142252395cdee618a3fa643fc4fd0
[platform/framework/web/crosswalk.git] / src / android_webview / javatests / src / org / chromium / android_webview / test / AwContentsClientOnScaleChangedTest.java
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
3 // found in the LICENSE file.
4
5 package org.chromium.android_webview.test;
6
7 import org.chromium.android_webview.AwContents;
8 import org.chromium.android_webview.test.util.CommonResources;
9 import org.chromium.base.test.util.DisabledTest;
10 import org.chromium.content.browser.ContentViewCore;
11
12 /**
13  * Tests for the WebViewClient.onScaleChanged.
14  */
15 public class AwContentsClientOnScaleChangedTest extends AwTestBase {
16     private TestAwContentsClient mContentsClient;
17     private AwContents mAwContents;
18
19     @Override
20     protected void setUp() throws Exception {
21         super.setUp();
22         mContentsClient = new TestAwContentsClient();
23         AwTestContainerView testContainerView =
24                 createAwTestContainerViewOnMainSync(mContentsClient);
25         mAwContents = testContainerView.getAwContents();
26     }
27
28     @Override
29     protected void tearDown() throws Exception {
30         super.tearDown();
31     }
32
33     /*
34     @SmallTest
35     This test is timing out on ICS bots including cq. See crbug.com/175854.
36     */
37     @DisabledTest
38     public void testScaleUp() throws Throwable {
39         getAwSettingsOnUiThread(mAwContents).setUseWideViewPort(true);
40         loadDataSync(mAwContents, mContentsClient.getOnPageFinishedHelper(),
41                 CommonResources.ABOUT_HTML, "text/html", false);
42         ContentViewCore core = mAwContents.getContentViewCore();
43         int callCount = mContentsClient.getOnScaleChangedHelper().getCallCount();
44         core.onSizeChanged(
45                 core.getViewportWidthPix() / 2, core.getViewportHeightPix() / 2,
46                 core.getViewportWidthPix(), core.getViewportHeightPix());
47         // TODO: Investigate on using core.zoomIn();
48         mContentsClient.getOnScaleChangedHelper().waitForCallback(callCount);
49         assertTrue("Scale ratio:" + mContentsClient.getOnScaleChangedHelper().getLastScaleRatio(),
50                 mContentsClient.getOnScaleChangedHelper().getLastScaleRatio() < 1);
51     }
52 }