| 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" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 #include "ui/aura/client/capture_client.h" | 12 #include "ui/aura/client/capture_client.h" |
| 13 #include "ui/aura/client/event_client.h" | 13 #include "ui/aura/client/event_client.h" |
| 14 #include "ui/aura/client/focus_client.h" | 14 #include "ui/aura/client/focus_client.h" |
| 15 #include "ui/aura/env.h" | 15 #include "ui/aura/env.h" |
| 16 #include "ui/aura/test/aura_test_base.h" | 16 #include "ui/aura/test/aura_test_base.h" |
| 17 #include "ui/aura/test/env_test_helper.h" | 17 #include "ui/aura/test/env_test_helper.h" |
| 18 #include "ui/aura/test/event_generator.h" |
| 18 #include "ui/aura/test/test_cursor_client.h" | 19 #include "ui/aura/test/test_cursor_client.h" |
| 19 #include "ui/aura/test/test_screen.h" | 20 #include "ui/aura/test/test_screen.h" |
| 20 #include "ui/aura/test/test_window_delegate.h" | 21 #include "ui/aura/test/test_window_delegate.h" |
| 21 #include "ui/aura/test/test_windows.h" | 22 #include "ui/aura/test/test_windows.h" |
| 22 #include "ui/aura/window.h" | 23 #include "ui/aura/window.h" |
| 23 #include "ui/aura/window_tracker.h" | 24 #include "ui/aura/window_tracker.h" |
| 24 #include "ui/base/hit_test.h" | 25 #include "ui/base/hit_test.h" |
| 25 #include "ui/events/event.h" | 26 #include "ui/events/event.h" |
| 26 #include "ui/events/event_handler.h" | 27 #include "ui/events/event_handler.h" |
| 27 #include "ui/events/event_utils.h" | 28 #include "ui/events/event_utils.h" |
| 28 #include "ui/events/gestures/gesture_configuration.h" | 29 #include "ui/events/gestures/gesture_configuration.h" |
| 29 #include "ui/events/keycodes/keyboard_codes.h" | 30 #include "ui/events/keycodes/keyboard_codes.h" |
| 30 #include "ui/events/test/event_generator.h" | |
| 31 #include "ui/events/test/test_event_handler.h" | 31 #include "ui/events/test/test_event_handler.h" |
| 32 #include "ui/gfx/point.h" | 32 #include "ui/gfx/point.h" |
| 33 #include "ui/gfx/rect.h" | 33 #include "ui/gfx/rect.h" |
| 34 #include "ui/gfx/screen.h" | 34 #include "ui/gfx/screen.h" |
| 35 #include "ui/gfx/transform.h" | 35 #include "ui/gfx/transform.h" |
| 36 | 36 |
| 37 namespace aura { | 37 namespace aura { |
| 38 namespace { | 38 namespace { |
| 39 | 39 |
| 40 // A delegate that always returns a non-client component for hit tests. | 40 // A delegate that always returns a non-client component for hit tests. |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 client.Lock(); | 311 client.Lock(); |
| 312 | 312 |
| 313 // Since we're locked, the attempt to focus w2 will be ignored. | 313 // Since we're locked, the attempt to focus w2 will be ignored. |
| 314 w2->Focus(); | 314 w2->Focus(); |
| 315 EXPECT_TRUE(IsFocusedWindow(w1)); | 315 EXPECT_TRUE(IsFocusedWindow(w1)); |
| 316 EXPECT_FALSE(IsFocusedWindow(w2)); | 316 EXPECT_FALSE(IsFocusedWindow(w2)); |
| 317 | 317 |
| 318 { | 318 { |
| 319 // Attempting to send a key event to w1 (not in the lock container) should | 319 // Attempting to send a key event to w1 (not in the lock container) should |
| 320 // cause focus to be reset. | 320 // cause focus to be reset. |
| 321 ui::test::EventGenerator generator(root_window()); | 321 test::EventGenerator generator(root_window()); |
| 322 generator.PressKey(ui::VKEY_SPACE, 0); | 322 generator.PressKey(ui::VKEY_SPACE, 0); |
| 323 EXPECT_EQ(NULL, client::GetFocusClient(w1)->GetFocusedWindow()); | 323 EXPECT_EQ(NULL, client::GetFocusClient(w1)->GetFocusedWindow()); |
| 324 EXPECT_FALSE(IsFocusedWindow(w1)); | 324 EXPECT_FALSE(IsFocusedWindow(w1)); |
| 325 } | 325 } |
| 326 | 326 |
| 327 { | 327 { |
| 328 // Events sent to a window not in the lock container will not be processed. | 328 // Events sent to a window not in the lock container will not be processed. |
| 329 // i.e. never sent to the non-lock container's event filter. | 329 // i.e. never sent to the non-lock container's event filter. |
| 330 ui::test::EventGenerator generator(root_window(), w1); | 330 test::EventGenerator generator(root_window(), w1); |
| 331 generator.ClickLeftButton(); | 331 generator.ClickLeftButton(); |
| 332 EXPECT_EQ(0, nonlock_ef.num_mouse_events()); | 332 EXPECT_EQ(0, nonlock_ef.num_mouse_events()); |
| 333 | 333 |
| 334 // Events sent to a window in the lock container will be processed. | 334 // Events sent to a window in the lock container will be processed. |
| 335 ui::test::EventGenerator generator3(root_window(), w3.get()); | 335 test::EventGenerator generator3(root_window(), w3.get()); |
| 336 generator3.PressLeftButton(); | 336 generator3.PressLeftButton(); |
| 337 EXPECT_EQ(1, lock_ef.num_mouse_events()); | 337 EXPECT_EQ(1, lock_ef.num_mouse_events()); |
| 338 } | 338 } |
| 339 | 339 |
| 340 // Prevent w3 from being deleted by the hierarchy since its delegate is owned | 340 // Prevent w3 from being deleted by the hierarchy since its delegate is owned |
| 341 // by this scope. | 341 // by this scope. |
| 342 w3->parent()->RemoveChild(w3.get()); | 342 w3->parent()->RemoveChild(w3.get()); |
| 343 } | 343 } |
| 344 | 344 |
| 345 TEST_F(WindowEventDispatcherTest, IgnoreUnknownKeys) { | 345 TEST_F(WindowEventDispatcherTest, IgnoreUnknownKeys) { |
| (...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 819 // gesture if touch-move events are being held by the dispatcher. | 819 // gesture if touch-move events are being held by the dispatcher. |
| 820 TEST_F(WindowEventDispatcherTest, TouchMovesHeldOnScroll) { | 820 TEST_F(WindowEventDispatcherTest, TouchMovesHeldOnScroll) { |
| 821 EventFilterRecorder recorder; | 821 EventFilterRecorder recorder; |
| 822 root_window()->AddPreTargetHandler(&recorder); | 822 root_window()->AddPreTargetHandler(&recorder); |
| 823 test::TestWindowDelegate delegate; | 823 test::TestWindowDelegate delegate; |
| 824 HoldPointerOnScrollHandler handler(host()->dispatcher(), &recorder); | 824 HoldPointerOnScrollHandler handler(host()->dispatcher(), &recorder); |
| 825 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 825 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 826 &delegate, 1, gfx::Rect(50, 50, 100, 100), root_window())); | 826 &delegate, 1, gfx::Rect(50, 50, 100, 100), root_window())); |
| 827 window->AddPreTargetHandler(&handler); | 827 window->AddPreTargetHandler(&handler); |
| 828 | 828 |
| 829 ui::test::EventGenerator generator(root_window()); | 829 test::EventGenerator generator(root_window()); |
| 830 generator.GestureScrollSequence( | 830 generator.GestureScrollSequence( |
| 831 gfx::Point(60, 60), gfx::Point(10, 60), | 831 gfx::Point(60, 60), gfx::Point(10, 60), |
| 832 base::TimeDelta::FromMilliseconds(100), 25); | 832 base::TimeDelta::FromMilliseconds(100), 25); |
| 833 | 833 |
| 834 // |handler| will have reset |filter| and started holding the touch-move | 834 // |handler| will have reset |filter| and started holding the touch-move |
| 835 // events when scrolling started. At the end of the scroll (i.e. upon | 835 // events when scrolling started. At the end of the scroll (i.e. upon |
| 836 // touch-release), the held touch-move event will have been dispatched first, | 836 // touch-release), the held touch-move event will have been dispatched first, |
| 837 // along with the subsequent events (i.e. touch-release, scroll-end, and | 837 // along with the subsequent events (i.e. touch-release, scroll-end, and |
| 838 // gesture-end). | 838 // gesture-end). |
| 839 const EventFilterRecorder::Events& events = recorder.events(); | 839 const EventFilterRecorder::Events& events = recorder.events(); |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1156 // Deleting the window should not cause a crash, only prevent further | 1156 // Deleting the window should not cause a crash, only prevent further |
| 1157 // processing from occurring. | 1157 // processing from occurring. |
| 1158 scoped_ptr<Window> w1(CreateNormalWindow(1, root_window(), NULL)); | 1158 scoped_ptr<Window> w1(CreateNormalWindow(1, root_window(), NULL)); |
| 1159 DeletingWindowDelegate d11; | 1159 DeletingWindowDelegate d11; |
| 1160 Window* w11 = CreateNormalWindow(11, w1.get(), &d11); | 1160 Window* w11 = CreateNormalWindow(11, w1.get(), &d11); |
| 1161 WindowTracker tracker; | 1161 WindowTracker tracker; |
| 1162 DeletingEventFilter w1_filter; | 1162 DeletingEventFilter w1_filter; |
| 1163 w1->AddPreTargetHandler(&w1_filter); | 1163 w1->AddPreTargetHandler(&w1_filter); |
| 1164 client::GetFocusClient(w1.get())->FocusWindow(w11); | 1164 client::GetFocusClient(w1.get())->FocusWindow(w11); |
| 1165 | 1165 |
| 1166 ui::test::EventGenerator generator(root_window(), w11); | 1166 test::EventGenerator generator(root_window(), w11); |
| 1167 | 1167 |
| 1168 // First up, no one deletes anything. | 1168 // First up, no one deletes anything. |
| 1169 tracker.Add(w11); | 1169 tracker.Add(w11); |
| 1170 d11.Reset(w11, false); | 1170 d11.Reset(w11, false); |
| 1171 | 1171 |
| 1172 generator.PressLeftButton(); | 1172 generator.PressLeftButton(); |
| 1173 EXPECT_TRUE(tracker.Contains(w11)); | 1173 EXPECT_TRUE(tracker.Contains(w11)); |
| 1174 EXPECT_TRUE(d11.got_event()); | 1174 EXPECT_TRUE(d11.got_event()); |
| 1175 generator.ReleaseLeftButton(); | 1175 generator.ReleaseLeftButton(); |
| 1176 | 1176 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1220 } // namespace | 1220 } // namespace |
| 1221 | 1221 |
| 1222 // Tests that the gesture recognizer is reset for all child windows when a | 1222 // Tests that the gesture recognizer is reset for all child windows when a |
| 1223 // window hides. No expectations, just checks that the test does not crash. | 1223 // window hides. No expectations, just checks that the test does not crash. |
| 1224 TEST_F(WindowEventDispatcherTest, | 1224 TEST_F(WindowEventDispatcherTest, |
| 1225 GestureRecognizerResetsTargetWhenParentHides) { | 1225 GestureRecognizerResetsTargetWhenParentHides) { |
| 1226 scoped_ptr<Window> w1(CreateNormalWindow(1, root_window(), NULL)); | 1226 scoped_ptr<Window> w1(CreateNormalWindow(1, root_window(), NULL)); |
| 1227 DetachesParentOnTapDelegate delegate; | 1227 DetachesParentOnTapDelegate delegate; |
| 1228 scoped_ptr<Window> parent(CreateNormalWindow(22, w1.get(), NULL)); | 1228 scoped_ptr<Window> parent(CreateNormalWindow(22, w1.get(), NULL)); |
| 1229 Window* child = CreateNormalWindow(11, parent.get(), &delegate); | 1229 Window* child = CreateNormalWindow(11, parent.get(), &delegate); |
| 1230 ui::test::EventGenerator generator(root_window(), child); | 1230 test::EventGenerator generator(root_window(), child); |
| 1231 generator.GestureTapAt(gfx::Point(40, 40)); | 1231 generator.GestureTapAt(gfx::Point(40, 40)); |
| 1232 } | 1232 } |
| 1233 | 1233 |
| 1234 namespace { | 1234 namespace { |
| 1235 | 1235 |
| 1236 // A window delegate that processes nested gestures on tap. | 1236 // A window delegate that processes nested gestures on tap. |
| 1237 class NestedGestureDelegate : public test::TestWindowDelegate { | 1237 class NestedGestureDelegate : public test::TestWindowDelegate { |
| 1238 public: | 1238 public: |
| 1239 NestedGestureDelegate(ui::test::EventGenerator* generator, | 1239 NestedGestureDelegate(test::EventGenerator* generator, |
| 1240 const gfx::Point tap_location) | 1240 const gfx::Point tap_location) |
| 1241 : generator_(generator), | 1241 : generator_(generator), |
| 1242 tap_location_(tap_location), | 1242 tap_location_(tap_location), |
| 1243 gesture_end_count_(0) {} | 1243 gesture_end_count_(0) {} |
| 1244 virtual ~NestedGestureDelegate() {} | 1244 virtual ~NestedGestureDelegate() {} |
| 1245 | 1245 |
| 1246 int gesture_end_count() const { return gesture_end_count_; } | 1246 int gesture_end_count() const { return gesture_end_count_; } |
| 1247 | 1247 |
| 1248 private: | 1248 private: |
| 1249 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE { | 1249 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE { |
| 1250 switch (event->type()) { | 1250 switch (event->type()) { |
| 1251 case ui::ET_GESTURE_TAP_DOWN: | 1251 case ui::ET_GESTURE_TAP_DOWN: |
| 1252 event->SetHandled(); | 1252 event->SetHandled(); |
| 1253 break; | 1253 break; |
| 1254 case ui::ET_GESTURE_TAP: | 1254 case ui::ET_GESTURE_TAP: |
| 1255 if (generator_) | 1255 if (generator_) |
| 1256 generator_->GestureTapAt(tap_location_); | 1256 generator_->GestureTapAt(tap_location_); |
| 1257 event->SetHandled(); | 1257 event->SetHandled(); |
| 1258 break; | 1258 break; |
| 1259 case ui::ET_GESTURE_END: | 1259 case ui::ET_GESTURE_END: |
| 1260 ++gesture_end_count_; | 1260 ++gesture_end_count_; |
| 1261 break; | 1261 break; |
| 1262 default: | 1262 default: |
| 1263 break; | 1263 break; |
| 1264 } | 1264 } |
| 1265 } | 1265 } |
| 1266 | 1266 |
| 1267 ui::test::EventGenerator* generator_; | 1267 test::EventGenerator* generator_; |
| 1268 const gfx::Point tap_location_; | 1268 const gfx::Point tap_location_; |
| 1269 int gesture_end_count_; | 1269 int gesture_end_count_; |
| 1270 DISALLOW_COPY_AND_ASSIGN(NestedGestureDelegate); | 1270 DISALLOW_COPY_AND_ASSIGN(NestedGestureDelegate); |
| 1271 }; | 1271 }; |
| 1272 | 1272 |
| 1273 } // namespace | 1273 } // namespace |
| 1274 | 1274 |
| 1275 // Tests that gesture end is delivered after nested gesture processing. | 1275 // Tests that gesture end is delivered after nested gesture processing. |
| 1276 TEST_F(WindowEventDispatcherTest, GestureEndDeliveredAfterNestedGestures) { | 1276 TEST_F(WindowEventDispatcherTest, GestureEndDeliveredAfterNestedGestures) { |
| 1277 NestedGestureDelegate d1(NULL, gfx::Point()); | 1277 NestedGestureDelegate d1(NULL, gfx::Point()); |
| 1278 scoped_ptr<Window> w1(CreateNormalWindow(1, root_window(), &d1)); | 1278 scoped_ptr<Window> w1(CreateNormalWindow(1, root_window(), &d1)); |
| 1279 w1->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1279 w1->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 1280 | 1280 |
| 1281 ui::test::EventGenerator nested_generator(root_window(), w1.get()); | 1281 test::EventGenerator nested_generator(root_window(), w1.get()); |
| 1282 NestedGestureDelegate d2(&nested_generator, w1->bounds().CenterPoint()); | 1282 NestedGestureDelegate d2(&nested_generator, w1->bounds().CenterPoint()); |
| 1283 scoped_ptr<Window> w2(CreateNormalWindow(1, root_window(), &d2)); | 1283 scoped_ptr<Window> w2(CreateNormalWindow(1, root_window(), &d2)); |
| 1284 w2->SetBounds(gfx::Rect(100, 0, 100, 100)); | 1284 w2->SetBounds(gfx::Rect(100, 0, 100, 100)); |
| 1285 | 1285 |
| 1286 // Tap on w2 which triggers nested gestures for w1. | 1286 // Tap on w2 which triggers nested gestures for w1. |
| 1287 ui::test::EventGenerator generator(root_window(), w2.get()); | 1287 test::EventGenerator generator(root_window(), w2.get()); |
| 1288 generator.GestureTapAt(w2->bounds().CenterPoint()); | 1288 generator.GestureTapAt(w2->bounds().CenterPoint()); |
| 1289 | 1289 |
| 1290 // Both windows should get their gesture end events. | 1290 // Both windows should get their gesture end events. |
| 1291 EXPECT_EQ(1, d1.gesture_end_count()); | 1291 EXPECT_EQ(1, d1.gesture_end_count()); |
| 1292 EXPECT_EQ(1, d2.gesture_end_count()); | 1292 EXPECT_EQ(1, d2.gesture_end_count()); |
| 1293 } | 1293 } |
| 1294 | 1294 |
| 1295 // Tests whether we can repost the Tap down gesture event. | 1295 // Tests whether we can repost the Tap down gesture event. |
| 1296 TEST_F(WindowEventDispatcherTest, RepostTapdownGestureTest) { | 1296 TEST_F(WindowEventDispatcherTest, RepostTapdownGestureTest) { |
| 1297 EventFilterRecorder recorder; | 1297 EventFilterRecorder recorder; |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1394 | 1394 |
| 1395 scoped_ptr<aura::Window> repost_source(CreateTestWindowWithDelegate( | 1395 scoped_ptr<aura::Window> repost_source(CreateTestWindowWithDelegate( |
| 1396 &delegate, 1, gfx::Rect(0, 0, 50, 50), root_window())); | 1396 &delegate, 1, gfx::Rect(0, 0, 50, 50), root_window())); |
| 1397 | 1397 |
| 1398 RepostGestureEventRecorder repost_event_recorder(repost_source.get(), | 1398 RepostGestureEventRecorder repost_event_recorder(repost_source.get(), |
| 1399 repost_target.get()); | 1399 repost_target.get()); |
| 1400 root_window()->AddPreTargetHandler(&repost_event_recorder); | 1400 root_window()->AddPreTargetHandler(&repost_event_recorder); |
| 1401 | 1401 |
| 1402 // Generate a tap down gesture for the repost_source. This will be reposted | 1402 // Generate a tap down gesture for the repost_source. This will be reposted |
| 1403 // to repost_target. | 1403 // to repost_target. |
| 1404 ui::test::EventGenerator repost_generator(root_window(), repost_source.get()); | 1404 test::EventGenerator repost_generator(root_window(), repost_source.get()); |
| 1405 repost_generator.GestureTapAt(gfx::Point(40, 40)); | 1405 repost_generator.GestureTapAt(gfx::Point(40, 40)); |
| 1406 RunAllPendingInMessageLoop(); | 1406 RunAllPendingInMessageLoop(); |
| 1407 | 1407 |
| 1408 ui::test::EventGenerator scroll_generator(root_window(), repost_target.get()); | 1408 test::EventGenerator scroll_generator(root_window(), repost_target.get()); |
| 1409 scroll_generator.GestureScrollSequence( | 1409 scroll_generator.GestureScrollSequence( |
| 1410 gfx::Point(80, 80), | 1410 gfx::Point(80, 80), |
| 1411 gfx::Point(100, 100), | 1411 gfx::Point(100, 100), |
| 1412 base::TimeDelta::FromMilliseconds(100), | 1412 base::TimeDelta::FromMilliseconds(100), |
| 1413 3); | 1413 3); |
| 1414 RunAllPendingInMessageLoop(); | 1414 RunAllPendingInMessageLoop(); |
| 1415 | 1415 |
| 1416 int tap_down_count = 0; | 1416 int tap_down_count = 0; |
| 1417 for (size_t i = 0; i < repost_event_recorder.events().size(); ++i) { | 1417 for (size_t i = 0; i < repost_event_recorder.events().size(); ++i) { |
| 1418 if (repost_event_recorder.events()[i] == ui::ET_GESTURE_TAP_DOWN) | 1418 if (repost_event_recorder.events()[i] == ui::ET_GESTURE_TAP_DOWN) |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1458 // event generated on the previous mouse_moved_handler_. | 1458 // event generated on the previous mouse_moved_handler_. |
| 1459 TEST_F(WindowEventDispatcherTest, DeleteWindowDuringMouseMovedDispatch) { | 1459 TEST_F(WindowEventDispatcherTest, DeleteWindowDuringMouseMovedDispatch) { |
| 1460 // Create window 1 and set its event filter. Window 1 will take ownership of | 1460 // Create window 1 and set its event filter. Window 1 will take ownership of |
| 1461 // the event filter. | 1461 // the event filter. |
| 1462 scoped_ptr<Window> w1(CreateNormalWindow(1, root_window(), NULL)); | 1462 scoped_ptr<Window> w1(CreateNormalWindow(1, root_window(), NULL)); |
| 1463 OnMouseExitDeletingEventFilter w1_filter; | 1463 OnMouseExitDeletingEventFilter w1_filter; |
| 1464 w1->AddPreTargetHandler(&w1_filter); | 1464 w1->AddPreTargetHandler(&w1_filter); |
| 1465 w1->SetBounds(gfx::Rect(20, 20, 60, 60)); | 1465 w1->SetBounds(gfx::Rect(20, 20, 60, 60)); |
| 1466 EXPECT_EQ(NULL, host()->dispatcher()->mouse_moved_handler()); | 1466 EXPECT_EQ(NULL, host()->dispatcher()->mouse_moved_handler()); |
| 1467 | 1467 |
| 1468 ui::test::EventGenerator generator(root_window(), w1.get()); | 1468 test::EventGenerator generator(root_window(), w1.get()); |
| 1469 | 1469 |
| 1470 // Move mouse over window 1 to set it as the |mouse_moved_handler_| for the | 1470 // Move mouse over window 1 to set it as the |mouse_moved_handler_| for the |
| 1471 // root window. | 1471 // root window. |
| 1472 generator.MoveMouseTo(51, 51); | 1472 generator.MoveMouseTo(51, 51); |
| 1473 EXPECT_EQ(w1.get(), host()->dispatcher()->mouse_moved_handler()); | 1473 EXPECT_EQ(w1.get(), host()->dispatcher()->mouse_moved_handler()); |
| 1474 | 1474 |
| 1475 // Create window 2 under the mouse cursor and stack it above window 1. | 1475 // Create window 2 under the mouse cursor and stack it above window 1. |
| 1476 Window* w2 = CreateNormalWindow(2, root_window(), NULL); | 1476 Window* w2 = CreateNormalWindow(2, root_window(), NULL); |
| 1477 w2->SetBounds(gfx::Rect(30, 30, 40, 40)); | 1477 w2->SetBounds(gfx::Rect(30, 30, 40, 40)); |
| 1478 root_window()->StackChildAbove(w2, w1.get()); | 1478 root_window()->StackChildAbove(w2, w1.get()); |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1959 | 1959 |
| 1960 TEST_F(WindowEventDispatcherTestInHighDPI, TouchMovesHeldOnScroll) { | 1960 TEST_F(WindowEventDispatcherTestInHighDPI, TouchMovesHeldOnScroll) { |
| 1961 EventFilterRecorder recorder; | 1961 EventFilterRecorder recorder; |
| 1962 root_window()->AddPreTargetHandler(&recorder); | 1962 root_window()->AddPreTargetHandler(&recorder); |
| 1963 test::TestWindowDelegate delegate; | 1963 test::TestWindowDelegate delegate; |
| 1964 HoldPointerOnScrollHandler handler(host()->dispatcher(), &recorder); | 1964 HoldPointerOnScrollHandler handler(host()->dispatcher(), &recorder); |
| 1965 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 1965 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 1966 &delegate, 1, gfx::Rect(50, 50, 100, 100), root_window())); | 1966 &delegate, 1, gfx::Rect(50, 50, 100, 100), root_window())); |
| 1967 window->AddPreTargetHandler(&handler); | 1967 window->AddPreTargetHandler(&handler); |
| 1968 | 1968 |
| 1969 ui::test::EventGenerator generator(root_window()); | 1969 test::EventGenerator generator(root_window()); |
| 1970 generator.GestureScrollSequence( | 1970 generator.GestureScrollSequence( |
| 1971 gfx::Point(120, 120), gfx::Point(20, 120), | 1971 gfx::Point(120, 120), gfx::Point(20, 120), |
| 1972 base::TimeDelta::FromMilliseconds(100), 25); | 1972 base::TimeDelta::FromMilliseconds(100), 25); |
| 1973 | 1973 |
| 1974 // |handler| will have reset |filter| and started holding the touch-move | 1974 // |handler| will have reset |filter| and started holding the touch-move |
| 1975 // events when scrolling started. At the end of the scroll (i.e. upon | 1975 // events when scrolling started. At the end of the scroll (i.e. upon |
| 1976 // touch-release), the held touch-move event will have been dispatched first, | 1976 // touch-release), the held touch-move event will have been dispatched first, |
| 1977 // along with the subsequent events (i.e. touch-release, scroll-end, and | 1977 // along with the subsequent events (i.e. touch-release, scroll-end, and |
| 1978 // gesture-end). | 1978 // gesture-end). |
| 1979 const EventFilterRecorder::Events& events = recorder.events(); | 1979 const EventFilterRecorder::Events& events = recorder.events(); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2001 window_ = window.Pass(); | 2001 window_ = window.Pass(); |
| 2002 } | 2002 } |
| 2003 bool has_window() const { return !!window_.get(); } | 2003 bool has_window() const { return !!window_.get(); } |
| 2004 | 2004 |
| 2005 private: | 2005 private: |
| 2006 scoped_ptr<aura::Window> window_; | 2006 scoped_ptr<aura::Window> window_; |
| 2007 DISALLOW_COPY_AND_ASSIGN(SelfDestructDelegate); | 2007 DISALLOW_COPY_AND_ASSIGN(SelfDestructDelegate); |
| 2008 }; | 2008 }; |
| 2009 | 2009 |
| 2010 TEST_F(WindowEventDispatcherTest, SynthesizedLocatedEvent) { | 2010 TEST_F(WindowEventDispatcherTest, SynthesizedLocatedEvent) { |
| 2011 ui::test::EventGenerator generator(root_window()); | 2011 test::EventGenerator generator(root_window()); |
| 2012 generator.MoveMouseTo(10, 10); | 2012 generator.MoveMouseTo(10, 10); |
| 2013 EXPECT_EQ("10,10", | 2013 EXPECT_EQ("10,10", |
| 2014 Env::GetInstance()->last_mouse_location().ToString()); | 2014 Env::GetInstance()->last_mouse_location().ToString()); |
| 2015 | 2015 |
| 2016 // Synthesized event should not update the mouse location. | 2016 // Synthesized event should not update the mouse location. |
| 2017 ui::MouseEvent mouseev(ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), | 2017 ui::MouseEvent mouseev(ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), |
| 2018 ui::EF_IS_SYNTHESIZED, 0); | 2018 ui::EF_IS_SYNTHESIZED, 0); |
| 2019 generator.Dispatch(&mouseev); | 2019 generator.Dispatch(&mouseev); |
| 2020 EXPECT_EQ("10,10", | 2020 EXPECT_EQ("10,10", |
| 2021 Env::GetInstance()->last_mouse_location().ToString()); | 2021 Env::GetInstance()->last_mouse_location().ToString()); |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2263 ui::EF_LEFT_MOUSE_BUTTON); | 2263 ui::EF_LEFT_MOUSE_BUTTON); |
| 2264 DispatchEventUsingWindowDispatcher(&mouse); | 2264 DispatchEventUsingWindowDispatcher(&mouse); |
| 2265 EXPECT_TRUE(recorder_first.events().empty()); | 2265 EXPECT_TRUE(recorder_first.events().empty()); |
| 2266 ASSERT_EQ(1u, recorder_second.events().size()); | 2266 ASSERT_EQ(1u, recorder_second.events().size()); |
| 2267 EXPECT_EQ(ui::ET_MOUSE_PRESSED, recorder_second.events()[0]); | 2267 EXPECT_EQ(ui::ET_MOUSE_PRESSED, recorder_second.events()[0]); |
| 2268 EXPECT_EQ(event_location.ToString(), | 2268 EXPECT_EQ(event_location.ToString(), |
| 2269 recorder_second.mouse_locations()[0].ToString()); | 2269 recorder_second.mouse_locations()[0].ToString()); |
| 2270 } | 2270 } |
| 2271 | 2271 |
| 2272 } // namespace aura | 2272 } // namespace aura |
| OLD | NEW |