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

Side by Side Diff: ui/aura/gestures/gesture_recognizer_unittest.cc

Issue 570633002: Remove unsupported parameters by the unified gesture detector from Gesture Configuration. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/memory/scoped_vector.h" 6 #include "base/memory/scoped_vector.h"
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/timer/timer.h" 9 #include "base/timer/timer.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 628
629 } // namespace 629 } // namespace
630 630
631 class GestureRecognizerTest : public AuraTestBase, 631 class GestureRecognizerTest : public AuraTestBase,
632 public ::testing::WithParamInterface<bool> { 632 public ::testing::WithParamInterface<bool> {
633 public: 633 public:
634 GestureRecognizerTest() {} 634 GestureRecognizerTest() {}
635 635
636 virtual void SetUp() OVERRIDE { 636 virtual void SetUp() OVERRIDE {
637 AuraTestBase::SetUp(); 637 AuraTestBase::SetUp();
638 ui::GestureConfiguration::set_min_touch_down_duration_in_seconds_for_click(
639 0.001);
640 ui::GestureConfiguration::set_show_press_delay_in_ms(2); 638 ui::GestureConfiguration::set_show_press_delay_in_ms(2);
641 ui::GestureConfiguration::set_long_press_time_in_seconds(0.003); 639 ui::GestureConfiguration::set_long_press_time_in_seconds(0.003);
642 } 640 }
643 641
644 DISALLOW_COPY_AND_ASSIGN(GestureRecognizerTest); 642 DISALLOW_COPY_AND_ASSIGN(GestureRecognizerTest);
645 }; 643 };
646 644
647 // Check that appropriate touch events generate tap gesture events. 645 // Check that appropriate touch events generate tap gesture events.
648 TEST_F(GestureRecognizerTest, GestureEventTap) { 646 TEST_F(GestureRecognizerTest, GestureEventTap) {
649 scoped_ptr<GestureEventConsumeDelegate> delegate( 647 scoped_ptr<GestureEventConsumeDelegate> delegate(
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
1001 tes.LeapForward(50)); 999 tes.LeapForward(50));
1002 DispatchEventUsingWindowDispatcher(&release); 1000 DispatchEventUsingWindowDispatcher(&release);
1003 EXPECT_2_EVENTS(delegate->events(), 1001 EXPECT_2_EVENTS(delegate->events(),
1004 ui::ET_SCROLL_FLING_START, 1002 ui::ET_SCROLL_FLING_START,
1005 ui::ET_GESTURE_END); 1003 ui::ET_GESTURE_END);
1006 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); 1004 EXPECT_TRUE(delegate->bounding_box().IsEmpty());
1007 } 1005 }
1008 1006
1009 // Check that predicted scroll update positions are correct. 1007 // Check that predicted scroll update positions are correct.
1010 TEST_F(GestureRecognizerTest, GestureEventScrollPrediction) { 1008 TEST_F(GestureRecognizerTest, GestureEventScrollPrediction) {
1011 const double prediction_interval = 0.03; 1009 // We'll start by moving the touch point by (5, 5). We want all of that
1012 ui::GestureConfiguration::set_scroll_prediction_seconds(prediction_interval);
1013 // We'll start by moving the touch point by (5, 5). We want all of that
1014 // distance to be consumed by the slop, so we set the slop radius to 1010 // distance to be consumed by the slop, so we set the slop radius to
1015 // sqrt(5 * 5 + 5 * 5). 1011 // sqrt(5 * 5 + 5 * 5).
1016 ui::GestureConfiguration::set_max_touch_move_in_pixels_for_click( 1012 ui::GestureConfiguration::set_max_touch_move_in_pixels_for_click(
1017 sqrt(static_cast<double>(5 * 5 + 5 * 5))); 1013 sqrt(static_cast<double>(5 * 5 + 5 * 5)));
1018 1014
1019 scoped_ptr<GestureEventConsumeDelegate> delegate( 1015 scoped_ptr<GestureEventConsumeDelegate> delegate(
1020 new GestureEventConsumeDelegate()); 1016 new GestureEventConsumeDelegate());
1021 TimedEvents tes; 1017 TimedEvents tes;
1022 const int kWindowWidth = 123; 1018 const int kWindowWidth = 123;
1023 const int kWindowHeight = 45; 1019 const int kWindowHeight = 45;
(...skipping 2404 matching lines...) Expand 10 before | Expand all | Expand 10 after
3428 EXPECT_FALSE(delegate->scroll_update()); 3424 EXPECT_FALSE(delegate->scroll_update());
3429 EXPECT_FALSE(delegate->pinch_update()); 3425 EXPECT_FALSE(delegate->pinch_update());
3430 3426
3431 delegate->Reset(); 3427 delegate->Reset();
3432 } 3428 }
3433 3429
3434 // Checks that slow scrolls deliver the correct deltas. 3430 // Checks that slow scrolls deliver the correct deltas.
3435 // In particular, fix for http;//crbug.com/150573. 3431 // In particular, fix for http;//crbug.com/150573.
3436 TEST_F(GestureRecognizerTest, NoDriftInScroll) { 3432 TEST_F(GestureRecognizerTest, NoDriftInScroll) {
3437 ui::GestureConfiguration::set_max_touch_move_in_pixels_for_click(3); 3433 ui::GestureConfiguration::set_max_touch_move_in_pixels_for_click(3);
3438 ui::GestureConfiguration::set_min_scroll_delta_squared(9);
3439 scoped_ptr<GestureEventConsumeDelegate> delegate( 3434 scoped_ptr<GestureEventConsumeDelegate> delegate(
3440 new GestureEventConsumeDelegate()); 3435 new GestureEventConsumeDelegate());
3441 const int kWindowWidth = 234; 3436 const int kWindowWidth = 234;
3442 const int kWindowHeight = 345; 3437 const int kWindowHeight = 345;
3443 const int kTouchId = 5; 3438 const int kTouchId = 5;
3444 TimedEvents tes; 3439 TimedEvents tes;
3445 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 3440 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
3446 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 3441 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
3447 delegate.get(), -1234, bounds, root_window())); 3442 delegate.get(), -1234, bounds, root_window()));
3448 3443
(...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after
4278 ui::TouchEvent move3( 4273 ui::TouchEvent move3(
4279 ui::ET_TOUCH_MOVED, gfx::Point(65, 202), kTouchId1, tes.Now()); 4274 ui::ET_TOUCH_MOVED, gfx::Point(65, 202), kTouchId1, tes.Now());
4280 DispatchEventUsingWindowDispatcher(&move3); 4275 DispatchEventUsingWindowDispatcher(&move3);
4281 4276
4282 delegate->ReceivedAck(); 4277 delegate->ReceivedAck();
4283 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE); 4278 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE);
4284 } 4279 }
4285 4280
4286 } // namespace test 4281 } // namespace test
4287 } // namespace aura 4282 } // namespace aura
OLDNEW
« no previous file with comments | « no previous file | ui/aura/test/aura_test_base.cc » ('j') | ui/events/gestures/gesture_configuration.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698