| Index: Source/web/tests/WebFrameTest.cpp
|
| diff --git a/Source/web/tests/WebFrameTest.cpp b/Source/web/tests/WebFrameTest.cpp
|
| index 8fb12ccf6801050fdfda693a3160fbb0b3e3f54c..2bc05747fcab3affdae6a32ee66d0f41d03d7c11 100644
|
| --- a/Source/web/tests/WebFrameTest.cpp
|
| +++ b/Source/web/tests/WebFrameTest.cpp
|
| @@ -152,6 +152,12 @@ const int touchPointPadding = 32;
|
| EXPECT_FLOAT_EQ(expected.y(), actual.y()); \
|
| } while (false)
|
|
|
| +#define EXPECT_WEB_FLOAT_SIZE_EQ(expected, actual) \
|
| + do { \
|
| + EXPECT_FLOAT_EQ(expected.width, actual.width); \
|
| + EXPECT_FLOAT_EQ(expected.height, actual.height); \
|
| + } while (false)
|
| +
|
| class WebFrameTest : public ::testing::Test {
|
| protected:
|
| WebFrameTest()
|
| @@ -7437,4 +7443,257 @@ TEST_P(ParametrizedWebFrameTest, CreateLocalChildWithPreviousSibling)
|
| view->close();
|
| }
|
|
|
| +class OverscrollWebViewClient : public FrameTestHelpers::TestWebViewClient {
|
| +public:
|
| + virtual void didOverscroll(const WebFloatSize& unusedDelta, const WebFloatSize& accumulatedRootOverScroll, const WebFloatPoint& position, const WebFloatSize& velocity) override
|
| + {
|
| + m_unusedDelta = unusedDelta;
|
| + m_accumulatedRootOverScroll = accumulatedRootOverScroll;
|
| + }
|
| +
|
| + WebFloatSize m_unusedDelta;
|
| + WebFloatSize m_accumulatedRootOverScroll;
|
| +};
|
| +
|
| +class WebFrameOverscrollTest : public WebFrameTest {
|
| +protected:
|
| + WebGestureEvent generateEvent(WebInputEvent::Type type, int deltaX = 0, int deltaY = 0)
|
| + {
|
| + WebGestureEvent event;
|
| + event.type = type;
|
| + event.x = 100;
|
| + event.y = 100;
|
| + if (type == WebInputEvent::GestureScrollUpdate) {
|
| + event.data.scrollUpdate.deltaX = deltaX;
|
| + event.data.scrollUpdate.deltaY = deltaY;
|
| + }
|
| + return event;
|
| + }
|
| +
|
| + void ScrollBegin(FrameTestHelpers::WebViewHelper* webViewHelper)
|
| + {
|
| + webViewHelper->webViewImpl()->handleInputEvent(generateEvent(WebInputEvent::GestureScrollBegin));
|
| + }
|
| +
|
| + void ScrollUpdate(FrameTestHelpers::WebViewHelper* webViewHelper, float deltaX, float deltaY)
|
| + {
|
| + webViewHelper->webViewImpl()->handleInputEvent(generateEvent(WebInputEvent::GestureScrollUpdate, deltaX, deltaY));
|
| + }
|
| +
|
| + void ScrollEnd(FrameTestHelpers::WebViewHelper* webViewHelper)
|
| + {
|
| + webViewHelper->webViewImpl()->handleInputEvent(generateEvent(WebInputEvent::GestureScrollEnd));
|
| + }
|
| +};
|
| +
|
| +TEST_F(WebFrameOverscrollTest, AccumulatedRootOverscrollAndUnsedDeltaValuesOnOverscroll)
|
| +{
|
| + OverscrollWebViewClient client;
|
| + registerMockedHttpURLLoad("overscroll/overscroll.html");
|
| + FrameTestHelpers::WebViewHelper webViewHelper;
|
| + WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "overscroll/overscroll.html", true, 0, &client, configureAndroid);
|
| + webViewImpl->layout();
|
| +
|
| + // Calculation of accumulatedRootOverscroll and unusedDelta on multiple scrollUpdate.
|
| + ScrollBegin(&webViewHelper);
|
| + ScrollUpdate(&webViewHelper, -400, -400);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(0, 0), client.m_unusedDelta);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(0, 0), client.m_accumulatedRootOverScroll);
|
| +
|
| + ScrollUpdate(&webViewHelper, 0, -13);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(0, 13), client.m_unusedDelta);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(0, 13), client.m_accumulatedRootOverScroll);
|
| +
|
| + ScrollUpdate(&webViewHelper, -20, -13);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(20, 13), client.m_unusedDelta);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(20, 26), client.m_accumulatedRootOverScroll);
|
| +
|
| + // Overscroll is not reported for the below scroll gestures, due to which OverscrollWebViewClient
|
| + // retains last UnusedDelta and AccumulatedRootOverscroll values.
|
| + ScrollUpdate(&webViewHelper, 0, 1);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(20, 13), client.m_unusedDelta);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(20, 26), client.m_accumulatedRootOverScroll);
|
| +
|
| + ScrollUpdate(&webViewHelper, 1, 0);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(20, 13), client.m_unusedDelta);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(20, 26), client.m_accumulatedRootOverScroll);
|
| +
|
| + ScrollEnd(&webViewHelper);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(20, 13), client.m_unusedDelta);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(20, 26), client.m_accumulatedRootOverScroll);
|
| +}
|
| +
|
| +TEST_F(WebFrameOverscrollTest, AccumulatedOverscrollAndUnusedDeltaValuesOnDifferentAxesOverscroll)
|
| +{
|
| + OverscrollWebViewClient client;
|
| + registerMockedHttpURLLoad("overscroll/div-overscroll.html");
|
| + FrameTestHelpers::WebViewHelper webViewHelper;
|
| + WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "overscroll/div-overscroll.html", true, 0, &client, configureAndroid);
|
| + webViewImpl->layout();
|
| +
|
| + ScrollBegin(&webViewHelper);
|
| +
|
| + // Scroll the Div to the end.
|
| + ScrollUpdate(&webViewHelper, 0, -316);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(0, 0), client.m_unusedDelta);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(0, 0), client.m_accumulatedRootOverScroll);
|
| +
|
| + // Now On Scrolling DIV, scroll is bubbled and root layer is over-scrolled.
|
| + ScrollUpdate(&webViewHelper, 0, -50);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(0, 50), client.m_unusedDelta);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(0, 50), client.m_accumulatedRootOverScroll);
|
| +
|
| + // Overscroll is not reported, so client retains last UnusedDelta and AccumulatedRootOverscroll values.
|
| + ScrollUpdate(&webViewHelper, 0, 1);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(0, 50), client.m_unusedDelta);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(0, 50), client.m_accumulatedRootOverScroll);
|
| +
|
| + ScrollUpdate(&webViewHelper, 0, -50);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(0, 50), client.m_unusedDelta);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(0, 50), client.m_accumulatedRootOverScroll);
|
| +
|
| + // Now On Scrolling DIV, scroll is bubbled and root layer is over-scrolled.
|
| + ScrollUpdate(&webViewHelper, 0, -100);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(0, 100), client.m_unusedDelta);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(0, 100), client.m_accumulatedRootOverScroll);
|
| +
|
| + // Page scrolls vertically, but over-scrolls horizontally.
|
| + ScrollUpdate(&webViewHelper, 100, 50);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(-100, 0), client.m_unusedDelta);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(-100, 0), client.m_accumulatedRootOverScroll);
|
| +
|
| + // Scrolling up, Overscroll is not reported, so client retains last UnusedDelta and AccumulatedRootOverscroll values.
|
| + ScrollUpdate(&webViewHelper, 0, -50);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(-100, 0), client.m_unusedDelta);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(-100, 0), client.m_accumulatedRootOverScroll);
|
| +
|
| + // Page scrolls horizontally, but over-scrolls vertically.
|
| + ScrollUpdate(&webViewHelper, -100, -100);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(0, 100), client.m_unusedDelta);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(0, 100), client.m_accumulatedRootOverScroll);
|
| +}
|
| +
|
| +TEST_F(WebFrameOverscrollTest, RootLayerOverscrolledOnInnerDivOverScroll)
|
| +{
|
| + OverscrollWebViewClient client;
|
| + registerMockedHttpURLLoad("overscroll/div-overscroll.html");
|
| + FrameTestHelpers::WebViewHelper webViewHelper;
|
| + WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "overscroll/div-overscroll.html", true, 0, &client, configureAndroid);
|
| + webViewImpl->layout();
|
| +
|
| + ScrollBegin(&webViewHelper);
|
| +
|
| + // Scroll the Div to the end.
|
| + ScrollUpdate(&webViewHelper, 0, -316);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(0, 0), client.m_unusedDelta);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(0, 0), client.m_accumulatedRootOverScroll);
|
| +
|
| + // Now On Scrolling DIV, scroll is bubbled and root layer is over-scrolled.
|
| + ScrollUpdate(&webViewHelper, 0, -50);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(0, 50), client.m_unusedDelta);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(0, 50), client.m_accumulatedRootOverScroll);
|
| +}
|
| +
|
| +TEST_F(WebFrameOverscrollTest, RootLayerOverscrolledOnInnerIFrameOverScroll)
|
| +{
|
| + OverscrollWebViewClient client;
|
| + registerMockedHttpURLLoad("overscroll/iframe-overscroll.html");
|
| + registerMockedHttpURLLoad("overscroll/scrollable-iframe.html");
|
| + FrameTestHelpers::WebViewHelper webViewHelper;
|
| + WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "overscroll/iframe-overscroll.html", true, 0, &client, configureAndroid);
|
| + webViewImpl->layout();
|
| +
|
| + ScrollBegin(&webViewHelper);
|
| +
|
| + // Scroll the IFrame to the end.
|
| + ScrollUpdate(&webViewHelper, 0, -320);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(0, 0), client.m_unusedDelta);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(0, 0), client.m_accumulatedRootOverScroll);
|
| +
|
| + // Now On Scrolling IFrame, scroll is bubbled and root layer is over-scrolled.
|
| + ScrollUpdate(&webViewHelper, 0, -50);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(0, 50), client.m_unusedDelta);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(0, 50), client.m_accumulatedRootOverScroll);
|
| +}
|
| +
|
| +TEST_F(WebFrameOverscrollTest, NoOverscrollOnNonScrollableaxes)
|
| +{
|
| + OverscrollWebViewClient client;
|
| + registerMockedHttpURLLoad("overscroll/no-overscroll-on-nonscrollable-axes.html");
|
| + FrameTestHelpers::WebViewHelper webViewHelper;
|
| + WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "overscroll/no-overscroll-on-nonscrollable-axes.html", true, 0, &client, configureAndroid);
|
| + webViewImpl->layout();
|
| +
|
| + // Overscroll is not reported in all the directions.
|
| + ScrollBegin(&webViewHelper);
|
| + ScrollUpdate(&webViewHelper, 0, -1);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(0, 0), client.m_unusedDelta);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(0, 0), client.m_accumulatedRootOverScroll);
|
| +
|
| + ScrollUpdate(&webViewHelper, 0, 1);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(0, 0), client.m_unusedDelta);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(0, 0), client.m_accumulatedRootOverScroll);
|
| +
|
| + ScrollUpdate(&webViewHelper, 1, 0);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(0, 0), client.m_unusedDelta);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(0, 0), client.m_accumulatedRootOverScroll);
|
| +
|
| + ScrollUpdate(&webViewHelper, -1, 0);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(0, 0), client.m_unusedDelta);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(0, 0), client.m_accumulatedRootOverScroll);
|
| +
|
| + ScrollUpdate(&webViewHelper, 1, 1);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(0, 0), client.m_unusedDelta);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(0, 0), client.m_accumulatedRootOverScroll);
|
| +
|
| + ScrollUpdate(&webViewHelper, -1, 1);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(0, 0), client.m_unusedDelta);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(0, 0), client.m_accumulatedRootOverScroll);
|
| +
|
| + ScrollUpdate(&webViewHelper, 1, -1);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(0, 0), client.m_unusedDelta);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(0, 0), client.m_accumulatedRootOverScroll);
|
| +
|
| + ScrollUpdate(&webViewHelper, -1, -1);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(0, 0), client.m_unusedDelta);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(0, 0), client.m_accumulatedRootOverScroll);
|
| +
|
| + ScrollEnd(&webViewHelper);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(0, 0), client.m_unusedDelta);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(0, 0), client.m_accumulatedRootOverScroll);
|
| +}
|
| +
|
| +TEST_F(WebFrameOverscrollTest, ScaledPageRootLayerOverscrolled)
|
| +{
|
| + OverscrollWebViewClient client;
|
| + registerMockedHttpURLLoad("overscroll/overscroll.html");
|
| + FrameTestHelpers::WebViewHelper webViewHelper;
|
| + WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "overscroll/overscroll.html", true, 0, &client, configureAndroid);
|
| + webViewImpl->setPageScaleFactor(3.f);
|
| + webViewImpl->layout();
|
| +
|
| + // Calculation of accumulatedRootOverscroll and unusedDelta on scaled page.
|
| + ScrollBegin(&webViewHelper);
|
| + ScrollUpdate(&webViewHelper, 0, 30);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(0, -10), client.m_unusedDelta);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(0, -10), client.m_accumulatedRootOverScroll);
|
| +
|
| + ScrollUpdate(&webViewHelper, 0, 30);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(0, -10), client.m_unusedDelta);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(0, -20), client.m_accumulatedRootOverScroll);
|
| +
|
| + ScrollUpdate(&webViewHelper, 30, 30);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(-10, -10), client.m_unusedDelta);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(-10, -30), client.m_accumulatedRootOverScroll);
|
| +
|
| + ScrollUpdate(&webViewHelper, 30, 0);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(-10, 0), client.m_unusedDelta);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(-20, -30), client.m_accumulatedRootOverScroll);
|
| +
|
| + // Overscroll is not reported, so client retains last UnusedDelta and AccumulatedRootOverscroll values.
|
| + ScrollEnd(&webViewHelper);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(-10, 0), client.m_unusedDelta);
|
| + EXPECT_WEB_FLOAT_SIZE_EQ(WebFloatSize(-20, -30), client.m_accumulatedRootOverScroll);
|
| +}
|
| +
|
| } // namespace blink
|
|
|