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

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

Issue 2194353002: mash: Migrate ScopedTargetRootWindow to //ash/common (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: non-virtual Created 4 years, 4 months 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
« no previous file with comments | « ash/shell.cc ('k') | ash/wm/window_positioner_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 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/common/wm/window_cycle_controller.h" 5 #include "ash/common/wm/window_cycle_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 9
10 #include "ash/aura/wm_window_aura.h" 10 #include "ash/aura/wm_window_aura.h"
11 #include "ash/common/focus_cycler.h" 11 #include "ash/common/focus_cycler.h"
12 #include "ash/common/scoped_root_window_for_new_windows.h"
12 #include "ash/common/session/session_state_delegate.h" 13 #include "ash/common/session/session_state_delegate.h"
13 #include "ash/common/shell_window_ids.h" 14 #include "ash/common/shell_window_ids.h"
14 #include "ash/common/wm/window_cycle_list.h" 15 #include "ash/common/wm/window_cycle_list.h"
15 #include "ash/common/wm/window_state.h" 16 #include "ash/common/wm/window_state.h"
16 #include "ash/common/wm_shell.h" 17 #include "ash/common/wm_shell.h"
17 #include "ash/shelf/shelf.h" 18 #include "ash/shelf/shelf.h"
18 #include "ash/shelf/shelf_widget.h" 19 #include "ash/shelf/shelf_widget.h"
19 #include "ash/shell.h" 20 #include "ash/shell.h"
20 #include "ash/test/ash_test_base.h" 21 #include "ash/test/ash_test_base.h"
21 #include "ash/test/shelf_test_api.h" 22 #include "ash/test/shelf_test_api.h"
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 if (!SupportsMultipleDisplays()) 371 if (!SupportsMultipleDisplays())
371 return; 372 return;
372 373
373 // Set up a second root window 374 // Set up a second root window
374 UpdateDisplay("1000x600,600x400"); 375 UpdateDisplay("1000x600,600x400");
375 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 376 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
376 ASSERT_EQ(2U, root_windows.size()); 377 ASSERT_EQ(2U, root_windows.size());
377 378
378 WindowCycleController* controller = WmShell::Get()->window_cycle_controller(); 379 WindowCycleController* controller = WmShell::Get()->window_cycle_controller();
379 380
380 Shell::GetInstance()->set_target_root_window(root_windows[0]);
381
382 // Create two windows in the primary root. 381 // Create two windows in the primary root.
383 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0)); 382 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0));
384 EXPECT_EQ(root_windows[0], window0->GetRootWindow()); 383 EXPECT_EQ(root_windows[0], window0->GetRootWindow());
385 Window* top_container0 = 384 Window* top_container0 =
386 Shell::GetContainer(root_windows[0], kShellWindowId_AlwaysOnTopContainer); 385 Shell::GetContainer(root_windows[0], kShellWindowId_AlwaysOnTopContainer);
387 std::unique_ptr<Window> window1(CreateTestWindowWithId(1, top_container0)); 386 std::unique_ptr<Window> window1(CreateTestWindowWithId(1, top_container0));
388 EXPECT_EQ(root_windows[0], window1->GetRootWindow()); 387 EXPECT_EQ(root_windows[0], window1->GetRootWindow());
389 388
390 // And two on the secondary root. 389 // Move the active root window to the secondary root and create two windows.
391 Shell::GetInstance()->set_target_root_window(root_windows[1]); 390 ScopedRootWindowForNewWindows root_for_new_windows(
391 WmWindowAura::Get(root_windows[1]));
392 std::unique_ptr<Window> window2(CreateTestWindowInShellWithId(2)); 392 std::unique_ptr<Window> window2(CreateTestWindowInShellWithId(2));
393 EXPECT_EQ(root_windows[1], window2->GetRootWindow()); 393 EXPECT_EQ(root_windows[1], window2->GetRootWindow());
394 394
395 Window* top_container1 = 395 Window* top_container1 =
396 Shell::GetContainer(root_windows[1], kShellWindowId_AlwaysOnTopContainer); 396 Shell::GetContainer(root_windows[1], kShellWindowId_AlwaysOnTopContainer);
397 std::unique_ptr<Window> window3(CreateTestWindowWithId(3, top_container1)); 397 std::unique_ptr<Window> window3(CreateTestWindowWithId(3, top_container1));
398 EXPECT_EQ(root_windows[1], window3->GetRootWindow()); 398 EXPECT_EQ(root_windows[1], window3->GetRootWindow());
399 399
400 // Move the active root window to the secondary.
401 Shell::GetInstance()->set_target_root_window(root_windows[1]);
402
403 wm::ActivateWindow(window2.get()); 400 wm::ActivateWindow(window2.get());
404 401
405 EXPECT_EQ(root_windows[0], window0->GetRootWindow()); 402 EXPECT_EQ(root_windows[0], window0->GetRootWindow());
406 EXPECT_EQ(root_windows[0], window1->GetRootWindow()); 403 EXPECT_EQ(root_windows[0], window1->GetRootWindow());
407 EXPECT_EQ(root_windows[1], window2->GetRootWindow()); 404 EXPECT_EQ(root_windows[1], window2->GetRootWindow());
408 EXPECT_EQ(root_windows[1], window3->GetRootWindow()); 405 EXPECT_EQ(root_windows[1], window3->GetRootWindow());
409 406
410 // Simulate pressing and releasing Alt-tab. 407 // Simulate pressing and releasing Alt-tab.
411 EXPECT_TRUE(wm::IsActiveWindow(window2.get())); 408 EXPECT_TRUE(wm::IsActiveWindow(window2.get()));
412 controller->HandleCycleWindow(WindowCycleController::FORWARD); 409 controller->HandleCycleWindow(WindowCycleController::FORWARD);
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 generator.PressKey(ui::VKEY_TAB, ui::EF_ALT_DOWN); 609 generator.PressKey(ui::VKEY_TAB, ui::EF_ALT_DOWN);
613 EXPECT_EQ(0u, key_count.GetCountAndReset()); 610 EXPECT_EQ(0u, key_count.GetCountAndReset());
614 generator.ReleaseKey(ui::VKEY_TAB, ui::EF_ALT_DOWN); 611 generator.ReleaseKey(ui::VKEY_TAB, ui::EF_ALT_DOWN);
615 EXPECT_EQ(0u, key_count.GetCountAndReset()); 612 EXPECT_EQ(0u, key_count.GetCountAndReset());
616 generator.ReleaseKey(ui::VKEY_MENU, ui::EF_NONE); 613 generator.ReleaseKey(ui::VKEY_MENU, ui::EF_NONE);
617 EXPECT_TRUE(wm::GetWindowState(w1.get())->IsActive()); 614 EXPECT_TRUE(wm::GetWindowState(w1.get())->IsActive());
618 EXPECT_EQ(0u, key_count.GetCountAndReset()); 615 EXPECT_EQ(0u, key_count.GetCountAndReset());
619 } 616 }
620 617
621 } // namespace ash 618 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shell.cc ('k') | ash/wm/window_positioner_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698