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

Side by Side Diff: ui/events/blink/input_handler_proxy_unittest.cc

Issue 2047093002: Remove enable/disable wheel gestures setting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@can_scroll_remove
Patch Set: Remove unused, uninitialized variable on mac causing occasional failure Created 4 years, 6 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
« no previous file with comments | « ui/events/blink/input_handler_proxy.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "ui/events/blink/input_handler_proxy.h" 5 #include "ui/events/blink/input_handler_proxy.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/test/histogram_tester.h" 10 #include "base/test/histogram_tester.h"
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 EXPECT_EQ(expected_disposition_, 378 EXPECT_EQ(expected_disposition_,
379 input_handler_->HandleInputEvent(gesture_)); 379 input_handler_->HandleInputEvent(gesture_));
380 380
381 VERIFY_AND_RESET_MOCKS(); 381 VERIFY_AND_RESET_MOCKS();
382 } 382 }
383 383
384 void SetSmoothScrollEnabled(bool value) { 384 void SetSmoothScrollEnabled(bool value) {
385 input_handler_->smooth_scroll_enabled_ = value; 385 input_handler_->smooth_scroll_enabled_ = value;
386 } 386 }
387 387
388 void SetMouseWheelGesturesOn(bool value) {
389 input_handler_->set_use_gesture_events_for_mouse_wheel(value);
390 }
391
392 base::HistogramTester& histogram_tester() { 388 base::HistogramTester& histogram_tester() {
393 return histogram_tester_; 389 return histogram_tester_;
394 } 390 }
395 391
396 protected: 392 protected:
397 const bool synchronous_root_scroll_; 393 const bool synchronous_root_scroll_;
398 const bool install_synchronous_handler_; 394 const bool install_synchronous_handler_;
399 testing::StrictMock<MockInputHandler> mock_input_handler_; 395 testing::StrictMock<MockInputHandler> mock_input_handler_;
400 testing::StrictMock<MockSynchronousInputHandler> 396 testing::StrictMock<MockSynchronousInputHandler>
401 mock_synchronous_input_handler_; 397 mock_synchronous_input_handler_;
402 std::unique_ptr<TestInputHandlerProxy> input_handler_; 398 std::unique_ptr<TestInputHandlerProxy> input_handler_;
403 testing::StrictMock<MockInputHandlerProxyClient> mock_client_; 399 testing::StrictMock<MockInputHandlerProxyClient> mock_client_;
404 WebGestureEvent gesture_; 400 WebGestureEvent gesture_;
405 InputHandlerProxy::EventDisposition expected_disposition_; 401 InputHandlerProxy::EventDisposition expected_disposition_;
406 base::HistogramTester histogram_tester_; 402 base::HistogramTester histogram_tester_;
407 cc::InputHandlerScrollResult scroll_result_did_scroll_; 403 cc::InputHandlerScrollResult scroll_result_did_scroll_;
408 cc::InputHandlerScrollResult scroll_result_did_not_scroll_; 404 cc::InputHandlerScrollResult scroll_result_did_not_scroll_;
409 }; 405 };
410 406
411 TEST_P(InputHandlerProxyTest, MouseWheelByPageMainThread) {
412 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE;
413 SetMouseWheelGesturesOn(false);
414 WebMouseWheelEvent wheel;
415 wheel.type = WebInputEvent::MouseWheel;
416 wheel.scrollByPage = true;
417
418 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(wheel));
419 VERIFY_AND_RESET_MOCKS();
420 }
421
422 TEST_P(InputHandlerProxyTest, MouseWheelWithCtrlNotScroll) {
423 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE;
424 SetMouseWheelGesturesOn(false);
425 WebMouseWheelEvent wheel;
426 wheel.type = WebInputEvent::MouseWheel;
427 wheel.modifiers = WebInputEvent::ControlKey;
428 wheel.canScroll = false;
429 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(wheel));
430 VERIFY_AND_RESET_MOCKS();
431 }
432
433 TEST_P(InputHandlerProxyTest, MouseWheelNoListener) { 407 TEST_P(InputHandlerProxyTest, MouseWheelNoListener) {
434 expected_disposition_ = InputHandlerProxy::DROP_EVENT; 408 expected_disposition_ = InputHandlerProxy::DROP_EVENT;
435 EXPECT_CALL(mock_input_handler_, 409 EXPECT_CALL(mock_input_handler_,
436 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) 410 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel))
437 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); 411 .WillOnce(testing::Return(cc::EventListenerProperties::kNone));
438 412
439 WebMouseWheelEvent wheel; 413 WebMouseWheelEvent wheel;
440 wheel.type = WebInputEvent::MouseWheel; 414 wheel.type = WebInputEvent::MouseWheel;
441 wheel.modifiers = WebInputEvent::ControlKey; 415 wheel.modifiers = WebInputEvent::ControlKey;
442 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(wheel)); 416 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(wheel));
(...skipping 19 matching lines...) Expand all
462 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) 436 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel))
463 .WillOnce(testing::Return(cc::EventListenerProperties::kBlocking)); 437 .WillOnce(testing::Return(cc::EventListenerProperties::kBlocking));
464 438
465 WebMouseWheelEvent wheel; 439 WebMouseWheelEvent wheel;
466 wheel.type = WebInputEvent::MouseWheel; 440 wheel.type = WebInputEvent::MouseWheel;
467 wheel.modifiers = WebInputEvent::ControlKey; 441 wheel.modifiers = WebInputEvent::ControlKey;
468 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(wheel)); 442 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(wheel));
469 VERIFY_AND_RESET_MOCKS(); 443 VERIFY_AND_RESET_MOCKS();
470 } 444 }
471 445
472 // Mac does not smooth scroll wheel events (crbug.com/574283).
473 #if !defined(OS_MACOSX)
474 TEST_P(InputHandlerProxyTest, MouseWheelWithPreciseScrollingDeltas) {
475 #else
476 TEST_P(InputHandlerProxyTest, DISABLED_MouseWheelWithPreciseScrollingDeltas) {
477 #endif
478 SetSmoothScrollEnabled(true);
479 SetMouseWheelGesturesOn(false);
480 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
481 WebMouseWheelEvent wheel;
482 wheel.type = WebInputEvent::MouseWheel;
483
484 VERIFY_AND_RESET_MOCKS();
485
486 // Smooth scroll because hasPreciseScrollingDeltas is set to false.
487 wheel.hasPreciseScrollingDeltas = false;
488 EXPECT_CALL(mock_input_handler_, ScrollAnimated(::testing::_, ::testing::_))
489 .WillOnce(testing::Return(kImplThreadScrollState));
490 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(wheel));
491
492 VERIFY_AND_RESET_MOCKS();
493
494 // No smooth scroll because hasPreciseScrollingDeltas is set to true.
495 wheel.hasPreciseScrollingDeltas = true;
496 EXPECT_CALL(mock_input_handler_, ScrollBegin(::testing::_, ::testing::_))
497 .WillOnce(testing::Return(kImplThreadScrollState));
498 EXPECT_CALL(mock_input_handler_, ScrollBy(::testing::_))
499 .WillOnce(testing::Return(scroll_result_did_scroll_));
500 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
501 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(wheel));
502
503 VERIFY_AND_RESET_MOCKS();
504 }
505
506 // Mac does not smooth scroll wheel events (crbug.com/574283).
507 #if !defined(OS_MACOSX)
508 TEST_P(InputHandlerProxyTest, MouseWheelScrollIgnored) {
509 #else
510 TEST_P(InputHandlerProxyTest, DISABLED_MouseWheelScrollIgnored) {
511 #endif
512 SetSmoothScrollEnabled(true);
513 SetMouseWheelGesturesOn(false);
514 expected_disposition_ = InputHandlerProxy::DROP_EVENT;
515 WebMouseWheelEvent wheel;
516 wheel.type = WebInputEvent::MouseWheel;
517
518 EXPECT_CALL(mock_input_handler_, ScrollAnimated(testing::_, testing::_))
519 .WillOnce(testing::Return(kScrollIgnoredScrollState));
520
521 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(wheel));
522 VERIFY_AND_RESET_MOCKS();
523 }
524
525 TEST_P(InputHandlerProxyTest, GestureScrollStarted) { 446 TEST_P(InputHandlerProxyTest, GestureScrollStarted) {
526 // We shouldn't send any events to the widget for this gesture. 447 // We shouldn't send any events to the widget for this gesture.
527 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 448 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
528 VERIFY_AND_RESET_MOCKS(); 449 VERIFY_AND_RESET_MOCKS();
529 450
530 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 451 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
531 .WillOnce(testing::Return(kImplThreadScrollState)); 452 .WillOnce(testing::Return(kImplThreadScrollState));
532 453
533 gesture_.type = WebInputEvent::GestureScrollBegin; 454 gesture_.type = WebInputEvent::GestureScrollBegin;
534 EXPECT_EQ(expected_disposition_,input_handler_->HandleInputEvent(gesture_)); 455 EXPECT_EQ(expected_disposition_,input_handler_->HandleInputEvent(gesture_));
(...skipping 2324 matching lines...) Expand 10 before | Expand all | Expand 10 after
2859 testing::ElementsAre(base::Bucket(1, 1), base::Bucket(3, 1), 2780 testing::ElementsAre(base::Bucket(1, 1), base::Bucket(3, 1),
2860 base::Bucket(5, 1), base::Bucket(14, 1))); 2781 base::Bucket(5, 1), base::Bucket(14, 1)));
2861 } 2782 }
2862 2783
2863 2784
2864 INSTANTIATE_TEST_CASE_P(AnimateInput, 2785 INSTANTIATE_TEST_CASE_P(AnimateInput,
2865 InputHandlerProxyTest, 2786 InputHandlerProxyTest,
2866 testing::ValuesIn(test_types)); 2787 testing::ValuesIn(test_types));
2867 } // namespace test 2788 } // namespace test
2868 } // namespace ui 2789 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/blink/input_handler_proxy.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698