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

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

Issue 289373009: Support tap_count in ui::GestureProvider. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move to GestureProviderAura. Created 6 years, 7 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/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 3348 matching lines...) Expand 10 before | Expand all | Expand 10 after
3359 EXPECT_FALSE(delegate->begin()); 3359 EXPECT_FALSE(delegate->begin());
3360 EXPECT_TRUE(delegate->end()); 3360 EXPECT_TRUE(delegate->end());
3361 EXPECT_FALSE(delegate->scroll_begin()); 3361 EXPECT_FALSE(delegate->scroll_begin());
3362 EXPECT_FALSE(delegate->scroll_update()); 3362 EXPECT_FALSE(delegate->scroll_update());
3363 EXPECT_FALSE(delegate->scroll_end()); 3363 EXPECT_FALSE(delegate->scroll_end());
3364 EXPECT_FALSE(delegate->fling()); 3364 EXPECT_FALSE(delegate->fling());
3365 } 3365 }
3366 3366
3367 // Check that appropriate touch events generate double tap gesture events. 3367 // Check that appropriate touch events generate double tap gesture events.
3368 TEST_P(GestureRecognizerTest, GestureEventDoubleTap) { 3368 TEST_P(GestureRecognizerTest, GestureEventDoubleTap) {
3369 // TODO(tdresser): enable this test with unified GR once double / triple tap
3370 // gestures work. See crbug.com/357270.
3371 if (UsingUnifiedGR())
3372 return;
3373
3374 scoped_ptr<GestureEventConsumeDelegate> delegate( 3369 scoped_ptr<GestureEventConsumeDelegate> delegate(
3375 new GestureEventConsumeDelegate()); 3370 new GestureEventConsumeDelegate());
3376 const int kWindowWidth = 123; 3371 const int kWindowWidth = 123;
3377 const int kWindowHeight = 45; 3372 const int kWindowHeight = 45;
3378 const int kTouchId = 2; 3373 const int kTouchId = 2;
3379 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 3374 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
3380 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 3375 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
3381 delegate.get(), -1234, bounds, root_window())); 3376 delegate.get(), -1234, bounds, root_window()));
3382 TimedEvents tes; 3377 TimedEvents tes;
3383 3378
(...skipping 21 matching lines...) Expand all
3405 EXPECT_TRUE(delegate->end()); 3400 EXPECT_TRUE(delegate->end());
3406 EXPECT_FALSE(delegate->scroll_begin()); 3401 EXPECT_FALSE(delegate->scroll_begin());
3407 EXPECT_FALSE(delegate->scroll_update()); 3402 EXPECT_FALSE(delegate->scroll_update());
3408 EXPECT_FALSE(delegate->scroll_end()); 3403 EXPECT_FALSE(delegate->scroll_end());
3409 3404
3410 EXPECT_EQ(2, delegate->tap_count()); 3405 EXPECT_EQ(2, delegate->tap_count());
3411 } 3406 }
3412 3407
3413 // Check that appropriate touch events generate triple tap gesture events. 3408 // Check that appropriate touch events generate triple tap gesture events.
3414 TEST_P(GestureRecognizerTest, GestureEventTripleTap) { 3409 TEST_P(GestureRecognizerTest, GestureEventTripleTap) {
3415 // TODO(tdresser): enable this test with unified GR once double / triple tap
3416 // gestures work. See crbug.com/357270.
3417 if (UsingUnifiedGR())
3418 return;
3419
3420 scoped_ptr<GestureEventConsumeDelegate> delegate( 3410 scoped_ptr<GestureEventConsumeDelegate> delegate(
3421 new GestureEventConsumeDelegate()); 3411 new GestureEventConsumeDelegate());
3422 const int kWindowWidth = 123; 3412 const int kWindowWidth = 123;
3423 const int kWindowHeight = 45; 3413 const int kWindowHeight = 45;
3424 const int kTouchId = 2; 3414 const int kTouchId = 2;
3425 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 3415 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
3426 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 3416 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
3427 delegate.get(), -1234, bounds, root_window())); 3417 delegate.get(), -1234, bounds, root_window()));
3428 TimedEvents tes; 3418 TimedEvents tes;
3429 3419
(...skipping 20 matching lines...) Expand all
3450 delegate->Reset(); 3440 delegate->Reset();
3451 3441
3452 // Third tap 3442 // Third tap
3453 ui::TouchEvent press3(ui::ET_TOUCH_PRESSED, gfx::Point(102, 206), 3443 ui::TouchEvent press3(ui::ET_TOUCH_PRESSED, gfx::Point(102, 206),
3454 kTouchId, tes.LeapForward(200)); 3444 kTouchId, tes.LeapForward(200));
3455 DispatchEventUsingWindowDispatcher(&press3); 3445 DispatchEventUsingWindowDispatcher(&press3);
3456 ui::TouchEvent release3(ui::ET_TOUCH_RELEASED, gfx::Point(102, 206), 3446 ui::TouchEvent release3(ui::ET_TOUCH_RELEASED, gfx::Point(102, 206),
3457 kTouchId, tes.LeapForward(50)); 3447 kTouchId, tes.LeapForward(50));
3458 DispatchEventUsingWindowDispatcher(&release3); 3448 DispatchEventUsingWindowDispatcher(&release3);
3459 3449
3450 // Third, Fourth and Fifth Taps. Taps after the third should have their
3451 // |tap_count| wrap around back to 1.
3452 for (int i = 3; i < 5; ++i) {
3453 ui::TouchEvent press3(ui::ET_TOUCH_PRESSED,
3454 gfx::Point(102, 206),
3455 kTouchId,
3456 tes.LeapForward(200));
3457 DispatchEventUsingWindowDispatcher(&press3);
3458 ui::TouchEvent release3(ui::ET_TOUCH_RELEASED,
3459 gfx::Point(102, 206),
3460 kTouchId,
3461 tes.LeapForward(50));
3462 DispatchEventUsingWindowDispatcher(&release3);
3460 3463
3461 EXPECT_TRUE(delegate->tap()); 3464 EXPECT_TRUE(delegate->tap());
3462 EXPECT_TRUE(delegate->tap_down()); 3465 EXPECT_TRUE(delegate->tap_down());
3463 EXPECT_FALSE(delegate->tap_cancel()); 3466 EXPECT_FALSE(delegate->tap_cancel());
3464 EXPECT_TRUE(delegate->begin()); 3467 EXPECT_TRUE(delegate->begin());
3465 EXPECT_TRUE(delegate->end()); 3468 EXPECT_TRUE(delegate->end());
3466 EXPECT_FALSE(delegate->scroll_begin()); 3469 EXPECT_FALSE(delegate->scroll_begin());
3467 EXPECT_FALSE(delegate->scroll_update()); 3470 EXPECT_FALSE(delegate->scroll_update());
3468 EXPECT_FALSE(delegate->scroll_end()); 3471 EXPECT_FALSE(delegate->scroll_end());
3469 3472
3470 EXPECT_EQ(3, delegate->tap_count()); 3473 // The behavior for the Aura GR is incorrect.
3474 if (UsingUnifiedGR())
3475 EXPECT_EQ(1 + (i % 3), delegate->tap_count());
3476 else
3477 EXPECT_EQ(3, delegate->tap_count());
3478 }
3471 } 3479 }
3472 3480
3473 // Check that we don't get a double tap when the two taps are far apart. 3481 // Check that we don't get a double tap when the two taps are far apart.
3474 TEST_P(GestureRecognizerTest, TwoTapsFarApart) { 3482 TEST_P(GestureRecognizerTest, TwoTapsFarApart) {
3475 scoped_ptr<GestureEventConsumeDelegate> delegate( 3483 scoped_ptr<GestureEventConsumeDelegate> delegate(
3476 new GestureEventConsumeDelegate()); 3484 new GestureEventConsumeDelegate());
3477 const int kWindowWidth = 123; 3485 const int kWindowWidth = 123;
3478 const int kWindowHeight = 45; 3486 const int kWindowHeight = 45;
3479 const int kTouchId = 2; 3487 const int kTouchId = 2;
3480 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 3488 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after
4260 int default_flags = delegate->flags(); 4268 int default_flags = delegate->flags();
4261 4269
4262 ui::TouchEvent move1( 4270 ui::TouchEvent move1(
4263 ui::ET_TOUCH_MOVED, gfx::Point(397, 149), kTouchId, tes.LeapForward(50)); 4271 ui::ET_TOUCH_MOVED, gfx::Point(397, 149), kTouchId, tes.LeapForward(50));
4264 move1.set_flags(992); 4272 move1.set_flags(992);
4265 4273
4266 DispatchEventUsingWindowDispatcher(&move1); 4274 DispatchEventUsingWindowDispatcher(&move1);
4267 EXPECT_NE(default_flags, delegate->flags()); 4275 EXPECT_NE(default_flags, delegate->flags());
4268 } 4276 }
4269 4277
4270 // TODO - re-enable these tests once memory management issues have been sorted
4271 // out. See crbug.com/371990.
4272 INSTANTIATE_TEST_CASE_P(GestureRecognizer, 4278 INSTANTIATE_TEST_CASE_P(GestureRecognizer,
4273 GestureRecognizerTest, 4279 GestureRecognizerTest,
4274 ::testing::Bool()); 4280 ::testing::Bool());
4275 4281
4276 } // namespace test 4282 } // namespace test
4277 } // namespace aura 4283 } // namespace aura
OLDNEW
« no previous file with comments | « no previous file | ui/events/gesture_detection/gesture_detector.cc » ('j') | ui/events/gestures/gesture_provider_aura.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698