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

Side by Side Diff: ash/wm/workspace/workspace_layout_manager2_unittest.cc

Issue 11085053: Improving window auto management between workspaces (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Improved the entire window (auto) management Created 8 years, 2 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/workspace_layout_manager.h" 5 #include "ash/wm/workspace/workspace_layout_manager.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/test/ash_test_base.h" 8 #include "ash/test/ash_test_base.h"
9 #include "ash/wm/property_util.h" 9 #include "ash/wm/property_util.h"
10 #include "ash/wm/shelf_layout_manager.h" 10 #include "ash/wm/shelf_layout_manager.h"
11 #include "ash/wm/window_util.h" 11 #include "ash/wm/window_util.h"
12 #include "base/string_number_conversions.h"
12 #include "ui/aura/root_window.h" 13 #include "ui/aura/root_window.h"
13 #include "ui/aura/test/test_windows.h" 14 #include "ui/aura/test/test_windows.h"
14 #include "ui/aura/window.h" 15 #include "ui/aura/window.h"
15 #include "ui/gfx/insets.h" 16 #include "ui/gfx/insets.h"
16 17
17 namespace ash { 18 namespace ash {
18 19
19 namespace { 20 namespace {
20 21
21 class WorkspaceLayoutManager2Test : public test::AshTestBase { 22 class WorkspaceLayoutManager2Test : public test::AshTestBase {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 // If the window is out of the workspace, it would be moved on screen. 128 // If the window is out of the workspace, it would be moved on screen.
128 gfx::Rect root_window_bounds = 129 gfx::Rect root_window_bounds =
129 ash::Shell::GetInstance()->GetPrimaryRootWindow()->bounds(); 130 ash::Shell::GetInstance()->GetPrimaryRootWindow()->bounds();
130 window_bounds.Offset(root_window_bounds.width(), root_window_bounds.height()); 131 window_bounds.Offset(root_window_bounds.width(), root_window_bounds.height());
131 ASSERT_FALSE(window_bounds.Intersects(root_window_bounds)); 132 ASSERT_FALSE(window_bounds.Intersects(root_window_bounds));
132 scoped_ptr<aura::Window> out_window(CreateTestWindow(window_bounds)); 133 scoped_ptr<aura::Window> out_window(CreateTestWindow(window_bounds));
133 EXPECT_EQ(window_bounds.size(), out_window->bounds().size()); 134 EXPECT_EQ(window_bounds.size(), out_window->bounds().size());
134 EXPECT_TRUE(out_window->bounds().Intersects(root_window_bounds)); 135 EXPECT_TRUE(out_window->bounds().Intersects(root_window_bounds));
135 } 136 }
136 137
138 // Test the placement of the last remaining window.
139 TEST_F(WorkspaceLayoutManager2Test, PlaceRemainingWindowsOnDestroy) {
140 // Create a dummy window.
141 scoped_ptr<aura::Window> window1(
142 aura::test::CreateTestWindowWithId(0, NULL));
143 window1->SetBounds(gfx::Rect(16, 32, 640, 320));
144
145 scoped_ptr<aura::Window> window2(
146 aura::test::CreateTestWindowWithId(1, NULL));
147 window2->SetBounds(gfx::Rect(32, 48, 256, 512));
148
149 window1->Show();
150 window2->Show();
151
152 // Check the initial position of the windows.
153 EXPECT_EQ("16,32 640x320", window1->bounds().ToString());
154 EXPECT_EQ("32,48 256x512", window2->bounds().ToString());
155
156 // Get rid of the second window and make sure that the first window is
157 // centered
158 // browser_window2.reset();
159 window2.reset();
160 gfx::Rect work_area = window1->parent()->bounds();
161 //gfx::Screen::GetDisplayMatching(
162 // window1->GetBoundsInScreen()).work_area();
163
164 // Check the initial position of the windows.
165 EXPECT_EQ("16,32 640x320", window1->bounds().ToString());
166
167 // Now mark create a new window and mark both as manageable and try again.
168 ash::wm::SetWindowPositionManageable(window1.get(), true);
169
170 scoped_ptr<aura::Window> window3(
171 aura::test::CreateTestWindowWithId(2, NULL));
172 ash::wm::SetWindowPositionManageable(window3.get(), true);
173 window3->SetBounds(gfx::Rect(32, 48, 256, 512));
174 window3->Show();
175 EXPECT_EQ("16,32 640x320", window1->bounds().ToString());
176 EXPECT_EQ("32,48 256x512", window3->bounds().ToString());
177 window3.reset();
178
179 EXPECT_EQ(
180 base::IntToString((work_area.width() - window1->bounds().width()) / 2) +
181 ",32 640x320", window1->bounds().ToString());
182 }
183
137 } // namespace 184 } // namespace
138 185
139 } // namespace ash 186 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698