OLD | NEW |
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 7551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7562 event.type = type; | 7562 event.type = type; |
7563 event.x = 100; | 7563 event.x = 100; |
7564 event.y = 100; | 7564 event.y = 100; |
7565 if (type == WebInputEvent::GestureScrollUpdate) { | 7565 if (type == WebInputEvent::GestureScrollUpdate) { |
7566 event.data.scrollUpdate.deltaX = deltaX; | 7566 event.data.scrollUpdate.deltaX = deltaX; |
7567 event.data.scrollUpdate.deltaY = deltaY; | 7567 event.data.scrollUpdate.deltaY = deltaY; |
7568 } | 7568 } |
7569 return event; | 7569 return event; |
7570 } | 7570 } |
7571 | 7571 |
| 7572 void ScrollByWheel(FrameTestHelpers::WebViewHelper* webViewHelper, int windo
wX, int windowY, float deltaX, float deltaY) |
| 7573 { |
| 7574 WebMouseWheelEvent event; |
| 7575 event.type = WebInputEvent::MouseWheel; |
| 7576 event.deltaX = deltaX; |
| 7577 event.deltaY = deltaY; |
| 7578 event.windowX = windowX; |
| 7579 event.windowY = windowY; |
| 7580 event.canScroll = true; |
| 7581 webViewHelper->webViewImpl()->handleInputEvent(event); |
| 7582 } |
| 7583 |
7572 void ScrollBegin(FrameTestHelpers::WebViewHelper* webViewHelper) | 7584 void ScrollBegin(FrameTestHelpers::WebViewHelper* webViewHelper) |
7573 { | 7585 { |
7574 webViewHelper->webViewImpl()->handleInputEvent(generateEvent(WebInputEve
nt::GestureScrollBegin)); | 7586 webViewHelper->webViewImpl()->handleInputEvent(generateEvent(WebInputEve
nt::GestureScrollBegin)); |
7575 } | 7587 } |
7576 | 7588 |
7577 void ScrollUpdate(FrameTestHelpers::WebViewHelper* webViewHelper, float delt
aX, float deltaY) | 7589 void ScrollUpdate(FrameTestHelpers::WebViewHelper* webViewHelper, float delt
aX, float deltaY) |
7578 { | 7590 { |
7579 webViewHelper->webViewImpl()->handleInputEvent(generateEvent(WebInputEve
nt::GestureScrollUpdate, deltaX, deltaY)); | 7591 webViewHelper->webViewImpl()->handleInputEvent(generateEvent(WebInputEve
nt::GestureScrollUpdate, deltaX, deltaY)); |
7580 } | 7592 } |
7581 | 7593 |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7772 EXPECT_CALL(client, didOverscroll(WebFloatSize(-10, 0), WebFloatSize(-20, -3
0), WebFloatPoint(33, 33), WebFloatSize())); | 7784 EXPECT_CALL(client, didOverscroll(WebFloatSize(-10, 0), WebFloatSize(-20, -3
0), WebFloatPoint(33, 33), WebFloatSize())); |
7773 ScrollUpdate(&webViewHelper, 30, 0); | 7785 ScrollUpdate(&webViewHelper, 30, 0); |
7774 Mock::VerifyAndClearExpectations(&client); | 7786 Mock::VerifyAndClearExpectations(&client); |
7775 | 7787 |
7776 // Overscroll is not reported. | 7788 // Overscroll is not reported. |
7777 EXPECT_CALL(client, didOverscroll(WebFloatSize(), WebFloatSize(), WebFloatPo
int(33, 33), WebFloatSize())).Times(0); | 7789 EXPECT_CALL(client, didOverscroll(WebFloatSize(), WebFloatSize(), WebFloatPo
int(33, 33), WebFloatSize())).Times(0); |
7778 ScrollEnd(&webViewHelper); | 7790 ScrollEnd(&webViewHelper); |
7779 Mock::VerifyAndClearExpectations(&client); | 7791 Mock::VerifyAndClearExpectations(&client); |
7780 } | 7792 } |
7781 | 7793 |
| 7794 TEST_F(WebFrameOverscrollTest, ReportingLatestOverscrollForElasticOverscroll) |
| 7795 { |
| 7796 OverscrollWebViewClient client; |
| 7797 registerMockedHttpURLLoad("overscroll/overscroll.html"); |
| 7798 FrameTestHelpers::WebViewHelper webViewHelper; |
| 7799 webViewHelper.initializeAndLoad(m_baseURL + "overscroll/overscroll.html", tr
ue, 0, &client, configureAndroid); |
| 7800 |
| 7801 // On disabling elasticoverscroll, overscroll is not reported on MouseWheel. |
| 7802 webViewHelper.webView()->settings()->setElasticOverscrollEnabled(false); |
| 7803 EXPECT_CALL(client, didOverscroll(WebFloatSize(), WebFloatSize(), WebFloatPo
int(), WebFloatSize())).Times(0); |
| 7804 ScrollByWheel(&webViewHelper, 10, 10, 1000, 1000); |
| 7805 Mock::VerifyAndClearExpectations(&client); |
| 7806 |
| 7807 // On enabling elasticoverscroll, overscroll is reported on MouseWheel. |
| 7808 webViewHelper.webView()->settings()->setElasticOverscrollEnabled(true); |
| 7809 EXPECT_CALL(client, didOverscroll(WebFloatSize(1000, 1000), WebFloatSize(100
0, 1000), WebFloatPoint(), WebFloatSize())); |
| 7810 ScrollByWheel(&webViewHelper, 10, 10, 1000, 1000); |
| 7811 Mock::VerifyAndClearExpectations(&client); |
| 7812 } |
| 7813 |
7782 TEST_F(WebFrameTest, OrientationFrameDetach) | 7814 TEST_F(WebFrameTest, OrientationFrameDetach) |
7783 { | 7815 { |
7784 RuntimeEnabledFeatures::setOrientationEventEnabled(true); | 7816 RuntimeEnabledFeatures::setOrientationEventEnabled(true); |
7785 registerMockedHttpURLLoad("orientation-frame-detach.html"); | 7817 registerMockedHttpURLLoad("orientation-frame-detach.html"); |
7786 FrameTestHelpers::WebViewHelper webViewHelper; | 7818 FrameTestHelpers::WebViewHelper webViewHelper; |
7787 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "orie
ntation-frame-detach.html", true); | 7819 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "orie
ntation-frame-detach.html", true); |
7788 webViewImpl->mainFrameImpl()->sendOrientationChangeEvent(); | 7820 webViewImpl->mainFrameImpl()->sendOrientationChangeEvent(); |
7789 } | 7821 } |
7790 | 7822 |
7791 TEST_F(WebFrameTest, MaxFramesDetach) | 7823 TEST_F(WebFrameTest, MaxFramesDetach) |
7792 { | 7824 { |
7793 registerMockedHttpURLLoad("max-frames-detach.html"); | 7825 registerMockedHttpURLLoad("max-frames-detach.html"); |
7794 FrameTestHelpers::WebViewHelper webViewHelper; | 7826 FrameTestHelpers::WebViewHelper webViewHelper; |
7795 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "max-
frames-detach.html", true); | 7827 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "max-
frames-detach.html", true); |
7796 webViewImpl->mainFrameImpl()->collectGarbage(); | 7828 webViewImpl->mainFrameImpl()->collectGarbage(); |
7797 } | 7829 } |
7798 | 7830 |
7799 } // namespace blink | 7831 } // namespace blink |
OLD | NEW |