Chromium Code Reviews| Index: ui/aura/gestures/gesture_recognizer_unittest.cc |
| diff --git a/ui/aura/gestures/gesture_recognizer_unittest.cc b/ui/aura/gestures/gesture_recognizer_unittest.cc |
| index 963b24dac9c16db7845d6839a14f86743cac1941..71fb75b366ac076857478b2c9fbda06a454e7a2f 100644 |
| --- a/ui/aura/gestures/gesture_recognizer_unittest.cc |
| +++ b/ui/aura/gestures/gesture_recognizer_unittest.cc |
| @@ -605,7 +605,7 @@ class TestEventHandler : public ui::EventHandler { |
| TestEventHandler() : touch_released_count_(0), |
| touch_pressed_count_(0), |
| touch_moved_count_(0), |
| - touch_cancelled_count_(0) { |
| + touch_points_() { |
|
tdresser
2014/08/13 19:57:57
You don't need to initialize the std::vector.
lanwei
2014/08/14 00:38:45
Done.
|
| } |
| virtual ~TestEventHandler() {} |
| @@ -622,7 +622,7 @@ class TestEventHandler : public ui::EventHandler { |
| touch_moved_count_++; |
| break; |
| case ui::ET_TOUCH_CANCELLED: |
| - touch_cancelled_count_++; |
| + touch_points_.push_back(event->location()); |
| break; |
| default: |
| break; |
| @@ -633,19 +633,20 @@ class TestEventHandler : public ui::EventHandler { |
| touch_released_count_ = 0; |
| touch_pressed_count_ = 0; |
| touch_moved_count_ = 0; |
| - touch_cancelled_count_ = 0; |
| + touch_points_.clear(); |
| } |
| int touch_released_count() const { return touch_released_count_; } |
| int touch_pressed_count() const { return touch_pressed_count_; } |
| int touch_moved_count() const { return touch_moved_count_; } |
| - int touch_cancelled_count() const { return touch_cancelled_count_; } |
| + int touch_cancelled_count() const { return (int) touch_points_.size(); } |
|
tdresser
2014/08/13 19:57:58
Use static_cast<int>(touch_points_.size());
We don
lanwei
2014/08/14 00:38:46
Done.
|
| + std::vector<gfx::PointF> touch_points() const { return touch_points_; } |
|
tdresser
2014/08/13 19:57:57
Return a const std::vector<gfx::PointF>&, to avoid
lanwei
2014/08/14 00:38:46
Done.
|
| private: |
| int touch_released_count_; |
| int touch_pressed_count_; |
| int touch_moved_count_; |
| - int touch_cancelled_count_; |
| + std::vector<gfx::PointF> touch_points_; |
| DISALLOW_COPY_AND_ASSIGN(TestEventHandler); |
| }; |
| @@ -3769,6 +3770,10 @@ TEST_P(GestureRecognizerTest, GestureEventConsumedTouchMoveCanFireTapCancel) { |
| TEST_P(GestureRecognizerTest, |
| TransferEventDispatchesTouchCancel) { |
| + // Disabled for not unified GR |
|
tdresser
2014/08/13 19:57:57
This is a little hard to read (double negative!)
M
lanwei
2014/08/14 00:38:46
Done.
|
| + if (!UsingUnifiedGR()) |
| + return; |
| + |
| scoped_ptr<GestureEventConsumeDelegate> delegate( |
| new GestureEventConsumeDelegate()); |
| TimedEvents tes; |
| @@ -3778,8 +3783,8 @@ TEST_P(GestureRecognizerTest, |
| gfx::Rect bounds(0, 0, kWindowWidth, kWindowHeight); |
| scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| delegate.get(), -1234, bounds, root_window())); |
| - scoped_ptr<RemoveOnTouchCancelHandler> |
|
tdresser
2014/08/13 19:57:58
We should be able to delete the RemoveOnTouchCance
lanwei
2014/08/14 00:38:45
Done.
|
| - handler(new RemoveOnTouchCancelHandler()); |
| + scoped_ptr<TestEventHandler> |
|
tdresser
2014/08/13 19:57:57
Would this fit on one line?
lanwei
2014/08/14 00:38:46
Done.
|
| + handler(new TestEventHandler()); |
| window->AddPreTargetHandler(handler.get()); |
| // Start a gesture sequence on |window|. Then transfer the events to NULL. |
| @@ -3787,13 +3792,23 @@ TEST_P(GestureRecognizerTest, |
| delegate->Reset(); |
| ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
| kTouchId, tes.Now()); |
| - ui::TouchEvent p2(ui::ET_TOUCH_PRESSED, gfx::Point(50, 50), 1, tes.Now()); |
| DispatchEventUsingWindowDispatcher(&press); |
| + EXPECT_2_EVENTS(delegate->events(), |
| + ui::ET_GESTURE_BEGIN, |
|
tdresser
2014/08/13 19:57:58
These aren't indented correctly (silly eclipse).
lanwei
2014/08/14 00:38:46
Done.
|
| + ui::ET_GESTURE_TAP_DOWN); |
| + delegate->Reset(); |
| + ui::TouchEvent p2(ui::ET_TOUCH_PRESSED, gfx::Point(50, 50), 1, tes.Now()); |
|
tdresser
2014/08/13 19:57:57
Store the touch id in another const int, similar t
lanwei
2014/08/14 00:38:45
Done.
|
| DispatchEventUsingWindowDispatcher(&p2); |
| - EXPECT_FALSE(delegate->tap()); |
| - EXPECT_TRUE(delegate->tap_down()); |
| - EXPECT_TRUE(delegate->tap_cancel()); |
| - EXPECT_TRUE(delegate->begin()); |
| + EXPECT_2_EVENTS(delegate->events(), |
| + ui::ET_GESTURE_TAP_CANCEL, |
| + ui::ET_GESTURE_BEGIN); |
| + delegate->Reset(); |
| + ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(350, 300), 1, tes.Now()); |
| + DispatchEventUsingWindowDispatcher(&move); |
| + EXPECT_3_EVENTS(delegate->events(), |
| + ui::ET_GESTURE_SCROLL_BEGIN, |
| + ui::ET_GESTURE_SCROLL_UPDATE, |
| + ui::ET_GESTURE_PINCH_BEGIN); |
| EXPECT_EQ(2, handler->touch_pressed_count()); |
| delegate->Reset(); |
| handler->Reset(); |
| @@ -3804,9 +3819,15 @@ TEST_P(GestureRecognizerTest, |
| gesture_recognizer->TransferEventsTo(window.get(), NULL); |
| EXPECT_EQ(NULL, |
| gesture_recognizer->GetTouchLockedTarget(press)); |
| - // The event-handler removes |window| from its parent on the first |
| - // touch-cancel event, so it won't receive the second touch-cancel event. |
| - EXPECT_EQ(1, handler->touch_cancelled_count()); |
| + EXPECT_4_EVENTS(delegate->events(), |
| + ui::ET_GESTURE_PINCH_END, |
| + ui::ET_GESTURE_SCROLL_END, |
| + ui::ET_GESTURE_END, |
| + ui::ET_GESTURE_END); |
| + const std::vector<gfx::PointF>& points = handler->touch_points(); |
| + EXPECT_EQ(2, (int) points.size()); |
|
tdresser
2014/08/13 19:57:57
To avoid the cast:
EXPECT_EQ(2U, points.size());
lanwei
2014/08/14 00:38:46
Done.
|
| + EXPECT_EQ(gfx::Point(350, 300), points[0]); |
| + EXPECT_EQ(gfx::Point(101, 201), points[1]); |
| } |
| // Check that appropriate touch events generate show press events |