Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Side by Side Diff: ash/accelerators/accelerator_filter_unittest.cc

Issue 1117173003: Converting (Alt+LeftClick -> RightClick) to (Search+LeftClick -> RightClick) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added a test case for ignoring synthesized mouse events. Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/chromeos/events/event_rewriter.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
22 #include "ui/events/test/event_generator.h" 23 #include "ui/events/test/event_generator.h"
23 #include "ui/gfx/geometry/rect.h" 24 #include "ui/gfx/geometry/rect.h"
24 25
25 namespace ash { 26 namespace ash {
26 namespace test { 27 namespace test {
27 28
28 typedef AshTestBase AcceleratorFilterTest; 29 typedef AshTestBase AcceleratorFilterTest;
29 30
30 // Tests if AcceleratorFilter works without a focused window. 31 // Tests if AcceleratorFilter works without a focused window.
31 TEST_F(AcceleratorFilterTest, TestFilterWithoutFocus) { 32 TEST_F(AcceleratorFilterTest, TestFilterWithoutFocus) {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 // System keys pass through to a child window if the parent (top level) 128 // System keys pass through to a child window if the parent (top level)
128 // window has the property set. 129 // window has the property set.
129 scoped_ptr<aura::Window> child(CreateTestWindowInShellWithId(2)); 130 scoped_ptr<aura::Window> child(CreateTestWindowInShellWithId(2));
130 window->AddChild(child.get()); 131 window->AddChild(child.get());
131 dispatch_helper.set_target(child.get()); 132 dispatch_helper.set_target(child.get());
132 filter.OnKeyEvent(&press_volume_up); 133 filter.OnKeyEvent(&press_volume_up);
133 EXPECT_FALSE(press_volume_up.stopped_propagation()); 134 EXPECT_FALSE(press_volume_up.stopped_propagation());
134 } 135 }
135 #endif // defined(OS_CHROMEOS) 136 #endif // defined(OS_CHROMEOS)
136 137
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
137 } // namespace test 167 } // namespace test
138 } // namespace ash 168 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/events/event_rewriter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698