OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/accelerator_controller.h" | 5 #include "ash/accelerators/accelerator_controller.h" |
| 6 #include "ash/ime/event.h" |
6 #include "ash/shell.h" | 7 #include "ash/shell.h" |
7 #include "ash/shell_window_ids.h" | 8 #include "ash/shell_window_ids.h" |
8 #include "ash/test/aura_shell_test_base.h" | 9 #include "ash/test/aura_shell_test_base.h" |
9 #include "ash/wm/window_util.h" | 10 #include "ash/wm/window_util.h" |
10 #include "ui/aura/event.h" | 11 #include "ui/aura/event.h" |
11 #include "ui/aura/root_window.h" | 12 #include "ui/aura/root_window.h" |
12 #include "ui/aura/test/test_window_delegate.h" | 13 #include "ui/aura/test/test_window_delegate.h" |
13 #include "ui/aura/test/test_windows.h" | 14 #include "ui/aura/test/test_windows.h" |
14 #include "ui/aura/window.h" | 15 #include "ui/aura/window.h" |
15 | 16 |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 default_container); | 154 default_container); |
154 ActivateWindow(window); | 155 ActivateWindow(window); |
155 | 156 |
156 const ui::Accelerator accelerator_a(ui::VKEY_A, false, false, false); | 157 const ui::Accelerator accelerator_a(ui::VKEY_A, false, false, false); |
157 TestTarget target; | 158 TestTarget target; |
158 GetController()->Register(accelerator_a, &target); | 159 GetController()->Register(accelerator_a, &target); |
159 | 160 |
160 // The accelerator is processed only once. | 161 // The accelerator is processed only once. |
161 #if defined(OS_WIN) | 162 #if defined(OS_WIN) |
162 MSG msg1 = { NULL, WM_KEYDOWN, ui::VKEY_A, 0 }; | 163 MSG msg1 = { NULL, WM_KEYDOWN, ui::VKEY_A, 0 }; |
163 aura::KeyEvent key_event1(msg1, false); | 164 TranslatedKeyEvent key_event1(msg1, false); |
164 EXPECT_TRUE(aura::RootWindow::GetInstance()->DispatchKeyEvent(&key_event1)); | 165 EXPECT_TRUE(aura::RootWindow::GetInstance()->DispatchKeyEvent(&key_event1)); |
165 | 166 |
166 MSG msg2 = { NULL, WM_CHAR, L'A', 0 }; | 167 MSG msg2 = { NULL, WM_CHAR, L'A', 0 }; |
167 aura::KeyEvent key_event2(msg2, true); | 168 TranslatedKeyEvent key_event2(msg2, true); |
168 EXPECT_FALSE(aura::RootWindow::GetInstance()->DispatchKeyEvent(&key_event2)); | 169 EXPECT_FALSE(aura::RootWindow::GetInstance()->DispatchKeyEvent(&key_event2)); |
169 | 170 |
170 MSG msg3 = { NULL, WM_KEYUP, ui::VKEY_A, 0 }; | 171 MSG msg3 = { NULL, WM_KEYUP, ui::VKEY_A, 0 }; |
171 aura::KeyEvent key_event3(msg3, false); | 172 TranslatedKeyEvent key_event3(msg3, false); |
172 EXPECT_FALSE(aura::RootWindow::GetInstance()->DispatchKeyEvent(&key_event3)); | 173 EXPECT_FALSE(aura::RootWindow::GetInstance()->DispatchKeyEvent(&key_event3)); |
173 #elif defined(USE_X11) | 174 #elif defined(USE_X11) |
174 XEvent key_event; | 175 XEvent key_event; |
175 ui::InitXKeyEventForTesting(ui::ET_KEY_PRESSED, | 176 ui::InitXKeyEventForTesting(ui::ET_KEY_PRESSED, |
176 ui::VKEY_A, | 177 ui::VKEY_A, |
177 0, | 178 0, |
178 &key_event); | 179 &key_event); |
179 EXPECT_TRUE(aura::RootWindow::GetInstance()->GetDispatcher()->Dispatch( | 180 TranslatedKeyEvent key_event1(&key_event, false); |
180 &key_event)); | 181 EXPECT_TRUE(aura::RootWindow::GetInstance()->DispatchKeyEvent(&key_event1)); |
| 182 |
| 183 TranslatedKeyEvent key_event2(&key_event, true); |
| 184 EXPECT_FALSE(aura::RootWindow::GetInstance()->DispatchKeyEvent(&key_event2)); |
| 185 |
| 186 ui::InitXKeyEventForTesting(ui::ET_KEY_RELEASED, |
| 187 ui::VKEY_A, |
| 188 0, |
| 189 &key_event); |
| 190 TranslatedKeyEvent key_event3(&key_event, false); |
| 191 EXPECT_FALSE(aura::RootWindow::GetInstance()->DispatchKeyEvent(&key_event3)); |
181 #endif | 192 #endif |
182 EXPECT_EQ(1, target.accelerator_pressed_count()); | 193 EXPECT_EQ(1, target.accelerator_pressed_count()); |
183 } | 194 } |
184 #endif | 195 #endif |
185 | 196 |
186 TEST_F(AcceleratorControllerTest, GlobalAccelerators) { | 197 TEST_F(AcceleratorControllerTest, GlobalAccelerators) { |
187 // A focused window must exist for accelerators to be processed. | 198 // A focused window must exist for accelerators to be processed. |
188 aura::Window* default_container = | 199 aura::Window* default_container = |
189 ash::Shell::GetInstance()->GetContainer( | 200 ash::Shell::GetInstance()->GetContainer( |
190 internal::kShellWindowId_DefaultContainer); | 201 internal::kShellWindowId_DefaultContainer); |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 lock_modal_window->Show(); | 335 lock_modal_window->Show(); |
325 EXPECT_FALSE(GetController()->Process(cycle_forward)); | 336 EXPECT_FALSE(GetController()->Process(cycle_forward)); |
326 EXPECT_FALSE(GetController()->Process(cycle_backward)); | 337 EXPECT_FALSE(GetController()->Process(cycle_backward)); |
327 lock_screen_window->Hide(); | 338 lock_screen_window->Hide(); |
328 EXPECT_TRUE(GetController()->Process(cycle_forward)); | 339 EXPECT_TRUE(GetController()->Process(cycle_forward)); |
329 EXPECT_TRUE(GetController()->Process(cycle_backward)); | 340 EXPECT_TRUE(GetController()->Process(cycle_backward)); |
330 } | 341 } |
331 | 342 |
332 } // namespace test | 343 } // namespace test |
333 } // namespace ash | 344 } // namespace ash |
OLD | NEW |