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

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

Issue 10958053: Fix drift while scrolling. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: removed spurious whitespace change Created 8 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 | Annotate | Revision Log
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/memory/scoped_vector.h" 5 #include "base/memory/scoped_vector.h"
6 #include "base/string_number_conversions.h" 6 #include "base/string_number_conversions.h"
7 #include "base/timer.h" 7 #include "base/timer.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "ui/aura/root_window.h" 9 #include "ui/aura/root_window.h"
10 #include "ui/aura/test/aura_test_base.h" 10 #include "ui/aura/test/aura_test_base.h"
(...skipping 2603 matching lines...) Expand 10 before | Expand all | Expand 10 after
2614 EXPECT_FALSE(delegate->tap()); 2614 EXPECT_FALSE(delegate->tap());
2615 EXPECT_FALSE(delegate->tap_down()); 2615 EXPECT_FALSE(delegate->tap_down());
2616 EXPECT_TRUE(delegate->tap_cancel()); 2616 EXPECT_TRUE(delegate->tap_cancel());
2617 EXPECT_FALSE(delegate->begin()); 2617 EXPECT_FALSE(delegate->begin());
2618 EXPECT_FALSE(delegate->double_tap()); 2618 EXPECT_FALSE(delegate->double_tap());
2619 EXPECT_TRUE(delegate->scroll_begin()); 2619 EXPECT_TRUE(delegate->scroll_begin());
2620 EXPECT_TRUE(delegate->scroll_update()); 2620 EXPECT_TRUE(delegate->scroll_update());
2621 EXPECT_FALSE(delegate->scroll_end()); 2621 EXPECT_FALSE(delegate->scroll_end());
2622 EXPECT_EQ(29, delegate->scroll_x()); 2622 EXPECT_EQ(29, delegate->scroll_x());
2623 EXPECT_EQ(29, delegate->scroll_y()); 2623 EXPECT_EQ(29, delegate->scroll_y());
2624 EXPECT_EQ(gfx::Point(1, 1).ToString(), 2624 EXPECT_EQ(gfx::Point(30, 30).ToString(),
sadrul 2012/09/21 23:09:40 Nice.
2625 delegate->scroll_begin_position().ToString()); 2625 delegate->scroll_begin_position().ToString());
2626 2626
2627 // Start consuming touch-move events again. However, since gesture-scroll has 2627 // Start consuming touch-move events again. However, since gesture-scroll has
2628 // already started, the touch-move events should still result in scroll-update 2628 // already started, the touch-move events should still result in scroll-update
2629 // gesturs. 2629 // gestures.
2630 delegate->set_consume_touch_move(true); 2630 delegate->set_consume_touch_move(true);
2631 2631
2632 // Move some more to generate a few more scroll updates. 2632 // Move some more to generate a few more scroll updates.
2633 SendScrollEvent(root_window(), 110, 211, kTouchId, delegate.get()); 2633 SendScrollEvent(root_window(), 110, 211, kTouchId, delegate.get());
2634 EXPECT_FALSE(delegate->tap()); 2634 EXPECT_FALSE(delegate->tap());
2635 EXPECT_FALSE(delegate->tap_down()); 2635 EXPECT_FALSE(delegate->tap_down());
2636 EXPECT_FALSE(delegate->tap_cancel()); 2636 EXPECT_FALSE(delegate->tap_cancel());
2637 EXPECT_FALSE(delegate->begin()); 2637 EXPECT_FALSE(delegate->begin());
2638 EXPECT_FALSE(delegate->double_tap()); 2638 EXPECT_FALSE(delegate->double_tap());
2639 EXPECT_FALSE(delegate->scroll_begin()); 2639 EXPECT_FALSE(delegate->scroll_begin());
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
2849 move2.set_radius_y(60); 2849 move2.set_radius_y(60);
2850 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move2); 2850 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move2);
2851 EXPECT_FALSE(delegate->tap()); 2851 EXPECT_FALSE(delegate->tap());
2852 EXPECT_FALSE(delegate->tap_cancel()); 2852 EXPECT_FALSE(delegate->tap_cancel());
2853 EXPECT_FALSE(delegate->scroll_update()); 2853 EXPECT_FALSE(delegate->scroll_update());
2854 EXPECT_FALSE(delegate->pinch_update()); 2854 EXPECT_FALSE(delegate->pinch_update());
2855 2855
2856 delegate->Reset(); 2856 delegate->Reset();
2857 } 2857 }
2858 2858
2859 // Checks that slow scrolls deliver the correct deltas.
2860 // In particular, fix for http;//crbug.com/150573.
2861 TEST_F(GestureRecognizerTest, NoDriftInScroll) {
2862 ui::GestureConfiguration::set_max_touch_move_in_pixels_for_click(3);
2863 ui::GestureConfiguration::set_min_scroll_delta_squared(9);
2864 scoped_ptr<GestureEventConsumeDelegate> delegate(
2865 new GestureEventConsumeDelegate());
2866 const int kWindowWidth = 234;
2867 const int kWindowHeight = 345;
2868 const int kTouchId = 5;
2869 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
2870 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
2871 delegate.get(), -1234, bounds, NULL));
2872
2873 ui::TouchEvent press1(
2874 ui::ET_TOUCH_PRESSED, gfx::Point(101, 208), kTouchId, GetTime());
2875 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1);
2876 EXPECT_TRUE(delegate->begin());
2877
2878 delegate->Reset();
2879
2880 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(101, 206), kTouchId,
2881 press1.time_stamp() + base::TimeDelta::FromMilliseconds(40));
2882 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move1);
2883 EXPECT_FALSE(delegate->scroll_begin());
2884
2885 delegate->Reset();
2886
2887 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(101, 204), kTouchId,
2888 press1.time_stamp() + base::TimeDelta::FromMilliseconds(40));
2889 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move2);
2890 EXPECT_TRUE(delegate->tap_cancel());
2891 EXPECT_TRUE(delegate->scroll_begin());
2892 EXPECT_TRUE(delegate->scroll_update());
2893 EXPECT_EQ(-4, delegate->scroll_y());
2894
2895 delegate->Reset();
2896
2897 ui::TouchEvent move3(ui::ET_TOUCH_MOVED, gfx::Point(101, 204), kTouchId,
2898 press1.time_stamp() + base::TimeDelta::FromMilliseconds(40));
2899 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move3);
2900 EXPECT_FALSE(delegate->scroll_update());
2901
2902 delegate->Reset();
2903
2904 ui::TouchEvent move4(ui::ET_TOUCH_MOVED, gfx::Point(101, 203), kTouchId,
2905 press1.time_stamp() + base::TimeDelta::FromMilliseconds(40));
2906 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move4);
2907 EXPECT_TRUE(delegate->scroll_update());
2908 EXPECT_EQ(-1, delegate->scroll_y());
2909
2910 delegate->Reset();
2911 }
2912
2859 } // namespace test 2913 } // namespace test
2860 } // namespace aura 2914 } // namespace aura
OLDNEW
« no previous file with comments | « no previous file | ui/base/gestures/gesture_sequence.cc » ('j') | ui/base/gestures/gesture_sequence.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698