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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef UI_AURA_TEST_EVENT_GENERATOR_H_
6 #define UI_AURA_TEST_EVENT_GENERATOR_H_
7 #pragma once
8
9 #include "base/basictypes.h"
10 #include "ui/gfx/point.h"
11
12 namespace aura {
13 class Event;
14 class Window;
15
16 namespace test {
17
18 // EventGenerator is a tool that generates and dispatch events.
19 // TODO(oshima): Support key events.
20 class EventGenerator {
21 public:
22 // Creates an EventGenerator with the mouse location (0,0).
23 EventGenerator();
24
25 // Creates an EventGenerator with the mouse location at |initial_location|.
26 explicit EventGenerator(const gfx::Point& initial_location);
27
28 // 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.
29 explicit EventGenerator(Window* window);
30
31 virtual ~EventGenerator();
32
33 const gfx::Point& current_location() const { return current_location_; }
34
35 // Generates a left button press event.
36 void PressLeftButton();
37
38 // Generates a left button release event.
39 void ReleaseLeftButton();
40
41 // Generates events to click (press, release) left button.
42 void ClickLeftButton();
43
44 // Generates events to move mouse to be the given |point|.
45 void MoveMouseTo(const gfx::Point& point);
46
47 void MoveMouseTo(int x, int y) {
48 MoveMouseTo(gfx::Point(x, y));
49 }
50
51 void MoveMouseBy(int x, int y) {
52 MoveMouseTo(current_location_.Add(gfx::Point(x, y)));
53 }
54
55 // Generates events to drag mouse to given |point|.
56 void DragMouseTo(const gfx::Point& point);
57
58 void DragMouseTo(int x, int y) {
59 DragMouseTo(gfx::Point(x, y));
60 }
61
62 void DragMouseBy(int dx, int dy) {
63 DragMouseTo(current_location_.Add(gfx::Point(dx, dy)));
64 }
65
66 // Generates events to move the mouse to the center of the window.
67 void MoveMouseToCenterOf(Window* window);
68
69 private:
70 // Dispatch the |event| to the Desktop.
71 void Dispatch(const Event& event);
72
73 int flags_;
74 gfx::Point current_location_;
75 };
Ben Goodger (Google) 2011/10/16 22:23:33 DISALLOW_COPY_AND_ASSIGN
oshima 2011/10/17 19:30:57 Done.
76
77 } // namespace test
78 } // namespace aura
79
80 #endif // UI_AURA_TEST_EVENT_GENERATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698