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 delegate->Reset(); | |
2962 | |
2963 // Second tap (tested in GestureEventDoubleTap) | |
2964 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(101, 203), | |
2965 kTouchId, tes.LeapForward(200)); | |
2966 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2); | |
2967 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(102, 206), | |
2968 kTouchId, tes.LeapForward(50)); | |
2969 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release2); | |
sadrul
2013/05/28 17:48:46
check tap_count here and after the first tap
Yufeng Shen (Slow to review)
2013/05/28 19:31:44
Done.
| |
2970 | |
2971 // Third tap | |
2972 ui::TouchEvent press3(ui::ET_TOUCH_PRESSED, gfx::Point(102, 206), | |
2973 kTouchId, tes.LeapForward(200)); | |
2974 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press3); | |
2975 ui::TouchEvent release3(ui::ET_TOUCH_RELEASED, gfx::Point(102, 206), | |
2976 kTouchId, tes.LeapForward(50)); | |
2977 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release3); | |
2978 | |
2979 | |
2980 EXPECT_TRUE(delegate->tap()); | |
2981 EXPECT_TRUE(delegate->tap_down()); | |
2982 EXPECT_FALSE(delegate->tap_cancel()); | |
2983 EXPECT_TRUE(delegate->begin()); | |
2984 EXPECT_TRUE(delegate->end()); | |
2985 EXPECT_FALSE(delegate->scroll_begin()); | |
2986 EXPECT_FALSE(delegate->scroll_update()); | |
2987 EXPECT_FALSE(delegate->scroll_end()); | |
2988 | |
2989 EXPECT_EQ(3, delegate->tap_count()); | |
2990 } | |
2991 | |
2942 // Check that we don't get a double tap when the two taps are far apart. | 2992 // Check that we don't get a double tap when the two taps are far apart. |
2943 TEST_F(GestureRecognizerTest, TwoTapsFarApart) { | 2993 TEST_F(GestureRecognizerTest, TwoTapsFarApart) { |
2944 scoped_ptr<GestureEventConsumeDelegate> delegate( | 2994 scoped_ptr<GestureEventConsumeDelegate> delegate( |
2945 new GestureEventConsumeDelegate()); | 2995 new GestureEventConsumeDelegate()); |
2946 const int kWindowWidth = 123; | 2996 const int kWindowWidth = 123; |
2947 const int kWindowHeight = 45; | 2997 const int kWindowHeight = 45; |
2948 const int kTouchId = 2; | 2998 const int kTouchId = 2; |
2949 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 2999 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
2950 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 3000 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
2951 delegate.get(), -1234, bounds, root_window())); | 3001 delegate.get(), -1234, bounds, root_window())); |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3127 tes.LeapForward(40)); | 3177 tes.LeapForward(40)); |
3128 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move4); | 3178 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move4); |
3129 EXPECT_TRUE(delegate->scroll_update()); | 3179 EXPECT_TRUE(delegate->scroll_update()); |
3130 EXPECT_EQ(-1, delegate->scroll_y()); | 3180 EXPECT_EQ(-1, delegate->scroll_y()); |
3131 | 3181 |
3132 delegate->Reset(); | 3182 delegate->Reset(); |
3133 } | 3183 } |
3134 | 3184 |
3135 } // namespace test | 3185 } // namespace test |
3136 } // namespace aura | 3186 } // namespace aura |
OLD | NEW |