| 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/wm/core/accelerator_filter.h" | 5 #include "ui/wm/core/accelerator_filter.h" |
| 6 | 6 |
| 7 #include "ash/accelerators/accelerator_controller.h" | 7 #include "ash/accelerators/accelerator_controller.h" |
| 8 #include "ash/accelerators/accelerator_delegate.h" | 8 #include "ash/accelerators/accelerator_delegate.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/shell_window_ids.h" | 10 #include "ash/shell_window_ids.h" |
| 11 #include "ash/test/ash_test_base.h" | 11 #include "ash/test/ash_test_base.h" |
| 12 #include "ash/test/test_screenshot_delegate.h" | 12 #include "ash/test/test_screenshot_delegate.h" |
| 13 #include "ash/wm/window_state.h" | 13 #include "ash/wm/window_state.h" |
| 14 #include "ash/wm/window_util.h" | 14 #include "ash/wm/window_util.h" |
| 15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 17 #include "ui/aura/test/aura_test_base.h" | 17 #include "ui/aura/test/aura_test_base.h" |
| 18 #include "ui/aura/test/test_windows.h" | 18 #include "ui/aura/test/test_windows.h" |
| 19 #include "ui/aura/window.h" | 19 #include "ui/aura/window.h" |
| 20 #include "ui/base/accelerators/accelerator_history.h" | 20 #include "ui/base/accelerators/accelerator_history.h" |
| 21 #include "ui/events/event.h" | 21 #include "ui/events/event.h" |
| 22 #include "ui/events/event_utils.h" | |
| 23 #include "ui/events/test/event_generator.h" | 22 #include "ui/events/test/event_generator.h" |
| 24 #include "ui/gfx/geometry/rect.h" | 23 #include "ui/gfx/geometry/rect.h" |
| 25 | 24 |
| 26 namespace ash { | 25 namespace ash { |
| 27 namespace test { | 26 namespace test { |
| 28 | 27 |
| 29 typedef AshTestBase AcceleratorFilterTest; | 28 typedef AshTestBase AcceleratorFilterTest; |
| 30 | 29 |
| 31 // Tests if AcceleratorFilter works without a focused window. | 30 // Tests if AcceleratorFilter works without a focused window. |
| 32 TEST_F(AcceleratorFilterTest, TestFilterWithoutFocus) { | 31 TEST_F(AcceleratorFilterTest, TestFilterWithoutFocus) { |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 // System keys pass through to a child window if the parent (top level) | 127 // System keys pass through to a child window if the parent (top level) |
| 129 // window has the property set. | 128 // window has the property set. |
| 130 scoped_ptr<aura::Window> child(CreateTestWindowInShellWithId(2)); | 129 scoped_ptr<aura::Window> child(CreateTestWindowInShellWithId(2)); |
| 131 window->AddChild(child.get()); | 130 window->AddChild(child.get()); |
| 132 dispatch_helper.set_target(child.get()); | 131 dispatch_helper.set_target(child.get()); |
| 133 filter.OnKeyEvent(&press_volume_up); | 132 filter.OnKeyEvent(&press_volume_up); |
| 134 EXPECT_FALSE(press_volume_up.stopped_propagation()); | 133 EXPECT_FALSE(press_volume_up.stopped_propagation()); |
| 135 } | 134 } |
| 136 #endif // defined(OS_CHROMEOS) | 135 #endif // defined(OS_CHROMEOS) |
| 137 | 136 |
| 138 // Tests that pressing 'SEARCH' + LeftMouseClick, which will be rewritten as a | |
| 139 // RightMouseClick, will not toggle the AppList. | |
| 140 // This test will fail without the code to clear the current accelerator in | |
| 141 // the accelerator history present in |AcceleratorFilter::OnMouseEvent()|. | |
| 142 TEST_F(AcceleratorFilterTest, SearchClickDoesntToggleAppList) { | |
| 143 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | |
| 144 | |
| 145 EXPECT_FALSE(ash::Shell::GetInstance()->GetAppListTargetVisibility()); | |
| 146 generator.PressKey(ui::VKEY_LWIN, 0); | |
| 147 generator.ClickLeftButton(); | |
| 148 generator.ReleaseKey(ui::VKEY_LWIN, 0); | |
| 149 EXPECT_FALSE(ash::Shell::GetInstance()->GetAppListTargetVisibility()); | |
| 150 } | |
| 151 | |
| 152 // Make sure that synthesized mouse events don't interfere with tracking | |
| 153 // the key accelerators. | |
| 154 TEST_F(AcceleratorFilterTest, SynthesizeMouseEventsAreIgnored) { | |
| 155 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | |
| 156 const gfx::Point origin(0, 0); | |
| 157 | |
| 158 EXPECT_FALSE(ash::Shell::GetInstance()->GetAppListTargetVisibility()); | |
| 159 generator.PressKey(ui::VKEY_LWIN, 0); | |
| 160 ui::MouseEvent mouse_event(ui::ET_MOUSE_MOVED, origin, origin, | |
| 161 ui::EventTimeForNow(), ui::EF_IS_SYNTHESIZED, 0); | |
| 162 generator.Dispatch(&mouse_event); | |
| 163 generator.ReleaseKey(ui::VKEY_LWIN, 0); | |
| 164 EXPECT_TRUE(ash::Shell::GetInstance()->GetAppListTargetVisibility()); | |
| 165 } | |
| 166 | |
| 167 } // namespace test | 137 } // namespace test |
| 168 } // namespace ash | 138 } // namespace ash |
| OLD | NEW |