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/run_loop.h" | 6 #include "base/run_loop.h" |
7 #include "base/string_number_conversions.h" | 7 #include "base/string_number_conversions.h" |
8 #include "base/timer.h" | 8 #include "base/timer.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "ui/aura/env.h" | 10 #include "ui/aura/env.h" |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 | 303 |
304 class QueueTouchEventDelegate : public GestureEventConsumeDelegate { | 304 class QueueTouchEventDelegate : public GestureEventConsumeDelegate { |
305 public: | 305 public: |
306 explicit QueueTouchEventDelegate(RootWindow* root_window) | 306 explicit QueueTouchEventDelegate(RootWindow* root_window) |
307 : window_(NULL), | 307 : window_(NULL), |
308 root_window_(root_window), | 308 root_window_(root_window), |
309 queue_events_(true) { | 309 queue_events_(true) { |
310 } | 310 } |
311 virtual ~QueueTouchEventDelegate() {} | 311 virtual ~QueueTouchEventDelegate() {} |
312 | 312 |
313 virtual ui::EventResult OnTouchEvent(ui::TouchEvent* event) OVERRIDE { | 313 virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE { |
314 if (queue_events_) { | 314 if (queue_events_) { |
315 queue_.push(new ui::TouchEvent(*event, window_, window_)); | 315 queue_.push(new ui::TouchEvent(*event, window_, window_)); |
316 return ui::ER_CONSUMED; | 316 event->StopPropagation(); |
317 } | 317 } |
318 return ui::ER_UNHANDLED; | |
319 } | 318 } |
320 | 319 |
321 void ReceivedAck() { | 320 void ReceivedAck() { |
322 ReceivedAckImpl(false); | 321 ReceivedAckImpl(false); |
323 } | 322 } |
324 | 323 |
325 void ReceivedAckPreventDefaulted() { | 324 void ReceivedAckPreventDefaulted() { |
326 ReceivedAckImpl(true); | 325 ReceivedAckImpl(true); |
327 } | 326 } |
328 | 327 |
(...skipping 2269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2598 | 2597 |
2599 // Same as GestureEventConsumeDelegate, but consumes all the touch-move events. | 2598 // Same as GestureEventConsumeDelegate, but consumes all the touch-move events. |
2600 class ConsumesTouchMovesDelegate : public GestureEventConsumeDelegate { | 2599 class ConsumesTouchMovesDelegate : public GestureEventConsumeDelegate { |
2601 public: | 2600 public: |
2602 ConsumesTouchMovesDelegate() : consume_touch_move_(true) {} | 2601 ConsumesTouchMovesDelegate() : consume_touch_move_(true) {} |
2603 virtual ~ConsumesTouchMovesDelegate() {} | 2602 virtual ~ConsumesTouchMovesDelegate() {} |
2604 | 2603 |
2605 void set_consume_touch_move(bool consume) { consume_touch_move_ = consume; } | 2604 void set_consume_touch_move(bool consume) { consume_touch_move_ = consume; } |
2606 | 2605 |
2607 private: | 2606 private: |
2608 virtual ui::EventResult OnTouchEvent(ui::TouchEvent* touch) OVERRIDE { | 2607 virtual void OnTouchEvent(ui::TouchEvent* touch) OVERRIDE { |
2609 if (consume_touch_move_ && touch->type() == ui::ET_TOUCH_MOVED) | 2608 if (consume_touch_move_ && touch->type() == ui::ET_TOUCH_MOVED) |
2610 return ui::ER_HANDLED; | 2609 touch->SetHandled(); |
2611 return GestureEventConsumeDelegate::OnTouchEvent(touch); | 2610 else |
| 2611 GestureEventConsumeDelegate::OnTouchEvent(touch); |
2612 } | 2612 } |
2613 | 2613 |
2614 bool consume_touch_move_; | 2614 bool consume_touch_move_; |
2615 | 2615 |
2616 DISALLOW_COPY_AND_ASSIGN(ConsumesTouchMovesDelegate); | 2616 DISALLOW_COPY_AND_ASSIGN(ConsumesTouchMovesDelegate); |
2617 }; | 2617 }; |
2618 | 2618 |
2619 // Same as GestureEventScroll, but tests that the behavior is the same | 2619 // Same as GestureEventScroll, but tests that the behavior is the same |
2620 // even if all the touch-move events are consumed. | 2620 // even if all the touch-move events are consumed. |
2621 TEST_F(GestureRecognizerTest, GestureEventScrollTouchMoveConsumed) { | 2621 TEST_F(GestureRecognizerTest, GestureEventScrollTouchMoveConsumed) { |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3016 press1.time_stamp() + base::TimeDelta::FromMilliseconds(40)); | 3016 press1.time_stamp() + base::TimeDelta::FromMilliseconds(40)); |
3017 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move4); | 3017 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move4); |
3018 EXPECT_TRUE(delegate->scroll_update()); | 3018 EXPECT_TRUE(delegate->scroll_update()); |
3019 EXPECT_EQ(-1, delegate->scroll_y()); | 3019 EXPECT_EQ(-1, delegate->scroll_y()); |
3020 | 3020 |
3021 delegate->Reset(); | 3021 delegate->Reset(); |
3022 } | 3022 } |
3023 | 3023 |
3024 } // namespace test | 3024 } // namespace test |
3025 } // namespace aura | 3025 } // namespace aura |
OLD | NEW |