Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(101)

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

Issue 8273040: Minimum size for aura window (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed comments. moved&merged tests Created 9 years, 2 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
new file mode 100644
index 0000000000000000000000000000000000000000..280b098804070d84fbc5fd9cae09e5f3b1497653
--- /dev/null
+++ b/ui/aura/test/event_generator.h
@@ -0,0 +1,80 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_AURA_TEST_EVENT_GENERATOR_H_
+#define UI_AURA_TEST_EVENT_GENERATOR_H_
+#pragma once
+
+#include "base/basictypes.h"
+#include "ui/gfx/point.h"
+
+namespace aura {
+class Event;
+class Window;
+
+namespace test {
+
+// EventGenerator is a tool that generates and dispatch events.
+// TODO(oshima): Support key events.
+class EventGenerator {
+ public:
+ // Creates an EventGenerator with the mouse location (0,0).
+ EventGenerator();
+
+ // Creates an EventGenerator with the mouse location at |initial_location|.
+ explicit EventGenerator(const gfx::Point& initial_location);
+
+ // Creates an EventGenerator with the mouse location centered at |window|.
Ben Goodger (Google) 2011/10/16 22:23:33 centered over |window|.
oshima 2011/10/17 19:30:57 Done.
+ explicit EventGenerator(Window* window);
+
+ virtual ~EventGenerator();
+
+ const gfx::Point& current_location() const { return current_location_; }
+
+ // 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 events to move mouse to be the given |point|.
+ void MoveMouseTo(const gfx::Point& point);
+
+ void MoveMouseTo(int x, int y) {
+ MoveMouseTo(gfx::Point(x, y));
+ }
+
+ void MoveMouseBy(int x, int y) {
+ MoveMouseTo(current_location_.Add(gfx::Point(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_.Add(gfx::Point(dx, dy)));
+ }
+
+ // Generates events to move the mouse to the center of the window.
+ void MoveMouseToCenterOf(Window* window);
+
+ private:
+ // Dispatch the |event| to the Desktop.
+ void Dispatch(const Event& event);
+
+ int flags_;
+ gfx::Point current_location_;
+};
Ben Goodger (Google) 2011/10/16 22:23:33 DISALLOW_COPY_AND_ASSIGN
oshima 2011/10/17 19:30:57 Done.
+
+} // namespace test
+} // namespace aura
+
+#endif // UI_AURA_TEST_EVENT_GENERATOR_H_

Powered by Google App Engine
This is Rietveld 408576698