| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef UI_EVENTS_TEST_EVENT_GENERATOR_H_ | 5 #ifndef UI_EVENTS_TEST_EVENT_GENERATOR_H_ |
| 6 #define UI_EVENTS_TEST_EVENT_GENERATOR_H_ | 6 #define UI_EVENTS_TEST_EVENT_GENERATOR_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 virtual void ConvertPointFromTarget(const EventTarget* target, | 62 virtual void ConvertPointFromTarget(const EventTarget* target, |
| 63 gfx::Point* point) const = 0; | 63 gfx::Point* point) const = 0; |
| 64 virtual void ConvertPointToTarget(const EventTarget* target, | 64 virtual void ConvertPointToTarget(const EventTarget* target, |
| 65 gfx::Point* point) const = 0; | 65 gfx::Point* point) const = 0; |
| 66 | 66 |
| 67 // Convert a point from the coordinate system in the host that contains | 67 // Convert a point from the coordinate system in the host that contains |
| 68 // |hosted_target| into the root window's coordinate system. | 68 // |hosted_target| into the root window's coordinate system. |
| 69 virtual void ConvertPointFromHost(const EventTarget* hosted_target, | 69 virtual void ConvertPointFromHost(const EventTarget* hosted_target, |
| 70 gfx::Point* point) const = 0; | 70 gfx::Point* point) const = 0; |
| 71 | 71 |
| 72 // Detemines whether the input method should be the first to handle key events | 72 // Determines if the input method should be the first to handle key events |
| 73 // before dispathcing to Views. If it does, the given |event| will be | 73 // before dispatching to Views. If it does, the given |event| will be |
| 74 // dispatched and processed by the input method from the host of |target|. | 74 // dispatched and processed by the input method from the host of |target|. |
| 75 virtual void DispatchKeyEventToIME(EventTarget* target, | 75 virtual void DispatchKeyEventToIME(EventTarget* target, |
| 76 ui::KeyEvent* event) = 0; | 76 ui::KeyEvent* event) = 0; |
| 77 |
| 78 // Offers the event to pointer watchers on systems that provide them. |
| 79 // Does not consume the event (pointer watchers cannot consume events). |
| 80 virtual void DispatchEventToPointerWatchers(EventTarget* target, |
| 81 const PointerEvent& event) {} |
| 77 }; | 82 }; |
| 78 | 83 |
| 79 // ui::test::EventGenerator is a tool that generates and dispatches events. | 84 // ui::test::EventGenerator is a tool that generates and dispatches events. |
| 80 // Unlike |ui_controls| package in ui/base/test, this does not use platform | 85 // Unlike |ui_controls| package in ui/base/test, this does not use platform |
| 81 // native message loops. Instead, it sends events to the event dispatcher | 86 // native message loops. Instead, it sends events to the event dispatcher |
| 82 // synchronously. | 87 // synchronously. |
| 83 // | 88 // |
| 84 // This class is not suited for the following cases: | 89 // This class is not suited for the following cases: |
| 85 // | 90 // |
| 86 // 1) If your test depends on native events (ui::Event::native_event()). | 91 // 1) If your test depends on native events (ui::Event::native_event()). |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 void UpdateCurrentDispatcher(const gfx::Point& point); | 430 void UpdateCurrentDispatcher(const gfx::Point& point); |
| 426 void PressButton(int flag); | 431 void PressButton(int flag); |
| 427 void ReleaseButton(int flag); | 432 void ReleaseButton(int flag); |
| 428 | 433 |
| 429 gfx::Point GetLocationInCurrentRoot() const; | 434 gfx::Point GetLocationInCurrentRoot() const; |
| 430 gfx::Point CenterOfWindow(const EventTarget* window) const; | 435 gfx::Point CenterOfWindow(const EventTarget* window) const; |
| 431 | 436 |
| 432 void DispatchNextPendingEvent(); | 437 void DispatchNextPendingEvent(); |
| 433 void DoDispatchEvent(Event* event, bool async); | 438 void DoDispatchEvent(Event* event, bool async); |
| 434 | 439 |
| 440 // Offers event to pointer watchers (via delegate) if the event is a mouse or |
| 441 // touch event. |
| 442 void MaybeDispatchToPointerWatchers(const Event& event); |
| 443 |
| 435 const EventGeneratorDelegate* delegate() const; | 444 const EventGeneratorDelegate* delegate() const; |
| 436 EventGeneratorDelegate* delegate(); | 445 EventGeneratorDelegate* delegate(); |
| 437 | 446 |
| 438 std::unique_ptr<EventGeneratorDelegate> delegate_; | 447 std::unique_ptr<EventGeneratorDelegate> delegate_; |
| 439 gfx::Point current_location_; | 448 gfx::Point current_location_; |
| 440 EventTarget* current_target_; | 449 EventTarget* current_target_; |
| 441 int flags_; | 450 int flags_; |
| 442 bool grab_; | 451 bool grab_; |
| 443 ui::PointerDetails touch_pointer_details_; | 452 ui::PointerDetails touch_pointer_details_; |
| 444 | 453 |
| 445 std::list<std::unique_ptr<Event>> pending_events_; | 454 std::list<std::unique_ptr<Event>> pending_events_; |
| 446 // Set to true to cause events to be posted asynchronously. | 455 // Set to true to cause events to be posted asynchronously. |
| 447 bool async_; | 456 bool async_; |
| 448 Target target_; | 457 Target target_; |
| 449 std::unique_ptr<base::TickClock> tick_clock_; | 458 std::unique_ptr<base::TickClock> tick_clock_; |
| 450 | 459 |
| 451 DISALLOW_COPY_AND_ASSIGN(EventGenerator); | 460 DISALLOW_COPY_AND_ASSIGN(EventGenerator); |
| 452 }; | 461 }; |
| 453 | 462 |
| 454 } // namespace test | 463 } // namespace test |
| 455 } // namespace ui | 464 } // namespace ui |
| 456 | 465 |
| 457 #endif // UI_EVENTS_TEST_EVENT_GENERATOR_H_ | 466 #endif // UI_EVENTS_TEST_EVENT_GENERATOR_H_ |
| OLD | NEW |