Index: ui/aura/test/event_generator.h |
diff --git a/ui/aura/test/event_generator.h b/ui/aura/test/event_generator.h |
index c436d3fbd1165571fdcaaf950577ca499dbaa3e2..d5c345ebdc59e0cbcda283125453a72500c0ac79 100644 |
--- a/ui/aura/test/event_generator.h |
+++ b/ui/aura/test/event_generator.h |
@@ -12,6 +12,7 @@ |
#include "base/callback.h" |
#include "base/memory/scoped_ptr.h" |
#include "base/time/time.h" |
+#include "ui/base/test/event_generator_base.h" |
#include "ui/events/event_constants.h" |
#include "ui/events/keycodes/keyboard_codes.h" |
#include "ui/gfx/point.h" |
@@ -80,7 +81,7 @@ class EventGeneratorDelegate { |
// |
// Note: The coordinates of the points in API is determined by the |
// EventGeneratorDelegate. |
-class EventGenerator { |
+class EventGenerator : public ui::test::EventGeneratorBase { |
public: |
// Creates an EventGenerator with the mouse/touch location (0,0), |
// which uses the |root_window|'s coordinates. |
@@ -100,38 +101,9 @@ class EventGenerator { |
virtual ~EventGenerator(); |
- // Explicitly sets the location used by mouse/touch events. This is set by the |
- // various methods that take a location but can be manipulated directly, |
- // typically for touch. |
- void set_current_location(const gfx::Point& location) { |
- current_location_ = location; |
- } |
- const gfx::Point& current_location() const { return current_location_; } |
- |
void set_async(bool async) { async_ = async; } |
bool async() const { return async_; } |
- // Resets the event flags bitmask. |
- void set_flags(int flags) { flags_ = flags; } |
- |
- // Generates a left button press event. |
- void PressLeftButton(); |
- |
- // Generates a left button release event. |
- void ReleaseLeftButton(); |
- |
- // Generates events to click (press, release) left button. |
- void ClickLeftButton(); |
- |
- // Generates a double click event using the left button. |
- void DoubleClickLeftButton(); |
- |
- // Generates a right button press event. |
- void PressRightButton(); |
- |
- // Generates a right button release event. |
- void ReleaseRightButton(); |
- |
// Moves the mouse wheel by |delta_x|, |delta_y|. |
void MoveMouseWheel(int delta_x, int delta_y); |
@@ -145,16 +117,6 @@ class EventGenerator { |
MoveMouseToInHost(gfx::Point(x, y)); |
} |
- // Generates events to move mouse to be the given |point| in screen |
- // coordinates. |
- void MoveMouseTo(const gfx::Point& point_in_screen, int count); |
- void MoveMouseTo(const gfx::Point& point_in_screen) { |
- MoveMouseTo(point_in_screen, 1); |
- } |
- void MoveMouseTo(int x, int y) { |
- MoveMouseTo(gfx::Point(x, y)); |
- } |
- |
// Generates events to move mouse to be the given |point| in |window|'s |
// coordinates. |
void MoveMouseRelativeTo(const Window* window, const gfx::Point& point); |
@@ -163,18 +125,7 @@ class EventGenerator { |
} |
void MoveMouseBy(int x, int y) { |
- MoveMouseTo(current_location_ + gfx::Vector2d(x, y)); |
- } |
- |
- // Generates events to drag mouse to given |point|. |
- void DragMouseTo(const gfx::Point& point); |
- |
- void DragMouseTo(int x, int y) { |
- DragMouseTo(gfx::Point(x, y)); |
- } |
- |
- void DragMouseBy(int dx, int dy) { |
- DragMouseTo(current_location_ + gfx::Vector2d(dx, dy)); |
+ MoveMouseTo(current_location() + gfx::Vector2d(x, y)); |
} |
// Generates events to move the mouse to the center of the window. |
@@ -207,7 +158,7 @@ class EventGenerator { |
} |
void PressMoveAndReleaseTouchBy(int x, int y) { |
- PressMoveAndReleaseTouchTo(current_location_ + gfx::Vector2d(x, y)); |
+ PressMoveAndReleaseTouchTo(current_location() + gfx::Vector2d(x, y)); |
} |
// Generates press, move and release events to move touch |
@@ -324,13 +275,21 @@ class EventGenerator { |
// Get the current time from the tick clock. |
base::TimeDelta Now(); |
+ protected: |
+ // Overridden from EventGeneratorBase: |
+ virtual gfx::Point GetLocationInCurrentRoot() const OVERRIDE; |
+ virtual void DoMoveMouseTo(const gfx::Point& point_in_screen, |
+ int count) OVERRIDE; |
+ virtual void DispatchMouseEvent(ui::EventType type, |
+ const gfx::Point& location_in_root, |
+ int flags, |
+ int changed_button_flags) OVERRIDE; |
+ |
private: |
// Dispatch a key event to the WindowEventDispatcher. |
void DispatchKeyEvent(bool is_press, ui::KeyboardCode key_code, int flags); |
void UpdateCurrentDispatcher(const gfx::Point& point); |
- void PressButton(int flag); |
- void ReleaseButton(int flag); |
// Convert a point between API's coordinates and |
// |target|'s coordinates. |
@@ -339,17 +298,13 @@ class EventGenerator { |
void ConvertPointToTarget(const aura::Window* target, |
gfx::Point* point) const; |
- gfx::Point GetLocationInCurrentRoot() const; |
gfx::Point CenterOfWindow(const Window* window) const; |
void DispatchNextPendingEvent(); |
void DoDispatchEvent(ui::Event* event, bool async); |
scoped_ptr<EventGeneratorDelegate> delegate_; |
- gfx::Point current_location_; |
WindowTreeHost* current_host_; |
Ben Goodger (Google)
2014/07/11 18:26:49
so if I understand this correctly the issue you're
sadrul
2014/07/12 07:10:53
I think this is a good idea! Having a generic Even
tapted
2014/07/14 11:37:47
Done.
|
- int flags_; |
- bool grab_; |
std::list<ui::Event*> pending_events_; |
// Set to true to cause events to be posted asynchronously. |
bool async_; |