OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/accelerators/magnifier_key_scroller.h" | 5 #include "ash/accelerators/magnifier_key_scroller.h" |
6 | 6 |
7 #include "ash/magnifier/magnification_controller.h" | 7 #include "ash/magnifier/magnification_controller.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "ash/test/ash_test_base.h" | 9 #include "ash/test/ash_test_base.h" |
10 #include "ash/wm/window_util.h" | 10 #include "ash/wm/window_util.h" |
11 #include "ui/aura/test/event_generator.h" | |
12 #include "ui/aura/test/test_window_delegate.h" | 11 #include "ui/aura/test/test_window_delegate.h" |
| 12 #include "ui/events/test/event_generator.h" |
13 | 13 |
14 namespace ash { | 14 namespace ash { |
15 namespace { | 15 namespace { |
16 | 16 |
17 class KeyEventDelegate : public aura::test::TestWindowDelegate { | 17 class KeyEventDelegate : public aura::test::TestWindowDelegate { |
18 public: | 18 public: |
19 KeyEventDelegate() {} | 19 KeyEventDelegate() {} |
20 virtual ~KeyEventDelegate() {} | 20 virtual ~KeyEventDelegate() {} |
21 | 21 |
22 // ui::EventHandler overrides: | 22 // ui::EventHandler overrides: |
(...skipping 22 matching lines...) Expand all Loading... |
45 0, | 45 0, |
46 gfx::Rect(10, 10, 100, 100))); | 46 gfx::Rect(10, 10, 100, 100))); |
47 wm::ActivateWindow(window.get()); | 47 wm::ActivateWindow(window.get()); |
48 | 48 |
49 MagnifierKeyScroller::ScopedEnablerForTest scoped; | 49 MagnifierKeyScroller::ScopedEnablerForTest scoped; |
50 Shell* shell = Shell::GetInstance(); | 50 Shell* shell = Shell::GetInstance(); |
51 MagnificationController* controller = shell->magnification_controller(); | 51 MagnificationController* controller = shell->magnification_controller(); |
52 controller->SetEnabled(true); | 52 controller->SetEnabled(true); |
53 | 53 |
54 EXPECT_EQ("200,150", controller->GetWindowPosition().ToString()); | 54 EXPECT_EQ("200,150", controller->GetWindowPosition().ToString()); |
55 aura::test::EventGenerator& generator = GetEventGenerator(); | 55 ui::test::EventGenerator& generator = GetEventGenerator(); |
56 | 56 |
57 // Click and Release generates the press event upon release. | 57 // Click and Release generates the press event upon release. |
58 generator.PressKey(ui::VKEY_DOWN, ui::EF_SHIFT_DOWN); | 58 generator.PressKey(ui::VKEY_DOWN, ui::EF_SHIFT_DOWN); |
59 EXPECT_EQ("200,150", controller->GetWindowPosition().ToString()); | 59 EXPECT_EQ("200,150", controller->GetWindowPosition().ToString()); |
60 EXPECT_FALSE(delegate.event()); | 60 EXPECT_FALSE(delegate.event()); |
61 | 61 |
62 generator.ReleaseKey(ui::VKEY_DOWN, 0); | 62 generator.ReleaseKey(ui::VKEY_DOWN, 0); |
63 EXPECT_EQ("200,150", controller->GetWindowPosition().ToString()); | 63 EXPECT_EQ("200,150", controller->GetWindowPosition().ToString()); |
64 RunAllPendingInMessageLoop(); | 64 RunAllPendingInMessageLoop(); |
65 EXPECT_TRUE(delegate.event()); | 65 EXPECT_TRUE(delegate.event()); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 EXPECT_EQ(ui::ET_KEY_PRESSED, delegate.event()->type()); | 102 EXPECT_EQ(ui::ET_KEY_PRESSED, delegate.event()->type()); |
103 delegate.reset(); | 103 delegate.reset(); |
104 | 104 |
105 generator.ReleaseKey(ui::VKEY_DOWN, 0); | 105 generator.ReleaseKey(ui::VKEY_DOWN, 0); |
106 EXPECT_TRUE(delegate.event()); | 106 EXPECT_TRUE(delegate.event()); |
107 EXPECT_EQ(ui::ET_KEY_RELEASED, delegate.event()->type()); | 107 EXPECT_EQ(ui::ET_KEY_RELEASED, delegate.event()->type()); |
108 delegate.reset(); | 108 delegate.reset(); |
109 } | 109 } |
110 | 110 |
111 } // namespace ash | 111 } // namespace ash |
OLD | NEW |