OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/aura/window_event_dispatcher.h" | 5 #include "ui/aura/window_event_dispatcher.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 2522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2533 location + gfx::Vector2dF(200, 200), | 2533 location + gfx::Vector2dF(200, 200), |
2534 0, | 2534 0, |
2535 ui::EventTimeForNow() + base::TimeDelta::FromSeconds(1)); | 2535 ui::EventTimeForNow() + base::TimeDelta::FromSeconds(1)); |
2536 DispatchEventUsingWindowDispatcher(&release); | 2536 DispatchEventUsingWindowDispatcher(&release); |
2537 EXPECT_FALSE(recorder.LastTouchMayCauseScrolling()); | 2537 EXPECT_FALSE(recorder.LastTouchMayCauseScrolling()); |
2538 EXPECT_TRUE(recorder.HasReceivedEvent(ui::ET_TOUCH_RELEASED)); | 2538 EXPECT_TRUE(recorder.HasReceivedEvent(ui::ET_TOUCH_RELEASED)); |
2539 EXPECT_TRUE(recorder.HasReceivedEvent(ui::ET_GESTURE_SCROLL_END)); | 2539 EXPECT_TRUE(recorder.HasReceivedEvent(ui::ET_GESTURE_SCROLL_END)); |
2540 | 2540 |
2541 root_window()->RemovePreTargetHandler(&recorder); | 2541 root_window()->RemovePreTargetHandler(&recorder); |
2542 } | 2542 } |
| 2543 |
| 2544 // OnCursorMovedToRootLocation() is sometimes called instead of |
| 2545 // WindowTreeHost::MoveCursorTo() when the cursor did not move but the |
| 2546 // cursor's position in root coordinates has changed (e.g. when the displays's |
| 2547 // scale factor changed). Test that hover effects are properly updated. |
| 2548 TEST_F(WindowEventDispatcherTest, OnCursorMovedToRootLocationUpdatesHover) { |
| 2549 WindowEventDispatcher* dispatcher = host()->dispatcher(); |
| 2550 |
| 2551 scoped_ptr<Window> w(CreateNormalWindow(1, root_window(), nullptr)); |
| 2552 w->SetBounds(gfx::Rect(20, 20, 20, 20)); |
| 2553 w->Show(); |
| 2554 |
| 2555 // Move the cursor off of |w|. |
| 2556 dispatcher->OnCursorMovedToRootLocation(gfx::Point(100, 100)); |
| 2557 |
| 2558 EventFilterRecorder recorder; |
| 2559 w->AddPreTargetHandler(&recorder); |
| 2560 dispatcher->OnCursorMovedToRootLocation(gfx::Point(22, 22)); |
| 2561 RunAllPendingInMessageLoop(); |
| 2562 EXPECT_TRUE(recorder.HasReceivedEvent(ui::ET_MOUSE_ENTERED)); |
| 2563 recorder.Reset(); |
| 2564 |
| 2565 // The cursor should not be over |w| after changing the device scale factor to |
| 2566 // 2x. A ET_MOUSE_EXITED event should have been sent to |w|. |
| 2567 test_screen()->SetDeviceScaleFactor(2.f); |
| 2568 dispatcher->OnCursorMovedToRootLocation(gfx::Point(11, 11)); |
| 2569 RunAllPendingInMessageLoop(); |
| 2570 EXPECT_TRUE(recorder.HasReceivedEvent(ui::ET_MOUSE_EXITED)); |
| 2571 |
| 2572 w->RemovePreTargetHandler(&recorder); |
| 2573 } |
| 2574 |
2543 } // namespace aura | 2575 } // namespace aura |
OLD | NEW |