Chromium Code Reviews| 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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 152 }; | 152 }; |
| 153 | 153 |
| 154 // Selects dispatch method. Currently only supported on Mac. | 154 // Selects dispatch method. Currently only supported on Mac. |
| 155 void set_target(Target target) { target_ = target; } | 155 void set_target(Target target) { target_ = target; } |
| 156 Target target() const { return target_; } | 156 Target target() const { return target_; } |
| 157 | 157 |
| 158 // Resets the event flags bitmask. | 158 // Resets the event flags bitmask. |
| 159 void set_flags(int flags) { flags_ = flags; } | 159 void set_flags(int flags) { flags_ = flags; } |
| 160 int flags() const { return flags_; } | 160 int flags() const { return flags_; } |
| 161 | 161 |
| 162 // Many tests assume a window created at (0,0) will remain there when shown. | |
| 163 // However, an operating system's window manager may reposition the window | |
| 164 // into the work area. This can disrupt the coordinates used on test events, | |
| 165 // so an EventGeneratorDelegate may skip the step that remaps coordinates in | |
| 166 // the root window to window coordinates when dispatching events. | |
| 167 // Setting this to false skips that step, in which case the test must ensure | |
| 168 // it correctly maps coordinates in window coordinates to root window (screen) | |
| 169 // coordinates when calling, e.g., set_current_location(). | |
| 170 // Default is true. This only has any effect on Mac. | |
| 171 void set_assume_window_at_origin(bool assume_window_at_origin) { | |
|
sky
2017/04/05 15:39:53
Is a better name and description for this coordina
tapted
2017/04/05 23:57:18
I see how that would fit with the way the coordina
| |
| 172 assume_window_at_origin_ = assume_window_at_origin; | |
| 173 } | |
| 174 bool assume_window_at_origin() { return assume_window_at_origin_; } | |
| 175 | |
| 162 // Generates a left button press event. | 176 // Generates a left button press event. |
| 163 void PressLeftButton(); | 177 void PressLeftButton(); |
| 164 | 178 |
| 165 // Generates a left button release event. | 179 // Generates a left button release event. |
| 166 void ReleaseLeftButton(); | 180 void ReleaseLeftButton(); |
| 167 | 181 |
| 168 // Generates events to click (press, release) left button. | 182 // Generates events to click (press, release) left button. |
| 169 void ClickLeftButton(); | 183 void ClickLeftButton(); |
| 170 | 184 |
| 171 // Generates a double click event using the left button. | 185 // Generates a double click event using the left button. |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 439 | 453 |
| 440 // Offers event to pointer watchers (via delegate) if the event is a mouse or | 454 // Offers event to pointer watchers (via delegate) if the event is a mouse or |
| 441 // touch event. | 455 // touch event. |
| 442 void MaybeDispatchToPointerWatchers(const Event& event); | 456 void MaybeDispatchToPointerWatchers(const Event& event); |
| 443 | 457 |
| 444 const EventGeneratorDelegate* delegate() const; | 458 const EventGeneratorDelegate* delegate() const; |
| 445 EventGeneratorDelegate* delegate(); | 459 EventGeneratorDelegate* delegate(); |
| 446 | 460 |
| 447 std::unique_ptr<EventGeneratorDelegate> delegate_; | 461 std::unique_ptr<EventGeneratorDelegate> delegate_; |
| 448 gfx::Point current_location_; | 462 gfx::Point current_location_; |
| 449 EventTarget* current_target_; | 463 EventTarget* current_target_ = nullptr; |
| 450 int flags_; | 464 int flags_ = 0; |
| 451 bool grab_; | 465 bool grab_ = false; |
| 466 | |
| 452 ui::PointerDetails touch_pointer_details_; | 467 ui::PointerDetails touch_pointer_details_; |
| 453 | 468 |
| 454 std::list<std::unique_ptr<Event>> pending_events_; | 469 std::list<std::unique_ptr<Event>> pending_events_; |
| 470 | |
| 455 // Set to true to cause events to be posted asynchronously. | 471 // Set to true to cause events to be posted asynchronously. |
| 456 bool async_; | 472 bool async_ = false; |
| 457 Target target_; | 473 |
| 474 // Whether to skip mapping of coordinates from the root window to a hit window | |
| 475 // when dispatching events. | |
| 476 bool assume_window_at_origin_ = true; | |
|
tapted
2017/04/05 04:54:17
alternatively.. we could default this to `false` a
| |
| 477 | |
| 478 Target target_ = Target::WIDGET; | |
| 479 | |
| 458 std::unique_ptr<base::TickClock> tick_clock_; | 480 std::unique_ptr<base::TickClock> tick_clock_; |
| 459 | 481 |
| 460 DISALLOW_COPY_AND_ASSIGN(EventGenerator); | 482 DISALLOW_COPY_AND_ASSIGN(EventGenerator); |
| 461 }; | 483 }; |
| 462 | 484 |
| 463 } // namespace test | 485 } // namespace test |
| 464 } // namespace ui | 486 } // namespace ui |
| 465 | 487 |
| 466 #endif // UI_EVENTS_TEST_EVENT_GENERATOR_H_ | 488 #endif // UI_EVENTS_TEST_EVENT_GENERATOR_H_ |
| OLD | NEW |