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

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

Issue 10908127: events: Move EventTarget into Event. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 3 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
« no previous file with comments | « ui/aura/test/test_window_delegate.h ('k') | ui/aura/window_delegate.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/aura/test/test_window_delegate.h" 5 #include "ui/aura/test/test_window_delegate.h"
6 6
7 #include "base/stringprintf.h" 7 #include "base/stringprintf.h"
8 #include "ui/aura/window.h" 8 #include "ui/aura/window.h"
9 #include "ui/base/events/event.h" 9 #include "ui/base/events/event.h"
10 #include "ui/base/hit_test.h" 10 #include "ui/base/hit_test.h"
(...skipping 29 matching lines...) Expand all
40 void TestWindowDelegate::OnBoundsChanged(const gfx::Rect& old_bounds, 40 void TestWindowDelegate::OnBoundsChanged(const gfx::Rect& old_bounds,
41 const gfx::Rect& new_bounds) { 41 const gfx::Rect& new_bounds) {
42 } 42 }
43 43
44 void TestWindowDelegate::OnFocus(Window* old_focused_window) { 44 void TestWindowDelegate::OnFocus(Window* old_focused_window) {
45 } 45 }
46 46
47 void TestWindowDelegate::OnBlur() { 47 void TestWindowDelegate::OnBlur() {
48 } 48 }
49 49
50 bool TestWindowDelegate::OnKeyEvent(ui::KeyEvent* event) {
51 return false;
52 }
53
54 gfx::NativeCursor TestWindowDelegate::GetCursor(const gfx::Point& point) { 50 gfx::NativeCursor TestWindowDelegate::GetCursor(const gfx::Point& point) {
55 return gfx::kNullCursor; 51 return gfx::kNullCursor;
56 } 52 }
57 53
58 int TestWindowDelegate::GetNonClientComponent(const gfx::Point& point) const { 54 int TestWindowDelegate::GetNonClientComponent(const gfx::Point& point) const {
59 return window_component_; 55 return window_component_;
60 } 56 }
61 57
62 bool TestWindowDelegate::ShouldDescendIntoChildForEventHandling( 58 bool TestWindowDelegate::ShouldDescendIntoChildForEventHandling(
63 Window* child, 59 Window* child,
64 const gfx::Point& location) { 60 const gfx::Point& location) {
65 return true; 61 return true;
66 } 62 }
67 63
68 bool TestWindowDelegate::OnMouseEvent(ui::MouseEvent* event) {
69 return false;
70 }
71
72 ui::TouchStatus TestWindowDelegate::OnTouchEvent(ui::TouchEvent* event) {
73 return ui::TOUCH_STATUS_UNKNOWN;
74 }
75
76 ui::EventResult TestWindowDelegate::OnGestureEvent(
77 ui::GestureEvent* event) {
78 return ui::ER_UNHANDLED;
79 }
80
81 bool TestWindowDelegate::CanFocus() { 64 bool TestWindowDelegate::CanFocus() {
82 return true; 65 return true;
83 } 66 }
84 67
85 void TestWindowDelegate::OnCaptureLost() { 68 void TestWindowDelegate::OnCaptureLost() {
86 } 69 }
87 70
88 void TestWindowDelegate::OnPaint(gfx::Canvas* canvas) { 71 void TestWindowDelegate::OnPaint(gfx::Canvas* canvas) {
89 } 72 }
90 73
(...skipping 12 matching lines...) Expand all
103 void TestWindowDelegate::OnWindowTargetVisibilityChanged(bool visible) { 86 void TestWindowDelegate::OnWindowTargetVisibilityChanged(bool visible) {
104 } 87 }
105 88
106 bool TestWindowDelegate::HasHitTestMask() const { 89 bool TestWindowDelegate::HasHitTestMask() const {
107 return false; 90 return false;
108 } 91 }
109 92
110 void TestWindowDelegate::GetHitTestMask(gfx::Path* mask) const { 93 void TestWindowDelegate::GetHitTestMask(gfx::Path* mask) const {
111 } 94 }
112 95
96 ui::EventResult TestWindowDelegate::OnKeyEvent(ui::KeyEvent* event) {
97 return ui::ER_UNHANDLED;
98 }
99
100 ui::EventResult TestWindowDelegate::OnMouseEvent(ui::MouseEvent* event) {
101 return ui::ER_UNHANDLED;
102 }
103
104 ui::TouchStatus TestWindowDelegate::OnTouchEvent(ui::TouchEvent* event) {
105 return ui::TOUCH_STATUS_UNKNOWN;
106 }
107
108 ui::EventResult TestWindowDelegate::OnGestureEvent(
109 ui::GestureEvent* event) {
110 return ui::ER_UNHANDLED;
111 }
112
113 //////////////////////////////////////////////////////////////////////////////// 113 ////////////////////////////////////////////////////////////////////////////////
114 // ColorTestWindowDelegate 114 // ColorTestWindowDelegate
115 115
116 ColorTestWindowDelegate::ColorTestWindowDelegate(SkColor color) 116 ColorTestWindowDelegate::ColorTestWindowDelegate(SkColor color)
117 : color_(color), 117 : color_(color),
118 last_key_code_(ui::VKEY_UNKNOWN) { 118 last_key_code_(ui::VKEY_UNKNOWN) {
119 } 119 }
120 ColorTestWindowDelegate::~ColorTestWindowDelegate() { 120 ColorTestWindowDelegate::~ColorTestWindowDelegate() {
121 } 121 }
122 122
123 bool ColorTestWindowDelegate::OnKeyEvent(ui::KeyEvent* event) { 123 ui::EventResult ColorTestWindowDelegate::OnKeyEvent(ui::KeyEvent* event) {
124 last_key_code_ = event->key_code(); 124 last_key_code_ = event->key_code();
125 return true; 125 return ui::ER_HANDLED;
126 } 126 }
127 void ColorTestWindowDelegate::OnWindowDestroyed() { 127 void ColorTestWindowDelegate::OnWindowDestroyed() {
128 delete this; 128 delete this;
129 } 129 }
130 void ColorTestWindowDelegate::OnPaint(gfx::Canvas* canvas) { 130 void ColorTestWindowDelegate::OnPaint(gfx::Canvas* canvas) {
131 canvas->DrawColor(color_, SkXfermode::kSrc_Mode); 131 canvas->DrawColor(color_, SkXfermode::kSrc_Mode);
132 } 132 }
133 133
134 //////////////////////////////////////////////////////////////////////////////// 134 ////////////////////////////////////////////////////////////////////////////////
135 // MaskedWindowDelegate 135 // MaskedWindowDelegate
(...skipping 16 matching lines...) Expand all
152 EventCountDelegate::EventCountDelegate() 152 EventCountDelegate::EventCountDelegate()
153 : mouse_enter_count_(0), 153 : mouse_enter_count_(0),
154 mouse_move_count_(0), 154 mouse_move_count_(0),
155 mouse_leave_count_(0), 155 mouse_leave_count_(0),
156 mouse_press_count_(0), 156 mouse_press_count_(0),
157 mouse_release_count_(0), 157 mouse_release_count_(0),
158 key_press_count_(0), 158 key_press_count_(0),
159 key_release_count_(0) { 159 key_release_count_(0) {
160 } 160 }
161 161
162 bool EventCountDelegate::OnMouseEvent(ui::MouseEvent* event) { 162 ui::EventResult EventCountDelegate::OnKeyEvent(ui::KeyEvent* event) {
163 switch (event->type()) {
164 case ui::ET_KEY_PRESSED:
165 key_press_count_++;
166 break;
167 case ui::ET_KEY_RELEASED:
168 key_release_count_++;
169 default:
170 break;
171 }
172 return ui::ER_UNHANDLED;
173 }
174
175 ui::EventResult EventCountDelegate::OnMouseEvent(ui::MouseEvent* event) {
163 switch (event->type()) { 176 switch (event->type()) {
164 case ui::ET_MOUSE_MOVED: 177 case ui::ET_MOUSE_MOVED:
165 mouse_move_count_++; 178 mouse_move_count_++;
166 break; 179 break;
167 case ui::ET_MOUSE_ENTERED: 180 case ui::ET_MOUSE_ENTERED:
168 mouse_enter_count_++; 181 mouse_enter_count_++;
169 break; 182 break;
170 case ui::ET_MOUSE_EXITED: 183 case ui::ET_MOUSE_EXITED:
171 mouse_leave_count_++; 184 mouse_leave_count_++;
172 break; 185 break;
173 case ui::ET_MOUSE_PRESSED: 186 case ui::ET_MOUSE_PRESSED:
174 mouse_press_count_++; 187 mouse_press_count_++;
175 break; 188 break;
176 case ui::ET_MOUSE_RELEASED: 189 case ui::ET_MOUSE_RELEASED:
177 mouse_release_count_++; 190 mouse_release_count_++;
178 break; 191 break;
179 default: 192 default:
180 break; 193 break;
181 } 194 }
182 return false; 195 return ui::ER_UNHANDLED;
183 }
184
185 bool EventCountDelegate::OnKeyEvent(ui::KeyEvent* event) {
186 switch (event->type()) {
187 case ui::ET_KEY_PRESSED:
188 key_press_count_++;
189 break;
190 case ui::ET_KEY_RELEASED:
191 key_release_count_++;
192 default:
193 break;
194 }
195 return false;
196 } 196 }
197 197
198 std::string EventCountDelegate::GetMouseMotionCountsAndReset() { 198 std::string EventCountDelegate::GetMouseMotionCountsAndReset() {
199 std::string result = StringPrintf("%d %d %d", 199 std::string result = StringPrintf("%d %d %d",
200 mouse_enter_count_, 200 mouse_enter_count_,
201 mouse_move_count_, 201 mouse_move_count_,
202 mouse_leave_count_); 202 mouse_leave_count_);
203 mouse_enter_count_ = 0; 203 mouse_enter_count_ = 0;
204 mouse_move_count_ = 0; 204 mouse_move_count_ = 0;
205 mouse_leave_count_ = 0; 205 mouse_leave_count_ = 0;
(...skipping 14 matching lines...) Expand all
220 std::string result = StringPrintf("%d %d", 220 std::string result = StringPrintf("%d %d",
221 key_press_count_, 221 key_press_count_,
222 key_release_count_); 222 key_release_count_);
223 key_press_count_ = 0; 223 key_press_count_ = 0;
224 key_release_count_ = 0; 224 key_release_count_ = 0;
225 return result; 225 return result;
226 } 226 }
227 227
228 } // namespace test 228 } // namespace test
229 } // namespace aura 229 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/test/test_window_delegate.h ('k') | ui/aura/window_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698