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

Side by Side Diff: ui/aura_shell/workspace_controller_unittest.cc

Issue 8926004: Revert 114095 - Move the concept of Activation to the Shell. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 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 | « ui/aura_shell/workspace_controller.cc ('k') | ui/views/test/views_test_base.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:mergeinfo
OLDNEW
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 "ui/aura_shell/workspace_controller.h" 5 #include "ui/aura_shell/workspace_controller.h"
6 6
7 #include "ui/aura/test/aura_test_base.h" 7 #include "ui/aura/test/aura_test_base.h"
8 #include "ui/aura/test/test_stacking_client.h" 8 #include "ui/aura/test/test_stacking_client.h"
9 #include "ui/aura/window.h" 9 #include "ui/aura/window.h"
10 #include "ui/aura_shell/activation_controller.h"
11 #include "ui/aura_shell/shell_window_ids.h"
12 #include "ui/aura_shell/window_util.h"
13 #include "ui/aura_shell/workspace/workspace.h" 10 #include "ui/aura_shell/workspace/workspace.h"
14 #include "ui/aura_shell/workspace/workspace_manager.h" 11 #include "ui/aura_shell/workspace/workspace_manager.h"
15 12
16 namespace aura_shell { 13 namespace aura_shell {
17 namespace internal { 14 namespace internal {
18 15
19 using aura::Window; 16 using aura::Window;
20 17
21 class WorkspaceControllerTest : public aura::test::AuraTestBase { 18 class WorkspaceControllerTest : public aura::test::AuraTestBase {
22 public: 19 public:
23 WorkspaceControllerTest() {} 20 WorkspaceControllerTest() {}
24 virtual ~WorkspaceControllerTest() {} 21 virtual ~WorkspaceControllerTest() {}
25 22
26 virtual void SetUp() OVERRIDE { 23 virtual void SetUp() OVERRIDE {
27 aura::test::AuraTestBase::SetUp(); 24 aura::test::AuraTestBase::SetUp();
28 contents_view_ = GetTestStackingClient()->default_container(); 25 contents_view_ = GetTestStackingClient()->default_container();
29 // Activatable windows need to be in a container the ActivationController
30 // recognizes.
31 contents_view_->set_id(
32 aura_shell::internal::kShellWindowId_DefaultContainer);
33 activation_controller_.reset(new ActivationController);
34 activation_controller_->set_default_container_for_test(contents_view_);
35 controller_.reset(new WorkspaceController(contents_view_)); 26 controller_.reset(new WorkspaceController(contents_view_));
36 } 27 }
37 28
38 virtual void TearDown() OVERRIDE { 29 virtual void TearDown() OVERRIDE {
39 activation_controller_.reset();
40 controller_.reset(); 30 controller_.reset();
41 aura::test::AuraTestBase::TearDown(); 31 aura::test::AuraTestBase::TearDown();
42 } 32 }
43 33
44 aura::Window* CreateTestWindow() { 34 aura::Window* CreateTestWindow() {
45 aura::Window* window = new aura::Window(NULL); 35 aura::Window* window = new aura::Window(NULL);
46 window->Init(ui::Layer::LAYER_HAS_NO_TEXTURE); 36 window->Init(ui::Layer::LAYER_HAS_NO_TEXTURE);
47 contents_view()->AddChild(window); 37 contents_view()->AddChild(window);
48 window->Show(); 38 window->Show();
49 return window; 39 return window;
50 } 40 }
51 41
52 aura::Window* contents_view() { 42 aura::Window * contents_view() {
53 return contents_view_; 43 return contents_view_;
54 } 44 }
55 45
56 WorkspaceManager* workspace_manager() { 46 WorkspaceManager* workspace_manager() {
57 return controller_->workspace_manager(); 47 return controller_->workspace_manager();
58 } 48 }
59 49
60 scoped_ptr<WorkspaceController> controller_; 50 scoped_ptr<WorkspaceController> controller_;
61 51
62 private: 52 private:
63 aura::Window* contents_view_; 53 aura::Window* contents_view_;
64 54
65 scoped_ptr<ActivationController> activation_controller_;
66
67 DISALLOW_COPY_AND_ASSIGN(WorkspaceControllerTest); 55 DISALLOW_COPY_AND_ASSIGN(WorkspaceControllerTest);
68 }; 56 };
69 57
70 TEST_F(WorkspaceControllerTest, Overview) { 58 TEST_F(WorkspaceControllerTest, Overview) {
71 workspace_manager()->SetWorkspaceSize(gfx::Size(500, 300)); 59 workspace_manager()->SetWorkspaceSize(gfx::Size(500, 300));
72 60
73 // Creating two workspaces, ws1 which contains window w1, 61 // Creating two workspaces, ws1 which contains window w1,
74 // and ws2 which contains window w2. 62 // and ws2 which contains window w2.
75 Workspace* ws1 = workspace_manager()->CreateWorkspace(); 63 Workspace* ws1 = workspace_manager()->CreateWorkspace();
76 scoped_ptr<Window> w1(CreateTestWindow()); 64 scoped_ptr<Window> w1(CreateTestWindow());
77 EXPECT_TRUE(ws1->AddWindowAfter(w1.get(), NULL)); 65 EXPECT_TRUE(ws1->AddWindowAfter(w1.get(), NULL));
78 66
79 Workspace* ws2 = workspace_manager()->CreateWorkspace(); 67 Workspace* ws2 = workspace_manager()->CreateWorkspace();
80 scoped_ptr<Window> w2(CreateTestWindow()); 68 scoped_ptr<Window> w2(CreateTestWindow());
81 EXPECT_TRUE(ws2->AddWindowAfter(w2.get(), NULL)); 69 EXPECT_TRUE(ws2->AddWindowAfter(w2.get(), NULL));
82 70
83 // Activating a window switches the active workspace. 71 // Activating a window switches the active workspace.
84 aura_shell::ActivateWindow(w2.get()); 72 w2->Activate();
85 EXPECT_EQ(ws2, workspace_manager()->GetActiveWorkspace()); 73 EXPECT_EQ(ws2, workspace_manager()->GetActiveWorkspace());
86 74
87 // The size of contents_view() is now ws1(500) + ws2(500) + margin(50). 75 // The size of contents_view() is now ws1(500) + ws2(500) + margin(50).
88 EXPECT_EQ("0,0 1050x300", contents_view()->bounds().ToString()); 76 EXPECT_EQ("0,0 1050x300", contents_view()->bounds().ToString());
89 EXPECT_FALSE(workspace_manager()->is_overview()); 77 EXPECT_FALSE(workspace_manager()->is_overview());
90 workspace_manager()->SetOverview(true); 78 workspace_manager()->SetOverview(true);
91 EXPECT_TRUE(workspace_manager()->is_overview()); 79 EXPECT_TRUE(workspace_manager()->is_overview());
92 80
93 // Switching overview mode doesn't change the active workspace. 81 // Switching overview mode doesn't change the active workspace.
94 EXPECT_EQ(ws2, workspace_manager()->GetActiveWorkspace()); 82 EXPECT_EQ(ws2, workspace_manager()->GetActiveWorkspace());
95 83
96 // Activating window w1 switches the active window and 84 // Activating window w1 switches the active window and
97 // the mode back to normal mode. 85 // the mode back to normal mode.
98 aura_shell::ActivateWindow(w1.get()); 86 w1->Activate();
99 EXPECT_EQ(ws1, workspace_manager()->GetActiveWorkspace()); 87 EXPECT_EQ(ws1, workspace_manager()->GetActiveWorkspace());
100 EXPECT_FALSE(workspace_manager()->is_overview()); 88 EXPECT_FALSE(workspace_manager()->is_overview());
101 89
102 // Deleting w1 without StackingClient resets the active workspace 90 // Deleting w1 without StackingClient resets the active workspace
103 ws1->RemoveWindow(w1.get()); 91 ws1->RemoveWindow(w1.get());
104 delete ws1; 92 delete ws1;
105 w1.reset(); 93 w1.reset();
106 EXPECT_EQ(ws2, workspace_manager()->GetActiveWorkspace()); 94 EXPECT_EQ(ws2, workspace_manager()->GetActiveWorkspace());
107 EXPECT_EQ("0,0 500x300", contents_view()->bounds().ToString()); 95 EXPECT_EQ("0,0 500x300", contents_view()->bounds().ToString());
108 ws2->RemoveWindow(w2.get()); 96 ws2->RemoveWindow(w2.get());
109 delete ws2; 97 delete ws2;
110 // The size of contents_view() for no workspace case must be 98 // The size of contents_view() for no workspace case must be
111 // same as one contents_view() case. 99 // same as one contents_view() case.
112 EXPECT_EQ("0,0 500x300", contents_view()->bounds().ToString()); 100 EXPECT_EQ("0,0 500x300", contents_view()->bounds().ToString());
113 101
114 // Reset now before windows are destroyed. 102 // Reset now before windows are destroyed.
115 controller_.reset(); 103 controller_.reset();
116 } 104 }
117 105
118 } // namespace internal 106 } // namespace internal
119 } // namespace aura_shell 107 } // namespace aura_shell
OLDNEW
« no previous file with comments | « ui/aura_shell/workspace_controller.cc ('k') | ui/views/test/views_test_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698