| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ash/autoclick/autoclick_controller.h" | 5 #include "ash/autoclick/autoclick_controller.h" |
| 6 #include "ash/display/display_manager.h" |
| 6 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 7 #include "ash/test/ash_test_base.h" | 8 #include "ash/test/ash_test_base.h" |
| 8 #include "ui/aura/test/test_window_delegate.h" | 9 #include "ui/aura/test/test_window_delegate.h" |
| 9 #include "ui/aura/window.h" | 10 #include "ui/aura/window.h" |
| 10 #include "ui/aura/window_event_dispatcher.h" | 11 #include "ui/aura/window_event_dispatcher.h" |
| 11 #include "ui/events/event.h" | 12 #include "ui/events/event.h" |
| 12 #include "ui/events/event_constants.h" | 13 #include "ui/events/event_constants.h" |
| 13 #include "ui/events/event_handler.h" | 14 #include "ui/events/event_handler.h" |
| 14 #include "ui/events/event_utils.h" | 15 #include "ui/events/event_utils.h" |
| 15 #include "ui/events/keycodes/keyboard_codes.h" | 16 #include "ui/events/keycodes/keyboard_codes.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 AutoclickTest() {} | 60 AutoclickTest() {} |
| 60 ~AutoclickTest() override {} | 61 ~AutoclickTest() override {} |
| 61 | 62 |
| 62 void SetUp() override { | 63 void SetUp() override { |
| 63 test::AshTestBase::SetUp(); | 64 test::AshTestBase::SetUp(); |
| 64 Shell::GetInstance()->AddPreTargetHandler(&mouse_event_capturer_); | 65 Shell::GetInstance()->AddPreTargetHandler(&mouse_event_capturer_); |
| 65 GetAutoclickController()->SetAutoclickDelay(base::TimeDelta()); | 66 GetAutoclickController()->SetAutoclickDelay(base::TimeDelta()); |
| 66 | 67 |
| 67 // Move mouse to deterministic location at the start of each test. | 68 // Move mouse to deterministic location at the start of each test. |
| 68 GetEventGenerator().MoveMouseTo(100, 100); | 69 GetEventGenerator().MoveMouseTo(100, 100); |
| 70 |
| 71 // Make sure the display is initialized so we don't fail the test due to any |
| 72 // input events caused from creating the display. |
| 73 Shell::GetInstance()->display_manager()->UpdateDisplays(); |
| 74 RunAllPendingInMessageLoop(); |
| 69 } | 75 } |
| 70 | 76 |
| 71 void TearDown() override { | 77 void TearDown() override { |
| 72 Shell::GetInstance()->RemovePreTargetHandler(&mouse_event_capturer_); | 78 Shell::GetInstance()->RemovePreTargetHandler(&mouse_event_capturer_); |
| 73 test::AshTestBase::TearDown(); | 79 test::AshTestBase::TearDown(); |
| 74 } | 80 } |
| 75 | 81 |
| 76 void MoveMouseWithFlagsTo(int x, int y, ui::EventFlags flags) { | 82 void MoveMouseWithFlagsTo(int x, int y, ui::EventFlags flags) { |
| 77 GetEventGenerator().set_flags(flags); | 83 GetEventGenerator().set_flags(flags); |
| 78 GetEventGenerator().MoveMouseTo(x, y); | 84 GetEventGenerator().MoveMouseTo(x, y); |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 aura::test::EventCountDelegate delegate; | 283 aura::test::EventCountDelegate delegate; |
| 278 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithDelegate( | 284 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithDelegate( |
| 279 &delegate, 123, gfx::Rect(50, 50, 100, 100))); | 285 &delegate, 123, gfx::Rect(50, 50, 100, 100))); |
| 280 window->Show(); | 286 window->Show(); |
| 281 events = WaitForMouseEvents(); | 287 events = WaitForMouseEvents(); |
| 282 EXPECT_EQ(0u, events.size()); | 288 EXPECT_EQ(0u, events.size()); |
| 283 EXPECT_EQ("1 1 0", delegate.GetMouseMotionCountsAndReset()); | 289 EXPECT_EQ("1 1 0", delegate.GetMouseMotionCountsAndReset()); |
| 284 } | 290 } |
| 285 | 291 |
| 286 } // namespace ash | 292 } // namespace ash |
| OLD | NEW |