| 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 return queue_events_ ? ui::ER_ASYNC : ui::ER_UNHANDLED; |
| 292 return ui::TOUCH_STATUS_UNKNOWN; | |
| 293 return event->type() == ui::ET_TOUCH_RELEASED ? | |
| 294 ui::TOUCH_STATUS_QUEUED_END : ui::TOUCH_STATUS_QUEUED; | |
| 295 } | 292 } |
| 296 | 293 |
| 297 void ReceivedAck() { | 294 void ReceivedAck() { |
| 298 root_window_->AdvanceQueuedTouchEvent(window_, false); | 295 root_window_->AdvanceQueuedTouchEvent(window_, false); |
| 299 } | 296 } |
| 300 | 297 |
| 301 void ReceivedAckPreventDefaulted() { | 298 void ReceivedAckPreventDefaulted() { |
| 302 root_window_->AdvanceQueuedTouchEvent(window_, true); | 299 root_window_->AdvanceQueuedTouchEvent(window_, true); |
| 303 } | 300 } |
| 304 | 301 |
| (...skipping 2244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2549 | 2546 |
| 2550 // Same as GestureEventConsumeDelegate, but consumes all the touch-move events. | 2547 // Same as GestureEventConsumeDelegate, but consumes all the touch-move events. |
| 2551 class ConsumesTouchMovesDelegate : public GestureEventConsumeDelegate { | 2548 class ConsumesTouchMovesDelegate : public GestureEventConsumeDelegate { |
| 2552 public: | 2549 public: |
| 2553 ConsumesTouchMovesDelegate() : consume_touch_move_(true) {} | 2550 ConsumesTouchMovesDelegate() : consume_touch_move_(true) {} |
| 2554 virtual ~ConsumesTouchMovesDelegate() {} | 2551 virtual ~ConsumesTouchMovesDelegate() {} |
| 2555 | 2552 |
| 2556 void set_consume_touch_move(bool consume) { consume_touch_move_ = consume; } | 2553 void set_consume_touch_move(bool consume) { consume_touch_move_ = consume; } |
| 2557 | 2554 |
| 2558 private: | 2555 private: |
| 2559 virtual ui::TouchStatus OnTouchEvent(ui::TouchEvent* touch) OVERRIDE { | 2556 virtual ui::EventResult OnTouchEvent(ui::TouchEvent* touch) OVERRIDE { |
| 2560 if (consume_touch_move_ && touch->type() == ui::ET_TOUCH_MOVED) | 2557 if (consume_touch_move_ && touch->type() == ui::ET_TOUCH_MOVED) |
| 2561 return ui::TOUCH_STATUS_CONTINUE; | 2558 return ui::ER_HANDLED; |
| 2562 return GestureEventConsumeDelegate::OnTouchEvent(touch); | 2559 return GestureEventConsumeDelegate::OnTouchEvent(touch); |
| 2563 } | 2560 } |
| 2564 | 2561 |
| 2565 bool consume_touch_move_; | 2562 bool consume_touch_move_; |
| 2566 | 2563 |
| 2567 DISALLOW_COPY_AND_ASSIGN(ConsumesTouchMovesDelegate); | 2564 DISALLOW_COPY_AND_ASSIGN(ConsumesTouchMovesDelegate); |
| 2568 }; | 2565 }; |
| 2569 | 2566 |
| 2570 // Same as GestureEventScroll, but tests the different behaviour for consumed | 2567 // Same as GestureEventScroll, but tests the different behaviour for consumed |
| 2571 // touch-move events before and after scroll has started. | 2568 // touch-move events before and after scroll has started. |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2905 press1.time_stamp() + base::TimeDelta::FromMilliseconds(40)); | 2902 press1.time_stamp() + base::TimeDelta::FromMilliseconds(40)); |
| 2906 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move4); | 2903 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move4); |
| 2907 EXPECT_TRUE(delegate->scroll_update()); | 2904 EXPECT_TRUE(delegate->scroll_update()); |
| 2908 EXPECT_EQ(-1, delegate->scroll_y()); | 2905 EXPECT_EQ(-1, delegate->scroll_y()); |
| 2909 | 2906 |
| 2910 delegate->Reset(); | 2907 delegate->Reset(); |
| 2911 } | 2908 } |
| 2912 | 2909 |
| 2913 } // namespace test | 2910 } // namespace test |
| 2914 } // namespace aura | 2911 } // namespace aura |
| OLD | NEW |