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/shell.h" | 10 #include "ui/aura_shell/shell.h" |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 default_container); | 153 default_container); |
154 ActivateWindow(window); | 154 ActivateWindow(window); |
155 | 155 |
156 const ui::Accelerator accelerator_a(ui::VKEY_A, false, false, false); | 156 const ui::Accelerator accelerator_a(ui::VKEY_A, false, false, false); |
157 TestTarget target; | 157 TestTarget target; |
158 GetController()->Register(accelerator_a, &target); | 158 GetController()->Register(accelerator_a, &target); |
159 | 159 |
160 // The accelerator is processed only once. | 160 // The accelerator is processed only once. |
161 #if defined(OS_WIN) | 161 #if defined(OS_WIN) |
162 MSG msg1 = { NULL, WM_KEYDOWN, ui::VKEY_A, 0 }; | 162 MSG msg1 = { NULL, WM_KEYDOWN, ui::VKEY_A, 0 }; |
163 aura::KeyEvent key_event1(msg1, false); | 163 aura::TranslatedKeyEvent key_event1(msg1, false); |
164 EXPECT_TRUE(aura::RootWindow::GetInstance()->DispatchKeyEvent(&key_event1)); | 164 EXPECT_TRUE(aura::RootWindow::GetInstance()->DispatchTranslatedKeyEvent( |
| 165 &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 aura::TranslatedKeyEvent key_event2(msg2, true); |
168 EXPECT_FALSE(aura::RootWindow::GetInstance()->DispatchKeyEvent(&key_event2)); | 169 EXPECT_FALSE(aura::RootWindow::GetInstance()->DispatchTranslatedKeyEvent( |
| 170 &key_event2)); |
169 | 171 |
170 MSG msg3 = { NULL, WM_KEYUP, ui::VKEY_A, 0 }; | 172 MSG msg3 = { NULL, WM_KEYUP, ui::VKEY_A, 0 }; |
171 aura::KeyEvent key_event3(msg3, false); | 173 aura::TranslatedKeyEvent key_event3(msg3, false); |
172 EXPECT_FALSE(aura::RootWindow::GetInstance()->DispatchKeyEvent(&key_event3)); | 174 EXPECT_FALSE(aura::RootWindow::GetInstance()->DispatchTranslatedKeyEvent( |
| 175 &key_event3)); |
173 #elif defined(USE_X11) | 176 #elif defined(USE_X11) |
174 XEvent key_event; | 177 XEvent key_event; |
175 ui::InitXKeyEventForTesting(ui::ET_KEY_PRESSED, | 178 ui::InitXKeyEventForTesting(ui::ET_KEY_PRESSED, |
176 ui::VKEY_A, | 179 ui::VKEY_A, |
177 0, | 180 0, |
178 &key_event); | 181 &key_event); |
179 EXPECT_TRUE(aura::RootWindow::GetInstance()->GetDispatcher()->Dispatch( | 182 aura::TranslatedKeyEvent key_event1(&key_event, false); |
180 &key_event)); | 183 EXPECT_TRUE(aura::RootWindow::GetInstance()->DispatchTranslatedKeyEvent( |
| 184 &key_event1)); |
| 185 |
| 186 aura::TranslatedKeyEvent key_event2(&key_event, true); |
| 187 EXPECT_FALSE(aura::RootWindow::GetInstance()->DispatchTranslatedKeyEvent( |
| 188 &key_event2)); |
| 189 |
| 190 ui::InitXKeyEventForTesting(ui::ET_KEY_RELEASED, |
| 191 ui::VKEY_A, |
| 192 0, |
| 193 &key_event); |
| 194 aura::TranslatedKeyEvent key_event3(&key_event, false); |
| 195 EXPECT_FALSE(aura::RootWindow::GetInstance()->DispatchTranslatedKeyEvent( |
| 196 &key_event3)); |
181 #endif | 197 #endif |
182 EXPECT_EQ(1, target.accelerator_pressed_count()); | 198 EXPECT_EQ(1, target.accelerator_pressed_count()); |
183 } | 199 } |
184 #endif | 200 #endif |
185 | 201 |
186 TEST_F(ShellAcceleratorControllerTest, GlobalAccelerators) { | 202 TEST_F(ShellAcceleratorControllerTest, GlobalAccelerators) { |
187 // TODO(mazda): Uncomment the followings once they are implemented. | 203 // TODO(mazda): Uncomment the followings once they are implemented. |
188 // CycleBackward | 204 // CycleBackward |
189 // EXPECT_TRUE(GetController()->Process( | 205 // EXPECT_TRUE(GetController()->Process( |
190 // ui::Accelerator(ui::VKEY_TAB, true, false, true))); | 206 // 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(); | 328 lock_modal_window->Show(); |
313 EXPECT_FALSE(GetController()->Process(cycle_forward)); | 329 EXPECT_FALSE(GetController()->Process(cycle_forward)); |
314 EXPECT_FALSE(GetController()->Process(cycle_backward)); | 330 EXPECT_FALSE(GetController()->Process(cycle_backward)); |
315 lock_screen_window->Hide(); | 331 lock_screen_window->Hide(); |
316 EXPECT_TRUE(GetController()->Process(cycle_forward)); | 332 EXPECT_TRUE(GetController()->Process(cycle_forward)); |
317 EXPECT_TRUE(GetController()->Process(cycle_backward)); | 333 EXPECT_TRUE(GetController()->Process(cycle_backward)); |
318 } | 334 } |
319 | 335 |
320 } // namespace test | 336 } // namespace test |
321 } // namespace aura_shell | 337 } // namespace aura_shell |
OLD | NEW |