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

Side by Side Diff: content/renderer/input/input_handler_proxy_unittest.cc

Issue 902783003: MouseMove when the mouse is down to signal compositor priority (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix typo plus extra unit test Created 5 years, 10 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/input/input_handler_proxy.h" 5 #include "content/renderer/input/input_handler_proxy.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "cc/base/swap_promise_monitor.h" 9 #include "cc/base/swap_promise_monitor.h"
10 #include "content/common/input/did_overscroll_params.h" 10 #include "content/common/input/did_overscroll_params.h"
(...skipping 12 matching lines...) Expand all
23 using blink::WebFloatSize; 23 using blink::WebFloatSize;
24 using blink::WebGestureDevice; 24 using blink::WebGestureDevice;
25 using blink::WebGestureEvent; 25 using blink::WebGestureEvent;
26 using blink::WebInputEvent; 26 using blink::WebInputEvent;
27 using blink::WebKeyboardEvent; 27 using blink::WebKeyboardEvent;
28 using blink::WebMouseWheelEvent; 28 using blink::WebMouseWheelEvent;
29 using blink::WebPoint; 29 using blink::WebPoint;
30 using blink::WebSize; 30 using blink::WebSize;
31 using blink::WebTouchEvent; 31 using blink::WebTouchEvent;
32 using blink::WebTouchPoint; 32 using blink::WebTouchPoint;
33 using testing::Field;
33 34
34 namespace content { 35 namespace content {
35 namespace { 36 namespace {
36 37
37 double InSecondsF(const base::TimeTicks& time) { 38 double InSecondsF(const base::TimeTicks& time) {
38 return (time - base::TimeTicks()).InSecondsF(); 39 return (time - base::TimeTicks()).InSecondsF();
39 } 40 }
40 41
41 WebGestureEvent CreateFling(base::TimeTicks timestamp, 42 WebGestureEvent CreateFling(base::TimeTicks timestamp,
42 WebGestureDevice source_device, 43 WebGestureDevice source_device,
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 WebGestureDevice deviceSource, 174 WebGestureDevice deviceSource,
174 const WebFloatPoint& velocity, 175 const WebFloatPoint& velocity,
175 const WebSize& cumulative_scroll) override { 176 const WebSize& cumulative_scroll) override {
176 return new FakeWebGestureCurve( 177 return new FakeWebGestureCurve(
177 blink::WebFloatSize(velocity.x, velocity.y), 178 blink::WebFloatSize(velocity.x, velocity.y),
178 blink::WebFloatSize(cumulative_scroll.width, cumulative_scroll.height)); 179 blink::WebFloatSize(cumulative_scroll.width, cumulative_scroll.height));
179 } 180 }
180 181
181 MOCK_METHOD1(DidOverscroll, void(const DidOverscrollParams&)); 182 MOCK_METHOD1(DidOverscroll, void(const DidOverscrollParams&));
182 virtual void DidStopFlinging() override {} 183 virtual void DidStopFlinging() override {}
183 virtual void DidReceiveInputEvent(blink::WebInputEvent::Type) override {} 184 virtual void DidReceiveInputEvent(const blink::WebInputEvent&) override {}
184 virtual void DidAnimateForInput() override {} 185 virtual void DidAnimateForInput() override {}
185 186
186 private: 187 private:
187 DISALLOW_COPY_AND_ASSIGN(MockInputHandlerProxyClient); 188 DISALLOW_COPY_AND_ASSIGN(MockInputHandlerProxyClient);
188 }; 189 };
189 190
190 class MockInputHandlerProxyClientWithDidReceiveInputEvent 191 class MockInputHandlerProxyClientWithDidReceiveInputEvent
191 : public MockInputHandlerProxyClient { 192 : public MockInputHandlerProxyClient {
192 public: 193 public:
193 MockInputHandlerProxyClientWithDidReceiveInputEvent() {} 194 MockInputHandlerProxyClientWithDidReceiveInputEvent() {}
194 virtual ~MockInputHandlerProxyClientWithDidReceiveInputEvent() {} 195 virtual ~MockInputHandlerProxyClientWithDidReceiveInputEvent() {}
195 196
196 MOCK_METHOD1(DidReceiveInputEvent, void(blink::WebInputEvent::Type type)); 197 MOCK_METHOD1(DidReceiveInputEvent, void(const blink::WebInputEvent&));
197 MOCK_METHOD0(DidAnimateForInput, void()); 198 MOCK_METHOD0(DidAnimateForInput, void());
198 199
199 private: 200 private:
200 DISALLOW_COPY_AND_ASSIGN(MockInputHandlerProxyClientWithDidReceiveInputEvent); 201 DISALLOW_COPY_AND_ASSIGN(MockInputHandlerProxyClientWithDidReceiveInputEvent);
201 }; 202 };
202 203
203 WebTouchPoint CreateWebTouchPoint(WebTouchPoint::State state, float x, 204 WebTouchPoint CreateWebTouchPoint(WebTouchPoint::State state, float x,
204 float y) { 205 float y) {
205 WebTouchPoint point; 206 WebTouchPoint point;
206 point.state = state; 207 point.state = state;
(...skipping 1878 matching lines...) Expand 10 before | Expand all | Expand 10 after
2085 testing::StrictMock< 2086 testing::StrictMock<
2086 MockInputHandlerProxyClientWithDidReceiveInputEvent> mock_client; 2087 MockInputHandlerProxyClientWithDidReceiveInputEvent> mock_client;
2087 input_handler_.reset( 2088 input_handler_.reset(
2088 new content::InputHandlerProxy(&mock_input_handler_, &mock_client)); 2089 new content::InputHandlerProxy(&mock_input_handler_, &mock_client));
2089 2090
2090 // Note the type of input event isn't important. 2091 // Note the type of input event isn't important.
2091 WebMouseWheelEvent wheel; 2092 WebMouseWheelEvent wheel;
2092 wheel.type = WebInputEvent::MouseWheel; 2093 wheel.type = WebInputEvent::MouseWheel;
2093 wheel.scrollByPage = true; 2094 wheel.scrollByPage = true;
2094 2095
2095 EXPECT_CALL(mock_client, DidReceiveInputEvent(WebInputEvent::MouseWheel)); 2096 EXPECT_CALL(mock_client,
2097 DidReceiveInputEvent(
2098 Field(&WebInputEvent::type, WebInputEvent::MouseWheel)));
2096 2099
2097 input_handler_->HandleInputEvent(wheel); 2100 input_handler_->HandleInputEvent(wheel);
2098 testing::Mock::VerifyAndClearExpectations(&mock_client); 2101 testing::Mock::VerifyAndClearExpectations(&mock_client);
2099 } 2102 }
2100 2103
2101 TEST_F(InputHandlerProxyTest, DidReceiveInputEvent_ForFling) { 2104 TEST_F(InputHandlerProxyTest, DidReceiveInputEvent_ForFling) {
2102 testing::StrictMock< 2105 testing::StrictMock<
2103 MockInputHandlerProxyClientWithDidReceiveInputEvent> mock_client; 2106 MockInputHandlerProxyClientWithDidReceiveInputEvent> mock_client;
2104 input_handler_.reset( 2107 input_handler_.reset(
2105 new content::InputHandlerProxy(&mock_input_handler_, &mock_client)); 2108 new content::InputHandlerProxy(&mock_input_handler_, &mock_client));
2106 2109
2107 gesture_.type = WebInputEvent::GestureFlingStart; 2110 gesture_.type = WebInputEvent::GestureFlingStart;
2108 WebFloatPoint fling_delta = WebFloatPoint(100, 100); 2111 WebFloatPoint fling_delta = WebFloatPoint(100, 100);
2109 gesture_.data.flingStart.velocityX = fling_delta.x; 2112 gesture_.data.flingStart.velocityX = fling_delta.x;
2110 gesture_.data.flingStart.velocityY = fling_delta.y; 2113 gesture_.data.flingStart.velocityY = fling_delta.y;
2111 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 2114 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate());
2112 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 2115 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
2113 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); 2116 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted));
2114 EXPECT_CALL(mock_input_handler_, ScrollEnd()); 2117 EXPECT_CALL(mock_input_handler_, ScrollEnd());
2115 EXPECT_CALL(mock_client, 2118 EXPECT_CALL(mock_client,
2116 DidReceiveInputEvent(WebInputEvent::GestureFlingStart)); 2119 DidReceiveInputEvent(Field(&WebInputEvent::type,
2120 WebInputEvent::GestureFlingStart)));
2117 EXPECT_EQ(InputHandlerProxy::DID_HANDLE, 2121 EXPECT_EQ(InputHandlerProxy::DID_HANDLE,
2118 input_handler_->HandleInputEvent(gesture_)); 2122 input_handler_->HandleInputEvent(gesture_));
2119 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 2123 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
2120 testing::Mock::VerifyAndClearExpectations(&mock_client); 2124 testing::Mock::VerifyAndClearExpectations(&mock_client);
2121 2125
2122 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 2126 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate());
2123 EXPECT_CALL(mock_client, DidAnimateForInput()); 2127 EXPECT_CALL(mock_client, DidAnimateForInput());
2124 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); 2128 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10);
2125 input_handler_->Animate(time); 2129 input_handler_->Animate(time);
2126 2130
2127 testing::Mock::VerifyAndClearExpectations(&mock_client); 2131 testing::Mock::VerifyAndClearExpectations(&mock_client);
2128 } 2132 }
2129 2133
2130 } // namespace 2134 } // namespace
2131 } // namespace content 2135 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/input/input_handler_proxy_client.h ('k') | content/renderer/input/input_handler_wrapper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698