OLD | NEW |
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/event.h" | |
9 #include "ui/aura/window.h" | 8 #include "ui/aura/window.h" |
| 9 #include "ui/base/event.h" |
10 #include "ui/base/hit_test.h" | 10 #include "ui/base/hit_test.h" |
11 #include "ui/gfx/canvas.h" | 11 #include "ui/gfx/canvas.h" |
12 #include "ui/gfx/path.h" | 12 #include "ui/gfx/path.h" |
13 #include "ui/gfx/skia_util.h" | 13 #include "ui/gfx/skia_util.h" |
14 | 14 |
15 namespace aura { | 15 namespace aura { |
16 namespace test { | 16 namespace test { |
17 | 17 |
18 //////////////////////////////////////////////////////////////////////////////// | 18 //////////////////////////////////////////////////////////////////////////////// |
19 // TestWindowDelegate | 19 // TestWindowDelegate |
(...skipping 11 matching lines...) Expand all Loading... |
31 void TestWindowDelegate::OnBoundsChanged(const gfx::Rect& old_bounds, | 31 void TestWindowDelegate::OnBoundsChanged(const gfx::Rect& old_bounds, |
32 const gfx::Rect& new_bounds) { | 32 const gfx::Rect& new_bounds) { |
33 } | 33 } |
34 | 34 |
35 void TestWindowDelegate::OnFocus(Window* old_focused_window) { | 35 void TestWindowDelegate::OnFocus(Window* old_focused_window) { |
36 } | 36 } |
37 | 37 |
38 void TestWindowDelegate::OnBlur() { | 38 void TestWindowDelegate::OnBlur() { |
39 } | 39 } |
40 | 40 |
41 bool TestWindowDelegate::OnKeyEvent(KeyEvent* event) { | 41 bool TestWindowDelegate::OnKeyEvent(ui::KeyEvent* event) { |
42 return false; | 42 return false; |
43 } | 43 } |
44 | 44 |
45 gfx::NativeCursor TestWindowDelegate::GetCursor(const gfx::Point& point) { | 45 gfx::NativeCursor TestWindowDelegate::GetCursor(const gfx::Point& point) { |
46 return gfx::kNullCursor; | 46 return gfx::kNullCursor; |
47 } | 47 } |
48 | 48 |
49 int TestWindowDelegate::GetNonClientComponent(const gfx::Point& point) const { | 49 int TestWindowDelegate::GetNonClientComponent(const gfx::Point& point) const { |
50 return window_component_; | 50 return window_component_; |
51 } | 51 } |
52 | 52 |
53 bool TestWindowDelegate::ShouldDescendIntoChildForEventHandling( | 53 bool TestWindowDelegate::ShouldDescendIntoChildForEventHandling( |
54 Window* child, | 54 Window* child, |
55 const gfx::Point& location) { | 55 const gfx::Point& location) { |
56 return true; | 56 return true; |
57 } | 57 } |
58 | 58 |
59 bool TestWindowDelegate::OnMouseEvent(MouseEvent* event) { | 59 bool TestWindowDelegate::OnMouseEvent(ui::MouseEvent* event) { |
60 return false; | 60 return false; |
61 } | 61 } |
62 | 62 |
63 ui::TouchStatus TestWindowDelegate::OnTouchEvent(TouchEvent* event) { | 63 ui::TouchStatus TestWindowDelegate::OnTouchEvent(ui::TouchEventImpl* event) { |
64 return ui::TOUCH_STATUS_UNKNOWN; | 64 return ui::TOUCH_STATUS_UNKNOWN; |
65 } | 65 } |
66 | 66 |
67 ui::GestureStatus TestWindowDelegate::OnGestureEvent(GestureEvent* event) { | 67 ui::GestureStatus TestWindowDelegate::OnGestureEvent( |
| 68 ui::GestureEventImpl* event) { |
68 return ui::GESTURE_STATUS_UNKNOWN; | 69 return ui::GESTURE_STATUS_UNKNOWN; |
69 } | 70 } |
70 | 71 |
71 bool TestWindowDelegate::CanFocus() { | 72 bool TestWindowDelegate::CanFocus() { |
72 return true; | 73 return true; |
73 } | 74 } |
74 | 75 |
75 void TestWindowDelegate::OnCaptureLost() { | 76 void TestWindowDelegate::OnCaptureLost() { |
76 } | 77 } |
77 | 78 |
(...skipping 23 matching lines...) Expand all Loading... |
101 //////////////////////////////////////////////////////////////////////////////// | 102 //////////////////////////////////////////////////////////////////////////////// |
102 // ColorTestWindowDelegate | 103 // ColorTestWindowDelegate |
103 | 104 |
104 ColorTestWindowDelegate::ColorTestWindowDelegate(SkColor color) | 105 ColorTestWindowDelegate::ColorTestWindowDelegate(SkColor color) |
105 : color_(color), | 106 : color_(color), |
106 last_key_code_(ui::VKEY_UNKNOWN) { | 107 last_key_code_(ui::VKEY_UNKNOWN) { |
107 } | 108 } |
108 ColorTestWindowDelegate::~ColorTestWindowDelegate() { | 109 ColorTestWindowDelegate::~ColorTestWindowDelegate() { |
109 } | 110 } |
110 | 111 |
111 bool ColorTestWindowDelegate::OnKeyEvent(KeyEvent* event) { | 112 bool ColorTestWindowDelegate::OnKeyEvent(ui::KeyEvent* event) { |
112 last_key_code_ = event->key_code(); | 113 last_key_code_ = event->key_code(); |
113 return true; | 114 return true; |
114 } | 115 } |
115 void ColorTestWindowDelegate::OnWindowDestroyed() { | 116 void ColorTestWindowDelegate::OnWindowDestroyed() { |
116 delete this; | 117 delete this; |
117 } | 118 } |
118 void ColorTestWindowDelegate::OnPaint(gfx::Canvas* canvas) { | 119 void ColorTestWindowDelegate::OnPaint(gfx::Canvas* canvas) { |
119 canvas->DrawColor(color_, SkXfermode::kSrc_Mode); | 120 canvas->DrawColor(color_, SkXfermode::kSrc_Mode); |
120 } | 121 } |
121 | 122 |
(...skipping 18 matching lines...) Expand all Loading... |
140 EventCountDelegate::EventCountDelegate() | 141 EventCountDelegate::EventCountDelegate() |
141 : mouse_enter_count_(0), | 142 : mouse_enter_count_(0), |
142 mouse_move_count_(0), | 143 mouse_move_count_(0), |
143 mouse_leave_count_(0), | 144 mouse_leave_count_(0), |
144 mouse_press_count_(0), | 145 mouse_press_count_(0), |
145 mouse_release_count_(0), | 146 mouse_release_count_(0), |
146 key_press_count_(0), | 147 key_press_count_(0), |
147 key_release_count_(0) { | 148 key_release_count_(0) { |
148 } | 149 } |
149 | 150 |
150 bool EventCountDelegate::OnMouseEvent(MouseEvent* event) { | 151 bool EventCountDelegate::OnMouseEvent(ui::MouseEvent* event) { |
151 switch (event->type()) { | 152 switch (event->type()) { |
152 case ui::ET_MOUSE_MOVED: | 153 case ui::ET_MOUSE_MOVED: |
153 mouse_move_count_++; | 154 mouse_move_count_++; |
154 break; | 155 break; |
155 case ui::ET_MOUSE_ENTERED: | 156 case ui::ET_MOUSE_ENTERED: |
156 mouse_enter_count_++; | 157 mouse_enter_count_++; |
157 break; | 158 break; |
158 case ui::ET_MOUSE_EXITED: | 159 case ui::ET_MOUSE_EXITED: |
159 mouse_leave_count_++; | 160 mouse_leave_count_++; |
160 break; | 161 break; |
161 case ui::ET_MOUSE_PRESSED: | 162 case ui::ET_MOUSE_PRESSED: |
162 mouse_press_count_++; | 163 mouse_press_count_++; |
163 break; | 164 break; |
164 case ui::ET_MOUSE_RELEASED: | 165 case ui::ET_MOUSE_RELEASED: |
165 mouse_release_count_++; | 166 mouse_release_count_++; |
166 break; | 167 break; |
167 default: | 168 default: |
168 break; | 169 break; |
169 } | 170 } |
170 return false; | 171 return false; |
171 } | 172 } |
172 | 173 |
173 bool EventCountDelegate::OnKeyEvent(KeyEvent* event) { | 174 bool EventCountDelegate::OnKeyEvent(ui::KeyEvent* event) { |
174 switch (event->type()) { | 175 switch (event->type()) { |
175 case ui::ET_KEY_PRESSED: | 176 case ui::ET_KEY_PRESSED: |
176 key_press_count_++; | 177 key_press_count_++; |
177 break; | 178 break; |
178 case ui::ET_KEY_RELEASED: | 179 case ui::ET_KEY_RELEASED: |
179 key_release_count_++; | 180 key_release_count_++; |
180 default: | 181 default: |
181 break; | 182 break; |
182 } | 183 } |
183 return false; | 184 return false; |
(...skipping 24 matching lines...) Expand all Loading... |
208 std::string result = StringPrintf("%d %d", | 209 std::string result = StringPrintf("%d %d", |
209 key_press_count_, | 210 key_press_count_, |
210 key_release_count_); | 211 key_release_count_); |
211 key_press_count_ = 0; | 212 key_press_count_ = 0; |
212 key_release_count_ = 0; | 213 key_release_count_ = 0; |
213 return result; | 214 return result; |
214 } | 215 } |
215 | 216 |
216 } // namespace test | 217 } // namespace test |
217 } // namespace aura | 218 } // namespace aura |
OLD | NEW |