| 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/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/root_window.h" | 9 #include "ui/aura/root_window.h" |
| 10 #include "ui/aura/test/aura_test_base.h" | 10 #include "ui/aura/test/aura_test_base.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 return consumer && !consumer->ignores_events() ? | 29 return consumer && !consumer->ignores_events() ? |
| 30 base::IntToString(static_cast<Window*>(consumer)->id()) : "?"; | 30 base::IntToString(static_cast<Window*>(consumer)->id()) : "?"; |
| 31 } | 31 } |
| 32 | 32 |
| 33 // A delegate that keeps track of gesture events. | 33 // A delegate that keeps track of gesture events. |
| 34 class GestureEventConsumeDelegate : public TestWindowDelegate { | 34 class GestureEventConsumeDelegate : public TestWindowDelegate { |
| 35 public: | 35 public: |
| 36 GestureEventConsumeDelegate() | 36 GestureEventConsumeDelegate() |
| 37 : tap_(false), | 37 : tap_(false), |
| 38 tap_down_(false), | 38 tap_down_(false), |
| 39 tap_cancel_(false), |
| 39 begin_(false), | 40 begin_(false), |
| 40 end_(false), | 41 end_(false), |
| 41 double_tap_(false), | 42 double_tap_(false), |
| 42 scroll_begin_(false), | 43 scroll_begin_(false), |
| 43 scroll_update_(false), | 44 scroll_update_(false), |
| 44 scroll_end_(false), | 45 scroll_end_(false), |
| 45 pinch_begin_(false), | 46 pinch_begin_(false), |
| 46 pinch_update_(false), | 47 pinch_update_(false), |
| 47 pinch_end_(false), | 48 pinch_end_(false), |
| 48 long_press_(false), | 49 long_press_(false), |
| (...skipping 10 matching lines...) Expand all Loading... |
| 59 velocity_x_(0), | 60 velocity_x_(0), |
| 60 velocity_y_(0), | 61 velocity_y_(0), |
| 61 tap_count_(0) { | 62 tap_count_(0) { |
| 62 } | 63 } |
| 63 | 64 |
| 64 virtual ~GestureEventConsumeDelegate() {} | 65 virtual ~GestureEventConsumeDelegate() {} |
| 65 | 66 |
| 66 void Reset() { | 67 void Reset() { |
| 67 tap_ = false; | 68 tap_ = false; |
| 68 tap_down_ = false; | 69 tap_down_ = false; |
| 70 tap_cancel_ = false; |
| 69 begin_ = false; | 71 begin_ = false; |
| 70 end_ = false; | 72 end_ = false; |
| 71 double_tap_ = false; | 73 double_tap_ = false; |
| 72 scroll_begin_ = false; | 74 scroll_begin_ = false; |
| 73 scroll_update_ = false; | 75 scroll_update_ = false; |
| 74 scroll_end_ = false; | 76 scroll_end_ = false; |
| 75 pinch_begin_ = false; | 77 pinch_begin_ = false; |
| 76 pinch_update_ = false; | 78 pinch_update_ = false; |
| 77 pinch_end_ = false; | 79 pinch_end_ = false; |
| 78 long_press_ = false; | 80 long_press_ = false; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 90 scroll_y_ = 0; | 92 scroll_y_ = 0; |
| 91 scroll_velocity_x_ = 0; | 93 scroll_velocity_x_ = 0; |
| 92 scroll_velocity_y_ = 0; | 94 scroll_velocity_y_ = 0; |
| 93 velocity_x_ = 0; | 95 velocity_x_ = 0; |
| 94 velocity_y_ = 0; | 96 velocity_y_ = 0; |
| 95 tap_count_ = 0; | 97 tap_count_ = 0; |
| 96 } | 98 } |
| 97 | 99 |
| 98 bool tap() const { return tap_; } | 100 bool tap() const { return tap_; } |
| 99 bool tap_down() const { return tap_down_; } | 101 bool tap_down() const { return tap_down_; } |
| 102 bool tap_cancel() const { return tap_cancel_; } |
| 100 bool begin() const { return begin_; } | 103 bool begin() const { return begin_; } |
| 101 bool end() const { return end_; } | 104 bool end() const { return end_; } |
| 102 bool double_tap() const { return double_tap_; } | 105 bool double_tap() const { return double_tap_; } |
| 103 bool scroll_begin() const { return scroll_begin_; } | 106 bool scroll_begin() const { return scroll_begin_; } |
| 104 bool scroll_update() const { return scroll_update_; } | 107 bool scroll_update() const { return scroll_update_; } |
| 105 bool scroll_end() const { return scroll_end_; } | 108 bool scroll_end() const { return scroll_end_; } |
| 106 bool pinch_begin() const { return pinch_begin_; } | 109 bool pinch_begin() const { return pinch_begin_; } |
| 107 bool pinch_update() const { return pinch_update_; } | 110 bool pinch_update() const { return pinch_update_; } |
| 108 bool pinch_end() const { return pinch_end_; } | 111 bool pinch_end() const { return pinch_end_; } |
| 109 bool long_press() const { return long_press_; } | 112 bool long_press() const { return long_press_; } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 137 bounding_box_ = gesture->details().bounding_box(); | 140 bounding_box_ = gesture->details().bounding_box(); |
| 138 switch (gesture->type()) { | 141 switch (gesture->type()) { |
| 139 case ui::ET_GESTURE_TAP: | 142 case ui::ET_GESTURE_TAP: |
| 140 tap_location_ = gesture->location(); | 143 tap_location_ = gesture->location(); |
| 141 tap_count_ = gesture->details().tap_count(); | 144 tap_count_ = gesture->details().tap_count(); |
| 142 tap_ = true; | 145 tap_ = true; |
| 143 break; | 146 break; |
| 144 case ui::ET_GESTURE_TAP_DOWN: | 147 case ui::ET_GESTURE_TAP_DOWN: |
| 145 tap_down_ = true; | 148 tap_down_ = true; |
| 146 break; | 149 break; |
| 150 case ui::ET_GESTURE_TAP_CANCEL: |
| 151 tap_cancel_ = true; |
| 152 break; |
| 147 case ui::ET_GESTURE_BEGIN: | 153 case ui::ET_GESTURE_BEGIN: |
| 148 begin_ = true; | 154 begin_ = true; |
| 149 break; | 155 break; |
| 150 case ui::ET_GESTURE_END: | 156 case ui::ET_GESTURE_END: |
| 151 end_ = true; | 157 end_ = true; |
| 152 break; | 158 break; |
| 153 case ui::ET_GESTURE_DOUBLE_TAP: | 159 case ui::ET_GESTURE_DOUBLE_TAP: |
| 154 double_tap_ = true; | 160 double_tap_ = true; |
| 155 break; | 161 break; |
| 156 case ui::ET_GESTURE_SCROLL_BEGIN: | 162 case ui::ET_GESTURE_SCROLL_BEGIN: |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 break; | 206 break; |
| 201 default: | 207 default: |
| 202 NOTREACHED(); | 208 NOTREACHED(); |
| 203 } | 209 } |
| 204 return ui::ER_CONSUMED; | 210 return ui::ER_CONSUMED; |
| 205 } | 211 } |
| 206 | 212 |
| 207 private: | 213 private: |
| 208 bool tap_; | 214 bool tap_; |
| 209 bool tap_down_; | 215 bool tap_down_; |
| 216 bool tap_cancel_; |
| 210 bool begin_; | 217 bool begin_; |
| 211 bool end_; | 218 bool end_; |
| 212 bool double_tap_; | 219 bool double_tap_; |
| 213 bool scroll_begin_; | 220 bool scroll_begin_; |
| 214 bool scroll_update_; | 221 bool scroll_update_; |
| 215 bool scroll_end_; | 222 bool scroll_end_; |
| 216 bool pinch_begin_; | 223 bool pinch_begin_; |
| 217 bool pinch_update_; | 224 bool pinch_update_; |
| 218 bool pinch_end_; | 225 bool pinch_end_; |
| 219 bool long_press_; | 226 bool long_press_; |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 453 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 447 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 454 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 448 delegate.get(), -1234, bounds, NULL)); | 455 delegate.get(), -1234, bounds, NULL)); |
| 449 | 456 |
| 450 delegate->Reset(); | 457 delegate->Reset(); |
| 451 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | 458 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
| 452 kTouchId, GetTime()); | 459 kTouchId, GetTime()); |
| 453 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); | 460 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); |
| 454 EXPECT_FALSE(delegate->tap()); | 461 EXPECT_FALSE(delegate->tap()); |
| 455 EXPECT_TRUE(delegate->tap_down()); | 462 EXPECT_TRUE(delegate->tap_down()); |
| 463 EXPECT_FALSE(delegate->tap_cancel()); |
| 456 EXPECT_TRUE(delegate->begin()); | 464 EXPECT_TRUE(delegate->begin()); |
| 457 EXPECT_FALSE(delegate->double_tap()); | 465 EXPECT_FALSE(delegate->double_tap()); |
| 458 EXPECT_FALSE(delegate->scroll_begin()); | 466 EXPECT_FALSE(delegate->scroll_begin()); |
| 459 EXPECT_FALSE(delegate->scroll_update()); | 467 EXPECT_FALSE(delegate->scroll_update()); |
| 460 EXPECT_FALSE(delegate->scroll_end()); | 468 EXPECT_FALSE(delegate->scroll_end()); |
| 461 EXPECT_FALSE(delegate->long_press()); | 469 EXPECT_FALSE(delegate->long_press()); |
| 462 | 470 |
| 463 // Make sure there is enough delay before the touch is released so that it is | 471 // Make sure there is enough delay before the touch is released so that it is |
| 464 // recognized as a tap. | 472 // recognized as a tap. |
| 465 delegate->Reset(); | 473 delegate->Reset(); |
| 466 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 474 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 467 kTouchId, press.time_stamp() + | 475 kTouchId, press.time_stamp() + |
| 468 base::TimeDelta::FromMilliseconds(50)); | 476 base::TimeDelta::FromMilliseconds(50)); |
| 469 | 477 |
| 470 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); | 478 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); |
| 471 EXPECT_TRUE(delegate->tap()); | 479 EXPECT_TRUE(delegate->tap()); |
| 472 EXPECT_FALSE(delegate->tap_down()); | 480 EXPECT_FALSE(delegate->tap_down()); |
| 481 EXPECT_FALSE(delegate->tap_cancel()); |
| 473 EXPECT_FALSE(delegate->begin()); | 482 EXPECT_FALSE(delegate->begin()); |
| 474 EXPECT_TRUE(delegate->end()); | 483 EXPECT_TRUE(delegate->end()); |
| 475 EXPECT_FALSE(delegate->double_tap()); | 484 EXPECT_FALSE(delegate->double_tap()); |
| 476 EXPECT_FALSE(delegate->scroll_begin()); | 485 EXPECT_FALSE(delegate->scroll_begin()); |
| 477 EXPECT_FALSE(delegate->scroll_update()); | 486 EXPECT_FALSE(delegate->scroll_update()); |
| 478 EXPECT_FALSE(delegate->scroll_end()); | 487 EXPECT_FALSE(delegate->scroll_end()); |
| 479 | 488 |
| 480 EXPECT_EQ(1, delegate->tap_count()); | 489 EXPECT_EQ(1, delegate->tap_count()); |
| 481 } | 490 } |
| 482 | 491 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 495 // Test with no ET_TOUCH_MOVED events. | 504 // Test with no ET_TOUCH_MOVED events. |
| 496 { | 505 { |
| 497 delegate->Reset(); | 506 delegate->Reset(); |
| 498 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | 507 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
| 499 kTouchId, GetTime()); | 508 kTouchId, GetTime()); |
| 500 press.set_radius_x(5); | 509 press.set_radius_x(5); |
| 501 press.set_radius_y(12); | 510 press.set_radius_y(12); |
| 502 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); | 511 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); |
| 503 EXPECT_FALSE(delegate->tap()); | 512 EXPECT_FALSE(delegate->tap()); |
| 504 EXPECT_TRUE(delegate->tap_down()); | 513 EXPECT_TRUE(delegate->tap_down()); |
| 514 EXPECT_FALSE(delegate->tap_cancel()); |
| 505 EXPECT_TRUE(delegate->begin()); | 515 EXPECT_TRUE(delegate->begin()); |
| 506 EXPECT_FALSE(delegate->double_tap()); | 516 EXPECT_FALSE(delegate->double_tap()); |
| 507 EXPECT_FALSE(delegate->scroll_begin()); | 517 EXPECT_FALSE(delegate->scroll_begin()); |
| 508 EXPECT_FALSE(delegate->scroll_update()); | 518 EXPECT_FALSE(delegate->scroll_update()); |
| 509 EXPECT_FALSE(delegate->scroll_end()); | 519 EXPECT_FALSE(delegate->scroll_end()); |
| 510 EXPECT_FALSE(delegate->long_press()); | 520 EXPECT_FALSE(delegate->long_press()); |
| 511 | 521 |
| 512 // Make sure there is enough delay before the touch is released so that it | 522 // Make sure there is enough delay before the touch is released so that it |
| 513 // is recognized as a tap. | 523 // is recognized as a tap. |
| 514 delegate->Reset(); | 524 delegate->Reset(); |
| 515 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 525 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 516 kTouchId, press.time_stamp() + | 526 kTouchId, press.time_stamp() + |
| 517 base::TimeDelta::FromMilliseconds(50)); | 527 base::TimeDelta::FromMilliseconds(50)); |
| 518 release.set_radius_x(5); | 528 release.set_radius_x(5); |
| 519 release.set_radius_y(12); | 529 release.set_radius_y(12); |
| 520 | 530 |
| 521 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); | 531 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); |
| 522 EXPECT_TRUE(delegate->tap()); | 532 EXPECT_TRUE(delegate->tap()); |
| 523 EXPECT_FALSE(delegate->tap_down()); | 533 EXPECT_FALSE(delegate->tap_down()); |
| 534 EXPECT_FALSE(delegate->tap_cancel()); |
| 524 EXPECT_FALSE(delegate->begin()); | 535 EXPECT_FALSE(delegate->begin()); |
| 525 EXPECT_TRUE(delegate->end()); | 536 EXPECT_TRUE(delegate->end()); |
| 526 EXPECT_FALSE(delegate->double_tap()); | 537 EXPECT_FALSE(delegate->double_tap()); |
| 527 EXPECT_FALSE(delegate->scroll_begin()); | 538 EXPECT_FALSE(delegate->scroll_begin()); |
| 528 EXPECT_FALSE(delegate->scroll_update()); | 539 EXPECT_FALSE(delegate->scroll_update()); |
| 529 EXPECT_FALSE(delegate->scroll_end()); | 540 EXPECT_FALSE(delegate->scroll_end()); |
| 530 | 541 |
| 531 EXPECT_EQ(1, delegate->tap_count()); | 542 EXPECT_EQ(1, delegate->tap_count()); |
| 532 gfx::Point actual_point(delegate->tap_location()); | 543 gfx::Point actual_point(delegate->tap_location()); |
| 533 EXPECT_EQ(24, delegate->bounding_box().width()); | 544 EXPECT_EQ(24, delegate->bounding_box().width()); |
| 534 EXPECT_EQ(24, delegate->bounding_box().height()); | 545 EXPECT_EQ(24, delegate->bounding_box().height()); |
| 535 EXPECT_EQ(100, actual_point.x()); | 546 EXPECT_EQ(100, actual_point.x()); |
| 536 EXPECT_EQ(200, actual_point.y()); | 547 EXPECT_EQ(200, actual_point.y()); |
| 537 } | 548 } |
| 538 | 549 |
| 539 // Test with no ET_TOUCH_MOVED events but different touch points and radii. | 550 // Test with no ET_TOUCH_MOVED events but different touch points and radii. |
| 540 { | 551 { |
| 541 delegate->Reset(); | 552 delegate->Reset(); |
| 542 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(365, 290), | 553 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(365, 290), |
| 543 kTouchId, GetTime()); | 554 kTouchId, GetTime()); |
| 544 press.set_radius_x(8); | 555 press.set_radius_x(8); |
| 545 press.set_radius_y(14); | 556 press.set_radius_y(14); |
| 546 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); | 557 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); |
| 547 EXPECT_FALSE(delegate->tap()); | 558 EXPECT_FALSE(delegate->tap()); |
| 548 EXPECT_TRUE(delegate->tap_down()); | 559 EXPECT_TRUE(delegate->tap_down()); |
| 560 EXPECT_FALSE(delegate->tap_cancel()); |
| 549 EXPECT_TRUE(delegate->begin()); | 561 EXPECT_TRUE(delegate->begin()); |
| 550 EXPECT_FALSE(delegate->double_tap()); | 562 EXPECT_FALSE(delegate->double_tap()); |
| 551 EXPECT_FALSE(delegate->scroll_begin()); | 563 EXPECT_FALSE(delegate->scroll_begin()); |
| 552 EXPECT_FALSE(delegate->scroll_update()); | 564 EXPECT_FALSE(delegate->scroll_update()); |
| 553 EXPECT_FALSE(delegate->scroll_end()); | 565 EXPECT_FALSE(delegate->scroll_end()); |
| 554 EXPECT_FALSE(delegate->long_press()); | 566 EXPECT_FALSE(delegate->long_press()); |
| 555 | 567 |
| 556 delegate->Reset(); | 568 delegate->Reset(); |
| 557 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(367, 291), | 569 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(367, 291), |
| 558 kTouchId, press.time_stamp() + | 570 kTouchId, press.time_stamp() + |
| 559 base::TimeDelta::FromMilliseconds(50)); | 571 base::TimeDelta::FromMilliseconds(50)); |
| 560 release.set_radius_x(20); | 572 release.set_radius_x(20); |
| 561 release.set_radius_y(13); | 573 release.set_radius_y(13); |
| 562 | 574 |
| 563 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); | 575 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); |
| 564 EXPECT_TRUE(delegate->tap()); | 576 EXPECT_TRUE(delegate->tap()); |
| 565 EXPECT_FALSE(delegate->tap_down()); | 577 EXPECT_FALSE(delegate->tap_down()); |
| 578 EXPECT_FALSE(delegate->tap_cancel()); |
| 566 EXPECT_FALSE(delegate->begin()); | 579 EXPECT_FALSE(delegate->begin()); |
| 567 EXPECT_TRUE(delegate->end()); | 580 EXPECT_TRUE(delegate->end()); |
| 568 EXPECT_FALSE(delegate->double_tap()); | 581 EXPECT_FALSE(delegate->double_tap()); |
| 569 EXPECT_FALSE(delegate->scroll_begin()); | 582 EXPECT_FALSE(delegate->scroll_begin()); |
| 570 EXPECT_FALSE(delegate->scroll_update()); | 583 EXPECT_FALSE(delegate->scroll_update()); |
| 571 EXPECT_FALSE(delegate->scroll_end()); | 584 EXPECT_FALSE(delegate->scroll_end()); |
| 572 | 585 |
| 573 EXPECT_EQ(1, delegate->tap_count()); | 586 EXPECT_EQ(1, delegate->tap_count()); |
| 574 gfx::Point actual_point(delegate->tap_location()); | 587 gfx::Point actual_point(delegate->tap_location()); |
| 575 EXPECT_EQ(40, delegate->bounding_box().width()); | 588 EXPECT_EQ(40, delegate->bounding_box().width()); |
| 576 EXPECT_EQ(40, delegate->bounding_box().height()); | 589 EXPECT_EQ(40, delegate->bounding_box().height()); |
| 577 EXPECT_EQ(366, actual_point.x()); | 590 EXPECT_EQ(366, actual_point.x()); |
| 578 EXPECT_EQ(290, actual_point.y()); | 591 EXPECT_EQ(290, actual_point.y()); |
| 579 } | 592 } |
| 580 | 593 |
| 581 // Test with a single ET_TOUCH_MOVED event. | 594 // Test with a single ET_TOUCH_MOVED event. |
| 582 { | 595 { |
| 583 delegate->Reset(); | 596 delegate->Reset(); |
| 584 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(46, 205), | 597 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(46, 205), |
| 585 kTouchId, GetTime()); | 598 kTouchId, GetTime()); |
| 586 press.set_radius_x(6); | 599 press.set_radius_x(6); |
| 587 press.set_radius_y(10); | 600 press.set_radius_y(10); |
| 588 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); | 601 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); |
| 589 EXPECT_FALSE(delegate->tap()); | 602 EXPECT_FALSE(delegate->tap()); |
| 590 EXPECT_TRUE(delegate->tap_down()); | 603 EXPECT_TRUE(delegate->tap_down()); |
| 604 EXPECT_FALSE(delegate->tap_cancel()); |
| 591 EXPECT_TRUE(delegate->begin()); | 605 EXPECT_TRUE(delegate->begin()); |
| 606 EXPECT_FALSE(delegate->tap_cancel()); |
| 592 EXPECT_FALSE(delegate->double_tap()); | 607 EXPECT_FALSE(delegate->double_tap()); |
| 593 EXPECT_FALSE(delegate->scroll_begin()); | 608 EXPECT_FALSE(delegate->scroll_begin()); |
| 594 EXPECT_FALSE(delegate->scroll_update()); | 609 EXPECT_FALSE(delegate->scroll_update()); |
| 595 EXPECT_FALSE(delegate->scroll_end()); | 610 EXPECT_FALSE(delegate->scroll_end()); |
| 596 EXPECT_FALSE(delegate->long_press()); | 611 EXPECT_FALSE(delegate->long_press()); |
| 597 | 612 |
| 598 delegate->Reset(); | 613 delegate->Reset(); |
| 599 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(49, 204), | 614 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(49, 204), |
| 600 kTouchId, press.time_stamp() + | 615 kTouchId, press.time_stamp() + |
| 601 base::TimeDelta::FromMilliseconds(50)); | 616 base::TimeDelta::FromMilliseconds(50)); |
| 602 move.set_radius_x(8); | 617 move.set_radius_x(8); |
| 603 move.set_radius_y(12); | 618 move.set_radius_y(12); |
| 604 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move); | 619 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move); |
| 605 EXPECT_FALSE(delegate->tap()); | 620 EXPECT_FALSE(delegate->tap()); |
| 606 EXPECT_FALSE(delegate->tap_down()); | 621 EXPECT_FALSE(delegate->tap_down()); |
| 622 EXPECT_FALSE(delegate->tap_cancel()); |
| 607 EXPECT_FALSE(delegate->begin()); | 623 EXPECT_FALSE(delegate->begin()); |
| 608 EXPECT_FALSE(delegate->double_tap()); | 624 EXPECT_FALSE(delegate->double_tap()); |
| 609 EXPECT_FALSE(delegate->scroll_begin()); | 625 EXPECT_FALSE(delegate->scroll_begin()); |
| 610 EXPECT_FALSE(delegate->scroll_update()); | 626 EXPECT_FALSE(delegate->scroll_update()); |
| 611 EXPECT_FALSE(delegate->scroll_end()); | 627 EXPECT_FALSE(delegate->scroll_end()); |
| 612 EXPECT_FALSE(delegate->long_press()); | 628 EXPECT_FALSE(delegate->long_press()); |
| 613 | 629 |
| 614 delegate->Reset(); | 630 delegate->Reset(); |
| 615 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(49, 204), | 631 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(49, 204), |
| 616 kTouchId, press.time_stamp() + | 632 kTouchId, press.time_stamp() + |
| 617 base::TimeDelta::FromMilliseconds(50)); | 633 base::TimeDelta::FromMilliseconds(50)); |
| 618 release.set_radius_x(4); | 634 release.set_radius_x(4); |
| 619 release.set_radius_y(8); | 635 release.set_radius_y(8); |
| 620 | 636 |
| 621 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); | 637 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); |
| 622 EXPECT_TRUE(delegate->tap()); | 638 EXPECT_TRUE(delegate->tap()); |
| 623 EXPECT_FALSE(delegate->tap_down()); | 639 EXPECT_FALSE(delegate->tap_down()); |
| 640 EXPECT_FALSE(delegate->tap_cancel()); |
| 624 EXPECT_FALSE(delegate->begin()); | 641 EXPECT_FALSE(delegate->begin()); |
| 625 EXPECT_TRUE(delegate->end()); | 642 EXPECT_TRUE(delegate->end()); |
| 626 EXPECT_FALSE(delegate->double_tap()); | 643 EXPECT_FALSE(delegate->double_tap()); |
| 627 EXPECT_FALSE(delegate->scroll_begin()); | 644 EXPECT_FALSE(delegate->scroll_begin()); |
| 628 EXPECT_FALSE(delegate->scroll_update()); | 645 EXPECT_FALSE(delegate->scroll_update()); |
| 629 EXPECT_FALSE(delegate->scroll_end()); | 646 EXPECT_FALSE(delegate->scroll_end()); |
| 630 | 647 |
| 631 EXPECT_EQ(1, delegate->tap_count()); | 648 EXPECT_EQ(1, delegate->tap_count()); |
| 632 gfx::Point actual_point(delegate->tap_location()); | 649 gfx::Point actual_point(delegate->tap_location()); |
| 633 EXPECT_EQ(25, delegate->bounding_box().width()); | 650 EXPECT_EQ(25, delegate->bounding_box().width()); |
| 634 EXPECT_EQ(24, delegate->bounding_box().height()); | 651 EXPECT_EQ(24, delegate->bounding_box().height()); |
| 635 EXPECT_EQ(48, actual_point.x()); | 652 EXPECT_EQ(48, actual_point.x()); |
| 636 EXPECT_EQ(203, actual_point.y()); | 653 EXPECT_EQ(203, actual_point.y()); |
| 637 } | 654 } |
| 638 | 655 |
| 639 // Test with a few ET_TOUCH_MOVED events. | 656 // Test with a few ET_TOUCH_MOVED events. |
| 640 { | 657 { |
| 641 delegate->Reset(); | 658 delegate->Reset(); |
| 642 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(400, 150), | 659 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(400, 150), |
| 643 kTouchId, GetTime()); | 660 kTouchId, GetTime()); |
| 644 press.set_radius_x(7); | 661 press.set_radius_x(7); |
| 645 press.set_radius_y(10); | 662 press.set_radius_y(10); |
| 646 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); | 663 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); |
| 647 EXPECT_FALSE(delegate->tap()); | 664 EXPECT_FALSE(delegate->tap()); |
| 648 EXPECT_TRUE(delegate->tap_down()); | 665 EXPECT_TRUE(delegate->tap_down()); |
| 666 EXPECT_FALSE(delegate->tap_cancel()); |
| 649 EXPECT_TRUE(delegate->begin()); | 667 EXPECT_TRUE(delegate->begin()); |
| 650 EXPECT_FALSE(delegate->double_tap()); | 668 EXPECT_FALSE(delegate->double_tap()); |
| 651 EXPECT_FALSE(delegate->scroll_begin()); | 669 EXPECT_FALSE(delegate->scroll_begin()); |
| 652 EXPECT_FALSE(delegate->scroll_update()); | 670 EXPECT_FALSE(delegate->scroll_update()); |
| 653 EXPECT_FALSE(delegate->scroll_end()); | 671 EXPECT_FALSE(delegate->scroll_end()); |
| 654 EXPECT_FALSE(delegate->long_press()); | 672 EXPECT_FALSE(delegate->long_press()); |
| 655 | 673 |
| 656 delegate->Reset(); | 674 delegate->Reset(); |
| 657 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(397, 151), | 675 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(397, 151), |
| 658 kTouchId, press.time_stamp() + | 676 kTouchId, press.time_stamp() + |
| 659 base::TimeDelta::FromMilliseconds(50)); | 677 base::TimeDelta::FromMilliseconds(50)); |
| 660 move.set_radius_x(13); | 678 move.set_radius_x(13); |
| 661 move.set_radius_y(12); | 679 move.set_radius_y(12); |
| 662 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move); | 680 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move); |
| 663 EXPECT_FALSE(delegate->tap()); | 681 EXPECT_FALSE(delegate->tap()); |
| 664 EXPECT_FALSE(delegate->tap_down()); | 682 EXPECT_FALSE(delegate->tap_down()); |
| 683 EXPECT_FALSE(delegate->tap_cancel()); |
| 665 EXPECT_FALSE(delegate->begin()); | 684 EXPECT_FALSE(delegate->begin()); |
| 666 EXPECT_FALSE(delegate->double_tap()); | 685 EXPECT_FALSE(delegate->double_tap()); |
| 667 EXPECT_FALSE(delegate->scroll_begin()); | 686 EXPECT_FALSE(delegate->scroll_begin()); |
| 668 EXPECT_FALSE(delegate->scroll_update()); | 687 EXPECT_FALSE(delegate->scroll_update()); |
| 669 EXPECT_FALSE(delegate->scroll_end()); | 688 EXPECT_FALSE(delegate->scroll_end()); |
| 670 EXPECT_FALSE(delegate->long_press()); | 689 EXPECT_FALSE(delegate->long_press()); |
| 671 | 690 |
| 672 delegate->Reset(); | 691 delegate->Reset(); |
| 673 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(397, 149), | 692 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(397, 149), |
| 674 kTouchId, move.time_stamp() + | 693 kTouchId, move.time_stamp() + |
| 675 base::TimeDelta::FromMilliseconds(50)); | 694 base::TimeDelta::FromMilliseconds(50)); |
| 676 move1.set_radius_x(16); | 695 move1.set_radius_x(16); |
| 677 move1.set_radius_y(16); | 696 move1.set_radius_y(16); |
| 678 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move1); | 697 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move1); |
| 679 EXPECT_FALSE(delegate->tap()); | 698 EXPECT_FALSE(delegate->tap()); |
| 680 EXPECT_FALSE(delegate->tap_down()); | 699 EXPECT_FALSE(delegate->tap_down()); |
| 700 EXPECT_FALSE(delegate->tap_cancel()); |
| 681 EXPECT_FALSE(delegate->begin()); | 701 EXPECT_FALSE(delegate->begin()); |
| 682 EXPECT_FALSE(delegate->double_tap()); | 702 EXPECT_FALSE(delegate->double_tap()); |
| 683 EXPECT_FALSE(delegate->scroll_begin()); | 703 EXPECT_FALSE(delegate->scroll_begin()); |
| 684 EXPECT_FALSE(delegate->scroll_update()); | 704 EXPECT_FALSE(delegate->scroll_update()); |
| 685 EXPECT_FALSE(delegate->scroll_end()); | 705 EXPECT_FALSE(delegate->scroll_end()); |
| 686 EXPECT_FALSE(delegate->long_press()); | 706 EXPECT_FALSE(delegate->long_press()); |
| 687 | 707 |
| 688 delegate->Reset(); | 708 delegate->Reset(); |
| 689 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(400, 150), | 709 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(400, 150), |
| 690 kTouchId, move1.time_stamp() + | 710 kTouchId, move1.time_stamp() + |
| 691 base::TimeDelta::FromMilliseconds(50)); | 711 base::TimeDelta::FromMilliseconds(50)); |
| 692 move2.set_radius_x(14); | 712 move2.set_radius_x(14); |
| 693 move2.set_radius_y(10); | 713 move2.set_radius_y(10); |
| 694 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move2); | 714 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move2); |
| 695 EXPECT_FALSE(delegate->tap()); | 715 EXPECT_FALSE(delegate->tap()); |
| 696 EXPECT_FALSE(delegate->tap_down()); | 716 EXPECT_FALSE(delegate->tap_down()); |
| 717 EXPECT_FALSE(delegate->tap_cancel()); |
| 697 EXPECT_FALSE(delegate->begin()); | 718 EXPECT_FALSE(delegate->begin()); |
| 698 EXPECT_FALSE(delegate->double_tap()); | 719 EXPECT_FALSE(delegate->double_tap()); |
| 699 EXPECT_FALSE(delegate->scroll_begin()); | 720 EXPECT_FALSE(delegate->scroll_begin()); |
| 700 EXPECT_FALSE(delegate->scroll_update()); | 721 EXPECT_FALSE(delegate->scroll_update()); |
| 701 EXPECT_FALSE(delegate->scroll_end()); | 722 EXPECT_FALSE(delegate->scroll_end()); |
| 702 EXPECT_FALSE(delegate->long_press()); | 723 EXPECT_FALSE(delegate->long_press()); |
| 703 | 724 |
| 704 delegate->Reset(); | 725 delegate->Reset(); |
| 705 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(401, 149), | 726 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(401, 149), |
| 706 kTouchId, press.time_stamp() + | 727 kTouchId, press.time_stamp() + |
| 707 base::TimeDelta::FromMilliseconds(50)); | 728 base::TimeDelta::FromMilliseconds(50)); |
| 708 release.set_radius_x(8); | 729 release.set_radius_x(8); |
| 709 release.set_radius_y(9); | 730 release.set_radius_y(9); |
| 710 | 731 |
| 711 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); | 732 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); |
| 712 EXPECT_TRUE(delegate->tap()); | 733 EXPECT_TRUE(delegate->tap()); |
| 713 EXPECT_FALSE(delegate->tap_down()); | 734 EXPECT_FALSE(delegate->tap_down()); |
| 735 EXPECT_FALSE(delegate->tap_cancel()); |
| 714 EXPECT_FALSE(delegate->begin()); | 736 EXPECT_FALSE(delegate->begin()); |
| 715 EXPECT_TRUE(delegate->end()); | 737 EXPECT_TRUE(delegate->end()); |
| 716 EXPECT_FALSE(delegate->double_tap()); | 738 EXPECT_FALSE(delegate->double_tap()); |
| 717 EXPECT_FALSE(delegate->scroll_begin()); | 739 EXPECT_FALSE(delegate->scroll_begin()); |
| 718 EXPECT_FALSE(delegate->scroll_update()); | 740 EXPECT_FALSE(delegate->scroll_update()); |
| 719 EXPECT_FALSE(delegate->scroll_end()); | 741 EXPECT_FALSE(delegate->scroll_end()); |
| 720 | 742 |
| 721 EXPECT_EQ(1, delegate->tap_count()); | 743 EXPECT_EQ(1, delegate->tap_count()); |
| 722 gfx::Point actual_point(delegate->tap_location()); | 744 gfx::Point actual_point(delegate->tap_location()); |
| 723 EXPECT_EQ(33, delegate->bounding_box().width()); | 745 EXPECT_EQ(33, delegate->bounding_box().width()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 737 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 759 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 738 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 760 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 739 delegate.get(), -1234, bounds, NULL)); | 761 delegate.get(), -1234, bounds, NULL)); |
| 740 | 762 |
| 741 delegate->Reset(); | 763 delegate->Reset(); |
| 742 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | 764 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
| 743 kTouchId, GetTime()); | 765 kTouchId, GetTime()); |
| 744 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); | 766 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); |
| 745 EXPECT_FALSE(delegate->tap()); | 767 EXPECT_FALSE(delegate->tap()); |
| 746 EXPECT_TRUE(delegate->tap_down()); | 768 EXPECT_TRUE(delegate->tap_down()); |
| 769 EXPECT_FALSE(delegate->tap_cancel()); |
| 747 EXPECT_TRUE(delegate->begin()); | 770 EXPECT_TRUE(delegate->begin()); |
| 748 EXPECT_FALSE(delegate->double_tap()); | 771 EXPECT_FALSE(delegate->double_tap()); |
| 749 EXPECT_FALSE(delegate->scroll_begin()); | 772 EXPECT_FALSE(delegate->scroll_begin()); |
| 750 EXPECT_FALSE(delegate->scroll_update()); | 773 EXPECT_FALSE(delegate->scroll_update()); |
| 751 EXPECT_FALSE(delegate->scroll_end()); | 774 EXPECT_FALSE(delegate->scroll_end()); |
| 752 | 775 |
| 753 // Move the touch-point enough so that it is considered as a scroll. This | 776 // Move the touch-point enough so that it is considered as a scroll. This |
| 754 // should generate both SCROLL_BEGIN and SCROLL_UPDATE gestures. | 777 // should generate both SCROLL_BEGIN and SCROLL_UPDATE gestures. |
| 755 // The first movement is diagonal, to ensure that we have a free scroll, | 778 // The first movement is diagonal, to ensure that we have a free scroll, |
| 756 // and not a rail scroll. | 779 // and not a rail scroll. |
| 757 SendScrollEvent(root_window(), 130, 230, kTouchId, delegate.get()); | 780 SendScrollEvent(root_window(), 130, 230, kTouchId, delegate.get()); |
| 758 EXPECT_FALSE(delegate->tap()); | 781 EXPECT_FALSE(delegate->tap()); |
| 759 EXPECT_FALSE(delegate->tap_down()); | 782 EXPECT_FALSE(delegate->tap_down()); |
| 783 EXPECT_TRUE(delegate->tap_cancel()); |
| 760 EXPECT_FALSE(delegate->begin()); | 784 EXPECT_FALSE(delegate->begin()); |
| 761 EXPECT_FALSE(delegate->double_tap()); | 785 EXPECT_FALSE(delegate->double_tap()); |
| 762 EXPECT_TRUE(delegate->scroll_begin()); | 786 EXPECT_TRUE(delegate->scroll_begin()); |
| 763 EXPECT_TRUE(delegate->scroll_update()); | 787 EXPECT_TRUE(delegate->scroll_update()); |
| 764 EXPECT_FALSE(delegate->scroll_end()); | 788 EXPECT_FALSE(delegate->scroll_end()); |
| 765 EXPECT_EQ(29, delegate->scroll_x()); | 789 EXPECT_EQ(29, delegate->scroll_x()); |
| 766 EXPECT_EQ(29, delegate->scroll_y()); | 790 EXPECT_EQ(29, delegate->scroll_y()); |
| 767 EXPECT_EQ(0, delegate->scroll_velocity_x()); | 791 EXPECT_EQ(0, delegate->scroll_velocity_x()); |
| 768 EXPECT_EQ(0, delegate->scroll_velocity_y()); | 792 EXPECT_EQ(0, delegate->scroll_velocity_y()); |
| 769 EXPECT_EQ(gfx::Point(1, 1).ToString(), | 793 EXPECT_EQ(gfx::Point(1, 1).ToString(), |
| 770 delegate->scroll_begin_position().ToString()); | 794 delegate->scroll_begin_position().ToString()); |
| 771 | 795 |
| 772 // When scrolling with a single finger, the bounding box of the gesture should | 796 // When scrolling with a single finger, the bounding box of the gesture should |
| 773 // be empty, since it's a single point and the radius for testing is zero. | 797 // be empty, since it's a single point and the radius for testing is zero. |
| 774 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); | 798 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); |
| 775 | 799 |
| 776 // Move some more to generate a few more scroll updates. | 800 // Move some more to generate a few more scroll updates. |
| 777 SendScrollEvent(root_window(), 110, 211, kTouchId, delegate.get()); | 801 SendScrollEvent(root_window(), 110, 211, kTouchId, delegate.get()); |
| 778 EXPECT_FALSE(delegate->tap()); | 802 EXPECT_FALSE(delegate->tap()); |
| 779 EXPECT_FALSE(delegate->tap_down()); | 803 EXPECT_FALSE(delegate->tap_down()); |
| 804 EXPECT_FALSE(delegate->tap_cancel()); |
| 780 EXPECT_FALSE(delegate->begin()); | 805 EXPECT_FALSE(delegate->begin()); |
| 781 EXPECT_FALSE(delegate->double_tap()); | 806 EXPECT_FALSE(delegate->double_tap()); |
| 782 EXPECT_FALSE(delegate->scroll_begin()); | 807 EXPECT_FALSE(delegate->scroll_begin()); |
| 783 EXPECT_TRUE(delegate->scroll_update()); | 808 EXPECT_TRUE(delegate->scroll_update()); |
| 784 EXPECT_FALSE(delegate->scroll_end()); | 809 EXPECT_FALSE(delegate->scroll_end()); |
| 785 EXPECT_EQ(-20, delegate->scroll_x()); | 810 EXPECT_EQ(-20, delegate->scroll_x()); |
| 786 EXPECT_EQ(-19, delegate->scroll_y()); | 811 EXPECT_EQ(-19, delegate->scroll_y()); |
| 787 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); | 812 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); |
| 788 | 813 |
| 789 SendScrollEvent(root_window(), 140, 215, kTouchId, delegate.get()); | 814 SendScrollEvent(root_window(), 140, 215, kTouchId, delegate.get()); |
| 790 EXPECT_FALSE(delegate->tap()); | 815 EXPECT_FALSE(delegate->tap()); |
| 791 EXPECT_FALSE(delegate->tap_down()); | 816 EXPECT_FALSE(delegate->tap_down()); |
| 817 EXPECT_FALSE(delegate->tap_cancel()); |
| 792 EXPECT_FALSE(delegate->begin()); | 818 EXPECT_FALSE(delegate->begin()); |
| 793 EXPECT_FALSE(delegate->double_tap()); | 819 EXPECT_FALSE(delegate->double_tap()); |
| 794 EXPECT_FALSE(delegate->scroll_begin()); | 820 EXPECT_FALSE(delegate->scroll_begin()); |
| 795 EXPECT_TRUE(delegate->scroll_update()); | 821 EXPECT_TRUE(delegate->scroll_update()); |
| 796 EXPECT_FALSE(delegate->scroll_end()); | 822 EXPECT_FALSE(delegate->scroll_end()); |
| 797 EXPECT_EQ(30, delegate->scroll_x()); | 823 EXPECT_EQ(30, delegate->scroll_x()); |
| 798 EXPECT_EQ(4, delegate->scroll_y()); | 824 EXPECT_EQ(4, delegate->scroll_y()); |
| 799 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); | 825 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); |
| 800 | 826 |
| 801 // Release the touch. This should end the scroll. | 827 // Release the touch. This should end the scroll. |
| 802 delegate->Reset(); | 828 delegate->Reset(); |
| 803 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 829 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 804 kTouchId, press.time_stamp() + | 830 kTouchId, press.time_stamp() + |
| 805 base::TimeDelta::FromMilliseconds(50)); | 831 base::TimeDelta::FromMilliseconds(50)); |
| 806 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); | 832 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); |
| 807 EXPECT_FALSE(delegate->tap()); | 833 EXPECT_FALSE(delegate->tap()); |
| 808 EXPECT_FALSE(delegate->tap_down()); | 834 EXPECT_FALSE(delegate->tap_down()); |
| 835 EXPECT_FALSE(delegate->tap_cancel()); |
| 809 EXPECT_FALSE(delegate->begin()); | 836 EXPECT_FALSE(delegate->begin()); |
| 810 EXPECT_TRUE(delegate->end()); | 837 EXPECT_TRUE(delegate->end()); |
| 811 EXPECT_FALSE(delegate->double_tap()); | 838 EXPECT_FALSE(delegate->double_tap()); |
| 812 EXPECT_FALSE(delegate->scroll_begin()); | 839 EXPECT_FALSE(delegate->scroll_begin()); |
| 813 EXPECT_FALSE(delegate->scroll_update()); | 840 EXPECT_FALSE(delegate->scroll_update()); |
| 814 EXPECT_TRUE(delegate->scroll_end()); | 841 EXPECT_TRUE(delegate->scroll_end()); |
| 815 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); | 842 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); |
| 816 } | 843 } |
| 817 | 844 |
| 818 // Check that the bounding box during a scroll event is correct. | 845 // Check that the bounding box during a scroll event is correct. |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1005 static_cast<TimerTestGestureSequence*>( | 1032 static_cast<TimerTestGestureSequence*>( |
| 1006 gesture_recognizer->GetGestureSequenceForTesting(window.get())); | 1033 gesture_recognizer->GetGestureSequenceForTesting(window.get())); |
| 1007 | 1034 |
| 1008 root_window()->SetGestureRecognizerForTesting(gesture_recognizer); | 1035 root_window()->SetGestureRecognizerForTesting(gesture_recognizer); |
| 1009 | 1036 |
| 1010 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | 1037 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
| 1011 kTouchId, GetTime()); | 1038 kTouchId, GetTime()); |
| 1012 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1); | 1039 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1); |
| 1013 EXPECT_TRUE(delegate->tap_down()); | 1040 EXPECT_TRUE(delegate->tap_down()); |
| 1014 EXPECT_TRUE(delegate->begin()); | 1041 EXPECT_TRUE(delegate->begin()); |
| 1042 EXPECT_FALSE(delegate->tap_cancel()); |
| 1015 | 1043 |
| 1016 // We haven't pressed long enough for a long press to occur | 1044 // We haven't pressed long enough for a long press to occur |
| 1017 EXPECT_FALSE(delegate->long_press()); | 1045 EXPECT_FALSE(delegate->long_press()); |
| 1018 | 1046 |
| 1019 // Wait until the timer runs out | 1047 // Wait until the timer runs out |
| 1020 gesture_sequence->ForceTimeout(); | 1048 gesture_sequence->ForceTimeout(); |
| 1021 EXPECT_TRUE(delegate->long_press()); | 1049 EXPECT_TRUE(delegate->long_press()); |
| 1022 EXPECT_EQ(0, delegate->touch_id()); | 1050 EXPECT_EQ(0, delegate->touch_id()); |
| 1051 EXPECT_FALSE(delegate->tap_cancel()); |
| 1023 | 1052 |
| 1024 delegate->Reset(); | 1053 delegate->Reset(); |
| 1025 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 1054 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 1026 kTouchId, GetTime()); | 1055 kTouchId, GetTime()); |
| 1027 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release1); | 1056 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release1); |
| 1028 EXPECT_FALSE(delegate->long_press()); | 1057 EXPECT_FALSE(delegate->long_press()); |
| 1058 |
| 1059 // Note the tap down isn't cancelled until the release |
| 1060 EXPECT_TRUE(delegate->tap_cancel()); |
| 1029 } | 1061 } |
| 1030 | 1062 |
| 1031 // Check that scrolling cancels a long press | 1063 // Check that scrolling cancels a long press |
| 1032 TEST_F(GestureRecognizerTest, GestureEventLongPressCancelledByScroll) { | 1064 TEST_F(GestureRecognizerTest, GestureEventLongPressCancelledByScroll) { |
| 1033 scoped_ptr<GestureEventConsumeDelegate> delegate( | 1065 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 1034 new GestureEventConsumeDelegate()); | 1066 new GestureEventConsumeDelegate()); |
| 1035 const int kWindowWidth = 123; | 1067 const int kWindowWidth = 123; |
| 1036 const int kWindowHeight = 45; | 1068 const int kWindowHeight = 45; |
| 1037 const int kTouchId = 6; | 1069 const int kTouchId = 6; |
| 1038 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 1070 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1049 | 1081 |
| 1050 root_window()->SetGestureRecognizerForTesting(gesture_recognizer); | 1082 root_window()->SetGestureRecognizerForTesting(gesture_recognizer); |
| 1051 | 1083 |
| 1052 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | 1084 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
| 1053 kTouchId, GetTime()); | 1085 kTouchId, GetTime()); |
| 1054 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1); | 1086 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1); |
| 1055 EXPECT_TRUE(delegate->tap_down()); | 1087 EXPECT_TRUE(delegate->tap_down()); |
| 1056 | 1088 |
| 1057 // We haven't pressed long enough for a long press to occur | 1089 // We haven't pressed long enough for a long press to occur |
| 1058 EXPECT_FALSE(delegate->long_press()); | 1090 EXPECT_FALSE(delegate->long_press()); |
| 1091 EXPECT_FALSE(delegate->tap_cancel()); |
| 1059 | 1092 |
| 1060 // Scroll around, to cancel the long press | 1093 // Scroll around, to cancel the long press |
| 1061 SendScrollEvent(root_window(), 130, 230, kTouchId, delegate.get()); | 1094 SendScrollEvent(root_window(), 130, 230, kTouchId, delegate.get()); |
| 1062 // Wait until the timer runs out | 1095 // Wait until the timer runs out |
| 1063 gesture_sequence->ForceTimeout(); | 1096 gesture_sequence->ForceTimeout(); |
| 1064 EXPECT_FALSE(delegate->long_press()); | 1097 EXPECT_FALSE(delegate->long_press()); |
| 1098 EXPECT_TRUE(delegate->tap_cancel()); |
| 1065 | 1099 |
| 1066 delegate->Reset(); | 1100 delegate->Reset(); |
| 1067 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 1101 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 1068 kTouchId, GetTime()); | 1102 kTouchId, GetTime()); |
| 1069 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release1); | 1103 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release1); |
| 1070 EXPECT_FALSE(delegate->long_press()); | 1104 EXPECT_FALSE(delegate->long_press()); |
| 1105 EXPECT_FALSE(delegate->tap_cancel()); |
| 1071 } | 1106 } |
| 1072 | 1107 |
| 1073 // Check that second tap cancels a long press | 1108 // Check that second tap cancels a long press |
| 1074 TEST_F(GestureRecognizerTest, GestureEventLongPressCancelledBySecondTap) { | 1109 TEST_F(GestureRecognizerTest, GestureEventLongPressCancelledBySecondTap) { |
| 1075 scoped_ptr<GestureEventConsumeDelegate> delegate( | 1110 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 1076 new GestureEventConsumeDelegate()); | 1111 new GestureEventConsumeDelegate()); |
| 1077 const int kWindowWidth = 300; | 1112 const int kWindowWidth = 300; |
| 1078 const int kWindowHeight = 400; | 1113 const int kWindowHeight = 400; |
| 1079 const int kTouchId1 = 8; | 1114 const int kTouchId1 = 8; |
| 1080 const int kTouchId2 = 2; | 1115 const int kTouchId2 = 2; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1099 | 1134 |
| 1100 // We haven't pressed long enough for a long press to occur | 1135 // We haven't pressed long enough for a long press to occur |
| 1101 EXPECT_FALSE(delegate->long_press()); | 1136 EXPECT_FALSE(delegate->long_press()); |
| 1102 | 1137 |
| 1103 // Second tap, to cancel the long press | 1138 // Second tap, to cancel the long press |
| 1104 delegate->Reset(); | 1139 delegate->Reset(); |
| 1105 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), | 1140 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), |
| 1106 kTouchId2, GetTime()); | 1141 kTouchId2, GetTime()); |
| 1107 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2); | 1142 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2); |
| 1108 EXPECT_FALSE(delegate->tap_down()); // no touch down for second tap. | 1143 EXPECT_FALSE(delegate->tap_down()); // no touch down for second tap. |
| 1144 EXPECT_TRUE(delegate->tap_cancel()); |
| 1109 EXPECT_TRUE(delegate->begin()); | 1145 EXPECT_TRUE(delegate->begin()); |
| 1110 | 1146 |
| 1111 // Wait until the timer runs out | 1147 // Wait until the timer runs out |
| 1112 gesture_sequence->ForceTimeout(); | 1148 gesture_sequence->ForceTimeout(); |
| 1113 | 1149 |
| 1114 // No long press occurred | 1150 // No long press occurred |
| 1115 EXPECT_FALSE(delegate->long_press()); | 1151 EXPECT_FALSE(delegate->long_press()); |
| 1116 | 1152 |
| 1117 delegate->Reset(); | 1153 delegate->Reset(); |
| 1118 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 1154 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 1119 kTouchId1, GetTime()); | 1155 kTouchId1, GetTime()); |
| 1120 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release1); | 1156 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release1); |
| 1121 EXPECT_FALSE(delegate->long_press()); | 1157 EXPECT_FALSE(delegate->long_press()); |
| 1122 EXPECT_TRUE(delegate->two_finger_tap()); | 1158 EXPECT_TRUE(delegate->two_finger_tap()); |
| 1159 EXPECT_FALSE(delegate->tap_cancel()); |
| 1123 } | 1160 } |
| 1124 | 1161 |
| 1125 // Check that horizontal scroll gestures cause scrolls on horizontal rails. | 1162 // Check that horizontal scroll gestures cause scrolls on horizontal rails. |
| 1126 // Also tests that horizontal rails can be broken. | 1163 // Also tests that horizontal rails can be broken. |
| 1127 TEST_F(GestureRecognizerTest, GestureEventHorizontalRailScroll) { | 1164 TEST_F(GestureRecognizerTest, GestureEventHorizontalRailScroll) { |
| 1128 scoped_ptr<GestureEventConsumeDelegate> delegate( | 1165 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 1129 new GestureEventConsumeDelegate()); | 1166 new GestureEventConsumeDelegate()); |
| 1130 const int kTouchId = 7; | 1167 const int kTouchId = 7; |
| 1131 gfx::Rect bounds(0, 0, 1000, 1000); | 1168 gfx::Rect bounds(0, 0, 1000, 1000); |
| 1132 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 1169 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1226 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 1263 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 1227 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 1264 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 1228 delegate.get(), -1234, bounds, NULL)); | 1265 delegate.get(), -1234, bounds, NULL)); |
| 1229 | 1266 |
| 1230 delegate->Reset(); | 1267 delegate->Reset(); |
| 1231 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | 1268 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
| 1232 kTouchId, GetTime()); | 1269 kTouchId, GetTime()); |
| 1233 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); | 1270 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); |
| 1234 EXPECT_FALSE(delegate->tap()); | 1271 EXPECT_FALSE(delegate->tap()); |
| 1235 EXPECT_TRUE(delegate->tap_down()); | 1272 EXPECT_TRUE(delegate->tap_down()); |
| 1273 EXPECT_FALSE(delegate->tap_cancel()); |
| 1236 EXPECT_FALSE(delegate->double_tap()); | 1274 EXPECT_FALSE(delegate->double_tap()); |
| 1237 EXPECT_FALSE(delegate->scroll_begin()); | 1275 EXPECT_FALSE(delegate->scroll_begin()); |
| 1238 EXPECT_FALSE(delegate->scroll_update()); | 1276 EXPECT_FALSE(delegate->scroll_update()); |
| 1239 EXPECT_FALSE(delegate->scroll_end()); | 1277 EXPECT_FALSE(delegate->scroll_end()); |
| 1240 | 1278 |
| 1241 // Make sure there is enough delay before the touch is released so that it is | 1279 // Make sure there is enough delay before the touch is released so that it is |
| 1242 // recognized as a tap. | 1280 // recognized as a tap. |
| 1243 delegate->Reset(); | 1281 delegate->Reset(); |
| 1244 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 1282 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 1245 kTouchId, press.time_stamp() + | 1283 kTouchId, press.time_stamp() + |
| 1246 base::TimeDelta::FromMilliseconds(50)); | 1284 base::TimeDelta::FromMilliseconds(50)); |
| 1247 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); | 1285 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); |
| 1248 EXPECT_TRUE(delegate->tap()); | 1286 EXPECT_TRUE(delegate->tap()); |
| 1249 EXPECT_FALSE(delegate->tap_down()); | 1287 EXPECT_FALSE(delegate->tap_down()); |
| 1288 EXPECT_FALSE(delegate->tap_cancel()); |
| 1250 EXPECT_FALSE(delegate->double_tap()); | 1289 EXPECT_FALSE(delegate->double_tap()); |
| 1251 EXPECT_FALSE(delegate->scroll_begin()); | 1290 EXPECT_FALSE(delegate->scroll_begin()); |
| 1252 EXPECT_FALSE(delegate->scroll_update()); | 1291 EXPECT_FALSE(delegate->scroll_update()); |
| 1253 EXPECT_FALSE(delegate->scroll_end()); | 1292 EXPECT_FALSE(delegate->scroll_end()); |
| 1254 | 1293 |
| 1255 // Now, do a scroll gesture. Delay it sufficiently so that it doesn't trigger | 1294 // Now, do a scroll gesture. Delay it sufficiently so that it doesn't trigger |
| 1256 // a double-tap. | 1295 // a double-tap. |
| 1257 delegate->Reset(); | 1296 delegate->Reset(); |
| 1258 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | 1297 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
| 1259 kTouchId, release.time_stamp() + | 1298 kTouchId, release.time_stamp() + |
| 1260 base::TimeDelta::FromMilliseconds(1000)); | 1299 base::TimeDelta::FromMilliseconds(1000)); |
| 1261 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1); | 1300 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1); |
| 1262 EXPECT_FALSE(delegate->tap()); | 1301 EXPECT_FALSE(delegate->tap()); |
| 1263 EXPECT_TRUE(delegate->tap_down()); | 1302 EXPECT_TRUE(delegate->tap_down()); |
| 1303 EXPECT_FALSE(delegate->tap_cancel()); |
| 1264 EXPECT_FALSE(delegate->double_tap()); | 1304 EXPECT_FALSE(delegate->double_tap()); |
| 1265 EXPECT_FALSE(delegate->scroll_begin()); | 1305 EXPECT_FALSE(delegate->scroll_begin()); |
| 1266 EXPECT_FALSE(delegate->scroll_update()); | 1306 EXPECT_FALSE(delegate->scroll_update()); |
| 1267 EXPECT_FALSE(delegate->scroll_end()); | 1307 EXPECT_FALSE(delegate->scroll_end()); |
| 1268 | 1308 |
| 1269 // Move the touch-point enough so that it is considered as a scroll. This | 1309 // Move the touch-point enough so that it is considered as a scroll. This |
| 1270 // should generate both SCROLL_BEGIN and SCROLL_UPDATE gestures. | 1310 // should generate both SCROLL_BEGIN and SCROLL_UPDATE gestures. |
| 1271 // The first movement is diagonal, to ensure that we have a free scroll, | 1311 // The first movement is diagonal, to ensure that we have a free scroll, |
| 1272 // and not a rail scroll. | 1312 // and not a rail scroll. |
| 1273 delegate->Reset(); | 1313 delegate->Reset(); |
| 1274 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(130, 230), | 1314 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(130, 230), |
| 1275 kTouchId, GetTime()); | 1315 kTouchId, GetTime()); |
| 1276 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move); | 1316 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move); |
| 1277 EXPECT_FALSE(delegate->tap()); | 1317 EXPECT_FALSE(delegate->tap()); |
| 1278 EXPECT_FALSE(delegate->tap_down()); | 1318 EXPECT_FALSE(delegate->tap_down()); |
| 1319 EXPECT_TRUE(delegate->tap_cancel()); |
| 1279 EXPECT_FALSE(delegate->double_tap()); | 1320 EXPECT_FALSE(delegate->double_tap()); |
| 1280 EXPECT_TRUE(delegate->scroll_begin()); | 1321 EXPECT_TRUE(delegate->scroll_begin()); |
| 1281 EXPECT_TRUE(delegate->scroll_update()); | 1322 EXPECT_TRUE(delegate->scroll_update()); |
| 1282 EXPECT_FALSE(delegate->scroll_end()); | 1323 EXPECT_FALSE(delegate->scroll_end()); |
| 1283 EXPECT_EQ(29, delegate->scroll_x()); | 1324 EXPECT_EQ(29, delegate->scroll_x()); |
| 1284 EXPECT_EQ(29, delegate->scroll_y()); | 1325 EXPECT_EQ(29, delegate->scroll_y()); |
| 1285 | 1326 |
| 1286 // Move some more to generate a few more scroll updates. | 1327 // Move some more to generate a few more scroll updates. |
| 1287 delegate->Reset(); | 1328 delegate->Reset(); |
| 1288 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(110, 211), | 1329 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(110, 211), |
| 1289 kTouchId, GetTime()); | 1330 kTouchId, GetTime()); |
| 1290 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move1); | 1331 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move1); |
| 1291 EXPECT_FALSE(delegate->tap()); | 1332 EXPECT_FALSE(delegate->tap()); |
| 1292 EXPECT_FALSE(delegate->tap_down()); | 1333 EXPECT_FALSE(delegate->tap_down()); |
| 1334 EXPECT_FALSE(delegate->tap_cancel()); |
| 1293 EXPECT_FALSE(delegate->double_tap()); | 1335 EXPECT_FALSE(delegate->double_tap()); |
| 1294 EXPECT_FALSE(delegate->scroll_begin()); | 1336 EXPECT_FALSE(delegate->scroll_begin()); |
| 1295 EXPECT_TRUE(delegate->scroll_update()); | 1337 EXPECT_TRUE(delegate->scroll_update()); |
| 1296 EXPECT_FALSE(delegate->scroll_end()); | 1338 EXPECT_FALSE(delegate->scroll_end()); |
| 1297 EXPECT_EQ(-20, delegate->scroll_x()); | 1339 EXPECT_EQ(-20, delegate->scroll_x()); |
| 1298 EXPECT_EQ(-19, delegate->scroll_y()); | 1340 EXPECT_EQ(-19, delegate->scroll_y()); |
| 1299 | 1341 |
| 1300 delegate->Reset(); | 1342 delegate->Reset(); |
| 1301 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(140, 215), | 1343 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(140, 215), |
| 1302 kTouchId, GetTime()); | 1344 kTouchId, GetTime()); |
| 1303 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move2); | 1345 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move2); |
| 1304 EXPECT_FALSE(delegate->tap()); | 1346 EXPECT_FALSE(delegate->tap()); |
| 1305 EXPECT_FALSE(delegate->tap_down()); | 1347 EXPECT_FALSE(delegate->tap_down()); |
| 1348 EXPECT_FALSE(delegate->tap_cancel()); |
| 1306 EXPECT_FALSE(delegate->double_tap()); | 1349 EXPECT_FALSE(delegate->double_tap()); |
| 1307 EXPECT_FALSE(delegate->scroll_begin()); | 1350 EXPECT_FALSE(delegate->scroll_begin()); |
| 1308 EXPECT_TRUE(delegate->scroll_update()); | 1351 EXPECT_TRUE(delegate->scroll_update()); |
| 1309 EXPECT_FALSE(delegate->scroll_end()); | 1352 EXPECT_FALSE(delegate->scroll_end()); |
| 1310 EXPECT_EQ(30, delegate->scroll_x()); | 1353 EXPECT_EQ(30, delegate->scroll_x()); |
| 1311 EXPECT_EQ(4, delegate->scroll_y()); | 1354 EXPECT_EQ(4, delegate->scroll_y()); |
| 1312 | 1355 |
| 1313 // Release the touch. This should end the scroll. | 1356 // Release the touch. This should end the scroll. |
| 1314 delegate->Reset(); | 1357 delegate->Reset(); |
| 1315 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 1358 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 1316 kTouchId, GetTime()); | 1359 kTouchId, GetTime()); |
| 1317 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release1); | 1360 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release1); |
| 1318 EXPECT_FALSE(delegate->tap()); | 1361 EXPECT_FALSE(delegate->tap()); |
| 1319 EXPECT_FALSE(delegate->tap_down()); | 1362 EXPECT_FALSE(delegate->tap_down()); |
| 1363 EXPECT_FALSE(delegate->tap_cancel()); |
| 1320 EXPECT_FALSE(delegate->double_tap()); | 1364 EXPECT_FALSE(delegate->double_tap()); |
| 1321 EXPECT_FALSE(delegate->scroll_begin()); | 1365 EXPECT_FALSE(delegate->scroll_begin()); |
| 1322 EXPECT_FALSE(delegate->scroll_update()); | 1366 EXPECT_FALSE(delegate->scroll_update()); |
| 1323 EXPECT_TRUE(delegate->scroll_end()); | 1367 EXPECT_TRUE(delegate->scroll_end()); |
| 1324 } | 1368 } |
| 1325 | 1369 |
| 1326 TEST_F(GestureRecognizerTest, AsynchronousGestureRecognition) { | 1370 TEST_F(GestureRecognizerTest, AsynchronousGestureRecognition) { |
| 1327 scoped_ptr<QueueTouchEventDelegate> queued_delegate( | 1371 scoped_ptr<QueueTouchEventDelegate> queued_delegate( |
| 1328 new QueueTouchEventDelegate(root_window())); | 1372 new QueueTouchEventDelegate(root_window())); |
| 1329 const int kWindowWidth = 123; | 1373 const int kWindowWidth = 123; |
| 1330 const int kWindowHeight = 45; | 1374 const int kWindowHeight = 45; |
| 1331 const int kTouchId1 = 6; | 1375 const int kTouchId1 = 6; |
| 1332 const int kTouchId2 = 4; | 1376 const int kTouchId2 = 4; |
| 1333 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 1377 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 1334 scoped_ptr<aura::Window> queue(CreateTestWindowWithDelegate( | 1378 scoped_ptr<aura::Window> queue(CreateTestWindowWithDelegate( |
| 1335 queued_delegate.get(), -1234, bounds, NULL)); | 1379 queued_delegate.get(), -1234, bounds, NULL)); |
| 1336 | 1380 |
| 1337 queued_delegate->set_window(queue.get()); | 1381 queued_delegate->set_window(queue.get()); |
| 1338 | 1382 |
| 1339 // Touch down on the window. This should not generate any gesture event. | 1383 // Touch down on the window. This should not generate any gesture event. |
| 1340 queued_delegate->Reset(); | 1384 queued_delegate->Reset(); |
| 1341 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | 1385 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
| 1342 kTouchId1, GetTime()); | 1386 kTouchId1, GetTime()); |
| 1343 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); | 1387 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); |
| 1344 EXPECT_FALSE(queued_delegate->tap()); | 1388 EXPECT_FALSE(queued_delegate->tap()); |
| 1345 EXPECT_FALSE(queued_delegate->tap_down()); | 1389 EXPECT_FALSE(queued_delegate->tap_down()); |
| 1390 EXPECT_FALSE(queued_delegate->tap_cancel()); |
| 1346 EXPECT_FALSE(queued_delegate->begin()); | 1391 EXPECT_FALSE(queued_delegate->begin()); |
| 1347 EXPECT_FALSE(queued_delegate->double_tap()); | 1392 EXPECT_FALSE(queued_delegate->double_tap()); |
| 1348 EXPECT_FALSE(queued_delegate->scroll_begin()); | 1393 EXPECT_FALSE(queued_delegate->scroll_begin()); |
| 1349 EXPECT_FALSE(queued_delegate->scroll_update()); | 1394 EXPECT_FALSE(queued_delegate->scroll_update()); |
| 1350 EXPECT_FALSE(queued_delegate->scroll_end()); | 1395 EXPECT_FALSE(queued_delegate->scroll_end()); |
| 1351 | 1396 |
| 1352 // Introduce some delay before the touch is released so that it is recognized | 1397 // Introduce some delay before the touch is released so that it is recognized |
| 1353 // as a tap. However, this still should not create any gesture events. | 1398 // as a tap. However, this still should not create any gesture events. |
| 1354 queued_delegate->Reset(); | 1399 queued_delegate->Reset(); |
| 1355 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 1400 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 1356 kTouchId1, press.time_stamp() + | 1401 kTouchId1, press.time_stamp() + |
| 1357 base::TimeDelta::FromMilliseconds(50)); | 1402 base::TimeDelta::FromMilliseconds(50)); |
| 1358 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); | 1403 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); |
| 1359 EXPECT_FALSE(queued_delegate->tap()); | 1404 EXPECT_FALSE(queued_delegate->tap()); |
| 1360 EXPECT_FALSE(queued_delegate->tap_down()); | 1405 EXPECT_FALSE(queued_delegate->tap_down()); |
| 1406 EXPECT_FALSE(queued_delegate->tap_cancel()); |
| 1361 EXPECT_FALSE(queued_delegate->begin()); | 1407 EXPECT_FALSE(queued_delegate->begin()); |
| 1362 EXPECT_FALSE(queued_delegate->end()); | 1408 EXPECT_FALSE(queued_delegate->end()); |
| 1363 EXPECT_FALSE(queued_delegate->double_tap()); | 1409 EXPECT_FALSE(queued_delegate->double_tap()); |
| 1364 EXPECT_FALSE(queued_delegate->scroll_begin()); | 1410 EXPECT_FALSE(queued_delegate->scroll_begin()); |
| 1365 EXPECT_FALSE(queued_delegate->scroll_update()); | 1411 EXPECT_FALSE(queued_delegate->scroll_update()); |
| 1366 EXPECT_FALSE(queued_delegate->scroll_end()); | 1412 EXPECT_FALSE(queued_delegate->scroll_end()); |
| 1367 | 1413 |
| 1368 // Create another window, and place a touch-down on it. This should create a | 1414 // Create another window, and place a touch-down on it. This should create a |
| 1369 // tap-down gesture. | 1415 // tap-down gesture. |
| 1370 scoped_ptr<GestureEventConsumeDelegate> delegate( | 1416 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 1371 new GestureEventConsumeDelegate()); | 1417 new GestureEventConsumeDelegate()); |
| 1372 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 1418 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 1373 delegate.get(), -2345, gfx::Rect(0, 0, 50, 50), NULL)); | 1419 delegate.get(), -2345, gfx::Rect(0, 0, 50, 50), NULL)); |
| 1374 delegate->Reset(); | 1420 delegate->Reset(); |
| 1375 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 20), | 1421 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 20), |
| 1376 kTouchId2, GetTime()); | 1422 kTouchId2, GetTime()); |
| 1377 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2); | 1423 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2); |
| 1378 EXPECT_FALSE(delegate->tap()); | 1424 EXPECT_FALSE(delegate->tap()); |
| 1379 EXPECT_TRUE(delegate->tap_down()); | 1425 EXPECT_TRUE(delegate->tap_down()); |
| 1426 EXPECT_FALSE(delegate->tap_cancel()); |
| 1380 EXPECT_FALSE(queued_delegate->begin()); | 1427 EXPECT_FALSE(queued_delegate->begin()); |
| 1381 EXPECT_FALSE(queued_delegate->end()); | 1428 EXPECT_FALSE(queued_delegate->end()); |
| 1382 EXPECT_FALSE(delegate->double_tap()); | 1429 EXPECT_FALSE(delegate->double_tap()); |
| 1383 EXPECT_FALSE(delegate->scroll_begin()); | 1430 EXPECT_FALSE(delegate->scroll_begin()); |
| 1384 EXPECT_FALSE(delegate->scroll_update()); | 1431 EXPECT_FALSE(delegate->scroll_update()); |
| 1385 EXPECT_FALSE(delegate->scroll_end()); | 1432 EXPECT_FALSE(delegate->scroll_end()); |
| 1386 | 1433 |
| 1387 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(10, 20), | 1434 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(10, 20), |
| 1388 kTouchId2, GetTime()); | 1435 kTouchId2, GetTime()); |
| 1389 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release2); | 1436 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release2); |
| 1390 | 1437 |
| 1391 // Process the first queued event. | 1438 // Process the first queued event. |
| 1392 queued_delegate->Reset(); | 1439 queued_delegate->Reset(); |
| 1393 queued_delegate->ReceivedAck(); | 1440 queued_delegate->ReceivedAck(); |
| 1394 EXPECT_FALSE(queued_delegate->tap()); | 1441 EXPECT_FALSE(queued_delegate->tap()); |
| 1395 EXPECT_TRUE(queued_delegate->tap_down()); | 1442 EXPECT_TRUE(queued_delegate->tap_down()); |
| 1396 EXPECT_TRUE(queued_delegate->begin()); | 1443 EXPECT_TRUE(queued_delegate->begin()); |
| 1444 EXPECT_FALSE(queued_delegate->tap_cancel()); |
| 1397 EXPECT_FALSE(queued_delegate->end()); | 1445 EXPECT_FALSE(queued_delegate->end()); |
| 1398 EXPECT_FALSE(queued_delegate->double_tap()); | 1446 EXPECT_FALSE(queued_delegate->double_tap()); |
| 1399 EXPECT_FALSE(queued_delegate->scroll_begin()); | 1447 EXPECT_FALSE(queued_delegate->scroll_begin()); |
| 1400 EXPECT_FALSE(queued_delegate->scroll_update()); | 1448 EXPECT_FALSE(queued_delegate->scroll_update()); |
| 1401 EXPECT_FALSE(queued_delegate->scroll_end()); | 1449 EXPECT_FALSE(queued_delegate->scroll_end()); |
| 1402 | 1450 |
| 1403 // Now, process the second queued event. | 1451 // Now, process the second queued event. |
| 1404 queued_delegate->Reset(); | 1452 queued_delegate->Reset(); |
| 1405 queued_delegate->ReceivedAck(); | 1453 queued_delegate->ReceivedAck(); |
| 1406 EXPECT_TRUE(queued_delegate->tap()); | 1454 EXPECT_TRUE(queued_delegate->tap()); |
| 1407 EXPECT_FALSE(queued_delegate->tap_down()); | 1455 EXPECT_FALSE(queued_delegate->tap_down()); |
| 1456 EXPECT_FALSE(queued_delegate->tap_cancel()); |
| 1408 EXPECT_FALSE(queued_delegate->begin()); | 1457 EXPECT_FALSE(queued_delegate->begin()); |
| 1409 EXPECT_TRUE(queued_delegate->end()); | 1458 EXPECT_TRUE(queued_delegate->end()); |
| 1410 EXPECT_FALSE(queued_delegate->double_tap()); | 1459 EXPECT_FALSE(queued_delegate->double_tap()); |
| 1411 EXPECT_FALSE(queued_delegate->scroll_begin()); | 1460 EXPECT_FALSE(queued_delegate->scroll_begin()); |
| 1412 EXPECT_FALSE(queued_delegate->scroll_update()); | 1461 EXPECT_FALSE(queued_delegate->scroll_update()); |
| 1413 EXPECT_FALSE(queued_delegate->scroll_end()); | 1462 EXPECT_FALSE(queued_delegate->scroll_end()); |
| 1414 | 1463 |
| 1415 // Start all over. Press on the first window, then press again on the second | 1464 // Start all over. Press on the first window, then press again on the second |
| 1416 // window. The second press should still go to the first window. | 1465 // window. The second press should still go to the first window. |
| 1417 queued_delegate->Reset(); | 1466 queued_delegate->Reset(); |
| 1418 ui::TouchEvent press3(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | 1467 ui::TouchEvent press3(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
| 1419 kTouchId1, GetTime()); | 1468 kTouchId1, GetTime()); |
| 1420 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press3); | 1469 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press3); |
| 1421 EXPECT_FALSE(queued_delegate->tap()); | 1470 EXPECT_FALSE(queued_delegate->tap()); |
| 1422 EXPECT_FALSE(queued_delegate->tap_down()); | 1471 EXPECT_FALSE(queued_delegate->tap_down()); |
| 1472 EXPECT_FALSE(queued_delegate->tap_cancel()); |
| 1423 EXPECT_FALSE(queued_delegate->begin()); | 1473 EXPECT_FALSE(queued_delegate->begin()); |
| 1424 EXPECT_FALSE(queued_delegate->end()); | 1474 EXPECT_FALSE(queued_delegate->end()); |
| 1425 EXPECT_FALSE(queued_delegate->begin()); | 1475 EXPECT_FALSE(queued_delegate->begin()); |
| 1426 EXPECT_FALSE(queued_delegate->end()); | 1476 EXPECT_FALSE(queued_delegate->end()); |
| 1427 EXPECT_FALSE(queued_delegate->double_tap()); | 1477 EXPECT_FALSE(queued_delegate->double_tap()); |
| 1428 EXPECT_FALSE(queued_delegate->scroll_begin()); | 1478 EXPECT_FALSE(queued_delegate->scroll_begin()); |
| 1429 EXPECT_FALSE(queued_delegate->scroll_update()); | 1479 EXPECT_FALSE(queued_delegate->scroll_update()); |
| 1430 EXPECT_FALSE(queued_delegate->scroll_end()); | 1480 EXPECT_FALSE(queued_delegate->scroll_end()); |
| 1431 | 1481 |
| 1432 queued_delegate->Reset(); | 1482 queued_delegate->Reset(); |
| 1433 delegate->Reset(); | 1483 delegate->Reset(); |
| 1434 ui::TouchEvent press4(ui::ET_TOUCH_PRESSED, gfx::Point(103, 203), | 1484 ui::TouchEvent press4(ui::ET_TOUCH_PRESSED, gfx::Point(103, 203), |
| 1435 kTouchId2, GetTime()); | 1485 kTouchId2, GetTime()); |
| 1436 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press4); | 1486 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press4); |
| 1437 EXPECT_FALSE(delegate->tap()); | 1487 EXPECT_FALSE(delegate->tap()); |
| 1438 EXPECT_FALSE(delegate->tap_down()); | 1488 EXPECT_FALSE(delegate->tap_down()); |
| 1489 EXPECT_FALSE(delegate->tap_cancel()); |
| 1439 EXPECT_FALSE(delegate->begin()); | 1490 EXPECT_FALSE(delegate->begin()); |
| 1440 EXPECT_FALSE(delegate->end()); | 1491 EXPECT_FALSE(delegate->end()); |
| 1441 EXPECT_FALSE(delegate->double_tap()); | 1492 EXPECT_FALSE(delegate->double_tap()); |
| 1442 EXPECT_FALSE(delegate->scroll_begin()); | 1493 EXPECT_FALSE(delegate->scroll_begin()); |
| 1443 EXPECT_FALSE(delegate->scroll_update()); | 1494 EXPECT_FALSE(delegate->scroll_update()); |
| 1444 EXPECT_FALSE(delegate->scroll_end()); | 1495 EXPECT_FALSE(delegate->scroll_end()); |
| 1445 EXPECT_FALSE(queued_delegate->tap()); | 1496 EXPECT_FALSE(queued_delegate->tap()); |
| 1446 EXPECT_FALSE(queued_delegate->tap_down()); | 1497 EXPECT_FALSE(queued_delegate->tap_down()); |
| 1498 EXPECT_FALSE(queued_delegate->tap_cancel()); |
| 1447 EXPECT_FALSE(queued_delegate->begin()); | 1499 EXPECT_FALSE(queued_delegate->begin()); |
| 1448 EXPECT_FALSE(queued_delegate->end()); | 1500 EXPECT_FALSE(queued_delegate->end()); |
| 1449 EXPECT_FALSE(queued_delegate->double_tap()); | 1501 EXPECT_FALSE(queued_delegate->double_tap()); |
| 1450 EXPECT_FALSE(queued_delegate->scroll_begin()); | 1502 EXPECT_FALSE(queued_delegate->scroll_begin()); |
| 1451 EXPECT_FALSE(queued_delegate->scroll_update()); | 1503 EXPECT_FALSE(queued_delegate->scroll_update()); |
| 1452 EXPECT_FALSE(queued_delegate->scroll_end()); | 1504 EXPECT_FALSE(queued_delegate->scroll_end()); |
| 1453 | 1505 |
| 1454 // Move the second touch-point enough so that it is considered a pinch. This | 1506 // Move the second touch-point enough so that it is considered a pinch. This |
| 1455 // should generate both SCROLL_BEGIN and PINCH_BEGIN gestures. | 1507 // should generate both SCROLL_BEGIN and PINCH_BEGIN gestures. |
| 1456 queued_delegate->Reset(); | 1508 queued_delegate->Reset(); |
| 1457 delegate->Reset(); | 1509 delegate->Reset(); |
| 1458 int x_move = ui::GestureConfiguration::max_touch_move_in_pixels_for_click(); | 1510 int x_move = ui::GestureConfiguration::max_touch_move_in_pixels_for_click(); |
| 1459 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(103 + x_move, 203), | 1511 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(103 + x_move, 203), |
| 1460 kTouchId2, GetTime()); | 1512 kTouchId2, GetTime()); |
| 1461 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move); | 1513 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move); |
| 1462 EXPECT_FALSE(delegate->tap()); | 1514 EXPECT_FALSE(delegate->tap()); |
| 1463 EXPECT_FALSE(delegate->tap_down()); | 1515 EXPECT_FALSE(delegate->tap_down()); |
| 1516 EXPECT_FALSE(delegate->tap_cancel()); |
| 1464 EXPECT_FALSE(delegate->begin()); | 1517 EXPECT_FALSE(delegate->begin()); |
| 1465 EXPECT_FALSE(delegate->double_tap()); | 1518 EXPECT_FALSE(delegate->double_tap()); |
| 1466 EXPECT_FALSE(delegate->scroll_begin()); | 1519 EXPECT_FALSE(delegate->scroll_begin()); |
| 1467 EXPECT_FALSE(delegate->scroll_update()); | 1520 EXPECT_FALSE(delegate->scroll_update()); |
| 1468 EXPECT_FALSE(delegate->scroll_end()); | 1521 EXPECT_FALSE(delegate->scroll_end()); |
| 1469 EXPECT_FALSE(queued_delegate->tap()); | 1522 EXPECT_FALSE(queued_delegate->tap()); |
| 1470 EXPECT_FALSE(queued_delegate->tap_down()); | 1523 EXPECT_FALSE(queued_delegate->tap_down()); |
| 1524 EXPECT_FALSE(queued_delegate->tap_cancel()); |
| 1471 EXPECT_FALSE(queued_delegate->begin()); | 1525 EXPECT_FALSE(queued_delegate->begin()); |
| 1472 EXPECT_FALSE(queued_delegate->double_tap()); | 1526 EXPECT_FALSE(queued_delegate->double_tap()); |
| 1473 EXPECT_FALSE(queued_delegate->scroll_begin()); | 1527 EXPECT_FALSE(queued_delegate->scroll_begin()); |
| 1474 EXPECT_FALSE(queued_delegate->scroll_update()); | 1528 EXPECT_FALSE(queued_delegate->scroll_update()); |
| 1475 EXPECT_FALSE(queued_delegate->scroll_end()); | 1529 EXPECT_FALSE(queued_delegate->scroll_end()); |
| 1476 | 1530 |
| 1477 queued_delegate->Reset(); | 1531 queued_delegate->Reset(); |
| 1478 queued_delegate->ReceivedAck(); | 1532 queued_delegate->ReceivedAck(); |
| 1479 EXPECT_FALSE(queued_delegate->tap()); | 1533 EXPECT_FALSE(queued_delegate->tap()); |
| 1480 EXPECT_TRUE(queued_delegate->tap_down()); | 1534 EXPECT_TRUE(queued_delegate->tap_down()); |
| 1481 EXPECT_TRUE(queued_delegate->begin()); | 1535 EXPECT_TRUE(queued_delegate->begin()); |
| 1536 EXPECT_FALSE(queued_delegate->tap_cancel()); |
| 1482 EXPECT_FALSE(queued_delegate->end()); | 1537 EXPECT_FALSE(queued_delegate->end()); |
| 1483 EXPECT_FALSE(queued_delegate->double_tap()); | 1538 EXPECT_FALSE(queued_delegate->double_tap()); |
| 1484 EXPECT_FALSE(queued_delegate->scroll_begin()); | 1539 EXPECT_FALSE(queued_delegate->scroll_begin()); |
| 1485 EXPECT_FALSE(queued_delegate->scroll_update()); | 1540 EXPECT_FALSE(queued_delegate->scroll_update()); |
| 1486 EXPECT_FALSE(queued_delegate->scroll_end()); | 1541 EXPECT_FALSE(queued_delegate->scroll_end()); |
| 1487 | 1542 |
| 1488 queued_delegate->Reset(); | 1543 queued_delegate->Reset(); |
| 1489 queued_delegate->ReceivedAck(); | 1544 queued_delegate->ReceivedAck(); |
| 1490 EXPECT_FALSE(queued_delegate->tap()); | 1545 EXPECT_FALSE(queued_delegate->tap()); |
| 1491 EXPECT_FALSE(queued_delegate->tap_down()); // no touch down for second tap. | 1546 EXPECT_FALSE(queued_delegate->tap_down()); // no touch down for second tap. |
| 1547 EXPECT_TRUE(queued_delegate->tap_cancel()); |
| 1492 EXPECT_TRUE(queued_delegate->begin()); | 1548 EXPECT_TRUE(queued_delegate->begin()); |
| 1493 EXPECT_FALSE(queued_delegate->end()); | 1549 EXPECT_FALSE(queued_delegate->end()); |
| 1494 EXPECT_FALSE(queued_delegate->double_tap()); | 1550 EXPECT_FALSE(queued_delegate->double_tap()); |
| 1495 EXPECT_FALSE(queued_delegate->scroll_begin()); | 1551 EXPECT_FALSE(queued_delegate->scroll_begin()); |
| 1496 EXPECT_FALSE(queued_delegate->scroll_update()); | 1552 EXPECT_FALSE(queued_delegate->scroll_update()); |
| 1497 EXPECT_FALSE(queued_delegate->scroll_end()); | 1553 EXPECT_FALSE(queued_delegate->scroll_end()); |
| 1498 EXPECT_FALSE(queued_delegate->pinch_begin()); | 1554 EXPECT_FALSE(queued_delegate->pinch_begin()); |
| 1499 EXPECT_FALSE(queued_delegate->pinch_update()); | 1555 EXPECT_FALSE(queued_delegate->pinch_update()); |
| 1500 EXPECT_FALSE(queued_delegate->pinch_end()); | 1556 EXPECT_FALSE(queued_delegate->pinch_end()); |
| 1501 | 1557 |
| 1502 queued_delegate->Reset(); | 1558 queued_delegate->Reset(); |
| 1503 queued_delegate->ReceivedAck(); | 1559 queued_delegate->ReceivedAck(); |
| 1504 EXPECT_FALSE(queued_delegate->tap()); | 1560 EXPECT_FALSE(queued_delegate->tap()); |
| 1505 EXPECT_FALSE(queued_delegate->tap_down()); | 1561 EXPECT_FALSE(queued_delegate->tap_down()); |
| 1562 EXPECT_FALSE(queued_delegate->tap_cancel()); |
| 1506 EXPECT_FALSE(queued_delegate->begin()); | 1563 EXPECT_FALSE(queued_delegate->begin()); |
| 1507 EXPECT_FALSE(queued_delegate->end()); | 1564 EXPECT_FALSE(queued_delegate->end()); |
| 1508 EXPECT_FALSE(queued_delegate->double_tap()); | 1565 EXPECT_FALSE(queued_delegate->double_tap()); |
| 1509 EXPECT_TRUE(queued_delegate->scroll_begin()); | 1566 EXPECT_TRUE(queued_delegate->scroll_begin()); |
| 1510 EXPECT_FALSE(queued_delegate->scroll_update()); | 1567 EXPECT_FALSE(queued_delegate->scroll_update()); |
| 1511 EXPECT_FALSE(queued_delegate->scroll_end()); | 1568 EXPECT_FALSE(queued_delegate->scroll_end()); |
| 1512 EXPECT_TRUE(queued_delegate->pinch_begin()); | 1569 EXPECT_TRUE(queued_delegate->pinch_begin()); |
| 1513 EXPECT_FALSE(queued_delegate->pinch_update()); | 1570 EXPECT_FALSE(queued_delegate->pinch_update()); |
| 1514 EXPECT_FALSE(queued_delegate->pinch_end()); | 1571 EXPECT_FALSE(queued_delegate->pinch_end()); |
| 1515 } | 1572 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1527 delegate.get(), -1234, bounds, NULL)); | 1584 delegate.get(), -1234, bounds, NULL)); |
| 1528 | 1585 |
| 1529 aura::RootWindow* root = root_window(); | 1586 aura::RootWindow* root = root_window(); |
| 1530 | 1587 |
| 1531 delegate->Reset(); | 1588 delegate->Reset(); |
| 1532 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | 1589 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
| 1533 kTouchId1, GetTime()); | 1590 kTouchId1, GetTime()); |
| 1534 root->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); | 1591 root->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); |
| 1535 EXPECT_FALSE(delegate->tap()); | 1592 EXPECT_FALSE(delegate->tap()); |
| 1536 EXPECT_TRUE(delegate->tap_down()); | 1593 EXPECT_TRUE(delegate->tap_down()); |
| 1594 EXPECT_FALSE(delegate->tap_cancel()); |
| 1537 EXPECT_FALSE(delegate->double_tap()); | 1595 EXPECT_FALSE(delegate->double_tap()); |
| 1538 EXPECT_FALSE(delegate->scroll_begin()); | 1596 EXPECT_FALSE(delegate->scroll_begin()); |
| 1539 EXPECT_FALSE(delegate->scroll_update()); | 1597 EXPECT_FALSE(delegate->scroll_update()); |
| 1540 EXPECT_FALSE(delegate->scroll_end()); | 1598 EXPECT_FALSE(delegate->scroll_end()); |
| 1541 | 1599 |
| 1542 // Move the touch-point enough so that it is considered as a scroll. This | 1600 // Move the touch-point enough so that it is considered as a scroll. This |
| 1543 // should generate both SCROLL_BEGIN and SCROLL_UPDATE gestures. | 1601 // should generate both SCROLL_BEGIN and SCROLL_UPDATE gestures. |
| 1544 delegate->Reset(); | 1602 delegate->Reset(); |
| 1545 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(130, 301), | 1603 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(130, 301), |
| 1546 kTouchId1, GetTime()); | 1604 kTouchId1, GetTime()); |
| 1547 root->AsRootWindowHostDelegate()->OnHostTouchEvent(&move); | 1605 root->AsRootWindowHostDelegate()->OnHostTouchEvent(&move); |
| 1548 EXPECT_FALSE(delegate->tap()); | 1606 EXPECT_FALSE(delegate->tap()); |
| 1549 EXPECT_FALSE(delegate->tap_down()); | 1607 EXPECT_FALSE(delegate->tap_down()); |
| 1608 EXPECT_TRUE(delegate->tap_cancel()); |
| 1550 EXPECT_FALSE(delegate->double_tap()); | 1609 EXPECT_FALSE(delegate->double_tap()); |
| 1551 EXPECT_TRUE(delegate->scroll_begin()); | 1610 EXPECT_TRUE(delegate->scroll_begin()); |
| 1552 EXPECT_TRUE(delegate->scroll_update()); | 1611 EXPECT_TRUE(delegate->scroll_update()); |
| 1553 EXPECT_FALSE(delegate->scroll_end()); | 1612 EXPECT_FALSE(delegate->scroll_end()); |
| 1554 | 1613 |
| 1555 // Press the second finger. It should cause pinch-begin. Note that we will not | 1614 // Press the second finger. It should cause pinch-begin. Note that we will not |
| 1556 // transition to two finger tap here because the touch points are far enough. | 1615 // transition to two finger tap here because the touch points are far enough. |
| 1557 delegate->Reset(); | 1616 delegate->Reset(); |
| 1558 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), | 1617 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), |
| 1559 kTouchId2, GetTime()); | 1618 kTouchId2, GetTime()); |
| 1560 root->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2); | 1619 root->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2); |
| 1561 EXPECT_FALSE(delegate->tap()); | 1620 EXPECT_FALSE(delegate->tap()); |
| 1562 EXPECT_FALSE(delegate->tap_down()); // no touch down for second tap. | 1621 EXPECT_FALSE(delegate->tap_down()); // no touch down for second tap. |
| 1622 EXPECT_FALSE(delegate->tap_cancel()); |
| 1563 EXPECT_FALSE(delegate->double_tap()); | 1623 EXPECT_FALSE(delegate->double_tap()); |
| 1564 EXPECT_FALSE(delegate->scroll_begin()); | 1624 EXPECT_FALSE(delegate->scroll_begin()); |
| 1565 EXPECT_FALSE(delegate->scroll_update()); | 1625 EXPECT_FALSE(delegate->scroll_update()); |
| 1566 EXPECT_FALSE(delegate->scroll_end()); | 1626 EXPECT_FALSE(delegate->scroll_end()); |
| 1567 EXPECT_TRUE(delegate->pinch_begin()); | 1627 EXPECT_TRUE(delegate->pinch_begin()); |
| 1568 EXPECT_EQ(gfx::Rect(10, 10, 120, 291).ToString(), | 1628 EXPECT_EQ(gfx::Rect(10, 10, 120, 291).ToString(), |
| 1569 delegate->bounding_box().ToString()); | 1629 delegate->bounding_box().ToString()); |
| 1570 | 1630 |
| 1571 // Move the first finger. | 1631 // Move the first finger. |
| 1572 delegate->Reset(); | 1632 delegate->Reset(); |
| 1573 ui::TouchEvent move3(ui::ET_TOUCH_MOVED, gfx::Point(95, 201), | 1633 ui::TouchEvent move3(ui::ET_TOUCH_MOVED, gfx::Point(95, 201), |
| 1574 kTouchId1, GetTime()); | 1634 kTouchId1, GetTime()); |
| 1575 root->AsRootWindowHostDelegate()->OnHostTouchEvent(&move3); | 1635 root->AsRootWindowHostDelegate()->OnHostTouchEvent(&move3); |
| 1576 EXPECT_FALSE(delegate->tap()); | 1636 EXPECT_FALSE(delegate->tap()); |
| 1577 EXPECT_FALSE(delegate->tap_down()); | 1637 EXPECT_FALSE(delegate->tap_down()); |
| 1638 EXPECT_FALSE(delegate->tap_cancel()); |
| 1578 EXPECT_FALSE(delegate->double_tap()); | 1639 EXPECT_FALSE(delegate->double_tap()); |
| 1579 EXPECT_FALSE(delegate->scroll_begin()); | 1640 EXPECT_FALSE(delegate->scroll_begin()); |
| 1580 EXPECT_FALSE(delegate->scroll_update()); | 1641 EXPECT_FALSE(delegate->scroll_update()); |
| 1581 EXPECT_FALSE(delegate->scroll_end()); | 1642 EXPECT_FALSE(delegate->scroll_end()); |
| 1582 EXPECT_FALSE(delegate->pinch_begin()); | 1643 EXPECT_FALSE(delegate->pinch_begin()); |
| 1583 EXPECT_TRUE(delegate->pinch_update()); | 1644 EXPECT_TRUE(delegate->pinch_update()); |
| 1584 EXPECT_EQ(gfx::Rect(10, 10, 85, 191).ToString(), | 1645 EXPECT_EQ(gfx::Rect(10, 10, 85, 191).ToString(), |
| 1585 delegate->bounding_box().ToString()); | 1646 delegate->bounding_box().ToString()); |
| 1586 | 1647 |
| 1587 // Now move the second finger. | 1648 // Now move the second finger. |
| 1588 delegate->Reset(); | 1649 delegate->Reset(); |
| 1589 ui::TouchEvent move4(ui::ET_TOUCH_MOVED, gfx::Point(55, 15), | 1650 ui::TouchEvent move4(ui::ET_TOUCH_MOVED, gfx::Point(55, 15), |
| 1590 kTouchId2, GetTime()); | 1651 kTouchId2, GetTime()); |
| 1591 root->AsRootWindowHostDelegate()->OnHostTouchEvent(&move4); | 1652 root->AsRootWindowHostDelegate()->OnHostTouchEvent(&move4); |
| 1592 EXPECT_FALSE(delegate->tap()); | 1653 EXPECT_FALSE(delegate->tap()); |
| 1593 EXPECT_FALSE(delegate->tap_down()); | 1654 EXPECT_FALSE(delegate->tap_down()); |
| 1655 EXPECT_FALSE(delegate->tap_cancel()); |
| 1594 EXPECT_FALSE(delegate->double_tap()); | 1656 EXPECT_FALSE(delegate->double_tap()); |
| 1595 EXPECT_FALSE(delegate->scroll_begin()); | 1657 EXPECT_FALSE(delegate->scroll_begin()); |
| 1596 EXPECT_FALSE(delegate->scroll_update()); | 1658 EXPECT_FALSE(delegate->scroll_update()); |
| 1597 EXPECT_FALSE(delegate->scroll_end()); | 1659 EXPECT_FALSE(delegate->scroll_end()); |
| 1598 EXPECT_FALSE(delegate->pinch_begin()); | 1660 EXPECT_FALSE(delegate->pinch_begin()); |
| 1599 EXPECT_TRUE(delegate->pinch_update()); | 1661 EXPECT_TRUE(delegate->pinch_update()); |
| 1600 EXPECT_EQ(gfx::Rect(55, 15, 40, 186).ToString(), | 1662 EXPECT_EQ(gfx::Rect(55, 15, 40, 186).ToString(), |
| 1601 delegate->bounding_box().ToString()); | 1663 delegate->bounding_box().ToString()); |
| 1602 | 1664 |
| 1603 // Release the first finger. This should end pinch. | 1665 // Release the first finger. This should end pinch. |
| 1604 delegate->Reset(); | 1666 delegate->Reset(); |
| 1605 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 1667 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 1606 kTouchId1, press.time_stamp() + | 1668 kTouchId1, press.time_stamp() + |
| 1607 base::TimeDelta::FromMilliseconds(50)); | 1669 base::TimeDelta::FromMilliseconds(50)); |
| 1608 root->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); | 1670 root->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); |
| 1609 EXPECT_FALSE(delegate->tap()); | 1671 EXPECT_FALSE(delegate->tap()); |
| 1610 EXPECT_FALSE(delegate->tap_down()); | 1672 EXPECT_FALSE(delegate->tap_down()); |
| 1673 EXPECT_FALSE(delegate->tap_cancel()); |
| 1611 EXPECT_FALSE(delegate->double_tap()); | 1674 EXPECT_FALSE(delegate->double_tap()); |
| 1612 EXPECT_FALSE(delegate->scroll_begin()); | 1675 EXPECT_FALSE(delegate->scroll_begin()); |
| 1613 EXPECT_FALSE(delegate->scroll_update()); | 1676 EXPECT_FALSE(delegate->scroll_update()); |
| 1614 EXPECT_FALSE(delegate->scroll_end()); | 1677 EXPECT_FALSE(delegate->scroll_end()); |
| 1615 EXPECT_TRUE(delegate->pinch_end()); | 1678 EXPECT_TRUE(delegate->pinch_end()); |
| 1616 EXPECT_EQ(gfx::Rect(55, 15, 46, 186).ToString(), | 1679 EXPECT_EQ(gfx::Rect(55, 15, 46, 186).ToString(), |
| 1617 delegate->bounding_box().ToString()); | 1680 delegate->bounding_box().ToString()); |
| 1618 | 1681 |
| 1619 // Move the second finger. This should still generate a scroll. | 1682 // Move the second finger. This should still generate a scroll. |
| 1620 delegate->Reset(); | 1683 delegate->Reset(); |
| 1621 ui::TouchEvent move5(ui::ET_TOUCH_MOVED, gfx::Point(25, 10), | 1684 ui::TouchEvent move5(ui::ET_TOUCH_MOVED, gfx::Point(25, 10), |
| 1622 kTouchId2, GetTime()); | 1685 kTouchId2, GetTime()); |
| 1623 root->AsRootWindowHostDelegate()->OnHostTouchEvent(&move5); | 1686 root->AsRootWindowHostDelegate()->OnHostTouchEvent(&move5); |
| 1624 EXPECT_FALSE(delegate->tap()); | 1687 EXPECT_FALSE(delegate->tap()); |
| 1625 EXPECT_FALSE(delegate->tap_down()); | 1688 EXPECT_FALSE(delegate->tap_down()); |
| 1689 EXPECT_FALSE(delegate->tap_cancel()); |
| 1626 EXPECT_FALSE(delegate->double_tap()); | 1690 EXPECT_FALSE(delegate->double_tap()); |
| 1627 EXPECT_FALSE(delegate->scroll_begin()); | 1691 EXPECT_FALSE(delegate->scroll_begin()); |
| 1628 EXPECT_TRUE(delegate->scroll_update()); | 1692 EXPECT_TRUE(delegate->scroll_update()); |
| 1629 EXPECT_FALSE(delegate->scroll_end()); | 1693 EXPECT_FALSE(delegate->scroll_end()); |
| 1630 EXPECT_FALSE(delegate->pinch_begin()); | 1694 EXPECT_FALSE(delegate->pinch_begin()); |
| 1631 EXPECT_FALSE(delegate->pinch_update()); | 1695 EXPECT_FALSE(delegate->pinch_update()); |
| 1632 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); | 1696 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); |
| 1633 } | 1697 } |
| 1634 | 1698 |
| 1635 TEST_F(GestureRecognizerTest, GestureEventPinchFromScrollFromPinch) { | 1699 TEST_F(GestureRecognizerTest, GestureEventPinchFromScrollFromPinch) { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1695 delegate.get(), -1234, bounds, NULL)); | 1759 delegate.get(), -1234, bounds, NULL)); |
| 1696 | 1760 |
| 1697 aura::RootWindow* root = root_window(); | 1761 aura::RootWindow* root = root_window(); |
| 1698 | 1762 |
| 1699 delegate->Reset(); | 1763 delegate->Reset(); |
| 1700 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 301), | 1764 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 301), |
| 1701 kTouchId1, GetTime()); | 1765 kTouchId1, GetTime()); |
| 1702 root->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); | 1766 root->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); |
| 1703 EXPECT_FALSE(delegate->tap()); | 1767 EXPECT_FALSE(delegate->tap()); |
| 1704 EXPECT_TRUE(delegate->tap_down()); | 1768 EXPECT_TRUE(delegate->tap_down()); |
| 1769 EXPECT_FALSE(delegate->tap_cancel()); |
| 1705 EXPECT_FALSE(delegate->double_tap()); | 1770 EXPECT_FALSE(delegate->double_tap()); |
| 1706 EXPECT_FALSE(delegate->scroll_begin()); | 1771 EXPECT_FALSE(delegate->scroll_begin()); |
| 1707 EXPECT_FALSE(delegate->scroll_update()); | 1772 EXPECT_FALSE(delegate->scroll_update()); |
| 1708 EXPECT_FALSE(delegate->scroll_end()); | 1773 EXPECT_FALSE(delegate->scroll_end()); |
| 1709 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); | 1774 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); |
| 1710 | 1775 |
| 1711 // Press the second finger far enough to break two finger tap. It should | 1776 // Press the second finger far enough to break two finger tap. It should |
| 1712 // instead cause a scroll-begin and pinch-begin. | 1777 // instead cause a scroll-begin and pinch-begin. |
| 1713 delegate->Reset(); | 1778 delegate->Reset(); |
| 1714 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), | 1779 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), |
| 1715 kTouchId2, GetTime()); | 1780 kTouchId2, GetTime()); |
| 1716 root->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2); | 1781 root->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2); |
| 1717 EXPECT_FALSE(delegate->tap()); | 1782 EXPECT_FALSE(delegate->tap()); |
| 1718 EXPECT_FALSE(delegate->tap_down()); // no touch down for second tap. | 1783 EXPECT_FALSE(delegate->tap_down()); // no touch down for second tap. |
| 1784 EXPECT_TRUE(delegate->tap_cancel()); |
| 1719 EXPECT_FALSE(delegate->double_tap()); | 1785 EXPECT_FALSE(delegate->double_tap()); |
| 1720 EXPECT_TRUE(delegate->scroll_begin()); | 1786 EXPECT_TRUE(delegate->scroll_begin()); |
| 1721 EXPECT_FALSE(delegate->scroll_update()); | 1787 EXPECT_FALSE(delegate->scroll_update()); |
| 1722 EXPECT_FALSE(delegate->scroll_end()); | 1788 EXPECT_FALSE(delegate->scroll_end()); |
| 1723 EXPECT_TRUE(delegate->pinch_begin()); | 1789 EXPECT_TRUE(delegate->pinch_begin()); |
| 1724 EXPECT_EQ(gfx::Rect(10, 10, 91, 291).ToString(), | 1790 EXPECT_EQ(gfx::Rect(10, 10, 91, 291).ToString(), |
| 1725 delegate->bounding_box().ToString()); | 1791 delegate->bounding_box().ToString()); |
| 1726 | 1792 |
| 1727 // Move the first finger. | 1793 // Move the first finger. |
| 1728 delegate->Reset(); | 1794 delegate->Reset(); |
| 1729 ui::TouchEvent move3(ui::ET_TOUCH_MOVED, gfx::Point(65, 201), | 1795 ui::TouchEvent move3(ui::ET_TOUCH_MOVED, gfx::Point(65, 201), |
| 1730 kTouchId1, GetTime()); | 1796 kTouchId1, GetTime()); |
| 1731 root->AsRootWindowHostDelegate()->OnHostTouchEvent(&move3); | 1797 root->AsRootWindowHostDelegate()->OnHostTouchEvent(&move3); |
| 1732 EXPECT_FALSE(delegate->tap()); | 1798 EXPECT_FALSE(delegate->tap()); |
| 1733 EXPECT_FALSE(delegate->tap_down()); | 1799 EXPECT_FALSE(delegate->tap_down()); |
| 1800 EXPECT_FALSE(delegate->tap_cancel()); |
| 1734 EXPECT_FALSE(delegate->double_tap()); | 1801 EXPECT_FALSE(delegate->double_tap()); |
| 1735 EXPECT_FALSE(delegate->scroll_begin()); | 1802 EXPECT_FALSE(delegate->scroll_begin()); |
| 1736 EXPECT_FALSE(delegate->scroll_update()); | 1803 EXPECT_FALSE(delegate->scroll_update()); |
| 1737 EXPECT_FALSE(delegate->scroll_end()); | 1804 EXPECT_FALSE(delegate->scroll_end()); |
| 1738 EXPECT_FALSE(delegate->pinch_begin()); | 1805 EXPECT_FALSE(delegate->pinch_begin()); |
| 1739 EXPECT_TRUE(delegate->pinch_update()); | 1806 EXPECT_TRUE(delegate->pinch_update()); |
| 1740 EXPECT_EQ(gfx::Rect(10, 10, 55, 191).ToString(), | 1807 EXPECT_EQ(gfx::Rect(10, 10, 55, 191).ToString(), |
| 1741 delegate->bounding_box().ToString()); | 1808 delegate->bounding_box().ToString()); |
| 1742 | 1809 |
| 1743 // Now move the second finger. | 1810 // Now move the second finger. |
| 1744 delegate->Reset(); | 1811 delegate->Reset(); |
| 1745 ui::TouchEvent move4(ui::ET_TOUCH_MOVED, gfx::Point(55, 15), | 1812 ui::TouchEvent move4(ui::ET_TOUCH_MOVED, gfx::Point(55, 15), |
| 1746 kTouchId2, GetTime()); | 1813 kTouchId2, GetTime()); |
| 1747 root->AsRootWindowHostDelegate()->OnHostTouchEvent(&move4); | 1814 root->AsRootWindowHostDelegate()->OnHostTouchEvent(&move4); |
| 1748 EXPECT_FALSE(delegate->tap()); | 1815 EXPECT_FALSE(delegate->tap()); |
| 1749 EXPECT_FALSE(delegate->tap_down()); | 1816 EXPECT_FALSE(delegate->tap_down()); |
| 1817 EXPECT_FALSE(delegate->tap_cancel()); |
| 1750 EXPECT_FALSE(delegate->double_tap()); | 1818 EXPECT_FALSE(delegate->double_tap()); |
| 1751 EXPECT_FALSE(delegate->scroll_begin()); | 1819 EXPECT_FALSE(delegate->scroll_begin()); |
| 1752 EXPECT_FALSE(delegate->scroll_update()); | 1820 EXPECT_FALSE(delegate->scroll_update()); |
| 1753 EXPECT_FALSE(delegate->scroll_end()); | 1821 EXPECT_FALSE(delegate->scroll_end()); |
| 1754 EXPECT_FALSE(delegate->pinch_begin()); | 1822 EXPECT_FALSE(delegate->pinch_begin()); |
| 1755 EXPECT_TRUE(delegate->pinch_update()); | 1823 EXPECT_TRUE(delegate->pinch_update()); |
| 1756 EXPECT_EQ(gfx::Rect(55, 15, 10, 186).ToString(), | 1824 EXPECT_EQ(gfx::Rect(55, 15, 10, 186).ToString(), |
| 1757 delegate->bounding_box().ToString()); | 1825 delegate->bounding_box().ToString()); |
| 1758 | 1826 |
| 1759 // Release the first finger. This should end pinch. | 1827 // Release the first finger. This should end pinch. |
| 1760 delegate->Reset(); | 1828 delegate->Reset(); |
| 1761 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 1829 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 1762 kTouchId1, press.time_stamp() + | 1830 kTouchId1, press.time_stamp() + |
| 1763 base::TimeDelta::FromMilliseconds(50)); | 1831 base::TimeDelta::FromMilliseconds(50)); |
| 1764 root->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); | 1832 root->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); |
| 1765 EXPECT_FALSE(delegate->tap()); | 1833 EXPECT_FALSE(delegate->tap()); |
| 1766 EXPECT_FALSE(delegate->tap_down()); | 1834 EXPECT_FALSE(delegate->tap_down()); |
| 1835 EXPECT_FALSE(delegate->tap_cancel()); |
| 1767 EXPECT_FALSE(delegate->double_tap()); | 1836 EXPECT_FALSE(delegate->double_tap()); |
| 1768 EXPECT_FALSE(delegate->scroll_begin()); | 1837 EXPECT_FALSE(delegate->scroll_begin()); |
| 1769 EXPECT_FALSE(delegate->scroll_update()); | 1838 EXPECT_FALSE(delegate->scroll_update()); |
| 1770 EXPECT_FALSE(delegate->scroll_end()); | 1839 EXPECT_FALSE(delegate->scroll_end()); |
| 1771 EXPECT_TRUE(delegate->pinch_end()); | 1840 EXPECT_TRUE(delegate->pinch_end()); |
| 1772 EXPECT_EQ(gfx::Rect(55, 15, 46, 186).ToString(), | 1841 EXPECT_EQ(gfx::Rect(55, 15, 46, 186).ToString(), |
| 1773 delegate->bounding_box().ToString()); | 1842 delegate->bounding_box().ToString()); |
| 1774 | 1843 |
| 1775 // Move the second finger. This should still generate a scroll. | 1844 // Move the second finger. This should still generate a scroll. |
| 1776 delegate->Reset(); | 1845 delegate->Reset(); |
| 1777 ui::TouchEvent move5(ui::ET_TOUCH_MOVED, gfx::Point(25, 10), | 1846 ui::TouchEvent move5(ui::ET_TOUCH_MOVED, gfx::Point(25, 10), |
| 1778 kTouchId2, GetTime()); | 1847 kTouchId2, GetTime()); |
| 1779 root->AsRootWindowHostDelegate()->OnHostTouchEvent(&move5); | 1848 root->AsRootWindowHostDelegate()->OnHostTouchEvent(&move5); |
| 1780 EXPECT_FALSE(delegate->tap()); | 1849 EXPECT_FALSE(delegate->tap()); |
| 1781 EXPECT_FALSE(delegate->tap_down()); | 1850 EXPECT_FALSE(delegate->tap_down()); |
| 1851 EXPECT_FALSE(delegate->tap_cancel()); |
| 1782 EXPECT_FALSE(delegate->double_tap()); | 1852 EXPECT_FALSE(delegate->double_tap()); |
| 1783 EXPECT_FALSE(delegate->scroll_begin()); | 1853 EXPECT_FALSE(delegate->scroll_begin()); |
| 1784 EXPECT_TRUE(delegate->scroll_update()); | 1854 EXPECT_TRUE(delegate->scroll_update()); |
| 1785 EXPECT_FALSE(delegate->scroll_end()); | 1855 EXPECT_FALSE(delegate->scroll_end()); |
| 1786 EXPECT_FALSE(delegate->pinch_begin()); | 1856 EXPECT_FALSE(delegate->pinch_begin()); |
| 1787 EXPECT_FALSE(delegate->pinch_update()); | 1857 EXPECT_FALSE(delegate->pinch_update()); |
| 1788 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); | 1858 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); |
| 1789 } | 1859 } |
| 1790 | 1860 |
| 1791 TEST_F(GestureRecognizerTest, GestureEventIgnoresDisconnectedEvents) { | 1861 TEST_F(GestureRecognizerTest, GestureEventIgnoresDisconnectedEvents) { |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1932 kTouchId, press.time_stamp() + | 2002 kTouchId, press.time_stamp() + |
| 1933 base::TimeDelta::FromMilliseconds(50)); | 2003 base::TimeDelta::FromMilliseconds(50)); |
| 1934 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); | 2004 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); |
| 1935 | 2005 |
| 1936 delegate->Reset(); | 2006 delegate->Reset(); |
| 1937 delegate->ReceivedAck(); | 2007 delegate->ReceivedAck(); |
| 1938 EXPECT_TRUE(delegate->tap_down()); | 2008 EXPECT_TRUE(delegate->tap_down()); |
| 1939 delegate->Reset(); | 2009 delegate->Reset(); |
| 1940 delegate->ReceivedAckPreventDefaulted(); | 2010 delegate->ReceivedAckPreventDefaulted(); |
| 1941 EXPECT_FALSE(delegate->tap()); | 2011 EXPECT_FALSE(delegate->tap()); |
| 2012 EXPECT_TRUE(delegate->tap_cancel()); |
| 1942 } | 2013 } |
| 1943 | 2014 |
| 1944 TEST_F(GestureRecognizerTest, PinchScrollWithPreventDefaultedRelease) { | 2015 TEST_F(GestureRecognizerTest, PinchScrollWithPreventDefaultedRelease) { |
| 1945 scoped_ptr<QueueTouchEventDelegate> delegate( | 2016 scoped_ptr<QueueTouchEventDelegate> delegate( |
| 1946 new QueueTouchEventDelegate(root_window())); | 2017 new QueueTouchEventDelegate(root_window())); |
| 1947 const int kTouchId1 = 7; | 2018 const int kTouchId1 = 7; |
| 1948 const int kTouchId2 = 5; | 2019 const int kTouchId2 = 5; |
| 1949 gfx::Rect bounds(10, 20, 100, 100); | 2020 gfx::Rect bounds(10, 20, 100, 100); |
| 1950 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 2021 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 1951 delegate.get(), -1234, bounds, NULL)); | 2022 delegate.get(), -1234, bounds, NULL)); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1963 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); | 2034 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); |
| 1964 delegate->Reset(); | 2035 delegate->Reset(); |
| 1965 | 2036 |
| 1966 // Ack the press event. | 2037 // Ack the press event. |
| 1967 delegate->ReceivedAck(); | 2038 delegate->ReceivedAck(); |
| 1968 EXPECT_TRUE(delegate->tap_down()); | 2039 EXPECT_TRUE(delegate->tap_down()); |
| 1969 delegate->Reset(); | 2040 delegate->Reset(); |
| 1970 | 2041 |
| 1971 // Ack the move event. | 2042 // Ack the move event. |
| 1972 delegate->ReceivedAck(); | 2043 delegate->ReceivedAck(); |
| 2044 EXPECT_TRUE(delegate->tap_cancel()); |
| 1973 EXPECT_TRUE(delegate->scroll_begin()); | 2045 EXPECT_TRUE(delegate->scroll_begin()); |
| 1974 delegate->Reset(); | 2046 delegate->Reset(); |
| 1975 | 2047 |
| 1976 // Ack the release event. Although the release event has been processed, it | 2048 // Ack the release event. Although the release event has been processed, it |
| 1977 // should still generate a scroll-end event. | 2049 // should still generate a scroll-end event. |
| 1978 delegate->ReceivedAckPreventDefaulted(); | 2050 delegate->ReceivedAckPreventDefaulted(); |
| 1979 EXPECT_TRUE(delegate->scroll_end()); | 2051 EXPECT_TRUE(delegate->scroll_end()); |
| 1980 | 2052 |
| 1981 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(55, 25), kTouchId2, | 2053 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(55, 25), kTouchId2, |
| 1982 GetTime()); | 2054 GetTime()); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2041 RunAllPendingInMessageLoop(); | 2113 RunAllPendingInMessageLoop(); |
| 2042 | 2114 |
| 2043 EXPECT_TRUE(delegate->tap_down()); | 2115 EXPECT_TRUE(delegate->tap_down()); |
| 2044 | 2116 |
| 2045 scoped_ptr<aura::Window> capture(CreateTestWindowWithBounds( | 2117 scoped_ptr<aura::Window> capture(CreateTestWindowWithBounds( |
| 2046 gfx::Rect(10, 10, 200, 200), NULL)); | 2118 gfx::Rect(10, 10, 200, 200), NULL)); |
| 2047 capture->SetCapture(); | 2119 capture->SetCapture(); |
| 2048 RunAllPendingInMessageLoop(); | 2120 RunAllPendingInMessageLoop(); |
| 2049 | 2121 |
| 2050 EXPECT_TRUE(delegate->end()); | 2122 EXPECT_TRUE(delegate->end()); |
| 2123 EXPECT_TRUE(delegate->tap_cancel()); |
| 2051 } | 2124 } |
| 2052 | 2125 |
| 2053 TEST_F(GestureRecognizerTest, PressDoesNotCrash) { | 2126 TEST_F(GestureRecognizerTest, PressDoesNotCrash) { |
| 2054 scoped_ptr<GestureEventConsumeDelegate> delegate( | 2127 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 2055 new GestureEventConsumeDelegate()); | 2128 new GestureEventConsumeDelegate()); |
| 2056 TestGestureRecognizer* gesture_recognizer = | 2129 TestGestureRecognizer* gesture_recognizer = |
| 2057 new TestGestureRecognizer(root_window()); | 2130 new TestGestureRecognizer(root_window()); |
| 2058 root_window()->SetGestureRecognizerForTesting(gesture_recognizer); | 2131 root_window()->SetGestureRecognizerForTesting(gesture_recognizer); |
| 2059 | 2132 |
| 2060 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 2133 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 2061 delegate.get(), -1234, gfx::Rect(10, 10, 300, 300), NULL)); | 2134 delegate.get(), -1234, gfx::Rect(10, 10, 300, 300), NULL)); |
| 2062 | 2135 |
| 2063 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(45, 45), 7, GetTime()); | 2136 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(45, 45), 7, GetTime()); |
| 2064 press.set_radius_x(40); | 2137 press.set_radius_x(40); |
| 2065 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); | 2138 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); |
| 2066 EXPECT_TRUE(delegate->tap_down()); | 2139 EXPECT_TRUE(delegate->tap_down()); |
| 2067 EXPECT_EQ(gfx::Rect(5, 5, 80, 80).ToString(), | 2140 EXPECT_EQ(gfx::Rect(5, 5, 80, 80).ToString(), |
| 2068 delegate->bounding_box().ToString()); | 2141 delegate->bounding_box().ToString()); |
| 2069 delegate->Reset(); | 2142 delegate->Reset(); |
| 2070 | 2143 |
| 2071 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(55, 45), 7, GetTime()); | 2144 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(55, 45), 7, GetTime()); |
| 2072 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2); | 2145 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2); |
| 2073 | 2146 |
| 2074 // This new press should not generate a tap-down. | 2147 // This new press should not generate a tap-down. |
| 2075 EXPECT_FALSE(delegate->begin()); | 2148 EXPECT_FALSE(delegate->begin()); |
| 2076 EXPECT_FALSE(delegate->tap_down()); | 2149 EXPECT_FALSE(delegate->tap_down()); |
| 2150 EXPECT_FALSE(delegate->tap_cancel()); |
| 2077 EXPECT_FALSE(delegate->scroll_begin()); | 2151 EXPECT_FALSE(delegate->scroll_begin()); |
| 2078 } | 2152 } |
| 2079 | 2153 |
| 2080 // Tests that if a consumer has touch-events queued, then no touch-event gets | 2154 // Tests that if a consumer has touch-events queued, then no touch-event gets |
| 2081 // processed synchronously until all the queued evets are processed. | 2155 // processed synchronously until all the queued evets are processed. |
| 2082 TEST_F(GestureRecognizerTest, SyncTouchEventWithQueuedTouchEvents) { | 2156 TEST_F(GestureRecognizerTest, SyncTouchEventWithQueuedTouchEvents) { |
| 2083 scoped_ptr<QueueTouchEventDelegate> queued_delegate( | 2157 scoped_ptr<QueueTouchEventDelegate> queued_delegate( |
| 2084 new QueueTouchEventDelegate(root_window())); | 2158 new QueueTouchEventDelegate(root_window())); |
| 2085 const int kWindowWidth = 123; | 2159 const int kWindowWidth = 123; |
| 2086 const int kWindowHeight = 45; | 2160 const int kWindowHeight = 45; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 2111 | 2185 |
| 2112 // Process the two queued events. | 2186 // Process the two queued events. |
| 2113 queued_delegate->ReceivedAck(); | 2187 queued_delegate->ReceivedAck(); |
| 2114 RunAllPendingInMessageLoop(); | 2188 RunAllPendingInMessageLoop(); |
| 2115 EXPECT_TRUE(queued_delegate->begin()); | 2189 EXPECT_TRUE(queued_delegate->begin()); |
| 2116 EXPECT_TRUE(queued_delegate->tap_down()); | 2190 EXPECT_TRUE(queued_delegate->tap_down()); |
| 2117 queued_delegate->Reset(); | 2191 queued_delegate->Reset(); |
| 2118 | 2192 |
| 2119 queued_delegate->ReceivedAck(); | 2193 queued_delegate->ReceivedAck(); |
| 2120 RunAllPendingInMessageLoop(); | 2194 RunAllPendingInMessageLoop(); |
| 2195 EXPECT_TRUE(queued_delegate->tap_cancel()); |
| 2121 EXPECT_TRUE(queued_delegate->scroll_begin()); | 2196 EXPECT_TRUE(queued_delegate->scroll_begin()); |
| 2122 EXPECT_TRUE(queued_delegate->scroll_update()); | 2197 EXPECT_TRUE(queued_delegate->scroll_update()); |
| 2123 EXPECT_TRUE(queued_delegate->scroll_end()); | 2198 EXPECT_TRUE(queued_delegate->scroll_end()); |
| 2124 EXPECT_TRUE(queued_delegate->end()); | 2199 EXPECT_TRUE(queued_delegate->end()); |
| 2125 } | 2200 } |
| 2126 | 2201 |
| 2127 TEST_F(GestureRecognizerTest, TwoFingerTap) { | 2202 TEST_F(GestureRecognizerTest, TwoFingerTap) { |
| 2128 scoped_ptr<GestureEventConsumeDelegate> delegate( | 2203 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 2129 new GestureEventConsumeDelegate()); | 2204 new GestureEventConsumeDelegate()); |
| 2130 const int kWindowWidth = 123; | 2205 const int kWindowWidth = 123; |
| 2131 const int kWindowHeight = 45; | 2206 const int kWindowHeight = 45; |
| 2132 const int kTouchId1 = 2; | 2207 const int kTouchId1 = 2; |
| 2133 const int kTouchId2 = 3; | 2208 const int kTouchId2 = 3; |
| 2134 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 2209 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 2135 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 2210 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 2136 delegate.get(), -1234, bounds, NULL)); | 2211 delegate.get(), -1234, bounds, NULL)); |
| 2137 | 2212 |
| 2138 delegate->Reset(); | 2213 delegate->Reset(); |
| 2139 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | 2214 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
| 2140 kTouchId1, GetTime()); | 2215 kTouchId1, GetTime()); |
| 2141 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1); | 2216 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1); |
| 2142 EXPECT_FALSE(delegate->tap()); | 2217 EXPECT_FALSE(delegate->tap()); |
| 2143 EXPECT_TRUE(delegate->tap_down()); | 2218 EXPECT_TRUE(delegate->tap_down()); |
| 2219 EXPECT_FALSE(delegate->tap_cancel()); |
| 2144 EXPECT_FALSE(delegate->double_tap()); | 2220 EXPECT_FALSE(delegate->double_tap()); |
| 2145 EXPECT_FALSE(delegate->scroll_begin()); | 2221 EXPECT_FALSE(delegate->scroll_begin()); |
| 2146 EXPECT_FALSE(delegate->scroll_update()); | 2222 EXPECT_FALSE(delegate->scroll_update()); |
| 2147 EXPECT_FALSE(delegate->scroll_end()); | 2223 EXPECT_FALSE(delegate->scroll_end()); |
| 2148 EXPECT_FALSE(delegate->long_press()); | 2224 EXPECT_FALSE(delegate->long_press()); |
| 2149 EXPECT_FALSE(delegate->two_finger_tap()); | 2225 EXPECT_FALSE(delegate->two_finger_tap()); |
| 2150 | 2226 |
| 2151 delegate->Reset(); | 2227 delegate->Reset(); |
| 2152 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), | 2228 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), |
| 2153 kTouchId2, GetTime()); | 2229 kTouchId2, GetTime()); |
| 2154 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2); | 2230 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2); |
| 2155 EXPECT_FALSE(delegate->tap()); | 2231 EXPECT_FALSE(delegate->tap()); |
| 2156 EXPECT_FALSE(delegate->tap_down()); // no touch down for second tap. | 2232 EXPECT_FALSE(delegate->tap_down()); // no touch down for second tap. |
| 2233 EXPECT_TRUE(delegate->tap_cancel()); |
| 2157 EXPECT_FALSE(delegate->double_tap()); | 2234 EXPECT_FALSE(delegate->double_tap()); |
| 2158 EXPECT_FALSE(delegate->scroll_begin()); | 2235 EXPECT_FALSE(delegate->scroll_begin()); |
| 2159 EXPECT_FALSE(delegate->scroll_update()); | 2236 EXPECT_FALSE(delegate->scroll_update()); |
| 2160 EXPECT_FALSE(delegate->scroll_end()); | 2237 EXPECT_FALSE(delegate->scroll_end()); |
| 2161 EXPECT_FALSE(delegate->long_press()); | 2238 EXPECT_FALSE(delegate->long_press()); |
| 2162 EXPECT_FALSE(delegate->two_finger_tap()); | 2239 EXPECT_FALSE(delegate->two_finger_tap()); |
| 2163 | 2240 |
| 2164 // Little bit of touch move should not affect our state. | 2241 // Little bit of touch move should not affect our state. |
| 2165 delegate->Reset(); | 2242 delegate->Reset(); |
| 2166 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(102, 202), | 2243 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(102, 202), |
| 2167 kTouchId1, GetTime()); | 2244 kTouchId1, GetTime()); |
| 2168 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move1); | 2245 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move1); |
| 2169 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(131, 202), | 2246 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(131, 202), |
| 2170 kTouchId2, GetTime()); | 2247 kTouchId2, GetTime()); |
| 2171 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move2); | 2248 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move2); |
| 2172 EXPECT_FALSE(delegate->tap()); | 2249 EXPECT_FALSE(delegate->tap()); |
| 2173 EXPECT_FALSE(delegate->tap_down()); | 2250 EXPECT_FALSE(delegate->tap_down()); |
| 2251 EXPECT_FALSE(delegate->tap_cancel()); |
| 2174 EXPECT_FALSE(delegate->double_tap()); | 2252 EXPECT_FALSE(delegate->double_tap()); |
| 2175 EXPECT_FALSE(delegate->scroll_begin()); | 2253 EXPECT_FALSE(delegate->scroll_begin()); |
| 2176 EXPECT_FALSE(delegate->scroll_update()); | 2254 EXPECT_FALSE(delegate->scroll_update()); |
| 2177 EXPECT_FALSE(delegate->scroll_end()); | 2255 EXPECT_FALSE(delegate->scroll_end()); |
| 2178 EXPECT_FALSE(delegate->long_press()); | 2256 EXPECT_FALSE(delegate->long_press()); |
| 2179 EXPECT_FALSE(delegate->two_finger_tap()); | 2257 EXPECT_FALSE(delegate->two_finger_tap()); |
| 2180 | 2258 |
| 2181 // Make sure there is enough delay before the touch is released so that it is | 2259 // Make sure there is enough delay before the touch is released so that it is |
| 2182 // recognized as a tap. | 2260 // recognized as a tap. |
| 2183 delegate->Reset(); | 2261 delegate->Reset(); |
| 2184 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 2262 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 2185 kTouchId1, press1.time_stamp() + | 2263 kTouchId1, press1.time_stamp() + |
| 2186 base::TimeDelta::FromMilliseconds(50)); | 2264 base::TimeDelta::FromMilliseconds(50)); |
| 2187 | 2265 |
| 2188 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release1); | 2266 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release1); |
| 2189 EXPECT_FALSE(delegate->tap()); | 2267 EXPECT_FALSE(delegate->tap()); |
| 2190 EXPECT_FALSE(delegate->tap_down()); | 2268 EXPECT_FALSE(delegate->tap_down()); |
| 2269 EXPECT_FALSE(delegate->tap_cancel()); |
| 2191 EXPECT_FALSE(delegate->double_tap()); | 2270 EXPECT_FALSE(delegate->double_tap()); |
| 2192 EXPECT_FALSE(delegate->scroll_begin()); | 2271 EXPECT_FALSE(delegate->scroll_begin()); |
| 2193 EXPECT_FALSE(delegate->scroll_update()); | 2272 EXPECT_FALSE(delegate->scroll_update()); |
| 2194 EXPECT_FALSE(delegate->scroll_end()); | 2273 EXPECT_FALSE(delegate->scroll_end()); |
| 2195 EXPECT_TRUE(delegate->two_finger_tap()); | 2274 EXPECT_TRUE(delegate->two_finger_tap()); |
| 2196 | 2275 |
| 2197 // Lift second finger. | 2276 // Lift second finger. |
| 2198 // Make sure there is enough delay before the touch is released so that it is | 2277 // Make sure there is enough delay before the touch is released so that it is |
| 2199 // recognized as a tap. | 2278 // recognized as a tap. |
| 2200 delegate->Reset(); | 2279 delegate->Reset(); |
| 2201 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(130, 201), | 2280 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(130, 201), |
| 2202 kTouchId2, press2.time_stamp() + | 2281 kTouchId2, press2.time_stamp() + |
| 2203 base::TimeDelta::FromMilliseconds(50)); | 2282 base::TimeDelta::FromMilliseconds(50)); |
| 2204 | 2283 |
| 2205 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release2); | 2284 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release2); |
| 2206 EXPECT_FALSE(delegate->tap()); | 2285 EXPECT_FALSE(delegate->tap()); |
| 2207 EXPECT_FALSE(delegate->tap_down()); | 2286 EXPECT_FALSE(delegate->tap_down()); |
| 2287 EXPECT_FALSE(delegate->tap_cancel()); |
| 2208 EXPECT_FALSE(delegate->double_tap()); | 2288 EXPECT_FALSE(delegate->double_tap()); |
| 2209 EXPECT_FALSE(delegate->scroll_begin()); | 2289 EXPECT_FALSE(delegate->scroll_begin()); |
| 2210 EXPECT_FALSE(delegate->scroll_update()); | 2290 EXPECT_FALSE(delegate->scroll_update()); |
| 2211 EXPECT_TRUE(delegate->scroll_end()); | 2291 EXPECT_TRUE(delegate->scroll_end()); |
| 2212 EXPECT_FALSE(delegate->two_finger_tap()); | 2292 EXPECT_FALSE(delegate->two_finger_tap()); |
| 2213 } | 2293 } |
| 2214 | 2294 |
| 2215 TEST_F(GestureRecognizerTest, TwoFingerTapExpired) { | 2295 TEST_F(GestureRecognizerTest, TwoFingerTapExpired) { |
| 2216 scoped_ptr<GestureEventConsumeDelegate> delegate( | 2296 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 2217 new GestureEventConsumeDelegate()); | 2297 new GestureEventConsumeDelegate()); |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2452 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 2532 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 2453 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 2533 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 2454 delegate.get(), -1234, bounds, NULL)); | 2534 delegate.get(), -1234, bounds, NULL)); |
| 2455 | 2535 |
| 2456 delegate->Reset(); | 2536 delegate->Reset(); |
| 2457 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | 2537 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
| 2458 kTouchId1, GetTime()); | 2538 kTouchId1, GetTime()); |
| 2459 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1); | 2539 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1); |
| 2460 EXPECT_FALSE(delegate->tap()); | 2540 EXPECT_FALSE(delegate->tap()); |
| 2461 EXPECT_TRUE(delegate->tap_down()); | 2541 EXPECT_TRUE(delegate->tap_down()); |
| 2542 EXPECT_FALSE(delegate->tap_cancel()); |
| 2462 EXPECT_FALSE(delegate->double_tap()); | 2543 EXPECT_FALSE(delegate->double_tap()); |
| 2463 EXPECT_FALSE(delegate->scroll_begin()); | 2544 EXPECT_FALSE(delegate->scroll_begin()); |
| 2464 EXPECT_FALSE(delegate->scroll_update()); | 2545 EXPECT_FALSE(delegate->scroll_update()); |
| 2465 EXPECT_FALSE(delegate->scroll_end()); | 2546 EXPECT_FALSE(delegate->scroll_end()); |
| 2466 EXPECT_FALSE(delegate->long_press()); | 2547 EXPECT_FALSE(delegate->long_press()); |
| 2467 EXPECT_FALSE(delegate->two_finger_tap()); | 2548 EXPECT_FALSE(delegate->two_finger_tap()); |
| 2468 | 2549 |
| 2469 delegate->Reset(); | 2550 delegate->Reset(); |
| 2470 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(430, 201), | 2551 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(430, 201), |
| 2471 kTouchId2, GetTime()); | 2552 kTouchId2, GetTime()); |
| 2472 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2); | 2553 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2); |
| 2473 EXPECT_FALSE(delegate->tap()); | 2554 EXPECT_FALSE(delegate->tap()); |
| 2474 EXPECT_FALSE(delegate->tap_down()); // no touch down for second tap. | 2555 EXPECT_FALSE(delegate->tap_down()); // no touch down for second tap. |
| 2556 EXPECT_TRUE(delegate->tap_cancel()); |
| 2475 EXPECT_FALSE(delegate->double_tap()); | 2557 EXPECT_FALSE(delegate->double_tap()); |
| 2476 EXPECT_TRUE(delegate->scroll_begin()); | 2558 EXPECT_TRUE(delegate->scroll_begin()); |
| 2477 EXPECT_FALSE(delegate->scroll_update()); | 2559 EXPECT_FALSE(delegate->scroll_update()); |
| 2478 EXPECT_FALSE(delegate->scroll_end()); | 2560 EXPECT_FALSE(delegate->scroll_end()); |
| 2479 EXPECT_FALSE(delegate->long_press()); | 2561 EXPECT_FALSE(delegate->long_press()); |
| 2480 EXPECT_FALSE(delegate->two_finger_tap()); | 2562 EXPECT_FALSE(delegate->two_finger_tap()); |
| 2481 EXPECT_TRUE(delegate->pinch_begin()); | 2563 EXPECT_TRUE(delegate->pinch_begin()); |
| 2482 } | 2564 } |
| 2483 | 2565 |
| 2484 // Verifies if a window is the target of multiple touch-ids and we hide the | 2566 // Verifies if a window is the target of multiple touch-ids and we hide the |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2571 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 2653 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 2572 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 2654 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 2573 delegate.get(), -1234, bounds, NULL)); | 2655 delegate.get(), -1234, bounds, NULL)); |
| 2574 | 2656 |
| 2575 delegate->Reset(); | 2657 delegate->Reset(); |
| 2576 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | 2658 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
| 2577 kTouchId, GetTime()); | 2659 kTouchId, GetTime()); |
| 2578 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); | 2660 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); |
| 2579 EXPECT_FALSE(delegate->tap()); | 2661 EXPECT_FALSE(delegate->tap()); |
| 2580 EXPECT_TRUE(delegate->tap_down()); | 2662 EXPECT_TRUE(delegate->tap_down()); |
| 2663 EXPECT_FALSE(delegate->tap_cancel()); |
| 2581 EXPECT_TRUE(delegate->begin()); | 2664 EXPECT_TRUE(delegate->begin()); |
| 2582 EXPECT_FALSE(delegate->double_tap()); | 2665 EXPECT_FALSE(delegate->double_tap()); |
| 2583 EXPECT_FALSE(delegate->scroll_begin()); | 2666 EXPECT_FALSE(delegate->scroll_begin()); |
| 2584 EXPECT_FALSE(delegate->scroll_update()); | 2667 EXPECT_FALSE(delegate->scroll_update()); |
| 2585 EXPECT_FALSE(delegate->scroll_end()); | 2668 EXPECT_FALSE(delegate->scroll_end()); |
| 2586 | 2669 |
| 2587 // Move the touch-point enough so that it would normally be considered a | 2670 // Move the touch-point enough so that it would normally be considered a |
| 2588 // scroll. But since the touch-moves will be consumed, the scroll should not | 2671 // scroll. But since the touch-moves will be consumed, the scroll should not |
| 2589 // start. | 2672 // start. We should, however, get the TAP_CANCEL event now (since it's now |
| 2673 // impossible for the gesture to become a tap). |
| 2590 SendScrollEvent(root_window(), 130, 230, kTouchId, delegate.get()); | 2674 SendScrollEvent(root_window(), 130, 230, kTouchId, delegate.get()); |
| 2591 EXPECT_FALSE(delegate->tap()); | 2675 EXPECT_FALSE(delegate->tap()); |
| 2592 EXPECT_FALSE(delegate->tap_down()); | 2676 EXPECT_FALSE(delegate->tap_down()); |
| 2677 // TODO(rbyers): Really we should get the TapCancel here instead of below, |
| 2678 // but this is a symptom of a larger issue: crbug.com/146397. |
| 2679 EXPECT_FALSE(delegate->tap_cancel()); |
| 2593 EXPECT_FALSE(delegate->begin()); | 2680 EXPECT_FALSE(delegate->begin()); |
| 2594 EXPECT_FALSE(delegate->double_tap()); | 2681 EXPECT_FALSE(delegate->double_tap()); |
| 2595 EXPECT_FALSE(delegate->scroll_begin()); | 2682 EXPECT_FALSE(delegate->scroll_begin()); |
| 2596 EXPECT_FALSE(delegate->scroll_update()); | 2683 EXPECT_FALSE(delegate->scroll_update()); |
| 2597 EXPECT_FALSE(delegate->scroll_end()); | 2684 EXPECT_FALSE(delegate->scroll_end()); |
| 2598 | 2685 |
| 2599 // Now, stop consuming touch-move events, and move the touch-point again. | 2686 // Now, stop consuming touch-move events, and move the touch-point again. |
| 2600 delegate->set_consume_touch_move(false); | 2687 delegate->set_consume_touch_move(false); |
| 2601 SendScrollEvent(root_window(), 159, 259, kTouchId, delegate.get()); | 2688 SendScrollEvent(root_window(), 159, 259, kTouchId, delegate.get()); |
| 2602 EXPECT_FALSE(delegate->tap()); | 2689 EXPECT_FALSE(delegate->tap()); |
| 2603 EXPECT_FALSE(delegate->tap_down()); | 2690 EXPECT_FALSE(delegate->tap_down()); |
| 2691 EXPECT_TRUE(delegate->tap_cancel()); |
| 2604 EXPECT_FALSE(delegate->begin()); | 2692 EXPECT_FALSE(delegate->begin()); |
| 2605 EXPECT_FALSE(delegate->double_tap()); | 2693 EXPECT_FALSE(delegate->double_tap()); |
| 2606 EXPECT_TRUE(delegate->scroll_begin()); | 2694 EXPECT_TRUE(delegate->scroll_begin()); |
| 2607 EXPECT_TRUE(delegate->scroll_update()); | 2695 EXPECT_TRUE(delegate->scroll_update()); |
| 2608 EXPECT_FALSE(delegate->scroll_end()); | 2696 EXPECT_FALSE(delegate->scroll_end()); |
| 2609 EXPECT_EQ(29, delegate->scroll_x()); | 2697 EXPECT_EQ(29, delegate->scroll_x()); |
| 2610 EXPECT_EQ(29, delegate->scroll_y()); | 2698 EXPECT_EQ(29, delegate->scroll_y()); |
| 2611 EXPECT_EQ(gfx::Point(1, 1).ToString(), | 2699 EXPECT_EQ(gfx::Point(1, 1).ToString(), |
| 2612 delegate->scroll_begin_position().ToString()); | 2700 delegate->scroll_begin_position().ToString()); |
| 2613 | 2701 |
| 2614 // Start consuming touch-move events again. However, since gesture-scroll has | 2702 // Start consuming touch-move events again. However, since gesture-scroll has |
| 2615 // already started, the touch-move events should still result in scroll-update | 2703 // already started, the touch-move events should still result in scroll-update |
| 2616 // gesturs. | 2704 // gesturs. |
| 2617 delegate->set_consume_touch_move(true); | 2705 delegate->set_consume_touch_move(true); |
| 2618 | 2706 |
| 2619 // Move some more to generate a few more scroll updates. | 2707 // Move some more to generate a few more scroll updates. |
| 2620 SendScrollEvent(root_window(), 110, 211, kTouchId, delegate.get()); | 2708 SendScrollEvent(root_window(), 110, 211, kTouchId, delegate.get()); |
| 2621 EXPECT_FALSE(delegate->tap()); | 2709 EXPECT_FALSE(delegate->tap()); |
| 2622 EXPECT_FALSE(delegate->tap_down()); | 2710 EXPECT_FALSE(delegate->tap_down()); |
| 2711 EXPECT_FALSE(delegate->tap_cancel()); |
| 2623 EXPECT_FALSE(delegate->begin()); | 2712 EXPECT_FALSE(delegate->begin()); |
| 2624 EXPECT_FALSE(delegate->double_tap()); | 2713 EXPECT_FALSE(delegate->double_tap()); |
| 2625 EXPECT_FALSE(delegate->scroll_begin()); | 2714 EXPECT_FALSE(delegate->scroll_begin()); |
| 2626 EXPECT_TRUE(delegate->scroll_update()); | 2715 EXPECT_TRUE(delegate->scroll_update()); |
| 2627 EXPECT_FALSE(delegate->scroll_end()); | 2716 EXPECT_FALSE(delegate->scroll_end()); |
| 2628 EXPECT_EQ(-49, delegate->scroll_x()); | 2717 EXPECT_EQ(-49, delegate->scroll_x()); |
| 2629 EXPECT_EQ(-48, delegate->scroll_y()); | 2718 EXPECT_EQ(-48, delegate->scroll_y()); |
| 2630 | 2719 |
| 2631 SendScrollEvent(root_window(), 140, 215, kTouchId, delegate.get()); | 2720 SendScrollEvent(root_window(), 140, 215, kTouchId, delegate.get()); |
| 2632 EXPECT_FALSE(delegate->tap()); | 2721 EXPECT_FALSE(delegate->tap()); |
| 2633 EXPECT_FALSE(delegate->tap_down()); | 2722 EXPECT_FALSE(delegate->tap_down()); |
| 2723 EXPECT_FALSE(delegate->tap_cancel()); |
| 2634 EXPECT_FALSE(delegate->begin()); | 2724 EXPECT_FALSE(delegate->begin()); |
| 2635 EXPECT_FALSE(delegate->double_tap()); | 2725 EXPECT_FALSE(delegate->double_tap()); |
| 2636 EXPECT_FALSE(delegate->scroll_begin()); | 2726 EXPECT_FALSE(delegate->scroll_begin()); |
| 2637 EXPECT_TRUE(delegate->scroll_update()); | 2727 EXPECT_TRUE(delegate->scroll_update()); |
| 2638 EXPECT_FALSE(delegate->scroll_end()); | 2728 EXPECT_FALSE(delegate->scroll_end()); |
| 2639 EXPECT_EQ(30, delegate->scroll_x()); | 2729 EXPECT_EQ(30, delegate->scroll_x()); |
| 2640 EXPECT_EQ(4, delegate->scroll_y()); | 2730 EXPECT_EQ(4, delegate->scroll_y()); |
| 2641 | 2731 |
| 2642 // Release the touch. This should end the scroll. | 2732 // Release the touch. This should end the scroll. |
| 2643 delegate->Reset(); | 2733 delegate->Reset(); |
| 2644 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 2734 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 2645 kTouchId, press.time_stamp() + | 2735 kTouchId, press.time_stamp() + |
| 2646 base::TimeDelta::FromMilliseconds(50)); | 2736 base::TimeDelta::FromMilliseconds(50)); |
| 2647 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); | 2737 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); |
| 2648 EXPECT_FALSE(delegate->tap()); | 2738 EXPECT_FALSE(delegate->tap()); |
| 2649 EXPECT_FALSE(delegate->tap_down()); | 2739 EXPECT_FALSE(delegate->tap_down()); |
| 2740 EXPECT_FALSE(delegate->tap_cancel()); |
| 2650 EXPECT_FALSE(delegate->begin()); | 2741 EXPECT_FALSE(delegate->begin()); |
| 2651 EXPECT_TRUE(delegate->end()); | 2742 EXPECT_TRUE(delegate->end()); |
| 2652 EXPECT_FALSE(delegate->double_tap()); | 2743 EXPECT_FALSE(delegate->double_tap()); |
| 2653 EXPECT_FALSE(delegate->scroll_begin()); | 2744 EXPECT_FALSE(delegate->scroll_begin()); |
| 2654 EXPECT_FALSE(delegate->scroll_update()); | 2745 EXPECT_FALSE(delegate->scroll_update()); |
| 2655 EXPECT_TRUE(delegate->scroll_end()); | 2746 EXPECT_TRUE(delegate->scroll_end()); |
| 2656 } | 2747 } |
| 2657 | 2748 |
| 2658 // Check that appropriate touch events generate double tap gesture events. | 2749 // Check that appropriate touch events generate double tap gesture events. |
| 2659 TEST_F(GestureRecognizerTest, GestureEventDoubleTap) { | 2750 TEST_F(GestureRecognizerTest, GestureEventDoubleTap) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2681 kTouchId, release1.time_stamp() + | 2772 kTouchId, release1.time_stamp() + |
| 2682 base::TimeDelta::FromMilliseconds(200)); | 2773 base::TimeDelta::FromMilliseconds(200)); |
| 2683 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2); | 2774 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2); |
| 2684 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(102, 206), | 2775 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(102, 206), |
| 2685 kTouchId, press2.time_stamp() + | 2776 kTouchId, press2.time_stamp() + |
| 2686 base::TimeDelta::FromMilliseconds(50)); | 2777 base::TimeDelta::FromMilliseconds(50)); |
| 2687 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release2); | 2778 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release2); |
| 2688 | 2779 |
| 2689 EXPECT_TRUE(delegate->tap()); | 2780 EXPECT_TRUE(delegate->tap()); |
| 2690 EXPECT_TRUE(delegate->tap_down()); | 2781 EXPECT_TRUE(delegate->tap_down()); |
| 2782 EXPECT_FALSE(delegate->tap_cancel()); |
| 2691 EXPECT_TRUE(delegate->begin()); | 2783 EXPECT_TRUE(delegate->begin()); |
| 2692 EXPECT_TRUE(delegate->end()); | 2784 EXPECT_TRUE(delegate->end()); |
| 2693 EXPECT_TRUE(delegate->double_tap()); | 2785 EXPECT_TRUE(delegate->double_tap()); |
| 2694 EXPECT_FALSE(delegate->scroll_begin()); | 2786 EXPECT_FALSE(delegate->scroll_begin()); |
| 2695 EXPECT_FALSE(delegate->scroll_update()); | 2787 EXPECT_FALSE(delegate->scroll_update()); |
| 2696 EXPECT_FALSE(delegate->scroll_end()); | 2788 EXPECT_FALSE(delegate->scroll_end()); |
| 2697 | 2789 |
| 2698 EXPECT_EQ(2, delegate->tap_count()); | 2790 EXPECT_EQ(2, delegate->tap_count()); |
| 2699 } | 2791 } |
| 2700 | 2792 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 2724 kTouchId, release1.time_stamp() + | 2816 kTouchId, release1.time_stamp() + |
| 2725 base::TimeDelta::FromMilliseconds(200)); | 2817 base::TimeDelta::FromMilliseconds(200)); |
| 2726 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2); | 2818 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2); |
| 2727 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(201, 201), | 2819 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(201, 201), |
| 2728 kTouchId, press2.time_stamp() + | 2820 kTouchId, press2.time_stamp() + |
| 2729 base::TimeDelta::FromMilliseconds(50)); | 2821 base::TimeDelta::FromMilliseconds(50)); |
| 2730 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release2); | 2822 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release2); |
| 2731 | 2823 |
| 2732 EXPECT_TRUE(delegate->tap()); | 2824 EXPECT_TRUE(delegate->tap()); |
| 2733 EXPECT_TRUE(delegate->tap_down()); | 2825 EXPECT_TRUE(delegate->tap_down()); |
| 2826 EXPECT_FALSE(delegate->tap_cancel()); |
| 2734 EXPECT_TRUE(delegate->begin()); | 2827 EXPECT_TRUE(delegate->begin()); |
| 2735 EXPECT_TRUE(delegate->end()); | 2828 EXPECT_TRUE(delegate->end()); |
| 2736 EXPECT_FALSE(delegate->double_tap()); | 2829 EXPECT_FALSE(delegate->double_tap()); |
| 2737 EXPECT_FALSE(delegate->scroll_begin()); | 2830 EXPECT_FALSE(delegate->scroll_begin()); |
| 2738 EXPECT_FALSE(delegate->scroll_update()); | 2831 EXPECT_FALSE(delegate->scroll_update()); |
| 2739 EXPECT_FALSE(delegate->scroll_end()); | 2832 EXPECT_FALSE(delegate->scroll_end()); |
| 2740 | 2833 |
| 2741 EXPECT_EQ(1, delegate->tap_count()); | 2834 EXPECT_EQ(1, delegate->tap_count()); |
| 2742 } | 2835 } |
| 2743 | 2836 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 2768 kTouchId, release1.time_stamp() + | 2861 kTouchId, release1.time_stamp() + |
| 2769 base::TimeDelta::FromMilliseconds(2000)); | 2862 base::TimeDelta::FromMilliseconds(2000)); |
| 2770 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2); | 2863 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2); |
| 2771 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 2864 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 2772 kTouchId, press2.time_stamp() + | 2865 kTouchId, press2.time_stamp() + |
| 2773 base::TimeDelta::FromMilliseconds(50)); | 2866 base::TimeDelta::FromMilliseconds(50)); |
| 2774 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release2); | 2867 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release2); |
| 2775 | 2868 |
| 2776 EXPECT_TRUE(delegate->tap()); | 2869 EXPECT_TRUE(delegate->tap()); |
| 2777 EXPECT_TRUE(delegate->tap_down()); | 2870 EXPECT_TRUE(delegate->tap_down()); |
| 2871 EXPECT_FALSE(delegate->tap_cancel()); |
| 2778 EXPECT_TRUE(delegate->begin()); | 2872 EXPECT_TRUE(delegate->begin()); |
| 2779 EXPECT_TRUE(delegate->end()); | 2873 EXPECT_TRUE(delegate->end()); |
| 2780 EXPECT_FALSE(delegate->double_tap()); | 2874 EXPECT_FALSE(delegate->double_tap()); |
| 2781 EXPECT_FALSE(delegate->scroll_begin()); | 2875 EXPECT_FALSE(delegate->scroll_begin()); |
| 2782 EXPECT_FALSE(delegate->scroll_update()); | 2876 EXPECT_FALSE(delegate->scroll_update()); |
| 2783 EXPECT_FALSE(delegate->scroll_end()); | 2877 EXPECT_FALSE(delegate->scroll_end()); |
| 2784 | 2878 |
| 2785 EXPECT_EQ(1, delegate->tap_count()); | 2879 EXPECT_EQ(1, delegate->tap_count()); |
| 2786 } | 2880 } |
| 2787 | 2881 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2823 | 2917 |
| 2824 delegate->Reset(); | 2918 delegate->Reset(); |
| 2825 | 2919 |
| 2826 // The position doesn't move, but the radius changes. | 2920 // The position doesn't move, but the radius changes. |
| 2827 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(101, 201), kTouchId, | 2921 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(101, 201), kTouchId, |
| 2828 press2.time_stamp() + base::TimeDelta::FromMilliseconds(40)); | 2922 press2.time_stamp() + base::TimeDelta::FromMilliseconds(40)); |
| 2829 move2.set_radius_x(50); | 2923 move2.set_radius_x(50); |
| 2830 move2.set_radius_y(60); | 2924 move2.set_radius_y(60); |
| 2831 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move2); | 2925 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move2); |
| 2832 EXPECT_FALSE(delegate->tap()); | 2926 EXPECT_FALSE(delegate->tap()); |
| 2927 EXPECT_FALSE(delegate->tap_cancel()); |
| 2833 EXPECT_FALSE(delegate->scroll_update()); | 2928 EXPECT_FALSE(delegate->scroll_update()); |
| 2834 EXPECT_FALSE(delegate->pinch_update()); | 2929 EXPECT_FALSE(delegate->pinch_update()); |
| 2835 | 2930 |
| 2836 delegate->Reset(); | 2931 delegate->Reset(); |
| 2837 } | 2932 } |
| 2838 | 2933 |
| 2839 } // namespace test | 2934 } // namespace test |
| 2840 } // namespace aura | 2935 } // namespace aura |
| OLD | NEW |