OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
sky
2012/10/17 16:25:20
This file has been nuked.
oshima
2012/10/17 17:49:43
rebased
| |
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/workspace/workspace_manager.h" | 5 #include "ash/wm/workspace/workspace_manager.h" |
6 | 6 |
7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
8 #include "ash/root_window_controller.h" | |
8 #include "ash/screen_ash.h" | 9 #include "ash/screen_ash.h" |
9 #include "ash/shell.h" | 10 #include "ash/shell.h" |
10 #include "ash/shell_window_ids.h" | 11 #include "ash/shell_window_ids.h" |
11 #include "ash/test/ash_test_base.h" | 12 #include "ash/test/ash_test_base.h" |
12 #include "ash/wm/activation_controller.h" | 13 #include "ash/wm/activation_controller.h" |
13 #include "ash/wm/property_util.h" | 14 #include "ash/wm/property_util.h" |
14 #include "ash/wm/shelf_layout_manager.h" | 15 #include "ash/wm/shelf_layout_manager.h" |
15 #include "ash/wm/window_util.h" | 16 #include "ash/wm/window_util.h" |
16 #include "ash/wm/workspace/workspace.h" | 17 #include "ash/wm/workspace/workspace.h" |
17 #include "ash/wm/workspace/workspace_layout_manager.h" | 18 #include "ash/wm/workspace/workspace_layout_manager.h" |
18 #include "ash/wm/workspace_controller_test_helper.h" | 19 #include "ash/wm/workspace_controller_test_helper.h" |
19 #include "base/command_line.h" | 20 #include "base/command_line.h" |
20 #include "ui/aura/client/aura_constants.h" | 21 #include "ui/aura/client/aura_constants.h" |
21 #include "ui/aura/root_window.h" | 22 #include "ui/aura/root_window.h" |
22 #include "ui/aura/test/event_generator.h" | 23 #include "ui/aura/test/event_generator.h" |
23 #include "ui/aura/window.h" | 24 #include "ui/aura/window.h" |
24 #include "ui/base/ui_base_types.h" | 25 #include "ui/base/ui_base_types.h" |
25 #include "ui/compositor/layer.h" | 26 #include "ui/compositor/layer.h" |
26 #include "ui/gfx/screen.h" | 27 #include "ui/gfx/screen.h" |
27 | 28 |
28 using aura::Window; | 29 using aura::Window; |
29 | 30 |
30 namespace ash { | 31 namespace ash { |
31 namespace internal { | 32 namespace internal { |
32 | 33 |
33 namespace { | |
34 | |
35 bool GetWindowOverlapsShelf() { | |
36 return Shell::GetInstance()->shelf()->window_overlaps_shelf(); | |
37 } | |
38 | |
39 } // namespace | |
40 | |
41 class WorkspaceManagerTest : public test::AshTestBase { | 34 class WorkspaceManagerTest : public test::AshTestBase { |
42 public: | 35 public: |
43 WorkspaceManagerTest() : manager_(NULL) {} | 36 WorkspaceManagerTest() : manager_(NULL) {} |
44 virtual ~WorkspaceManagerTest() {} | 37 virtual ~WorkspaceManagerTest() {} |
45 | 38 |
46 aura::Window* CreateTestWindowUnparented() { | 39 aura::Window* CreateTestWindowUnparented() { |
47 aura::Window* window = new aura::Window(NULL); | 40 aura::Window* window = new aura::Window(NULL); |
48 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | 41 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
49 window->SetType(aura::client::WINDOW_TYPE_NORMAL); | 42 window->SetType(aura::client::WINDOW_TYPE_NORMAL); |
50 window->Init(ui::LAYER_TEXTURED); | 43 window->Init(ui::LAYER_TEXTURED); |
(...skipping 20 matching lines...) Expand all Loading... | |
71 } | 64 } |
72 | 65 |
73 gfx::Rect GetFullscreenBounds(aura::Window* window) { | 66 gfx::Rect GetFullscreenBounds(aura::Window* window) { |
74 return Shell::GetScreen()->GetDisplayNearestWindow(window).bounds(); | 67 return Shell::GetScreen()->GetDisplayNearestWindow(window).bounds(); |
75 } | 68 } |
76 | 69 |
77 Workspace* active_workspace() { | 70 Workspace* active_workspace() { |
78 return manager_->active_workspace_; | 71 return manager_->active_workspace_; |
79 } | 72 } |
80 | 73 |
74 ShelfLayoutManager* shelf_layout_manager() { | |
75 return Shell::GetPrimaryRootWindowController()->shelf(); | |
76 } | |
77 | |
78 bool GetWindowOverlapsShelf() { | |
79 return shelf_layout_manager()->window_overlaps_shelf(); | |
80 } | |
81 | |
81 Workspace* FindBy(aura::Window* window) const { | 82 Workspace* FindBy(aura::Window* window) const { |
82 return manager_->FindBy(window); | 83 return manager_->FindBy(window); |
83 } | 84 } |
84 | 85 |
85 // Overridden from AshTestBase: | 86 // Overridden from AshTestBase: |
86 virtual void SetUp() OVERRIDE { | 87 virtual void SetUp() OVERRIDE { |
87 CommandLine::ForCurrentProcess()->AppendSwitch( | 88 CommandLine::ForCurrentProcess()->AppendSwitch( |
88 switches::kAshDisableWorkspace2); | 89 switches::kAshDisableWorkspace2); |
89 test::AshTestBase::SetUp(); | 90 test::AshTestBase::SetUp(); |
90 WorkspaceControllerTestHelper workspace_helper( | 91 WorkspaceControllerTestHelper workspace_helper( |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
463 TEST_F(WorkspaceManagerTest, ShelfStateUpdated) { | 464 TEST_F(WorkspaceManagerTest, ShelfStateUpdated) { |
464 // Since ShelfLayoutManager queries for mouse location, move the mouse so | 465 // Since ShelfLayoutManager queries for mouse location, move the mouse so |
465 // it isn't over the shelf. | 466 // it isn't over the shelf. |
466 aura::test::EventGenerator generator( | 467 aura::test::EventGenerator generator( |
467 Shell::GetPrimaryRootWindow(), gfx::Point()); | 468 Shell::GetPrimaryRootWindow(), gfx::Point()); |
468 generator.MoveMouseTo(0, 0); | 469 generator.MoveMouseTo(0, 0); |
469 | 470 |
470 // Two windows, w1 normal, w2 maximized. | 471 // Two windows, w1 normal, w2 maximized. |
471 scoped_ptr<Window> w1(CreateTestWindow()); | 472 scoped_ptr<Window> w1(CreateTestWindow()); |
472 const gfx::Rect w1_bounds(0, 1, 101, 102); | 473 const gfx::Rect w1_bounds(0, 1, 101, 102); |
473 ShelfLayoutManager* shelf = Shell::GetInstance()->shelf(); | 474 ShelfLayoutManager* shelf = shelf_layout_manager(); |
474 shelf->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 475 shelf->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
475 const gfx::Rect touches_shelf_bounds( | 476 const gfx::Rect touches_shelf_bounds( |
476 0, shelf->GetIdealBounds().y() - 10, 101, 102); | 477 0, shelf->GetIdealBounds().y() - 10, 101, 102); |
477 // Move |w1| to overlap the shelf. | 478 // Move |w1| to overlap the shelf. |
478 w1->SetBounds(touches_shelf_bounds); | 479 w1->SetBounds(touches_shelf_bounds); |
479 EXPECT_FALSE(GetWindowOverlapsShelf()); | 480 EXPECT_FALSE(GetWindowOverlapsShelf()); |
480 | 481 |
481 // A visible ignored window should not trigger the overlap. | 482 // A visible ignored window should not trigger the overlap. |
482 scoped_ptr<Window> w_ignored(CreateTestWindow()); | 483 scoped_ptr<Window> w_ignored(CreateTestWindow()); |
483 w_ignored->SetBounds(touches_shelf_bounds); | 484 w_ignored->SetBounds(touches_shelf_bounds); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
615 wm::ActivateWindow(w1.get()); | 616 wm::ActivateWindow(w1.get()); |
616 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); | 617 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); |
617 EXPECT_FALSE(w1->IsVisible()); | 618 EXPECT_FALSE(w1->IsVisible()); |
618 w1->Show(); | 619 w1->Show(); |
619 EXPECT_TRUE(w1->IsVisible()); | 620 EXPECT_TRUE(w1->IsVisible()); |
620 } | 621 } |
621 | 622 |
622 // Test that we report we're in the fullscreen state even if the fullscreen | 623 // Test that we report we're in the fullscreen state even if the fullscreen |
623 // window isn't being managed by us (http://crbug.com/123931). | 624 // window isn't being managed by us (http://crbug.com/123931). |
624 TEST_F(WorkspaceManagerTest, GetWindowStateWithUnmanagedFullscreenWindow) { | 625 TEST_F(WorkspaceManagerTest, GetWindowStateWithUnmanagedFullscreenWindow) { |
625 ShelfLayoutManager* shelf = Shell::GetInstance()->shelf(); | 626 ShelfLayoutManager* shelf = shelf_layout_manager(); |
626 | 627 |
627 // We need to create a regular window first so there's an active workspace. | 628 // We need to create a regular window first so there's an active workspace. |
628 scoped_ptr<Window> w1(CreateTestWindow()); | 629 scoped_ptr<Window> w1(CreateTestWindow()); |
629 w1->Show(); | 630 w1->Show(); |
630 | 631 |
631 scoped_ptr<Window> w2(CreateTestWindow()); | 632 scoped_ptr<Window> w2(CreateTestWindow()); |
632 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); | 633 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
633 SetPersistsAcrossAllWorkspaces( | 634 SetPersistsAcrossAllWorkspaces( |
634 w2.get(), | 635 w2.get(), |
635 WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_YES); | 636 WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_YES); |
(...skipping 11 matching lines...) Expand all Loading... | |
647 EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state()); | 648 EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state()); |
648 | 649 |
649 w2.reset(); | 650 w2.reset(); |
650 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); | 651 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); |
651 } | 652 } |
652 | 653 |
653 // Variant of GetWindowStateWithUnmanagedFullscreenWindow that uses a maximized | 654 // Variant of GetWindowStateWithUnmanagedFullscreenWindow that uses a maximized |
654 // window rather than a normal window. | 655 // window rather than a normal window. |
655 TEST_F(WorkspaceManagerTest, | 656 TEST_F(WorkspaceManagerTest, |
656 GetWindowStateWithUnmanagedFullscreenWindowWithMaximized) { | 657 GetWindowStateWithUnmanagedFullscreenWindowWithMaximized) { |
657 ShelfLayoutManager* shelf = Shell::GetInstance()->shelf(); | 658 ShelfLayoutManager* shelf = shelf_layout_manager(); |
658 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 659 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
659 | 660 |
660 // Make the first window maximized. | 661 // Make the first window maximized. |
661 scoped_ptr<Window> w1(CreateTestWindow()); | 662 scoped_ptr<Window> w1(CreateTestWindow()); |
662 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 663 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
663 w1->Show(); | 664 w1->Show(); |
664 | 665 |
665 scoped_ptr<Window> w2(CreateTestWindow()); | 666 scoped_ptr<Window> w2(CreateTestWindow()); |
666 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); | 667 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
667 SetPersistsAcrossAllWorkspaces( | 668 SetPersistsAcrossAllWorkspaces( |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
726 | 727 |
727 // Verifies going from maximized to minimized sets the right state for painting | 728 // Verifies going from maximized to minimized sets the right state for painting |
728 // the background of the launcher. | 729 // the background of the launcher. |
729 TEST_F(WorkspaceManagerTest, MinimizeResetsVisibility) { | 730 TEST_F(WorkspaceManagerTest, MinimizeResetsVisibility) { |
730 scoped_ptr<Window> w1(CreateTestWindow()); | 731 scoped_ptr<Window> w1(CreateTestWindow()); |
731 w1->Show(); | 732 w1->Show(); |
732 wm::ActivateWindow(w1.get()); | 733 wm::ActivateWindow(w1.get()); |
733 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 734 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
734 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); | 735 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); |
735 EXPECT_EQ(ShelfLayoutManager::VISIBLE, | 736 EXPECT_EQ(ShelfLayoutManager::VISIBLE, |
736 Shell::GetInstance()->shelf()->visibility_state()); | 737 shelf_layout_manager()->visibility_state()); |
737 EXPECT_FALSE(Shell::GetInstance()->launcher()->paints_background()); | 738 EXPECT_FALSE(Launcher::ForPrimaryDisplay()->paints_background()); |
738 } | 739 } |
739 | 740 |
740 } // namespace internal | 741 } // namespace internal |
741 } // namespace ash | 742 } // namespace ash |
OLD | NEW |