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

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

Issue 10824158: Pass tap count (1 or 2) with tap gesture events (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with trunk Created 8 years, 4 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/event.h" 9 #include "ui/aura/event.h"
10 #include "ui/aura/root_window.h" 10 #include "ui/aura/root_window.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 scroll_end_(false), 44 scroll_end_(false),
45 pinch_begin_(false), 45 pinch_begin_(false),
46 pinch_update_(false), 46 pinch_update_(false),
47 pinch_end_(false), 47 pinch_end_(false),
48 long_press_(false), 48 long_press_(false),
49 fling_(false), 49 fling_(false),
50 two_finger_tap_(false), 50 two_finger_tap_(false),
51 scroll_x_(0), 51 scroll_x_(0),
52 scroll_y_(0), 52 scroll_y_(0),
53 velocity_x_(0), 53 velocity_x_(0),
54 velocity_y_(0) { 54 velocity_y_(0),
55 tap_count_(0) {
55 } 56 }
56 57
57 virtual ~GestureEventConsumeDelegate() {} 58 virtual ~GestureEventConsumeDelegate() {}
58 59
59 void Reset() { 60 void Reset() {
60 tap_ = false; 61 tap_ = false;
61 tap_down_ = false; 62 tap_down_ = false;
62 begin_ = false; 63 begin_ = false;
63 end_ = false; 64 end_ = false;
64 double_tap_ = false; 65 double_tap_ = false;
65 scroll_begin_ = false; 66 scroll_begin_ = false;
66 scroll_update_ = false; 67 scroll_update_ = false;
67 scroll_end_ = false; 68 scroll_end_ = false;
68 pinch_begin_ = false; 69 pinch_begin_ = false;
69 pinch_update_ = false; 70 pinch_update_ = false;
70 pinch_end_ = false; 71 pinch_end_ = false;
71 long_press_ = false; 72 long_press_ = false;
72 fling_ = false; 73 fling_ = false;
73 two_finger_tap_ = false; 74 two_finger_tap_ = false;
74 75
75 scroll_begin_position_.SetPoint(0, 0); 76 scroll_begin_position_.SetPoint(0, 0);
76 tap_location_.SetPoint(0, 0); 77 tap_location_.SetPoint(0, 0);
77 78
78 scroll_x_ = 0; 79 scroll_x_ = 0;
79 scroll_y_ = 0; 80 scroll_y_ = 0;
80 velocity_x_ = 0; 81 velocity_x_ = 0;
81 velocity_y_ = 0; 82 velocity_y_ = 0;
83 tap_count_ = 0;
82 } 84 }
83 85
84 bool tap() const { return tap_; } 86 bool tap() const { return tap_; }
85 bool tap_down() const { return tap_down_; } 87 bool tap_down() const { return tap_down_; }
86 bool begin() const { return begin_; } 88 bool begin() const { return begin_; }
87 bool end() const { return end_; } 89 bool end() const { return end_; }
88 bool double_tap() const { return double_tap_; } 90 bool double_tap() const { return double_tap_; }
89 bool scroll_begin() const { return scroll_begin_; } 91 bool scroll_begin() const { return scroll_begin_; }
90 bool scroll_update() const { return scroll_update_; } 92 bool scroll_update() const { return scroll_update_; }
91 bool scroll_end() const { return scroll_end_; } 93 bool scroll_end() const { return scroll_end_; }
(...skipping 11 matching lines...) Expand all
103 const gfx::Point tap_location() const { 105 const gfx::Point tap_location() const {
104 return tap_location_; 106 return tap_location_;
105 } 107 }
106 108
107 float scroll_x() const { return scroll_x_; } 109 float scroll_x() const { return scroll_x_; }
108 float scroll_y() const { return scroll_y_; } 110 float scroll_y() const { return scroll_y_; }
109 int touch_id() const { return touch_id_; } 111 int touch_id() const { return touch_id_; }
110 float velocity_x() const { return velocity_x_; } 112 float velocity_x() const { return velocity_x_; }
111 float velocity_y() const { return velocity_y_; } 113 float velocity_y() const { return velocity_y_; }
112 const gfx::Rect& bounding_box() const { return bounding_box_; } 114 const gfx::Rect& bounding_box() const { return bounding_box_; }
115 int tap_count() const { return tap_count_; }
113 116
114 virtual ui::GestureStatus OnGestureEvent(GestureEvent* gesture) OVERRIDE { 117 virtual ui::GestureStatus OnGestureEvent(GestureEvent* gesture) OVERRIDE {
115 bounding_box_ = gesture->details().bounding_box(); 118 bounding_box_ = gesture->details().bounding_box();
116 switch (gesture->type()) { 119 switch (gesture->type()) {
117 case ui::ET_GESTURE_TAP: 120 case ui::ET_GESTURE_TAP:
118 tap_location_ = gesture->location(); 121 tap_location_ = gesture->location();
122 tap_count_ = gesture->details().tap_count();
119 tap_ = true; 123 tap_ = true;
120 break; 124 break;
121 case ui::ET_GESTURE_TAP_DOWN: 125 case ui::ET_GESTURE_TAP_DOWN:
122 tap_down_ = true; 126 tap_down_ = true;
123 break; 127 break;
124 case ui::ET_GESTURE_BEGIN: 128 case ui::ET_GESTURE_BEGIN:
125 begin_ = true; 129 begin_ = true;
126 break; 130 break;
127 case ui::ET_GESTURE_END: 131 case ui::ET_GESTURE_END:
128 end_ = true; 132 end_ = true;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 193
190 gfx::Point scroll_begin_position_; 194 gfx::Point scroll_begin_position_;
191 gfx::Point tap_location_; 195 gfx::Point tap_location_;
192 196
193 float scroll_x_; 197 float scroll_x_;
194 float scroll_y_; 198 float scroll_y_;
195 float velocity_x_; 199 float velocity_x_;
196 float velocity_y_; 200 float velocity_y_;
197 int touch_id_; 201 int touch_id_;
198 gfx::Rect bounding_box_; 202 gfx::Rect bounding_box_;
203 int tap_count_;
199 204
200 DISALLOW_COPY_AND_ASSIGN(GestureEventConsumeDelegate); 205 DISALLOW_COPY_AND_ASSIGN(GestureEventConsumeDelegate);
201 }; 206 };
202 207
203 class QueueTouchEventDelegate : public GestureEventConsumeDelegate { 208 class QueueTouchEventDelegate : public GestureEventConsumeDelegate {
204 public: 209 public:
205 explicit QueueTouchEventDelegate(RootWindow* root_window) 210 explicit QueueTouchEventDelegate(RootWindow* root_window)
206 : window_(NULL), 211 : window_(NULL),
207 root_window_(root_window) { 212 root_window_(root_window) {
208 } 213 }
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 429
425 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); 430 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release);
426 EXPECT_TRUE(delegate->tap()); 431 EXPECT_TRUE(delegate->tap());
427 EXPECT_FALSE(delegate->tap_down()); 432 EXPECT_FALSE(delegate->tap_down());
428 EXPECT_FALSE(delegate->begin()); 433 EXPECT_FALSE(delegate->begin());
429 EXPECT_TRUE(delegate->end()); 434 EXPECT_TRUE(delegate->end());
430 EXPECT_FALSE(delegate->double_tap()); 435 EXPECT_FALSE(delegate->double_tap());
431 EXPECT_FALSE(delegate->scroll_begin()); 436 EXPECT_FALSE(delegate->scroll_begin());
432 EXPECT_FALSE(delegate->scroll_update()); 437 EXPECT_FALSE(delegate->scroll_update());
433 EXPECT_FALSE(delegate->scroll_end()); 438 EXPECT_FALSE(delegate->scroll_end());
439
440 EXPECT_EQ(1, delegate->tap_count());
434 } 441 }
435 442
436 // Check that appropriate touch events generate tap gesture events 443 // Check that appropriate touch events generate tap gesture events
437 // when information about the touch radii are provided. 444 // when information about the touch radii are provided.
438 TEST_F(GestureRecognizerTest, GestureEventTapRegion) { 445 TEST_F(GestureRecognizerTest, GestureEventTapRegion) {
439 scoped_ptr<GestureEventConsumeDelegate> delegate( 446 scoped_ptr<GestureEventConsumeDelegate> delegate(
440 new GestureEventConsumeDelegate()); 447 new GestureEventConsumeDelegate());
441 const int kWindowWidth = 800; 448 const int kWindowWidth = 800;
442 const int kWindowHeight = 600; 449 const int kWindowHeight = 600;
443 const int kTouchId = 2; 450 const int kTouchId = 2;
(...skipping 30 matching lines...) Expand all
474 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); 481 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release);
475 EXPECT_TRUE(delegate->tap()); 482 EXPECT_TRUE(delegate->tap());
476 EXPECT_FALSE(delegate->tap_down()); 483 EXPECT_FALSE(delegate->tap_down());
477 EXPECT_FALSE(delegate->begin()); 484 EXPECT_FALSE(delegate->begin());
478 EXPECT_TRUE(delegate->end()); 485 EXPECT_TRUE(delegate->end());
479 EXPECT_FALSE(delegate->double_tap()); 486 EXPECT_FALSE(delegate->double_tap());
480 EXPECT_FALSE(delegate->scroll_begin()); 487 EXPECT_FALSE(delegate->scroll_begin());
481 EXPECT_FALSE(delegate->scroll_update()); 488 EXPECT_FALSE(delegate->scroll_update());
482 EXPECT_FALSE(delegate->scroll_end()); 489 EXPECT_FALSE(delegate->scroll_end());
483 490
491 EXPECT_EQ(1, delegate->tap_count());
484 gfx::Point actual_point(delegate->tap_location()); 492 gfx::Point actual_point(delegate->tap_location());
485 EXPECT_EQ(24, delegate->bounding_box().width()); 493 EXPECT_EQ(24, delegate->bounding_box().width());
486 EXPECT_EQ(24, delegate->bounding_box().height()); 494 EXPECT_EQ(24, delegate->bounding_box().height());
487 EXPECT_EQ(100, actual_point.x()); 495 EXPECT_EQ(100, actual_point.x());
488 EXPECT_EQ(200, actual_point.y()); 496 EXPECT_EQ(200, actual_point.y());
489 } 497 }
490 498
491 // Test with no ET_TOUCH_MOVED events but different touch points and radii. 499 // Test with no ET_TOUCH_MOVED events but different touch points and radii.
492 { 500 {
493 delegate->Reset(); 501 delegate->Reset();
(...skipping 21 matching lines...) Expand all
515 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); 523 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release);
516 EXPECT_TRUE(delegate->tap()); 524 EXPECT_TRUE(delegate->tap());
517 EXPECT_FALSE(delegate->tap_down()); 525 EXPECT_FALSE(delegate->tap_down());
518 EXPECT_FALSE(delegate->begin()); 526 EXPECT_FALSE(delegate->begin());
519 EXPECT_TRUE(delegate->end()); 527 EXPECT_TRUE(delegate->end());
520 EXPECT_FALSE(delegate->double_tap()); 528 EXPECT_FALSE(delegate->double_tap());
521 EXPECT_FALSE(delegate->scroll_begin()); 529 EXPECT_FALSE(delegate->scroll_begin());
522 EXPECT_FALSE(delegate->scroll_update()); 530 EXPECT_FALSE(delegate->scroll_update());
523 EXPECT_FALSE(delegate->scroll_end()); 531 EXPECT_FALSE(delegate->scroll_end());
524 532
533 EXPECT_EQ(1, delegate->tap_count());
525 gfx::Point actual_point(delegate->tap_location()); 534 gfx::Point actual_point(delegate->tap_location());
526 EXPECT_EQ(46, delegate->bounding_box().width()); 535 EXPECT_EQ(46, delegate->bounding_box().width());
527 EXPECT_EQ(40, delegate->bounding_box().height()); 536 EXPECT_EQ(40, delegate->bounding_box().height());
528 EXPECT_EQ(373, actual_point.x()); 537 EXPECT_EQ(373, actual_point.x());
529 EXPECT_EQ(290, actual_point.y()); 538 EXPECT_EQ(290, actual_point.y());
530 } 539 }
531 540
532 // Test with a single ET_TOUCH_MOVED event. 541 // Test with a single ET_TOUCH_MOVED event.
533 { 542 {
534 delegate->Reset(); 543 delegate->Reset();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); 581 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release);
573 EXPECT_TRUE(delegate->tap()); 582 EXPECT_TRUE(delegate->tap());
574 EXPECT_FALSE(delegate->tap_down()); 583 EXPECT_FALSE(delegate->tap_down());
575 EXPECT_FALSE(delegate->begin()); 584 EXPECT_FALSE(delegate->begin());
576 EXPECT_TRUE(delegate->end()); 585 EXPECT_TRUE(delegate->end());
577 EXPECT_FALSE(delegate->double_tap()); 586 EXPECT_FALSE(delegate->double_tap());
578 EXPECT_FALSE(delegate->scroll_begin()); 587 EXPECT_FALSE(delegate->scroll_begin());
579 EXPECT_FALSE(delegate->scroll_update()); 588 EXPECT_FALSE(delegate->scroll_update());
580 EXPECT_FALSE(delegate->scroll_end()); 589 EXPECT_FALSE(delegate->scroll_end());
581 590
591 EXPECT_EQ(1, delegate->tap_count());
582 gfx::Point actual_point(delegate->tap_location()); 592 gfx::Point actual_point(delegate->tap_location());
583 EXPECT_EQ(28, delegate->bounding_box().width()); 593 EXPECT_EQ(28, delegate->bounding_box().width());
584 EXPECT_EQ(28, delegate->bounding_box().height()); 594 EXPECT_EQ(28, delegate->bounding_box().height());
585 EXPECT_EQ(49, actual_point.x()); 595 EXPECT_EQ(49, actual_point.x());
586 EXPECT_EQ(200, actual_point.y()); 596 EXPECT_EQ(200, actual_point.y());
587 } 597 }
588 598
589 // Test with a few ET_TOUCH_MOVED events. 599 // Test with a few ET_TOUCH_MOVED events.
590 { 600 {
591 delegate->Reset(); 601 delegate->Reset();
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); 671 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release);
662 EXPECT_TRUE(delegate->tap()); 672 EXPECT_TRUE(delegate->tap());
663 EXPECT_FALSE(delegate->tap_down()); 673 EXPECT_FALSE(delegate->tap_down());
664 EXPECT_FALSE(delegate->begin()); 674 EXPECT_FALSE(delegate->begin());
665 EXPECT_TRUE(delegate->end()); 675 EXPECT_TRUE(delegate->end());
666 EXPECT_FALSE(delegate->double_tap()); 676 EXPECT_FALSE(delegate->double_tap());
667 EXPECT_FALSE(delegate->scroll_begin()); 677 EXPECT_FALSE(delegate->scroll_begin());
668 EXPECT_FALSE(delegate->scroll_update()); 678 EXPECT_FALSE(delegate->scroll_update());
669 EXPECT_FALSE(delegate->scroll_end()); 679 EXPECT_FALSE(delegate->scroll_end());
670 680
681 EXPECT_EQ(1, delegate->tap_count());
671 gfx::Point actual_point(delegate->tap_location()); 682 gfx::Point actual_point(delegate->tap_location());
672 EXPECT_EQ(35, delegate->bounding_box().width()); 683 EXPECT_EQ(35, delegate->bounding_box().width());
673 EXPECT_EQ(36, delegate->bounding_box().height()); 684 EXPECT_EQ(36, delegate->bounding_box().height());
674 EXPECT_EQ(396, actual_point.x()); 685 EXPECT_EQ(396, actual_point.x());
675 EXPECT_EQ(149, actual_point.y()); 686 EXPECT_EQ(149, actual_point.y());
676 } 687 }
677 } 688 }
678 689
679 // Check that appropriate touch events generate scroll gesture events. 690 // Check that appropriate touch events generate scroll gesture events.
680 TEST_F(GestureRecognizerTest, GestureEventScroll) { 691 TEST_F(GestureRecognizerTest, GestureEventScroll) {
(...skipping 1687 matching lines...) Expand 10 before | Expand all | Expand 10 after
2368 EXPECT_FALSE(delegate->tap()); 2379 EXPECT_FALSE(delegate->tap());
2369 EXPECT_FALSE(delegate->tap_down()); 2380 EXPECT_FALSE(delegate->tap_down());
2370 EXPECT_FALSE(delegate->begin()); 2381 EXPECT_FALSE(delegate->begin());
2371 EXPECT_TRUE(delegate->end()); 2382 EXPECT_TRUE(delegate->end());
2372 EXPECT_FALSE(delegate->double_tap()); 2383 EXPECT_FALSE(delegate->double_tap());
2373 EXPECT_FALSE(delegate->scroll_begin()); 2384 EXPECT_FALSE(delegate->scroll_begin());
2374 EXPECT_FALSE(delegate->scroll_update()); 2385 EXPECT_FALSE(delegate->scroll_update());
2375 EXPECT_TRUE(delegate->scroll_end()); 2386 EXPECT_TRUE(delegate->scroll_end());
2376 } 2387 }
2377 2388
2389 // Check that appropriate touch events generate double tap gesture events.
2390 TEST_F(GestureRecognizerTest, GestureEventDoubleTap) {
2391 scoped_ptr<GestureEventConsumeDelegate> delegate(
2392 new GestureEventConsumeDelegate());
2393 const int kWindowWidth = 123;
2394 const int kWindowHeight = 45;
2395 const int kTouchId = 2;
2396 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
2397 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
2398 delegate.get(), -1234, bounds, NULL));
2399
2400 // First tap (tested in GestureEventTap)
2401 TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(104, 201),
2402 kTouchId, GetTime());
2403 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1);
2404 TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(104, 201),
2405 kTouchId, press1.time_stamp() +
2406 base::TimeDelta::FromMilliseconds(50));
2407 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release1);
2408 delegate->Reset();
2409
2410 // Second tap
2411 TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(101, 203),
2412 kTouchId, release1.time_stamp() +
2413 base::TimeDelta::FromMilliseconds(200));
2414 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2);
2415 TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(102, 206),
2416 kTouchId, press2.time_stamp() +
2417 base::TimeDelta::FromMilliseconds(50));
2418 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release2);
2419
2420 EXPECT_TRUE(delegate->tap());
2421 EXPECT_TRUE(delegate->tap_down());
2422 EXPECT_TRUE(delegate->begin());
2423 EXPECT_TRUE(delegate->end());
2424 EXPECT_TRUE(delegate->double_tap());
2425 EXPECT_FALSE(delegate->scroll_begin());
2426 EXPECT_FALSE(delegate->scroll_update());
2427 EXPECT_FALSE(delegate->scroll_end());
2428
2429 EXPECT_EQ(2, delegate->tap_count());
2430 }
2431
2432 // Check that we don't get a double tap when the two taps are far apart.
2433 TEST_F(GestureRecognizerTest, TwoTapsFarApart) {
2434 scoped_ptr<GestureEventConsumeDelegate> delegate(
2435 new GestureEventConsumeDelegate());
2436 const int kWindowWidth = 123;
2437 const int kWindowHeight = 45;
2438 const int kTouchId = 2;
2439 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
2440 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
2441 delegate.get(), -1234, bounds, NULL));
2442
2443 // First tap (tested in GestureEventTap)
2444 TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
2445 kTouchId, GetTime());
2446 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1);
2447 TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201),
2448 kTouchId, press1.time_stamp() +
2449 base::TimeDelta::FromMilliseconds(50));
2450 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release1);
2451 delegate->Reset();
2452
2453 // Second tap, close in time but far in distance
2454 TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(201, 201),
2455 kTouchId, release1.time_stamp() +
2456 base::TimeDelta::FromMilliseconds(200));
2457 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2);
2458 TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(201, 201),
2459 kTouchId, press2.time_stamp() +
2460 base::TimeDelta::FromMilliseconds(50));
2461 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release2);
2462
2463 EXPECT_TRUE(delegate->tap());
2464 EXPECT_TRUE(delegate->tap_down());
2465 EXPECT_TRUE(delegate->begin());
2466 EXPECT_TRUE(delegate->end());
2467 EXPECT_FALSE(delegate->double_tap());
2468 EXPECT_FALSE(delegate->scroll_begin());
2469 EXPECT_FALSE(delegate->scroll_update());
2470 EXPECT_FALSE(delegate->scroll_end());
2471
2472 EXPECT_EQ(1, delegate->tap_count());
2473 }
2474
2475 // Check that we don't get a double tap when the two taps have a long enough
2476 // delay in between.
2477 TEST_F(GestureRecognizerTest, TwoTapsWithDelayBetween) {
2478 scoped_ptr<GestureEventConsumeDelegate> delegate(
2479 new GestureEventConsumeDelegate());
2480 const int kWindowWidth = 123;
2481 const int kWindowHeight = 45;
2482 const int kTouchId = 2;
2483 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
2484 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
2485 delegate.get(), -1234, bounds, NULL));
2486
2487 // First tap (tested in GestureEventTap)
2488 TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
2489 kTouchId, GetTime());
2490 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1);
2491 TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201),
2492 kTouchId, press1.time_stamp() +
2493 base::TimeDelta::FromMilliseconds(50));
2494 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release1);
2495 delegate->Reset();
2496
2497 // Second tap, close in distance but after some delay
2498 TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
2499 kTouchId, release1.time_stamp() +
2500 base::TimeDelta::FromMilliseconds(2000));
2501 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2);
2502 TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201),
2503 kTouchId, press2.time_stamp() +
2504 base::TimeDelta::FromMilliseconds(50));
2505 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release2);
2506
2507 EXPECT_TRUE(delegate->tap());
2508 EXPECT_TRUE(delegate->tap_down());
2509 EXPECT_TRUE(delegate->begin());
2510 EXPECT_TRUE(delegate->end());
2511 EXPECT_FALSE(delegate->double_tap());
2512 EXPECT_FALSE(delegate->scroll_begin());
2513 EXPECT_FALSE(delegate->scroll_update());
2514 EXPECT_FALSE(delegate->scroll_end());
2515
2516 EXPECT_EQ(1, delegate->tap_count());
2517 }
2518
2378 } // namespace test 2519 } // namespace test
2379 } // namespace aura 2520 } // namespace aura
OLDNEW
« no previous file with comments | « content/browser/renderer_host/web_input_event_aurax11.cc ('k') | ui/base/gestures/gesture_sequence.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698