OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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.test.suitebuilder.annotation.SmallTest; | 8 import android.test.suitebuilder.annotation.SmallTest; |
9 import android.view.View; | 9 import android.view.View; |
10 import android.widget.OverScroller; | 10 import android.widget.OverScroller; |
11 | 11 |
12 import org.chromium.android_webview.AwContents; | 12 import org.chromium.android_webview.AwContents; |
13 import org.chromium.android_webview.AwScrollOffsetManager; | 13 import org.chromium.android_webview.AwScrollOffsetManager; |
14 import org.chromium.android_webview.test.util.AwTestTouchUtils; | 14 import org.chromium.android_webview.test.util.AwTestTouchUtils; |
15 import org.chromium.android_webview.test.util.CommonResources; | 15 import org.chromium.android_webview.test.util.CommonResources; |
16 import org.chromium.android_webview.test.util.JavascriptEventObserver; | 16 import org.chromium.android_webview.test.util.JavascriptEventObserver; |
17 import org.chromium.base.test.util.Feature; | 17 import org.chromium.base.test.util.Feature; |
18 import org.chromium.content.browser.test.util.CallbackHelper; | 18 import org.chromium.content.browser.test.util.CallbackHelper; |
19 import org.chromium.content_public.browser.GestureStateListener; | 19 import org.chromium.content_public.browser.GestureStateListener; |
20 import org.chromium.ui.gfx.DeviceDisplayInfo; | 20 import org.chromium.ui.gfx.DeviceDisplayInfo; |
21 | 21 |
| 22 import java.util.Locale; |
22 import java.util.concurrent.Callable; | 23 import java.util.concurrent.Callable; |
23 import java.util.concurrent.CountDownLatch; | 24 import java.util.concurrent.CountDownLatch; |
24 import java.util.concurrent.atomic.AtomicBoolean; | 25 import java.util.concurrent.atomic.AtomicBoolean; |
25 | 26 |
26 /** | 27 /** |
27 * Integration tests for synchronous scrolling. | 28 * Integration tests for synchronous scrolling. |
28 */ | 29 */ |
29 public class AndroidScrollIntegrationTest extends AwTestBase { | 30 public class AndroidScrollIntegrationTest extends AwTestBase { |
30 private static class OverScrollByCallbackHelper extends CallbackHelper { | 31 private static class OverScrollByCallbackHelper extends CallbackHelper { |
31 int mDeltaX; | 32 int mDeltaX; |
(...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
823 (int) Math.ceil(awContents.computeVerticalScrollRange() / ol
dScale); | 824 (int) Math.ceil(awContents.computeVerticalScrollRange() / ol
dScale); |
824 | 825 |
825 awContents.zoomIn(); | 826 awContents.zoomIn(); |
826 | 827 |
827 int newScrollRange = | 828 int newScrollRange = |
828 awContents.computeVerticalScrollRange() - testContainerView.
getHeight(); | 829 awContents.computeVerticalScrollRange() - testContainerView.
getHeight(); |
829 float newScale = awContents.getScale(); | 830 float newScale = awContents.getScale(); |
830 int newContentHeightApproximation = | 831 int newContentHeightApproximation = |
831 (int) Math.ceil(awContents.computeVerticalScrollRange() / ne
wScale); | 832 (int) Math.ceil(awContents.computeVerticalScrollRange() / ne
wScale); |
832 | 833 |
833 assertTrue(String.format("Scale range should increase after zoom
(%f) > (%f)", | 834 assertTrue(String.format(Locale.ENGLISH, |
| 835 "Scale range should increase after zoom (%f) > (%f)", |
834 newScale, oldScale), newScale > oldScale); | 836 newScale, oldScale), newScale > oldScale); |
835 assertTrue(String.format("Scroll range should increase after zoo
m (%d) > (%d)", | 837 assertTrue(String.format(Locale.ENGLISH, |
| 838 "Scroll range should increase after zoom (%d) > (%d)", |
836 newScrollRange, oldScrollRange), newScrollRange > oldScr
ollRange); | 839 newScrollRange, oldScrollRange), newScrollRange > oldScr
ollRange); |
837 assertEquals(awContents.getContentHeightCss(), oldContentHeightA
pproximation); | 840 assertEquals(awContents.getContentHeightCss(), oldContentHeightA
pproximation); |
838 assertEquals(awContents.getContentHeightCss(), newContentHeightA
pproximation); | 841 assertEquals(awContents.getContentHeightCss(), newContentHeightA
pproximation); |
839 } | 842 } |
840 }); | 843 }); |
841 | 844 |
842 } | 845 } |
843 } | 846 } |
OLD | NEW |