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 window. | |
145 WINDOW, | |
146 // Default. Emulates default Window dispatch. Most robust. | |
147 WIDGET, | |
sadrul
2016/11/21 16:30:53
The difference between WINDOW and WIDGET isn't rea
themblsha
2016/11/21 17:02:20
Made the comments more verbose. "Currently only su
sadrul
2016/11/21 18:11:33
Whoops, I missed that comment :)
| |
148 }; | |
149 | |
150 // Selects dispatch method. Currently only supported on Mac. | |
151 void set_target(Target target) { target_ = target; } | |
152 Target target() const { return target_; } | |
143 | 153 |
144 // Resets the event flags bitmask. | 154 // Resets the event flags bitmask. |
145 void set_flags(int flags) { flags_ = flags; } | 155 void set_flags(int flags) { flags_ = flags; } |
146 int flags() const { return flags_; } | 156 int flags() const { return flags_; } |
147 | 157 |
148 // Generates a left button press event. | 158 // Generates a left button press event. |
149 void PressLeftButton(); | 159 void PressLeftButton(); |
150 | 160 |
151 // Generates a left button release event. | 161 // Generates a left button release event. |
152 void ReleaseLeftButton(); | 162 void ReleaseLeftButton(); |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
403 | 413 |
404 std::unique_ptr<EventGeneratorDelegate> delegate_; | 414 std::unique_ptr<EventGeneratorDelegate> delegate_; |
405 gfx::Point current_location_; | 415 gfx::Point current_location_; |
406 EventTarget* current_target_; | 416 EventTarget* current_target_; |
407 int flags_; | 417 int flags_; |
408 bool grab_; | 418 bool grab_; |
409 bool pen_pointer_mode_ = false; | 419 bool pen_pointer_mode_ = false; |
410 std::list<std::unique_ptr<Event>> pending_events_; | 420 std::list<std::unique_ptr<Event>> pending_events_; |
411 // Set to true to cause events to be posted asynchronously. | 421 // Set to true to cause events to be posted asynchronously. |
412 bool async_; | 422 bool async_; |
413 bool targeting_application_; | 423 Target target_; |
414 std::unique_ptr<base::TickClock> tick_clock_; | 424 std::unique_ptr<base::TickClock> tick_clock_; |
415 | 425 |
416 DISALLOW_COPY_AND_ASSIGN(EventGenerator); | 426 DISALLOW_COPY_AND_ASSIGN(EventGenerator); |
417 }; | 427 }; |
418 | 428 |
419 } // namespace test | 429 } // namespace test |
420 } // namespace ui | 430 } // namespace ui |
421 | 431 |
422 #endif // UI_EVENTS_TEST_EVENT_GENERATOR_H_ | 432 #endif // UI_EVENTS_TEST_EVENT_GENERATOR_H_ |
OLD | NEW |