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

Side by Side Diff: ui/aura_shell/shell_accelerator_controller_unittest.cc

Issue 8817018: Implement cycle window forward/backward by keyboard shortcuts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 9 years 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 | Annotate | Revision Log
« no previous file with comments | « ui/aura_shell/shell_accelerator_controller.cc ('k') | ui/aura_shell/shell_unittest.cc » ('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) 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_shell/shell.h" 10 #include "ui/aura_shell/shell.h"
10 #include "ui/aura_shell/shell_accelerator_controller.h" 11 #include "ui/aura_shell/shell_accelerator_controller.h"
11 #include "ui/aura_shell/shell_window_ids.h" 12 #include "ui/aura_shell/shell_window_ids.h"
12 #include "ui/aura_shell/test/aura_shell_test_base.h" 13 #include "ui/aura_shell/test/aura_shell_test_base.h"
13 #include "ui/aura_shell/window_util.h" 14 #include "ui/aura_shell/window_util.h"
14 15
15 #if defined(USE_X11) 16 #if defined(USE_X11)
16 #include <X11/Xlib.h> 17 #include <X11/Xlib.h>
17 #include "ui/base/x/x11_util.h" 18 #include "ui/base/x/x11_util.h"
18 #endif 19 #endif
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 EXPECT_TRUE(GetController()->Process( 201 EXPECT_TRUE(GetController()->Process(
201 ui::Accelerator(ui::VKEY_HOME, false, true, false))); 202 ui::Accelerator(ui::VKEY_HOME, false, true, false)));
202 #if !defined(OS_LINUX) 203 #if !defined(OS_LINUX)
203 // ToggleDesktopFullScreen (not implemented yet on Linux) 204 // ToggleDesktopFullScreen (not implemented yet on Linux)
204 EXPECT_TRUE(GetController()->Process( 205 EXPECT_TRUE(GetController()->Process(
205 ui::Accelerator(ui::VKEY_F11, false, true, false))); 206 ui::Accelerator(ui::VKEY_F11, false, true, false)));
206 #endif 207 #endif
207 #endif 208 #endif
208 } 209 }
209 210
211 TEST_F(ShellAcceleratorControllerTest, HandleCycleWindow) {
212 aura::Window* default_container =
213 aura_shell::Shell::GetInstance()->GetContainer(
214 internal::kShellWindowId_DefaultContainer);
215 aura::Window* window0 = aura::test::CreateTestWindowWithDelegate(
216 new aura::test::TestWindowDelegate,
217 -1,
218 gfx::Rect(),
219 default_container);
220 aura::Window* window1 = aura::test::CreateTestWindowWithDelegate(
221 new aura::test::TestWindowDelegate,
222 -1,
223 gfx::Rect(),
224 default_container);
225 aura::Window* window2 = aura::test::CreateTestWindowWithDelegate(
226 new aura::test::TestWindowDelegate,
227 -1,
228 gfx::Rect(),
229 default_container);
230 ActivateWindow(window0);
231 EXPECT_TRUE(IsActiveWindow(window0));
232
233 ui::Accelerator cycle_forward(ui::VKEY_TAB, false, false, true);
234 EXPECT_TRUE(GetController()->Process(cycle_forward));
235 EXPECT_TRUE(IsActiveWindow(window1));
236 EXPECT_TRUE(GetController()->Process(cycle_forward));
237 EXPECT_TRUE(IsActiveWindow(window2));
238 EXPECT_TRUE(GetController()->Process(cycle_forward));
239 EXPECT_TRUE(IsActiveWindow(window0));
240
241 ui::Accelerator cycle_backward(ui::VKEY_TAB, true, false, true);
242 EXPECT_TRUE(GetController()->Process(cycle_backward));
243 EXPECT_TRUE(IsActiveWindow(window2));
244 EXPECT_TRUE(GetController()->Process(cycle_backward));
245 EXPECT_TRUE(IsActiveWindow(window1));
246 EXPECT_TRUE(GetController()->Process(cycle_backward));
247 EXPECT_TRUE(IsActiveWindow(window0));
248
249 aura::Window* modal_container =
250 aura_shell::Shell::GetInstance()->GetContainer(
251 internal::kShellWindowId_AlwaysOnTopContainer);
252 aura::Window* modal_window = aura::test::CreateTestWindowWithDelegate(
253 new aura::test::TestWindowDelegate,
254 -1,
255 gfx::Rect(),
256 modal_container);
257
258 // When the modal window is active, cycling window does not take effect.
259 ActivateWindow(modal_window);
260 EXPECT_TRUE(IsActiveWindow(modal_window));
261 EXPECT_FALSE(GetController()->Process(cycle_forward));
262 EXPECT_TRUE(IsActiveWindow(modal_window));
263 EXPECT_FALSE(IsActiveWindow(window0));
264 EXPECT_FALSE(IsActiveWindow(window1));
265 EXPECT_FALSE(IsActiveWindow(window2));
266 EXPECT_FALSE(GetController()->Process(cycle_backward));
267 EXPECT_TRUE(IsActiveWindow(modal_window));
268 EXPECT_FALSE(IsActiveWindow(window0));
269 EXPECT_FALSE(IsActiveWindow(window1));
270 EXPECT_FALSE(IsActiveWindow(window2));
271
272 // The modal window is not activated by cycling window.
273 ActivateWindow(window0);
274 EXPECT_TRUE(GetController()->Process(cycle_forward));
275 EXPECT_FALSE(IsActiveWindow(modal_window));
276 EXPECT_TRUE(GetController()->Process(cycle_forward));
277 EXPECT_FALSE(IsActiveWindow(modal_window));
278 EXPECT_TRUE(GetController()->Process(cycle_forward));
279 EXPECT_FALSE(IsActiveWindow(modal_window));
280 EXPECT_TRUE(GetController()->Process(cycle_backward));
281 EXPECT_FALSE(IsActiveWindow(modal_window));
282 EXPECT_TRUE(GetController()->Process(cycle_backward));
283 EXPECT_FALSE(IsActiveWindow(modal_window));
284 EXPECT_TRUE(GetController()->Process(cycle_backward));
285 EXPECT_FALSE(IsActiveWindow(modal_window));
286
287 // When a screen lock window is visible, cycling window does not take effect.
288 aura::Window* lock_screen_container =
289 aura_shell::Shell::GetInstance()->GetContainer(
290 internal::kShellWindowId_LockScreenContainer);
291 aura::Window* lock_screen_window = aura::test::CreateTestWindowWithDelegate(
292 new aura::test::TestWindowDelegate,
293 -1,
294 gfx::Rect(),
295 lock_screen_container);
296
297 lock_screen_window->Show();
298 EXPECT_FALSE(GetController()->Process(cycle_forward));
299 EXPECT_FALSE(GetController()->Process(cycle_backward));
300
301 // When a screen lock window is visible, cycling window does not take effect.
302 // But otherwise, cycling window does take effect.
303 aura::Window* lock_modal_container =
304 aura_shell::Shell::GetInstance()->GetContainer(
305 internal::kShellWindowId_LockModalContainer);
306 aura::Window* lock_modal_window = aura::test::CreateTestWindowWithDelegate(
307 new aura::test::TestWindowDelegate,
308 -1,
309 gfx::Rect(),
310 lock_modal_container);
311
312 lock_modal_window->Show();
313 EXPECT_FALSE(GetController()->Process(cycle_forward));
314 EXPECT_FALSE(GetController()->Process(cycle_backward));
315 lock_screen_window->Hide();
316 EXPECT_TRUE(GetController()->Process(cycle_forward));
317 EXPECT_TRUE(GetController()->Process(cycle_backward));
318 }
319
210 } // namespace test 320 } // namespace test
211 } // namespace aura_shell 321 } // namespace aura_shell
OLDNEW
« no previous file with comments | « ui/aura_shell/shell_accelerator_controller.cc ('k') | ui/aura_shell/shell_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698