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

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

Issue 557403002: InputHandlerProxy to inform blink scheduler of input events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added a test Created 6 years, 3 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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 WebGestureDevice deviceSource, 172 WebGestureDevice deviceSource,
173 const WebFloatPoint& velocity, 173 const WebFloatPoint& velocity,
174 const WebSize& cumulative_scroll) OVERRIDE { 174 const WebSize& cumulative_scroll) OVERRIDE {
175 return new FakeWebGestureCurve( 175 return new FakeWebGestureCurve(
176 blink::WebFloatSize(velocity.x, velocity.y), 176 blink::WebFloatSize(velocity.x, velocity.y),
177 blink::WebFloatSize(cumulative_scroll.width, cumulative_scroll.height)); 177 blink::WebFloatSize(cumulative_scroll.width, cumulative_scroll.height));
178 } 178 }
179 179
180 MOCK_METHOD1(DidOverscroll, void(const DidOverscrollParams&)); 180 MOCK_METHOD1(DidOverscroll, void(const DidOverscrollParams&));
181 virtual void DidStopFlinging() OVERRIDE {} 181 virtual void DidStopFlinging() OVERRIDE {}
182 virtual void DidReceiveInputEvent() OVERRIDE {}
182 183
183 private: 184 private:
184 DISALLOW_COPY_AND_ASSIGN(MockInputHandlerProxyClient); 185 DISALLOW_COPY_AND_ASSIGN(MockInputHandlerProxyClient);
185 }; 186 };
186 187
188 class MockInputHandlerProxyClientWithDidReceiveInputEvent
189 : public MockInputHandlerProxyClient {
190 public:
191 MockInputHandlerProxyClientWithDidReceiveInputEvent() {}
192 virtual ~MockInputHandlerProxyClientWithDidReceiveInputEvent() {}
193
194 MOCK_METHOD0(DidReceiveInputEvent, void());
195
196 private:
197 DISALLOW_COPY_AND_ASSIGN(MockInputHandlerProxyClientWithDidReceiveInputEvent);
198 };
199
187 WebTouchPoint CreateWebTouchPoint(WebTouchPoint::State state, float x, 200 WebTouchPoint CreateWebTouchPoint(WebTouchPoint::State state, float x,
188 float y) { 201 float y) {
189 WebTouchPoint point; 202 WebTouchPoint point;
190 point.state = state; 203 point.state = state;
191 point.screenPosition = WebFloatPoint(x, y); 204 point.screenPosition = WebFloatPoint(x, y);
192 point.position = WebFloatPoint(x, y); 205 point.position = WebFloatPoint(x, y);
193 return point; 206 return point;
194 } 207 }
195 208
196 class InputHandlerProxyTest : public testing::Test { 209 class InputHandlerProxyTest : public testing::Test {
(...skipping 1731 matching lines...) Expand 10 before | Expand all | Expand 10 after
1928 // GestureScrollEnd should terminate the resumed scroll properly. 1941 // GestureScrollEnd should terminate the resumed scroll properly.
1929 time += dt; 1942 time += dt;
1930 gesture_.timeStampSeconds = InSecondsF(time); 1943 gesture_.timeStampSeconds = InSecondsF(time);
1931 gesture_.type = WebInputEvent::GestureScrollEnd; 1944 gesture_.type = WebInputEvent::GestureScrollEnd;
1932 EXPECT_CALL(mock_input_handler_, ScrollEnd()); 1945 EXPECT_CALL(mock_input_handler_, ScrollEnd());
1933 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1946 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1934 1947
1935 VERIFY_AND_RESET_MOCKS(); 1948 VERIFY_AND_RESET_MOCKS();
1936 } 1949 }
1937 1950
1951 TEST_F(InputHandlerProxyTest, DidReceiveInputEvent) {
1952 testing::StrictMock<
1953 MockInputHandlerProxyClientWithDidReceiveInputEvent> mock_client;
1954 input_handler_.reset(
1955 new content::InputHandlerProxy(&mock_input_handler_, &mock_client));
1956
1957 // Note the type of input event isn't important.
1958 WebMouseWheelEvent wheel;
1959 wheel.type = WebInputEvent::MouseWheel;
1960 wheel.scrollByPage = true;
1961
1962 EXPECT_CALL(mock_client, DidReceiveInputEvent());
1963
1964 input_handler_->HandleInputEvent(wheel);
1965 testing::Mock::VerifyAndClearExpectations(&mock_client);
1966 }
1967
1938 } // namespace 1968 } // namespace
1939 } // namespace content 1969 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698