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 "ui/aura/event.h" | 5 #include "ui/aura/event.h" |
6 #include "ui/aura/root_window.h" | 6 #include "ui/aura/root_window.h" |
7 #include "ui/aura/test/test_window_delegate.h" | 7 #include "ui/aura/test/test_window_delegate.h" |
8 #include "ui/aura/test/test_windows.h" | 8 #include "ui/aura/test/test_windows.h" |
9 #include "ui/aura/window.h" | 9 #include "ui/aura/window.h" |
| 10 #include "ui/aura_shell/event.h" |
10 #include "ui/aura_shell/shell.h" | 11 #include "ui/aura_shell/shell.h" |
11 #include "ui/aura_shell/shell_accelerator_controller.h" | 12 #include "ui/aura_shell/shell_accelerator_controller.h" |
12 #include "ui/aura_shell/shell_window_ids.h" | 13 #include "ui/aura_shell/shell_window_ids.h" |
13 #include "ui/aura_shell/test/aura_shell_test_base.h" | 14 #include "ui/aura_shell/test/aura_shell_test_base.h" |
14 #include "ui/aura_shell/window_util.h" | 15 #include "ui/aura_shell/window_util.h" |
15 | 16 |
16 #if defined(USE_X11) | 17 #if defined(USE_X11) |
17 #include <X11/Xlib.h> | 18 #include <X11/Xlib.h> |
18 #include "ui/base/x/x11_util.h" | 19 #include "ui/base/x/x11_util.h" |
19 #endif | 20 #endif |
(...skipping 133 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(ShellAcceleratorControllerTest, GlobalAccelerators) { | 197 TEST_F(ShellAcceleratorControllerTest, GlobalAccelerators) { |
187 // TODO(mazda): Uncomment the followings once they are implemented. | 198 // TODO(mazda): Uncomment the followings once they are implemented. |
188 // CycleBackward | 199 // CycleBackward |
189 // EXPECT_TRUE(GetController()->Process( | 200 // EXPECT_TRUE(GetController()->Process( |
190 // ui::Accelerator(ui::VKEY_TAB, true, false, true))); | 201 // ui::Accelerator(ui::VKEY_TAB, true, false, true))); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 lock_modal_window->Show(); | 323 lock_modal_window->Show(); |
313 EXPECT_FALSE(GetController()->Process(cycle_forward)); | 324 EXPECT_FALSE(GetController()->Process(cycle_forward)); |
314 EXPECT_FALSE(GetController()->Process(cycle_backward)); | 325 EXPECT_FALSE(GetController()->Process(cycle_backward)); |
315 lock_screen_window->Hide(); | 326 lock_screen_window->Hide(); |
316 EXPECT_TRUE(GetController()->Process(cycle_forward)); | 327 EXPECT_TRUE(GetController()->Process(cycle_forward)); |
317 EXPECT_TRUE(GetController()->Process(cycle_backward)); | 328 EXPECT_TRUE(GetController()->Process(cycle_backward)); |
318 } | 329 } |
319 | 330 |
320 } // namespace test | 331 } // namespace test |
321 } // namespace aura_shell | 332 } // namespace aura_shell |
OLD | NEW |