Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(693)

Side by Side Diff: Source/web/tests/WebFrameTest.cpp

Issue 1056983004: OverscrollGlow for mainThread-{BLINK CHANGES} (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebased to latest Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/web/ChromeClientImpl.cpp ('k') | Source/web/tests/data/overscroll/div-overscroll.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 #include "public/web/WebSpellCheckClient.h" 112 #include "public/web/WebSpellCheckClient.h"
113 #include "public/web/WebTextCheckingCompletion.h" 113 #include "public/web/WebTextCheckingCompletion.h"
114 #include "public/web/WebTextCheckingResult.h" 114 #include "public/web/WebTextCheckingResult.h"
115 #include "public/web/WebViewClient.h" 115 #include "public/web/WebViewClient.h"
116 #include "web/WebLocalFrameImpl.h" 116 #include "web/WebLocalFrameImpl.h"
117 #include "web/WebRemoteFrameImpl.h" 117 #include "web/WebRemoteFrameImpl.h"
118 #include "web/WebViewImpl.h" 118 #include "web/WebViewImpl.h"
119 #include "web/tests/FrameTestHelpers.h" 119 #include "web/tests/FrameTestHelpers.h"
120 #include "wtf/Forward.h" 120 #include "wtf/Forward.h"
121 #include "wtf/dtoa/utils.h" 121 #include "wtf/dtoa/utils.h"
122 #include <gmock/gmock.h>
122 #include <gtest/gtest.h> 123 #include <gtest/gtest.h>
123 #include <map> 124 #include <map>
124 #include <v8.h> 125 #include <v8.h>
125 126
126 using blink::URLTestHelpers::toKURL; 127 using blink::URLTestHelpers::toKURL;
127 using blink::FrameTestHelpers::UseMockScrollbarSettings; 128 using blink::FrameTestHelpers::UseMockScrollbarSettings;
128 using blink::testing::runPendingTasks; 129 using blink::testing::runPendingTasks;
129 using testing::ElementsAre; 130 using testing::ElementsAre;
131 using ::testing::Mock;
130 132
131 namespace blink { 133 namespace blink {
132 134
135 ::std::ostream& operator<<(::std::ostream& os, const WebFloatSize& size)
136 {
137 return os << "WebFloatSize: ["
138 << size.width<< ", " << size.height<< "]";
139 }
140
141 ::std::ostream& operator<<(::std::ostream& os, const WebFloatPoint& point)
142 {
143 return os << "WebFloatPoint: ["
144 << point.x<< ", " << point.y<< "]";
145 }
146
133 const int touchPointPadding = 32; 147 const int touchPointPadding = 32;
134 148
135 #define EXPECT_RECT_EQ(expected, actual) \ 149 #define EXPECT_RECT_EQ(expected, actual) \
136 do { \ 150 do { \
137 EXPECT_EQ(expected.x(), actual.x()); \ 151 EXPECT_EQ(expected.x(), actual.x()); \
138 EXPECT_EQ(expected.y(), actual.y()); \ 152 EXPECT_EQ(expected.y(), actual.y()); \
139 EXPECT_EQ(expected.width(), actual.width()); \ 153 EXPECT_EQ(expected.width(), actual.width()); \
140 EXPECT_EQ(expected.height(), actual.height()); \ 154 EXPECT_EQ(expected.height(), actual.height()); \
141 } while (false) 155 } while (false)
142 156
(...skipping 7321 matching lines...) Expand 10 before | Expand all | Expand 10 after
7464 EXPECT_EQ(fourthFrame, parent->lastChild()); 7478 EXPECT_EQ(fourthFrame, parent->lastChild());
7465 7479
7466 EXPECT_EQ(parent, firstFrame->parent()); 7480 EXPECT_EQ(parent, firstFrame->parent());
7467 EXPECT_EQ(parent, secondFrame->parent()); 7481 EXPECT_EQ(parent, secondFrame->parent());
7468 EXPECT_EQ(parent, thirdFrame->parent()); 7482 EXPECT_EQ(parent, thirdFrame->parent());
7469 EXPECT_EQ(parent, fourthFrame->parent()); 7483 EXPECT_EQ(parent, fourthFrame->parent());
7470 7484
7471 view->close(); 7485 view->close();
7472 } 7486 }
7473 7487
7488 class OverscrollWebViewClient : public FrameTestHelpers::TestWebViewClient {
7489 public:
7490 MOCK_METHOD4(didOverscroll, void(const WebFloatSize&, const WebFloatSize&, c onst WebFloatPoint&, const WebFloatSize&));
7491 };
7492
7493 class WebFrameOverscrollTest : public WebFrameTest {
7494 protected:
7495 WebGestureEvent generateEvent(WebInputEvent::Type type, int deltaX = 0, int deltaY = 0)
7496 {
7497 WebGestureEvent event;
7498 event.type = type;
7499 event.x = 100;
7500 event.y = 100;
7501 if (type == WebInputEvent::GestureScrollUpdate) {
7502 event.data.scrollUpdate.deltaX = deltaX;
7503 event.data.scrollUpdate.deltaY = deltaY;
7504 }
7505 return event;
7506 }
7507
7508 void ScrollBegin(FrameTestHelpers::WebViewHelper* webViewHelper)
7509 {
7510 webViewHelper->webViewImpl()->handleInputEvent(generateEvent(WebInputEve nt::GestureScrollBegin));
7511 }
7512
7513 void ScrollUpdate(FrameTestHelpers::WebViewHelper* webViewHelper, float delt aX, float deltaY)
7514 {
7515 webViewHelper->webViewImpl()->handleInputEvent(generateEvent(WebInputEve nt::GestureScrollUpdate, deltaX, deltaY));
7516 }
7517
7518 void ScrollEnd(FrameTestHelpers::WebViewHelper* webViewHelper)
7519 {
7520 webViewHelper->webViewImpl()->handleInputEvent(generateEvent(WebInputEve nt::GestureScrollEnd));
7521 }
7522 };
7523
7524 TEST_F(WebFrameOverscrollTest, AccumulatedRootOverscrollAndUnsedDeltaValuesOnOve rscroll)
7525 {
7526 OverscrollWebViewClient client;
7527 registerMockedHttpURLLoad("overscroll/overscroll.html");
7528 FrameTestHelpers::WebViewHelper webViewHelper;
7529 webViewHelper.initializeAndLoad(m_baseURL + "overscroll/overscroll.html", tr ue, 0, &client, configureAndroid);
7530
7531 // Calculation of accumulatedRootOverscroll and unusedDelta on multiple scro llUpdate.
7532 ScrollBegin(&webViewHelper);
7533 EXPECT_CALL(client, didOverscroll(WebFloatSize(8, 16), WebFloatSize(8, 16), WebFloatPoint(100, 100), WebFloatSize()));
7534 ScrollUpdate(&webViewHelper, -308, -316);
7535 Mock::VerifyAndClearExpectations(&client);
7536
7537 EXPECT_CALL(client, didOverscroll(WebFloatSize(0, 13), WebFloatSize(8, 29), WebFloatPoint(100, 100), WebFloatSize()));
7538 ScrollUpdate(&webViewHelper, 0, -13);
7539 Mock::VerifyAndClearExpectations(&client);
7540
7541 EXPECT_CALL(client, didOverscroll(WebFloatSize(20, 13), WebFloatSize(28, 42) , WebFloatPoint(100, 100), WebFloatSize()));
7542 ScrollUpdate(&webViewHelper, -20, -13);
7543 Mock::VerifyAndClearExpectations(&client);
7544
7545 // Overscroll is not reported.
7546 EXPECT_CALL(client, didOverscroll(WebFloatSize(), WebFloatSize(), WebFloatPo int(100, 100), WebFloatSize())).Times(0);
7547 ScrollUpdate(&webViewHelper, 0, 1);
7548 Mock::VerifyAndClearExpectations(&client);
7549
7550 EXPECT_CALL(client, didOverscroll(WebFloatSize(), WebFloatSize(), WebFloatPo int(100, 100), WebFloatSize())).Times(0);
7551 ScrollUpdate(&webViewHelper, 1, 0);
7552 Mock::VerifyAndClearExpectations(&client);
7553
7554 // Overscroll is reported.
7555 EXPECT_CALL(client, didOverscroll(WebFloatSize(0, -701), WebFloatSize(0, -70 1), WebFloatPoint(100, 100), WebFloatSize()));
7556 ScrollUpdate(&webViewHelper, 0, 1000);
7557 Mock::VerifyAndClearExpectations(&client);
7558
7559 // Overscroll is not reported.
7560 EXPECT_CALL(client, didOverscroll(WebFloatSize(), WebFloatSize(), WebFloatPo int(100, 100), WebFloatSize())).Times(0);
7561 ScrollEnd(&webViewHelper);
7562 Mock::VerifyAndClearExpectations(&client);
7563 }
7564
7565 TEST_F(WebFrameOverscrollTest, AccumulatedOverscrollAndUnusedDeltaValuesOnDiffer entAxesOverscroll)
7566 {
7567 OverscrollWebViewClient client;
7568 registerMockedHttpURLLoad("overscroll/div-overscroll.html");
7569 FrameTestHelpers::WebViewHelper webViewHelper;
7570 webViewHelper.initializeAndLoad(m_baseURL + "overscroll/div-overscroll.html" , true, 0, &client, configureAndroid);
7571
7572 ScrollBegin(&webViewHelper);
7573
7574 // Scroll the Div to the end.
7575 EXPECT_CALL(client, didOverscroll(WebFloatSize(), WebFloatSize(), WebFloatPo int(100, 100), WebFloatSize())).Times(0);
7576 ScrollUpdate(&webViewHelper, 0, -316);
7577 Mock::VerifyAndClearExpectations(&client);
7578
7579 // Now On Scrolling DIV, scroll is bubbled and root layer is over-scrolled.
7580 EXPECT_CALL(client, didOverscroll(WebFloatSize(0, 100), WebFloatSize(0, 100) , WebFloatPoint(100, 100), WebFloatSize()));
7581 ScrollUpdate(&webViewHelper, 0, -100);
7582 Mock::VerifyAndClearExpectations(&client);
7583
7584 // Page scrolls vertically, but over-scrolls horizontally.
7585 EXPECT_CALL(client, didOverscroll(WebFloatSize(-100, 0), WebFloatSize(-100, 0), WebFloatPoint(100, 100), WebFloatSize()));
7586 ScrollUpdate(&webViewHelper, 100, 50);
7587 Mock::VerifyAndClearExpectations(&client);
7588
7589 // Scrolling up, Overscroll is not reported.
7590 EXPECT_CALL(client, didOverscroll(WebFloatSize(), WebFloatSize(), WebFloatPo int(), WebFloatSize())).Times(0);
7591 ScrollUpdate(&webViewHelper, 0, -50);
7592 Mock::VerifyAndClearExpectations(&client);
7593
7594 // Page scrolls horizontally, but over-scrolls vertically.
7595 EXPECT_CALL(client, didOverscroll(WebFloatSize(0, 100), WebFloatSize(0, 100) , WebFloatPoint(100, 100), WebFloatSize()));
7596 ScrollUpdate(&webViewHelper, -100, -100);
7597 Mock::VerifyAndClearExpectations(&client);
7598 }
7599
7600 TEST_F(WebFrameOverscrollTest, RootLayerOverscrolledOnInnerDivOverScroll)
7601 {
7602 OverscrollWebViewClient client;
7603 registerMockedHttpURLLoad("overscroll/div-overscroll.html");
7604 FrameTestHelpers::WebViewHelper webViewHelper;
7605 webViewHelper.initializeAndLoad(m_baseURL + "overscroll/div-overscroll.html" , true, 0, &client, configureAndroid);
7606
7607 ScrollBegin(&webViewHelper);
7608
7609 // Scroll the Div to the end.
7610 EXPECT_CALL(client, didOverscroll(WebFloatSize(), WebFloatSize(), WebFloatPo int(100, 100), WebFloatSize())).Times(0);
7611 ScrollUpdate(&webViewHelper, 0, -316);
7612 Mock::VerifyAndClearExpectations(&client);
7613
7614 // Now On Scrolling DIV, scroll is bubbled and root layer is over-scrolled.
7615 EXPECT_CALL(client, didOverscroll(WebFloatSize(0, 50), WebFloatSize(0, 50), WebFloatPoint(100, 100), WebFloatSize()));
7616 ScrollUpdate(&webViewHelper, 0, -50);
7617 Mock::VerifyAndClearExpectations(&client);
7618 }
7619
7620 TEST_F(WebFrameOverscrollTest, RootLayerOverscrolledOnInnerIFrameOverScroll)
7621 {
7622 OverscrollWebViewClient client;
7623 registerMockedHttpURLLoad("overscroll/iframe-overscroll.html");
7624 registerMockedHttpURLLoad("overscroll/scrollable-iframe.html");
7625 FrameTestHelpers::WebViewHelper webViewHelper;
7626 webViewHelper.initializeAndLoad(m_baseURL + "overscroll/iframe-overscroll.ht ml", true, 0, &client, configureAndroid);
7627
7628 ScrollBegin(&webViewHelper);
7629 // Scroll the IFrame to the end.
7630 EXPECT_CALL(client, didOverscroll(WebFloatSize(), WebFloatSize(), WebFloatPo int(100, 100), WebFloatSize())).Times(0);
7631 ScrollUpdate(&webViewHelper, 0, -320);
7632 Mock::VerifyAndClearExpectations(&client);
7633
7634 // Now On Scrolling IFrame, scroll is bubbled and root layer is over-scrolle d.
7635 EXPECT_CALL(client, didOverscroll(WebFloatSize(0, 50), WebFloatSize(0, 50), WebFloatPoint(100, 100), WebFloatSize()));
7636 ScrollUpdate(&webViewHelper, 0, -50);
7637 Mock::VerifyAndClearExpectations(&client);
7638 }
7639
7640 TEST_F(WebFrameOverscrollTest, NoOverscrollOnNonScrollableaxes)
7641 {
7642 OverscrollWebViewClient client;
7643 registerMockedHttpURLLoad("overscroll/no-overscroll-on-nonscrollable-axes.ht ml");
7644 FrameTestHelpers::WebViewHelper webViewHelper;
7645 webViewHelper.initializeAndLoad(m_baseURL + "overscroll/no-overscroll-on-non scrollable-axes.html", true, 0, &client, configureAndroid);
7646
7647 // Overscroll is not reported in all the directions.
7648 ScrollBegin(&webViewHelper);
7649 EXPECT_CALL(client, didOverscroll(WebFloatSize(), WebFloatSize(), WebFloatPo int(100, 100), WebFloatSize())).Times(0);
7650 ScrollUpdate(&webViewHelper, 0, -1);
7651 Mock::VerifyAndClearExpectations(&client);
7652
7653 EXPECT_CALL(client, didOverscroll(WebFloatSize(), WebFloatSize(), WebFloatPo int(100, 100), WebFloatSize())).Times(0);
7654 ScrollUpdate(&webViewHelper, 0, 1);
7655 Mock::VerifyAndClearExpectations(&client);
7656
7657 EXPECT_CALL(client, didOverscroll(WebFloatSize(), WebFloatSize(), WebFloatPo int(100, 100), WebFloatSize())).Times(0);
7658 ScrollUpdate(&webViewHelper, 1, 0);
7659 Mock::VerifyAndClearExpectations(&client);
7660
7661 EXPECT_CALL(client, didOverscroll(WebFloatSize(), WebFloatSize(), WebFloatPo int(100, 100), WebFloatSize())).Times(0);
7662 ScrollUpdate(&webViewHelper, -1, 0);
7663 Mock::VerifyAndClearExpectations(&client);
7664
7665 EXPECT_CALL(client, didOverscroll(WebFloatSize(), WebFloatSize(), WebFloatPo int(100, 100), WebFloatSize())).Times(0);
7666 ScrollUpdate(&webViewHelper, 1, 1);
7667 Mock::VerifyAndClearExpectations(&client);
7668
7669 EXPECT_CALL(client, didOverscroll(WebFloatSize(), WebFloatSize(), WebFloatPo int(100, 100), WebFloatSize())).Times(0);
7670 ScrollUpdate(&webViewHelper, -1, 1);
7671 Mock::VerifyAndClearExpectations(&client);
7672
7673 EXPECT_CALL(client, didOverscroll(WebFloatSize(), WebFloatSize(), WebFloatPo int(100, 100), WebFloatSize())).Times(0);
7674 ScrollUpdate(&webViewHelper, 1, -1);
7675 Mock::VerifyAndClearExpectations(&client);
7676
7677 EXPECT_CALL(client, didOverscroll(WebFloatSize(), WebFloatSize(), WebFloatPo int(100, 100), WebFloatSize())).Times(0);
7678 ScrollUpdate(&webViewHelper, -1, -1);
7679 Mock::VerifyAndClearExpectations(&client);
7680
7681 EXPECT_CALL(client, didOverscroll(WebFloatSize(), WebFloatSize(), WebFloatPo int(100, 100), WebFloatSize())).Times(0);
7682 ScrollEnd(&webViewHelper);
7683 Mock::VerifyAndClearExpectations(&client);
7684 }
7685
7686 TEST_F(WebFrameOverscrollTest, ScaledPageRootLayerOverscrolled)
7687 {
7688 OverscrollWebViewClient client;
7689 registerMockedHttpURLLoad("overscroll/overscroll.html");
7690 FrameTestHelpers::WebViewHelper webViewHelper;
7691 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "over scroll/overscroll.html", true, 0, &client, configureAndroid);
7692 webViewImpl->setPageScaleFactor(3.0);
7693
7694 // Calculation of accumulatedRootOverscroll and unusedDelta on scaled page.
7695 ScrollBegin(&webViewHelper);
7696 EXPECT_CALL(client, didOverscroll(WebFloatSize(0, -10), WebFloatSize(0, -10) , WebFloatPoint(33, 33), WebFloatSize()));
7697 ScrollUpdate(&webViewHelper, 0, 30);
7698 Mock::VerifyAndClearExpectations(&client);
7699
7700 EXPECT_CALL(client, didOverscroll(WebFloatSize(0, -10), WebFloatSize(0, -20) , WebFloatPoint(33, 33), WebFloatSize()));
7701 ScrollUpdate(&webViewHelper, 0, 30);
7702 Mock::VerifyAndClearExpectations(&client);
7703
7704 EXPECT_CALL(client, didOverscroll(WebFloatSize(-10, -10), WebFloatSize(-10, -30), WebFloatPoint(33, 33), WebFloatSize()));
7705 ScrollUpdate(&webViewHelper, 30, 30);
7706 Mock::VerifyAndClearExpectations(&client);
7707
7708 EXPECT_CALL(client, didOverscroll(WebFloatSize(-10, 0), WebFloatSize(-20, -3 0), WebFloatPoint(33, 33), WebFloatSize()));
7709 ScrollUpdate(&webViewHelper, 30, 0);
7710 Mock::VerifyAndClearExpectations(&client);
7711
7712 // Overscroll is not reported.
7713 EXPECT_CALL(client, didOverscroll(WebFloatSize(), WebFloatSize(), WebFloatPo int(33, 33), WebFloatSize())).Times(0);
7714 ScrollEnd(&webViewHelper);
7715 Mock::VerifyAndClearExpectations(&client);
7716 }
7717
7474 } // namespace blink 7718 } // namespace blink
OLDNEW
« no previous file with comments | « Source/web/ChromeClientImpl.cpp ('k') | Source/web/tests/data/overscroll/div-overscroll.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698