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/display/display_manager.h" | 7 #include "ash/display/display_manager.h" |
8 #include "ash/display/window_tree_host_manager.h" | 8 #include "ash/display/window_tree_host_manager.h" |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "ash/sticky_keys/sticky_keys_controller.h" | 10 #include "ash/sticky_keys/sticky_keys_controller.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 // This test addresses the crash report at crbug.com/435600, speculated to be | 45 // This test addresses the crash report at crbug.com/435600, speculated to be |
46 // caused by using sticky keys with multiple displays. | 46 // caused by using sticky keys with multiple displays. |
47 TEST_F(StickyKeysOverlayTest, OverlayNotDestroyedAfterDisplayRemoved) { | 47 TEST_F(StickyKeysOverlayTest, OverlayNotDestroyedAfterDisplayRemoved) { |
48 // Add a secondary display to the left of the primary one. | 48 // Add a secondary display to the left of the primary one. |
49 UpdateDisplay("1280x1024,1980x1080"); | 49 UpdateDisplay("1280x1024,1980x1080"); |
50 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 50 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
51 display::DisplayIdList display_ids = | 51 display::DisplayIdList display_ids = |
52 display_manager->GetCurrentDisplayIdList(); | 52 display_manager->GetCurrentDisplayIdList(); |
53 int64_t primary_display_id = display_ids[0]; | 53 int64_t primary_display_id = display_ids[0]; |
54 int64_t secondary_display_id = display_ids[1]; | 54 int64_t secondary_display_id = display_ids[1]; |
55 display_manager->SetLayoutForCurrentDisplays( | 55 display_manager->SetLayoutForCurrentDisplays(test::CreateDisplayLayout( |
56 test::CreateDisplayLayout(display::DisplayPlacement::LEFT, 0)); | 56 display_manager, display::DisplayPlacement::LEFT, 0)); |
57 | 57 |
58 // The overlay should belong to the secondary root window. | 58 // The overlay should belong to the secondary root window. |
59 StickyKeysOverlay overlay; | 59 StickyKeysOverlay overlay; |
60 views::Widget* overlay_widget = overlay.GetWidgetForTesting(); | 60 views::Widget* overlay_widget = overlay.GetWidgetForTesting(); |
61 WindowTreeHostManager* window_tree_host_manager = | 61 WindowTreeHostManager* window_tree_host_manager = |
62 Shell::GetInstance()->window_tree_host_manager(); | 62 Shell::GetInstance()->window_tree_host_manager(); |
63 EXPECT_EQ( | 63 EXPECT_EQ( |
64 window_tree_host_manager->GetRootWindowForDisplayId(secondary_display_id), | 64 window_tree_host_manager->GetRootWindowForDisplayId(secondary_display_id), |
65 overlay_widget->GetNativeWindow()->GetRootWindow()); | 65 overlay_widget->GetNativeWindow()->GetRootWindow()); |
66 | 66 |
67 // Removing the second display should move the overlay to the primary root | 67 // Removing the second display should move the overlay to the primary root |
68 // window. | 68 // window. |
69 UpdateDisplay("1280x1024"); | 69 UpdateDisplay("1280x1024"); |
70 EXPECT_EQ( | 70 EXPECT_EQ( |
71 window_tree_host_manager->GetRootWindowForDisplayId(primary_display_id), | 71 window_tree_host_manager->GetRootWindowForDisplayId(primary_display_id), |
72 overlay_widget->GetNativeWindow()->GetRootWindow()); | 72 overlay_widget->GetNativeWindow()->GetRootWindow()); |
73 | 73 |
74 overlay.SetModifierKeyState(ui::EF_SHIFT_DOWN, STICKY_KEY_STATE_ENABLED); | 74 overlay.SetModifierKeyState(ui::EF_SHIFT_DOWN, STICKY_KEY_STATE_ENABLED); |
75 EXPECT_EQ(STICKY_KEY_STATE_ENABLED, | 75 EXPECT_EQ(STICKY_KEY_STATE_ENABLED, |
76 overlay.GetModifierKeyState(ui::EF_SHIFT_DOWN)); | 76 overlay.GetModifierKeyState(ui::EF_SHIFT_DOWN)); |
77 overlay.SetModifierKeyState(ui::EF_SHIFT_DOWN, STICKY_KEY_STATE_DISABLED); | 77 overlay.SetModifierKeyState(ui::EF_SHIFT_DOWN, STICKY_KEY_STATE_DISABLED); |
78 EXPECT_EQ(STICKY_KEY_STATE_DISABLED, | 78 EXPECT_EQ(STICKY_KEY_STATE_DISABLED, |
79 overlay.GetModifierKeyState(ui::EF_SHIFT_DOWN)); | 79 overlay.GetModifierKeyState(ui::EF_SHIFT_DOWN)); |
80 } | 80 } |
81 | 81 |
82 // Additional sticky key overlay tests that depend on chromeos::EventRewriter | 82 // Additional sticky key overlay tests that depend on chromeos::EventRewriter |
83 // are now in chrome/browser/chromeos/events/event_rewriter_unittest.cc . | 83 // are now in chrome/browser/chromeos/events/event_rewriter_unittest.cc . |
84 | 84 |
85 } // namespace ash | 85 } // namespace ash |
OLD | NEW |