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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 // various methods that take a location but can be manipulated directly, | 127 // various methods that take a location but can be manipulated directly, |
128 // typically for touch. | 128 // typically for touch. |
129 void set_current_location(const gfx::Point& location) { | 129 void set_current_location(const gfx::Point& location) { |
130 current_location_ = location; | 130 current_location_ = location; |
131 } | 131 } |
132 const gfx::Point& current_location() const { return current_location_; } | 132 const gfx::Point& current_location() const { return current_location_; } |
133 | 133 |
134 void set_async(bool async) { async_ = async; } | 134 void set_async(bool async) { async_ = async; } |
135 bool async() const { return async_; } | 135 bool async() const { return async_; } |
136 | 136 |
137 // Dispatch events through the application instead of directly to the | 137 // Events could be dispatched using different methods. The choice is a |
138 // target window. Currently only supported on Mac. | 138 // tradeoff between test robustness and coverage of OS internals that affect |
139 void set_targeting_application(bool targeting_application) { | 139 // event dispatch. |
140 targeting_application_ = targeting_application; | 140 // Currently only supported on Mac. |
141 } | 141 enum class Target { |
142 bool targeting_application() const { return targeting_application_; } | 142 // Dispatch through the application. Least robust. |
| 143 APPLICATION, |
| 144 // Dispatch directly to target NSWindow via -sendEvent:. |
| 145 WINDOW, |
| 146 // Default. Emulates default NSWindow dispatch: calls specific event handler |
| 147 // based on event type. Most robust. |
| 148 WIDGET, |
| 149 }; |
| 150 |
| 151 // Selects dispatch method. Currently only supported on Mac. |
| 152 void set_target(Target target) { target_ = target; } |
| 153 Target target() const { return target_; } |
143 | 154 |
144 // Resets the event flags bitmask. | 155 // Resets the event flags bitmask. |
145 void set_flags(int flags) { flags_ = flags; } | 156 void set_flags(int flags) { flags_ = flags; } |
146 int flags() const { return flags_; } | 157 int flags() const { return flags_; } |
147 | 158 |
148 // Generates a left button press event. | 159 // Generates a left button press event. |
149 void PressLeftButton(); | 160 void PressLeftButton(); |
150 | 161 |
151 // Generates a left button release event. | 162 // Generates a left button release event. |
152 void ReleaseLeftButton(); | 163 void ReleaseLeftButton(); |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 | 414 |
404 std::unique_ptr<EventGeneratorDelegate> delegate_; | 415 std::unique_ptr<EventGeneratorDelegate> delegate_; |
405 gfx::Point current_location_; | 416 gfx::Point current_location_; |
406 EventTarget* current_target_; | 417 EventTarget* current_target_; |
407 int flags_; | 418 int flags_; |
408 bool grab_; | 419 bool grab_; |
409 bool pen_pointer_mode_ = false; | 420 bool pen_pointer_mode_ = false; |
410 std::list<std::unique_ptr<Event>> pending_events_; | 421 std::list<std::unique_ptr<Event>> pending_events_; |
411 // Set to true to cause events to be posted asynchronously. | 422 // Set to true to cause events to be posted asynchronously. |
412 bool async_; | 423 bool async_; |
413 bool targeting_application_; | 424 Target target_; |
414 std::unique_ptr<base::TickClock> tick_clock_; | 425 std::unique_ptr<base::TickClock> tick_clock_; |
415 | 426 |
416 DISALLOW_COPY_AND_ASSIGN(EventGenerator); | 427 DISALLOW_COPY_AND_ASSIGN(EventGenerator); |
417 }; | 428 }; |
418 | 429 |
419 } // namespace test | 430 } // namespace test |
420 } // namespace ui | 431 } // namespace ui |
421 | 432 |
422 #endif // UI_EVENTS_TEST_EVENT_GENERATOR_H_ | 433 #endif // UI_EVENTS_TEST_EVENT_GENERATOR_H_ |
OLD | NEW |