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

Side by Side Diff: ash/wm/window_cycle_controller_unittest.cc

Issue 11421006: Desktop aura: Break aura::Window::SetParent in two. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix ash_unittests Created 8 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 | « ash/wm/window_animations_unittest.cc ('k') | ash/wm/window_manager_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) 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/display_manager.h" 10 #include "ash/display/display_manager.h"
(...skipping 23 matching lines...) Expand all
34 typedef test::AshTestBase WindowCycleControllerTest; 34 typedef test::AshTestBase WindowCycleControllerTest;
35 35
36 TEST_F(WindowCycleControllerTest, HandleCycleWindowBaseCases) { 36 TEST_F(WindowCycleControllerTest, HandleCycleWindowBaseCases) {
37 WindowCycleController* controller = 37 WindowCycleController* controller =
38 Shell::GetInstance()->window_cycle_controller(); 38 Shell::GetInstance()->window_cycle_controller();
39 39
40 // Cycling doesn't crash if there are no windows. 40 // Cycling doesn't crash if there are no windows.
41 controller->HandleCycleWindow(WindowCycleController::FORWARD, false); 41 controller->HandleCycleWindow(WindowCycleController::FORWARD, false);
42 42
43 // Create a single test window. 43 // Create a single test window.
44 scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL)); 44 scoped_ptr<Window> window0(CreateTestWindowInShellWithId(0));
45 wm::ActivateWindow(window0.get()); 45 wm::ActivateWindow(window0.get());
46 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); 46 EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
47 47
48 // Cycling works for a single window, even though nothing changes. 48 // Cycling works for a single window, even though nothing changes.
49 controller->HandleCycleWindow(WindowCycleController::FORWARD, false); 49 controller->HandleCycleWindow(WindowCycleController::FORWARD, false);
50 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); 50 EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
51 } 51 }
52 52
53 // Verifies if there is only one window and it isn't active that cycling 53 // Verifies if there is only one window and it isn't active that cycling
54 // activates it. 54 // activates it.
55 TEST_F(WindowCycleControllerTest, SingleWindowNotActive) { 55 TEST_F(WindowCycleControllerTest, SingleWindowNotActive) {
56 WindowCycleController* controller = 56 WindowCycleController* controller =
57 Shell::GetInstance()->window_cycle_controller(); 57 Shell::GetInstance()->window_cycle_controller();
58 58
59 // Create a single test window. 59 // Create a single test window.
60 scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL)); 60 scoped_ptr<Window> window0(CreateTestWindowInShellWithId(0));
61 wm::ActivateWindow(window0.get()); 61 wm::ActivateWindow(window0.get());
62 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); 62 EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
63 63
64 // Rotate focus, this should move focus to another window that isn't part of 64 // Rotate focus, this should move focus to another window that isn't part of
65 // the default container. 65 // the default container.
66 Shell::GetInstance()->RotateFocus(Shell::FORWARD); 66 Shell::GetInstance()->RotateFocus(Shell::FORWARD);
67 EXPECT_FALSE(wm::IsActiveWindow(window0.get())); 67 EXPECT_FALSE(wm::IsActiveWindow(window0.get()));
68 68
69 // Cycling should activate the window. 69 // Cycling should activate the window.
70 controller->HandleCycleWindow(WindowCycleController::FORWARD, false); 70 controller->HandleCycleWindow(WindowCycleController::FORWARD, false);
71 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); 71 EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
72 } 72 }
73 73
74 TEST_F(WindowCycleControllerTest, HandleCycleWindow) { 74 TEST_F(WindowCycleControllerTest, HandleCycleWindow) {
75 WindowCycleController* controller = 75 WindowCycleController* controller =
76 Shell::GetInstance()->window_cycle_controller(); 76 Shell::GetInstance()->window_cycle_controller();
77 77
78 // Set up several windows to use to test cycling. Create them in reverse 78 // Set up several windows to use to test cycling. Create them in reverse
79 // order so they are stacked 0 over 1 over 2. 79 // order so they are stacked 0 over 1 over 2.
80 scoped_ptr<Window> window2(CreateTestWindowWithId(2, NULL)); 80 scoped_ptr<Window> window2(CreateTestWindowInShellWithId(2));
81 scoped_ptr<Window> window1(CreateTestWindowWithId(1, NULL)); 81 scoped_ptr<Window> window1(CreateTestWindowInShellWithId(1));
82 scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL)); 82 scoped_ptr<Window> window0(CreateTestWindowInShellWithId(0));
83 wm::ActivateWindow(window0.get()); 83 wm::ActivateWindow(window0.get());
84 84
85 // Simulate pressing and releasing Alt-tab. 85 // Simulate pressing and releasing Alt-tab.
86 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); 86 EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
87 controller->HandleCycleWindow(WindowCycleController::FORWARD, true); 87 controller->HandleCycleWindow(WindowCycleController::FORWARD, true);
88 88
89 // Window lists should return the topmost window in front. 89 // Window lists should return the topmost window in front.
90 ASSERT_TRUE(controller->windows()); 90 ASSERT_TRUE(controller->windows());
91 ASSERT_EQ(3u, controller->windows()->windows().size()); 91 ASSERT_EQ(3u, controller->windows()->windows().size());
92 ASSERT_EQ(window0.get(), controller->windows()->windows()[0]); 92 ASSERT_EQ(window0.get(), controller->windows()->windows()[0]);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 controller->HandleCycleWindow(WindowCycleController::BACKWARD, false); 177 controller->HandleCycleWindow(WindowCycleController::BACKWARD, false);
178 EXPECT_TRUE(wm::IsActiveWindow(modal_window.get())); 178 EXPECT_TRUE(wm::IsActiveWindow(modal_window.get()));
179 EXPECT_FALSE(wm::IsActiveWindow(window0.get())); 179 EXPECT_FALSE(wm::IsActiveWindow(window0.get()));
180 EXPECT_FALSE(wm::IsActiveWindow(window1.get())); 180 EXPECT_FALSE(wm::IsActiveWindow(window1.get()));
181 EXPECT_FALSE(wm::IsActiveWindow(window2.get())); 181 EXPECT_FALSE(wm::IsActiveWindow(window2.get()));
182 } 182 }
183 183
184 // Cycles between a maximized and normal window. 184 // Cycles between a maximized and normal window.
185 TEST_F(WindowCycleControllerTest, MaximizedWindow) { 185 TEST_F(WindowCycleControllerTest, MaximizedWindow) {
186 // Create a couple of test windows. 186 // Create a couple of test windows.
187 scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL)); 187 scoped_ptr<Window> window0(CreateTestWindowInShellWithId(0));
188 scoped_ptr<Window> window1(CreateTestWindowWithId(1, NULL)); 188 scoped_ptr<Window> window1(CreateTestWindowInShellWithId(1));
189 189
190 wm::MaximizeWindow(window1.get()); 190 wm::MaximizeWindow(window1.get());
191 wm::ActivateWindow(window1.get()); 191 wm::ActivateWindow(window1.get());
192 EXPECT_TRUE(wm::IsActiveWindow(window1.get())); 192 EXPECT_TRUE(wm::IsActiveWindow(window1.get()));
193 193
194 // Rotate focus, this should move focus to window0. 194 // Rotate focus, this should move focus to window0.
195 WindowCycleController* controller = 195 WindowCycleController* controller =
196 Shell::GetInstance()->window_cycle_controller(); 196 Shell::GetInstance()->window_cycle_controller();
197 controller->HandleCycleWindow(WindowCycleController::FORWARD, false); 197 controller->HandleCycleWindow(WindowCycleController::FORWARD, false);
198 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); 198 EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
199 199
200 // One more time. 200 // One more time.
201 controller->HandleCycleWindow(WindowCycleController::FORWARD, false); 201 controller->HandleCycleWindow(WindowCycleController::FORWARD, false);
202 EXPECT_TRUE(wm::IsActiveWindow(window1.get())); 202 EXPECT_TRUE(wm::IsActiveWindow(window1.get()));
203 } 203 }
204 204
205 // Cycles to a minimized window. 205 // Cycles to a minimized window.
206 TEST_F(WindowCycleControllerTest, Minimized) { 206 TEST_F(WindowCycleControllerTest, Minimized) {
207 // Create a couple of test windows. 207 // Create a couple of test windows.
208 scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL)); 208 scoped_ptr<Window> window0(CreateTestWindowInShellWithId(0));
209 scoped_ptr<Window> window1(CreateTestWindowWithId(1, NULL)); 209 scoped_ptr<Window> window1(CreateTestWindowInShellWithId(1));
210 210
211 wm::MinimizeWindow(window1.get()); 211 wm::MinimizeWindow(window1.get());
212 wm::ActivateWindow(window0.get()); 212 wm::ActivateWindow(window0.get());
213 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); 213 EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
214 214
215 // Rotate focus, this should move focus to window1 and unminimize it. 215 // Rotate focus, this should move focus to window1 and unminimize it.
216 WindowCycleController* controller = 216 WindowCycleController* controller =
217 Shell::GetInstance()->window_cycle_controller(); 217 Shell::GetInstance()->window_cycle_controller();
218 controller->HandleCycleWindow(WindowCycleController::FORWARD, false); 218 controller->HandleCycleWindow(WindowCycleController::FORWARD, false);
219 EXPECT_FALSE(wm::IsWindowMinimized(window1.get())); 219 EXPECT_FALSE(wm::IsWindowMinimized(window1.get()));
220 EXPECT_TRUE(wm::IsActiveWindow(window1.get())); 220 EXPECT_TRUE(wm::IsActiveWindow(window1.get()));
221 221
222 // One more time back to w0. 222 // One more time back to w0.
223 controller->HandleCycleWindow(WindowCycleController::FORWARD, false); 223 controller->HandleCycleWindow(WindowCycleController::FORWARD, false);
224 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); 224 EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
225 } 225 }
226 226
227 TEST_F(WindowCycleControllerTest, AlwaysOnTopWindow) { 227 TEST_F(WindowCycleControllerTest, AlwaysOnTopWindow) {
228 WindowCycleController* controller = 228 WindowCycleController* controller =
229 Shell::GetInstance()->window_cycle_controller(); 229 Shell::GetInstance()->window_cycle_controller();
230 230
231 // Set up several windows to use to test cycling. 231 // Set up several windows to use to test cycling.
232 scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL)); 232 scoped_ptr<Window> window0(CreateTestWindowInShellWithId(0));
233 scoped_ptr<Window> window1(CreateTestWindowWithId(1, NULL)); 233 scoped_ptr<Window> window1(CreateTestWindowInShellWithId(1));
234 234
235 Window* top_container = 235 Window* top_container =
236 Shell::GetContainer( 236 Shell::GetContainer(
237 Shell::GetPrimaryRootWindow(), 237 Shell::GetPrimaryRootWindow(),
238 internal::kShellWindowId_AlwaysOnTopContainer); 238 internal::kShellWindowId_AlwaysOnTopContainer);
239 scoped_ptr<Window> window2(CreateTestWindowWithId(2, top_container)); 239 scoped_ptr<Window> window2(CreateTestWindowWithId(2, top_container));
240 wm::ActivateWindow(window0.get()); 240 wm::ActivateWindow(window0.get());
241 241
242 // Simulate pressing and releasing Alt-tab. 242 // Simulate pressing and releasing Alt-tab.
243 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); 243 EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
(...skipping 22 matching lines...) Expand all
266 266
267 controller->HandleCycleWindow(WindowCycleController::FORWARD, true); 267 controller->HandleCycleWindow(WindowCycleController::FORWARD, true);
268 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); 268 EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
269 } 269 }
270 270
271 TEST_F(WindowCycleControllerTest, AlwaysOnTopMultiWindow) { 271 TEST_F(WindowCycleControllerTest, AlwaysOnTopMultiWindow) {
272 WindowCycleController* controller = 272 WindowCycleController* controller =
273 Shell::GetInstance()->window_cycle_controller(); 273 Shell::GetInstance()->window_cycle_controller();
274 274
275 // Set up several windows to use to test cycling. 275 // Set up several windows to use to test cycling.
276 scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL)); 276 scoped_ptr<Window> window0(CreateTestWindowInShellWithId(0));
277 scoped_ptr<Window> window1(CreateTestWindowWithId(1, NULL)); 277 scoped_ptr<Window> window1(CreateTestWindowInShellWithId(1));
278 278
279 Window* top_container = 279 Window* top_container =
280 Shell::GetContainer( 280 Shell::GetContainer(
281 Shell::GetPrimaryRootWindow(), 281 Shell::GetPrimaryRootWindow(),
282 internal::kShellWindowId_AlwaysOnTopContainer); 282 internal::kShellWindowId_AlwaysOnTopContainer);
283 scoped_ptr<Window> window2(CreateTestWindowWithId(2, top_container)); 283 scoped_ptr<Window> window2(CreateTestWindowWithId(2, top_container));
284 scoped_ptr<Window> window3(CreateTestWindowWithId(3, top_container)); 284 scoped_ptr<Window> window3(CreateTestWindowWithId(3, top_container));
285 wm::ActivateWindow(window0.get()); 285 wm::ActivateWindow(window0.get());
286 286
287 // Simulate pressing and releasing Alt-tab. 287 // Simulate pressing and releasing Alt-tab.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 UpdateDisplay("0+0-1000x600,1001+0-600x400"); 322 UpdateDisplay("0+0-1000x600,1001+0-600x400");
323 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); 323 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
324 ASSERT_EQ(2U, root_windows.size()); 324 ASSERT_EQ(2U, root_windows.size());
325 325
326 WindowCycleController* controller = 326 WindowCycleController* controller =
327 Shell::GetInstance()->window_cycle_controller(); 327 Shell::GetInstance()->window_cycle_controller();
328 328
329 Shell::GetInstance()->set_active_root_window(root_windows[0]); 329 Shell::GetInstance()->set_active_root_window(root_windows[0]);
330 330
331 // Create two windows in the primary root. 331 // Create two windows in the primary root.
332 scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL)); 332 scoped_ptr<Window> window0(CreateTestWindowInShellWithId(0));
333 EXPECT_EQ(root_windows[0], window0->GetRootWindow()); 333 EXPECT_EQ(root_windows[0], window0->GetRootWindow());
334 Window* top_container0 = 334 Window* top_container0 =
335 Shell::GetContainer( 335 Shell::GetContainer(
336 root_windows[0], 336 root_windows[0],
337 internal::kShellWindowId_AlwaysOnTopContainer); 337 internal::kShellWindowId_AlwaysOnTopContainer);
338 scoped_ptr<Window> window1(CreateTestWindowWithId(1, top_container0)); 338 scoped_ptr<Window> window1(CreateTestWindowWithId(1, top_container0));
339 EXPECT_EQ(root_windows[0], window1->GetRootWindow()); 339 EXPECT_EQ(root_windows[0], window1->GetRootWindow());
340 340
341 // And two on the secondary root. 341 // And two on the secondary root.
342 Shell::GetInstance()->set_active_root_window(root_windows[1]); 342 Shell::GetInstance()->set_active_root_window(root_windows[1]);
343 scoped_ptr<Window> window2(CreateTestWindowWithId(2, NULL)); 343 scoped_ptr<Window> window2(CreateTestWindowInShellWithId(2));
344 EXPECT_EQ(root_windows[1], window2->GetRootWindow()); 344 EXPECT_EQ(root_windows[1], window2->GetRootWindow());
345 345
346 Window* top_container1 = 346 Window* top_container1 =
347 Shell::GetContainer( 347 Shell::GetContainer(
348 root_windows[1], 348 root_windows[1],
349 internal::kShellWindowId_AlwaysOnTopContainer); 349 internal::kShellWindowId_AlwaysOnTopContainer);
350 scoped_ptr<Window> window3(CreateTestWindowWithId(3, top_container1)); 350 scoped_ptr<Window> window3(CreateTestWindowWithId(3, top_container1));
351 EXPECT_EQ(root_windows[1], window3->GetRootWindow()); 351 EXPECT_EQ(root_windows[1], window3->GetRootWindow());
352 352
353 // Move the active root window to the secondary. 353 // Move the active root window to the secondary.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 391
392 controller->HandleCycleWindow(WindowCycleController::FORWARD, true); 392 controller->HandleCycleWindow(WindowCycleController::FORWARD, true);
393 EXPECT_TRUE(wm::IsActiveWindow(window2.get())); 393 EXPECT_TRUE(wm::IsActiveWindow(window2.get()));
394 } 394 }
395 395
396 TEST_F(WindowCycleControllerTest, MostRecentlyUsed) { 396 TEST_F(WindowCycleControllerTest, MostRecentlyUsed) {
397 WindowCycleController* controller = 397 WindowCycleController* controller =
398 Shell::GetInstance()->window_cycle_controller(); 398 Shell::GetInstance()->window_cycle_controller();
399 399
400 // Set up several windows to use to test cycling. 400 // Set up several windows to use to test cycling.
401 scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL)); 401 scoped_ptr<Window> window0(CreateTestWindowInShellWithId(0));
402 scoped_ptr<Window> window1(CreateTestWindowWithId(1, NULL)); 402 scoped_ptr<Window> window1(CreateTestWindowInShellWithId(1));
403 scoped_ptr<Window> window2(CreateTestWindowWithId(2, NULL)); 403 scoped_ptr<Window> window2(CreateTestWindowInShellWithId(2));
404 404
405 wm::ActivateWindow(window0.get()); 405 wm::ActivateWindow(window0.get());
406 406
407 // Simulate pressing and releasing Alt-tab. 407 // Simulate pressing and releasing Alt-tab.
408 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); 408 EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
409 controller->HandleCycleWindow(WindowCycleController::FORWARD, true); 409 controller->HandleCycleWindow(WindowCycleController::FORWARD, true);
410 410
411 // Window lists should return the topmost window in front. 411 // Window lists should return the topmost window in front.
412 ASSERT_TRUE(controller->windows()); 412 ASSERT_TRUE(controller->windows());
413 ASSERT_EQ(3u, controller->windows()->windows().size()); 413 ASSERT_EQ(3u, controller->windows()->windows().size());
(...skipping 17 matching lines...) Expand all
431 controller->HandleCycleWindow(WindowCycleController::FORWARD, true); 431 controller->HandleCycleWindow(WindowCycleController::FORWARD, true);
432 EXPECT_TRUE(wm::IsActiveWindow(window2.get())); 432 EXPECT_TRUE(wm::IsActiveWindow(window2.get()));
433 433
434 controller->HandleCycleWindow(WindowCycleController::FORWARD, true); 434 controller->HandleCycleWindow(WindowCycleController::FORWARD, true);
435 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); 435 EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
436 } 436 }
437 437
438 } // namespace 438 } // namespace
439 439
440 } // namespace ash 440 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/window_animations_unittest.cc ('k') | ash/wm/window_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698