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

Side by Side Diff: ui/aura/test/event_generator.cc

Issue 8273040: Minimum size for aura window (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed comment, add 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 #include "ui/aura/test/event_generator.h"
6
7 #include "ui/aura/desktop.h"
8 #include "ui/aura/event.h"
9
10 namespace aura {
11 namespace test {
12
13 EventGenerator::EventGenerator() : flags_(0) {
14 }
15
16 EventGenerator::EventGenerator(const gfx::Point& point)
17 : flags_(0),
18 current_(point) {
19 }
20
21 EventGenerator::~EventGenerator() {
22 }
23
24 void EventGenerator::ClickLeftButton() {
25 PressLeftButton();
26 ReleaseLeftButton();
27 }
28
29 void EventGenerator::PressLeftButton() {
30 if ((flags_ & ui::EF_LEFT_BUTTON_DOWN) == 0) {
31 flags_ |= ui::EF_LEFT_BUTTON_DOWN;
32 Dispatch(MouseEvent(ui::ET_MOUSE_PRESSED, current_, flags_));
33 }
34 }
35
36 void EventGenerator::ReleaseLeftButton() {
37 if (flags_ & ui::EF_LEFT_BUTTON_DOWN) {
38 flags_ ^= ui::EF_LEFT_BUTTON_DOWN;
39 Dispatch(MouseEvent(ui::ET_MOUSE_RELEASED, current_, 0));
40 }
41 }
42
43 void EventGenerator::MoveMouseTo(const gfx::Point& point) {
44 if (flags_ & ui::EF_LEFT_BUTTON_DOWN ) {
45 Dispatch(MouseEvent(ui::ET_MOUSE_DRAGGED, current_.Middle(point), flags_));
46 Dispatch(MouseEvent(ui::ET_MOUSE_DRAGGED, point, flags_));
47 } else {
48 Dispatch(MouseEvent(ui::ET_MOUSE_MOVED, current_.Middle(point), flags_));
49 Dispatch(MouseEvent(ui::ET_MOUSE_MOVED, point, flags_));
50 }
51 current_ = point;
52 }
53
54 void EventGenerator::DragMouseTo(const gfx::Point& point) {
55 PressLeftButton();
56 MoveMouseTo(point);
57 ReleaseLeftButton();
58 }
59
60 void EventGenerator::Dispatch(const Event& event) {
61 switch (event.type()) {
62 case ui::ET_KEY_PRESSED:
63 case ui::ET_KEY_RELEASED:
64 aura::Desktop::GetInstance()->OnKeyEvent(
65 *static_cast<const KeyEvent*>(&event));
66 break;
67 case ui::ET_MOUSE_PRESSED:
68 case ui::ET_MOUSE_DRAGGED:
69 case ui::ET_MOUSE_RELEASED:
70 case ui::ET_MOUSE_MOVED:
71 case ui::ET_MOUSE_ENTERED:
72 case ui::ET_MOUSE_EXITED:
73 case ui::ET_MOUSEWHEEL:
74 aura::Desktop::GetInstance()->OnMouseEvent(
75 *static_cast<const MouseEvent*>(&event));
76 break;
77 default:
78 NOTIMPLEMENTED();
79 break;
80 }
81 }
82
83 } // namespace test
84 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698