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

Unified Diff: ui/events/blink/input_handler_proxy_unittest.cc

Issue 2341873002: Handle touchpad flings with passive event listeners on compositor thread. (Closed)
Patch Set: Try to fix funky windows build failure Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/events/blink/input_handler_proxy_client.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/events/blink/input_handler_proxy_unittest.cc
diff --git a/ui/events/blink/input_handler_proxy_unittest.cc b/ui/events/blink/input_handler_proxy_unittest.cc
index d701dafb59421b2eb1fe0ac4806584ead59478ff..c92f94688038bf7863d41ba4d81232796b8092af 100644
--- a/ui/events/blink/input_handler_proxy_unittest.cc
+++ b/ui/events/blink/input_handler_proxy_unittest.cc
@@ -210,15 +210,26 @@ class MockInputHandlerProxyClient
MockInputHandlerProxyClient() {}
~MockInputHandlerProxyClient() override {}
- void WillShutdown() override {}
+ MOCK_METHOD0(WillShutdown, void());
MOCK_METHOD1(TransferActiveWheelFlingAnimation,
void(const WebActiveWheelFlingParameters&));
+ MOCK_METHOD2(DispatchNonBlockingEventToMainThread_,
+ void(const WebInputEvent& event,
+ const ui::LatencyInfo& latency_info));
+
+ void DispatchNonBlockingEventToMainThread(
+ ui::ScopedWebInputEvent event,
+ const ui::LatencyInfo& latency_info) {
+ CHECK(event.get());
+ DispatchNonBlockingEventToMainThread_(*event.get(), latency_info);
+ }
+
blink::WebGestureCurve* CreateFlingAnimationCurve(
WebGestureDevice deviceSource,
const WebFloatPoint& velocity,
- const WebSize& cumulative_scroll) override {
+ const WebSize& cumulative_scroll) {
return new FakeWebGestureCurve(
blink::WebFloatSize(velocity.x, velocity.y),
blink::WebFloatSize(cumulative_scroll.width, cumulative_scroll.height));
@@ -229,9 +240,9 @@ class MockInputHandlerProxyClient
const gfx::Vector2dF& latest_overscroll_delta,
const gfx::Vector2dF& current_fling_velocity,
const gfx::PointF& causal_event_viewport_point));
- void DidStartFlinging() override {}
- void DidStopFlinging() override {}
- void DidAnimateForInput() override {}
+ void DidStartFlinging() override{};
Rick Byers 2016/09/16 14:00:54 nit: why the semicolons? Definitions don't normal
dtapuska 2016/09/19 19:37:39 Err; I initially tried to mock this entire class;
+ void DidStopFlinging() override{};
+ void DidAnimateForInput() override{};
private:
DISALLOW_COPY_AND_ASSIGN(MockInputHandlerProxyClient);
@@ -1001,54 +1012,30 @@ TEST_P(InputHandlerProxyTest, GestureFlingPassiveListener) {
VERIFY_AND_RESET_MOCKS();
- // The second call should punt the fling to the main thread
- // because of a passive event listener.
- EXPECT_SET_NEEDS_ANIMATE_INPUT(0);
+ // The second call should punt activate the fling and call the method
+ // dispatching the events for the passive event listeners.
+ EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
EXPECT_CALL(mock_input_handler_,
GetEventListenerProperties(cc::EventListenerClass::kMouseWheel))
.WillOnce(testing::Return(cc::EventListenerProperties::kPassive));
EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
- .Times(0);
- EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_)).Times(0);
- EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)).Times(0);
- // Expected wheel fling animation parameters:
- // *) fling_delta and fling_point should match the original GestureFlingStart
- // event
- // *) startTime should be 10 to match the time parameter of the first
- // Animate() call after the GestureFlingStart
+ .WillOnce(testing::Return(kImplThreadScrollState));
EXPECT_CALL(
- mock_client_,
- TransferActiveWheelFlingAnimation(testing::AllOf(
- testing::Field(&WebActiveWheelFlingParameters::delta,
- testing::Eq(fling_delta)),
- testing::Field(&WebActiveWheelFlingParameters::point,
- testing::Eq(fling_point)),
- testing::Field(&WebActiveWheelFlingParameters::globalPoint,
- testing::Eq(fling_global_point)),
- testing::Field(&WebActiveWheelFlingParameters::modifiers,
- testing::Eq(modifiers)),
- testing::Field(&WebActiveWheelFlingParameters::startTime,
- testing::Eq(10)),
- testing::Field(&WebActiveWheelFlingParameters::cumulativeScroll,
- testing::_))));
+ mock_input_handler_,
+ ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0))))
+ .WillOnce(testing::Return(scroll_result_did_scroll_));
+ EXPECT_CALL(mock_client_,
+ DispatchNonBlockingEventToMainThread_(testing::_, testing::_))
Rick Byers 2016/09/16 14:00:54 nit: Don't you want to still test the parameters o
dtapuska 2016/09/19 19:37:39 Done.
+ .Times(1);
+ EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)).Times(1);
+
time += base::TimeDelta::FromMilliseconds(100);
Animate(time);
VERIFY_AND_RESET_MOCKS();
- // Since we've aborted the fling, the next animation should be a no-op and
- // should not result in another
- // frame being requested.
- EXPECT_SET_NEEDS_ANIMATE_INPUT(0);
- EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
- .Times(0);
- time += base::TimeDelta::FromMilliseconds(100);
- Animate(time);
-
- // Since we've transferred the fling to the main thread, we need to pass the
- // next GestureFlingCancel to the main
- // thread as well.
- expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE;
+ // Ensure we can cancel the gesture.
+ expected_disposition_ = InputHandlerProxy::DID_HANDLE;
gesture_.type = WebInputEvent::GestureFlingCancel;
EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
« no previous file with comments | « ui/events/blink/input_handler_proxy_client.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698