OLD | NEW |
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 "ash/wm/window_cycle_controller.h" | 5 #include "ash/wm/window_cycle_controller.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "ash/display/display_controller.h" | 9 #include "ash/display/display_controller.h" |
10 #include "ash/display/multi_display_manager.h" | 10 #include "ash/display/multi_display_manager.h" |
11 #include "ash/shell.h" | 11 #include "ash/shell.h" |
12 #include "ash/shell_window_ids.h" | 12 #include "ash/shell_window_ids.h" |
13 #include "ash/test/ash_test_base.h" | 13 #include "ash/test/ash_test_base.h" |
14 #include "ash/test/test_shell_delegate.h" | 14 #include "ash/test/test_shell_delegate.h" |
15 #include "ash/wm/window_cycle_list.h" | 15 #include "ash/wm/window_cycle_list.h" |
16 #include "ash/wm/window_util.h" | 16 #include "ash/wm/window_util.h" |
17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
| 18 #include "ui/aura/client/screen_position_client.h" |
18 #include "ui/aura/env.h" | 19 #include "ui/aura/env.h" |
19 #include "ui/aura/test/test_windows.h" | 20 #include "ui/aura/test/test_windows.h" |
20 #include "ui/aura/window.h" | 21 #include "ui/aura/window.h" |
21 #include "ui/gfx/rect.h" | 22 #include "ui/gfx/rect.h" |
| 23 #include "ui/gfx/screen.h" |
22 | 24 |
23 namespace ash { | 25 namespace ash { |
24 | 26 |
25 namespace { | 27 namespace { |
26 | 28 |
27 using aura::test::CreateTestWindowWithId; | 29 using aura::test::CreateTestWindowWithId; |
28 using aura::test::TestWindowDelegate; | 30 using aura::test::TestWindowDelegate; |
29 using aura::Window; | 31 using aura::Window; |
30 | 32 |
31 typedef test::AshTestBase WindowCycleControllerTest; | 33 typedef test::AshTestBase WindowCycleControllerTest; |
32 | 34 |
33 TEST_F(WindowCycleControllerTest, HandleCycleWindowBaseCases) { | 35 TEST_F(WindowCycleControllerTest, HandleCycleWindowBaseCases) { |
34 WindowCycleController* controller = | 36 WindowCycleController* controller = |
35 Shell::GetInstance()->window_cycle_controller(); | 37 Shell::GetInstance()->window_cycle_controller(); |
36 | 38 |
37 // Cycling doesn't crash if there are no windows. | 39 // Cycling doesn't crash if there are no windows. |
38 controller->HandleCycleWindow(WindowCycleController::FORWARD, false); | 40 controller->HandleCycleWindow(WindowCycleController::FORWARD, false); |
39 | 41 |
40 // Create a single test window. | 42 // Create a single test window. |
41 Window* default_container = | 43 scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL)); |
42 ash::Shell::GetContainer( | |
43 Shell::GetPrimaryRootWindow(), | |
44 internal::kShellWindowId_DefaultContainer); | |
45 scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container)); | |
46 wm::ActivateWindow(window0.get()); | 44 wm::ActivateWindow(window0.get()); |
47 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 45 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
48 | 46 |
49 // Cycling works for a single window, even though nothing changes. | 47 // Cycling works for a single window, even though nothing changes. |
50 controller->HandleCycleWindow(WindowCycleController::FORWARD, false); | 48 controller->HandleCycleWindow(WindowCycleController::FORWARD, false); |
51 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 49 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
52 } | 50 } |
53 | 51 |
54 // Verifies if there is only one window and it isn't active that cycling | 52 // Verifies if there is only one window and it isn't active that cycling |
55 // activates it. | 53 // activates it. |
56 TEST_F(WindowCycleControllerTest, SingleWindowNotActive) { | 54 TEST_F(WindowCycleControllerTest, SingleWindowNotActive) { |
57 WindowCycleController* controller = | 55 WindowCycleController* controller = |
58 Shell::GetInstance()->window_cycle_controller(); | 56 Shell::GetInstance()->window_cycle_controller(); |
59 | 57 |
60 // Create a single test window. | 58 // Create a single test window. |
61 Window* default_container = | 59 scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL)); |
62 ash::Shell::GetContainer( | |
63 Shell::GetPrimaryRootWindow(), | |
64 internal::kShellWindowId_DefaultContainer); | |
65 scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container)); | |
66 wm::ActivateWindow(window0.get()); | 60 wm::ActivateWindow(window0.get()); |
67 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 61 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
68 | 62 |
69 // Rotate focus, this should move focus to another window that isn't part of | 63 // Rotate focus, this should move focus to another window that isn't part of |
70 // the default container. | 64 // the default container. |
71 Shell::GetInstance()->RotateFocus(Shell::FORWARD); | 65 Shell::GetInstance()->RotateFocus(Shell::FORWARD); |
72 EXPECT_FALSE(wm::IsActiveWindow(window0.get())); | 66 EXPECT_FALSE(wm::IsActiveWindow(window0.get())); |
73 | 67 |
74 // Cycling should activate the window. | 68 // Cycling should activate the window. |
75 controller->HandleCycleWindow(WindowCycleController::FORWARD, false); | 69 controller->HandleCycleWindow(WindowCycleController::FORWARD, false); |
76 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 70 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
77 } | 71 } |
78 | 72 |
79 TEST_F(WindowCycleControllerTest, HandleCycleWindow) { | 73 TEST_F(WindowCycleControllerTest, HandleCycleWindow) { |
80 WindowCycleController* controller = | 74 WindowCycleController* controller = |
81 Shell::GetInstance()->window_cycle_controller(); | 75 Shell::GetInstance()->window_cycle_controller(); |
82 | 76 |
83 // Set up several windows to use to test cycling. Create them in reverse | 77 // Set up several windows to use to test cycling. Create them in reverse |
84 // order so they are stacked 0 over 1 over 2. | 78 // order so they are stacked 0 over 1 over 2. |
85 Window* default_container = | 79 scoped_ptr<Window> window2(CreateTestWindowWithId(2, NULL)); |
86 Shell::GetContainer( | 80 scoped_ptr<Window> window1(CreateTestWindowWithId(1, NULL)); |
87 Shell::GetPrimaryRootWindow(), | 81 scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL)); |
88 internal::kShellWindowId_DefaultContainer); | |
89 scoped_ptr<Window> window2(CreateTestWindowWithId(2, default_container)); | |
90 scoped_ptr<Window> window1(CreateTestWindowWithId(1, default_container)); | |
91 scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container)); | |
92 wm::ActivateWindow(window0.get()); | 82 wm::ActivateWindow(window0.get()); |
93 | 83 |
94 // Simulate pressing and releasing Alt-tab. | 84 // Simulate pressing and releasing Alt-tab. |
95 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 85 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
96 controller->HandleCycleWindow(WindowCycleController::FORWARD, true); | 86 controller->HandleCycleWindow(WindowCycleController::FORWARD, true); |
97 | 87 |
98 // Window lists should return the topmost window in front. | 88 // Window lists should return the topmost window in front. |
99 ASSERT_TRUE(controller->windows()); | 89 ASSERT_TRUE(controller->windows()); |
100 ASSERT_EQ(3u, controller->windows()->windows().size()); | 90 ASSERT_EQ(3u, controller->windows()->windows().size()); |
101 ASSERT_EQ(window0.get(), controller->windows()->windows()[0]); | 91 ASSERT_EQ(window0.get(), controller->windows()->windows()[0]); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 controller->HandleCycleWindow(WindowCycleController::BACKWARD, false); | 175 controller->HandleCycleWindow(WindowCycleController::BACKWARD, false); |
186 EXPECT_TRUE(wm::IsActiveWindow(modal_window.get())); | 176 EXPECT_TRUE(wm::IsActiveWindow(modal_window.get())); |
187 EXPECT_FALSE(wm::IsActiveWindow(window0.get())); | 177 EXPECT_FALSE(wm::IsActiveWindow(window0.get())); |
188 EXPECT_FALSE(wm::IsActiveWindow(window1.get())); | 178 EXPECT_FALSE(wm::IsActiveWindow(window1.get())); |
189 EXPECT_FALSE(wm::IsActiveWindow(window2.get())); | 179 EXPECT_FALSE(wm::IsActiveWindow(window2.get())); |
190 } | 180 } |
191 | 181 |
192 // Cycles between a maximized and normal window. | 182 // Cycles between a maximized and normal window. |
193 TEST_F(WindowCycleControllerTest, MaximizedWindow) { | 183 TEST_F(WindowCycleControllerTest, MaximizedWindow) { |
194 // Create a couple of test windows. | 184 // Create a couple of test windows. |
195 Window* default_container = | 185 scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL)); |
196 ash::Shell::GetContainer( | 186 scoped_ptr<Window> window1(CreateTestWindowWithId(1, NULL)); |
197 Shell::GetPrimaryRootWindow(), | |
198 internal::kShellWindowId_DefaultContainer); | |
199 scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container)); | |
200 scoped_ptr<Window> window1(CreateTestWindowWithId(1, default_container)); | |
201 | 187 |
202 wm::MaximizeWindow(window1.get()); | 188 wm::MaximizeWindow(window1.get()); |
203 wm::ActivateWindow(window1.get()); | 189 wm::ActivateWindow(window1.get()); |
204 EXPECT_TRUE(wm::IsActiveWindow(window1.get())); | 190 EXPECT_TRUE(wm::IsActiveWindow(window1.get())); |
205 | 191 |
206 // Rotate focus, this should move focus to window0. | 192 // Rotate focus, this should move focus to window0. |
207 WindowCycleController* controller = | 193 WindowCycleController* controller = |
208 Shell::GetInstance()->window_cycle_controller(); | 194 Shell::GetInstance()->window_cycle_controller(); |
209 controller->HandleCycleWindow(WindowCycleController::FORWARD, false); | 195 controller->HandleCycleWindow(WindowCycleController::FORWARD, false); |
210 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 196 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
211 | 197 |
212 // One more time. | 198 // One more time. |
213 controller->HandleCycleWindow(WindowCycleController::FORWARD, false); | 199 controller->HandleCycleWindow(WindowCycleController::FORWARD, false); |
214 EXPECT_TRUE(wm::IsActiveWindow(window1.get())); | 200 EXPECT_TRUE(wm::IsActiveWindow(window1.get())); |
215 } | 201 } |
216 | 202 |
217 // Cycles to a minimized window. | 203 // Cycles to a minimized window. |
218 TEST_F(WindowCycleControllerTest, Minimized) { | 204 TEST_F(WindowCycleControllerTest, Minimized) { |
219 // Create a couple of test windows. | 205 // Create a couple of test windows. |
220 Window* default_container = | 206 scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL)); |
221 Shell::GetContainer( | 207 scoped_ptr<Window> window1(CreateTestWindowWithId(1, NULL)); |
222 Shell::GetPrimaryRootWindow(), | |
223 internal::kShellWindowId_DefaultContainer); | |
224 scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container)); | |
225 scoped_ptr<Window> window1(CreateTestWindowWithId(1, default_container)); | |
226 | 208 |
227 wm::MinimizeWindow(window1.get()); | 209 wm::MinimizeWindow(window1.get()); |
228 wm::ActivateWindow(window0.get()); | 210 wm::ActivateWindow(window0.get()); |
229 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 211 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
230 | 212 |
231 // Rotate focus, this should move focus to window1 and unminimize it. | 213 // Rotate focus, this should move focus to window1 and unminimize it. |
232 WindowCycleController* controller = | 214 WindowCycleController* controller = |
233 Shell::GetInstance()->window_cycle_controller(); | 215 Shell::GetInstance()->window_cycle_controller(); |
234 controller->HandleCycleWindow(WindowCycleController::FORWARD, false); | 216 controller->HandleCycleWindow(WindowCycleController::FORWARD, false); |
235 EXPECT_FALSE(wm::IsWindowMinimized(window1.get())); | 217 EXPECT_FALSE(wm::IsWindowMinimized(window1.get())); |
236 EXPECT_TRUE(wm::IsActiveWindow(window1.get())); | 218 EXPECT_TRUE(wm::IsActiveWindow(window1.get())); |
237 | 219 |
238 // One more time back to w0. | 220 // One more time back to w0. |
239 controller->HandleCycleWindow(WindowCycleController::FORWARD, false); | 221 controller->HandleCycleWindow(WindowCycleController::FORWARD, false); |
240 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 222 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
241 } | 223 } |
242 | 224 |
243 TEST_F(WindowCycleControllerTest, AlwaysOnTopWindow) { | 225 TEST_F(WindowCycleControllerTest, AlwaysOnTopWindow) { |
244 WindowCycleController* controller = | 226 WindowCycleController* controller = |
245 Shell::GetInstance()->window_cycle_controller(); | 227 Shell::GetInstance()->window_cycle_controller(); |
246 | 228 |
247 // Set up several windows to use to test cycling. | 229 // Set up several windows to use to test cycling. |
248 Window* default_container = | 230 scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL)); |
249 Shell::GetContainer( | 231 scoped_ptr<Window> window1(CreateTestWindowWithId(1, NULL)); |
250 Shell::GetPrimaryRootWindow(), | |
251 internal::kShellWindowId_DefaultContainer); | |
252 scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container)); | |
253 scoped_ptr<Window> window1(CreateTestWindowWithId(1, default_container)); | |
254 | 232 |
255 Window* top_container = | 233 Window* top_container = |
256 Shell::GetContainer( | 234 Shell::GetContainer( |
257 Shell::GetPrimaryRootWindow(), | 235 Shell::GetPrimaryRootWindow(), |
258 internal::kShellWindowId_AlwaysOnTopContainer); | 236 internal::kShellWindowId_AlwaysOnTopContainer); |
259 scoped_ptr<Window> window2(CreateTestWindowWithId(2, top_container)); | 237 scoped_ptr<Window> window2(CreateTestWindowWithId(2, top_container)); |
260 wm::ActivateWindow(window0.get()); | 238 wm::ActivateWindow(window0.get()); |
261 | 239 |
262 // Simulate pressing and releasing Alt-tab. | 240 // Simulate pressing and releasing Alt-tab. |
263 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 241 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
(...skipping 22 matching lines...) Expand all Loading... |
286 | 264 |
287 controller->HandleCycleWindow(WindowCycleController::FORWARD, true); | 265 controller->HandleCycleWindow(WindowCycleController::FORWARD, true); |
288 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 266 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
289 } | 267 } |
290 | 268 |
291 TEST_F(WindowCycleControllerTest, AlwaysOnTopMultiWindow) { | 269 TEST_F(WindowCycleControllerTest, AlwaysOnTopMultiWindow) { |
292 WindowCycleController* controller = | 270 WindowCycleController* controller = |
293 Shell::GetInstance()->window_cycle_controller(); | 271 Shell::GetInstance()->window_cycle_controller(); |
294 | 272 |
295 // Set up several windows to use to test cycling. | 273 // Set up several windows to use to test cycling. |
296 Window* default_container = | 274 scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL)); |
297 Shell::GetContainer( | 275 scoped_ptr<Window> window1(CreateTestWindowWithId(1, NULL)); |
298 Shell::GetPrimaryRootWindow(), | |
299 internal::kShellWindowId_DefaultContainer); | |
300 scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container)); | |
301 scoped_ptr<Window> window1(CreateTestWindowWithId(1, default_container)); | |
302 | 276 |
303 Window* top_container = | 277 Window* top_container = |
304 Shell::GetContainer( | 278 Shell::GetContainer( |
305 Shell::GetPrimaryRootWindow(), | 279 Shell::GetPrimaryRootWindow(), |
306 internal::kShellWindowId_AlwaysOnTopContainer); | 280 internal::kShellWindowId_AlwaysOnTopContainer); |
307 scoped_ptr<Window> window2(CreateTestWindowWithId(2, top_container)); | 281 scoped_ptr<Window> window2(CreateTestWindowWithId(2, top_container)); |
308 scoped_ptr<Window> window3(CreateTestWindowWithId(3, top_container)); | 282 scoped_ptr<Window> window3(CreateTestWindowWithId(3, top_container)); |
309 wm::ActivateWindow(window0.get()); | 283 wm::ActivateWindow(window0.get()); |
310 | 284 |
311 // Simulate pressing and releasing Alt-tab. | 285 // Simulate pressing and releasing Alt-tab. |
(...skipping 28 matching lines...) Expand all Loading... |
340 controller->HandleCycleWindow(WindowCycleController::FORWARD, true); | 314 controller->HandleCycleWindow(WindowCycleController::FORWARD, true); |
341 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 315 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
342 } | 316 } |
343 | 317 |
344 TEST_F(WindowCycleControllerTest, AlwaysOnTopMultipleRootWindows) { | 318 TEST_F(WindowCycleControllerTest, AlwaysOnTopMultipleRootWindows) { |
345 // Set up a second root window | 319 // Set up a second root window |
346 UpdateDisplay("0+0-1000x600,1001+0-600x400"); | 320 UpdateDisplay("0+0-1000x600,1001+0-600x400"); |
347 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 321 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
348 ASSERT_EQ(2U, root_windows.size()); | 322 ASSERT_EQ(2U, root_windows.size()); |
349 | 323 |
350 // Move the active root window to the secondary. | |
351 Shell::GetInstance()->set_active_root_window(root_windows[1]); | |
352 | |
353 WindowCycleController* controller = | 324 WindowCycleController* controller = |
354 Shell::GetInstance()->window_cycle_controller(); | 325 Shell::GetInstance()->window_cycle_controller(); |
355 | 326 |
356 // Set up several windows to use to test cycling. | 327 Shell::GetInstance()->set_active_root_window(root_windows[0]); |
357 Window* default_container0 = | |
358 Shell::GetContainer( | |
359 root_windows[0], | |
360 internal::kShellWindowId_DefaultContainer); | |
361 scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container0)); | |
362 | 328 |
| 329 // Create two windows in the primary root. |
| 330 scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL)); |
| 331 EXPECT_EQ(root_windows[0], window0->GetRootWindow()); |
363 Window* top_container0 = | 332 Window* top_container0 = |
364 Shell::GetContainer( | 333 Shell::GetContainer( |
365 root_windows[0], | 334 root_windows[0], |
366 internal::kShellWindowId_AlwaysOnTopContainer); | 335 internal::kShellWindowId_AlwaysOnTopContainer); |
367 scoped_ptr<Window> window1(CreateTestWindowWithId(1, top_container0)); | 336 scoped_ptr<Window> window1(CreateTestWindowWithId(1, top_container0)); |
| 337 EXPECT_EQ(root_windows[0], window1->GetRootWindow()); |
368 | 338 |
369 // Set up several windows to use to test cycling. | 339 // And two on the secondary root. |
370 Window* default_container1 = | 340 Shell::GetInstance()->set_active_root_window(root_windows[1]); |
371 Shell::GetContainer( | 341 scoped_ptr<Window> window2(CreateTestWindowWithId(2, NULL)); |
372 root_windows[1], | 342 EXPECT_EQ(root_windows[1], window2->GetRootWindow()); |
373 internal::kShellWindowId_DefaultContainer); | |
374 scoped_ptr<Window> window2(CreateTestWindowWithId(2, default_container1)); | |
375 | 343 |
376 Window* top_container1 = | 344 Window* top_container1 = |
377 Shell::GetContainer( | 345 Shell::GetContainer( |
378 root_windows[1], | 346 root_windows[1], |
379 internal::kShellWindowId_AlwaysOnTopContainer); | 347 internal::kShellWindowId_AlwaysOnTopContainer); |
380 scoped_ptr<Window> window3(CreateTestWindowWithId(3, top_container1)); | 348 scoped_ptr<Window> window3(CreateTestWindowWithId(3, top_container1)); |
| 349 EXPECT_EQ(root_windows[1], window3->GetRootWindow()); |
381 | 350 |
| 351 // Move the active root window to the secondary. |
| 352 Shell::GetInstance()->set_active_root_window(root_windows[1]); |
382 | 353 |
383 wm::ActivateWindow(window2.get()); | 354 wm::ActivateWindow(window2.get()); |
384 | 355 |
| 356 EXPECT_EQ(root_windows[0], window0->GetRootWindow()); |
| 357 EXPECT_EQ(root_windows[0], window1->GetRootWindow()); |
| 358 EXPECT_EQ(root_windows[1], window2->GetRootWindow()); |
| 359 EXPECT_EQ(root_windows[1], window3->GetRootWindow()); |
| 360 |
385 // Simulate pressing and releasing Alt-tab. | 361 // Simulate pressing and releasing Alt-tab. |
386 EXPECT_TRUE(wm::IsActiveWindow(window2.get())); | 362 EXPECT_TRUE(wm::IsActiveWindow(window2.get())); |
387 controller->HandleCycleWindow(WindowCycleController::FORWARD, true); | 363 controller->HandleCycleWindow(WindowCycleController::FORWARD, true); |
388 | 364 |
389 // Window lists should return the topmost window in front. | 365 // Window lists should return the topmost window in front. |
390 ASSERT_TRUE(controller->windows()); | 366 ASSERT_TRUE(controller->windows()); |
391 ASSERT_EQ(4u, controller->windows()->windows().size()); | 367 ASSERT_EQ(4u, controller->windows()->windows().size()); |
392 EXPECT_EQ(window2.get(), controller->windows()->windows()[0]); | 368 EXPECT_EQ(window2.get(), controller->windows()->windows()[0]); |
393 EXPECT_EQ(window3.get(), controller->windows()->windows()[1]); | 369 EXPECT_EQ(window3.get(), controller->windows()->windows()[1]); |
394 EXPECT_EQ(window1.get(), controller->windows()->windows()[2]); | 370 EXPECT_EQ(window1.get(), controller->windows()->windows()[2]); |
(...skipping 18 matching lines...) Expand all Loading... |
413 | 389 |
414 controller->HandleCycleWindow(WindowCycleController::FORWARD, true); | 390 controller->HandleCycleWindow(WindowCycleController::FORWARD, true); |
415 EXPECT_TRUE(wm::IsActiveWindow(window2.get())); | 391 EXPECT_TRUE(wm::IsActiveWindow(window2.get())); |
416 } | 392 } |
417 | 393 |
418 TEST_F(WindowCycleControllerTest, MostRecentlyUsed) { | 394 TEST_F(WindowCycleControllerTest, MostRecentlyUsed) { |
419 WindowCycleController* controller = | 395 WindowCycleController* controller = |
420 Shell::GetInstance()->window_cycle_controller(); | 396 Shell::GetInstance()->window_cycle_controller(); |
421 | 397 |
422 // Set up several windows to use to test cycling. | 398 // Set up several windows to use to test cycling. |
423 Window* container = | 399 scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL)); |
424 Shell::GetContainer( | 400 scoped_ptr<Window> window1(CreateTestWindowWithId(1, NULL)); |
425 Shell::GetPrimaryRootWindow(), | 401 scoped_ptr<Window> window2(CreateTestWindowWithId(2, NULL)); |
426 internal::kShellWindowId_DefaultContainer); | |
427 scoped_ptr<Window> window0(CreateTestWindowWithId(0, container)); | |
428 scoped_ptr<Window> window1(CreateTestWindowWithId(1, container)); | |
429 scoped_ptr<Window> window2(CreateTestWindowWithId(2, container)); | |
430 | 402 |
431 wm::ActivateWindow(window0.get()); | 403 wm::ActivateWindow(window0.get()); |
432 | 404 |
433 // Simulate pressing and releasing Alt-tab. | 405 // Simulate pressing and releasing Alt-tab. |
434 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 406 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
435 controller->HandleCycleWindow(WindowCycleController::FORWARD, true); | 407 controller->HandleCycleWindow(WindowCycleController::FORWARD, true); |
436 | 408 |
437 // Window lists should return the topmost window in front. | 409 // Window lists should return the topmost window in front. |
438 ASSERT_TRUE(controller->windows()); | 410 ASSERT_TRUE(controller->windows()); |
439 ASSERT_EQ(3u, controller->windows()->windows().size()); | 411 ASSERT_EQ(3u, controller->windows()->windows().size()); |
(...skipping 17 matching lines...) Expand all Loading... |
457 controller->HandleCycleWindow(WindowCycleController::FORWARD, true); | 429 controller->HandleCycleWindow(WindowCycleController::FORWARD, true); |
458 EXPECT_TRUE(wm::IsActiveWindow(window2.get())); | 430 EXPECT_TRUE(wm::IsActiveWindow(window2.get())); |
459 | 431 |
460 controller->HandleCycleWindow(WindowCycleController::FORWARD, true); | 432 controller->HandleCycleWindow(WindowCycleController::FORWARD, true); |
461 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 433 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
462 } | 434 } |
463 | 435 |
464 } // namespace | 436 } // namespace |
465 | 437 |
466 } // namespace ash | 438 } // namespace ash |
OLD | NEW |