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/sticky_keys/sticky_keys_overlay.h" | 5 #include "ash/sticky_keys/sticky_keys_overlay.h" |
6 | 6 |
| 7 #include "ash/public/cpp/config.h" |
7 #include "ash/shell.h" | 8 #include "ash/shell.h" |
8 #include "ash/shell_port.h" | 9 #include "ash/shell_port.h" |
9 #include "ash/sticky_keys/sticky_keys_controller.h" | 10 #include "ash/sticky_keys/sticky_keys_controller.h" |
10 #include "ash/test/ash_test_base.h" | 11 #include "ash/test/ash_test_base.h" |
11 #include "ash/wm_window.h" | 12 #include "ash/wm_window.h" |
12 #include "ui/display/display_layout.h" | 13 #include "ui/display/display_layout.h" |
13 #include "ui/display/manager/display_manager.h" | 14 #include "ui/display/manager/display_manager.h" |
14 #include "ui/display/test/display_manager_test_api.h" | 15 #include "ui/display/test/display_manager_test_api.h" |
15 #include "ui/events/event.h" | 16 #include "ui/events/event.h" |
16 #include "ui/views/widget/widget.h" | 17 #include "ui/views/widget/widget.h" |
(...skipping 23 matching lines...) Expand all Loading... |
40 EXPECT_EQ(STICKY_KEY_STATE_ENABLED, | 41 EXPECT_EQ(STICKY_KEY_STATE_ENABLED, |
41 overlay.GetModifierKeyState(ui::EF_CONTROL_DOWN)); | 42 overlay.GetModifierKeyState(ui::EF_CONTROL_DOWN)); |
42 EXPECT_EQ(STICKY_KEY_STATE_LOCKED, | 43 EXPECT_EQ(STICKY_KEY_STATE_LOCKED, |
43 overlay.GetModifierKeyState(ui::EF_COMMAND_DOWN)); | 44 overlay.GetModifierKeyState(ui::EF_COMMAND_DOWN)); |
44 } | 45 } |
45 | 46 |
46 // This test addresses the crash report at crbug.com/435600, speculated to be | 47 // This test addresses the crash report at crbug.com/435600, speculated to be |
47 // caused by using sticky keys with multiple displays. | 48 // caused by using sticky keys with multiple displays. |
48 TEST_F(StickyKeysOverlayTest, OverlayNotDestroyedAfterDisplayRemoved) { | 49 TEST_F(StickyKeysOverlayTest, OverlayNotDestroyedAfterDisplayRemoved) { |
49 // TODO: investigate failure in mash, http://crbug.com/696006. | 50 // TODO: investigate failure in mash, http://crbug.com/696006. |
50 if (ShellPort::Get()->IsRunningInMash()) | 51 if (Shell::GetAshConfig() == Config::MASH) |
51 return; | 52 return; |
52 | 53 |
53 // Add a secondary display to the left of the primary one. | 54 // Add a secondary display to the left of the primary one. |
54 UpdateDisplay("1280x1024,1980x1080"); | 55 UpdateDisplay("1280x1024,1980x1080"); |
55 display::DisplayIdList display_ids = | 56 display::DisplayIdList display_ids = |
56 display_manager()->GetCurrentDisplayIdList(); | 57 display_manager()->GetCurrentDisplayIdList(); |
57 int64_t primary_display_id = display_ids[0]; | 58 int64_t primary_display_id = display_ids[0]; |
58 int64_t secondary_display_id = display_ids[1]; | 59 int64_t secondary_display_id = display_ids[1]; |
59 // TODO: disabled as ScreenRotationAnimator does not work in mash, | 60 // TODO: disabled as ScreenRotationAnimator does not work in mash, |
60 // http://crbug.com/696754. | 61 // http://crbug.com/696754. |
61 if (ShellPort::Get()->IsRunningInMash()) | 62 if (Shell::GetAshConfig() == Config::MASH) |
62 return; | 63 return; |
63 display_manager()->SetLayoutForCurrentDisplays( | 64 display_manager()->SetLayoutForCurrentDisplays( |
64 display::test::CreateDisplayLayout(display_manager(), | 65 display::test::CreateDisplayLayout(display_manager(), |
65 display::DisplayPlacement::LEFT, 0)); | 66 display::DisplayPlacement::LEFT, 0)); |
66 | 67 |
67 // The overlay should belong to the secondary root window. | 68 // The overlay should belong to the secondary root window. |
68 StickyKeysOverlay overlay; | 69 StickyKeysOverlay overlay; |
69 views::Widget* overlay_widget = overlay.GetWidgetForTesting(); | 70 views::Widget* overlay_widget = overlay.GetWidgetForTesting(); |
70 EXPECT_EQ(ShellPort::Get() | 71 EXPECT_EQ(ShellPort::Get() |
71 ->GetRootWindowForDisplayId(secondary_display_id) | 72 ->GetRootWindowForDisplayId(secondary_display_id) |
(...skipping 13 matching lines...) Expand all Loading... |
85 overlay.GetModifierKeyState(ui::EF_SHIFT_DOWN)); | 86 overlay.GetModifierKeyState(ui::EF_SHIFT_DOWN)); |
86 overlay.SetModifierKeyState(ui::EF_SHIFT_DOWN, STICKY_KEY_STATE_DISABLED); | 87 overlay.SetModifierKeyState(ui::EF_SHIFT_DOWN, STICKY_KEY_STATE_DISABLED); |
87 EXPECT_EQ(STICKY_KEY_STATE_DISABLED, | 88 EXPECT_EQ(STICKY_KEY_STATE_DISABLED, |
88 overlay.GetModifierKeyState(ui::EF_SHIFT_DOWN)); | 89 overlay.GetModifierKeyState(ui::EF_SHIFT_DOWN)); |
89 } | 90 } |
90 | 91 |
91 // Additional sticky key overlay tests that depend on ui::EventRewriterChromeOS | 92 // Additional sticky key overlay tests that depend on ui::EventRewriterChromeOS |
92 // are now in chrome/browser/chromeos/events/event_rewriter_unittest.cc . | 93 // are now in chrome/browser/chromeos/events/event_rewriter_unittest.cc . |
93 | 94 |
94 } // namespace ash | 95 } // namespace ash |
OLD | NEW |