| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 private: | 98 private: |
| 99 DISALLOW_COPY_AND_ASSIGN(ConsumeKeyHandler); | 99 DISALLOW_COPY_AND_ASSIGN(ConsumeKeyHandler); |
| 100 }; | 100 }; |
| 101 | 101 |
| 102 bool IsFocusedWindow(aura::Window* window) { | 102 bool IsFocusedWindow(aura::Window* window) { |
| 103 return client::GetFocusClient(window)->GetFocusedWindow() == window; | 103 return client::GetFocusClient(window)->GetFocusedWindow() == window; |
| 104 } | 104 } |
| 105 | 105 |
| 106 } // namespace | 106 } // namespace |
| 107 | 107 |
| 108 typedef test::AuraTestBase WindowEventDispatcherTest; | 108 using WindowEventDispatcherTest = test::AuraTestBaseWithType; |
| 109 | 109 |
| 110 TEST_F(WindowEventDispatcherTest, OnHostMouseEvent) { | 110 TEST_P(WindowEventDispatcherTest, OnHostMouseEvent) { |
| 111 // Create two non-overlapping windows so we don't have to worry about which | 111 // Create two non-overlapping windows so we don't have to worry about which |
| 112 // is on top. | 112 // is on top. |
| 113 std::unique_ptr<NonClientDelegate> delegate1(new NonClientDelegate()); | 113 std::unique_ptr<NonClientDelegate> delegate1(new NonClientDelegate()); |
| 114 std::unique_ptr<NonClientDelegate> delegate2(new NonClientDelegate()); | 114 std::unique_ptr<NonClientDelegate> delegate2(new NonClientDelegate()); |
| 115 const int kWindowWidth = 123; | 115 const int kWindowWidth = 123; |
| 116 const int kWindowHeight = 45; | 116 const int kWindowHeight = 45; |
| 117 gfx::Rect bounds1(100, 200, kWindowWidth, kWindowHeight); | 117 gfx::Rect bounds1(100, 200, kWindowWidth, kWindowHeight); |
| 118 gfx::Rect bounds2(300, 400, kWindowWidth, kWindowHeight); | 118 gfx::Rect bounds2(300, 400, kWindowWidth, kWindowHeight); |
| 119 std::unique_ptr<aura::Window> window1(CreateTestWindowWithDelegate( | 119 std::unique_ptr<aura::Window> window1(CreateTestWindowWithDelegate( |
| 120 delegate1.get(), -1234, bounds1, root_window())); | 120 delegate1.get(), -1234, bounds1, root_window())); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 135 EXPECT_EQ(gfx::Point(1, 1), delegate1->non_client_location()); | 135 EXPECT_EQ(gfx::Point(1, 1), delegate1->non_client_location()); |
| 136 // Mouse event was received by target window. | 136 // Mouse event was received by target window. |
| 137 EXPECT_EQ(1, delegate1->mouse_event_count()); | 137 EXPECT_EQ(1, delegate1->mouse_event_count()); |
| 138 EXPECT_EQ(0, delegate2->mouse_event_count()); | 138 EXPECT_EQ(0, delegate2->mouse_event_count()); |
| 139 // Event was in local coordinates. | 139 // Event was in local coordinates. |
| 140 EXPECT_EQ(gfx::Point(1, 1), delegate1->mouse_event_location()); | 140 EXPECT_EQ(gfx::Point(1, 1), delegate1->mouse_event_location()); |
| 141 // Non-client flag was set. | 141 // Non-client flag was set. |
| 142 EXPECT_TRUE(delegate1->mouse_event_flags() & ui::EF_IS_NON_CLIENT); | 142 EXPECT_TRUE(delegate1->mouse_event_flags() & ui::EF_IS_NON_CLIENT); |
| 143 } | 143 } |
| 144 | 144 |
| 145 TEST_F(WindowEventDispatcherTest, RepostEvent) { | 145 TEST_P(WindowEventDispatcherTest, RepostEvent) { |
| 146 // Test RepostEvent in RootWindow. It only works for Mouse Press and touch | 146 // Test RepostEvent in RootWindow. It only works for Mouse Press and touch |
| 147 // press. | 147 // press. |
| 148 EXPECT_FALSE(Env::GetInstance()->IsMouseButtonDown()); | 148 EXPECT_FALSE(Env::GetInstance()->IsMouseButtonDown()); |
| 149 gfx::Point point(10, 10); | 149 gfx::Point point(10, 10); |
| 150 ui::MouseEvent event(ui::ET_MOUSE_PRESSED, point, point, | 150 ui::MouseEvent event(ui::ET_MOUSE_PRESSED, point, point, |
| 151 ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, | 151 ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, |
| 152 ui::EF_LEFT_MOUSE_BUTTON); | 152 ui::EF_LEFT_MOUSE_BUTTON); |
| 153 host()->dispatcher()->RepostEvent(&event); | 153 host()->dispatcher()->RepostEvent(&event); |
| 154 RunAllPendingInMessageLoop(); | 154 RunAllPendingInMessageLoop(); |
| 155 EXPECT_TRUE(Env::GetInstance()->IsMouseButtonDown()); | 155 EXPECT_TRUE(Env::GetInstance()->IsMouseButtonDown()); |
| 156 | 156 |
| 157 ui::TouchEvent touch_pressed_event( | 157 ui::TouchEvent touch_pressed_event( |
| 158 ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 0, ui::EventTimeForNow()); | 158 ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 0, ui::EventTimeForNow()); |
| 159 host()->dispatcher()->RepostEvent(&touch_pressed_event); | 159 host()->dispatcher()->RepostEvent(&touch_pressed_event); |
| 160 RunAllPendingInMessageLoop(); | 160 RunAllPendingInMessageLoop(); |
| 161 EXPECT_TRUE(Env::GetInstance()->is_touch_down()); | 161 EXPECT_TRUE(Env::GetInstance()->is_touch_down()); |
| 162 } | 162 } |
| 163 | 163 |
| 164 // Check that we correctly track the state of the mouse buttons in response to | 164 // Check that we correctly track the state of the mouse buttons in response to |
| 165 // button press and release events. | 165 // button press and release events. |
| 166 TEST_F(WindowEventDispatcherTest, MouseButtonState) { | 166 TEST_P(WindowEventDispatcherTest, MouseButtonState) { |
| 167 EXPECT_FALSE(Env::GetInstance()->IsMouseButtonDown()); | 167 EXPECT_FALSE(Env::GetInstance()->IsMouseButtonDown()); |
| 168 | 168 |
| 169 gfx::Point location; | 169 gfx::Point location; |
| 170 std::unique_ptr<ui::MouseEvent> event; | 170 std::unique_ptr<ui::MouseEvent> event; |
| 171 | 171 |
| 172 // Press the left button. | 172 // Press the left button. |
| 173 event.reset(new ui::MouseEvent( | 173 event.reset(new ui::MouseEvent( |
| 174 ui::ET_MOUSE_PRESSED, location, location, ui::EventTimeForNow(), | 174 ui::ET_MOUSE_PRESSED, location, location, ui::EventTimeForNow(), |
| 175 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 175 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 176 DispatchEventUsingWindowDispatcher(event.get()); | 176 DispatchEventUsingWindowDispatcher(event.get()); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 199 EXPECT_FALSE(Env::GetInstance()->IsMouseButtonDown()); | 199 EXPECT_FALSE(Env::GetInstance()->IsMouseButtonDown()); |
| 200 | 200 |
| 201 // Press the middle button. | 201 // Press the middle button. |
| 202 event.reset(new ui::MouseEvent( | 202 event.reset(new ui::MouseEvent( |
| 203 ui::ET_MOUSE_PRESSED, location, location, ui::EventTimeForNow(), | 203 ui::ET_MOUSE_PRESSED, location, location, ui::EventTimeForNow(), |
| 204 ui::EF_MIDDLE_MOUSE_BUTTON, ui::EF_MIDDLE_MOUSE_BUTTON)); | 204 ui::EF_MIDDLE_MOUSE_BUTTON, ui::EF_MIDDLE_MOUSE_BUTTON)); |
| 205 DispatchEventUsingWindowDispatcher(event.get()); | 205 DispatchEventUsingWindowDispatcher(event.get()); |
| 206 EXPECT_TRUE(Env::GetInstance()->IsMouseButtonDown()); | 206 EXPECT_TRUE(Env::GetInstance()->IsMouseButtonDown()); |
| 207 } | 207 } |
| 208 | 208 |
| 209 TEST_F(WindowEventDispatcherTest, TranslatedEvent) { | 209 TEST_P(WindowEventDispatcherTest, TranslatedEvent) { |
| 210 std::unique_ptr<Window> w1(test::CreateTestWindowWithDelegate( | 210 std::unique_ptr<Window> w1(test::CreateTestWindowWithDelegate( |
| 211 NULL, 1, gfx::Rect(50, 50, 100, 100), root_window())); | 211 NULL, 1, gfx::Rect(50, 50, 100, 100), root_window())); |
| 212 | 212 |
| 213 gfx::Point origin(100, 100); | 213 gfx::Point origin(100, 100); |
| 214 ui::MouseEvent root(ui::ET_MOUSE_PRESSED, origin, origin, | 214 ui::MouseEvent root(ui::ET_MOUSE_PRESSED, origin, origin, |
| 215 ui::EventTimeForNow(), 0, 0); | 215 ui::EventTimeForNow(), 0, 0); |
| 216 | 216 |
| 217 EXPECT_EQ("100,100", root.location().ToString()); | 217 EXPECT_EQ("100,100", root.location().ToString()); |
| 218 EXPECT_EQ("100,100", root.root_location().ToString()); | 218 EXPECT_EQ("100,100", root.root_location().ToString()); |
| 219 | 219 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 ui::EventTarget* GetToplevelEventTarget() override { return NULL; } | 275 ui::EventTarget* GetToplevelEventTarget() override { return NULL; } |
| 276 | 276 |
| 277 Window* root_window_; | 277 Window* root_window_; |
| 278 bool lock_; | 278 bool lock_; |
| 279 | 279 |
| 280 DISALLOW_COPY_AND_ASSIGN(TestEventClient); | 280 DISALLOW_COPY_AND_ASSIGN(TestEventClient); |
| 281 }; | 281 }; |
| 282 | 282 |
| 283 } // namespace | 283 } // namespace |
| 284 | 284 |
| 285 TEST_F(WindowEventDispatcherTest, CanProcessEventsWithinSubtree) { | 285 TEST_P(WindowEventDispatcherTest, CanProcessEventsWithinSubtree) { |
| 286 TestEventClient client(root_window()); | 286 TestEventClient client(root_window()); |
| 287 test::TestWindowDelegate d; | 287 test::TestWindowDelegate d; |
| 288 | 288 |
| 289 ui::test::TestEventHandler nonlock_ef; | 289 ui::test::TestEventHandler nonlock_ef; |
| 290 ui::test::TestEventHandler lock_ef; | 290 ui::test::TestEventHandler lock_ef; |
| 291 client.GetNonLockWindow()->AddPreTargetHandler(&nonlock_ef); | 291 client.GetNonLockWindow()->AddPreTargetHandler(&nonlock_ef); |
| 292 client.GetLockWindow()->AddPreTargetHandler(&lock_ef); | 292 client.GetLockWindow()->AddPreTargetHandler(&lock_ef); |
| 293 | 293 |
| 294 Window* w1 = test::CreateTestWindowWithBounds(gfx::Rect(10, 10, 20, 20), | 294 Window* w1 = test::CreateTestWindowWithBounds(gfx::Rect(10, 10, 20, 20), |
| 295 client.GetNonLockWindow()); | 295 client.GetNonLockWindow()); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 ui::test::EventGenerator generator3(root_window(), w3.get()); | 330 ui::test::EventGenerator generator3(root_window(), w3.get()); |
| 331 generator3.PressLeftButton(); | 331 generator3.PressLeftButton(); |
| 332 EXPECT_EQ(1, lock_ef.num_mouse_events()); | 332 EXPECT_EQ(1, lock_ef.num_mouse_events()); |
| 333 } | 333 } |
| 334 | 334 |
| 335 // Prevent w3 from being deleted by the hierarchy since its delegate is owned | 335 // Prevent w3 from being deleted by the hierarchy since its delegate is owned |
| 336 // by this scope. | 336 // by this scope. |
| 337 w3->parent()->RemoveChild(w3.get()); | 337 w3->parent()->RemoveChild(w3.get()); |
| 338 } | 338 } |
| 339 | 339 |
| 340 TEST_F(WindowEventDispatcherTest, DontIgnoreUnknownKeys) { | 340 TEST_P(WindowEventDispatcherTest, DontIgnoreUnknownKeys) { |
| 341 ConsumeKeyHandler handler; | 341 ConsumeKeyHandler handler; |
| 342 root_window()->AddPreTargetHandler(&handler); | 342 root_window()->AddPreTargetHandler(&handler); |
| 343 | 343 |
| 344 ui::KeyEvent unknown_event(ui::ET_KEY_PRESSED, ui::VKEY_UNKNOWN, ui::EF_NONE); | 344 ui::KeyEvent unknown_event(ui::ET_KEY_PRESSED, ui::VKEY_UNKNOWN, ui::EF_NONE); |
| 345 DispatchEventUsingWindowDispatcher(&unknown_event); | 345 DispatchEventUsingWindowDispatcher(&unknown_event); |
| 346 EXPECT_TRUE(unknown_event.handled()); | 346 EXPECT_TRUE(unknown_event.handled()); |
| 347 EXPECT_EQ(1, handler.num_key_events()); | 347 EXPECT_EQ(1, handler.num_key_events()); |
| 348 | 348 |
| 349 handler.Reset(); | 349 handler.Reset(); |
| 350 ui::KeyEvent known_event(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE); | 350 ui::KeyEvent known_event(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 362 handler.Reset(); | 362 handler.Reset(); |
| 363 ui::KeyEvent unknown_key_with_char_event(ui::ET_KEY_PRESSED, ui::VKEY_UNKNOWN, | 363 ui::KeyEvent unknown_key_with_char_event(ui::ET_KEY_PRESSED, ui::VKEY_UNKNOWN, |
| 364 ui::EF_NONE); | 364 ui::EF_NONE); |
| 365 unknown_key_with_char_event.set_character(0x00e4 /* "ä" */); | 365 unknown_key_with_char_event.set_character(0x00e4 /* "ä" */); |
| 366 DispatchEventUsingWindowDispatcher(&unknown_key_with_char_event); | 366 DispatchEventUsingWindowDispatcher(&unknown_key_with_char_event); |
| 367 EXPECT_TRUE(unknown_key_with_char_event.handled()); | 367 EXPECT_TRUE(unknown_key_with_char_event.handled()); |
| 368 EXPECT_EQ(1, handler.num_key_events()); | 368 EXPECT_EQ(1, handler.num_key_events()); |
| 369 root_window()->RemovePreTargetHandler(&handler); | 369 root_window()->RemovePreTargetHandler(&handler); |
| 370 } | 370 } |
| 371 | 371 |
| 372 TEST_F(WindowEventDispatcherTest, NoDelegateWindowReceivesKeyEvents) { | 372 TEST_P(WindowEventDispatcherTest, NoDelegateWindowReceivesKeyEvents) { |
| 373 std::unique_ptr<Window> w1(CreateNormalWindow(1, root_window(), NULL)); | 373 std::unique_ptr<Window> w1(CreateNormalWindow(1, root_window(), NULL)); |
| 374 w1->Show(); | 374 w1->Show(); |
| 375 w1->Focus(); | 375 w1->Focus(); |
| 376 | 376 |
| 377 ui::test::TestEventHandler handler; | 377 ui::test::TestEventHandler handler; |
| 378 w1->AddPreTargetHandler(&handler); | 378 w1->AddPreTargetHandler(&handler); |
| 379 ui::KeyEvent key_press(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE); | 379 ui::KeyEvent key_press(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE); |
| 380 DispatchEventUsingWindowDispatcher(&key_press); | 380 DispatchEventUsingWindowDispatcher(&key_press); |
| 381 EXPECT_TRUE(key_press.handled()); | 381 EXPECT_TRUE(key_press.handled()); |
| 382 EXPECT_EQ(1, handler.num_key_events()); | 382 EXPECT_EQ(1, handler.num_key_events()); |
| 383 | 383 |
| 384 w1->RemovePreTargetHandler(&handler); | 384 w1->RemovePreTargetHandler(&handler); |
| 385 } | 385 } |
| 386 | 386 |
| 387 // Tests that touch-events that are beyond the bounds of the root-window do get | 387 // Tests that touch-events that are beyond the bounds of the root-window do get |
| 388 // propagated to the event filters correctly with the root as the target. | 388 // propagated to the event filters correctly with the root as the target. |
| 389 TEST_F(WindowEventDispatcherTest, TouchEventsOutsideBounds) { | 389 TEST_P(WindowEventDispatcherTest, TouchEventsOutsideBounds) { |
| 390 ui::test::TestEventHandler handler; | 390 ui::test::TestEventHandler handler; |
| 391 root_window()->AddPreTargetHandler(&handler); | 391 root_window()->AddPreTargetHandler(&handler); |
| 392 | 392 |
| 393 gfx::Point position = root_window()->bounds().origin(); | 393 gfx::Point position = root_window()->bounds().origin(); |
| 394 position.Offset(-10, -10); | 394 position.Offset(-10, -10); |
| 395 ui::TouchEvent press( | 395 ui::TouchEvent press( |
| 396 ui::ET_TOUCH_PRESSED, position, 0, ui::EventTimeForNow()); | 396 ui::ET_TOUCH_PRESSED, position, 0, ui::EventTimeForNow()); |
| 397 DispatchEventUsingWindowDispatcher(&press); | 397 DispatchEventUsingWindowDispatcher(&press); |
| 398 EXPECT_EQ(1, handler.num_touch_events()); | 398 EXPECT_EQ(1, handler.num_touch_events()); |
| 399 | 399 |
| 400 position = root_window()->bounds().origin(); | 400 position = root_window()->bounds().origin(); |
| 401 position.Offset(root_window()->bounds().width() + 10, | 401 position.Offset(root_window()->bounds().width() + 10, |
| 402 root_window()->bounds().height() + 10); | 402 root_window()->bounds().height() + 10); |
| 403 ui::TouchEvent release( | 403 ui::TouchEvent release( |
| 404 ui::ET_TOUCH_RELEASED, position, 0, ui::EventTimeForNow()); | 404 ui::ET_TOUCH_RELEASED, position, 0, ui::EventTimeForNow()); |
| 405 DispatchEventUsingWindowDispatcher(&release); | 405 DispatchEventUsingWindowDispatcher(&release); |
| 406 EXPECT_EQ(2, handler.num_touch_events()); | 406 EXPECT_EQ(2, handler.num_touch_events()); |
| 407 root_window()->RemovePreTargetHandler(&handler); | 407 root_window()->RemovePreTargetHandler(&handler); |
| 408 } | 408 } |
| 409 | 409 |
| 410 // Tests that scroll events are dispatched correctly. | 410 // Tests that scroll events are dispatched correctly. |
| 411 TEST_F(WindowEventDispatcherTest, ScrollEventDispatch) { | 411 TEST_P(WindowEventDispatcherTest, ScrollEventDispatch) { |
| 412 base::TimeTicks now = ui::EventTimeForNow(); | 412 base::TimeTicks now = ui::EventTimeForNow(); |
| 413 ui::test::TestEventHandler handler; | 413 ui::test::TestEventHandler handler; |
| 414 root_window()->AddPreTargetHandler(&handler); | 414 root_window()->AddPreTargetHandler(&handler); |
| 415 | 415 |
| 416 test::TestWindowDelegate delegate; | 416 test::TestWindowDelegate delegate; |
| 417 std::unique_ptr<Window> w1(CreateNormalWindow(1, root_window(), &delegate)); | 417 std::unique_ptr<Window> w1(CreateNormalWindow(1, root_window(), &delegate)); |
| 418 w1->SetBounds(gfx::Rect(20, 20, 40, 40)); | 418 w1->SetBounds(gfx::Rect(20, 20, 40, 40)); |
| 419 | 419 |
| 420 // A scroll event on the root-window itself is dispatched. | 420 // A scroll event on the root-window itself is dispatched. |
| 421 ui::ScrollEvent scroll1(ui::ET_SCROLL, | 421 ui::ScrollEvent scroll1(ui::ET_SCROLL, |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 621 | 621 |
| 622 #if defined(OS_WIN) && defined(ARCH_CPU_X86) | 622 #if defined(OS_WIN) && defined(ARCH_CPU_X86) |
| 623 #define MAYBE(x) DISABLED_##x | 623 #define MAYBE(x) DISABLED_##x |
| 624 #else | 624 #else |
| 625 #define MAYBE(x) x | 625 #define MAYBE(x) x |
| 626 #endif | 626 #endif |
| 627 | 627 |
| 628 // Verifies a repost mouse event targets the window with capture (if there is | 628 // Verifies a repost mouse event targets the window with capture (if there is |
| 629 // one). | 629 // one). |
| 630 // Flaky on 32-bit Windows bots. http://crbug.com/388290 | 630 // Flaky on 32-bit Windows bots. http://crbug.com/388290 |
| 631 TEST_F(WindowEventDispatcherTest, MAYBE(RepostTargetsCaptureWindow)) { | 631 TEST_P(WindowEventDispatcherTest, MAYBE(RepostTargetsCaptureWindow)) { |
| 632 // Set capture on |window| generate a mouse event (that is reposted) and not | 632 // Set capture on |window| generate a mouse event (that is reposted) and not |
| 633 // over |window| and verify |window| gets it (|window| gets it because it has | 633 // over |window| and verify |window| gets it (|window| gets it because it has |
| 634 // capture). | 634 // capture). |
| 635 EXPECT_FALSE(Env::GetInstance()->IsMouseButtonDown()); | 635 EXPECT_FALSE(Env::GetInstance()->IsMouseButtonDown()); |
| 636 EventFilterRecorder recorder; | 636 EventFilterRecorder recorder; |
| 637 std::unique_ptr<Window> window(CreateNormalWindow(1, root_window(), NULL)); | 637 std::unique_ptr<Window> window(CreateNormalWindow(1, root_window(), NULL)); |
| 638 window->SetBounds(gfx::Rect(20, 20, 40, 30)); | 638 window->SetBounds(gfx::Rect(20, 20, 40, 30)); |
| 639 window->AddPreTargetHandler(&recorder); | 639 window->AddPreTargetHandler(&recorder); |
| 640 window->SetCapture(); | 640 window->SetCapture(); |
| 641 const ui::MouseEvent press_event( | 641 const ui::MouseEvent press_event( |
| 642 ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), ui::EventTimeForNow(), | 642 ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), ui::EventTimeForNow(), |
| 643 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); | 643 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); |
| 644 host()->dispatcher()->RepostEvent(&press_event); | 644 host()->dispatcher()->RepostEvent(&press_event); |
| 645 RunAllPendingInMessageLoop(); // Necessitated by RepostEvent(). | 645 RunAllPendingInMessageLoop(); // Necessitated by RepostEvent(). |
| 646 // Mouse moves/enters may be generated. We only care about a pressed. | 646 // Mouse moves/enters may be generated. We only care about a pressed. |
| 647 EXPECT_TRUE(EventTypesToString(recorder.events()).find("MOUSE_PRESSED") != | 647 EXPECT_TRUE(EventTypesToString(recorder.events()).find("MOUSE_PRESSED") != |
| 648 std::string::npos) << EventTypesToString(recorder.events()); | 648 std::string::npos) << EventTypesToString(recorder.events()); |
| 649 } | 649 } |
| 650 | 650 |
| 651 TEST_F(WindowEventDispatcherTest, MouseMovesHeld) { | 651 TEST_P(WindowEventDispatcherTest, MouseMovesHeld) { |
| 652 EventFilterRecorder recorder; | 652 EventFilterRecorder recorder; |
| 653 root_window()->AddPreTargetHandler(&recorder); | 653 root_window()->AddPreTargetHandler(&recorder); |
| 654 | 654 |
| 655 test::TestWindowDelegate delegate; | 655 test::TestWindowDelegate delegate; |
| 656 std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 656 std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 657 &delegate, 1, gfx::Rect(0, 0, 100, 100), root_window())); | 657 &delegate, 1, gfx::Rect(0, 0, 100, 100), root_window())); |
| 658 | 658 |
| 659 ui::MouseEvent mouse_move_event(ui::ET_MOUSE_MOVED, gfx::Point(0, 0), | 659 ui::MouseEvent mouse_move_event(ui::ET_MOUSE_MOVED, gfx::Point(0, 0), |
| 660 gfx::Point(0, 0), ui::EventTimeForNow(), 0, | 660 gfx::Point(0, 0), ui::EventTimeForNow(), 0, |
| 661 0); | 661 0); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 768 RunAllPendingInMessageLoop(); | 768 RunAllPendingInMessageLoop(); |
| 769 EXPECT_TRUE(recorder.events().empty()); | 769 EXPECT_TRUE(recorder.events().empty()); |
| 770 host()->dispatcher()->ReleasePointerMoves(); | 770 host()->dispatcher()->ReleasePointerMoves(); |
| 771 RunAllPendingInMessageLoop(); | 771 RunAllPendingInMessageLoop(); |
| 772 EXPECT_EQ("MOUSE_MOVED", EventTypesToString(recorder.events())); | 772 EXPECT_EQ("MOUSE_MOVED", EventTypesToString(recorder.events())); |
| 773 EXPECT_EQ(gfx::Point(13, 13), recorder.mouse_location(0)); | 773 EXPECT_EQ(gfx::Point(13, 13), recorder.mouse_location(0)); |
| 774 recorder.Reset(); | 774 recorder.Reset(); |
| 775 root_window()->RemovePreTargetHandler(&recorder); | 775 root_window()->RemovePreTargetHandler(&recorder); |
| 776 } | 776 } |
| 777 | 777 |
| 778 TEST_F(WindowEventDispatcherTest, TouchMovesHeld) { | 778 TEST_P(WindowEventDispatcherTest, TouchMovesHeld) { |
| 779 EventFilterRecorder recorder; | 779 EventFilterRecorder recorder; |
| 780 root_window()->AddPreTargetHandler(&recorder); | 780 root_window()->AddPreTargetHandler(&recorder); |
| 781 | 781 |
| 782 test::TestWindowDelegate delegate; | 782 test::TestWindowDelegate delegate; |
| 783 std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 783 std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 784 &delegate, 1, gfx::Rect(50, 50, 100, 100), root_window())); | 784 &delegate, 1, gfx::Rect(50, 50, 100, 100), root_window())); |
| 785 | 785 |
| 786 // Starting the touch and throwing out the first few events, since the system | 786 // Starting the touch and throwing out the first few events, since the system |
| 787 // is going to generate synthetic mouse events that are not relevant to the | 787 // is going to generate synthetic mouse events that are not relevant to the |
| 788 // test. | 788 // test. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 827 EventTypesToString(recorder.events())); | 827 EventTypesToString(recorder.events())); |
| 828 recorder.Reset(); | 828 recorder.Reset(); |
| 829 host()->dispatcher()->ReleasePointerMoves(); | 829 host()->dispatcher()->ReleasePointerMoves(); |
| 830 RunAllPendingInMessageLoop(); | 830 RunAllPendingInMessageLoop(); |
| 831 EXPECT_TRUE(recorder.events().empty()); | 831 EXPECT_TRUE(recorder.events().empty()); |
| 832 root_window()->RemovePreTargetHandler(&recorder); | 832 root_window()->RemovePreTargetHandler(&recorder); |
| 833 } | 833 } |
| 834 | 834 |
| 835 // Tests that mouse move event has a right location | 835 // Tests that mouse move event has a right location |
| 836 // when there isn't the target window | 836 // when there isn't the target window |
| 837 TEST_F(WindowEventDispatcherTest, MouseEventWithoutTargetWindow) { | 837 TEST_P(WindowEventDispatcherTest, MouseEventWithoutTargetWindow) { |
| 838 EventFilterRecorder recorder_first; | 838 EventFilterRecorder recorder_first; |
| 839 EventFilterRecorder recorder_second; | 839 EventFilterRecorder recorder_second; |
| 840 | 840 |
| 841 test::TestWindowDelegate delegate; | 841 test::TestWindowDelegate delegate; |
| 842 std::unique_ptr<aura::Window> window_first(CreateTestWindowWithDelegate( | 842 std::unique_ptr<aura::Window> window_first(CreateTestWindowWithDelegate( |
| 843 &delegate, 1, gfx::Rect(20, 10, 10, 20), root_window())); | 843 &delegate, 1, gfx::Rect(20, 10, 10, 20), root_window())); |
| 844 window_first->Show(); | 844 window_first->Show(); |
| 845 window_first->AddPreTargetHandler(&recorder_first); | 845 window_first->AddPreTargetHandler(&recorder_first); |
| 846 | 846 |
| 847 std::unique_ptr<aura::Window> window_second(CreateTestWindowWithDelegate( | 847 std::unique_ptr<aura::Window> window_second(CreateTestWindowWithDelegate( |
| 848 &delegate, 2, gfx::Rect(20, 30, 10, 20), root_window())); | 848 &delegate, 2, gfx::Rect(20, 30, 10, 20), root_window())); |
| 849 window_second->Show(); | 849 window_second->Show(); |
| 850 window_second->AddPreTargetHandler(&recorder_second); | 850 window_second->AddPreTargetHandler(&recorder_second); |
| 851 | 851 |
| 852 const gfx::Point event_location(22, 33); | 852 const gfx::Point event_location(22, 33); |
| 853 ui::MouseEvent mouse(ui::ET_MOUSE_MOVED, event_location, event_location, | 853 ui::MouseEvent mouse(ui::ET_MOUSE_MOVED, event_location, event_location, |
| 854 ui::EventTimeForNow(), 0, 0); | 854 ui::EventTimeForNow(), 0, 0); |
| 855 DispatchEventUsingWindowDispatcher(&mouse); | 855 DispatchEventUsingWindowDispatcher(&mouse); |
| 856 | 856 |
| 857 EXPECT_TRUE(recorder_first.events().empty()); | 857 EXPECT_TRUE(recorder_first.events().empty()); |
| 858 EXPECT_EQ("MOUSE_ENTERED MOUSE_MOVED", | 858 EXPECT_EQ("MOUSE_ENTERED MOUSE_MOVED", |
| 859 EventTypesToString(recorder_second.events())); | 859 EventTypesToString(recorder_second.events())); |
| 860 ASSERT_EQ(2u, recorder_second.mouse_locations().size()); | 860 ASSERT_EQ(2u, recorder_second.mouse_locations().size()); |
| 861 EXPECT_EQ(gfx::Point(2, 3).ToString(), | 861 EXPECT_EQ(gfx::Point(2, 3).ToString(), |
| 862 recorder_second.mouse_locations()[0].ToString()); | 862 recorder_second.mouse_locations()[0].ToString()); |
| 863 } | 863 } |
| 864 | 864 |
| 865 // Tests that a mouse exit is dispatched to the last mouse location when | 865 // Tests that a mouse exit is dispatched to the last mouse location when |
| 866 // the window is hiddden. | 866 // the window is hiddden. |
| 867 TEST_F(WindowEventDispatcherTest, DispatchMouseExitWhenHidingWindow) { | 867 TEST_P(WindowEventDispatcherTest, DispatchMouseExitWhenHidingWindow) { |
| 868 EventFilterRecorder recorder; | 868 EventFilterRecorder recorder; |
| 869 | 869 |
| 870 test::TestWindowDelegate delegate; | 870 test::TestWindowDelegate delegate; |
| 871 std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 871 std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 872 &delegate, 1, gfx::Rect(10, 10, 50, 50), root_window())); | 872 &delegate, 1, gfx::Rect(10, 10, 50, 50), root_window())); |
| 873 window->Show(); | 873 window->Show(); |
| 874 window->AddPreTargetHandler(&recorder); | 874 window->AddPreTargetHandler(&recorder); |
| 875 | 875 |
| 876 // Dispatch a mouse move event into the window. | 876 // Dispatch a mouse move event into the window. |
| 877 const gfx::Point event_location(22, 33); | 877 const gfx::Point event_location(22, 33); |
| 878 ui::MouseEvent mouse(ui::ET_MOUSE_MOVED, event_location, event_location, | 878 ui::MouseEvent mouse(ui::ET_MOUSE_MOVED, event_location, event_location, |
| 879 ui::EventTimeForNow(), 0, 0); | 879 ui::EventTimeForNow(), 0, 0); |
| 880 DispatchEventUsingWindowDispatcher(&mouse); | 880 DispatchEventUsingWindowDispatcher(&mouse); |
| 881 EXPECT_FALSE(recorder.events().empty()); | 881 EXPECT_FALSE(recorder.events().empty()); |
| 882 recorder.Reset(); | 882 recorder.Reset(); |
| 883 | 883 |
| 884 // Hide the window and verify a mouse exit event's location. | 884 // Hide the window and verify a mouse exit event's location. |
| 885 window->Hide(); | 885 window->Hide(); |
| 886 EXPECT_FALSE(recorder.events().empty()); | 886 EXPECT_FALSE(recorder.events().empty()); |
| 887 EXPECT_EQ("MOUSE_EXITED", EventTypesToString(recorder.events())); | 887 EXPECT_EQ("MOUSE_EXITED", EventTypesToString(recorder.events())); |
| 888 ASSERT_EQ(1u, recorder.mouse_locations().size()); | 888 ASSERT_EQ(1u, recorder.mouse_locations().size()); |
| 889 EXPECT_EQ(gfx::Point(12, 23).ToString(), | 889 EXPECT_EQ(gfx::Point(12, 23).ToString(), |
| 890 recorder.mouse_locations()[0].ToString()); | 890 recorder.mouse_locations()[0].ToString()); |
| 891 } | 891 } |
| 892 | 892 |
| 893 // Verifies that a direct call to ProcessedTouchEvent() does not cause a crash. | 893 // Verifies that a direct call to ProcessedTouchEvent() does not cause a crash. |
| 894 TEST_F(WindowEventDispatcherTest, CallToProcessedTouchEvent) { | 894 TEST_P(WindowEventDispatcherTest, CallToProcessedTouchEvent) { |
| 895 test::TestWindowDelegate delegate; | 895 test::TestWindowDelegate delegate; |
| 896 std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 896 std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 897 &delegate, 1, gfx::Rect(50, 50, 100, 100), root_window())); | 897 &delegate, 1, gfx::Rect(50, 50, 100, 100), root_window())); |
| 898 | 898 |
| 899 host()->dispatcher()->ProcessedTouchEvent(0, window.get(), ui::ER_UNHANDLED); | 899 host()->dispatcher()->ProcessedTouchEvent(0, window.get(), ui::ER_UNHANDLED); |
| 900 } | 900 } |
| 901 | 901 |
| 902 // This event handler requests the dispatcher to start holding pointer-move | 902 // This event handler requests the dispatcher to start holding pointer-move |
| 903 // events when it receives the first scroll-update gesture. | 903 // events when it receives the first scroll-update gesture. |
| 904 class HoldPointerOnScrollHandler : public ui::test::TestEventHandler { | 904 class HoldPointerOnScrollHandler : public ui::test::TestEventHandler { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 925 | 925 |
| 926 WindowEventDispatcher* dispatcher_; | 926 WindowEventDispatcher* dispatcher_; |
| 927 EventFilterRecorder* filter_; | 927 EventFilterRecorder* filter_; |
| 928 bool holding_moves_; | 928 bool holding_moves_; |
| 929 | 929 |
| 930 DISALLOW_COPY_AND_ASSIGN(HoldPointerOnScrollHandler); | 930 DISALLOW_COPY_AND_ASSIGN(HoldPointerOnScrollHandler); |
| 931 }; | 931 }; |
| 932 | 932 |
| 933 // Tests that touch-move events don't contribute to an in-progress scroll | 933 // Tests that touch-move events don't contribute to an in-progress scroll |
| 934 // gesture if touch-move events are being held by the dispatcher. | 934 // gesture if touch-move events are being held by the dispatcher. |
| 935 TEST_F(WindowEventDispatcherTest, TouchMovesHeldOnScroll) { | 935 TEST_P(WindowEventDispatcherTest, TouchMovesHeldOnScroll) { |
| 936 EventFilterRecorder recorder; | 936 EventFilterRecorder recorder; |
| 937 root_window()->AddPreTargetHandler(&recorder); | 937 root_window()->AddPreTargetHandler(&recorder); |
| 938 test::TestWindowDelegate delegate; | 938 test::TestWindowDelegate delegate; |
| 939 HoldPointerOnScrollHandler handler(host()->dispatcher(), &recorder); | 939 HoldPointerOnScrollHandler handler(host()->dispatcher(), &recorder); |
| 940 std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 940 std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 941 &delegate, 1, gfx::Rect(50, 50, 100, 100), root_window())); | 941 &delegate, 1, gfx::Rect(50, 50, 100, 100), root_window())); |
| 942 window->AddPreTargetHandler(&handler); | 942 window->AddPreTargetHandler(&handler); |
| 943 | 943 |
| 944 ui::test::EventGenerator generator(root_window()); | 944 ui::test::EventGenerator generator(root_window()); |
| 945 generator.GestureScrollSequence( | 945 generator.GestureScrollSequence( |
| (...skipping 13 matching lines...) Expand all Loading... |
| 959 ASSERT_EQ(2u, recorder.touch_locations().size()); | 959 ASSERT_EQ(2u, recorder.touch_locations().size()); |
| 960 EXPECT_EQ(gfx::Point(-40, 10).ToString(), | 960 EXPECT_EQ(gfx::Point(-40, 10).ToString(), |
| 961 recorder.touch_locations()[0].ToString()); | 961 recorder.touch_locations()[0].ToString()); |
| 962 EXPECT_EQ(gfx::Point(-40, 10).ToString(), | 962 EXPECT_EQ(gfx::Point(-40, 10).ToString(), |
| 963 recorder.touch_locations()[1].ToString()); | 963 recorder.touch_locations()[1].ToString()); |
| 964 root_window()->RemovePreTargetHandler(&recorder); | 964 root_window()->RemovePreTargetHandler(&recorder); |
| 965 } | 965 } |
| 966 | 966 |
| 967 // Tests that a 'held' touch-event does contribute to gesture event when it is | 967 // Tests that a 'held' touch-event does contribute to gesture event when it is |
| 968 // dispatched. | 968 // dispatched. |
| 969 TEST_F(WindowEventDispatcherTest, HeldTouchMoveContributesToGesture) { | 969 TEST_P(WindowEventDispatcherTest, HeldTouchMoveContributesToGesture) { |
| 970 EventFilterRecorder recorder; | 970 EventFilterRecorder recorder; |
| 971 root_window()->AddPreTargetHandler(&recorder); | 971 root_window()->AddPreTargetHandler(&recorder); |
| 972 | 972 |
| 973 const gfx::Point location(20, 20); | 973 const gfx::Point location(20, 20); |
| 974 ui::TouchEvent press( | 974 ui::TouchEvent press( |
| 975 ui::ET_TOUCH_PRESSED, location, 0, ui::EventTimeForNow()); | 975 ui::ET_TOUCH_PRESSED, location, 0, ui::EventTimeForNow()); |
| 976 DispatchEventUsingWindowDispatcher(&press); | 976 DispatchEventUsingWindowDispatcher(&press); |
| 977 EXPECT_TRUE(recorder.HasReceivedEvent(ui::ET_TOUCH_PRESSED)); | 977 EXPECT_TRUE(recorder.HasReceivedEvent(ui::ET_TOUCH_PRESSED)); |
| 978 recorder.Reset(); | 978 recorder.Reset(); |
| 979 | 979 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 993 RunAllPendingInMessageLoop(); | 993 RunAllPendingInMessageLoop(); |
| 994 EXPECT_TRUE(recorder.HasReceivedEvent(ui::ET_TOUCH_MOVED)); | 994 EXPECT_TRUE(recorder.HasReceivedEvent(ui::ET_TOUCH_MOVED)); |
| 995 EXPECT_TRUE(recorder.HasReceivedEvent(ui::ET_GESTURE_SCROLL_BEGIN)); | 995 EXPECT_TRUE(recorder.HasReceivedEvent(ui::ET_GESTURE_SCROLL_BEGIN)); |
| 996 EXPECT_TRUE(recorder.HasReceivedEvent(ui::ET_GESTURE_SCROLL_UPDATE)); | 996 EXPECT_TRUE(recorder.HasReceivedEvent(ui::ET_GESTURE_SCROLL_UPDATE)); |
| 997 | 997 |
| 998 root_window()->RemovePreTargetHandler(&recorder); | 998 root_window()->RemovePreTargetHandler(&recorder); |
| 999 } | 999 } |
| 1000 | 1000 |
| 1001 // Tests that synthetic mouse events are ignored when mouse | 1001 // Tests that synthetic mouse events are ignored when mouse |
| 1002 // events are disabled. | 1002 // events are disabled. |
| 1003 TEST_F(WindowEventDispatcherTest, DispatchSyntheticMouseEvents) { | 1003 TEST_P(WindowEventDispatcherTest, DispatchSyntheticMouseEvents) { |
| 1004 EventFilterRecorder recorder; | 1004 EventFilterRecorder recorder; |
| 1005 root_window()->AddPreTargetHandler(&recorder); | 1005 root_window()->AddPreTargetHandler(&recorder); |
| 1006 | 1006 |
| 1007 test::TestWindowDelegate delegate; | 1007 test::TestWindowDelegate delegate; |
| 1008 std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 1008 std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 1009 &delegate, 1234, gfx::Rect(5, 5, 100, 100), root_window())); | 1009 &delegate, 1234, gfx::Rect(5, 5, 100, 100), root_window())); |
| 1010 window->Show(); | 1010 window->Show(); |
| 1011 window->SetCapture(); | 1011 window->SetCapture(); |
| 1012 | 1012 |
| 1013 test::TestCursorClient cursor_client(root_window()); | 1013 test::TestCursorClient cursor_client(root_window()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1028 recorder.Reset(); | 1028 recorder.Reset(); |
| 1029 | 1029 |
| 1030 // Dispatch a synthetic mouse event when mouse events are disabled. | 1030 // Dispatch a synthetic mouse event when mouse events are disabled. |
| 1031 cursor_client.DisableMouseEvents(); | 1031 cursor_client.DisableMouseEvents(); |
| 1032 DispatchEventUsingWindowDispatcher(&mouse2); | 1032 DispatchEventUsingWindowDispatcher(&mouse2); |
| 1033 EXPECT_TRUE(recorder.events().empty()); | 1033 EXPECT_TRUE(recorder.events().empty()); |
| 1034 root_window()->RemovePreTargetHandler(&recorder); | 1034 root_window()->RemovePreTargetHandler(&recorder); |
| 1035 } | 1035 } |
| 1036 | 1036 |
| 1037 // Tests that a mouse-move event is not synthesized when a mouse-button is down. | 1037 // Tests that a mouse-move event is not synthesized when a mouse-button is down. |
| 1038 TEST_F(WindowEventDispatcherTest, DoNotSynthesizeWhileButtonDown) { | 1038 TEST_P(WindowEventDispatcherTest, DoNotSynthesizeWhileButtonDown) { |
| 1039 EventFilterRecorder recorder; | 1039 EventFilterRecorder recorder; |
| 1040 test::TestWindowDelegate delegate; | 1040 test::TestWindowDelegate delegate; |
| 1041 std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 1041 std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 1042 &delegate, 1234, gfx::Rect(5, 5, 100, 100), root_window())); | 1042 &delegate, 1234, gfx::Rect(5, 5, 100, 100), root_window())); |
| 1043 window->Show(); | 1043 window->Show(); |
| 1044 | 1044 |
| 1045 window->AddPreTargetHandler(&recorder); | 1045 window->AddPreTargetHandler(&recorder); |
| 1046 // Dispatch a non-synthetic mouse event when mouse events are enabled. | 1046 // Dispatch a non-synthetic mouse event when mouse events are enabled. |
| 1047 ui::MouseEvent mouse1(ui::ET_MOUSE_PRESSED, gfx::Point(10, 10), | 1047 ui::MouseEvent mouse1(ui::ET_MOUSE_PRESSED, gfx::Point(10, 10), |
| 1048 gfx::Point(10, 10), ui::EventTimeForNow(), | 1048 gfx::Point(10, 10), ui::EventTimeForNow(), |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1065 #if defined(OS_WIN) && defined(ARCH_CPU_X86) | 1065 #if defined(OS_WIN) && defined(ARCH_CPU_X86) |
| 1066 #define MAYBE(x) DISABLED_##x | 1066 #define MAYBE(x) DISABLED_##x |
| 1067 #else | 1067 #else |
| 1068 #define MAYBE(x) x | 1068 #define MAYBE(x) x |
| 1069 #endif | 1069 #endif |
| 1070 | 1070 |
| 1071 // Tests synthetic mouse events generated when window bounds changes such that | 1071 // Tests synthetic mouse events generated when window bounds changes such that |
| 1072 // the cursor previously outside the window becomes inside, or vice versa. | 1072 // the cursor previously outside the window becomes inside, or vice versa. |
| 1073 // Do not synthesize events if the window ignores events or is invisible. | 1073 // Do not synthesize events if the window ignores events or is invisible. |
| 1074 // Flaky on 32-bit Windows bots. http://crbug.com/388272 | 1074 // Flaky on 32-bit Windows bots. http://crbug.com/388272 |
| 1075 TEST_F(WindowEventDispatcherTest, | 1075 TEST_P(WindowEventDispatcherTest, |
| 1076 MAYBE(SynthesizeMouseEventsOnWindowBoundsChanged)) { | 1076 MAYBE(SynthesizeMouseEventsOnWindowBoundsChanged)) { |
| 1077 test::TestWindowDelegate delegate; | 1077 test::TestWindowDelegate delegate; |
| 1078 std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 1078 std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 1079 &delegate, 1234, gfx::Rect(5, 5, 100, 100), root_window())); | 1079 &delegate, 1234, gfx::Rect(5, 5, 100, 100), root_window())); |
| 1080 window->Show(); | 1080 window->Show(); |
| 1081 window->SetCapture(); | 1081 window->SetCapture(); |
| 1082 | 1082 |
| 1083 EventFilterRecorder recorder; | 1083 EventFilterRecorder recorder; |
| 1084 window->AddPreTargetHandler(&recorder); | 1084 window->AddPreTargetHandler(&recorder); |
| 1085 | 1085 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1119 | 1119 |
| 1120 // Update the window bounds so that cursor is outside the window. | 1120 // Update the window bounds so that cursor is outside the window. |
| 1121 // This should not trigger a synthetic event. | 1121 // This should not trigger a synthetic event. |
| 1122 window->SetBounds(bounds1); | 1122 window->SetBounds(bounds1); |
| 1123 RunAllPendingInMessageLoop(); | 1123 RunAllPendingInMessageLoop(); |
| 1124 EXPECT_TRUE(recorder.events().empty()); | 1124 EXPECT_TRUE(recorder.events().empty()); |
| 1125 } | 1125 } |
| 1126 | 1126 |
| 1127 // Tests that a mouse exit is dispatched to the last known cursor location | 1127 // Tests that a mouse exit is dispatched to the last known cursor location |
| 1128 // when the cursor becomes invisible. | 1128 // when the cursor becomes invisible. |
| 1129 TEST_F(WindowEventDispatcherTest, DispatchMouseExitWhenCursorHidden) { | 1129 TEST_P(WindowEventDispatcherTest, DispatchMouseExitWhenCursorHidden) { |
| 1130 EventFilterRecorder recorder; | 1130 EventFilterRecorder recorder; |
| 1131 root_window()->AddPreTargetHandler(&recorder); | 1131 root_window()->AddPreTargetHandler(&recorder); |
| 1132 | 1132 |
| 1133 test::TestWindowDelegate delegate; | 1133 test::TestWindowDelegate delegate; |
| 1134 gfx::Point window_origin(7, 18); | 1134 gfx::Point window_origin(7, 18); |
| 1135 std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 1135 std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 1136 &delegate, 1234, gfx::Rect(window_origin, gfx::Size(100, 100)), | 1136 &delegate, 1234, gfx::Rect(window_origin, gfx::Size(100, 100)), |
| 1137 root_window())); | 1137 root_window())); |
| 1138 window->Show(); | 1138 window->Show(); |
| 1139 | 1139 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1155 // (in the correct coordinate space). | 1155 // (in the correct coordinate space). |
| 1156 int translated_x = mouse_location.x() - window_origin.x(); | 1156 int translated_x = mouse_location.x() - window_origin.x(); |
| 1157 int translated_y = mouse_location.y() - window_origin.y(); | 1157 int translated_y = mouse_location.y() - window_origin.y(); |
| 1158 gfx::Point translated_point(translated_x, translated_y); | 1158 gfx::Point translated_point(translated_x, translated_y); |
| 1159 EXPECT_EQ(recorder.mouse_location(0).ToString(), translated_point.ToString()); | 1159 EXPECT_EQ(recorder.mouse_location(0).ToString(), translated_point.ToString()); |
| 1160 root_window()->RemovePreTargetHandler(&recorder); | 1160 root_window()->RemovePreTargetHandler(&recorder); |
| 1161 } | 1161 } |
| 1162 | 1162 |
| 1163 // Tests that a synthetic mouse exit is dispatched to the last known cursor | 1163 // Tests that a synthetic mouse exit is dispatched to the last known cursor |
| 1164 // location after mouse events are disabled on the cursor client. | 1164 // location after mouse events are disabled on the cursor client. |
| 1165 TEST_F(WindowEventDispatcherTest, | 1165 TEST_P(WindowEventDispatcherTest, |
| 1166 DispatchSyntheticMouseExitAfterMouseEventsDisabled) { | 1166 DispatchSyntheticMouseExitAfterMouseEventsDisabled) { |
| 1167 EventFilterRecorder recorder; | 1167 EventFilterRecorder recorder; |
| 1168 root_window()->AddPreTargetHandler(&recorder); | 1168 root_window()->AddPreTargetHandler(&recorder); |
| 1169 | 1169 |
| 1170 test::TestWindowDelegate delegate; | 1170 test::TestWindowDelegate delegate; |
| 1171 gfx::Point window_origin(7, 18); | 1171 gfx::Point window_origin(7, 18); |
| 1172 std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 1172 std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 1173 &delegate, 1234, gfx::Rect(window_origin, gfx::Size(100, 100)), | 1173 &delegate, 1234, gfx::Rect(window_origin, gfx::Size(100, 100)), |
| 1174 root_window())); | 1174 root_window())); |
| 1175 window->Show(); | 1175 window->Show(); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1262 got_event_ = true; | 1262 got_event_ = true; |
| 1263 } | 1263 } |
| 1264 | 1264 |
| 1265 Window* window_; | 1265 Window* window_; |
| 1266 bool delete_during_handle_; | 1266 bool delete_during_handle_; |
| 1267 bool got_event_; | 1267 bool got_event_; |
| 1268 | 1268 |
| 1269 DISALLOW_COPY_AND_ASSIGN(DeletingWindowDelegate); | 1269 DISALLOW_COPY_AND_ASSIGN(DeletingWindowDelegate); |
| 1270 }; | 1270 }; |
| 1271 | 1271 |
| 1272 TEST_F(WindowEventDispatcherTest, DeleteWindowDuringDispatch) { | 1272 TEST_P(WindowEventDispatcherTest, DeleteWindowDuringDispatch) { |
| 1273 // Verifies that we can delete a window during each phase of event handling. | 1273 // Verifies that we can delete a window during each phase of event handling. |
| 1274 // Deleting the window should not cause a crash, only prevent further | 1274 // Deleting the window should not cause a crash, only prevent further |
| 1275 // processing from occurring. | 1275 // processing from occurring. |
| 1276 std::unique_ptr<Window> w1(CreateNormalWindow(1, root_window(), NULL)); | 1276 std::unique_ptr<Window> w1(CreateNormalWindow(1, root_window(), NULL)); |
| 1277 DeletingWindowDelegate d11; | 1277 DeletingWindowDelegate d11; |
| 1278 Window* w11 = CreateNormalWindow(11, w1.get(), &d11); | 1278 Window* w11 = CreateNormalWindow(11, w1.get(), &d11); |
| 1279 WindowTracker tracker; | 1279 WindowTracker tracker; |
| 1280 DeletingEventFilter w1_filter; | 1280 DeletingEventFilter w1_filter; |
| 1281 w1->AddPreTargetHandler(&w1_filter); | 1281 w1->AddPreTargetHandler(&w1_filter); |
| 1282 client::GetFocusClient(w1.get())->FocusWindow(w11); | 1282 client::GetFocusClient(w1.get())->FocusWindow(w11); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1332 } | 1332 } |
| 1333 } | 1333 } |
| 1334 | 1334 |
| 1335 DISALLOW_COPY_AND_ASSIGN(DetachesParentOnTapDelegate); | 1335 DISALLOW_COPY_AND_ASSIGN(DetachesParentOnTapDelegate); |
| 1336 }; | 1336 }; |
| 1337 | 1337 |
| 1338 } // namespace | 1338 } // namespace |
| 1339 | 1339 |
| 1340 // Tests that the gesture recognizer is reset for all child windows when a | 1340 // Tests that the gesture recognizer is reset for all child windows when a |
| 1341 // window hides. No expectations, just checks that the test does not crash. | 1341 // window hides. No expectations, just checks that the test does not crash. |
| 1342 TEST_F(WindowEventDispatcherTest, | 1342 TEST_P(WindowEventDispatcherTest, |
| 1343 GestureRecognizerResetsTargetWhenParentHides) { | 1343 GestureRecognizerResetsTargetWhenParentHides) { |
| 1344 std::unique_ptr<Window> w1(CreateNormalWindow(1, root_window(), NULL)); | 1344 std::unique_ptr<Window> w1(CreateNormalWindow(1, root_window(), NULL)); |
| 1345 DetachesParentOnTapDelegate delegate; | 1345 DetachesParentOnTapDelegate delegate; |
| 1346 std::unique_ptr<Window> parent(CreateNormalWindow(22, w1.get(), NULL)); | 1346 std::unique_ptr<Window> parent(CreateNormalWindow(22, w1.get(), NULL)); |
| 1347 Window* child = CreateNormalWindow(11, parent.get(), &delegate); | 1347 Window* child = CreateNormalWindow(11, parent.get(), &delegate); |
| 1348 ui::test::EventGenerator generator(root_window(), child); | 1348 ui::test::EventGenerator generator(root_window(), child); |
| 1349 generator.GestureTapAt(gfx::Point(40, 40)); | 1349 generator.GestureTapAt(gfx::Point(40, 40)); |
| 1350 } | 1350 } |
| 1351 | 1351 |
| 1352 namespace { | 1352 namespace { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1384 | 1384 |
| 1385 ui::test::EventGenerator* generator_; | 1385 ui::test::EventGenerator* generator_; |
| 1386 const gfx::Point tap_location_; | 1386 const gfx::Point tap_location_; |
| 1387 int gesture_end_count_; | 1387 int gesture_end_count_; |
| 1388 DISALLOW_COPY_AND_ASSIGN(NestedGestureDelegate); | 1388 DISALLOW_COPY_AND_ASSIGN(NestedGestureDelegate); |
| 1389 }; | 1389 }; |
| 1390 | 1390 |
| 1391 } // namespace | 1391 } // namespace |
| 1392 | 1392 |
| 1393 // Tests that gesture end is delivered after nested gesture processing. | 1393 // Tests that gesture end is delivered after nested gesture processing. |
| 1394 TEST_F(WindowEventDispatcherTest, GestureEndDeliveredAfterNestedGestures) { | 1394 TEST_P(WindowEventDispatcherTest, GestureEndDeliveredAfterNestedGestures) { |
| 1395 NestedGestureDelegate d1(NULL, gfx::Point()); | 1395 NestedGestureDelegate d1(NULL, gfx::Point()); |
| 1396 std::unique_ptr<Window> w1(CreateNormalWindow(1, root_window(), &d1)); | 1396 std::unique_ptr<Window> w1(CreateNormalWindow(1, root_window(), &d1)); |
| 1397 w1->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1397 w1->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 1398 | 1398 |
| 1399 ui::test::EventGenerator nested_generator(root_window(), w1.get()); | 1399 ui::test::EventGenerator nested_generator(root_window(), w1.get()); |
| 1400 NestedGestureDelegate d2(&nested_generator, w1->bounds().CenterPoint()); | 1400 NestedGestureDelegate d2(&nested_generator, w1->bounds().CenterPoint()); |
| 1401 std::unique_ptr<Window> w2(CreateNormalWindow(1, root_window(), &d2)); | 1401 std::unique_ptr<Window> w2(CreateNormalWindow(1, root_window(), &d2)); |
| 1402 w2->SetBounds(gfx::Rect(100, 0, 100, 100)); | 1402 w2->SetBounds(gfx::Rect(100, 0, 100, 100)); |
| 1403 | 1403 |
| 1404 // Tap on w2 which triggers nested gestures for w1. | 1404 // Tap on w2 which triggers nested gestures for w1. |
| 1405 ui::test::EventGenerator generator(root_window(), w2.get()); | 1405 ui::test::EventGenerator generator(root_window(), w2.get()); |
| 1406 generator.GestureTapAt(w2->bounds().CenterPoint()); | 1406 generator.GestureTapAt(w2->bounds().CenterPoint()); |
| 1407 | 1407 |
| 1408 // Both windows should get their gesture end events. | 1408 // Both windows should get their gesture end events. |
| 1409 EXPECT_EQ(1, d1.gesture_end_count()); | 1409 EXPECT_EQ(1, d1.gesture_end_count()); |
| 1410 EXPECT_EQ(1, d2.gesture_end_count()); | 1410 EXPECT_EQ(1, d2.gesture_end_count()); |
| 1411 } | 1411 } |
| 1412 | 1412 |
| 1413 // Tests whether we can repost the Tap down gesture event. | 1413 // Tests whether we can repost the Tap down gesture event. |
| 1414 TEST_F(WindowEventDispatcherTest, RepostTapdownGestureTest) { | 1414 TEST_P(WindowEventDispatcherTest, RepostTapdownGestureTest) { |
| 1415 EventFilterRecorder recorder; | 1415 EventFilterRecorder recorder; |
| 1416 root_window()->AddPreTargetHandler(&recorder); | 1416 root_window()->AddPreTargetHandler(&recorder); |
| 1417 | 1417 |
| 1418 test::TestWindowDelegate delegate; | 1418 test::TestWindowDelegate delegate; |
| 1419 std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 1419 std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 1420 &delegate, 1, gfx::Rect(0, 0, 100, 100), root_window())); | 1420 &delegate, 1, gfx::Rect(0, 0, 100, 100), root_window())); |
| 1421 | 1421 |
| 1422 ui::GestureEventDetails details(ui::ET_GESTURE_TAP_DOWN); | 1422 ui::GestureEventDetails details(ui::ET_GESTURE_TAP_DOWN); |
| 1423 gfx::Point point(10, 10); | 1423 gfx::Point point(10, 10); |
| 1424 ui::GestureEvent event(point.x(), | 1424 ui::GestureEvent event(point.x(), |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1484 // set to true if we reposted the ET_GESTURE_TAP_DOWN event. | 1484 // set to true if we reposted the ET_GESTURE_TAP_DOWN event. |
| 1485 bool reposted_; | 1485 bool reposted_; |
| 1486 // set true if we're done cleaning up after hiding repost_source_; | 1486 // set true if we're done cleaning up after hiding repost_source_; |
| 1487 bool done_cleanup_; | 1487 bool done_cleanup_; |
| 1488 DISALLOW_COPY_AND_ASSIGN(RepostGestureEventRecorder); | 1488 DISALLOW_COPY_AND_ASSIGN(RepostGestureEventRecorder); |
| 1489 }; | 1489 }; |
| 1490 | 1490 |
| 1491 // Tests whether events which are generated after the reposted gesture event | 1491 // Tests whether events which are generated after the reposted gesture event |
| 1492 // are received after that. In this case the scroll sequence events should | 1492 // are received after that. In this case the scroll sequence events should |
| 1493 // be received after the reposted gesture event. | 1493 // be received after the reposted gesture event. |
| 1494 TEST_F(WindowEventDispatcherTest, GestureRepostEventOrder) { | 1494 TEST_P(WindowEventDispatcherTest, GestureRepostEventOrder) { |
| 1495 // Expected events at the end for the repost_target window defined below. | 1495 // Expected events at the end for the repost_target window defined below. |
| 1496 const char kExpectedTargetEvents[] = | 1496 const char kExpectedTargetEvents[] = |
| 1497 // TODO)(rbyers): Gesture event reposting is disabled - crbug.com/279039. | 1497 // TODO)(rbyers): Gesture event reposting is disabled - crbug.com/279039. |
| 1498 // "GESTURE_BEGIN GESTURE_TAP_DOWN " | 1498 // "GESTURE_BEGIN GESTURE_TAP_DOWN " |
| 1499 "TOUCH_PRESSED GESTURE_BEGIN GESTURE_TAP_DOWN TOUCH_MOVED " | 1499 "TOUCH_PRESSED GESTURE_BEGIN GESTURE_TAP_DOWN TOUCH_MOVED " |
| 1500 "GESTURE_TAP_CANCEL GESTURE_SCROLL_BEGIN GESTURE_SCROLL_UPDATE TOUCH_MOVED " | 1500 "GESTURE_TAP_CANCEL GESTURE_SCROLL_BEGIN GESTURE_SCROLL_UPDATE TOUCH_MOVED " |
| 1501 "GESTURE_SCROLL_UPDATE TOUCH_MOVED GESTURE_SCROLL_UPDATE TOUCH_RELEASED " | 1501 "GESTURE_SCROLL_UPDATE TOUCH_MOVED GESTURE_SCROLL_UPDATE TOUCH_RELEASED " |
| 1502 "GESTURE_SCROLL_END GESTURE_END"; | 1502 "GESTURE_SCROLL_END GESTURE_END"; |
| 1503 // We create two windows. | 1503 // We create two windows. |
| 1504 // The first window (repost_source) is the one to which the initial tap | 1504 // The first window (repost_source) is the one to which the initial tap |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1572 } | 1572 } |
| 1573 | 1573 |
| 1574 T* object_to_delete_; | 1574 T* object_to_delete_; |
| 1575 | 1575 |
| 1576 DISALLOW_COPY_AND_ASSIGN(OnMouseExitDeletingEventFilter); | 1576 DISALLOW_COPY_AND_ASSIGN(OnMouseExitDeletingEventFilter); |
| 1577 }; | 1577 }; |
| 1578 | 1578 |
| 1579 // Tests that RootWindow drops mouse-moved event that is supposed to be sent to | 1579 // Tests that RootWindow drops mouse-moved event that is supposed to be sent to |
| 1580 // a child, but the child is destroyed because of the synthesized mouse-exit | 1580 // a child, but the child is destroyed because of the synthesized mouse-exit |
| 1581 // event generated on the previous mouse_moved_handler_. | 1581 // event generated on the previous mouse_moved_handler_. |
| 1582 TEST_F(WindowEventDispatcherTest, DeleteWindowDuringMouseMovedDispatch) { | 1582 TEST_P(WindowEventDispatcherTest, DeleteWindowDuringMouseMovedDispatch) { |
| 1583 // Create window 1 and set its event filter. Window 1 will take ownership of | 1583 // Create window 1 and set its event filter. Window 1 will take ownership of |
| 1584 // the event filter. | 1584 // the event filter. |
| 1585 std::unique_ptr<Window> w1(CreateNormalWindow(1, root_window(), NULL)); | 1585 std::unique_ptr<Window> w1(CreateNormalWindow(1, root_window(), NULL)); |
| 1586 OnMouseExitDeletingEventFilter<Window> w1_filter; | 1586 OnMouseExitDeletingEventFilter<Window> w1_filter; |
| 1587 w1->AddPreTargetHandler(&w1_filter); | 1587 w1->AddPreTargetHandler(&w1_filter); |
| 1588 w1->SetBounds(gfx::Rect(20, 20, 60, 60)); | 1588 w1->SetBounds(gfx::Rect(20, 20, 60, 60)); |
| 1589 EXPECT_EQ(NULL, host()->dispatcher()->mouse_moved_handler()); | 1589 EXPECT_EQ(NULL, host()->dispatcher()->mouse_moved_handler()); |
| 1590 | 1590 |
| 1591 ui::test::EventGenerator generator(root_window(), w1.get()); | 1591 ui::test::EventGenerator generator(root_window(), w1.get()); |
| 1592 | 1592 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1611 generator.MoveMouseTo(52, 52); | 1611 generator.MoveMouseTo(52, 52); |
| 1612 EXPECT_EQ(NULL, host()->dispatcher()->mouse_moved_handler()); | 1612 EXPECT_EQ(NULL, host()->dispatcher()->mouse_moved_handler()); |
| 1613 | 1613 |
| 1614 // Check events received by window 1. | 1614 // Check events received by window 1. |
| 1615 EXPECT_EQ("MOUSE_ENTERED MOUSE_MOVED MOUSE_EXITED", | 1615 EXPECT_EQ("MOUSE_ENTERED MOUSE_MOVED MOUSE_EXITED", |
| 1616 EventTypesToString(w1_filter.events())); | 1616 EventTypesToString(w1_filter.events())); |
| 1617 } | 1617 } |
| 1618 | 1618 |
| 1619 // Tests the case where the event dispatcher is deleted during the pre-dispatch | 1619 // Tests the case where the event dispatcher is deleted during the pre-dispatch |
| 1620 // phase of dispatching and event. | 1620 // phase of dispatching and event. |
| 1621 TEST_F(WindowEventDispatcherTest, DeleteDispatcherDuringPreDispatch) { | 1621 TEST_P(WindowEventDispatcherTest, DeleteDispatcherDuringPreDispatch) { |
| 1622 // Create a host for the window hierarchy. This host will be destroyed later | 1622 // Create a host for the window hierarchy. This host will be destroyed later |
| 1623 // on. | 1623 // on. |
| 1624 WindowTreeHost* host = WindowTreeHost::Create(gfx::Rect(0, 0, 100, 100)); | 1624 WindowTreeHost* host = WindowTreeHost::Create(gfx::Rect(0, 0, 100, 100)); |
| 1625 host->InitHost(); | 1625 host->InitHost(); |
| 1626 | 1626 |
| 1627 // Create two windows. | 1627 // Create two windows. |
| 1628 Window* w1 = CreateNormalWindow(1, host->window(), nullptr); | 1628 Window* w1 = CreateNormalWindow(1, host->window(), nullptr); |
| 1629 w1->SetBounds(gfx::Rect(20, 20, 60, 60)); | 1629 w1->SetBounds(gfx::Rect(20, 20, 60, 60)); |
| 1630 Window* w2 = CreateNormalWindow(2, host->window(), nullptr); | 1630 Window* w2 = CreateNormalWindow(2, host->window(), nullptr); |
| 1631 w2->SetBounds(gfx::Rect(80, 20, 120, 60)); | 1631 w2->SetBounds(gfx::Rect(80, 20, 120, 60)); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1684 private: | 1684 private: |
| 1685 bool* got_destroying_; | 1685 bool* got_destroying_; |
| 1686 bool* has_valid_root_; | 1686 bool* has_valid_root_; |
| 1687 | 1687 |
| 1688 DISALLOW_COPY_AND_ASSIGN(ValidRootDuringDestructionWindowObserver); | 1688 DISALLOW_COPY_AND_ASSIGN(ValidRootDuringDestructionWindowObserver); |
| 1689 }; | 1689 }; |
| 1690 | 1690 |
| 1691 } // namespace | 1691 } // namespace |
| 1692 | 1692 |
| 1693 // Verifies GetRootWindow() from ~Window returns a valid root. | 1693 // Verifies GetRootWindow() from ~Window returns a valid root. |
| 1694 TEST_F(WindowEventDispatcherTest, ValidRootDuringDestruction) { | 1694 TEST_P(WindowEventDispatcherTest, ValidRootDuringDestruction) { |
| 1695 bool got_destroying = false; | 1695 bool got_destroying = false; |
| 1696 bool has_valid_root = false; | 1696 bool has_valid_root = false; |
| 1697 ValidRootDuringDestructionWindowObserver observer(&got_destroying, | 1697 ValidRootDuringDestructionWindowObserver observer(&got_destroying, |
| 1698 &has_valid_root); | 1698 &has_valid_root); |
| 1699 { | 1699 { |
| 1700 std::unique_ptr<WindowTreeHost> host( | 1700 std::unique_ptr<WindowTreeHost> host( |
| 1701 WindowTreeHost::Create(gfx::Rect(0, 0, 100, 100))); | 1701 WindowTreeHost::Create(gfx::Rect(0, 0, 100, 100))); |
| 1702 host->InitHost(); | 1702 host->InitHost(); |
| 1703 // Owned by WindowEventDispatcher. | 1703 // Owned by WindowEventDispatcher. |
| 1704 Window* w1 = CreateNormalWindow(1, host->window(), NULL); | 1704 Window* w1 = CreateNormalWindow(1, host->window(), NULL); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1738 DISALLOW_COPY_AND_ASSIGN(DontResetHeldEventWindowDelegate); | 1738 DISALLOW_COPY_AND_ASSIGN(DontResetHeldEventWindowDelegate); |
| 1739 }; | 1739 }; |
| 1740 | 1740 |
| 1741 } // namespace | 1741 } // namespace |
| 1742 | 1742 |
| 1743 // Verifies RootWindow doesn't reset |RootWindow::held_repostable_event_| after | 1743 // Verifies RootWindow doesn't reset |RootWindow::held_repostable_event_| after |
| 1744 // dispatching. This is done by using DontResetHeldEventWindowDelegate, which | 1744 // dispatching. This is done by using DontResetHeldEventWindowDelegate, which |
| 1745 // tracks the number of events with ui::EF_SHIFT_DOWN set (all reposted events | 1745 // tracks the number of events with ui::EF_SHIFT_DOWN set (all reposted events |
| 1746 // have EF_SHIFT_DOWN). When the first event is seen RepostEvent() is used to | 1746 // have EF_SHIFT_DOWN). When the first event is seen RepostEvent() is used to |
| 1747 // schedule another reposted event. | 1747 // schedule another reposted event. |
| 1748 TEST_F(WindowEventDispatcherTest, DontResetHeldEvent) { | 1748 TEST_P(WindowEventDispatcherTest, DontResetHeldEvent) { |
| 1749 DontResetHeldEventWindowDelegate delegate(root_window()); | 1749 DontResetHeldEventWindowDelegate delegate(root_window()); |
| 1750 std::unique_ptr<Window> w1(CreateNormalWindow(1, root_window(), &delegate)); | 1750 std::unique_ptr<Window> w1(CreateNormalWindow(1, root_window(), &delegate)); |
| 1751 w1->SetBounds(gfx::Rect(0, 0, 40, 40)); | 1751 w1->SetBounds(gfx::Rect(0, 0, 40, 40)); |
| 1752 ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, gfx::Point(10, 10), | 1752 ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, gfx::Point(10, 10), |
| 1753 gfx::Point(10, 10), ui::EventTimeForNow(), | 1753 gfx::Point(10, 10), ui::EventTimeForNow(), |
| 1754 ui::EF_SHIFT_DOWN, 0); | 1754 ui::EF_SHIFT_DOWN, 0); |
| 1755 root_window()->GetHost()->dispatcher()->RepostEvent(&pressed); | 1755 root_window()->GetHost()->dispatcher()->RepostEvent(&pressed); |
| 1756 ui::MouseEvent pressed2(ui::ET_MOUSE_PRESSED, gfx::Point(10, 10), | 1756 ui::MouseEvent pressed2(ui::ET_MOUSE_PRESSED, gfx::Point(10, 10), |
| 1757 gfx::Point(10, 10), ui::EventTimeForNow(), 0, 0); | 1757 gfx::Point(10, 10), ui::EventTimeForNow(), 0, 0); |
| 1758 // Dispatch an event to flush event scheduled by way of RepostEvent(). | 1758 // Dispatch an event to flush event scheduled by way of RepostEvent(). |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1795 bool got_mouse_event_; | 1795 bool got_mouse_event_; |
| 1796 bool got_destroy_; | 1796 bool got_destroy_; |
| 1797 | 1797 |
| 1798 DISALLOW_COPY_AND_ASSIGN(DeleteHostFromHeldMouseEventDelegate); | 1798 DISALLOW_COPY_AND_ASSIGN(DeleteHostFromHeldMouseEventDelegate); |
| 1799 }; | 1799 }; |
| 1800 | 1800 |
| 1801 } // namespace | 1801 } // namespace |
| 1802 | 1802 |
| 1803 // Verifies if a WindowTreeHost is deleted from dispatching a held mouse event | 1803 // Verifies if a WindowTreeHost is deleted from dispatching a held mouse event |
| 1804 // we don't crash. | 1804 // we don't crash. |
| 1805 TEST_F(WindowEventDispatcherTest, DeleteHostFromHeldMouseEvent) { | 1805 TEST_P(WindowEventDispatcherTest, DeleteHostFromHeldMouseEvent) { |
| 1806 // Should be deleted by |delegate|. | 1806 // Should be deleted by |delegate|. |
| 1807 WindowTreeHost* h2 = WindowTreeHost::Create(gfx::Rect(0, 0, 100, 100)); | 1807 WindowTreeHost* h2 = WindowTreeHost::Create(gfx::Rect(0, 0, 100, 100)); |
| 1808 h2->InitHost(); | 1808 h2->InitHost(); |
| 1809 DeleteHostFromHeldMouseEventDelegate delegate(h2); | 1809 DeleteHostFromHeldMouseEventDelegate delegate(h2); |
| 1810 // Owned by |h2|. | 1810 // Owned by |h2|. |
| 1811 Window* w1 = CreateNormalWindow(1, h2->window(), &delegate); | 1811 Window* w1 = CreateNormalWindow(1, h2->window(), &delegate); |
| 1812 w1->SetBounds(gfx::Rect(0, 0, 40, 40)); | 1812 w1->SetBounds(gfx::Rect(0, 0, 40, 40)); |
| 1813 ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, gfx::Point(10, 10), | 1813 ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, gfx::Point(10, 10), |
| 1814 gfx::Point(10, 10), ui::EventTimeForNow(), | 1814 gfx::Point(10, 10), ui::EventTimeForNow(), |
| 1815 ui::EF_SHIFT_DOWN, 0); | 1815 ui::EF_SHIFT_DOWN, 0); |
| 1816 h2->dispatcher()->RepostEvent(&pressed); | 1816 h2->dispatcher()->RepostEvent(&pressed); |
| 1817 // RunAllPendingInMessageLoop() to make sure the |pressed| is run. | 1817 // RunAllPendingInMessageLoop() to make sure the |pressed| is run. |
| 1818 RunAllPendingInMessageLoop(); | 1818 RunAllPendingInMessageLoop(); |
| 1819 EXPECT_TRUE(delegate.got_mouse_event()); | 1819 EXPECT_TRUE(delegate.got_mouse_event()); |
| 1820 EXPECT_TRUE(delegate.got_destroy()); | 1820 EXPECT_TRUE(delegate.got_destroy()); |
| 1821 } | 1821 } |
| 1822 | 1822 |
| 1823 TEST_F(WindowEventDispatcherTest, WindowHideCancelsActiveTouches) { | 1823 TEST_P(WindowEventDispatcherTest, WindowHideCancelsActiveTouches) { |
| 1824 EventFilterRecorder recorder; | 1824 EventFilterRecorder recorder; |
| 1825 root_window()->AddPreTargetHandler(&recorder); | 1825 root_window()->AddPreTargetHandler(&recorder); |
| 1826 | 1826 |
| 1827 test::TestWindowDelegate delegate; | 1827 test::TestWindowDelegate delegate; |
| 1828 std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 1828 std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 1829 &delegate, 1, gfx::Rect(0, 0, 100, 100), root_window())); | 1829 &delegate, 1, gfx::Rect(0, 0, 100, 100), root_window())); |
| 1830 | 1830 |
| 1831 gfx::Point position1 = root_window()->bounds().origin(); | 1831 gfx::Point position1 = root_window()->bounds().origin(); |
| 1832 ui::TouchEvent press( | 1832 ui::TouchEvent press( |
| 1833 ui::ET_TOUCH_PRESSED, position1, 0, ui::EventTimeForNow()); | 1833 ui::ET_TOUCH_PRESSED, position1, 0, ui::EventTimeForNow()); |
| 1834 DispatchEventUsingWindowDispatcher(&press); | 1834 DispatchEventUsingWindowDispatcher(&press); |
| 1835 | 1835 |
| 1836 EXPECT_EQ("TOUCH_PRESSED GESTURE_BEGIN GESTURE_TAP_DOWN", | 1836 EXPECT_EQ("TOUCH_PRESSED GESTURE_BEGIN GESTURE_TAP_DOWN", |
| 1837 EventTypesToString(recorder.GetAndResetEvents())); | 1837 EventTypesToString(recorder.GetAndResetEvents())); |
| 1838 | 1838 |
| 1839 window->Hide(); | 1839 window->Hide(); |
| 1840 | 1840 |
| 1841 EXPECT_EQ(ui::ET_TOUCH_CANCELLED, recorder.events()[0]); | 1841 EXPECT_EQ(ui::ET_TOUCH_CANCELLED, recorder.events()[0]); |
| 1842 EXPECT_TRUE(recorder.HasReceivedEvent(ui::ET_GESTURE_TAP_CANCEL)); | 1842 EXPECT_TRUE(recorder.HasReceivedEvent(ui::ET_GESTURE_TAP_CANCEL)); |
| 1843 EXPECT_TRUE(recorder.HasReceivedEvent(ui::ET_GESTURE_END)); | 1843 EXPECT_TRUE(recorder.HasReceivedEvent(ui::ET_GESTURE_END)); |
| 1844 EXPECT_EQ(3U, recorder.events().size()); | 1844 EXPECT_EQ(3U, recorder.events().size()); |
| 1845 root_window()->RemovePreTargetHandler(&recorder); | 1845 root_window()->RemovePreTargetHandler(&recorder); |
| 1846 } | 1846 } |
| 1847 | 1847 |
| 1848 TEST_F(WindowEventDispatcherTest, WindowHideCancelsActiveGestures) { | 1848 TEST_P(WindowEventDispatcherTest, WindowHideCancelsActiveGestures) { |
| 1849 EventFilterRecorder recorder; | 1849 EventFilterRecorder recorder; |
| 1850 root_window()->AddPreTargetHandler(&recorder); | 1850 root_window()->AddPreTargetHandler(&recorder); |
| 1851 | 1851 |
| 1852 test::TestWindowDelegate delegate; | 1852 test::TestWindowDelegate delegate; |
| 1853 std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 1853 std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 1854 &delegate, 1, gfx::Rect(0, 0, 100, 100), root_window())); | 1854 &delegate, 1, gfx::Rect(0, 0, 100, 100), root_window())); |
| 1855 | 1855 |
| 1856 gfx::Point position1 = root_window()->bounds().origin(); | 1856 gfx::Point position1 = root_window()->bounds().origin(); |
| 1857 gfx::Point position2 = root_window()->bounds().CenterPoint(); | 1857 gfx::Point position2 = root_window()->bounds().CenterPoint(); |
| 1858 ui::TouchEvent press( | 1858 ui::TouchEvent press( |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1893 | 1893 |
| 1894 events_string = EventTypesToString(recorder.GetAndResetEvents()); | 1894 events_string = EventTypesToString(recorder.GetAndResetEvents()); |
| 1895 EXPECT_TRUE((expected == events_string) || (expected_ugr == events_string)); | 1895 EXPECT_TRUE((expected == events_string) || (expected_ugr == events_string)); |
| 1896 | 1896 |
| 1897 root_window()->RemovePreTargetHandler(&recorder); | 1897 root_window()->RemovePreTargetHandler(&recorder); |
| 1898 } | 1898 } |
| 1899 | 1899 |
| 1900 // Places two windows side by side. Presses down on one window, and starts a | 1900 // Places two windows side by side. Presses down on one window, and starts a |
| 1901 // scroll. Sets capture on the other window and ensures that the "ending" events | 1901 // scroll. Sets capture on the other window and ensures that the "ending" events |
| 1902 // aren't sent to the window which gained capture. | 1902 // aren't sent to the window which gained capture. |
| 1903 TEST_F(WindowEventDispatcherTest, EndingEventDoesntRetarget) { | 1903 TEST_P(WindowEventDispatcherTest, EndingEventDoesntRetarget) { |
| 1904 EventFilterRecorder recorder1; | 1904 EventFilterRecorder recorder1; |
| 1905 EventFilterRecorder recorder2; | 1905 EventFilterRecorder recorder2; |
| 1906 std::unique_ptr<Window> window1(CreateNormalWindow(1, root_window(), NULL)); | 1906 std::unique_ptr<Window> window1(CreateNormalWindow(1, root_window(), NULL)); |
| 1907 window1->SetBounds(gfx::Rect(0, 0, 40, 40)); | 1907 window1->SetBounds(gfx::Rect(0, 0, 40, 40)); |
| 1908 | 1908 |
| 1909 std::unique_ptr<Window> window2(CreateNormalWindow(2, root_window(), NULL)); | 1909 std::unique_ptr<Window> window2(CreateNormalWindow(2, root_window(), NULL)); |
| 1910 window2->SetBounds(gfx::Rect(40, 0, 40, 40)); | 1910 window2->SetBounds(gfx::Rect(40, 0, 40, 40)); |
| 1911 | 1911 |
| 1912 window1->AddPreTargetHandler(&recorder1); | 1912 window1->AddPreTargetHandler(&recorder1); |
| 1913 window2->AddPreTargetHandler(&recorder2); | 1913 window2->AddPreTargetHandler(&recorder2); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1962 | 1962 |
| 1963 private: | 1963 private: |
| 1964 std::unique_ptr<aura::Window> capture_window_; | 1964 std::unique_ptr<aura::Window> capture_window_; |
| 1965 | 1965 |
| 1966 DISALLOW_COPY_AND_ASSIGN(CaptureWindowTracker); | 1966 DISALLOW_COPY_AND_ASSIGN(CaptureWindowTracker); |
| 1967 }; | 1967 }; |
| 1968 | 1968 |
| 1969 } | 1969 } |
| 1970 | 1970 |
| 1971 // Verifies handling loss of capture by the capture window being hidden. | 1971 // Verifies handling loss of capture by the capture window being hidden. |
| 1972 TEST_F(WindowEventDispatcherTest, CaptureWindowHidden) { | 1972 TEST_P(WindowEventDispatcherTest, CaptureWindowHidden) { |
| 1973 CaptureWindowTracker capture_window_tracker; | 1973 CaptureWindowTracker capture_window_tracker; |
| 1974 capture_window_tracker.CreateCaptureWindow(root_window()); | 1974 capture_window_tracker.CreateCaptureWindow(root_window()); |
| 1975 capture_window_tracker.capture_window()->Hide(); | 1975 capture_window_tracker.capture_window()->Hide(); |
| 1976 EXPECT_EQ(NULL, capture_window_tracker.capture_window()); | 1976 EXPECT_EQ(NULL, capture_window_tracker.capture_window()); |
| 1977 } | 1977 } |
| 1978 | 1978 |
| 1979 // Verifies handling loss of capture by the capture window being destroyed. | 1979 // Verifies handling loss of capture by the capture window being destroyed. |
| 1980 TEST_F(WindowEventDispatcherTest, CaptureWindowDestroyed) { | 1980 TEST_P(WindowEventDispatcherTest, CaptureWindowDestroyed) { |
| 1981 CaptureWindowTracker capture_window_tracker; | 1981 CaptureWindowTracker capture_window_tracker; |
| 1982 capture_window_tracker.CreateCaptureWindow(root_window()); | 1982 capture_window_tracker.CreateCaptureWindow(root_window()); |
| 1983 capture_window_tracker.reset(); | 1983 capture_window_tracker.reset(); |
| 1984 EXPECT_EQ(NULL, capture_window_tracker.capture_window()); | 1984 EXPECT_EQ(NULL, capture_window_tracker.capture_window()); |
| 1985 } | 1985 } |
| 1986 | 1986 |
| 1987 class ExitMessageLoopOnMousePress : public ui::test::TestEventHandler { | 1987 class ExitMessageLoopOnMousePress : public ui::test::TestEventHandler { |
| 1988 public: | 1988 public: |
| 1989 ExitMessageLoopOnMousePress() {} | 1989 ExitMessageLoopOnMousePress() {} |
| 1990 ~ExitMessageLoopOnMousePress() override {} | 1990 ~ExitMessageLoopOnMousePress() override {} |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2055 std::unique_ptr<ui::MouseEvent> event) { | 2055 std::unique_ptr<ui::MouseEvent> event) { |
| 2056 dispatcher->RepostEvent(event.get()); | 2056 dispatcher->RepostEvent(event.get()); |
| 2057 } | 2057 } |
| 2058 | 2058 |
| 2059 std::unique_ptr<Window> window_; | 2059 std::unique_ptr<Window> window_; |
| 2060 ExitMessageLoopOnMousePress handler_; | 2060 ExitMessageLoopOnMousePress handler_; |
| 2061 | 2061 |
| 2062 DISALLOW_COPY_AND_ASSIGN(WindowEventDispatcherTestWithMessageLoop); | 2062 DISALLOW_COPY_AND_ASSIGN(WindowEventDispatcherTestWithMessageLoop); |
| 2063 }; | 2063 }; |
| 2064 | 2064 |
| 2065 TEST_F(WindowEventDispatcherTestWithMessageLoop, EventRepostedInNonNestedLoop) { | 2065 TEST_P(WindowEventDispatcherTestWithMessageLoop, EventRepostedInNonNestedLoop) { |
| 2066 CHECK(!message_loop()->is_running()); | 2066 CHECK(!message_loop()->is_running()); |
| 2067 // Perform the test in a callback, so that it runs after the message-loop | 2067 // Perform the test in a callback, so that it runs after the message-loop |
| 2068 // starts. | 2068 // starts. |
| 2069 message_loop()->task_runner()->PostTask( | 2069 message_loop()->task_runner()->PostTask( |
| 2070 FROM_HERE, base::Bind(&WindowEventDispatcherTestWithMessageLoop::RunTest, | 2070 FROM_HERE, base::Bind(&WindowEventDispatcherTestWithMessageLoop::RunTest, |
| 2071 base::Unretained(this))); | 2071 base::Unretained(this))); |
| 2072 base::RunLoop().Run(); | 2072 base::RunLoop().Run(); |
| 2073 } | 2073 } |
| 2074 | 2074 |
| 2075 class WindowEventDispatcherTestInHighDPI : public WindowEventDispatcherTest { | 2075 class WindowEventDispatcherTestInHighDPI : public WindowEventDispatcherTest { |
| 2076 public: | 2076 public: |
| 2077 WindowEventDispatcherTestInHighDPI() {} | 2077 WindowEventDispatcherTestInHighDPI() {} |
| 2078 ~WindowEventDispatcherTestInHighDPI() override {} | 2078 ~WindowEventDispatcherTestInHighDPI() override {} |
| 2079 | 2079 |
| 2080 void DispatchEvent(ui::Event* event) { | 2080 void DispatchEvent(ui::Event* event) { |
| 2081 DispatchEventUsingWindowDispatcher(event); | 2081 DispatchEventUsingWindowDispatcher(event); |
| 2082 } | 2082 } |
| 2083 | 2083 |
| 2084 protected: | 2084 protected: |
| 2085 void SetUp() override { | 2085 void SetUp() override { |
| 2086 WindowEventDispatcherTest::SetUp(); | 2086 WindowEventDispatcherTest::SetUp(); |
| 2087 test_screen()->SetDeviceScaleFactor(2.f); | 2087 test_screen()->SetDeviceScaleFactor(2.f); |
| 2088 } | 2088 } |
| 2089 }; | 2089 }; |
| 2090 | 2090 |
| 2091 TEST_F(WindowEventDispatcherTestInHighDPI, EventLocationTransform) { | 2091 TEST_P(WindowEventDispatcherTestInHighDPI, EventLocationTransform) { |
| 2092 test::TestWindowDelegate delegate; | 2092 test::TestWindowDelegate delegate; |
| 2093 std::unique_ptr<aura::Window> child(test::CreateTestWindowWithDelegate( | 2093 std::unique_ptr<aura::Window> child(test::CreateTestWindowWithDelegate( |
| 2094 &delegate, 1234, gfx::Rect(20, 20, 100, 100), root_window())); | 2094 &delegate, 1234, gfx::Rect(20, 20, 100, 100), root_window())); |
| 2095 child->Show(); | 2095 child->Show(); |
| 2096 | 2096 |
| 2097 ui::test::TestEventHandler handler_child; | 2097 ui::test::TestEventHandler handler_child; |
| 2098 ui::test::TestEventHandler handler_root; | 2098 ui::test::TestEventHandler handler_root; |
| 2099 root_window()->AddPreTargetHandler(&handler_root); | 2099 root_window()->AddPreTargetHandler(&handler_root); |
| 2100 child->AddPreTargetHandler(&handler_child); | 2100 child->AddPreTargetHandler(&handler_child); |
| 2101 | 2101 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2117 EXPECT_EQ(2, handler_child.num_mouse_events()); | 2117 EXPECT_EQ(2, handler_child.num_mouse_events()); |
| 2118 // The root receives both the ENTER and the MOVED events dispatched to | 2118 // The root receives both the ENTER and the MOVED events dispatched to |
| 2119 // |child|, as well as an EXIT event. | 2119 // |child|, as well as an EXIT event. |
| 2120 EXPECT_EQ(3, handler_root.num_mouse_events()); | 2120 EXPECT_EQ(3, handler_root.num_mouse_events()); |
| 2121 } | 2121 } |
| 2122 | 2122 |
| 2123 child->RemovePreTargetHandler(&handler_child); | 2123 child->RemovePreTargetHandler(&handler_child); |
| 2124 root_window()->RemovePreTargetHandler(&handler_root); | 2124 root_window()->RemovePreTargetHandler(&handler_root); |
| 2125 } | 2125 } |
| 2126 | 2126 |
| 2127 TEST_F(WindowEventDispatcherTestInHighDPI, TouchMovesHeldOnScroll) { | 2127 TEST_P(WindowEventDispatcherTestInHighDPI, TouchMovesHeldOnScroll) { |
| 2128 EventFilterRecorder recorder; | 2128 EventFilterRecorder recorder; |
| 2129 root_window()->AddPreTargetHandler(&recorder); | 2129 root_window()->AddPreTargetHandler(&recorder); |
| 2130 test::TestWindowDelegate delegate; | 2130 test::TestWindowDelegate delegate; |
| 2131 HoldPointerOnScrollHandler handler(host()->dispatcher(), &recorder); | 2131 HoldPointerOnScrollHandler handler(host()->dispatcher(), &recorder); |
| 2132 std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 2132 std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 2133 &delegate, 1, gfx::Rect(50, 50, 100, 100), root_window())); | 2133 &delegate, 1, gfx::Rect(50, 50, 100, 100), root_window())); |
| 2134 window->AddPreTargetHandler(&handler); | 2134 window->AddPreTargetHandler(&handler); |
| 2135 | 2135 |
| 2136 ui::test::EventGenerator generator(root_window()); | 2136 ui::test::EventGenerator generator(root_window()); |
| 2137 generator.GestureScrollSequence( | 2137 generator.GestureScrollSequence( |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2187 | 2187 |
| 2188 base::Closure callback_; | 2188 base::Closure callback_; |
| 2189 gfx::Point mouse_move_location_; | 2189 gfx::Point mouse_move_location_; |
| 2190 | 2190 |
| 2191 DISALLOW_COPY_AND_ASSIGN(TriggerNestedLoopOnRightMousePress); | 2191 DISALLOW_COPY_AND_ASSIGN(TriggerNestedLoopOnRightMousePress); |
| 2192 }; | 2192 }; |
| 2193 | 2193 |
| 2194 // Tests that if dispatching a 'held' event triggers a nested message loop, then | 2194 // Tests that if dispatching a 'held' event triggers a nested message loop, then |
| 2195 // the events that are dispatched from the nested message loop are transformed | 2195 // the events that are dispatched from the nested message loop are transformed |
| 2196 // correctly. | 2196 // correctly. |
| 2197 TEST_F(WindowEventDispatcherTestInHighDPI, | 2197 TEST_P(WindowEventDispatcherTestInHighDPI, |
| 2198 EventsTransformedInRepostedEventTriggeredNestedLoop) { | 2198 EventsTransformedInRepostedEventTriggeredNestedLoop) { |
| 2199 std::unique_ptr<Window> window(CreateNormalWindow(1, root_window(), NULL)); | 2199 std::unique_ptr<Window> window(CreateNormalWindow(1, root_window(), NULL)); |
| 2200 // Make sure the window is visible. | 2200 // Make sure the window is visible. |
| 2201 RunAllPendingInMessageLoop(); | 2201 RunAllPendingInMessageLoop(); |
| 2202 | 2202 |
| 2203 ui::MouseEvent mouse_move(ui::ET_MOUSE_MOVED, gfx::Point(80, 80), | 2203 ui::MouseEvent mouse_move(ui::ET_MOUSE_MOVED, gfx::Point(80, 80), |
| 2204 gfx::Point(80, 80), ui::EventTimeForNow(), | 2204 gfx::Point(80, 80), ui::EventTimeForNow(), |
| 2205 ui::EF_NONE, ui::EF_NONE); | 2205 ui::EF_NONE, ui::EF_NONE); |
| 2206 const base::Closure callback_on_right_click = base::Bind( | 2206 const base::Closure callback_on_right_click = base::Bind( |
| 2207 base::IgnoreResult(&WindowEventDispatcherTestInHighDPI::DispatchEvent), | 2207 base::IgnoreResult(&WindowEventDispatcherTestInHighDPI::DispatchEvent), |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2239 void set_window(std::unique_ptr<aura::Window> window) { | 2239 void set_window(std::unique_ptr<aura::Window> window) { |
| 2240 window_ = std::move(window); | 2240 window_ = std::move(window); |
| 2241 } | 2241 } |
| 2242 bool has_window() const { return !!window_.get(); } | 2242 bool has_window() const { return !!window_.get(); } |
| 2243 | 2243 |
| 2244 private: | 2244 private: |
| 2245 std::unique_ptr<aura::Window> window_; | 2245 std::unique_ptr<aura::Window> window_; |
| 2246 DISALLOW_COPY_AND_ASSIGN(SelfDestructDelegate); | 2246 DISALLOW_COPY_AND_ASSIGN(SelfDestructDelegate); |
| 2247 }; | 2247 }; |
| 2248 | 2248 |
| 2249 TEST_F(WindowEventDispatcherTest, SynthesizedLocatedEvent) { | 2249 TEST_P(WindowEventDispatcherTest, SynthesizedLocatedEvent) { |
| 2250 ui::test::EventGenerator generator(root_window()); | 2250 ui::test::EventGenerator generator(root_window()); |
| 2251 generator.MoveMouseTo(10, 10); | 2251 generator.MoveMouseTo(10, 10); |
| 2252 EXPECT_EQ("10,10", | 2252 EXPECT_EQ("10,10", |
| 2253 Env::GetInstance()->last_mouse_location().ToString()); | 2253 Env::GetInstance()->last_mouse_location().ToString()); |
| 2254 | 2254 |
| 2255 // Synthesized event should not update the mouse location. | 2255 // Synthesized event should not update the mouse location. |
| 2256 ui::MouseEvent mouseev(ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), | 2256 ui::MouseEvent mouseev(ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), |
| 2257 ui::EventTimeForNow(), ui::EF_IS_SYNTHESIZED, 0); | 2257 ui::EventTimeForNow(), ui::EF_IS_SYNTHESIZED, 0); |
| 2258 generator.Dispatch(&mouseev); | 2258 generator.Dispatch(&mouseev); |
| 2259 EXPECT_EQ("10,10", | 2259 EXPECT_EQ("10,10", |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2273 | 2273 |
| 2274 generator.MoveMouseTo(100, 100); | 2274 generator.MoveMouseTo(100, 100); |
| 2275 EXPECT_FALSE(delegate.has_window()); | 2275 EXPECT_FALSE(delegate.has_window()); |
| 2276 EXPECT_EQ("100,100", | 2276 EXPECT_EQ("100,100", |
| 2277 Env::GetInstance()->last_mouse_location().ToString()); | 2277 Env::GetInstance()->last_mouse_location().ToString()); |
| 2278 } | 2278 } |
| 2279 | 2279 |
| 2280 // Tests that the window which has capture can get destroyed as a result of | 2280 // Tests that the window which has capture can get destroyed as a result of |
| 2281 // ui::ET_MOUSE_CAPTURE_CHANGED event dispatched in | 2281 // ui::ET_MOUSE_CAPTURE_CHANGED event dispatched in |
| 2282 // WindowEventDispatcher::UpdateCapture without causing a "use after free". | 2282 // WindowEventDispatcher::UpdateCapture without causing a "use after free". |
| 2283 TEST_F(WindowEventDispatcherTest, DestroyWindowOnCaptureChanged) { | 2283 TEST_P(WindowEventDispatcherTest, DestroyWindowOnCaptureChanged) { |
| 2284 SelfDestructDelegate delegate; | 2284 SelfDestructDelegate delegate; |
| 2285 std::unique_ptr<aura::Window> window_first(CreateTestWindowWithDelegate( | 2285 std::unique_ptr<aura::Window> window_first(CreateTestWindowWithDelegate( |
| 2286 &delegate, 1, gfx::Rect(20, 10, 10, 20), root_window())); | 2286 &delegate, 1, gfx::Rect(20, 10, 10, 20), root_window())); |
| 2287 Window* window_first_raw = window_first.get(); | 2287 Window* window_first_raw = window_first.get(); |
| 2288 window_first->Show(); | 2288 window_first->Show(); |
| 2289 window_first->SetCapture(); | 2289 window_first->SetCapture(); |
| 2290 delegate.set_window(std::move(window_first)); | 2290 delegate.set_window(std::move(window_first)); |
| 2291 EXPECT_TRUE(delegate.has_window()); | 2291 EXPECT_TRUE(delegate.has_window()); |
| 2292 | 2292 |
| 2293 std::unique_ptr<aura::Window> window_second( | 2293 std::unique_ptr<aura::Window> window_second( |
| (...skipping 19 matching lines...) Expand all Loading... |
| 2313 void ResetFocusWithinActiveWindow(Window* window) override {} | 2313 void ResetFocusWithinActiveWindow(Window* window) override {} |
| 2314 Window* GetFocusedWindow() override { return focused_; } | 2314 Window* GetFocusedWindow() override { return focused_; } |
| 2315 | 2315 |
| 2316 Window* focused_; | 2316 Window* focused_; |
| 2317 | 2317 |
| 2318 DISALLOW_COPY_AND_ASSIGN(StaticFocusClient); | 2318 DISALLOW_COPY_AND_ASSIGN(StaticFocusClient); |
| 2319 }; | 2319 }; |
| 2320 | 2320 |
| 2321 // Tests that host-cancel-mode event can be dispatched to a dispatcher safely | 2321 // Tests that host-cancel-mode event can be dispatched to a dispatcher safely |
| 2322 // when the focused window does not live in the dispatcher's tree. | 2322 // when the focused window does not live in the dispatcher's tree. |
| 2323 TEST_F(WindowEventDispatcherTest, HostCancelModeWithFocusedWindowOutside) { | 2323 TEST_P(WindowEventDispatcherTest, HostCancelModeWithFocusedWindowOutside) { |
| 2324 test::TestWindowDelegate delegate; | 2324 test::TestWindowDelegate delegate; |
| 2325 std::unique_ptr<Window> focused(CreateTestWindowWithDelegate( | 2325 std::unique_ptr<Window> focused(CreateTestWindowWithDelegate( |
| 2326 &delegate, 123, gfx::Rect(20, 30, 100, 50), NULL)); | 2326 &delegate, 123, gfx::Rect(20, 30, 100, 50), NULL)); |
| 2327 StaticFocusClient focus_client(focused.get()); | 2327 StaticFocusClient focus_client(focused.get()); |
| 2328 client::SetFocusClient(root_window(), &focus_client); | 2328 client::SetFocusClient(root_window(), &focus_client); |
| 2329 EXPECT_FALSE(root_window()->Contains(focused.get())); | 2329 EXPECT_FALSE(root_window()->Contains(focused.get())); |
| 2330 EXPECT_EQ(focused.get(), | 2330 EXPECT_EQ(focused.get(), |
| 2331 client::GetFocusClient(root_window())->GetFocusedWindow()); | 2331 client::GetFocusClient(root_window())->GetFocusedWindow()); |
| 2332 host()->dispatcher()->DispatchCancelModeEvent(); | 2332 host()->dispatcher()->DispatchCancelModeEvent(); |
| 2333 EXPECT_EQ(focused.get(), | 2333 EXPECT_EQ(focused.get(), |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2386 | 2386 |
| 2387 Window* window_to_move_; | 2387 Window* window_to_move_; |
| 2388 Window* root_window_to_move_to_; | 2388 Window* root_window_to_move_to_; |
| 2389 | 2389 |
| 2390 DISALLOW_COPY_AND_ASSIGN(MoveWindowHandler); | 2390 DISALLOW_COPY_AND_ASSIGN(MoveWindowHandler); |
| 2391 }; | 2391 }; |
| 2392 | 2392 |
| 2393 // Tests that nested event dispatch works correctly if the target of the older | 2393 // Tests that nested event dispatch works correctly if the target of the older |
| 2394 // event being dispatched is moved to a different dispatcher in response to an | 2394 // event being dispatched is moved to a different dispatcher in response to an |
| 2395 // event in the inner loop. | 2395 // event in the inner loop. |
| 2396 TEST_F(WindowEventDispatcherTest, NestedEventDispatchTargetMoved) { | 2396 TEST_P(WindowEventDispatcherTest, NestedEventDispatchTargetMoved) { |
| 2397 std::unique_ptr<WindowTreeHost> second_host( | 2397 std::unique_ptr<WindowTreeHost> second_host( |
| 2398 WindowTreeHost::Create(gfx::Rect(20, 30, 100, 50))); | 2398 WindowTreeHost::Create(gfx::Rect(20, 30, 100, 50))); |
| 2399 second_host->InitHost(); | 2399 second_host->InitHost(); |
| 2400 Window* second_root = second_host->window(); | 2400 Window* second_root = second_host->window(); |
| 2401 | 2401 |
| 2402 // Create two windows parented to |root_window()|. | 2402 // Create two windows parented to |root_window()|. |
| 2403 test::TestWindowDelegate delegate; | 2403 test::TestWindowDelegate delegate; |
| 2404 std::unique_ptr<Window> first(CreateTestWindowWithDelegate( | 2404 std::unique_ptr<Window> first(CreateTestWindowWithDelegate( |
| 2405 &delegate, 123, gfx::Rect(20, 10, 10, 20), root_window())); | 2405 &delegate, 123, gfx::Rect(20, 10, 10, 20), root_window())); |
| 2406 std::unique_ptr<Window> second(CreateTestWindowWithDelegate( | 2406 std::unique_ptr<Window> second(CreateTestWindowWithDelegate( |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2442 AlwaysMouseDownInputStateLookup() {} | 2442 AlwaysMouseDownInputStateLookup() {} |
| 2443 ~AlwaysMouseDownInputStateLookup() override {} | 2443 ~AlwaysMouseDownInputStateLookup() override {} |
| 2444 | 2444 |
| 2445 private: | 2445 private: |
| 2446 // InputStateLookup: | 2446 // InputStateLookup: |
| 2447 bool IsMouseButtonDown() const override { return true; } | 2447 bool IsMouseButtonDown() const override { return true; } |
| 2448 | 2448 |
| 2449 DISALLOW_COPY_AND_ASSIGN(AlwaysMouseDownInputStateLookup); | 2449 DISALLOW_COPY_AND_ASSIGN(AlwaysMouseDownInputStateLookup); |
| 2450 }; | 2450 }; |
| 2451 | 2451 |
| 2452 TEST_F(WindowEventDispatcherTest, | 2452 TEST_P(WindowEventDispatcherTest, |
| 2453 CursorVisibilityChangedWhileCaptureWindowInAnotherDispatcher) { | 2453 CursorVisibilityChangedWhileCaptureWindowInAnotherDispatcher) { |
| 2454 test::EventCountDelegate delegate; | 2454 test::EventCountDelegate delegate; |
| 2455 std::unique_ptr<Window> window(CreateTestWindowWithDelegate( | 2455 std::unique_ptr<Window> window(CreateTestWindowWithDelegate( |
| 2456 &delegate, 123, gfx::Rect(20, 10, 10, 20), root_window())); | 2456 &delegate, 123, gfx::Rect(20, 10, 10, 20), root_window())); |
| 2457 window->Show(); | 2457 window->Show(); |
| 2458 | 2458 |
| 2459 std::unique_ptr<WindowTreeHost> second_host( | 2459 std::unique_ptr<WindowTreeHost> second_host( |
| 2460 WindowTreeHost::Create(gfx::Rect(20, 30, 100, 50))); | 2460 WindowTreeHost::Create(gfx::Rect(20, 30, 100, 50))); |
| 2461 second_host->InitHost(); | 2461 second_host->InitHost(); |
| 2462 WindowEventDispatcher* second_dispatcher = second_host->dispatcher(); | 2462 WindowEventDispatcher* second_dispatcher = second_host->dispatcher(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 2487 // Reset the mouse-event counts for |window|. | 2487 // Reset the mouse-event counts for |window|. |
| 2488 delegate.GetMouseMotionCountsAndReset(); | 2488 delegate.GetMouseMotionCountsAndReset(); |
| 2489 | 2489 |
| 2490 // Notify both hosts that the cursor is now hidden. This should send a single | 2490 // Notify both hosts that the cursor is now hidden. This should send a single |
| 2491 // mouse-exit event to |window|. | 2491 // mouse-exit event to |window|. |
| 2492 host()->OnCursorVisibilityChanged(false); | 2492 host()->OnCursorVisibilityChanged(false); |
| 2493 second_host->OnCursorVisibilityChanged(false); | 2493 second_host->OnCursorVisibilityChanged(false); |
| 2494 EXPECT_EQ("0 0 1", delegate.GetMouseMotionCountsAndReset()); | 2494 EXPECT_EQ("0 0 1", delegate.GetMouseMotionCountsAndReset()); |
| 2495 } | 2495 } |
| 2496 | 2496 |
| 2497 TEST_F(WindowEventDispatcherTest, | 2497 TEST_P(WindowEventDispatcherTest, |
| 2498 RedirectedEventToDifferentDispatcherLocation) { | 2498 RedirectedEventToDifferentDispatcherLocation) { |
| 2499 std::unique_ptr<WindowTreeHost> second_host( | 2499 std::unique_ptr<WindowTreeHost> second_host( |
| 2500 WindowTreeHost::Create(gfx::Rect(20, 30, 100, 50))); | 2500 WindowTreeHost::Create(gfx::Rect(20, 30, 100, 50))); |
| 2501 second_host->InitHost(); | 2501 second_host->InitHost(); |
| 2502 client::SetCaptureClient(second_host->window(), | 2502 client::SetCaptureClient(second_host->window(), |
| 2503 client::GetCaptureClient(root_window())); | 2503 client::GetCaptureClient(root_window())); |
| 2504 | 2504 |
| 2505 test::EventCountDelegate delegate; | 2505 test::EventCountDelegate delegate; |
| 2506 std::unique_ptr<Window> window_first(CreateTestWindowWithDelegate( | 2506 std::unique_ptr<Window> window_first(CreateTestWindowWithDelegate( |
| 2507 &delegate, 123, gfx::Rect(20, 10, 10, 20), root_window())); | 2507 &delegate, 123, gfx::Rect(20, 10, 10, 20), root_window())); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2552 } | 2552 } |
| 2553 | 2553 |
| 2554 WindowEventDispatcher* dispatcher_; | 2554 WindowEventDispatcher* dispatcher_; |
| 2555 Window* window_; | 2555 Window* window_; |
| 2556 | 2556 |
| 2557 DISALLOW_COPY_AND_ASSIGN(AsyncWindowDelegate); | 2557 DISALLOW_COPY_AND_ASSIGN(AsyncWindowDelegate); |
| 2558 }; | 2558 }; |
| 2559 | 2559 |
| 2560 // Tests that gesture events dispatched through the asynchronous flow have | 2560 // Tests that gesture events dispatched through the asynchronous flow have |
| 2561 // co-ordinates in the right co-ordinate space. | 2561 // co-ordinates in the right co-ordinate space. |
| 2562 TEST_F(WindowEventDispatcherTest, GestureEventCoordinates) { | 2562 TEST_P(WindowEventDispatcherTest, GestureEventCoordinates) { |
| 2563 const float kX = 67.3f; | 2563 const float kX = 67.3f; |
| 2564 const float kY = 97.8f; | 2564 const float kY = 97.8f; |
| 2565 | 2565 |
| 2566 const int kWindowOffset = 50; | 2566 const int kWindowOffset = 50; |
| 2567 EventFilterRecorder recorder; | 2567 EventFilterRecorder recorder; |
| 2568 root_window()->AddPreTargetHandler(&recorder); | 2568 root_window()->AddPreTargetHandler(&recorder); |
| 2569 AsyncWindowDelegate delegate(host()->dispatcher()); | 2569 AsyncWindowDelegate delegate(host()->dispatcher()); |
| 2570 HoldPointerOnScrollHandler handler(host()->dispatcher(), &recorder); | 2570 HoldPointerOnScrollHandler handler(host()->dispatcher(), &recorder); |
| 2571 std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 2571 std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 2572 &delegate, 1, gfx::Rect(kWindowOffset, kWindowOffset, 100, 100), | 2572 &delegate, 1, gfx::Rect(kWindowOffset, kWindowOffset, 100, 100), |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2586 EXPECT_EQ(gfx::Point(kX - kWindowOffset, kY - kWindowOffset).ToString(), | 2586 EXPECT_EQ(gfx::Point(kX - kWindowOffset, kY - kWindowOffset).ToString(), |
| 2587 recorder.touch_locations()[0].ToString()); | 2587 recorder.touch_locations()[0].ToString()); |
| 2588 | 2588 |
| 2589 ASSERT_EQ(2u, recorder.gesture_locations().size()); | 2589 ASSERT_EQ(2u, recorder.gesture_locations().size()); |
| 2590 EXPECT_EQ(gfx::Point(kX - kWindowOffset, kY - kWindowOffset).ToString(), | 2590 EXPECT_EQ(gfx::Point(kX - kWindowOffset, kY - kWindowOffset).ToString(), |
| 2591 recorder.gesture_locations()[0].ToString()); | 2591 recorder.gesture_locations()[0].ToString()); |
| 2592 root_window()->RemovePreTargetHandler(&recorder); | 2592 root_window()->RemovePreTargetHandler(&recorder); |
| 2593 } | 2593 } |
| 2594 | 2594 |
| 2595 // Tests that a scroll-generating touch-event is marked as such. | 2595 // Tests that a scroll-generating touch-event is marked as such. |
| 2596 TEST_F(WindowEventDispatcherTest, TouchMovesMarkedWhenCausingScroll) { | 2596 TEST_P(WindowEventDispatcherTest, TouchMovesMarkedWhenCausingScroll) { |
| 2597 EventFilterRecorder recorder; | 2597 EventFilterRecorder recorder; |
| 2598 root_window()->AddPreTargetHandler(&recorder); | 2598 root_window()->AddPreTargetHandler(&recorder); |
| 2599 | 2599 |
| 2600 const gfx::Point location(20, 20); | 2600 const gfx::Point location(20, 20); |
| 2601 ui::TouchEvent press( | 2601 ui::TouchEvent press( |
| 2602 ui::ET_TOUCH_PRESSED, location, 0, ui::EventTimeForNow()); | 2602 ui::ET_TOUCH_PRESSED, location, 0, ui::EventTimeForNow()); |
| 2603 DispatchEventUsingWindowDispatcher(&press); | 2603 DispatchEventUsingWindowDispatcher(&press); |
| 2604 EXPECT_FALSE(recorder.LastTouchMayCauseScrolling()); | 2604 EXPECT_FALSE(recorder.LastTouchMayCauseScrolling()); |
| 2605 EXPECT_TRUE(recorder.HasReceivedEvent(ui::ET_TOUCH_PRESSED)); | 2605 EXPECT_TRUE(recorder.HasReceivedEvent(ui::ET_TOUCH_PRESSED)); |
| 2606 recorder.Reset(); | 2606 recorder.Reset(); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 2635 EXPECT_TRUE(recorder.HasReceivedEvent(ui::ET_TOUCH_RELEASED)); | 2635 EXPECT_TRUE(recorder.HasReceivedEvent(ui::ET_TOUCH_RELEASED)); |
| 2636 EXPECT_TRUE(recorder.HasReceivedEvent(ui::ET_GESTURE_SCROLL_END)); | 2636 EXPECT_TRUE(recorder.HasReceivedEvent(ui::ET_GESTURE_SCROLL_END)); |
| 2637 | 2637 |
| 2638 root_window()->RemovePreTargetHandler(&recorder); | 2638 root_window()->RemovePreTargetHandler(&recorder); |
| 2639 } | 2639 } |
| 2640 | 2640 |
| 2641 // OnCursorMovedToRootLocation() is sometimes called instead of | 2641 // OnCursorMovedToRootLocation() is sometimes called instead of |
| 2642 // WindowTreeHost::MoveCursorTo() when the cursor did not move but the | 2642 // WindowTreeHost::MoveCursorTo() when the cursor did not move but the |
| 2643 // cursor's position in root coordinates has changed (e.g. when the displays's | 2643 // cursor's position in root coordinates has changed (e.g. when the displays's |
| 2644 // scale factor changed). Test that hover effects are properly updated. | 2644 // scale factor changed). Test that hover effects are properly updated. |
| 2645 TEST_F(WindowEventDispatcherTest, OnCursorMovedToRootLocationUpdatesHover) { | 2645 TEST_P(WindowEventDispatcherTest, OnCursorMovedToRootLocationUpdatesHover) { |
| 2646 WindowEventDispatcher* dispatcher = host()->dispatcher(); | 2646 WindowEventDispatcher* dispatcher = host()->dispatcher(); |
| 2647 | 2647 |
| 2648 std::unique_ptr<Window> w(CreateNormalWindow(1, root_window(), nullptr)); | 2648 std::unique_ptr<Window> w(CreateNormalWindow(1, root_window(), nullptr)); |
| 2649 w->SetBounds(gfx::Rect(20, 20, 20, 20)); | 2649 w->SetBounds(gfx::Rect(20, 20, 20, 20)); |
| 2650 w->Show(); | 2650 w->Show(); |
| 2651 | 2651 |
| 2652 // Move the cursor off of |w|. | 2652 // Move the cursor off of |w|. |
| 2653 dispatcher->OnCursorMovedToRootLocation(gfx::Point(100, 100)); | 2653 dispatcher->OnCursorMovedToRootLocation(gfx::Point(100, 100)); |
| 2654 | 2654 |
| 2655 EventFilterRecorder recorder; | 2655 EventFilterRecorder recorder; |
| 2656 w->AddPreTargetHandler(&recorder); | 2656 w->AddPreTargetHandler(&recorder); |
| 2657 dispatcher->OnCursorMovedToRootLocation(gfx::Point(22, 22)); | 2657 dispatcher->OnCursorMovedToRootLocation(gfx::Point(22, 22)); |
| 2658 RunAllPendingInMessageLoop(); | 2658 RunAllPendingInMessageLoop(); |
| 2659 EXPECT_TRUE(recorder.HasReceivedEvent(ui::ET_MOUSE_ENTERED)); | 2659 EXPECT_TRUE(recorder.HasReceivedEvent(ui::ET_MOUSE_ENTERED)); |
| 2660 recorder.Reset(); | 2660 recorder.Reset(); |
| 2661 | 2661 |
| 2662 // The cursor should not be over |w| after changing the device scale factor to | 2662 // The cursor should not be over |w| after changing the device scale factor to |
| 2663 // 2x. A ET_MOUSE_EXITED event should have been sent to |w|. | 2663 // 2x. A ET_MOUSE_EXITED event should have been sent to |w|. |
| 2664 test_screen()->SetDeviceScaleFactor(2.f); | 2664 test_screen()->SetDeviceScaleFactor(2.f); |
| 2665 dispatcher->OnCursorMovedToRootLocation(gfx::Point(11, 11)); | 2665 dispatcher->OnCursorMovedToRootLocation(gfx::Point(11, 11)); |
| 2666 RunAllPendingInMessageLoop(); | 2666 RunAllPendingInMessageLoop(); |
| 2667 EXPECT_TRUE(recorder.HasReceivedEvent(ui::ET_MOUSE_EXITED)); | 2667 EXPECT_TRUE(recorder.HasReceivedEvent(ui::ET_MOUSE_EXITED)); |
| 2668 | 2668 |
| 2669 w->RemovePreTargetHandler(&recorder); | 2669 w->RemovePreTargetHandler(&recorder); |
| 2670 } | 2670 } |
| 2671 | 2671 |
| 2672 INSTANTIATE_TEST_CASE_P(/* no prefix */, |
| 2673 WindowEventDispatcherTest, |
| 2674 ::testing::Values(test::BackendType::CLASSIC, |
| 2675 test::BackendType::MUS)); |
| 2676 |
| 2677 INSTANTIATE_TEST_CASE_P(/* no prefix */, |
| 2678 WindowEventDispatcherTestWithMessageLoop, |
| 2679 ::testing::Values(test::BackendType::CLASSIC, |
| 2680 test::BackendType::MUS)); |
| 2681 |
| 2682 INSTANTIATE_TEST_CASE_P(/* no prefix */, |
| 2683 WindowEventDispatcherTestInHighDPI, |
| 2684 ::testing::Values(test::BackendType::CLASSIC, |
| 2685 test::BackendType::MUS)); |
| 2686 |
| 2672 } // namespace aura | 2687 } // namespace aura |
| OLD | NEW |