summaryrefslogtreecommitdiffstats
path: root/android_webview/javatests
diff options
context:
space:
mode:
Diffstat (limited to 'android_webview/javatests')
-rw-r--r--android_webview/javatests/src/org/chromium/android_webview/test/AwScrollOffsetManagerTest.java48
1 files changed, 48 insertions, 0 deletions
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/AwScrollOffsetManagerTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/AwScrollOffsetManagerTest.java
index b692820..176c451 100644
--- a/android_webview/javatests/src/org/chromium/android_webview/test/AwScrollOffsetManagerTest.java
+++ b/android_webview/javatests/src/org/chromium/android_webview/test/AwScrollOffsetManagerTest.java
@@ -214,6 +214,54 @@ public class AwScrollOffsetManagerTest extends InstrumentationTestCase {
assertEquals(0, delegate.getNativeScrollY());
}
+
+ @SmallTest
+ @Feature({"AndroidWebView"})
+ public void testScrollDeferredOnInvalidContentSize() {
+ TestScrollOffsetManagerDelegate delegate = new TestScrollOffsetManagerDelegate();
+ OverScroller scroller = new OverScroller(getInstrumentation().getContext());
+ AwScrollOffsetManager offsetManager = new AwScrollOffsetManager(delegate, scroller);
+
+ offsetManager.setContentSize(0, 0);
+ offsetManager.setContainerViewSize(VIEW_WIDTH, VIEW_HEIGHT);
+
+ final int firstScrollX = MAX_HORIZONTAL_OFFSET + 10;
+ final int firstScrollY = MAX_VERTICAL_OFFSET + 11;
+ int expectedCallCount = delegate.getOverScrollCallCount();
+ offsetManager.scrollContainerViewTo(firstScrollX, firstScrollY);
+ assertEquals(expectedCallCount, delegate.getOverScrollCallCount());
+ assertEquals(0, delegate.getOverScrollDeltaX() + delegate.getScrollX());
+ assertEquals(0, delegate.getOverScrollDeltaY() + delegate.getScrollY());
+
+ // Repeated scrolls will also be deferred, overwriting any previous deferred scroll offset.
+ final int secondScrollX = MAX_HORIZONTAL_OFFSET;
+ final int secondScrollY = MAX_VERTICAL_OFFSET;
+ offsetManager.scrollContainerViewTo(secondScrollX, secondScrollY);
+ assertEquals(expectedCallCount, delegate.getOverScrollCallCount());
+ assertEquals(0, delegate.getOverScrollDeltaX() + delegate.getScrollX());
+ assertEquals(0, delegate.getOverScrollDeltaY() + delegate.getScrollY());
+
+ // Setting a valid size will release the deferred container scroll offset.
+ expectedCallCount++;
+ offsetManager.setContentSize(CONTENT_WIDTH, CONTENT_HEIGHT);
+ assertEquals(expectedCallCount, delegate.getOverScrollCallCount());
+ assertEquals(secondScrollX, delegate.getOverScrollDeltaX() + delegate.getScrollX());
+ assertEquals(secondScrollY, delegate.getOverScrollDeltaY() + delegate.getScrollY());
+ offsetManager.onContainerViewOverScrolled(secondScrollX, secondScrollY, false, false);
+
+ assertEquals(secondScrollX, delegate.getOverScrollDeltaX());
+ assertEquals(secondScrollY, delegate.getOverScrollDeltaY());
+ assertEquals(MAX_HORIZONTAL_OFFSET, delegate.getScrollX());
+ assertEquals(MAX_VERTICAL_OFFSET, delegate.getScrollY());
+
+ // Subsequently setting valid content sizes should not release another scroll update.
+ offsetManager.setContentSize(CONTENT_WIDTH + 10, CONTENT_HEIGHT + 10);
+ assertEquals(expectedCallCount, delegate.getOverScrollCallCount());
+ offsetManager.setContentSize(CONTENT_WIDTH, CONTENT_HEIGHT);
+ assertEquals(expectedCallCount, delegate.getOverScrollCallCount());
+ }
+
+
@SmallTest
@Feature({"AndroidWebView"})
public void testDelegateCanOverrideScroll() {