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/window_event_dispatcher.h" | 5 #include "ui/aura/window_event_dispatcher.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 mouse_event_flags_(0x0) { | 46 mouse_event_flags_(0x0) { |
47 } | 47 } |
48 virtual ~NonClientDelegate() {} | 48 virtual ~NonClientDelegate() {} |
49 | 49 |
50 int non_client_count() const { return non_client_count_; } | 50 int non_client_count() const { return non_client_count_; } |
51 gfx::Point non_client_location() const { return non_client_location_; } | 51 gfx::Point non_client_location() const { return non_client_location_; } |
52 int mouse_event_count() const { return mouse_event_count_; } | 52 int mouse_event_count() const { return mouse_event_count_; } |
53 gfx::Point mouse_event_location() const { return mouse_event_location_; } | 53 gfx::Point mouse_event_location() const { return mouse_event_location_; } |
54 int mouse_event_flags() const { return mouse_event_flags_; } | 54 int mouse_event_flags() const { return mouse_event_flags_; } |
55 | 55 |
56 virtual int GetNonClientComponent(const gfx::Point& location) const OVERRIDE { | 56 virtual int GetNonClientComponent(const gfx::Point& location) const override { |
57 NonClientDelegate* self = const_cast<NonClientDelegate*>(this); | 57 NonClientDelegate* self = const_cast<NonClientDelegate*>(this); |
58 self->non_client_count_++; | 58 self->non_client_count_++; |
59 self->non_client_location_ = location; | 59 self->non_client_location_ = location; |
60 return HTTOPLEFT; | 60 return HTTOPLEFT; |
61 } | 61 } |
62 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE { | 62 virtual void OnMouseEvent(ui::MouseEvent* event) override { |
63 mouse_event_count_++; | 63 mouse_event_count_++; |
64 mouse_event_location_ = event->location(); | 64 mouse_event_location_ = event->location(); |
65 mouse_event_flags_ = event->flags(); | 65 mouse_event_flags_ = event->flags(); |
66 event->SetHandled(); | 66 event->SetHandled(); |
67 } | 67 } |
68 | 68 |
69 private: | 69 private: |
70 int non_client_count_; | 70 int non_client_count_; |
71 gfx::Point non_client_location_; | 71 gfx::Point non_client_location_; |
72 int mouse_event_count_; | 72 int mouse_event_count_; |
73 gfx::Point mouse_event_location_; | 73 gfx::Point mouse_event_location_; |
74 int mouse_event_flags_; | 74 int mouse_event_flags_; |
75 | 75 |
76 DISALLOW_COPY_AND_ASSIGN(NonClientDelegate); | 76 DISALLOW_COPY_AND_ASSIGN(NonClientDelegate); |
77 }; | 77 }; |
78 | 78 |
79 // A simple event handler that consumes key events. | 79 // A simple event handler that consumes key events. |
80 class ConsumeKeyHandler : public ui::test::TestEventHandler { | 80 class ConsumeKeyHandler : public ui::test::TestEventHandler { |
81 public: | 81 public: |
82 ConsumeKeyHandler() {} | 82 ConsumeKeyHandler() {} |
83 virtual ~ConsumeKeyHandler() {} | 83 virtual ~ConsumeKeyHandler() {} |
84 | 84 |
85 // Overridden from ui::EventHandler: | 85 // Overridden from ui::EventHandler: |
86 virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE { | 86 virtual void OnKeyEvent(ui::KeyEvent* event) override { |
87 ui::test::TestEventHandler::OnKeyEvent(event); | 87 ui::test::TestEventHandler::OnKeyEvent(event); |
88 event->StopPropagation(); | 88 event->StopPropagation(); |
89 } | 89 } |
90 | 90 |
91 private: | 91 private: |
92 DISALLOW_COPY_AND_ASSIGN(ConsumeKeyHandler); | 92 DISALLOW_COPY_AND_ASSIGN(ConsumeKeyHandler); |
93 }; | 93 }; |
94 | 94 |
95 bool IsFocusedWindow(aura::Window* window) { | 95 bool IsFocusedWindow(aura::Window* window) { |
96 return client::GetFocusClient(window)->GetFocusedWindow() == window; | 96 return client::GetFocusClient(window)->GetFocusedWindow() == window; |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 const Window* GetLockWindow() const { | 261 const Window* GetLockWindow() const { |
262 return root_window_->GetChildById(kLockWindowId); | 262 return root_window_->GetChildById(kLockWindowId); |
263 } | 263 } |
264 Window* GetNonLockWindow() { | 264 Window* GetNonLockWindow() { |
265 return root_window_->GetChildById(kNonLockWindowId); | 265 return root_window_->GetChildById(kNonLockWindowId); |
266 } | 266 } |
267 | 267 |
268 private: | 268 private: |
269 // Overridden from client::EventClient: | 269 // Overridden from client::EventClient: |
270 virtual bool CanProcessEventsWithinSubtree( | 270 virtual bool CanProcessEventsWithinSubtree( |
271 const Window* window) const OVERRIDE { | 271 const Window* window) const override { |
272 return lock_ ? | 272 return lock_ ? |
273 window->Contains(GetLockWindow()) || GetLockWindow()->Contains(window) : | 273 window->Contains(GetLockWindow()) || GetLockWindow()->Contains(window) : |
274 true; | 274 true; |
275 } | 275 } |
276 | 276 |
277 virtual ui::EventTarget* GetToplevelEventTarget() OVERRIDE { | 277 virtual ui::EventTarget* GetToplevelEventTarget() override { |
278 return NULL; | 278 return NULL; |
279 } | 279 } |
280 | 280 |
281 Window* root_window_; | 281 Window* root_window_; |
282 bool lock_; | 282 bool lock_; |
283 | 283 |
284 DISALLOW_COPY_AND_ASSIGN(TestEventClient); | 284 DISALLOW_COPY_AND_ASSIGN(TestEventClient); |
285 }; | 285 }; |
286 | 286 |
287 } // namespace | 287 } // namespace |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 | 479 |
480 void Reset() { | 480 void Reset() { |
481 events_.clear(); | 481 events_.clear(); |
482 mouse_locations_.clear(); | 482 mouse_locations_.clear(); |
483 touch_locations_.clear(); | 483 touch_locations_.clear(); |
484 gesture_locations_.clear(); | 484 gesture_locations_.clear(); |
485 mouse_event_flags_.clear(); | 485 mouse_event_flags_.clear(); |
486 } | 486 } |
487 | 487 |
488 // ui::EventHandler overrides: | 488 // ui::EventHandler overrides: |
489 virtual void OnEvent(ui::Event* event) OVERRIDE { | 489 virtual void OnEvent(ui::Event* event) override { |
490 ui::EventHandler::OnEvent(event); | 490 ui::EventHandler::OnEvent(event); |
491 events_.push_back(event->type()); | 491 events_.push_back(event->type()); |
492 if (wait_until_event_ == event->type() && run_loop_) { | 492 if (wait_until_event_ == event->type() && run_loop_) { |
493 run_loop_->Quit(); | 493 run_loop_->Quit(); |
494 wait_until_event_ = ui::ET_UNKNOWN; | 494 wait_until_event_ = ui::ET_UNKNOWN; |
495 } | 495 } |
496 } | 496 } |
497 | 497 |
498 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE { | 498 virtual void OnMouseEvent(ui::MouseEvent* event) override { |
499 mouse_locations_.push_back(event->location()); | 499 mouse_locations_.push_back(event->location()); |
500 mouse_event_flags_.push_back(event->flags()); | 500 mouse_event_flags_.push_back(event->flags()); |
501 } | 501 } |
502 | 502 |
503 virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE { | 503 virtual void OnTouchEvent(ui::TouchEvent* event) override { |
504 touch_locations_.push_back(event->location()); | 504 touch_locations_.push_back(event->location()); |
505 } | 505 } |
506 | 506 |
507 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE { | 507 virtual void OnGestureEvent(ui::GestureEvent* event) override { |
508 gesture_locations_.push_back(event->location()); | 508 gesture_locations_.push_back(event->location()); |
509 } | 509 } |
510 | 510 |
511 bool HasReceivedEvent(ui::EventType type) { | 511 bool HasReceivedEvent(ui::EventType type) { |
512 return std::find(events_.begin(), events_.end(), type) != events_.end(); | 512 return std::find(events_.begin(), events_.end(), type) != events_.end(); |
513 } | 513 } |
514 | 514 |
515 private: | 515 private: |
516 scoped_ptr<base::RunLoop> run_loop_; | 516 scoped_ptr<base::RunLoop> run_loop_; |
517 ui::EventType wait_until_event_; | 517 ui::EventType wait_until_event_; |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
831 public: | 831 public: |
832 HoldPointerOnScrollHandler(WindowEventDispatcher* dispatcher, | 832 HoldPointerOnScrollHandler(WindowEventDispatcher* dispatcher, |
833 EventFilterRecorder* filter) | 833 EventFilterRecorder* filter) |
834 : dispatcher_(dispatcher), | 834 : dispatcher_(dispatcher), |
835 filter_(filter), | 835 filter_(filter), |
836 holding_moves_(false) {} | 836 holding_moves_(false) {} |
837 virtual ~HoldPointerOnScrollHandler() {} | 837 virtual ~HoldPointerOnScrollHandler() {} |
838 | 838 |
839 private: | 839 private: |
840 // ui::test::TestEventHandler: | 840 // ui::test::TestEventHandler: |
841 virtual void OnGestureEvent(ui::GestureEvent* gesture) OVERRIDE { | 841 virtual void OnGestureEvent(ui::GestureEvent* gesture) override { |
842 if (!holding_moves_ && gesture->type() == ui::ET_GESTURE_SCROLL_UPDATE) { | 842 if (!holding_moves_ && gesture->type() == ui::ET_GESTURE_SCROLL_UPDATE) { |
843 holding_moves_ = true; | 843 holding_moves_ = true; |
844 dispatcher_->HoldPointerMoves(); | 844 dispatcher_->HoldPointerMoves(); |
845 filter_->Reset(); | 845 filter_->Reset(); |
846 } else if (gesture->type() == ui::ET_GESTURE_SCROLL_END) { | 846 } else if (gesture->type() == ui::ET_GESTURE_SCROLL_END) { |
847 dispatcher_->ReleasePointerMoves(); | 847 dispatcher_->ReleasePointerMoves(); |
848 holding_moves_ = false; | 848 holding_moves_ = false; |
849 } | 849 } |
850 } | 850 } |
851 | 851 |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1134 DeletingEventFilter() | 1134 DeletingEventFilter() |
1135 : delete_during_pre_handle_(false) {} | 1135 : delete_during_pre_handle_(false) {} |
1136 virtual ~DeletingEventFilter() {} | 1136 virtual ~DeletingEventFilter() {} |
1137 | 1137 |
1138 void Reset(bool delete_during_pre_handle) { | 1138 void Reset(bool delete_during_pre_handle) { |
1139 delete_during_pre_handle_ = delete_during_pre_handle; | 1139 delete_during_pre_handle_ = delete_during_pre_handle; |
1140 } | 1140 } |
1141 | 1141 |
1142 private: | 1142 private: |
1143 // Overridden from ui::EventHandler: | 1143 // Overridden from ui::EventHandler: |
1144 virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE { | 1144 virtual void OnKeyEvent(ui::KeyEvent* event) override { |
1145 if (delete_during_pre_handle_) | 1145 if (delete_during_pre_handle_) |
1146 delete event->target(); | 1146 delete event->target(); |
1147 } | 1147 } |
1148 | 1148 |
1149 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE { | 1149 virtual void OnMouseEvent(ui::MouseEvent* event) override { |
1150 if (delete_during_pre_handle_) | 1150 if (delete_during_pre_handle_) |
1151 delete event->target(); | 1151 delete event->target(); |
1152 } | 1152 } |
1153 | 1153 |
1154 bool delete_during_pre_handle_; | 1154 bool delete_during_pre_handle_; |
1155 | 1155 |
1156 DISALLOW_COPY_AND_ASSIGN(DeletingEventFilter); | 1156 DISALLOW_COPY_AND_ASSIGN(DeletingEventFilter); |
1157 }; | 1157 }; |
1158 | 1158 |
1159 class DeletingWindowDelegate : public test::TestWindowDelegate { | 1159 class DeletingWindowDelegate : public test::TestWindowDelegate { |
1160 public: | 1160 public: |
1161 DeletingWindowDelegate() | 1161 DeletingWindowDelegate() |
1162 : window_(NULL), | 1162 : window_(NULL), |
1163 delete_during_handle_(false), | 1163 delete_during_handle_(false), |
1164 got_event_(false) {} | 1164 got_event_(false) {} |
1165 virtual ~DeletingWindowDelegate() {} | 1165 virtual ~DeletingWindowDelegate() {} |
1166 | 1166 |
1167 void Reset(Window* window, bool delete_during_handle) { | 1167 void Reset(Window* window, bool delete_during_handle) { |
1168 window_ = window; | 1168 window_ = window; |
1169 delete_during_handle_ = delete_during_handle; | 1169 delete_during_handle_ = delete_during_handle; |
1170 got_event_ = false; | 1170 got_event_ = false; |
1171 } | 1171 } |
1172 bool got_event() const { return got_event_; } | 1172 bool got_event() const { return got_event_; } |
1173 | 1173 |
1174 private: | 1174 private: |
1175 // Overridden from WindowDelegate: | 1175 // Overridden from WindowDelegate: |
1176 virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE { | 1176 virtual void OnKeyEvent(ui::KeyEvent* event) override { |
1177 if (delete_during_handle_) | 1177 if (delete_during_handle_) |
1178 delete window_; | 1178 delete window_; |
1179 got_event_ = true; | 1179 got_event_ = true; |
1180 } | 1180 } |
1181 | 1181 |
1182 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE { | 1182 virtual void OnMouseEvent(ui::MouseEvent* event) override { |
1183 if (delete_during_handle_) | 1183 if (delete_during_handle_) |
1184 delete window_; | 1184 delete window_; |
1185 got_event_ = true; | 1185 got_event_ = true; |
1186 } | 1186 } |
1187 | 1187 |
1188 Window* window_; | 1188 Window* window_; |
1189 bool delete_during_handle_; | 1189 bool delete_during_handle_; |
1190 bool got_event_; | 1190 bool got_event_; |
1191 | 1191 |
1192 DISALLOW_COPY_AND_ASSIGN(DeletingWindowDelegate); | 1192 DISALLOW_COPY_AND_ASSIGN(DeletingWindowDelegate); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1235 namespace { | 1235 namespace { |
1236 | 1236 |
1237 // A window delegate that detaches the parent of the target's parent window when | 1237 // A window delegate that detaches the parent of the target's parent window when |
1238 // it receives a tap event. | 1238 // it receives a tap event. |
1239 class DetachesParentOnTapDelegate : public test::TestWindowDelegate { | 1239 class DetachesParentOnTapDelegate : public test::TestWindowDelegate { |
1240 public: | 1240 public: |
1241 DetachesParentOnTapDelegate() {} | 1241 DetachesParentOnTapDelegate() {} |
1242 virtual ~DetachesParentOnTapDelegate() {} | 1242 virtual ~DetachesParentOnTapDelegate() {} |
1243 | 1243 |
1244 private: | 1244 private: |
1245 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE { | 1245 virtual void OnGestureEvent(ui::GestureEvent* event) override { |
1246 if (event->type() == ui::ET_GESTURE_TAP_DOWN) { | 1246 if (event->type() == ui::ET_GESTURE_TAP_DOWN) { |
1247 event->SetHandled(); | 1247 event->SetHandled(); |
1248 return; | 1248 return; |
1249 } | 1249 } |
1250 | 1250 |
1251 if (event->type() == ui::ET_GESTURE_TAP) { | 1251 if (event->type() == ui::ET_GESTURE_TAP) { |
1252 Window* parent = static_cast<Window*>(event->target())->parent(); | 1252 Window* parent = static_cast<Window*>(event->target())->parent(); |
1253 parent->parent()->RemoveChild(parent); | 1253 parent->parent()->RemoveChild(parent); |
1254 event->SetHandled(); | 1254 event->SetHandled(); |
1255 } | 1255 } |
(...skipping 24 matching lines...) Expand all Loading... |
1280 NestedGestureDelegate(ui::test::EventGenerator* generator, | 1280 NestedGestureDelegate(ui::test::EventGenerator* generator, |
1281 const gfx::Point tap_location) | 1281 const gfx::Point tap_location) |
1282 : generator_(generator), | 1282 : generator_(generator), |
1283 tap_location_(tap_location), | 1283 tap_location_(tap_location), |
1284 gesture_end_count_(0) {} | 1284 gesture_end_count_(0) {} |
1285 virtual ~NestedGestureDelegate() {} | 1285 virtual ~NestedGestureDelegate() {} |
1286 | 1286 |
1287 int gesture_end_count() const { return gesture_end_count_; } | 1287 int gesture_end_count() const { return gesture_end_count_; } |
1288 | 1288 |
1289 private: | 1289 private: |
1290 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE { | 1290 virtual void OnGestureEvent(ui::GestureEvent* event) override { |
1291 switch (event->type()) { | 1291 switch (event->type()) { |
1292 case ui::ET_GESTURE_TAP_DOWN: | 1292 case ui::ET_GESTURE_TAP_DOWN: |
1293 event->SetHandled(); | 1293 event->SetHandled(); |
1294 break; | 1294 break; |
1295 case ui::ET_GESTURE_TAP: | 1295 case ui::ET_GESTURE_TAP: |
1296 if (generator_) | 1296 if (generator_) |
1297 generator_->GestureTapAt(tap_location_); | 1297 generator_->GestureTapAt(tap_location_); |
1298 event->SetHandled(); | 1298 event->SetHandled(); |
1299 break; | 1299 break; |
1300 case ui::ET_GESTURE_END: | 1300 case ui::ET_GESTURE_END: |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1366 public: | 1366 public: |
1367 RepostGestureEventRecorder(aura::Window* repost_source, | 1367 RepostGestureEventRecorder(aura::Window* repost_source, |
1368 aura::Window* repost_target) | 1368 aura::Window* repost_target) |
1369 : repost_source_(repost_source), | 1369 : repost_source_(repost_source), |
1370 repost_target_(repost_target), | 1370 repost_target_(repost_target), |
1371 reposted_(false), | 1371 reposted_(false), |
1372 done_cleanup_(false) {} | 1372 done_cleanup_(false) {} |
1373 | 1373 |
1374 virtual ~RepostGestureEventRecorder() {} | 1374 virtual ~RepostGestureEventRecorder() {} |
1375 | 1375 |
1376 virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE { | 1376 virtual void OnTouchEvent(ui::TouchEvent* event) override { |
1377 if (reposted_ && event->type() == ui::ET_TOUCH_PRESSED) { | 1377 if (reposted_ && event->type() == ui::ET_TOUCH_PRESSED) { |
1378 done_cleanup_ = true; | 1378 done_cleanup_ = true; |
1379 Reset(); | 1379 Reset(); |
1380 } | 1380 } |
1381 EventFilterRecorder::OnTouchEvent(event); | 1381 EventFilterRecorder::OnTouchEvent(event); |
1382 } | 1382 } |
1383 | 1383 |
1384 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE { | 1384 virtual void OnGestureEvent(ui::GestureEvent* event) override { |
1385 EXPECT_EQ(done_cleanup_ ? repost_target_ : repost_source_, event->target()); | 1385 EXPECT_EQ(done_cleanup_ ? repost_target_ : repost_source_, event->target()); |
1386 if (event->type() == ui::ET_GESTURE_TAP_DOWN) { | 1386 if (event->type() == ui::ET_GESTURE_TAP_DOWN) { |
1387 if (!reposted_) { | 1387 if (!reposted_) { |
1388 EXPECT_NE(repost_target_, event->target()); | 1388 EXPECT_NE(repost_target_, event->target()); |
1389 reposted_ = true; | 1389 reposted_ = true; |
1390 repost_target_->GetHost()->dispatcher()->RepostEvent(*event); | 1390 repost_target_->GetHost()->dispatcher()->RepostEvent(*event); |
1391 // Ensure that the reposted gesture event above goes to the | 1391 // Ensure that the reposted gesture event above goes to the |
1392 // repost_target_; | 1392 // repost_target_; |
1393 repost_source_->GetRootWindow()->RemoveChild(repost_source_); | 1393 repost_source_->GetRootWindow()->RemoveChild(repost_source_); |
1394 return; | 1394 return; |
1395 } | 1395 } |
1396 } | 1396 } |
1397 EventFilterRecorder::OnGestureEvent(event); | 1397 EventFilterRecorder::OnGestureEvent(event); |
1398 } | 1398 } |
1399 | 1399 |
1400 // Ignore mouse events as they don't fire at all times. This causes | 1400 // Ignore mouse events as they don't fire at all times. This causes |
1401 // the GestureRepostEventOrder test to fail randomly. | 1401 // the GestureRepostEventOrder test to fail randomly. |
1402 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE {} | 1402 virtual void OnMouseEvent(ui::MouseEvent* event) override {} |
1403 | 1403 |
1404 private: | 1404 private: |
1405 aura::Window* repost_source_; | 1405 aura::Window* repost_source_; |
1406 aura::Window* repost_target_; | 1406 aura::Window* repost_target_; |
1407 // set to true if we reposted the ET_GESTURE_TAP_DOWN event. | 1407 // set to true if we reposted the ET_GESTURE_TAP_DOWN event. |
1408 bool reposted_; | 1408 bool reposted_; |
1409 // set true if we're done cleaning up after hiding repost_source_; | 1409 // set true if we're done cleaning up after hiding repost_source_; |
1410 bool done_cleanup_; | 1410 bool done_cleanup_; |
1411 DISALLOW_COPY_AND_ASSIGN(RepostGestureEventRecorder); | 1411 DISALLOW_COPY_AND_ASSIGN(RepostGestureEventRecorder); |
1412 }; | 1412 }; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1474 public: | 1474 public: |
1475 OnMouseExitDeletingEventFilter() : window_to_delete_(NULL) {} | 1475 OnMouseExitDeletingEventFilter() : window_to_delete_(NULL) {} |
1476 virtual ~OnMouseExitDeletingEventFilter() {} | 1476 virtual ~OnMouseExitDeletingEventFilter() {} |
1477 | 1477 |
1478 void set_window_to_delete(Window* window_to_delete) { | 1478 void set_window_to_delete(Window* window_to_delete) { |
1479 window_to_delete_ = window_to_delete; | 1479 window_to_delete_ = window_to_delete; |
1480 } | 1480 } |
1481 | 1481 |
1482 private: | 1482 private: |
1483 // Overridden from ui::EventHandler: | 1483 // Overridden from ui::EventHandler: |
1484 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE { | 1484 virtual void OnMouseEvent(ui::MouseEvent* event) override { |
1485 EventFilterRecorder::OnMouseEvent(event); | 1485 EventFilterRecorder::OnMouseEvent(event); |
1486 if (window_to_delete_) { | 1486 if (window_to_delete_) { |
1487 delete window_to_delete_; | 1487 delete window_to_delete_; |
1488 window_to_delete_ = NULL; | 1488 window_to_delete_ = NULL; |
1489 } | 1489 } |
1490 } | 1490 } |
1491 | 1491 |
1492 Window* window_to_delete_; | 1492 Window* window_to_delete_; |
1493 | 1493 |
1494 DISALLOW_COPY_AND_ASSIGN(OnMouseExitDeletingEventFilter); | 1494 DISALLOW_COPY_AND_ASSIGN(OnMouseExitDeletingEventFilter); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1540 // RootWindow at such time. | 1540 // RootWindow at such time. |
1541 class ValidRootDuringDestructionWindowObserver : public aura::WindowObserver { | 1541 class ValidRootDuringDestructionWindowObserver : public aura::WindowObserver { |
1542 public: | 1542 public: |
1543 ValidRootDuringDestructionWindowObserver(bool* got_destroying, | 1543 ValidRootDuringDestructionWindowObserver(bool* got_destroying, |
1544 bool* has_valid_root) | 1544 bool* has_valid_root) |
1545 : got_destroying_(got_destroying), | 1545 : got_destroying_(got_destroying), |
1546 has_valid_root_(has_valid_root) { | 1546 has_valid_root_(has_valid_root) { |
1547 } | 1547 } |
1548 | 1548 |
1549 // WindowObserver: | 1549 // WindowObserver: |
1550 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE { | 1550 virtual void OnWindowDestroying(aura::Window* window) override { |
1551 *got_destroying_ = true; | 1551 *got_destroying_ = true; |
1552 *has_valid_root_ = (window->GetRootWindow() != NULL); | 1552 *has_valid_root_ = (window->GetRootWindow() != NULL); |
1553 } | 1553 } |
1554 | 1554 |
1555 private: | 1555 private: |
1556 bool* got_destroying_; | 1556 bool* got_destroying_; |
1557 bool* has_valid_root_; | 1557 bool* has_valid_root_; |
1558 | 1558 |
1559 DISALLOW_COPY_AND_ASSIGN(ValidRootDuringDestructionWindowObserver); | 1559 DISALLOW_COPY_AND_ASSIGN(ValidRootDuringDestructionWindowObserver); |
1560 }; | 1560 }; |
(...skipping 24 matching lines...) Expand all Loading... |
1585 class DontResetHeldEventWindowDelegate : public test::TestWindowDelegate { | 1585 class DontResetHeldEventWindowDelegate : public test::TestWindowDelegate { |
1586 public: | 1586 public: |
1587 explicit DontResetHeldEventWindowDelegate(aura::Window* root) | 1587 explicit DontResetHeldEventWindowDelegate(aura::Window* root) |
1588 : root_(root), | 1588 : root_(root), |
1589 mouse_event_count_(0) {} | 1589 mouse_event_count_(0) {} |
1590 virtual ~DontResetHeldEventWindowDelegate() {} | 1590 virtual ~DontResetHeldEventWindowDelegate() {} |
1591 | 1591 |
1592 int mouse_event_count() const { return mouse_event_count_; } | 1592 int mouse_event_count() const { return mouse_event_count_; } |
1593 | 1593 |
1594 // TestWindowDelegate: | 1594 // TestWindowDelegate: |
1595 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE { | 1595 virtual void OnMouseEvent(ui::MouseEvent* event) override { |
1596 if ((event->flags() & ui::EF_SHIFT_DOWN) != 0 && | 1596 if ((event->flags() & ui::EF_SHIFT_DOWN) != 0 && |
1597 mouse_event_count_++ == 0) { | 1597 mouse_event_count_++ == 0) { |
1598 ui::MouseEvent mouse_event(ui::ET_MOUSE_PRESSED, | 1598 ui::MouseEvent mouse_event(ui::ET_MOUSE_PRESSED, |
1599 gfx::Point(10, 10), gfx::Point(10, 10), | 1599 gfx::Point(10, 10), gfx::Point(10, 10), |
1600 ui::EF_SHIFT_DOWN, 0); | 1600 ui::EF_SHIFT_DOWN, 0); |
1601 root_->GetHost()->dispatcher()->RepostEvent(mouse_event); | 1601 root_->GetHost()->dispatcher()->RepostEvent(mouse_event); |
1602 } | 1602 } |
1603 } | 1603 } |
1604 | 1604 |
1605 private: | 1605 private: |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1646 : host_(host), | 1646 : host_(host), |
1647 got_mouse_event_(false), | 1647 got_mouse_event_(false), |
1648 got_destroy_(false) { | 1648 got_destroy_(false) { |
1649 } | 1649 } |
1650 virtual ~DeleteHostFromHeldMouseEventDelegate() {} | 1650 virtual ~DeleteHostFromHeldMouseEventDelegate() {} |
1651 | 1651 |
1652 bool got_mouse_event() const { return got_mouse_event_; } | 1652 bool got_mouse_event() const { return got_mouse_event_; } |
1653 bool got_destroy() const { return got_destroy_; } | 1653 bool got_destroy() const { return got_destroy_; } |
1654 | 1654 |
1655 // TestWindowDelegate: | 1655 // TestWindowDelegate: |
1656 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE { | 1656 virtual void OnMouseEvent(ui::MouseEvent* event) override { |
1657 if ((event->flags() & ui::EF_SHIFT_DOWN) != 0) { | 1657 if ((event->flags() & ui::EF_SHIFT_DOWN) != 0) { |
1658 got_mouse_event_ = true; | 1658 got_mouse_event_ = true; |
1659 delete host_; | 1659 delete host_; |
1660 } | 1660 } |
1661 } | 1661 } |
1662 virtual void OnWindowDestroyed(Window* window) OVERRIDE { | 1662 virtual void OnWindowDestroyed(Window* window) override { |
1663 got_destroy_ = true; | 1663 got_destroy_ = true; |
1664 } | 1664 } |
1665 | 1665 |
1666 private: | 1666 private: |
1667 WindowTreeHost* host_; | 1667 WindowTreeHost* host_; |
1668 bool got_mouse_event_; | 1668 bool got_mouse_event_; |
1669 bool got_destroy_; | 1669 bool got_destroy_; |
1670 | 1670 |
1671 DISALLOW_COPY_AND_ASSIGN(DeleteHostFromHeldMouseEventDelegate); | 1671 DISALLOW_COPY_AND_ASSIGN(DeleteHostFromHeldMouseEventDelegate); |
1672 }; | 1672 }; |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1817 void CreateCaptureWindow(aura::Window* root_window) { | 1817 void CreateCaptureWindow(aura::Window* root_window) { |
1818 capture_window_.reset(test::CreateTestWindowWithDelegate( | 1818 capture_window_.reset(test::CreateTestWindowWithDelegate( |
1819 this, -1234, gfx::Rect(20, 20, 20, 20), root_window)); | 1819 this, -1234, gfx::Rect(20, 20, 20, 20), root_window)); |
1820 capture_window_->SetCapture(); | 1820 capture_window_->SetCapture(); |
1821 } | 1821 } |
1822 | 1822 |
1823 void reset() { | 1823 void reset() { |
1824 capture_window_.reset(); | 1824 capture_window_.reset(); |
1825 } | 1825 } |
1826 | 1826 |
1827 virtual void OnCaptureLost() OVERRIDE { | 1827 virtual void OnCaptureLost() override { |
1828 capture_window_.reset(); | 1828 capture_window_.reset(); |
1829 } | 1829 } |
1830 | 1830 |
1831 virtual void OnWindowDestroyed(Window* window) OVERRIDE { | 1831 virtual void OnWindowDestroyed(Window* window) override { |
1832 TestWindowDelegate::OnWindowDestroyed(window); | 1832 TestWindowDelegate::OnWindowDestroyed(window); |
1833 capture_window_.reset(); | 1833 capture_window_.reset(); |
1834 } | 1834 } |
1835 | 1835 |
1836 aura::Window* capture_window() { return capture_window_.get(); } | 1836 aura::Window* capture_window() { return capture_window_.get(); } |
1837 | 1837 |
1838 private: | 1838 private: |
1839 scoped_ptr<aura::Window> capture_window_; | 1839 scoped_ptr<aura::Window> capture_window_; |
1840 | 1840 |
1841 DISALLOW_COPY_AND_ASSIGN(CaptureWindowTracker); | 1841 DISALLOW_COPY_AND_ASSIGN(CaptureWindowTracker); |
(...skipping 16 matching lines...) Expand all Loading... |
1858 capture_window_tracker.reset(); | 1858 capture_window_tracker.reset(); |
1859 EXPECT_EQ(NULL, capture_window_tracker.capture_window()); | 1859 EXPECT_EQ(NULL, capture_window_tracker.capture_window()); |
1860 } | 1860 } |
1861 | 1861 |
1862 class ExitMessageLoopOnMousePress : public ui::test::TestEventHandler { | 1862 class ExitMessageLoopOnMousePress : public ui::test::TestEventHandler { |
1863 public: | 1863 public: |
1864 ExitMessageLoopOnMousePress() {} | 1864 ExitMessageLoopOnMousePress() {} |
1865 virtual ~ExitMessageLoopOnMousePress() {} | 1865 virtual ~ExitMessageLoopOnMousePress() {} |
1866 | 1866 |
1867 protected: | 1867 protected: |
1868 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE { | 1868 virtual void OnMouseEvent(ui::MouseEvent* event) override { |
1869 ui::test::TestEventHandler::OnMouseEvent(event); | 1869 ui::test::TestEventHandler::OnMouseEvent(event); |
1870 if (event->type() == ui::ET_MOUSE_PRESSED) | 1870 if (event->type() == ui::ET_MOUSE_PRESSED) |
1871 base::MessageLoopForUI::current()->Quit(); | 1871 base::MessageLoopForUI::current()->Quit(); |
1872 } | 1872 } |
1873 | 1873 |
1874 private: | 1874 private: |
1875 DISALLOW_COPY_AND_ASSIGN(ExitMessageLoopOnMousePress); | 1875 DISALLOW_COPY_AND_ASSIGN(ExitMessageLoopOnMousePress); |
1876 }; | 1876 }; |
1877 | 1877 |
1878 class WindowEventDispatcherTestWithMessageLoop | 1878 class WindowEventDispatcherTestWithMessageLoop |
(...skipping 29 matching lines...) Expand all Loading... |
1908 | 1908 |
1909 // Let the current message-loop run. The event-handler will terminate the | 1909 // Let the current message-loop run. The event-handler will terminate the |
1910 // message-loop when it receives the reposted event. | 1910 // message-loop when it receives the reposted event. |
1911 } | 1911 } |
1912 | 1912 |
1913 base::MessageLoop* message_loop() { | 1913 base::MessageLoop* message_loop() { |
1914 return base::MessageLoopForUI::current(); | 1914 return base::MessageLoopForUI::current(); |
1915 } | 1915 } |
1916 | 1916 |
1917 protected: | 1917 protected: |
1918 virtual void SetUp() OVERRIDE { | 1918 virtual void SetUp() override { |
1919 WindowEventDispatcherTest::SetUp(); | 1919 WindowEventDispatcherTest::SetUp(); |
1920 window_.reset(CreateNormalWindow(1, root_window(), NULL)); | 1920 window_.reset(CreateNormalWindow(1, root_window(), NULL)); |
1921 window_->AddPreTargetHandler(&handler_); | 1921 window_->AddPreTargetHandler(&handler_); |
1922 } | 1922 } |
1923 | 1923 |
1924 virtual void TearDown() OVERRIDE { | 1924 virtual void TearDown() override { |
1925 window_.reset(); | 1925 window_.reset(); |
1926 WindowEventDispatcherTest::TearDown(); | 1926 WindowEventDispatcherTest::TearDown(); |
1927 } | 1927 } |
1928 | 1928 |
1929 private: | 1929 private: |
1930 // Used to avoid a copying |event| when binding to a closure. | 1930 // Used to avoid a copying |event| when binding to a closure. |
1931 static void RepostEventHelper(WindowEventDispatcher* dispatcher, | 1931 static void RepostEventHelper(WindowEventDispatcher* dispatcher, |
1932 scoped_ptr<ui::MouseEvent> event) { | 1932 scoped_ptr<ui::MouseEvent> event) { |
1933 dispatcher->RepostEvent(*event); | 1933 dispatcher->RepostEvent(*event); |
1934 } | 1934 } |
(...skipping 14 matching lines...) Expand all Loading... |
1949 base::Unretained(this))); | 1949 base::Unretained(this))); |
1950 message_loop()->Run(); | 1950 message_loop()->Run(); |
1951 } | 1951 } |
1952 | 1952 |
1953 class WindowEventDispatcherTestInHighDPI : public WindowEventDispatcherTest { | 1953 class WindowEventDispatcherTestInHighDPI : public WindowEventDispatcherTest { |
1954 public: | 1954 public: |
1955 WindowEventDispatcherTestInHighDPI() {} | 1955 WindowEventDispatcherTestInHighDPI() {} |
1956 virtual ~WindowEventDispatcherTestInHighDPI() {} | 1956 virtual ~WindowEventDispatcherTestInHighDPI() {} |
1957 | 1957 |
1958 protected: | 1958 protected: |
1959 virtual void SetUp() OVERRIDE { | 1959 virtual void SetUp() override { |
1960 WindowEventDispatcherTest::SetUp(); | 1960 WindowEventDispatcherTest::SetUp(); |
1961 test_screen()->SetDeviceScaleFactor(2.f); | 1961 test_screen()->SetDeviceScaleFactor(2.f); |
1962 } | 1962 } |
1963 }; | 1963 }; |
1964 | 1964 |
1965 TEST_F(WindowEventDispatcherTestInHighDPI, EventLocationTransform) { | 1965 TEST_F(WindowEventDispatcherTestInHighDPI, EventLocationTransform) { |
1966 test::TestWindowDelegate delegate; | 1966 test::TestWindowDelegate delegate; |
1967 scoped_ptr<aura::Window> child(test::CreateTestWindowWithDelegate(&delegate, | 1967 scoped_ptr<aura::Window> child(test::CreateTestWindowWithDelegate(&delegate, |
1968 1234, gfx::Rect(20, 20, 100, 100), root_window())); | 1968 1234, gfx::Rect(20, 20, 100, 100), root_window())); |
1969 child->Show(); | 1969 child->Show(); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2027 recorder.touch_locations()[0].ToString()); | 2027 recorder.touch_locations()[0].ToString()); |
2028 EXPECT_EQ(gfx::Point(-40, 10).ToString(), | 2028 EXPECT_EQ(gfx::Point(-40, 10).ToString(), |
2029 recorder.touch_locations()[1].ToString()); | 2029 recorder.touch_locations()[1].ToString()); |
2030 } | 2030 } |
2031 | 2031 |
2032 class SelfDestructDelegate : public test::TestWindowDelegate { | 2032 class SelfDestructDelegate : public test::TestWindowDelegate { |
2033 public: | 2033 public: |
2034 SelfDestructDelegate() {} | 2034 SelfDestructDelegate() {} |
2035 virtual ~SelfDestructDelegate() {} | 2035 virtual ~SelfDestructDelegate() {} |
2036 | 2036 |
2037 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE { | 2037 virtual void OnMouseEvent(ui::MouseEvent* event) override { |
2038 window_.reset(); | 2038 window_.reset(); |
2039 } | 2039 } |
2040 | 2040 |
2041 void set_window(scoped_ptr<aura::Window> window) { | 2041 void set_window(scoped_ptr<aura::Window> window) { |
2042 window_ = window.Pass(); | 2042 window_ = window.Pass(); |
2043 } | 2043 } |
2044 bool has_window() const { return !!window_.get(); } | 2044 bool has_window() const { return !!window_.get(); } |
2045 | 2045 |
2046 private: | 2046 private: |
2047 scoped_ptr<aura::Window> window_; | 2047 scoped_ptr<aura::Window> window_; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2080 } | 2080 } |
2081 | 2081 |
2082 class StaticFocusClient : public client::FocusClient { | 2082 class StaticFocusClient : public client::FocusClient { |
2083 public: | 2083 public: |
2084 explicit StaticFocusClient(Window* focused) | 2084 explicit StaticFocusClient(Window* focused) |
2085 : focused_(focused) {} | 2085 : focused_(focused) {} |
2086 virtual ~StaticFocusClient() {} | 2086 virtual ~StaticFocusClient() {} |
2087 | 2087 |
2088 private: | 2088 private: |
2089 // client::FocusClient: | 2089 // client::FocusClient: |
2090 virtual void AddObserver(client::FocusChangeObserver* observer) OVERRIDE {} | 2090 virtual void AddObserver(client::FocusChangeObserver* observer) override {} |
2091 virtual void RemoveObserver(client::FocusChangeObserver* observer) OVERRIDE {} | 2091 virtual void RemoveObserver(client::FocusChangeObserver* observer) override {} |
2092 virtual void FocusWindow(Window* window) OVERRIDE {} | 2092 virtual void FocusWindow(Window* window) override {} |
2093 virtual void ResetFocusWithinActiveWindow(Window* window) OVERRIDE {} | 2093 virtual void ResetFocusWithinActiveWindow(Window* window) override {} |
2094 virtual Window* GetFocusedWindow() OVERRIDE { return focused_; } | 2094 virtual Window* GetFocusedWindow() override { return focused_; } |
2095 | 2095 |
2096 Window* focused_; | 2096 Window* focused_; |
2097 | 2097 |
2098 DISALLOW_COPY_AND_ASSIGN(StaticFocusClient); | 2098 DISALLOW_COPY_AND_ASSIGN(StaticFocusClient); |
2099 }; | 2099 }; |
2100 | 2100 |
2101 // Tests that host-cancel-mode event can be dispatched to a dispatcher safely | 2101 // Tests that host-cancel-mode event can be dispatched to a dispatcher safely |
2102 // when the focused window does not live in the dispatcher's tree. | 2102 // when the focused window does not live in the dispatcher's tree. |
2103 TEST_F(WindowEventDispatcherTest, HostCancelModeWithFocusedWindowOutside) { | 2103 TEST_F(WindowEventDispatcherTest, HostCancelModeWithFocusedWindowOutside) { |
2104 test::TestWindowDelegate delegate; | 2104 test::TestWindowDelegate delegate; |
(...skipping 14 matching lines...) Expand all Loading... |
2119 class DispatchEventHandler : public ui::EventHandler { | 2119 class DispatchEventHandler : public ui::EventHandler { |
2120 public: | 2120 public: |
2121 explicit DispatchEventHandler(Window* target) | 2121 explicit DispatchEventHandler(Window* target) |
2122 : target_(target), | 2122 : target_(target), |
2123 dispatched_(false) {} | 2123 dispatched_(false) {} |
2124 virtual ~DispatchEventHandler() {} | 2124 virtual ~DispatchEventHandler() {} |
2125 | 2125 |
2126 bool dispatched() const { return dispatched_; } | 2126 bool dispatched() const { return dispatched_; } |
2127 private: | 2127 private: |
2128 // ui::EventHandler: | 2128 // ui::EventHandler: |
2129 virtual void OnMouseEvent(ui::MouseEvent* mouse) OVERRIDE { | 2129 virtual void OnMouseEvent(ui::MouseEvent* mouse) override { |
2130 if (mouse->type() == ui::ET_MOUSE_MOVED) { | 2130 if (mouse->type() == ui::ET_MOUSE_MOVED) { |
2131 ui::MouseEvent move(ui::ET_MOUSE_MOVED, target_->bounds().CenterPoint(), | 2131 ui::MouseEvent move(ui::ET_MOUSE_MOVED, target_->bounds().CenterPoint(), |
2132 target_->bounds().CenterPoint(), ui::EF_NONE, ui::EF_NONE); | 2132 target_->bounds().CenterPoint(), ui::EF_NONE, ui::EF_NONE); |
2133 ui::EventDispatchDetails details = | 2133 ui::EventDispatchDetails details = |
2134 target_->GetHost()->dispatcher()->OnEventFromSource(&move); | 2134 target_->GetHost()->dispatcher()->OnEventFromSource(&move); |
2135 ASSERT_FALSE(details.dispatcher_destroyed); | 2135 ASSERT_FALSE(details.dispatcher_destroyed); |
2136 EXPECT_FALSE(details.target_destroyed); | 2136 EXPECT_FALSE(details.target_destroyed); |
2137 EXPECT_EQ(target_, move.target()); | 2137 EXPECT_EQ(target_, move.target()); |
2138 dispatched_ = true; | 2138 dispatched_ = true; |
2139 } | 2139 } |
2140 ui::EventHandler::OnMouseEvent(mouse); | 2140 ui::EventHandler::OnMouseEvent(mouse); |
2141 } | 2141 } |
2142 | 2142 |
2143 Window* target_; | 2143 Window* target_; |
2144 bool dispatched_; | 2144 bool dispatched_; |
2145 | 2145 |
2146 DISALLOW_COPY_AND_ASSIGN(DispatchEventHandler); | 2146 DISALLOW_COPY_AND_ASSIGN(DispatchEventHandler); |
2147 }; | 2147 }; |
2148 | 2148 |
2149 // Moves |window| to |root_window| when it receives a mouse-move event. | 2149 // Moves |window| to |root_window| when it receives a mouse-move event. |
2150 class MoveWindowHandler : public ui::EventHandler { | 2150 class MoveWindowHandler : public ui::EventHandler { |
2151 public: | 2151 public: |
2152 MoveWindowHandler(Window* window, Window* root_window) | 2152 MoveWindowHandler(Window* window, Window* root_window) |
2153 : window_to_move_(window), | 2153 : window_to_move_(window), |
2154 root_window_to_move_to_(root_window) {} | 2154 root_window_to_move_to_(root_window) {} |
2155 virtual ~MoveWindowHandler() {} | 2155 virtual ~MoveWindowHandler() {} |
2156 | 2156 |
2157 private: | 2157 private: |
2158 // ui::EventHandler: | 2158 // ui::EventHandler: |
2159 virtual void OnMouseEvent(ui::MouseEvent* mouse) OVERRIDE { | 2159 virtual void OnMouseEvent(ui::MouseEvent* mouse) override { |
2160 if (mouse->type() == ui::ET_MOUSE_MOVED) { | 2160 if (mouse->type() == ui::ET_MOUSE_MOVED) { |
2161 root_window_to_move_to_->AddChild(window_to_move_); | 2161 root_window_to_move_to_->AddChild(window_to_move_); |
2162 } | 2162 } |
2163 ui::EventHandler::OnMouseEvent(mouse); | 2163 ui::EventHandler::OnMouseEvent(mouse); |
2164 } | 2164 } |
2165 | 2165 |
2166 Window* window_to_move_; | 2166 Window* window_to_move_; |
2167 Window* root_window_to_move_to_; | 2167 Window* root_window_to_move_to_; |
2168 | 2168 |
2169 DISALLOW_COPY_AND_ASSIGN(MoveWindowHandler); | 2169 DISALLOW_COPY_AND_ASSIGN(MoveWindowHandler); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2215 second->RemovePreTargetHandler(&move_window); | 2215 second->RemovePreTargetHandler(&move_window); |
2216 } | 2216 } |
2217 | 2217 |
2218 class AlwaysMouseDownInputStateLookup : public InputStateLookup { | 2218 class AlwaysMouseDownInputStateLookup : public InputStateLookup { |
2219 public: | 2219 public: |
2220 AlwaysMouseDownInputStateLookup() {} | 2220 AlwaysMouseDownInputStateLookup() {} |
2221 virtual ~AlwaysMouseDownInputStateLookup() {} | 2221 virtual ~AlwaysMouseDownInputStateLookup() {} |
2222 | 2222 |
2223 private: | 2223 private: |
2224 // InputStateLookup: | 2224 // InputStateLookup: |
2225 virtual bool IsMouseButtonDown() const OVERRIDE { return true; } | 2225 virtual bool IsMouseButtonDown() const override { return true; } |
2226 | 2226 |
2227 DISALLOW_COPY_AND_ASSIGN(AlwaysMouseDownInputStateLookup); | 2227 DISALLOW_COPY_AND_ASSIGN(AlwaysMouseDownInputStateLookup); |
2228 }; | 2228 }; |
2229 | 2229 |
2230 TEST_F(WindowEventDispatcherTest, | 2230 TEST_F(WindowEventDispatcherTest, |
2231 CursorVisibilityChangedWhileCaptureWindowInAnotherDispatcher) { | 2231 CursorVisibilityChangedWhileCaptureWindowInAnotherDispatcher) { |
2232 test::EventCountDelegate delegate; | 2232 test::EventCountDelegate delegate; |
2233 scoped_ptr<Window> window(CreateTestWindowWithDelegate(&delegate, 123, | 2233 scoped_ptr<Window> window(CreateTestWindowWithDelegate(&delegate, 123, |
2234 gfx::Rect(20, 10, 10, 20), root_window())); | 2234 gfx::Rect(20, 10, 10, 20), root_window())); |
2235 window->Show(); | 2235 window->Show(); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2312 | 2312 |
2313 class AsyncWindowDelegate : public test::TestWindowDelegate { | 2313 class AsyncWindowDelegate : public test::TestWindowDelegate { |
2314 public: | 2314 public: |
2315 AsyncWindowDelegate(WindowEventDispatcher* dispatcher) | 2315 AsyncWindowDelegate(WindowEventDispatcher* dispatcher) |
2316 : dispatcher_(dispatcher) {} | 2316 : dispatcher_(dispatcher) {} |
2317 | 2317 |
2318 void set_window(Window* window) { | 2318 void set_window(Window* window) { |
2319 window_ = window; | 2319 window_ = window; |
2320 } | 2320 } |
2321 private: | 2321 private: |
2322 virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE { | 2322 virtual void OnTouchEvent(ui::TouchEvent* event) override { |
2323 // Convert touch event back to root window coordinates. | 2323 // Convert touch event back to root window coordinates. |
2324 event->ConvertLocationToTarget(window_, window_->GetRootWindow()); | 2324 event->ConvertLocationToTarget(window_, window_->GetRootWindow()); |
2325 dispatcher_->ProcessedTouchEvent(event, window_, ui::ER_UNHANDLED); | 2325 dispatcher_->ProcessedTouchEvent(event, window_, ui::ER_UNHANDLED); |
2326 event->StopPropagation(); | 2326 event->StopPropagation(); |
2327 } | 2327 } |
2328 | 2328 |
2329 WindowEventDispatcher* dispatcher_; | 2329 WindowEventDispatcher* dispatcher_; |
2330 Window* window_; | 2330 Window* window_; |
2331 | 2331 |
2332 DISALLOW_COPY_AND_ASSIGN(AsyncWindowDelegate); | 2332 DISALLOW_COPY_AND_ASSIGN(AsyncWindowDelegate); |
(...skipping 27 matching lines...) Expand all Loading... |
2360 ASSERT_EQ(1u, recorder.touch_locations().size()); | 2360 ASSERT_EQ(1u, recorder.touch_locations().size()); |
2361 EXPECT_EQ(gfx::Point(kX - kWindowOffset, kY - kWindowOffset).ToString(), | 2361 EXPECT_EQ(gfx::Point(kX - kWindowOffset, kY - kWindowOffset).ToString(), |
2362 recorder.touch_locations()[0].ToString()); | 2362 recorder.touch_locations()[0].ToString()); |
2363 | 2363 |
2364 ASSERT_EQ(2u, recorder.gesture_locations().size()); | 2364 ASSERT_EQ(2u, recorder.gesture_locations().size()); |
2365 EXPECT_EQ(gfx::Point(kX - kWindowOffset, kY - kWindowOffset).ToString(), | 2365 EXPECT_EQ(gfx::Point(kX - kWindowOffset, kY - kWindowOffset).ToString(), |
2366 recorder.gesture_locations()[0].ToString()); | 2366 recorder.gesture_locations()[0].ToString()); |
2367 } | 2367 } |
2368 | 2368 |
2369 } // namespace aura | 2369 } // namespace aura |
OLD | NEW |