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