OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include <memory> |
8 | 9 |
9 #include "ash/session/session_state_delegate.h" | 10 #include "ash/session/session_state_delegate.h" |
10 #include "ash/shelf/shelf.h" | 11 #include "ash/shelf/shelf.h" |
11 #include "ash/shelf/shelf_widget.h" | 12 #include "ash/shelf/shelf_widget.h" |
12 #include "ash/shell.h" | 13 #include "ash/shell.h" |
13 #include "ash/shell_window_ids.h" | 14 #include "ash/shell_window_ids.h" |
14 #include "ash/test/ash_test_base.h" | 15 #include "ash/test/ash_test_base.h" |
15 #include "ash/test/shelf_test_api.h" | 16 #include "ash/test/shelf_test_api.h" |
16 #include "ash/test/shelf_view_test_api.h" | 17 #include "ash/test/shelf_view_test_api.h" |
17 #include "ash/test/test_shelf_delegate.h" | 18 #include "ash/test/test_shelf_delegate.h" |
18 #include "ash/test/test_shell_delegate.h" | 19 #include "ash/test/test_shell_delegate.h" |
19 #include "ash/wm/window_cycle_list.h" | 20 #include "ash/wm/window_cycle_list.h" |
20 #include "ash/wm/window_state.h" | 21 #include "ash/wm/window_state.h" |
21 #include "ash/wm/window_util.h" | 22 #include "ash/wm/window_util.h" |
22 #include "base/memory/scoped_ptr.h" | |
23 #include "ui/aura/client/aura_constants.h" | 23 #include "ui/aura/client/aura_constants.h" |
24 #include "ui/aura/client/screen_position_client.h" | 24 #include "ui/aura/client/screen_position_client.h" |
25 #include "ui/aura/env.h" | 25 #include "ui/aura/env.h" |
26 #include "ui/aura/test/test_windows.h" | 26 #include "ui/aura/test/test_windows.h" |
27 #include "ui/aura/window.h" | 27 #include "ui/aura/window.h" |
28 #include "ui/aura/window_event_dispatcher.h" | 28 #include "ui/aura/window_event_dispatcher.h" |
29 #include "ui/gfx/geometry/rect.h" | 29 #include "ui/gfx/geometry/rect.h" |
30 #include "ui/gfx/screen.h" | 30 #include "ui/gfx/screen.h" |
31 | 31 |
32 namespace ash { | 32 namespace ash { |
(...skipping 24 matching lines...) Expand all Loading... |
57 shelf_view_test_->RunMessageLoopUntilAnimationsDone(); | 57 shelf_view_test_->RunMessageLoopUntilAnimationsDone(); |
58 return window; | 58 return window; |
59 } | 59 } |
60 | 60 |
61 const WindowCycleList::WindowList& GetWindows( | 61 const WindowCycleList::WindowList& GetWindows( |
62 WindowCycleController* controller) { | 62 WindowCycleController* controller) { |
63 return controller->window_cycle_list()->windows(); | 63 return controller->window_cycle_list()->windows(); |
64 } | 64 } |
65 | 65 |
66 private: | 66 private: |
67 scoped_ptr<test::ShelfViewTestAPI> shelf_view_test_; | 67 std::unique_ptr<test::ShelfViewTestAPI> shelf_view_test_; |
68 | 68 |
69 DISALLOW_COPY_AND_ASSIGN(WindowCycleControllerTest); | 69 DISALLOW_COPY_AND_ASSIGN(WindowCycleControllerTest); |
70 }; | 70 }; |
71 | 71 |
72 TEST_F(WindowCycleControllerTest, HandleCycleWindowBaseCases) { | 72 TEST_F(WindowCycleControllerTest, HandleCycleWindowBaseCases) { |
73 WindowCycleController* controller = | 73 WindowCycleController* controller = |
74 Shell::GetInstance()->window_cycle_controller(); | 74 Shell::GetInstance()->window_cycle_controller(); |
75 | 75 |
76 // Cycling doesn't crash if there are no windows. | 76 // Cycling doesn't crash if there are no windows. |
77 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 77 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
78 | 78 |
79 // Create a single test window. | 79 // Create a single test window. |
80 scoped_ptr<Window> window0(CreateTestWindowInShellWithId(0)); | 80 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0)); |
81 wm::ActivateWindow(window0.get()); | 81 wm::ActivateWindow(window0.get()); |
82 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 82 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
83 | 83 |
84 // Cycling works for a single window, even though nothing changes. | 84 // Cycling works for a single window, even though nothing changes. |
85 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 85 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
86 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 86 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
87 } | 87 } |
88 | 88 |
89 // Verifies if there is only one window and it isn't active that cycling | 89 // Verifies if there is only one window and it isn't active that cycling |
90 // activates it. | 90 // activates it. |
91 TEST_F(WindowCycleControllerTest, SingleWindowNotActive) { | 91 TEST_F(WindowCycleControllerTest, SingleWindowNotActive) { |
92 WindowCycleController* controller = | 92 WindowCycleController* controller = |
93 Shell::GetInstance()->window_cycle_controller(); | 93 Shell::GetInstance()->window_cycle_controller(); |
94 | 94 |
95 // Create a single test window. | 95 // Create a single test window. |
96 scoped_ptr<Window> window0(CreateTestWindowInShellWithId(0)); | 96 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0)); |
97 wm::ActivateWindow(window0.get()); | 97 wm::ActivateWindow(window0.get()); |
98 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 98 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
99 | 99 |
100 // Rotate focus, this should move focus to another window that isn't part of | 100 // Rotate focus, this should move focus to another window that isn't part of |
101 // the default container. | 101 // the default container. |
102 Shell::GetInstance()->RotateFocus(Shell::FORWARD); | 102 Shell::GetInstance()->RotateFocus(Shell::FORWARD); |
103 EXPECT_FALSE(wm::IsActiveWindow(window0.get())); | 103 EXPECT_FALSE(wm::IsActiveWindow(window0.get())); |
104 | 104 |
105 // Cycling should activate the window. | 105 // Cycling should activate the window. |
106 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 106 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
107 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 107 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
108 } | 108 } |
109 | 109 |
110 TEST_F(WindowCycleControllerTest, HandleCycleWindow) { | 110 TEST_F(WindowCycleControllerTest, HandleCycleWindow) { |
111 WindowCycleController* controller = | 111 WindowCycleController* controller = |
112 Shell::GetInstance()->window_cycle_controller(); | 112 Shell::GetInstance()->window_cycle_controller(); |
113 | 113 |
114 // Set up several windows to use to test cycling. Create them in reverse | 114 // Set up several windows to use to test cycling. Create them in reverse |
115 // order so they are stacked 0 over 1 over 2. | 115 // order so they are stacked 0 over 1 over 2. |
116 scoped_ptr<Window> window2(CreateTestWindowInShellWithId(2)); | 116 std::unique_ptr<Window> window2(CreateTestWindowInShellWithId(2)); |
117 scoped_ptr<Window> window1(CreateTestWindowInShellWithId(1)); | 117 std::unique_ptr<Window> window1(CreateTestWindowInShellWithId(1)); |
118 scoped_ptr<Window> window0(CreateTestWindowInShellWithId(0)); | 118 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0)); |
119 wm::ActivateWindow(window0.get()); | 119 wm::ActivateWindow(window0.get()); |
120 | 120 |
121 // Simulate pressing and releasing Alt-tab. | 121 // Simulate pressing and releasing Alt-tab. |
122 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 122 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
123 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 123 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
124 | 124 |
125 // Window lists should return the topmost window in front. | 125 // Window lists should return the topmost window in front. |
126 ASSERT_TRUE(controller->window_cycle_list()); | 126 ASSERT_TRUE(controller->window_cycle_list()); |
127 ASSERT_EQ(3u, GetWindows(controller).size()); | 127 ASSERT_EQ(3u, GetWindows(controller).size()); |
128 ASSERT_EQ(window0.get(), GetWindows(controller)[0]); | 128 ASSERT_EQ(window0.get(), GetWindows(controller)[0]); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 184 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
185 EXPECT_TRUE(wm::IsActiveWindow(window1.get())); | 185 EXPECT_TRUE(wm::IsActiveWindow(window1.get())); |
186 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 186 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
187 EXPECT_TRUE(wm::IsActiveWindow(window2.get())); | 187 EXPECT_TRUE(wm::IsActiveWindow(window2.get())); |
188 | 188 |
189 // When a modal window is active, cycling window does not take effect. | 189 // When a modal window is active, cycling window does not take effect. |
190 aura::Window* modal_container = | 190 aura::Window* modal_container = |
191 ash::Shell::GetContainer( | 191 ash::Shell::GetContainer( |
192 Shell::GetPrimaryRootWindow(), | 192 Shell::GetPrimaryRootWindow(), |
193 kShellWindowId_SystemModalContainer); | 193 kShellWindowId_SystemModalContainer); |
194 scoped_ptr<Window> modal_window( | 194 std::unique_ptr<Window> modal_window( |
195 CreateTestWindowWithId(-2, modal_container)); | 195 CreateTestWindowWithId(-2, modal_container)); |
196 modal_window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_SYSTEM); | 196 modal_window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_SYSTEM); |
197 wm::ActivateWindow(modal_window.get()); | 197 wm::ActivateWindow(modal_window.get()); |
198 EXPECT_TRUE(wm::IsActiveWindow(modal_window.get())); | 198 EXPECT_TRUE(wm::IsActiveWindow(modal_window.get())); |
199 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 199 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
200 EXPECT_TRUE(wm::IsActiveWindow(modal_window.get())); | 200 EXPECT_TRUE(wm::IsActiveWindow(modal_window.get())); |
201 EXPECT_FALSE(wm::IsActiveWindow(window0.get())); | 201 EXPECT_FALSE(wm::IsActiveWindow(window0.get())); |
202 EXPECT_FALSE(wm::IsActiveWindow(window1.get())); | 202 EXPECT_FALSE(wm::IsActiveWindow(window1.get())); |
203 EXPECT_FALSE(wm::IsActiveWindow(window2.get())); | 203 EXPECT_FALSE(wm::IsActiveWindow(window2.get())); |
204 controller->HandleCycleWindow(WindowCycleController::BACKWARD); | 204 controller->HandleCycleWindow(WindowCycleController::BACKWARD); |
205 EXPECT_TRUE(wm::IsActiveWindow(modal_window.get())); | 205 EXPECT_TRUE(wm::IsActiveWindow(modal_window.get())); |
206 EXPECT_FALSE(wm::IsActiveWindow(window0.get())); | 206 EXPECT_FALSE(wm::IsActiveWindow(window0.get())); |
207 EXPECT_FALSE(wm::IsActiveWindow(window1.get())); | 207 EXPECT_FALSE(wm::IsActiveWindow(window1.get())); |
208 EXPECT_FALSE(wm::IsActiveWindow(window2.get())); | 208 EXPECT_FALSE(wm::IsActiveWindow(window2.get())); |
209 } | 209 } |
210 | 210 |
211 // Cycles between a maximized and normal window. | 211 // Cycles between a maximized and normal window. |
212 TEST_F(WindowCycleControllerTest, MaximizedWindow) { | 212 TEST_F(WindowCycleControllerTest, MaximizedWindow) { |
213 // Create a couple of test windows. | 213 // Create a couple of test windows. |
214 scoped_ptr<Window> window0(CreateTestWindowInShellWithId(0)); | 214 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0)); |
215 scoped_ptr<Window> window1(CreateTestWindowInShellWithId(1)); | 215 std::unique_ptr<Window> window1(CreateTestWindowInShellWithId(1)); |
216 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); | 216 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); |
217 window1_state->Maximize(); | 217 window1_state->Maximize(); |
218 window1_state->Activate(); | 218 window1_state->Activate(); |
219 EXPECT_TRUE(window1_state->IsActive()); | 219 EXPECT_TRUE(window1_state->IsActive()); |
220 | 220 |
221 // Rotate focus, this should move focus to window0. | 221 // Rotate focus, this should move focus to window0. |
222 WindowCycleController* controller = | 222 WindowCycleController* controller = |
223 Shell::GetInstance()->window_cycle_controller(); | 223 Shell::GetInstance()->window_cycle_controller(); |
224 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 224 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
225 EXPECT_TRUE(wm::GetWindowState(window0.get())->IsActive()); | 225 EXPECT_TRUE(wm::GetWindowState(window0.get())->IsActive()); |
226 | 226 |
227 // One more time. | 227 // One more time. |
228 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 228 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
229 EXPECT_TRUE(window1_state->IsActive()); | 229 EXPECT_TRUE(window1_state->IsActive()); |
230 } | 230 } |
231 | 231 |
232 // Cycles to a minimized window. | 232 // Cycles to a minimized window. |
233 TEST_F(WindowCycleControllerTest, Minimized) { | 233 TEST_F(WindowCycleControllerTest, Minimized) { |
234 // Create a couple of test windows. | 234 // Create a couple of test windows. |
235 scoped_ptr<Window> window0(CreateTestWindowInShellWithId(0)); | 235 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0)); |
236 scoped_ptr<Window> window1(CreateTestWindowInShellWithId(1)); | 236 std::unique_ptr<Window> window1(CreateTestWindowInShellWithId(1)); |
237 wm::WindowState* window0_state = wm::GetWindowState(window0.get()); | 237 wm::WindowState* window0_state = wm::GetWindowState(window0.get()); |
238 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); | 238 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); |
239 | 239 |
240 window1_state->Minimize(); | 240 window1_state->Minimize(); |
241 window0_state->Activate(); | 241 window0_state->Activate(); |
242 EXPECT_TRUE(window0_state->IsActive()); | 242 EXPECT_TRUE(window0_state->IsActive()); |
243 | 243 |
244 // Rotate focus, this should move focus to window1 and unminimize it. | 244 // Rotate focus, this should move focus to window1 and unminimize it. |
245 WindowCycleController* controller = | 245 WindowCycleController* controller = |
246 Shell::GetInstance()->window_cycle_controller(); | 246 Shell::GetInstance()->window_cycle_controller(); |
247 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 247 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
248 EXPECT_FALSE(window1_state->IsMinimized()); | 248 EXPECT_FALSE(window1_state->IsMinimized()); |
249 EXPECT_TRUE(window1_state->IsActive()); | 249 EXPECT_TRUE(window1_state->IsActive()); |
250 | 250 |
251 // One more time back to w0. | 251 // One more time back to w0. |
252 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 252 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
253 EXPECT_TRUE(window0_state->IsActive()); | 253 EXPECT_TRUE(window0_state->IsActive()); |
254 } | 254 } |
255 | 255 |
256 TEST_F(WindowCycleControllerTest, AlwaysOnTopWindow) { | 256 TEST_F(WindowCycleControllerTest, AlwaysOnTopWindow) { |
257 WindowCycleController* controller = | 257 WindowCycleController* controller = |
258 Shell::GetInstance()->window_cycle_controller(); | 258 Shell::GetInstance()->window_cycle_controller(); |
259 | 259 |
260 // Set up several windows to use to test cycling. | 260 // Set up several windows to use to test cycling. |
261 scoped_ptr<Window> window0(CreateTestWindowInShellWithId(0)); | 261 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0)); |
262 scoped_ptr<Window> window1(CreateTestWindowInShellWithId(1)); | 262 std::unique_ptr<Window> window1(CreateTestWindowInShellWithId(1)); |
263 | 263 |
264 Window* top_container = | 264 Window* top_container = |
265 Shell::GetContainer( | 265 Shell::GetContainer( |
266 Shell::GetPrimaryRootWindow(), | 266 Shell::GetPrimaryRootWindow(), |
267 kShellWindowId_AlwaysOnTopContainer); | 267 kShellWindowId_AlwaysOnTopContainer); |
268 scoped_ptr<Window> window2(CreateTestWindowWithId(2, top_container)); | 268 std::unique_ptr<Window> window2(CreateTestWindowWithId(2, top_container)); |
269 wm::ActivateWindow(window0.get()); | 269 wm::ActivateWindow(window0.get()); |
270 | 270 |
271 // Simulate pressing and releasing Alt-tab. | 271 // Simulate pressing and releasing Alt-tab. |
272 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 272 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
273 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 273 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
274 | 274 |
275 // Window lists should return the topmost window in front. | 275 // Window lists should return the topmost window in front. |
276 ASSERT_TRUE(controller->window_cycle_list()); | 276 ASSERT_TRUE(controller->window_cycle_list()); |
277 ASSERT_EQ(3u, GetWindows(controller).size()); | 277 ASSERT_EQ(3u, GetWindows(controller).size()); |
278 EXPECT_EQ(window0.get(), GetWindows(controller)[0]); | 278 EXPECT_EQ(window0.get(), GetWindows(controller)[0]); |
(...skipping 16 matching lines...) Expand all Loading... |
295 | 295 |
296 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 296 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
297 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 297 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
298 } | 298 } |
299 | 299 |
300 TEST_F(WindowCycleControllerTest, AlwaysOnTopMultiWindow) { | 300 TEST_F(WindowCycleControllerTest, AlwaysOnTopMultiWindow) { |
301 WindowCycleController* controller = | 301 WindowCycleController* controller = |
302 Shell::GetInstance()->window_cycle_controller(); | 302 Shell::GetInstance()->window_cycle_controller(); |
303 | 303 |
304 // Set up several windows to use to test cycling. | 304 // Set up several windows to use to test cycling. |
305 scoped_ptr<Window> window0(CreateTestWindowInShellWithId(0)); | 305 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0)); |
306 scoped_ptr<Window> window1(CreateTestWindowInShellWithId(1)); | 306 std::unique_ptr<Window> window1(CreateTestWindowInShellWithId(1)); |
307 | 307 |
308 Window* top_container = | 308 Window* top_container = |
309 Shell::GetContainer( | 309 Shell::GetContainer( |
310 Shell::GetPrimaryRootWindow(), | 310 Shell::GetPrimaryRootWindow(), |
311 kShellWindowId_AlwaysOnTopContainer); | 311 kShellWindowId_AlwaysOnTopContainer); |
312 scoped_ptr<Window> window2(CreateTestWindowWithId(2, top_container)); | 312 std::unique_ptr<Window> window2(CreateTestWindowWithId(2, top_container)); |
313 scoped_ptr<Window> window3(CreateTestWindowWithId(3, top_container)); | 313 std::unique_ptr<Window> window3(CreateTestWindowWithId(3, top_container)); |
314 wm::ActivateWindow(window0.get()); | 314 wm::ActivateWindow(window0.get()); |
315 | 315 |
316 // Simulate pressing and releasing Alt-tab. | 316 // Simulate pressing and releasing Alt-tab. |
317 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 317 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
318 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 318 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
319 | 319 |
320 // Window lists should return the topmost window in front. | 320 // Window lists should return the topmost window in front. |
321 ASSERT_TRUE(controller->window_cycle_list()); | 321 ASSERT_TRUE(controller->window_cycle_list()); |
322 ASSERT_EQ(4u, GetWindows(controller).size()); | 322 ASSERT_EQ(4u, GetWindows(controller).size()); |
323 EXPECT_EQ(window0.get(), GetWindows(controller)[0]); | 323 EXPECT_EQ(window0.get(), GetWindows(controller)[0]); |
(...skipping 30 matching lines...) Expand all Loading... |
354 UpdateDisplay("1000x600,600x400"); | 354 UpdateDisplay("1000x600,600x400"); |
355 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 355 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
356 ASSERT_EQ(2U, root_windows.size()); | 356 ASSERT_EQ(2U, root_windows.size()); |
357 | 357 |
358 WindowCycleController* controller = | 358 WindowCycleController* controller = |
359 Shell::GetInstance()->window_cycle_controller(); | 359 Shell::GetInstance()->window_cycle_controller(); |
360 | 360 |
361 Shell::GetInstance()->set_target_root_window(root_windows[0]); | 361 Shell::GetInstance()->set_target_root_window(root_windows[0]); |
362 | 362 |
363 // Create two windows in the primary root. | 363 // Create two windows in the primary root. |
364 scoped_ptr<Window> window0(CreateTestWindowInShellWithId(0)); | 364 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0)); |
365 EXPECT_EQ(root_windows[0], window0->GetRootWindow()); | 365 EXPECT_EQ(root_windows[0], window0->GetRootWindow()); |
366 Window* top_container0 = | 366 Window* top_container0 = |
367 Shell::GetContainer( | 367 Shell::GetContainer( |
368 root_windows[0], | 368 root_windows[0], |
369 kShellWindowId_AlwaysOnTopContainer); | 369 kShellWindowId_AlwaysOnTopContainer); |
370 scoped_ptr<Window> window1(CreateTestWindowWithId(1, top_container0)); | 370 std::unique_ptr<Window> window1(CreateTestWindowWithId(1, top_container0)); |
371 EXPECT_EQ(root_windows[0], window1->GetRootWindow()); | 371 EXPECT_EQ(root_windows[0], window1->GetRootWindow()); |
372 | 372 |
373 // And two on the secondary root. | 373 // And two on the secondary root. |
374 Shell::GetInstance()->set_target_root_window(root_windows[1]); | 374 Shell::GetInstance()->set_target_root_window(root_windows[1]); |
375 scoped_ptr<Window> window2(CreateTestWindowInShellWithId(2)); | 375 std::unique_ptr<Window> window2(CreateTestWindowInShellWithId(2)); |
376 EXPECT_EQ(root_windows[1], window2->GetRootWindow()); | 376 EXPECT_EQ(root_windows[1], window2->GetRootWindow()); |
377 | 377 |
378 Window* top_container1 = | 378 Window* top_container1 = |
379 Shell::GetContainer( | 379 Shell::GetContainer( |
380 root_windows[1], | 380 root_windows[1], |
381 kShellWindowId_AlwaysOnTopContainer); | 381 kShellWindowId_AlwaysOnTopContainer); |
382 scoped_ptr<Window> window3(CreateTestWindowWithId(3, top_container1)); | 382 std::unique_ptr<Window> window3(CreateTestWindowWithId(3, top_container1)); |
383 EXPECT_EQ(root_windows[1], window3->GetRootWindow()); | 383 EXPECT_EQ(root_windows[1], window3->GetRootWindow()); |
384 | 384 |
385 // Move the active root window to the secondary. | 385 // Move the active root window to the secondary. |
386 Shell::GetInstance()->set_target_root_window(root_windows[1]); | 386 Shell::GetInstance()->set_target_root_window(root_windows[1]); |
387 | 387 |
388 wm::ActivateWindow(window2.get()); | 388 wm::ActivateWindow(window2.get()); |
389 | 389 |
390 EXPECT_EQ(root_windows[0], window0->GetRootWindow()); | 390 EXPECT_EQ(root_windows[0], window0->GetRootWindow()); |
391 EXPECT_EQ(root_windows[0], window1->GetRootWindow()); | 391 EXPECT_EQ(root_windows[0], window1->GetRootWindow()); |
392 EXPECT_EQ(root_windows[1], window2->GetRootWindow()); | 392 EXPECT_EQ(root_windows[1], window2->GetRootWindow()); |
(...skipping 30 matching lines...) Expand all Loading... |
423 | 423 |
424 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 424 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
425 EXPECT_TRUE(wm::IsActiveWindow(window2.get())); | 425 EXPECT_TRUE(wm::IsActiveWindow(window2.get())); |
426 } | 426 } |
427 | 427 |
428 TEST_F(WindowCycleControllerTest, MostRecentlyUsed) { | 428 TEST_F(WindowCycleControllerTest, MostRecentlyUsed) { |
429 WindowCycleController* controller = | 429 WindowCycleController* controller = |
430 Shell::GetInstance()->window_cycle_controller(); | 430 Shell::GetInstance()->window_cycle_controller(); |
431 | 431 |
432 // Set up several windows to use to test cycling. | 432 // Set up several windows to use to test cycling. |
433 scoped_ptr<Window> window0(CreateTestWindowInShellWithId(0)); | 433 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0)); |
434 scoped_ptr<Window> window1(CreateTestWindowInShellWithId(1)); | 434 std::unique_ptr<Window> window1(CreateTestWindowInShellWithId(1)); |
435 scoped_ptr<Window> window2(CreateTestWindowInShellWithId(2)); | 435 std::unique_ptr<Window> window2(CreateTestWindowInShellWithId(2)); |
436 | 436 |
437 wm::ActivateWindow(window0.get()); | 437 wm::ActivateWindow(window0.get()); |
438 | 438 |
439 // Simulate pressing and releasing Alt-tab. | 439 // Simulate pressing and releasing Alt-tab. |
440 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 440 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
441 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 441 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
442 | 442 |
443 // Window lists should return the topmost window in front. | 443 // Window lists should return the topmost window in front. |
444 ASSERT_TRUE(controller->window_cycle_list()); | 444 ASSERT_TRUE(controller->window_cycle_list()); |
445 ASSERT_EQ(3u, GetWindows(controller).size()); | 445 ASSERT_EQ(3u, GetWindows(controller).size()); |
(...skipping 19 matching lines...) Expand all Loading... |
465 | 465 |
466 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 466 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
467 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 467 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
468 } | 468 } |
469 | 469 |
470 // Tests that beginning window selection hides the app list. | 470 // Tests that beginning window selection hides the app list. |
471 TEST_F(WindowCycleControllerTest, SelectingHidesAppList) { | 471 TEST_F(WindowCycleControllerTest, SelectingHidesAppList) { |
472 WindowCycleController* controller = | 472 WindowCycleController* controller = |
473 Shell::GetInstance()->window_cycle_controller(); | 473 Shell::GetInstance()->window_cycle_controller(); |
474 | 474 |
475 scoped_ptr<aura::Window> window0(CreateTestWindowInShellWithId(0)); | 475 std::unique_ptr<aura::Window> window0(CreateTestWindowInShellWithId(0)); |
476 scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); | 476 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); |
477 Shell::GetInstance()->ShowAppList(NULL); | 477 Shell::GetInstance()->ShowAppList(NULL); |
478 EXPECT_TRUE(Shell::GetInstance()->GetAppListTargetVisibility()); | 478 EXPECT_TRUE(Shell::GetInstance()->GetAppListTargetVisibility()); |
479 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 479 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
480 EXPECT_FALSE(Shell::GetInstance()->GetAppListTargetVisibility()); | 480 EXPECT_FALSE(Shell::GetInstance()->GetAppListTargetVisibility()); |
481 } | 481 } |
482 | 482 |
483 // Tests that cycling through windows shows and minimizes windows as they | 483 // Tests that cycling through windows shows and minimizes windows as they |
484 // are passed. | 484 // are passed. |
485 TEST_F(WindowCycleControllerTest, CyclePreservesMinimization) { | 485 TEST_F(WindowCycleControllerTest, CyclePreservesMinimization) { |
486 WindowCycleController* controller = | 486 WindowCycleController* controller = |
487 Shell::GetInstance()->window_cycle_controller(); | 487 Shell::GetInstance()->window_cycle_controller(); |
488 | 488 |
489 scoped_ptr<aura::Window> window0(CreateTestWindowInShellWithId(0)); | 489 std::unique_ptr<aura::Window> window0(CreateTestWindowInShellWithId(0)); |
490 scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); | 490 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); |
491 wm::ActivateWindow(window1.get()); | 491 wm::ActivateWindow(window1.get()); |
492 wm::GetWindowState(window1.get())->Minimize(); | 492 wm::GetWindowState(window1.get())->Minimize(); |
493 wm::ActivateWindow(window0.get()); | 493 wm::ActivateWindow(window0.get()); |
494 EXPECT_TRUE(wm::IsWindowMinimized(window1.get())); | 494 EXPECT_TRUE(wm::IsWindowMinimized(window1.get())); |
495 | 495 |
496 // On window 2. | 496 // On window 2. |
497 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 497 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
498 EXPECT_FALSE(wm::IsWindowMinimized(window1.get())); | 498 EXPECT_FALSE(wm::IsWindowMinimized(window1.get())); |
499 | 499 |
500 // Back on window 1. | 500 // Back on window 1. |
501 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 501 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
502 EXPECT_TRUE(wm::IsWindowMinimized(window1.get())); | 502 EXPECT_TRUE(wm::IsWindowMinimized(window1.get())); |
503 | 503 |
504 controller->StopCycling(); | 504 controller->StopCycling(); |
505 | 505 |
506 EXPECT_TRUE(wm::IsWindowMinimized(window1.get())); | 506 EXPECT_TRUE(wm::IsWindowMinimized(window1.get())); |
507 } | 507 } |
508 | 508 |
509 // Tests cycles between panel and normal windows. | 509 // Tests cycles between panel and normal windows. |
510 TEST_F(WindowCycleControllerTest, CyclePanels) { | 510 TEST_F(WindowCycleControllerTest, CyclePanels) { |
511 WindowCycleController* controller = | 511 WindowCycleController* controller = |
512 Shell::GetInstance()->window_cycle_controller(); | 512 Shell::GetInstance()->window_cycle_controller(); |
513 | 513 |
514 scoped_ptr<aura::Window> window0(CreateTestWindowInShellWithId(0)); | 514 std::unique_ptr<aura::Window> window0(CreateTestWindowInShellWithId(0)); |
515 scoped_ptr<aura::Window> panel0(CreatePanelWindow()); | 515 std::unique_ptr<aura::Window> panel0(CreatePanelWindow()); |
516 scoped_ptr<aura::Window> panel1(CreatePanelWindow()); | 516 std::unique_ptr<aura::Window> panel1(CreatePanelWindow()); |
517 wm::ActivateWindow(window0.get()); | 517 wm::ActivateWindow(window0.get()); |
518 wm::ActivateWindow(panel1.get()); | 518 wm::ActivateWindow(panel1.get()); |
519 wm::ActivateWindow(panel0.get()); | 519 wm::ActivateWindow(panel0.get()); |
520 EXPECT_TRUE(wm::IsActiveWindow(panel0.get())); | 520 EXPECT_TRUE(wm::IsActiveWindow(panel0.get())); |
521 | 521 |
522 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 522 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
523 controller->StopCycling(); | 523 controller->StopCycling(); |
524 EXPECT_TRUE(wm::IsActiveWindow(panel1.get())); | 524 EXPECT_TRUE(wm::IsActiveWindow(panel1.get())); |
525 | 525 |
526 // Cycling again should select the most recently used panel. | 526 // Cycling again should select the most recently used panel. |
527 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 527 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
528 controller->StopCycling(); | 528 controller->StopCycling(); |
529 EXPECT_TRUE(wm::IsActiveWindow(panel0.get())); | 529 EXPECT_TRUE(wm::IsActiveWindow(panel0.get())); |
530 | 530 |
531 // Cycling twice again should select the first window. | 531 // Cycling twice again should select the first window. |
532 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 532 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
533 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 533 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
534 controller->StopCycling(); | 534 controller->StopCycling(); |
535 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 535 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
536 } | 536 } |
537 | 537 |
538 // Tests cycles between panel and normal windows. | 538 // Tests cycles between panel and normal windows. |
539 TEST_F(WindowCycleControllerTest, CyclePanelsDestroyed) { | 539 TEST_F(WindowCycleControllerTest, CyclePanelsDestroyed) { |
540 WindowCycleController* controller = | 540 WindowCycleController* controller = |
541 Shell::GetInstance()->window_cycle_controller(); | 541 Shell::GetInstance()->window_cycle_controller(); |
542 | 542 |
543 scoped_ptr<aura::Window> window0(CreateTestWindowInShellWithId(0)); | 543 std::unique_ptr<aura::Window> window0(CreateTestWindowInShellWithId(0)); |
544 scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); | 544 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); |
545 scoped_ptr<aura::Window> window2(CreateTestWindowInShellWithId(2)); | 545 std::unique_ptr<aura::Window> window2(CreateTestWindowInShellWithId(2)); |
546 scoped_ptr<aura::Window> panel0(CreatePanelWindow()); | 546 std::unique_ptr<aura::Window> panel0(CreatePanelWindow()); |
547 scoped_ptr<aura::Window> panel1(CreatePanelWindow()); | 547 std::unique_ptr<aura::Window> panel1(CreatePanelWindow()); |
548 wm::ActivateWindow(window2.get()); | 548 wm::ActivateWindow(window2.get()); |
549 wm::ActivateWindow(panel1.get()); | 549 wm::ActivateWindow(panel1.get()); |
550 wm::ActivateWindow(panel0.get()); | 550 wm::ActivateWindow(panel0.get()); |
551 wm::ActivateWindow(window1.get()); | 551 wm::ActivateWindow(window1.get()); |
552 wm::ActivateWindow(window0.get()); | 552 wm::ActivateWindow(window0.get()); |
553 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 553 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
554 | 554 |
555 // Cycling once highlights window2. | 555 // Cycling once highlights window2. |
556 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 556 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
557 // All panels are destroyed. | 557 // All panels are destroyed. |
558 panel0.reset(); | 558 panel0.reset(); |
559 panel1.reset(); | 559 panel1.reset(); |
560 // Cycling again should now select window2. | 560 // Cycling again should now select window2. |
561 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 561 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
562 controller->StopCycling(); | 562 controller->StopCycling(); |
563 EXPECT_TRUE(wm::IsActiveWindow(window2.get())); | 563 EXPECT_TRUE(wm::IsActiveWindow(window2.get())); |
564 } | 564 } |
565 | 565 |
566 // Tests cycles between panel and normal windows. | 566 // Tests cycles between panel and normal windows. |
567 TEST_F(WindowCycleControllerTest, CycleMruPanelDestroyed) { | 567 TEST_F(WindowCycleControllerTest, CycleMruPanelDestroyed) { |
568 WindowCycleController* controller = | 568 WindowCycleController* controller = |
569 Shell::GetInstance()->window_cycle_controller(); | 569 Shell::GetInstance()->window_cycle_controller(); |
570 | 570 |
571 scoped_ptr<aura::Window> window0(CreateTestWindowInShellWithId(0)); | 571 std::unique_ptr<aura::Window> window0(CreateTestWindowInShellWithId(0)); |
572 scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); | 572 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); |
573 scoped_ptr<aura::Window> panel0(CreatePanelWindow()); | 573 std::unique_ptr<aura::Window> panel0(CreatePanelWindow()); |
574 scoped_ptr<aura::Window> panel1(CreatePanelWindow()); | 574 std::unique_ptr<aura::Window> panel1(CreatePanelWindow()); |
575 wm::ActivateWindow(panel1.get()); | 575 wm::ActivateWindow(panel1.get()); |
576 wm::ActivateWindow(panel0.get()); | 576 wm::ActivateWindow(panel0.get()); |
577 wm::ActivateWindow(window1.get()); | 577 wm::ActivateWindow(window1.get()); |
578 wm::ActivateWindow(window0.get()); | 578 wm::ActivateWindow(window0.get()); |
579 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 579 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
580 | 580 |
581 // Cycling once highlights window2. | 581 // Cycling once highlights window2. |
582 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 582 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
583 | 583 |
584 // Panel 1 is the next item as the MRU panel, removing it should make panel 2 | 584 // Panel 1 is the next item as the MRU panel, removing it should make panel 2 |
585 // the next window to be selected. | 585 // the next window to be selected. |
586 panel0.reset(); | 586 panel0.reset(); |
587 // Cycling again should now select panel1. | 587 // Cycling again should now select panel1. |
588 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 588 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
589 controller->StopCycling(); | 589 controller->StopCycling(); |
590 EXPECT_TRUE(wm::IsActiveWindow(panel1.get())); | 590 EXPECT_TRUE(wm::IsActiveWindow(panel1.get())); |
591 } | 591 } |
592 | 592 |
593 } // namespace ash | 593 } // namespace ash |
OLD | NEW |