Chromium Code Reviews| 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 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 280 | 280 |
| 281 class QueueTouchEventDelegate : public GestureEventConsumeDelegate { | 281 class QueueTouchEventDelegate : public GestureEventConsumeDelegate { |
| 282 public: | 282 public: |
| 283 explicit QueueTouchEventDelegate(RootWindow* root_window) | 283 explicit QueueTouchEventDelegate(RootWindow* root_window) |
| 284 : window_(NULL), | 284 : window_(NULL), |
| 285 root_window_(root_window), | 285 root_window_(root_window), |
| 286 queue_events_(true) { | 286 queue_events_(true) { |
| 287 } | 287 } |
| 288 virtual ~QueueTouchEventDelegate() {} | 288 virtual ~QueueTouchEventDelegate() {} |
| 289 | 289 |
| 290 virtual ui::TouchStatus OnTouchEvent(ui::TouchEvent* event) OVERRIDE { | 290 virtual ui::EventResult OnTouchEvent(ui::TouchEvent* event) OVERRIDE { |
| 291 if (!queue_events_) | 291 if (!queue_events_) |
| 292 return ui::TOUCH_STATUS_UNKNOWN; | 292 return ui::ER_UNHANDLED; |
| 293 return event->type() == ui::ET_TOUCH_RELEASED ? | 293 return ui::ER_ASYNC; |
|
Ben Goodger (Google)
2012/09/26 19:42:48
you can use a ternary here, it should fit on one l
sadrul
2012/09/26 21:26:05
Done.
| |
| 294 ui::TOUCH_STATUS_QUEUED_END : ui::TOUCH_STATUS_QUEUED; | |
| 295 } | 294 } |
| 296 | 295 |
| 297 void ReceivedAck() { | 296 void ReceivedAck() { |
| 298 root_window_->AdvanceQueuedTouchEvent(window_, false); | 297 root_window_->AdvanceQueuedTouchEvent(window_, false); |
| 299 } | 298 } |
| 300 | 299 |
| 301 void ReceivedAckPreventDefaulted() { | 300 void ReceivedAckPreventDefaulted() { |
| 302 root_window_->AdvanceQueuedTouchEvent(window_, true); | 301 root_window_->AdvanceQueuedTouchEvent(window_, true); |
| 303 } | 302 } |
| 304 | 303 |
| (...skipping 2244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2549 | 2548 |
| 2550 // Same as GestureEventConsumeDelegate, but consumes all the touch-move events. | 2549 // Same as GestureEventConsumeDelegate, but consumes all the touch-move events. |
| 2551 class ConsumesTouchMovesDelegate : public GestureEventConsumeDelegate { | 2550 class ConsumesTouchMovesDelegate : public GestureEventConsumeDelegate { |
| 2552 public: | 2551 public: |
| 2553 ConsumesTouchMovesDelegate() : consume_touch_move_(true) {} | 2552 ConsumesTouchMovesDelegate() : consume_touch_move_(true) {} |
| 2554 virtual ~ConsumesTouchMovesDelegate() {} | 2553 virtual ~ConsumesTouchMovesDelegate() {} |
| 2555 | 2554 |
| 2556 void set_consume_touch_move(bool consume) { consume_touch_move_ = consume; } | 2555 void set_consume_touch_move(bool consume) { consume_touch_move_ = consume; } |
| 2557 | 2556 |
| 2558 private: | 2557 private: |
| 2559 virtual ui::TouchStatus OnTouchEvent(ui::TouchEvent* touch) OVERRIDE { | 2558 virtual ui::EventResult OnTouchEvent(ui::TouchEvent* touch) OVERRIDE { |
| 2560 if (consume_touch_move_ && touch->type() == ui::ET_TOUCH_MOVED) | 2559 if (consume_touch_move_ && touch->type() == ui::ET_TOUCH_MOVED) |
| 2561 return ui::TOUCH_STATUS_CONTINUE; | 2560 return ui::ER_HANDLED; |
| 2562 return GestureEventConsumeDelegate::OnTouchEvent(touch); | 2561 return GestureEventConsumeDelegate::OnTouchEvent(touch); |
| 2563 } | 2562 } |
| 2564 | 2563 |
| 2565 bool consume_touch_move_; | 2564 bool consume_touch_move_; |
| 2566 | 2565 |
| 2567 DISALLOW_COPY_AND_ASSIGN(ConsumesTouchMovesDelegate); | 2566 DISALLOW_COPY_AND_ASSIGN(ConsumesTouchMovesDelegate); |
| 2568 }; | 2567 }; |
| 2569 | 2568 |
| 2570 // Same as GestureEventScroll, but tests the different behaviour for consumed | 2569 // Same as GestureEventScroll, but tests the different behaviour for consumed |
| 2571 // touch-move events before and after scroll has started. | 2570 // touch-move events before and after scroll has started. |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2851 EXPECT_FALSE(delegate->tap()); | 2850 EXPECT_FALSE(delegate->tap()); |
| 2852 EXPECT_FALSE(delegate->tap_cancel()); | 2851 EXPECT_FALSE(delegate->tap_cancel()); |
| 2853 EXPECT_FALSE(delegate->scroll_update()); | 2852 EXPECT_FALSE(delegate->scroll_update()); |
| 2854 EXPECT_FALSE(delegate->pinch_update()); | 2853 EXPECT_FALSE(delegate->pinch_update()); |
| 2855 | 2854 |
| 2856 delegate->Reset(); | 2855 delegate->Reset(); |
| 2857 } | 2856 } |
| 2858 | 2857 |
| 2859 } // namespace test | 2858 } // namespace test |
| 2860 } // namespace aura | 2859 } // namespace aura |
| OLD | NEW |