Chromium Code Reviews
[email protected] (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Unified Diff: ui/aura/test/event_generator.h

Issue 11691010: Support multiple displays in EventGenerator (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/aura/test/event_generator.h
diff --git a/ui/aura/test/event_generator.h b/ui/aura/test/event_generator.h
index 1e1626c98b63368649c71a9ff29486eaf57436dd..f57f2425bd8ac0a98d39241fe6a8dc77dfa3164b 100644
--- a/ui/aura/test/event_generator.h
+++ b/ui/aura/test/event_generator.h
@@ -6,6 +6,7 @@
#define UI_AURA_TEST_EVENT_GENERATOR_H_
#include "base/basictypes.h"
+#include "base/memory/scoped_ptr.h"
#include "ui/base/keycodes/keyboard_codes.h"
#include "ui/gfx/point.h"
@@ -21,20 +22,47 @@ namespace aura {
class RootWindow;
class Window;
+namespace client {
+class ScreenPositionClient;
+}
+
namespace test {
-// EventGenerator is a tool that generates and dispatch events.
+// A delegate interface for EventGenerator that provides a way to
+// locate aura root window for given point.
+class EventGeneratorDelegate {
+ public:
+ virtual ~EventGeneratorDelegate() {}
+
+ // Returns a root window for given point.
+ virtual RootWindow* GetRootWindowAt(const gfx::Point& point) const = 0;
+
+ // Returns the screen position client that determines the
+ // coordinates used in EventGenerator. EventGenerator uses
+ // RootWindow's coordinate if this retruns NULL.
+ virtual client::ScreenPositionClient* GetScreenPositionClient(
+ const aura::Window* window) const = 0;
+};
+
+// EventGenerator is a tool that generates and dispatch events. The
+// coordinates of the points in API is determined by the
+// EventGeneratorDelegate.
class EventGenerator {
public:
- // Creates an EventGenerator with the mouse/touch location (0,0).
+ // Creates an EventGenerator with the mouse/touch location (0,0),
+ // which uses the |root_window|'s coordinates.
explicit EventGenerator(RootWindow* root_window);
+ // Create an EventGenerator with EventGeneratorDelegate,
+ // which uses the coordinates used by |delegate|.
+ explicit EventGenerator(EventGeneratorDelegate* delegate);
+
// Creates an EventGenerator with the mouse/touch location
- // at |initial_location|.
+ // at |initial_location|, which uses the |root_window|'s coordinates.
EventGenerator(RootWindow* root_window, const gfx::Point& initial_location);
// Creates an EventGenerator with the mouse/touch location
- // centered over |window|.
+ // centered over |window|, which uses the |root_window|'s coordinates.
EventGenerator(RootWindow* root_window, Window* window);
virtual ~EventGenerator();
@@ -176,13 +204,33 @@ class EventGenerator {
// Dispatch the |event| to the RootWindow.
void Dispatch(ui::Event& event);
+ void set_current_root_window(RootWindow* root_window) {
+ current_root_window_ = root_window;
+ }
+
private:
// Dispatch a key event to the RootWindow.
void DispatchKeyEvent(bool is_press, ui::KeyboardCode key_code, int flags);
- RootWindow* root_window_;
- int flags_;
+ void UpdateCurrentRootWindow(const gfx::Point& point);
+ void PressButton(int flag);
+ void ReleaseButton(int flag);
+
+ // Convert a point between API's coordinates and
+ // |target|'s coordinates.
+ void ConvertPointFromTarget(const aura::Window* target,
+ gfx::Point* point) const;
+ void ConvertPointToTarget(const aura::Window* target,
+ gfx::Point* point) const;
+
+ gfx::Point GetLocationInCurrentRoot() const;
+ gfx::Point CenterOfWindow(const Window* window) const;
+
+ scoped_ptr<EventGeneratorDelegate> delegate_;
gfx::Point current_location_;
+ RootWindow* current_root_window_;
+ int flags_;
+ bool grab_;
DISALLOW_COPY_AND_ASSIGN(EventGenerator);
};

Powered by Google App Engine
This is Rietveld 408576698