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

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

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

Powered by Google App Engine
This is Rietveld 408576698