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/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/memory/scoped_vector.h" | 6 #include "base/memory/scoped_vector.h" |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/timer/timer.h" | 9 #include "base/timer/timer.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 ui::LatencyInfo latency_info_; | 328 ui::LatencyInfo latency_info_; |
329 | 329 |
330 ui::EventType wait_until_event_; | 330 ui::EventType wait_until_event_; |
331 | 331 |
332 DISALLOW_COPY_AND_ASSIGN(GestureEventConsumeDelegate); | 332 DISALLOW_COPY_AND_ASSIGN(GestureEventConsumeDelegate); |
333 }; | 333 }; |
334 | 334 |
335 class QueueTouchEventDelegate : public GestureEventConsumeDelegate { | 335 class QueueTouchEventDelegate : public GestureEventConsumeDelegate { |
336 public: | 336 public: |
337 explicit QueueTouchEventDelegate(WindowEventDispatcher* dispatcher) | 337 explicit QueueTouchEventDelegate(WindowEventDispatcher* dispatcher) |
338 : window_(NULL), | 338 : window_(NULL), dispatcher_(dispatcher) {} |
339 dispatcher_(dispatcher), | 339 virtual ~QueueTouchEventDelegate() {} |
340 queue_events_(true) { | |
341 } | |
342 virtual ~QueueTouchEventDelegate() { | |
343 while(!queue_.empty()) { | |
344 delete queue_.front(); | |
345 queue_.pop(); | |
346 } | |
347 } | |
348 | 340 |
349 virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE { | 341 virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE { |
350 if (queue_events_) { | 342 event->StopPropagation(); |
351 queue_.push(new ui::TouchEvent(*event, window_, window_)); | |
352 event->StopPropagation(); | |
353 } | |
354 } | 343 } |
355 | 344 |
356 void ReceivedAck() { | 345 void ReceivedAck() { |
357 ReceivedAckImpl(false); | 346 ReceivedAckImpl(false); |
358 } | 347 } |
359 | 348 |
360 void ReceivedAckPreventDefaulted() { | 349 void ReceivedAckPreventDefaulted() { |
361 ReceivedAckImpl(true); | 350 ReceivedAckImpl(true); |
362 } | 351 } |
363 | 352 |
364 void set_window(Window* w) { window_ = w; } | 353 void set_window(Window* w) { window_ = w; } |
365 void set_queue_events(bool queue) { queue_events_ = queue; } | |
366 | 354 |
367 private: | 355 private: |
368 void ReceivedAckImpl(bool prevent_defaulted) { | 356 void ReceivedAckImpl(bool prevent_defaulted) { |
369 scoped_ptr<ui::TouchEvent> event(queue_.front()); | 357 dispatcher_->ProcessedTouchEvent( |
370 dispatcher_->ProcessedTouchEvent(event.get(), window_, | 358 window_, prevent_defaulted ? ui::ER_HANDLED : ui::ER_UNHANDLED); |
371 prevent_defaulted ? ui::ER_HANDLED : ui::ER_UNHANDLED); | |
372 queue_.pop(); | |
373 } | 359 } |
374 | 360 |
375 std::queue<ui::TouchEvent*> queue_; | |
376 Window* window_; | 361 Window* window_; |
377 WindowEventDispatcher* dispatcher_; | 362 WindowEventDispatcher* dispatcher_; |
378 bool queue_events_; | |
379 | 363 |
380 DISALLOW_COPY_AND_ASSIGN(QueueTouchEventDelegate); | 364 DISALLOW_COPY_AND_ASSIGN(QueueTouchEventDelegate); |
381 }; | 365 }; |
382 | 366 |
383 // A delegate that ignores gesture events but keeps track of [synthetic] mouse | 367 // A delegate that ignores gesture events but keeps track of [synthetic] mouse |
384 // events. | 368 // events. |
385 class GestureEventSynthDelegate : public TestWindowDelegate { | 369 class GestureEventSynthDelegate : public TestWindowDelegate { |
386 public: | 370 public: |
387 GestureEventSynthDelegate() | 371 GestureEventSynthDelegate() |
388 : mouse_enter_(false), | 372 : mouse_enter_(false), |
(...skipping 3869 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4258 ui::TouchEvent move3( | 4242 ui::TouchEvent move3( |
4259 ui::ET_TOUCH_MOVED, gfx::Point(65, 202), kTouchId1, tes.Now()); | 4243 ui::ET_TOUCH_MOVED, gfx::Point(65, 202), kTouchId1, tes.Now()); |
4260 DispatchEventUsingWindowDispatcher(&move3); | 4244 DispatchEventUsingWindowDispatcher(&move3); |
4261 | 4245 |
4262 delegate->ReceivedAck(); | 4246 delegate->ReceivedAck(); |
4263 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE); | 4247 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE); |
4264 } | 4248 } |
4265 | 4249 |
4266 } // namespace test | 4250 } // namespace test |
4267 } // namespace aura | 4251 } // namespace aura |
OLD | NEW |