Chromium Code Reviews| 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 7671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7682 view->close(); | 7682 view->close(); |
| 7683 } | 7683 } |
| 7684 | 7684 |
| 7685 class OverscrollWebViewClient : public FrameTestHelpers::TestWebViewClient { | 7685 class OverscrollWebViewClient : public FrameTestHelpers::TestWebViewClient { |
| 7686 public: | 7686 public: |
| 7687 MOCK_METHOD4(didOverscroll, void(const WebFloatSize&, const WebFloatSize&, c onst WebFloatPoint&, const WebFloatSize&)); | 7687 MOCK_METHOD4(didOverscroll, void(const WebFloatSize&, const WebFloatSize&, c onst WebFloatPoint&, const WebFloatSize&)); |
| 7688 }; | 7688 }; |
| 7689 | 7689 |
| 7690 class WebFrameOverscrollTest : public WebFrameTest { | 7690 class WebFrameOverscrollTest : public WebFrameTest { |
| 7691 protected: | 7691 protected: |
| 7692 WebGestureEvent generateEvent(WebInputEvent::Type type, int deltaX = 0, int deltaY = 0) | 7692 WebGestureEvent generateEvent(WebInputEvent::Type type, float deltaX = 0.0, float deltaY = 0.0) |
| 7693 { | 7693 { |
| 7694 WebGestureEvent event; | 7694 WebGestureEvent event; |
| 7695 event.type = type; | 7695 event.type = type; |
| 7696 event.x = 100; | 7696 event.x = 100; |
| 7697 event.y = 100; | 7697 event.y = 100; |
| 7698 if (type == WebInputEvent::GestureScrollUpdate) { | 7698 if (type == WebInputEvent::GestureScrollUpdate) { |
| 7699 event.data.scrollUpdate.deltaX = deltaX; | 7699 event.data.scrollUpdate.deltaX = deltaX; |
| 7700 event.data.scrollUpdate.deltaY = deltaY; | 7700 event.data.scrollUpdate.deltaY = deltaY; |
| 7701 } | 7701 } |
| 7702 return event; | 7702 return event; |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7917 EXPECT_CALL(client, didOverscroll(WebFloatSize(-10, 0), WebFloatSize(-20, -3 0), WebFloatPoint(33, 33), WebFloatSize())); | 7917 EXPECT_CALL(client, didOverscroll(WebFloatSize(-10, 0), WebFloatSize(-20, -3 0), WebFloatPoint(33, 33), WebFloatSize())); |
| 7918 ScrollUpdate(&webViewHelper, 30, 0); | 7918 ScrollUpdate(&webViewHelper, 30, 0); |
| 7919 Mock::VerifyAndClearExpectations(&client); | 7919 Mock::VerifyAndClearExpectations(&client); |
| 7920 | 7920 |
| 7921 // Overscroll is not reported. | 7921 // Overscroll is not reported. |
| 7922 EXPECT_CALL(client, didOverscroll(WebFloatSize(), WebFloatSize(), WebFloatPo int(33, 33), WebFloatSize())).Times(0); | 7922 EXPECT_CALL(client, didOverscroll(WebFloatSize(), WebFloatSize(), WebFloatPo int(33, 33), WebFloatSize())).Times(0); |
| 7923 ScrollEnd(&webViewHelper); | 7923 ScrollEnd(&webViewHelper); |
| 7924 Mock::VerifyAndClearExpectations(&client); | 7924 Mock::VerifyAndClearExpectations(&client); |
| 7925 } | 7925 } |
| 7926 | 7926 |
| 7927 TEST_F(WebFrameOverscrollTest, NoOverscrollForSmallvalues) | |
| 7928 { | |
| 7929 OverscrollWebViewClient client; | |
| 7930 registerMockedHttpURLLoad("overscroll/overscroll.html"); | |
| 7931 FrameTestHelpers::WebViewHelper webViewHelper; | |
| 7932 webViewHelper.initializeAndLoad(m_baseURL + "overscroll/overscroll.html", tr ue, 0, &client, configureAndroid); | |
| 7933 | |
| 7934 ScrollBegin(&webViewHelper); | |
| 7935 EXPECT_CALL(client, didOverscroll(WebFloatSize(0, -10.01), WebFloatSize(0, - 10.01), WebFloatPoint(100, 100), WebFloatSize())); | |
| 7936 ScrollUpdate(&webViewHelper, 0, 10.01); | |
| 7937 Mock::VerifyAndClearExpectations(&client); | |
|
majidvp
2015/07/09 18:01:18
I suggest adding a test to verify that the thresho
majidvp
2015/07/09 18:21:30
What about this?
| |
| 7938 | |
| 7939 // For residual values overscrollDelta should be reset and didOverscroll sho uldn't be called. | |
| 7940 EXPECT_CALL(client, didOverscroll(_, _, _, _)).Times(0); | |
| 7941 ScrollUpdate(&webViewHelper, 0, 0.09); | |
| 7942 Mock::VerifyAndClearExpectations(&client); | |
| 7943 | |
| 7944 EXPECT_CALL(client, didOverscroll(_, _, _, _)).Times(0); | |
| 7945 ScrollUpdate(&webViewHelper, 0.09, 0.09); | |
| 7946 Mock::VerifyAndClearExpectations(&client); | |
| 7947 | |
| 7948 EXPECT_CALL(client, didOverscroll(_, _, _, _)).Times(0); | |
| 7949 ScrollUpdate(&webViewHelper, 0.09, 0); | |
| 7950 Mock::VerifyAndClearExpectations(&client); | |
| 7951 | |
| 7952 EXPECT_CALL(client, didOverscroll(_, _, _, _)).Times(0); | |
| 7953 ScrollUpdate(&webViewHelper, 0, -0.09); | |
| 7954 Mock::VerifyAndClearExpectations(&client); | |
| 7955 | |
| 7956 EXPECT_CALL(client, didOverscroll(_, _, _, _)).Times(0); | |
| 7957 ScrollUpdate(&webViewHelper, -0.09, -0.09); | |
| 7958 Mock::VerifyAndClearExpectations(&client); | |
| 7959 | |
| 7960 EXPECT_CALL(client, didOverscroll(_, _, _, _)).Times(0); | |
| 7961 ScrollUpdate(&webViewHelper, -0.09, 0); | |
| 7962 Mock::VerifyAndClearExpectations(&client); | |
| 7963 | |
| 7964 // Overscroll is not reported. | |
| 7965 EXPECT_CALL(client, didOverscroll(_, _, _, _)).Times(0); | |
| 7966 ScrollEnd(&webViewHelper); | |
| 7967 Mock::VerifyAndClearExpectations(&client); | |
| 7968 } | |
| 7969 | |
| 7927 TEST_F(WebFrameOverscrollTest, ReportingLatestOverscrollForElasticOverscroll) | 7970 TEST_F(WebFrameOverscrollTest, ReportingLatestOverscrollForElasticOverscroll) |
| 7928 { | 7971 { |
| 7929 OverscrollWebViewClient client; | 7972 OverscrollWebViewClient client; |
| 7930 registerMockedHttpURLLoad("overscroll/overscroll.html"); | 7973 registerMockedHttpURLLoad("overscroll/overscroll.html"); |
| 7931 FrameTestHelpers::WebViewHelper webViewHelper; | 7974 FrameTestHelpers::WebViewHelper webViewHelper; |
| 7932 webViewHelper.initializeAndLoad(m_baseURL + "overscroll/overscroll.html", tr ue, 0, &client, configureAndroid); | 7975 webViewHelper.initializeAndLoad(m_baseURL + "overscroll/overscroll.html", tr ue, 0, &client, configureAndroid); |
| 7933 | 7976 |
| 7934 // On disabling ReportWheelOverscroll, overscroll is not reported on MouseWh eel. | 7977 // On disabling ReportWheelOverscroll, overscroll is not reported on MouseWh eel. |
| 7935 webViewHelper.webView()->settings()->setReportWheelOverscroll(false); | 7978 webViewHelper.webView()->settings()->setReportWheelOverscroll(false); |
| 7936 EXPECT_CALL(client, didOverscroll(WebFloatSize(), WebFloatSize(), WebFloatPo int(), WebFloatSize())).Times(0); | 7979 EXPECT_CALL(client, didOverscroll(WebFloatSize(), WebFloatSize(), WebFloatPo int(), WebFloatSize())).Times(0); |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 7955 | 7998 |
| 7956 TEST_F(WebFrameTest, MaxFramesDetach) | 7999 TEST_F(WebFrameTest, MaxFramesDetach) |
| 7957 { | 8000 { |
| 7958 registerMockedHttpURLLoad("max-frames-detach.html"); | 8001 registerMockedHttpURLLoad("max-frames-detach.html"); |
| 7959 FrameTestHelpers::WebViewHelper webViewHelper; | 8002 FrameTestHelpers::WebViewHelper webViewHelper; |
| 7960 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "max- frames-detach.html", true); | 8003 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "max- frames-detach.html", true); |
| 7961 webViewImpl->mainFrameImpl()->collectGarbage(); | 8004 webViewImpl->mainFrameImpl()->collectGarbage(); |
| 7962 } | 8005 } |
| 7963 | 8006 |
| 7964 } // namespace blink | 8007 } // namespace blink |
| OLD | NEW |