| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/workspace_controller.h" | 5 #include "ash/wm/workspace_controller.h" |
| 6 | 6 |
| 7 #include "ash/shell_window_ids.h" | 7 #include "ash/shell_window_ids.h" |
| 8 #include "ash/wm/activation_controller.h" | 8 #include "ash/wm/activation_controller.h" |
| 9 #include "ash/wm/window_util.h" | 9 #include "ash/wm/window_util.h" |
| 10 #include "ash/wm/workspace/workspace.h" | 10 #include "ash/wm/workspace/workspace.h" |
| 11 #include "ash/wm/workspace/workspace_manager.h" | 11 #include "ash/wm/workspace/workspace_manager.h" |
| 12 #include "ui/aura/test/aura_test_base.h" | 12 #include "ui/aura/test/aura_test_base.h" |
| 13 #include "ui/aura/root_window.h" | 13 #include "ui/aura/root_window.h" |
| 14 #include "ui/aura/window.h" | 14 #include "ui/aura/window.h" |
| 15 | 15 |
| 16 namespace aura_shell { | 16 namespace ash { |
| 17 namespace internal { | 17 namespace internal { |
| 18 | 18 |
| 19 using aura::Window; | 19 using aura::Window; |
| 20 | 20 |
| 21 class WorkspaceControllerTest : public aura::test::AuraTestBase { | 21 class WorkspaceControllerTest : public aura::test::AuraTestBase { |
| 22 public: | 22 public: |
| 23 WorkspaceControllerTest() {} | 23 WorkspaceControllerTest() {} |
| 24 virtual ~WorkspaceControllerTest() {} | 24 virtual ~WorkspaceControllerTest() {} |
| 25 | 25 |
| 26 virtual void SetUp() OVERRIDE { | 26 virtual void SetUp() OVERRIDE { |
| 27 aura::test::AuraTestBase::SetUp(); | 27 aura::test::AuraTestBase::SetUp(); |
| 28 contents_view_ = aura::RootWindow::GetInstance(); | 28 contents_view_ = aura::RootWindow::GetInstance(); |
| 29 // Activatable windows need to be in a container the ActivationController | 29 // Activatable windows need to be in a container the ActivationController |
| 30 // recognizes. | 30 // recognizes. |
| 31 contents_view_->set_id( | 31 contents_view_->set_id( |
| 32 aura_shell::internal::kShellWindowId_DefaultContainer); | 32 ash::internal::kShellWindowId_DefaultContainer); |
| 33 activation_controller_.reset(new ActivationController); | 33 activation_controller_.reset(new ActivationController); |
| 34 activation_controller_->set_default_container_for_test(contents_view_); | 34 activation_controller_->set_default_container_for_test(contents_view_); |
| 35 controller_.reset(new WorkspaceController(contents_view_)); | 35 controller_.reset(new WorkspaceController(contents_view_)); |
| 36 } | 36 } |
| 37 | 37 |
| 38 virtual void TearDown() OVERRIDE { | 38 virtual void TearDown() OVERRIDE { |
| 39 activation_controller_.reset(); | 39 activation_controller_.reset(); |
| 40 controller_.reset(); | 40 controller_.reset(); |
| 41 aura::test::AuraTestBase::TearDown(); | 41 aura::test::AuraTestBase::TearDown(); |
| 42 } | 42 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 // and ws2 which contains window w2. | 74 // and ws2 which contains window w2. |
| 75 Workspace* ws1 = workspace_manager()->CreateWorkspace(); | 75 Workspace* ws1 = workspace_manager()->CreateWorkspace(); |
| 76 scoped_ptr<Window> w1(CreateTestWindow()); | 76 scoped_ptr<Window> w1(CreateTestWindow()); |
| 77 EXPECT_TRUE(ws1->AddWindowAfter(w1.get(), NULL)); | 77 EXPECT_TRUE(ws1->AddWindowAfter(w1.get(), NULL)); |
| 78 | 78 |
| 79 Workspace* ws2 = workspace_manager()->CreateWorkspace(); | 79 Workspace* ws2 = workspace_manager()->CreateWorkspace(); |
| 80 scoped_ptr<Window> w2(CreateTestWindow()); | 80 scoped_ptr<Window> w2(CreateTestWindow()); |
| 81 EXPECT_TRUE(ws2->AddWindowAfter(w2.get(), NULL)); | 81 EXPECT_TRUE(ws2->AddWindowAfter(w2.get(), NULL)); |
| 82 | 82 |
| 83 // Activating a window switches the active workspace. | 83 // Activating a window switches the active workspace. |
| 84 aura_shell::ActivateWindow(w2.get()); | 84 ash::ActivateWindow(w2.get()); |
| 85 EXPECT_EQ(ws2, workspace_manager()->GetActiveWorkspace()); | 85 EXPECT_EQ(ws2, workspace_manager()->GetActiveWorkspace()); |
| 86 | 86 |
| 87 // The size of contents_view() is now ws1(500) + ws2(500) + margin(50). | 87 // The size of contents_view() is now ws1(500) + ws2(500) + margin(50). |
| 88 EXPECT_EQ("0,0 1050x300", contents_view()->bounds().ToString()); | 88 EXPECT_EQ("0,0 1050x300", contents_view()->bounds().ToString()); |
| 89 EXPECT_FALSE(workspace_manager()->is_overview()); | 89 EXPECT_FALSE(workspace_manager()->is_overview()); |
| 90 workspace_manager()->SetOverview(true); | 90 workspace_manager()->SetOverview(true); |
| 91 EXPECT_TRUE(workspace_manager()->is_overview()); | 91 EXPECT_TRUE(workspace_manager()->is_overview()); |
| 92 | 92 |
| 93 // Switching overview mode doesn't change the active workspace. | 93 // Switching overview mode doesn't change the active workspace. |
| 94 EXPECT_EQ(ws2, workspace_manager()->GetActiveWorkspace()); | 94 EXPECT_EQ(ws2, workspace_manager()->GetActiveWorkspace()); |
| 95 | 95 |
| 96 // Activating window w1 switches the active window and | 96 // Activating window w1 switches the active window and |
| 97 // the mode back to normal mode. | 97 // the mode back to normal mode. |
| 98 aura_shell::ActivateWindow(w1.get()); | 98 ash::ActivateWindow(w1.get()); |
| 99 EXPECT_EQ(ws1, workspace_manager()->GetActiveWorkspace()); | 99 EXPECT_EQ(ws1, workspace_manager()->GetActiveWorkspace()); |
| 100 EXPECT_FALSE(workspace_manager()->is_overview()); | 100 EXPECT_FALSE(workspace_manager()->is_overview()); |
| 101 | 101 |
| 102 // Deleting w1 without StackingClient resets the active workspace | 102 // Deleting w1 without StackingClient resets the active workspace |
| 103 ws1->RemoveWindow(w1.get()); | 103 ws1->RemoveWindow(w1.get()); |
| 104 delete ws1; | 104 delete ws1; |
| 105 w1.reset(); | 105 w1.reset(); |
| 106 EXPECT_EQ(ws2, workspace_manager()->GetActiveWorkspace()); | 106 EXPECT_EQ(ws2, workspace_manager()->GetActiveWorkspace()); |
| 107 EXPECT_EQ("0,0 500x300", contents_view()->bounds().ToString()); | 107 EXPECT_EQ("0,0 500x300", contents_view()->bounds().ToString()); |
| 108 ws2->RemoveWindow(w2.get()); | 108 ws2->RemoveWindow(w2.get()); |
| 109 delete ws2; | 109 delete ws2; |
| 110 // The size of contents_view() for no workspace case must be | 110 // The size of contents_view() for no workspace case must be |
| 111 // same as one contents_view() case. | 111 // same as one contents_view() case. |
| 112 EXPECT_EQ("0,0 500x300", contents_view()->bounds().ToString()); | 112 EXPECT_EQ("0,0 500x300", contents_view()->bounds().ToString()); |
| 113 | 113 |
| 114 // Reset now before windows are destroyed. | 114 // Reset now before windows are destroyed. |
| 115 controller_.reset(); | 115 controller_.reset(); |
| 116 } | 116 } |
| 117 | 117 |
| 118 } // namespace internal | 118 } // namespace internal |
| 119 } // namespace aura_shell | 119 } // namespace ash |
| OLD | NEW |