| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 #include "config.h" | 26 #include "config.h" |
| 27 | 27 |
| 28 #include "WebCompositorInputHandlerImpl.h" | 28 #include "WebCompositorInputHandlerImpl.h" |
| 29 | 29 |
| 30 #include "WebCompositor.h" | 30 #include "WebCompositor.h" |
| 31 #include "WebCompositorInputHandlerClient.h" | 31 #include "WebCompositorInputHandlerClient.h" |
| 32 #include "WebInputEvent.h" | 32 #include "WebInputEvent.h" |
| 33 #include "cc/CCActiveGestureAnimation.h" | 33 #include "cc/CCActiveGestureAnimation.h" |
| 34 #include "cc/CCInputHandler.h" | 34 #include "cc/CCInputHandler.h" |
| 35 #include "cc/CCSingleThreadProxy.h" | 35 #include "cc/CCSingleThreadProxy.h" |
| 36 #include "platform/WebFloatPoint.h" |
| 37 #include "platform/WebPoint.h" |
| 36 | 38 |
| 37 #include <gmock/gmock.h> | 39 #include <gmock/gmock.h> |
| 38 #include <gtest/gtest.h> | 40 #include <gtest/gtest.h> |
| 39 #include <wtf/OwnPtr.h> | 41 #include <wtf/OwnPtr.h> |
| 40 | 42 |
| 41 using WebKit::WebCompositorInputHandler; | 43 using namespace WebKit; |
| 42 using WebKit::WebCompositorInputHandlerImpl; | |
| 43 | 44 |
| 44 namespace { | 45 namespace { |
| 45 | 46 |
| 46 class MockCCInputHandlerClient : public WebCore::CCInputHandlerClient { | 47 class MockCCInputHandlerClient : public WebCore::CCInputHandlerClient { |
| 47 WTF_MAKE_NONCOPYABLE(MockCCInputHandlerClient); | 48 WTF_MAKE_NONCOPYABLE(MockCCInputHandlerClient); |
| 48 public: | 49 public: |
| 49 MockCCInputHandlerClient() | 50 MockCCInputHandlerClient() |
| 50 { | 51 { |
| 51 } | 52 } |
| 52 virtual ~MockCCInputHandlerClient() { } | 53 virtual ~MockCCInputHandlerClient() { } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 66 virtual void startPageScaleAnimation(const WebCore::IntSize& targetPosition, | 67 virtual void startPageScaleAnimation(const WebCore::IntSize& targetPosition, |
| 67 bool anchorPoint, | 68 bool anchorPoint, |
| 68 float pageScale, | 69 float pageScale, |
| 69 double startTimeMs, | 70 double startTimeMs, |
| 70 double durationMs) OVERRIDE { } | 71 double durationMs) OVERRIDE { } |
| 71 | 72 |
| 72 virtual WebCore::CCActiveGestureAnimation* activeGestureAnimation() OVERRIDE
{ return 0; } | 73 virtual WebCore::CCActiveGestureAnimation* activeGestureAnimation() OVERRIDE
{ return 0; } |
| 73 virtual void setActiveGestureAnimation(PassOwnPtr<WebCore::CCActiveGestureAn
imation>) OVERRIDE { } | 74 virtual void setActiveGestureAnimation(PassOwnPtr<WebCore::CCActiveGestureAn
imation>) OVERRIDE { } |
| 74 }; | 75 }; |
| 75 | 76 |
| 76 class MockWebCompositorInputHandlerClient : public WebKit::WebCompositorInputHan
dlerClient { | 77 class MockWebCompositorInputHandlerClient : public WebCompositorInputHandlerClie
nt { |
| 77 WTF_MAKE_NONCOPYABLE(MockWebCompositorInputHandlerClient); | 78 WTF_MAKE_NONCOPYABLE(MockWebCompositorInputHandlerClient); |
| 78 public: | 79 public: |
| 79 MockWebCompositorInputHandlerClient() | 80 MockWebCompositorInputHandlerClient() |
| 80 : WebKit::WebCompositorInputHandlerClient() | 81 : WebCompositorInputHandlerClient() |
| 81 { | 82 { |
| 82 } | 83 } |
| 83 virtual ~MockWebCompositorInputHandlerClient() { } | 84 virtual ~MockWebCompositorInputHandlerClient() { } |
| 84 | 85 |
| 85 MOCK_METHOD0(willShutdown, void()); | 86 MOCK_METHOD0(willShutdown, void()); |
| 86 MOCK_METHOD0(didHandleInputEvent, void()); | 87 MOCK_METHOD0(didHandleInputEvent, void()); |
| 87 MOCK_METHOD1(didNotHandleInputEvent, void(bool sendToWidget)); | 88 MOCK_METHOD1(didNotHandleInputEvent, void(bool sendToWidget)); |
| 89 |
| 90 MOCK_METHOD1(transferActiveWheelFlingAnimation, void(const WebActiveWheelFli
ngParameters&)); |
| 91 |
| 88 }; | 92 }; |
| 89 | 93 |
| 90 TEST(WebCompositorInputHandlerImpl, fromIdentifier) | 94 TEST(WebCompositorInputHandlerImpl, fromIdentifier) |
| 91 { | 95 { |
| 92 WebKit::WebCompositor::initialize(0); | 96 WebCompositor::initialize(0); |
| 93 WebCore::DebugScopedSetImplThread alwaysImplThread; | 97 WebCore::DebugScopedSetImplThread alwaysImplThread; |
| 94 | 98 |
| 95 // Before creating any WebCompositorInputHandlers, lookups for any value sho
uld fail and not crash. | 99 // Before creating any WebCompositorInputHandlers, lookups for any value sho
uld fail and not crash. |
| 96 EXPECT_EQ(0, WebCompositorInputHandler::fromIdentifier(2)); | 100 EXPECT_EQ(0, WebCompositorInputHandler::fromIdentifier(2)); |
| 97 EXPECT_EQ(0, WebCompositorInputHandler::fromIdentifier(0)); | 101 EXPECT_EQ(0, WebCompositorInputHandler::fromIdentifier(0)); |
| 98 EXPECT_EQ(0, WebCompositorInputHandler::fromIdentifier(-1)); | 102 EXPECT_EQ(0, WebCompositorInputHandler::fromIdentifier(-1)); |
| 99 | 103 |
| 100 int compositorIdentifier = -1; | 104 int compositorIdentifier = -1; |
| 101 { | 105 { |
| 102 OwnPtr<WebCompositorInputHandlerImpl> inputHandler = WebCompositorInputH
andlerImpl::create(0); | 106 OwnPtr<WebCompositorInputHandlerImpl> inputHandler = WebCompositorInputH
andlerImpl::create(0); |
| 103 compositorIdentifier = inputHandler->identifier(); | 107 compositorIdentifier = inputHandler->identifier(); |
| 104 // The compositor we just created should be locatable. | 108 // The compositor we just created should be locatable. |
| 105 EXPECT_EQ(inputHandler.get(), WebCompositorInputHandler::fromIdentifier(
compositorIdentifier)); | 109 EXPECT_EQ(inputHandler.get(), WebCompositorInputHandler::fromIdentifier(
compositorIdentifier)); |
| 106 | 110 |
| 107 // But nothing else. | 111 // But nothing else. |
| 108 EXPECT_EQ(0, WebCompositorInputHandler::fromIdentifier(inputHandler->ide
ntifier() + 10)); | 112 EXPECT_EQ(0, WebCompositorInputHandler::fromIdentifier(inputHandler->ide
ntifier() + 10)); |
| 109 } | 113 } |
| 110 | 114 |
| 111 // After the compositor is destroyed, its entry should be removed from the m
ap. | 115 // After the compositor is destroyed, its entry should be removed from the m
ap. |
| 112 EXPECT_EQ(0, WebCompositorInputHandler::fromIdentifier(compositorIdentifier)
); | 116 EXPECT_EQ(0, WebCompositorInputHandler::fromIdentifier(compositorIdentifier)
); |
| 113 WebKit::WebCompositor::shutdown(); | 117 WebCompositor::shutdown(); |
| 114 } | 118 } |
| 115 | 119 |
| 116 class WebCompositorInputHandlerImplTest : public testing::Test { | 120 class WebCompositorInputHandlerImplTest : public testing::Test { |
| 117 public: | 121 public: |
| 118 WebCompositorInputHandlerImplTest() | 122 WebCompositorInputHandlerImplTest() |
| 119 : m_expectedDisposition(DidHandle) | 123 : m_expectedDisposition(DidHandle) |
| 120 { | 124 { |
| 121 WebKit::WebCompositor::initialize(0); | 125 WebCompositor::initialize(0); |
| 122 m_inputHandler = WebCompositorInputHandlerImpl::create(&m_mockCCInputHan
dlerClient); | 126 m_inputHandler = WebCompositorInputHandlerImpl::create(&m_mockCCInputHan
dlerClient); |
| 123 m_inputHandler->setClient(&m_mockClient); | 127 m_inputHandler->setClient(&m_mockClient); |
| 124 } | 128 } |
| 125 | 129 |
| 126 ~WebCompositorInputHandlerImplTest() | 130 ~WebCompositorInputHandlerImplTest() |
| 127 { | 131 { |
| 128 m_inputHandler->setClient(0); | 132 m_inputHandler->setClient(0); |
| 129 m_inputHandler.clear(); | 133 m_inputHandler.clear(); |
| 130 WebKit::WebCompositor::shutdown(); | 134 WebCompositor::shutdown(); |
| 131 } | 135 } |
| 132 | 136 |
| 133 void verifyAndResetMocks() | 137 // This is defined as a macro because when an expectation is not satisfied t
he only output you get |
| 134 { | 138 // out of gmock is the line number that set the expectation. |
| 135 testing::Mock::VerifyAndClearExpectations(&m_mockCCInputHandlerClient); | 139 #define VERIFY_AND_RESET_MOCKS() do
\ |
| 136 testing::Mock::VerifyAndClearExpectations(&m_mockClient); | 140 {
\ |
| 137 switch (m_expectedDisposition) { | 141 testing::Mock::VerifyAndClearExpectations(&m_mockCCInputHandlerClient);
\ |
| 138 case DidHandle: | 142 testing::Mock::VerifyAndClearExpectations(&m_mockClient);
\ |
| 139 // If we expect to handle events, we shouldn't get any didNotHandleI
nputEvent() calls with any parameter. | 143 switch (m_expectedDisposition) {
\ |
| 140 EXPECT_CALL(m_mockClient, didNotHandleInputEvent(::testing::_)).Time
s(0); | 144 case DidHandle:
\ |
| 141 EXPECT_CALL(m_mockClient, didHandleInputEvent()); | 145 /* If we expect to handle events, we shouldn't get any didNotHandleI
nputEvent() calls with any parameter. */ \ |
| 142 break; | 146 EXPECT_CALL(m_mockClient, didNotHandleInputEvent(::testing::_)).Time
s(0); \ |
| 143 case DidNotHandle: | 147 EXPECT_CALL(m_mockClient, didHandleInputEvent());
\ |
| 144 // If we aren't expecting to handle events, we shouldn't call didHan
dleInputEvent(). | 148 break;
\ |
| 145 EXPECT_CALL(m_mockClient, didHandleInputEvent()).Times(0); | 149 case DidNotHandle:
\ |
| 146 EXPECT_CALL(m_mockClient, didNotHandleInputEvent(false)).Times(0); | 150 /* If we aren't expecting to handle events, we shouldn't call didHan
dleInputEvent(). */ \ |
| 147 EXPECT_CALL(m_mockClient, didNotHandleInputEvent(true)); | 151 EXPECT_CALL(m_mockClient, didHandleInputEvent()).Times(0);
\ |
| 148 break; | 152 EXPECT_CALL(m_mockClient, didNotHandleInputEvent(false)).Times(0);
\ |
| 149 case DropEvent: | 153 EXPECT_CALL(m_mockClient, didNotHandleInputEvent(true));
\ |
| 150 // If we're expecting to drop, we shouldn't get any didHandle..() or
didNotHandleInputEvent(true /* sendToWidget */) calls. | 154 break;
\ |
| 151 EXPECT_CALL(m_mockClient, didHandleInputEvent()).Times(0); | 155 case DropEvent:
\ |
| 152 EXPECT_CALL(m_mockClient, didNotHandleInputEvent(true)).Times(0); | 156 /* If we're expecting to drop, we shouldn't get any didHandle..() or
didNotHandleInputEvent(true) calls. */ \ |
| 153 EXPECT_CALL(m_mockClient, didNotHandleInputEvent(false)); | 157 EXPECT_CALL(m_mockClient, didHandleInputEvent()).Times(0);
\ |
| 154 break; | 158 EXPECT_CALL(m_mockClient, didNotHandleInputEvent(true)).Times(0);
\ |
| 155 } | 159 EXPECT_CALL(m_mockClient, didNotHandleInputEvent(false));
\ |
| 156 } | 160 break;
\ |
| 161 }
\ |
| 162 } while (0) |
| 157 | 163 |
| 158 protected: | 164 protected: |
| 159 MockCCInputHandlerClient m_mockCCInputHandlerClient; | 165 MockCCInputHandlerClient m_mockCCInputHandlerClient; |
| 160 OwnPtr<WebCompositorInputHandlerImpl> m_inputHandler; | 166 OwnPtr<WebCompositorInputHandlerImpl> m_inputHandler; |
| 161 MockWebCompositorInputHandlerClient m_mockClient; | 167 MockWebCompositorInputHandlerClient m_mockClient; |
| 162 WebKit::WebGestureEvent gesture; | 168 WebGestureEvent gesture; |
| 163 | 169 |
| 164 enum ExpectedDisposition { DidHandle, DidNotHandle, DropEvent }; | 170 enum ExpectedDisposition { DidHandle, DidNotHandle, DropEvent }; |
| 165 ExpectedDisposition m_expectedDisposition; | 171 ExpectedDisposition m_expectedDisposition; |
| 166 | 172 |
| 167 private: | 173 private: |
| 168 WebCore::DebugScopedSetImplThread m_alwaysImplThread; | 174 WebCore::DebugScopedSetImplThread m_alwaysImplThread; |
| 169 }; | 175 }; |
| 170 | 176 |
| 171 | 177 |
| 172 TEST_F(WebCompositorInputHandlerImplTest, gestureScrollStarted) | 178 TEST_F(WebCompositorInputHandlerImplTest, gestureScrollStarted) |
| 173 { | 179 { |
| 174 // We shouldn't send any events to the widget for this gesture. | 180 // We shouldn't send any events to the widget for this gesture. |
| 175 m_expectedDisposition = DidHandle; | 181 m_expectedDisposition = DidHandle; |
| 176 verifyAndResetMocks(); | 182 VERIFY_AND_RESET_MOCKS(); |
| 177 | 183 |
| 178 EXPECT_CALL(m_mockCCInputHandlerClient, scrollBegin(testing::_, testing::_)) | 184 EXPECT_CALL(m_mockCCInputHandlerClient, scrollBegin(testing::_, testing::_)) |
| 179 .WillOnce(testing::Return(WebCore::CCInputHandlerClient::ScrollStarted))
; | 185 .WillOnce(testing::Return(WebCore::CCInputHandlerClient::ScrollStarted))
; |
| 180 | 186 |
| 181 gesture.type = WebKit::WebInputEvent::GestureScrollBegin; | 187 gesture.type = WebInputEvent::GestureScrollBegin; |
| 182 m_inputHandler->handleInputEvent(gesture); | 188 m_inputHandler->handleInputEvent(gesture); |
| 183 | 189 |
| 184 verifyAndResetMocks(); | 190 VERIFY_AND_RESET_MOCKS(); |
| 185 | 191 |
| 186 gesture.type = WebKit::WebInputEvent::GestureScrollUpdate; | 192 gesture.type = WebInputEvent::GestureScrollUpdate; |
| 187 gesture.deltaY = -40; // -Y means scroll down - i.e. in the +Y direction. | 193 gesture.deltaY = -40; // -Y means scroll down - i.e. in the +Y direction. |
| 188 EXPECT_CALL(m_mockCCInputHandlerClient, scrollBy(testing::Property(&WebCore:
:IntSize::height, testing::Gt(0)))); | 194 EXPECT_CALL(m_mockCCInputHandlerClient, scrollBy(testing::Property(&WebCore:
:IntSize::height, testing::Gt(0)))); |
| 189 m_inputHandler->handleInputEvent(gesture); | 195 m_inputHandler->handleInputEvent(gesture); |
| 190 | 196 |
| 191 verifyAndResetMocks(); | 197 VERIFY_AND_RESET_MOCKS(); |
| 192 | 198 |
| 193 gesture.type = WebKit::WebInputEvent::GestureScrollEnd; | 199 gesture.type = WebInputEvent::GestureScrollEnd; |
| 194 gesture.deltaY = 0; | 200 gesture.deltaY = 0; |
| 195 EXPECT_CALL(m_mockCCInputHandlerClient, scrollEnd()); | 201 EXPECT_CALL(m_mockCCInputHandlerClient, scrollEnd()); |
| 196 m_inputHandler->handleInputEvent(gesture); | 202 m_inputHandler->handleInputEvent(gesture); |
| 197 } | 203 } |
| 198 | 204 |
| 199 TEST_F(WebCompositorInputHandlerImplTest, gestureScrollFailed) | 205 TEST_F(WebCompositorInputHandlerImplTest, gestureScrollFailed) |
| 200 { | 206 { |
| 201 // We should send all events to the widget for this gesture. | 207 // We should send all events to the widget for this gesture. |
| 202 m_expectedDisposition = DidNotHandle; | 208 m_expectedDisposition = DidNotHandle; |
| 203 verifyAndResetMocks(); | 209 VERIFY_AND_RESET_MOCKS(); |
| 204 | 210 |
| 205 EXPECT_CALL(m_mockCCInputHandlerClient, scrollBegin(::testing::_, ::testing:
:_)) | 211 EXPECT_CALL(m_mockCCInputHandlerClient, scrollBegin(::testing::_, ::testing:
:_)) |
| 206 .WillOnce(testing::Return(WebCore::CCInputHandlerClient::ScrollFailed)); | 212 .WillOnce(testing::Return(WebCore::CCInputHandlerClient::ScrollFailed)); |
| 207 | 213 |
| 208 gesture.type = WebKit::WebInputEvent::GestureScrollBegin; | 214 gesture.type = WebInputEvent::GestureScrollBegin; |
| 209 m_inputHandler->handleInputEvent(gesture); | 215 m_inputHandler->handleInputEvent(gesture); |
| 210 | 216 |
| 211 verifyAndResetMocks(); | 217 VERIFY_AND_RESET_MOCKS(); |
| 212 | 218 |
| 213 gesture.type = WebKit::WebInputEvent::GestureScrollUpdate; | 219 gesture.type = WebInputEvent::GestureScrollUpdate; |
| 214 gesture.deltaY = 40; | 220 gesture.deltaY = 40; |
| 215 m_inputHandler->handleInputEvent(gesture); | 221 m_inputHandler->handleInputEvent(gesture); |
| 216 | 222 |
| 217 verifyAndResetMocks(); | 223 VERIFY_AND_RESET_MOCKS(); |
| 218 | 224 |
| 219 gesture.type = WebKit::WebInputEvent::GestureScrollEnd; | 225 gesture.type = WebInputEvent::GestureScrollEnd; |
| 220 gesture.deltaY = 0; | 226 gesture.deltaY = 0; |
| 221 m_inputHandler->handleInputEvent(gesture); | 227 m_inputHandler->handleInputEvent(gesture); |
| 222 } | 228 } |
| 223 | 229 |
| 224 TEST_F(WebCompositorInputHandlerImplTest, gestureScrollIgnored) | 230 TEST_F(WebCompositorInputHandlerImplTest, gestureScrollIgnored) |
| 225 { | 231 { |
| 226 // We shouldn't handle the GestureScrollBegin. | 232 // We shouldn't handle the GestureScrollBegin. |
| 227 // Instead, we should get one didNotHandleInputEvent(false) call per handleI
nputEvent(), | 233 // Instead, we should get one didNotHandleInputEvent(false) call per handleI
nputEvent(), |
| 228 // indicating that we could determine that there's nothing that could scroll
or otherwise | 234 // indicating that we could determine that there's nothing that could scroll
or otherwise |
| 229 // react to this gesture sequence and thus we should drop the whole gesture
sequence on the floor. | 235 // react to this gesture sequence and thus we should drop the whole gesture
sequence on the floor. |
| 230 m_expectedDisposition = DropEvent; | 236 m_expectedDisposition = DropEvent; |
| 231 verifyAndResetMocks(); | 237 VERIFY_AND_RESET_MOCKS(); |
| 232 | 238 |
| 233 EXPECT_CALL(m_mockCCInputHandlerClient, scrollBegin(testing::_, testing::_)) | 239 EXPECT_CALL(m_mockCCInputHandlerClient, scrollBegin(testing::_, testing::_)) |
| 234 .WillOnce(testing::Return(WebCore::CCInputHandlerClient::ScrollIgnored))
; | 240 .WillOnce(testing::Return(WebCore::CCInputHandlerClient::ScrollIgnored))
; |
| 235 | 241 |
| 236 gesture.type = WebKit::WebInputEvent::GestureScrollBegin; | 242 gesture.type = WebInputEvent::GestureScrollBegin; |
| 237 m_inputHandler->handleInputEvent(gesture); | 243 m_inputHandler->handleInputEvent(gesture); |
| 238 } | 244 } |
| 239 | 245 |
| 240 TEST_F(WebCompositorInputHandlerImplTest, gesturePinch) | 246 TEST_F(WebCompositorInputHandlerImplTest, gesturePinch) |
| 241 { | 247 { |
| 242 // We shouldn't send any events to the widget for this gesture. | 248 // We shouldn't send any events to the widget for this gesture. |
| 243 m_expectedDisposition = DidHandle; | 249 m_expectedDisposition = DidHandle; |
| 244 verifyAndResetMocks(); | 250 VERIFY_AND_RESET_MOCKS(); |
| 245 | 251 |
| 246 gesture.type = WebKit::WebInputEvent::GesturePinchBegin; | 252 gesture.type = WebInputEvent::GesturePinchBegin; |
| 247 EXPECT_CALL(m_mockCCInputHandlerClient, pinchGestureBegin()); | 253 EXPECT_CALL(m_mockCCInputHandlerClient, pinchGestureBegin()); |
| 248 m_inputHandler->handleInputEvent(gesture); | 254 m_inputHandler->handleInputEvent(gesture); |
| 249 | 255 |
| 250 verifyAndResetMocks(); | 256 VERIFY_AND_RESET_MOCKS(); |
| 251 | 257 |
| 252 gesture.type = WebKit::WebInputEvent::GesturePinchUpdate; | 258 gesture.type = WebInputEvent::GesturePinchUpdate; |
| 253 gesture.deltaX = 1.5; | 259 gesture.deltaX = 1.5; |
| 254 gesture.x = 7; | 260 gesture.x = 7; |
| 255 gesture.y = 13; | 261 gesture.y = 13; |
| 256 EXPECT_CALL(m_mockCCInputHandlerClient, pinchGestureUpdate(1.5, WebCore::Int
Point(7, 13))); | 262 EXPECT_CALL(m_mockCCInputHandlerClient, pinchGestureUpdate(1.5, WebCore::Int
Point(7, 13))); |
| 257 m_inputHandler->handleInputEvent(gesture); | 263 m_inputHandler->handleInputEvent(gesture); |
| 258 | 264 |
| 259 verifyAndResetMocks(); | 265 VERIFY_AND_RESET_MOCKS(); |
| 260 | 266 |
| 261 gesture.type = WebKit::WebInputEvent::GesturePinchUpdate; | 267 gesture.type = WebInputEvent::GesturePinchUpdate; |
| 262 gesture.deltaX = 0.5; | 268 gesture.deltaX = 0.5; |
| 263 gesture.x = 9; | 269 gesture.x = 9; |
| 264 gesture.y = 6; | 270 gesture.y = 6; |
| 265 EXPECT_CALL(m_mockCCInputHandlerClient, pinchGestureUpdate(.5, WebCore::IntP
oint(9, 6))); | 271 EXPECT_CALL(m_mockCCInputHandlerClient, pinchGestureUpdate(.5, WebCore::IntP
oint(9, 6))); |
| 266 m_inputHandler->handleInputEvent(gesture); | 272 m_inputHandler->handleInputEvent(gesture); |
| 267 | 273 |
| 268 verifyAndResetMocks(); | 274 VERIFY_AND_RESET_MOCKS(); |
| 269 | 275 |
| 270 gesture.type = WebKit::WebInputEvent::GesturePinchEnd; | 276 gesture.type = WebInputEvent::GesturePinchEnd; |
| 271 EXPECT_CALL(m_mockCCInputHandlerClient, pinchGestureEnd()); | 277 EXPECT_CALL(m_mockCCInputHandlerClient, pinchGestureEnd()); |
| 272 m_inputHandler->handleInputEvent(gesture); | 278 m_inputHandler->handleInputEvent(gesture); |
| 273 } | 279 } |
| 274 | 280 |
| 275 TEST_F(WebCompositorInputHandlerImplTest, gestureFlingStarted) | 281 TEST_F(WebCompositorInputHandlerImplTest, gestureFlingStarted) |
| 276 { | 282 { |
| 277 // We shouldn't send any events to the widget for this gesture. | 283 // We shouldn't send any events to the widget for this gesture. |
| 278 m_expectedDisposition = DidHandle; | 284 m_expectedDisposition = DidHandle; |
| 279 verifyAndResetMocks(); | 285 VERIFY_AND_RESET_MOCKS(); |
| 280 | 286 |
| 281 EXPECT_CALL(m_mockCCInputHandlerClient, scrollBegin(testing::_, testing::_)) | 287 EXPECT_CALL(m_mockCCInputHandlerClient, scrollBegin(testing::_, testing::_)) |
| 282 .WillOnce(testing::Return(WebCore::CCInputHandlerClient::ScrollStarted))
; | 288 .WillOnce(testing::Return(WebCore::CCInputHandlerClient::ScrollStarted))
; |
| 283 | 289 |
| 284 gesture.type = WebKit::WebInputEvent::GestureFlingStart; | 290 gesture.type = WebInputEvent::GestureFlingStart; |
| 285 gesture.deltaX = 10; | 291 gesture.deltaX = 10; |
| 286 EXPECT_CALL(m_mockCCInputHandlerClient, scheduleAnimation()); | 292 EXPECT_CALL(m_mockCCInputHandlerClient, scheduleAnimation()); |
| 287 m_inputHandler->handleInputEvent(gesture); | 293 m_inputHandler->handleInputEvent(gesture); |
| 288 | 294 |
| 289 verifyAndResetMocks(); | 295 VERIFY_AND_RESET_MOCKS(); |
| 290 | 296 |
| 291 // Verify that a GestureFlingCancel during an animation cancels it. | 297 // Verify that a GestureFlingCancel during an animation cancels it. |
| 292 gesture.type = WebKit::WebInputEvent::GestureFlingCancel; | 298 gesture.type = WebInputEvent::GestureFlingCancel; |
| 293 m_inputHandler->handleInputEvent(gesture); | 299 m_inputHandler->handleInputEvent(gesture); |
| 294 } | 300 } |
| 295 | 301 |
| 296 TEST_F(WebCompositorInputHandlerImplTest, gestureFlingFailed) | 302 TEST_F(WebCompositorInputHandlerImplTest, gestureFlingFailed) |
| 297 { | 303 { |
| 298 // We should send all events to the widget for this gesture. | 304 // We should send all events to the widget for this gesture. |
| 299 m_expectedDisposition = DidNotHandle; | 305 m_expectedDisposition = DidNotHandle; |
| 300 verifyAndResetMocks(); | 306 VERIFY_AND_RESET_MOCKS(); |
| 301 | 307 |
| 302 EXPECT_CALL(m_mockCCInputHandlerClient, scrollBegin(testing::_, testing::_)) | 308 EXPECT_CALL(m_mockCCInputHandlerClient, scrollBegin(testing::_, testing::_)) |
| 303 .WillOnce(testing::Return(WebCore::CCInputHandlerClient::ScrollFailed)); | 309 .WillOnce(testing::Return(WebCore::CCInputHandlerClient::ScrollFailed)); |
| 304 | 310 |
| 305 gesture.type = WebKit::WebInputEvent::GestureFlingStart; | 311 gesture.type = WebInputEvent::GestureFlingStart; |
| 306 m_inputHandler->handleInputEvent(gesture); | 312 m_inputHandler->handleInputEvent(gesture); |
| 307 | 313 |
| 308 verifyAndResetMocks(); | 314 VERIFY_AND_RESET_MOCKS(); |
| 309 | 315 |
| 310 // Even if we didn't start a fling ourselves, we still need to send the canc
el event to the widget. | 316 // Even if we didn't start a fling ourselves, we still need to send the canc
el event to the widget. |
| 311 gesture.type = WebKit::WebInputEvent::GestureFlingCancel; | 317 gesture.type = WebInputEvent::GestureFlingCancel; |
| 312 m_inputHandler->handleInputEvent(gesture); | 318 m_inputHandler->handleInputEvent(gesture); |
| 313 } | 319 } |
| 314 | 320 |
| 315 TEST_F(WebCompositorInputHandlerImplTest, gestureFlingIgnored) | 321 TEST_F(WebCompositorInputHandlerImplTest, gestureFlingIgnored) |
| 316 { | 322 { |
| 317 m_expectedDisposition = DidNotHandle; | 323 m_expectedDisposition = DidNotHandle; |
| 318 verifyAndResetMocks(); | 324 VERIFY_AND_RESET_MOCKS(); |
| 319 | 325 |
| 320 EXPECT_CALL(m_mockCCInputHandlerClient, scrollBegin(testing::_, testing::_)) | 326 EXPECT_CALL(m_mockCCInputHandlerClient, scrollBegin(testing::_, testing::_)) |
| 321 .WillOnce(testing::Return(WebCore::CCInputHandlerClient::ScrollIgnored))
; | 327 .WillOnce(testing::Return(WebCore::CCInputHandlerClient::ScrollIgnored))
; |
| 322 | 328 |
| 323 gesture.type = WebKit::WebInputEvent::GestureFlingStart; | 329 gesture.type = WebInputEvent::GestureFlingStart; |
| 324 m_inputHandler->handleInputEvent(gesture); | 330 m_inputHandler->handleInputEvent(gesture); |
| 325 | 331 |
| 326 verifyAndResetMocks(); | 332 VERIFY_AND_RESET_MOCKS(); |
| 327 | 333 |
| 328 // Even if we didn't start a fling ourselves, we still need to send the canc
el event to the widget. | 334 // Even if we didn't start a fling ourselves, we still need to send the canc
el event to the widget. |
| 329 gesture.type = WebKit::WebInputEvent::GestureFlingCancel; | 335 gesture.type = WebInputEvent::GestureFlingCancel; |
| 330 m_inputHandler->handleInputEvent(gesture); | 336 m_inputHandler->handleInputEvent(gesture); |
| 331 } | 337 } |
| 332 | 338 |
| 333 TEST_F(WebCompositorInputHandlerImplTest, gestureFlingAnimates) | 339 TEST_F(WebCompositorInputHandlerImplTest, gestureFlingAnimates) |
| 334 { | 340 { |
| 335 // We shouldn't send any events to the widget for this gesture. | 341 // We shouldn't send any events to the widget for this gesture. |
| 336 m_expectedDisposition = DidHandle; | 342 m_expectedDisposition = DidHandle; |
| 337 verifyAndResetMocks(); | 343 VERIFY_AND_RESET_MOCKS(); |
| 338 | 344 |
| 339 // On the fling start, we should schedule an animation but not actually star
t | 345 // On the fling start, we should schedule an animation but not actually star
t |
| 340 // scrolling. | 346 // scrolling. |
| 341 gesture.type = WebKit::WebInputEvent::GestureFlingStart; | 347 gesture.type = WebInputEvent::GestureFlingStart; |
| 342 gesture.deltaX = -1000; | 348 WebFloatPoint flingDelta = WebFloatPoint(1000, 0); |
| 349 WebPoint flingPoint = WebPoint(7, 13); |
| 350 WebPoint flingGlobalPoint = WebPoint(17, 23); |
| 351 int modifiers = 7; |
| 352 gesture.deltaX = flingDelta.x; |
| 353 gesture.deltaY = flingDelta.y; |
| 354 gesture.x = flingPoint.x; |
| 355 gesture.y = flingPoint.y; |
| 356 gesture.globalX = flingGlobalPoint.x; |
| 357 gesture.globalY = flingGlobalPoint.y; |
| 358 gesture.modifiers = modifiers; |
| 343 EXPECT_CALL(m_mockCCInputHandlerClient, scheduleAnimation()); | 359 EXPECT_CALL(m_mockCCInputHandlerClient, scheduleAnimation()); |
| 344 EXPECT_CALL(m_mockCCInputHandlerClient, scrollBegin(testing::_, testing::_)) | 360 EXPECT_CALL(m_mockCCInputHandlerClient, scrollBegin(testing::_, testing::_)) |
| 345 .WillOnce(testing::Return(WebCore::CCInputHandlerClient::ScrollStarted))
; | 361 .WillOnce(testing::Return(WebCore::CCInputHandlerClient::ScrollStarted))
; |
| 346 m_inputHandler->handleInputEvent(gesture); | 362 m_inputHandler->handleInputEvent(gesture); |
| 347 | 363 |
| 348 testing::Mock::VerifyAndClearExpectations(&m_mockCCInputHandlerClient); | 364 testing::Mock::VerifyAndClearExpectations(&m_mockCCInputHandlerClient); |
| 349 // The first animate call should let us pick up an animation start time, but
we | 365 // The first animate call should let us pick up an animation start time, but
we |
| 350 // shouldn't actually move anywhere just yet. The first frame after the flin
g start | 366 // shouldn't actually move anywhere just yet. The first frame after the flin
g start |
| 351 // will typically include the last scroll from the gesture that lead to the
scroll | 367 // will typically include the last scroll from the gesture that lead to the
scroll |
| 352 // (either wheel or gesture scroll), so there should be no visible hitch. | 368 // (either wheel or gesture scroll), so there should be no visible hitch. |
| 353 EXPECT_CALL(m_mockCCInputHandlerClient, scheduleAnimation()); | 369 EXPECT_CALL(m_mockCCInputHandlerClient, scheduleAnimation()); |
| 354 EXPECT_CALL(m_mockCCInputHandlerClient, scrollBegin(testing::_, testing::_))
.Times(0); | 370 EXPECT_CALL(m_mockCCInputHandlerClient, scrollBegin(testing::_, testing::_))
.Times(0); |
| 355 m_inputHandler->animate(10); | 371 m_inputHandler->animate(10); |
| 356 | 372 |
| 357 testing::Mock::VerifyAndClearExpectations(&m_mockCCInputHandlerClient); | 373 testing::Mock::VerifyAndClearExpectations(&m_mockCCInputHandlerClient); |
| 358 | 374 |
| 359 // The second call should start scrolling in the +X direction. | 375 // The second call should start scrolling in the -X direction. |
| 360 EXPECT_CALL(m_mockCCInputHandlerClient, scheduleAnimation()); | 376 EXPECT_CALL(m_mockCCInputHandlerClient, scheduleAnimation()); |
| 361 EXPECT_CALL(m_mockCCInputHandlerClient, scrollBegin(testing::_, testing::_)) | 377 EXPECT_CALL(m_mockCCInputHandlerClient, scrollBegin(testing::_, testing::_)) |
| 362 .WillOnce(testing::Return(WebCore::CCInputHandlerClient::ScrollStarted))
; | 378 .WillOnce(testing::Return(WebCore::CCInputHandlerClient::ScrollStarted))
; |
| 363 EXPECT_CALL(m_mockCCInputHandlerClient, scrollBy(testing::Property(&WebCore:
:IntSize::width, testing::Gt(0)))); | 379 EXPECT_CALL(m_mockCCInputHandlerClient, scrollBy(testing::Property(&WebCore:
:IntSize::width, testing::Lt(0)))); |
| 364 EXPECT_CALL(m_mockCCInputHandlerClient, scrollEnd()); | 380 EXPECT_CALL(m_mockCCInputHandlerClient, scrollEnd()); |
| 365 m_inputHandler->animate(10.1); | 381 m_inputHandler->animate(10.1); |
| 366 | 382 |
| 367 testing::Mock::VerifyAndClearExpectations(&m_mockCCInputHandlerClient); | 383 testing::Mock::VerifyAndClearExpectations(&m_mockCCInputHandlerClient); |
| 368 | 384 |
| 369 // Let's say on the third call we hit a non-scrollable region. We should abo
rt the fling and not scroll. | 385 // Let's say on the third call we hit a non-scrollable region. We should abo
rt the fling and not scroll. |
| 370 // FIXME: We also need to do some work to transfer the rest of this fling to
the main thread. | 386 // We also should pass the current fling parameters out to the client so the
rest of the fling can be |
| 371 // Add tests for this once it's implemented. | 387 // transferred to the main thread. |
| 372 EXPECT_CALL(m_mockCCInputHandlerClient, scheduleAnimation()); | 388 EXPECT_CALL(m_mockCCInputHandlerClient, scheduleAnimation()); |
| 373 EXPECT_CALL(m_mockCCInputHandlerClient, scrollBegin(testing::_, testing::_)) | 389 EXPECT_CALL(m_mockCCInputHandlerClient, scrollBegin(testing::_, testing::_)) |
| 374 .WillOnce(testing::Return(WebCore::CCInputHandlerClient::ScrollFailed)); | 390 .WillOnce(testing::Return(WebCore::CCInputHandlerClient::ScrollFailed)); |
| 375 EXPECT_CALL(m_mockCCInputHandlerClient, scrollBy(testing::_)).Times(0); | 391 EXPECT_CALL(m_mockCCInputHandlerClient, scrollBy(testing::_)).Times(0); |
| 376 EXPECT_CALL(m_mockCCInputHandlerClient, scrollEnd()).Times(0); | 392 EXPECT_CALL(m_mockCCInputHandlerClient, scrollEnd()).Times(0); |
| 393 |
| 394 // Expected wheel fling animation parameters: |
| 395 // *) flingDelta and flingPoint should match the original GestureFlingStart
event |
| 396 // *) startTime should be 10 to match the time parameter of the first animat
e() call after the GestureFlingStart |
| 397 // *) cumulativeScroll depends on the curve, but since we've animated in the
-X direction the X value should be < 0 |
| 398 EXPECT_CALL(m_mockClient, transferActiveWheelFlingAnimation(testing::AllOf( |
| 399 testing::Field(&WebActiveWheelFlingParameters::delta, testing::Eq(flingD
elta)), |
| 400 testing::Field(&WebActiveWheelFlingParameters::point, testing::Eq(flingP
oint)), |
| 401 testing::Field(&WebActiveWheelFlingParameters::globalPoint, testing::Eq(
flingGlobalPoint)), |
| 402 testing::Field(&WebActiveWheelFlingParameters::modifiers, testing::Eq(mo
difiers)), |
| 403 testing::Field(&WebActiveWheelFlingParameters::startTime, testing::Eq(10
)), |
| 404 testing::Field(&WebActiveWheelFlingParameters::cumulativeScroll, |
| 405 testing::Field(&WebSize::width, testing::Gt(0)))))); |
| 377 m_inputHandler->animate(10.2); | 406 m_inputHandler->animate(10.2); |
| 378 | 407 |
| 379 testing::Mock::VerifyAndClearExpectations(&m_mockCCInputHandlerClient); | 408 testing::Mock::VerifyAndClearExpectations(&m_mockCCInputHandlerClient); |
| 409 testing::Mock::VerifyAndClearExpectations(&m_mockClient); |
| 380 | 410 |
| 381 // Since we've aborted the fling, the next animation should be a no-op and s
hould not result in another | 411 // Since we've aborted the fling, the next animation should be a no-op and s
hould not result in another |
| 382 // frame being requested. | 412 // frame being requested. |
| 383 EXPECT_CALL(m_mockCCInputHandlerClient, scheduleAnimation()).Times(0); | 413 EXPECT_CALL(m_mockCCInputHandlerClient, scheduleAnimation()).Times(0); |
| 384 EXPECT_CALL(m_mockCCInputHandlerClient, scrollBegin(testing::_, testing::_))
.Times(0); | 414 EXPECT_CALL(m_mockCCInputHandlerClient, scrollBegin(testing::_, testing::_))
.Times(0); |
| 385 m_inputHandler->animate(10.3); | 415 m_inputHandler->animate(10.3); |
| 416 |
| 417 // Since we've transferred the fling to the main thread, we need to pass the
next GestureFlingCancel to the main |
| 418 // thread as well. |
| 419 EXPECT_CALL(m_mockClient, didNotHandleInputEvent(true)); |
| 420 gesture.type = WebInputEvent::GestureFlingCancel; |
| 421 m_inputHandler->handleInputEvent(gesture); |
| 422 } |
| 423 |
| 424 TEST_F(WebCompositorInputHandlerImplTest, gestureFlingTransferResets) |
| 425 { |
| 426 // We shouldn't send any events to the widget for this gesture. |
| 427 m_expectedDisposition = DidHandle; |
| 428 VERIFY_AND_RESET_MOCKS(); |
| 429 |
| 430 // Start a gesture fling in the -X direction with zero Y movement. |
| 431 gesture.type = WebInputEvent::GestureFlingStart; |
| 432 WebFloatPoint flingDelta = WebFloatPoint(1000, 0); |
| 433 WebPoint flingPoint = WebPoint(7, 13); |
| 434 WebPoint flingGlobalPoint = WebPoint(17, 23); |
| 435 int modifiers = 1; |
| 436 gesture.deltaX = flingDelta.x; |
| 437 gesture.deltaY = flingDelta.y; |
| 438 gesture.x = flingPoint.x; |
| 439 gesture.y = flingPoint.y; |
| 440 gesture.globalX = flingGlobalPoint.x; |
| 441 gesture.globalY = flingGlobalPoint.y; |
| 442 gesture.modifiers = modifiers; |
| 443 EXPECT_CALL(m_mockCCInputHandlerClient, scheduleAnimation()); |
| 444 EXPECT_CALL(m_mockCCInputHandlerClient, scrollBegin(testing::_, testing::_)) |
| 445 .WillOnce(testing::Return(WebCore::CCInputHandlerClient::ScrollStarted))
; |
| 446 m_inputHandler->handleInputEvent(gesture); |
| 447 |
| 448 testing::Mock::VerifyAndClearExpectations(&m_mockCCInputHandlerClient); |
| 449 |
| 450 // Start the fling animation at time 10. This shouldn't actually scroll, jus
t establish a start time. |
| 451 EXPECT_CALL(m_mockCCInputHandlerClient, scheduleAnimation()); |
| 452 EXPECT_CALL(m_mockCCInputHandlerClient, scrollBegin(testing::_, testing::_))
.Times(0); |
| 453 m_inputHandler->animate(10); |
| 454 |
| 455 testing::Mock::VerifyAndClearExpectations(&m_mockCCInputHandlerClient); |
| 456 |
| 457 // The second call should start scrolling in the -X direction. |
| 458 EXPECT_CALL(m_mockCCInputHandlerClient, scheduleAnimation()); |
| 459 EXPECT_CALL(m_mockCCInputHandlerClient, scrollBegin(testing::_, testing::_)) |
| 460 .WillOnce(testing::Return(WebCore::CCInputHandlerClient::ScrollStarted))
; |
| 461 EXPECT_CALL(m_mockCCInputHandlerClient, scrollBy(testing::Property(&WebCore:
:IntSize::width, testing::Lt(0)))); |
| 462 EXPECT_CALL(m_mockCCInputHandlerClient, scrollEnd()); |
| 463 m_inputHandler->animate(10.1); |
| 464 |
| 465 testing::Mock::VerifyAndClearExpectations(&m_mockCCInputHandlerClient); |
| 466 |
| 467 // Let's say on the third call we hit a non-scrollable region. We should abo
rt the fling and not scroll. |
| 468 // We also should pass the current fling parameters out to the client so the
rest of the fling can be |
| 469 // transferred to the main thread. |
| 470 EXPECT_CALL(m_mockCCInputHandlerClient, scheduleAnimation()); |
| 471 EXPECT_CALL(m_mockCCInputHandlerClient, scrollBegin(testing::_, testing::_)) |
| 472 .WillOnce(testing::Return(WebCore::CCInputHandlerClient::ScrollFailed)); |
| 473 EXPECT_CALL(m_mockCCInputHandlerClient, scrollBy(testing::_)).Times(0); |
| 474 EXPECT_CALL(m_mockCCInputHandlerClient, scrollEnd()).Times(0); |
| 475 |
| 476 // Expected wheel fling animation parameters: |
| 477 // *) flingDelta and flingPoint should match the original GestureFlingStart
event |
| 478 // *) startTime should be 10 to match the time parameter of the first animat
e() call after the GestureFlingStart |
| 479 // *) cumulativeScroll depends on the curve, but since we've animated in the
-X direction the X value should be < 0 |
| 480 EXPECT_CALL(m_mockClient, transferActiveWheelFlingAnimation(testing::AllOf( |
| 481 testing::Field(&WebActiveWheelFlingParameters::delta, testing::Eq(flingD
elta)), |
| 482 testing::Field(&WebActiveWheelFlingParameters::point, testing::Eq(flingP
oint)), |
| 483 testing::Field(&WebActiveWheelFlingParameters::globalPoint, testing::Eq(
flingGlobalPoint)), |
| 484 testing::Field(&WebActiveWheelFlingParameters::modifiers, testing::Eq(mo
difiers)), |
| 485 testing::Field(&WebActiveWheelFlingParameters::startTime, testing::Eq(10
)), |
| 486 testing::Field(&WebActiveWheelFlingParameters::cumulativeScroll, |
| 487 testing::Field(&WebSize::width, testing::Gt(0)))))); |
| 488 m_inputHandler->animate(10.2); |
| 489 |
| 490 testing::Mock::VerifyAndClearExpectations(&m_mockCCInputHandlerClient); |
| 491 testing::Mock::VerifyAndClearExpectations(&m_mockClient); |
| 492 |
| 493 // Since we've aborted the fling, the next animation should be a no-op and s
hould not result in another |
| 494 // frame being requested. |
| 495 EXPECT_CALL(m_mockCCInputHandlerClient, scheduleAnimation()).Times(0); |
| 496 EXPECT_CALL(m_mockCCInputHandlerClient, scrollBegin(testing::_, testing::_))
.Times(0); |
| 497 m_inputHandler->animate(10.3); |
| 498 |
| 499 testing::Mock::VerifyAndClearExpectations(&m_mockCCInputHandlerClient); |
| 500 |
| 501 // Since we've transferred the fling to the main thread, we need to pass the
next GestureFlingCancel to the main |
| 502 // thread as well. |
| 503 EXPECT_CALL(m_mockClient, didNotHandleInputEvent(true)); |
| 504 gesture.type = WebInputEvent::GestureFlingCancel; |
| 505 m_inputHandler->handleInputEvent(gesture); |
| 506 |
| 507 VERIFY_AND_RESET_MOCKS(); |
| 508 |
| 509 // Start a second gesture fling, this time in the +Y direction with no X. |
| 510 gesture.type = WebInputEvent::GestureFlingStart; |
| 511 flingDelta = WebFloatPoint(0, -1000); |
| 512 flingPoint = WebPoint(95, 87); |
| 513 flingGlobalPoint = WebPoint(32, 71); |
| 514 modifiers = 2; |
| 515 gesture.deltaX = flingDelta.x; |
| 516 gesture.deltaY = flingDelta.y; |
| 517 gesture.x = flingPoint.x; |
| 518 gesture.y = flingPoint.y; |
| 519 gesture.globalX = flingGlobalPoint.x; |
| 520 gesture.globalY = flingGlobalPoint.y; |
| 521 gesture.modifiers = modifiers; |
| 522 EXPECT_CALL(m_mockCCInputHandlerClient, scheduleAnimation()); |
| 523 EXPECT_CALL(m_mockCCInputHandlerClient, scrollBegin(testing::_, testing::_)) |
| 524 .WillOnce(testing::Return(WebCore::CCInputHandlerClient::ScrollStarted))
; |
| 525 m_inputHandler->handleInputEvent(gesture); |
| 526 |
| 527 testing::Mock::VerifyAndClearExpectations(&m_mockCCInputHandlerClient); |
| 528 |
| 529 // Start the second fling animation at time 30. |
| 530 EXPECT_CALL(m_mockCCInputHandlerClient, scheduleAnimation()); |
| 531 EXPECT_CALL(m_mockCCInputHandlerClient, scrollBegin(testing::_, testing::_))
.Times(0); |
| 532 m_inputHandler->animate(30); |
| 533 |
| 534 testing::Mock::VerifyAndClearExpectations(&m_mockCCInputHandlerClient); |
| 535 |
| 536 // Tick the second fling once normally. |
| 537 EXPECT_CALL(m_mockCCInputHandlerClient, scheduleAnimation()); |
| 538 EXPECT_CALL(m_mockCCInputHandlerClient, scrollBegin(testing::_, testing::_)) |
| 539 .WillOnce(testing::Return(WebCore::CCInputHandlerClient::ScrollStarted))
; |
| 540 EXPECT_CALL(m_mockCCInputHandlerClient, scrollBy(testing::Property(&WebCore:
:IntSize::height, testing::Gt(0)))); |
| 541 EXPECT_CALL(m_mockCCInputHandlerClient, scrollEnd()); |
| 542 m_inputHandler->animate(30.1); |
| 543 |
| 544 testing::Mock::VerifyAndClearExpectations(&m_mockCCInputHandlerClient); |
| 545 |
| 546 // Then abort the second fling. |
| 547 EXPECT_CALL(m_mockCCInputHandlerClient, scheduleAnimation()); |
| 548 EXPECT_CALL(m_mockCCInputHandlerClient, scrollBegin(testing::_, testing::_)) |
| 549 .WillOnce(testing::Return(WebCore::CCInputHandlerClient::ScrollFailed)); |
| 550 EXPECT_CALL(m_mockCCInputHandlerClient, scrollBy(testing::_)).Times(0); |
| 551 EXPECT_CALL(m_mockCCInputHandlerClient, scrollEnd()).Times(0); |
| 552 |
| 553 // We should get parameters from the second fling, nothing from the first fl
ing should "leak". |
| 554 EXPECT_CALL(m_mockClient, transferActiveWheelFlingAnimation(testing::AllOf( |
| 555 testing::Field(&WebActiveWheelFlingParameters::delta, testing::Eq(flingD
elta)), |
| 556 testing::Field(&WebActiveWheelFlingParameters::point, testing::Eq(flingP
oint)), |
| 557 testing::Field(&WebActiveWheelFlingParameters::globalPoint, testing::Eq(
flingGlobalPoint)), |
| 558 testing::Field(&WebActiveWheelFlingParameters::modifiers, testing::Eq(mo
difiers)), |
| 559 testing::Field(&WebActiveWheelFlingParameters::startTime, testing::Eq(30
)), |
| 560 testing::Field(&WebActiveWheelFlingParameters::cumulativeScroll, |
| 561 testing::Field(&WebSize::height, testing::Lt(0)))))); |
| 562 m_inputHandler->animate(30.2); |
| 386 } | 563 } |
| 387 | 564 |
| 388 } | 565 } |
| OLD | NEW |