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

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

Issue 101933004: Eager Gesture Recognizer (WIP) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Starting work on Android. Created 6 years, 11 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
« no previous file with comments | « ui/aura/gestures/eager_gesture_recognition_aura_unittest.cc ('k') | ui/aura/root_window.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 bool mouse_exit_; 452 bool mouse_exit_;
453 bool mouse_press_; 453 bool mouse_press_;
454 bool mouse_release_; 454 bool mouse_release_;
455 bool mouse_move_; 455 bool mouse_move_;
456 bool double_click_; 456 bool double_click_;
457 457
458 DISALLOW_COPY_AND_ASSIGN(GestureEventSynthDelegate); 458 DISALLOW_COPY_AND_ASSIGN(GestureEventSynthDelegate);
459 }; 459 };
460 460
461 class TestOneShotGestureSequenceTimer 461 class TestOneShotGestureSequenceTimer
462 : public base::OneShotTimer<ui::GestureSequence> { 462 : public base::OneShotTimer<ui::GestureEventQueueTimerInterface> {
463 public: 463 public:
464 TestOneShotGestureSequenceTimer() {} 464 TestOneShotGestureSequenceTimer() {}
465 465
466 void ForceTimeout() { 466 void ForceTimeout() {
467 if (IsRunning()) { 467 if (IsRunning()) {
468 user_task().Run(); 468 user_task().Run();
469 Stop(); 469 Stop();
470 } 470 }
471 } 471 }
472 472
473 private: 473 private:
474 DISALLOW_COPY_AND_ASSIGN(TestOneShotGestureSequenceTimer); 474 DISALLOW_COPY_AND_ASSIGN(TestOneShotGestureSequenceTimer);
475 }; 475 };
476 476
477 class TimerTestGestureSequence : public ui::GestureSequence { 477 class TimerTestGestureSequence : public ui::GestureSequence {
478 public: 478 public:
479 explicit TimerTestGestureSequence(ui::GestureSequenceDelegate* delegate) 479 explicit TimerTestGestureSequence(
480 : ui::GestureSequence(delegate) { 480 ui::GestureEventQueueTimerInterface* geq_timers)
481 : ui::GestureSequence(geq_timers) {
481 } 482 }
482 483
483 void ForceTimeout() { 484 void ForceTimeout() {
484 static_cast<TestOneShotGestureSequenceTimer*>( 485 static_cast<TestOneShotGestureSequenceTimer*>(
485 GetLongPressTimer())->ForceTimeout(); 486 GetLongPressTimer())->ForceTimeout();
486 } 487 }
487 488
488 bool IsTimerRunning() { 489 bool IsTimerRunning() {
489 return GetLongPressTimer()->IsRunning(); 490 return GetLongPressTimer()->IsRunning();
490 } 491 }
491 492
492 virtual base::OneShotTimer<ui::GestureSequence>* CreateTimer() OVERRIDE { 493 virtual base::OneShotTimer<ui::GestureEventQueueTimerInterface>*
494 CreateTimer() OVERRIDE {
493 return new TestOneShotGestureSequenceTimer(); 495 return new TestOneShotGestureSequenceTimer();
494 } 496 }
495 497
496 private: 498 private:
497 DISALLOW_COPY_AND_ASSIGN(TimerTestGestureSequence); 499 DISALLOW_COPY_AND_ASSIGN(TimerTestGestureSequence);
498 }; 500 };
499 501
500 class TestGestureRecognizer : public ui::GestureRecognizerImpl { 502 class TestGestureRecognizer : public ui::GestureRecognizerImpl {
501 public: 503 public:
502 TestGestureRecognizer() : GestureRecognizerImpl() { 504 TestGestureRecognizer() : GestureRecognizerImpl() {
503 } 505 }
504 506
505 ui::GestureSequence* GetGestureSequenceForTesting(Window* window) { 507 ui::GestureSequence* GetGestureSequenceForTesting(Window* window) {
506 return GetGestureSequenceForConsumer(window); 508 return GetGestureSequenceForConsumer(window, NULL);
507 } 509 }
508 510
509 private: 511 private:
510 DISALLOW_COPY_AND_ASSIGN(TestGestureRecognizer); 512 DISALLOW_COPY_AND_ASSIGN(TestGestureRecognizer);
511 }; 513 };
512 514
513 class TimerTestGestureRecognizer : public TestGestureRecognizer { 515 class TimerTestGestureRecognizer : public TestGestureRecognizer {
514 public: 516 public:
515 TimerTestGestureRecognizer() : TestGestureRecognizer() { 517 TimerTestGestureRecognizer() : TestGestureRecognizer() {
516 } 518 }
517 519
518 virtual ui::GestureSequence* CreateSequence( 520 virtual ui::GestureSequence* CreateSequence(
519 ui::GestureSequenceDelegate* delegate) OVERRIDE { 521 ui::GestureEventQueueTimerInterface* geq_timers) OVERRIDE {
520 return new TimerTestGestureSequence(delegate); 522 return new TimerTestGestureSequence(geq_timers);
521 } 523 }
522 524
523 private: 525 private:
524 DISALLOW_COPY_AND_ASSIGN(TimerTestGestureRecognizer); 526 DISALLOW_COPY_AND_ASSIGN(TimerTestGestureRecognizer);
525 }; 527 };
526 528
527 base::TimeDelta GetTime() { 529 base::TimeDelta GetTime() {
528 return ui::EventTimeForNow(); 530 return ui::EventTimeForNow();
529 } 531 }
530 532
(...skipping 3175 matching lines...) Expand 10 before | Expand all | Expand 10 after
3706 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 3708 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201),
3707 kTouchId, tes.LeapForward(50)); 3709 kTouchId, tes.LeapForward(50));
3708 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release1); 3710 dispatcher()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release1);
3709 EXPECT_TRUE(delegate->show_press()); 3711 EXPECT_TRUE(delegate->show_press());
3710 EXPECT_FALSE(delegate->tap_cancel()); 3712 EXPECT_FALSE(delegate->tap_cancel());
3711 EXPECT_TRUE(delegate->tap()); 3713 EXPECT_TRUE(delegate->tap());
3712 } 3714 }
3713 3715
3714 } // namespace test 3716 } // namespace test
3715 } // namespace aura 3717 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/gestures/eager_gesture_recognition_aura_unittest.cc ('k') | ui/aura/root_window.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698