OLD | NEW |
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/run_loop.h" | 6 #include "base/run_loop.h" |
7 #include "base/string_number_conversions.h" | 7 #include "base/string_number_conversions.h" |
8 #include "base/timer.h" | 8 #include "base/timer.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "ui/aura/env.h" | 10 #include "ui/aura/env.h" |
(...skipping 2921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2932 EXPECT_FALSE(delegate->tap_cancel()); | 2932 EXPECT_FALSE(delegate->tap_cancel()); |
2933 EXPECT_TRUE(delegate->begin()); | 2933 EXPECT_TRUE(delegate->begin()); |
2934 EXPECT_TRUE(delegate->end()); | 2934 EXPECT_TRUE(delegate->end()); |
2935 EXPECT_FALSE(delegate->scroll_begin()); | 2935 EXPECT_FALSE(delegate->scroll_begin()); |
2936 EXPECT_FALSE(delegate->scroll_update()); | 2936 EXPECT_FALSE(delegate->scroll_update()); |
2937 EXPECT_FALSE(delegate->scroll_end()); | 2937 EXPECT_FALSE(delegate->scroll_end()); |
2938 | 2938 |
2939 EXPECT_EQ(2, delegate->tap_count()); | 2939 EXPECT_EQ(2, delegate->tap_count()); |
2940 } | 2940 } |
2941 | 2941 |
| 2942 // Check that appropriate touch events generate triple tap gesture events. |
| 2943 TEST_F(GestureRecognizerTest, GestureEventTripleTap) { |
| 2944 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 2945 new GestureEventConsumeDelegate()); |
| 2946 const int kWindowWidth = 123; |
| 2947 const int kWindowHeight = 45; |
| 2948 const int kTouchId = 2; |
| 2949 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 2950 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 2951 delegate.get(), -1234, bounds, root_window())); |
| 2952 TimedEvents tes; |
| 2953 |
| 2954 // First tap (tested in GestureEventTap) |
| 2955 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(104, 201), |
| 2956 kTouchId, tes.Now()); |
| 2957 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1); |
| 2958 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(104, 201), |
| 2959 kTouchId, tes.LeapForward(50)); |
| 2960 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release1); |
| 2961 |
| 2962 EXPECT_EQ(1, delegate->tap_count()); |
| 2963 delegate->Reset(); |
| 2964 |
| 2965 // Second tap (tested in GestureEventDoubleTap) |
| 2966 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(101, 203), |
| 2967 kTouchId, tes.LeapForward(200)); |
| 2968 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2); |
| 2969 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(102, 206), |
| 2970 kTouchId, tes.LeapForward(50)); |
| 2971 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release2); |
| 2972 |
| 2973 EXPECT_EQ(2, delegate->tap_count()); |
| 2974 delegate->Reset(); |
| 2975 |
| 2976 // Third tap |
| 2977 ui::TouchEvent press3(ui::ET_TOUCH_PRESSED, gfx::Point(102, 206), |
| 2978 kTouchId, tes.LeapForward(200)); |
| 2979 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press3); |
| 2980 ui::TouchEvent release3(ui::ET_TOUCH_RELEASED, gfx::Point(102, 206), |
| 2981 kTouchId, tes.LeapForward(50)); |
| 2982 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release3); |
| 2983 |
| 2984 |
| 2985 EXPECT_TRUE(delegate->tap()); |
| 2986 EXPECT_TRUE(delegate->tap_down()); |
| 2987 EXPECT_FALSE(delegate->tap_cancel()); |
| 2988 EXPECT_TRUE(delegate->begin()); |
| 2989 EXPECT_TRUE(delegate->end()); |
| 2990 EXPECT_FALSE(delegate->scroll_begin()); |
| 2991 EXPECT_FALSE(delegate->scroll_update()); |
| 2992 EXPECT_FALSE(delegate->scroll_end()); |
| 2993 |
| 2994 EXPECT_EQ(3, delegate->tap_count()); |
| 2995 } |
| 2996 |
2942 // Check that we don't get a double tap when the two taps are far apart. | 2997 // Check that we don't get a double tap when the two taps are far apart. |
2943 TEST_F(GestureRecognizerTest, TwoTapsFarApart) { | 2998 TEST_F(GestureRecognizerTest, TwoTapsFarApart) { |
2944 scoped_ptr<GestureEventConsumeDelegate> delegate( | 2999 scoped_ptr<GestureEventConsumeDelegate> delegate( |
2945 new GestureEventConsumeDelegate()); | 3000 new GestureEventConsumeDelegate()); |
2946 const int kWindowWidth = 123; | 3001 const int kWindowWidth = 123; |
2947 const int kWindowHeight = 45; | 3002 const int kWindowHeight = 45; |
2948 const int kTouchId = 2; | 3003 const int kTouchId = 2; |
2949 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 3004 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
2950 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 3005 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
2951 delegate.get(), -1234, bounds, root_window())); | 3006 delegate.get(), -1234, bounds, root_window())); |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3127 tes.LeapForward(40)); | 3182 tes.LeapForward(40)); |
3128 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move4); | 3183 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move4); |
3129 EXPECT_TRUE(delegate->scroll_update()); | 3184 EXPECT_TRUE(delegate->scroll_update()); |
3130 EXPECT_EQ(-1, delegate->scroll_y()); | 3185 EXPECT_EQ(-1, delegate->scroll_y()); |
3131 | 3186 |
3132 delegate->Reset(); | 3187 delegate->Reset(); |
3133 } | 3188 } |
3134 | 3189 |
3135 } // namespace test | 3190 } // namespace test |
3136 } // namespace aura | 3191 } // namespace aura |
OLD | NEW |